Commits

Anonymous committed b6c1538

Report removal of multiple targets correctly when using -n -c. (Patrick Mezard)

Comments (0)

Files changed (3)

     files built along with the target is out of date or non-existent,
     not just if the command-line target itself is out of date.
 
+  - Fix the -n option when used with -c to print all of the targets
+    that will be removed for a multi-target Builder call.
+
   From Georg Mischler:
 
   - Remove the space after the -o option when invoking the Borland

src/engine/SCons/Script/Main.py

 
     def show(self):
         target = self.targets[0]
-        if (target.has_builder() or target.side_effect) and not target.isdir():
-            display("Removed " + str(target))
+        if target.has_builder() or target.side_effect:
+            for t in self.targets:
+                if not t.isdir():
+                    display("Removed " + str(t))
         if SCons.Environment.CleanTargets.has_key(target):
             files = SCons.Environment.CleanTargets[target]
             for f in files:
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
+"""
+Test various uses of the -c (clean) option.
+"""
+
 import os.path
 import sys
 import TestSCons
         # force symlink to a file that doesn't exist
         os.symlink('does_not_exist', str(target[0]))
     env.Command(target = 'symlink2', source = 'foo1.in', action = symlink2)
+# Test handling of Builder calls that have multiple targets.
+env.Command(['touch1.out', 'touch2.out'],
+            [],
+            [Touch('${TARGETS[0]}'), Touch('${TARGETS[1]}')])
 """ % python)
 
 test.write('foo1.in', "foo1.in\n")
 
 test.run(arguments = 'foo1.out foo2.out foo3.out')
 
-test.fail_test(test.read(test.workpath('foo1.out')) != "foo1.in\n")
-test.fail_test(test.read(test.workpath('foo2.xxx')) != "foo2.in\n")
-test.fail_test(test.read(test.workpath('foo2.out')) != "foo2.in\n")
-test.fail_test(test.read(test.workpath('foo3.out')) != "foo3.in\n")
+test.must_match(test.workpath('foo1.out'), "foo1.in\n")
+test.must_match(test.workpath('foo2.xxx'), "foo2.in\n")
+test.must_match(test.workpath('foo2.out'), "foo2.in\n")
+test.must_match(test.workpath('foo3.out'), "foo3.in\n")
 
 test.run(arguments = '-c foo1.out',
          stdout = test.wrap_stdout("Removed foo1.out\n", cleaning=1))
 
-test.fail_test(os.path.exists(test.workpath('foo1.out')))
-test.fail_test(not os.path.exists(test.workpath('foo2.xxx')))
-test.fail_test(not os.path.exists(test.workpath('foo2.out')))
-test.fail_test(not os.path.exists(test.workpath('foo3.out')))
+test.must_not_exist(test.workpath('foo1.out'))
+test.must_exist(test.workpath('foo2.xxx'))
+test.must_exist(test.workpath('foo2.out'))
+test.must_exist(test.workpath('foo3.out'))
 
 test.run(arguments = '--clean foo2.out foo2.xxx',
          stdout = test.wrap_stdout("Removed foo2.xxx\nRemoved foo2.out\n",
                                    cleaning=1))
 
-test.fail_test(os.path.exists(test.workpath('foo1.out')))
-test.fail_test(os.path.exists(test.workpath('foo2.xxx')))
-test.fail_test(os.path.exists(test.workpath('foo2.out')))
-test.fail_test(not os.path.exists(test.workpath('foo3.out')))
+test.must_not_exist(test.workpath('foo1.out'))
+test.must_not_exist(test.workpath('foo2.xxx'))
+test.must_not_exist(test.workpath('foo2.out'))
+test.must_exist(test.workpath('foo3.out'))
 
 test.run(arguments = '--remove foo3.out',
          stdout = test.wrap_stdout("Removed foo3.out\n", cleaning=1))
 
-test.fail_test(os.path.exists(test.workpath('foo1.out')))
-test.fail_test(os.path.exists(test.workpath('foo2.xxx')))
-test.fail_test(os.path.exists(test.workpath('foo2.out')))
-test.fail_test(os.path.exists(test.workpath('foo3.out')))
+test.must_not_exist(test.workpath('foo1.out'))
+test.must_not_exist(test.workpath('foo2.xxx'))
+test.must_not_exist(test.workpath('foo2.out'))
+test.must_not_exist(test.workpath('foo3.out'))
 
 test.run(arguments = '.')
 
-test.fail_test(test.read(test.workpath('foo1.out')) != "foo1.in\n")
-test.fail_test(test.read(test.workpath('foo2.xxx')) != "foo2.in\n")
-test.fail_test(test.read(test.workpath('foo2.out')) != "foo2.in\n")
-test.fail_test(test.read(test.workpath('foo3.out')) != "foo3.in\n")
+test.must_match(test.workpath('foo1.out'), "foo1.in\n")
+test.must_match(test.workpath('foo2.xxx'), "foo2.in\n")
+test.must_match(test.workpath('foo2.out'), "foo2.in\n")
+test.must_match(test.workpath('foo3.out'), "foo3.in\n")
+test.must_match(test.workpath('foo3.out'), "foo3.in\n")
+test.must_exist(test.workpath('touch1.out'))
+test.must_exist(test.workpath('touch2.out'))
 
 if hasattr(os, 'symlink'):
     test.fail_test(not os.path.islink(test.workpath('symlink1')))
 test.run(arguments = '-c foo2.xxx',
          stdout = test.wrap_stdout("Removed foo2.xxx\n", cleaning=1))
 
-test.fail_test(test.read(test.workpath('foo1.out')) != "foo1.in\n")
-test.fail_test(os.path.exists(test.workpath('foo2.xxx')))
-test.fail_test(test.read(test.workpath('foo2.out')) != "foo2.in\n")
-test.fail_test(test.read(test.workpath('foo3.out')) != "foo3.in\n")
+test.must_match(test.workpath('foo1.out'), "foo1.in\n")
+test.must_not_exist(test.workpath('foo2.xxx'))
+test.must_match(test.workpath('foo2.out'), "foo2.in\n")
+test.must_match(test.workpath('foo3.out'), "foo3.in\n")
+test.must_exist(test.workpath('touch1.out'))
+test.must_exist(test.workpath('touch2.out'))
 
 test.run(arguments = '-c .')
 
-test.fail_test(os.path.exists(test.workpath('foo1.out')))
-test.fail_test(os.path.exists(test.workpath('foo2.out')))
-test.fail_test(os.path.exists(test.workpath('foo3.out')))
+test.must_not_exist(test.workpath('foo1.out'))
+test.must_not_exist(test.workpath('foo2.out'))
+test.must_not_exist(test.workpath('foo3.out'))
+test.must_not_exist(test.workpath('touch1.out'))
+test.must_not_exist(test.workpath('touch2.out'))
 
 if hasattr(os, 'symlink'):
     test.fail_test(os.path.islink(test.workpath('symlink1')))
     test.fail_test(os.path.islink(test.workpath('symlink2')))
 
-test.run(arguments = 'foo1.out foo2.out foo3.out')
+args = 'foo1.out foo2.out foo3.out touch1.out'
 
-expect = test.wrap_stdout("""Removed foo1.out
+expect = test.wrap_stdout("""\
+Removed foo1.out
 Removed foo2.xxx
 Removed foo2.out
 Removed foo3.out
+Removed touch1.out
+Removed touch2.out
 """, cleaning=1)
 
-test.run(arguments = '-c -n foo1.out foo2.out foo3.out', stdout = expect)
+test.run(arguments = args)
 
-test.run(arguments = '-n -c foo1.out foo2.out foo3.out', stdout = expect)
+test.run(arguments = '-c -n ' + args, stdout = expect)
 
-test.fail_test(test.read(test.workpath('foo1.out')) != "foo1.in\n")
-test.fail_test(test.read(test.workpath('foo2.xxx')) != "foo2.in\n")
-test.fail_test(test.read(test.workpath('foo2.out')) != "foo2.in\n")
-test.fail_test(test.read(test.workpath('foo3.out')) != "foo3.in\n")
+test.run(arguments = '-n -c ' + args, stdout = expect)
+
+test.must_match(test.workpath('foo1.out'), "foo1.in\n")
+test.must_match(test.workpath('foo2.xxx'), "foo2.in\n")
+test.must_match(test.workpath('foo2.out'), "foo2.in\n")
+test.must_match(test.workpath('foo3.out'), "foo3.in\n")
+test.must_exist(test.workpath('touch1.out'))
+test.must_exist(test.workpath('touch2.out'))
 
 test.writable('.', 0)
 f = open(test.workpath('foo1.out'))
 test.run(arguments = '-c foo1.out',
          stdout = test.wrap_stdout("scons: Could not remove 'foo1.out': Permission denied\n", cleaning=1))
-test.fail_test(not os.path.exists(test.workpath('foo1.out')))
+test.must_exist(test.workpath('foo1.out'))
 f.close()
 test.writable('.', 1)
 
 Removed aux2.x
 """, cleaning=1)
 test.run(arguments = '-c foo2.xxx', stdout=expect)
-test.fail_test(test.read(test.workpath('foo1.out')) != "foo1.in\n")
-test.fail_test(os.path.exists(test.workpath('foo2.xxx')))
-test.fail_test(test.read(test.workpath('foo2.out')) != "foo2.in\n")
-test.fail_test(test.read(test.workpath('foo3.out')) != "foo3.in\n")
+test.must_match(test.workpath('foo1.out'), "foo1.in\n")
+test.must_not_exist(test.workpath('foo2.xxx'))
+test.must_match(test.workpath('foo2.out'), "foo2.in\n")
+test.must_match(test.workpath('foo3.out'), "foo3.in\n")
 
 expect = test.wrap_stdout("Removed %s\n" % os.path.join('subd', 'foox.in'),
                           cleaning = 1)
 test.run(arguments = '-c subd', stdout=expect)
-test.fail_test(os.path.exists(test.workpath('foox.in')))
+test.must_not_exist(test.workpath('foox.in'))
 
 expect = test.wrap_stdout("""Removed foo1.out
 Removed foo2.xxx
 """ % (os.path.join('subd','SConscript'), os.path.join('subd', 'foon.in')),
                           cleaning = 1)
 test.run(arguments = '-c .', stdout=expect)
-test.fail_test(os.path.exists(test.workpath('subdir', 'foon.in')))
-test.fail_test(os.path.exists(test.workpath('subdir')))
+test.must_not_exist(test.workpath('subdir', 'foon.in'))
+test.must_not_exist(test.workpath('subdir'))
 
 
 # Ensure that Set/GetOption('clean') works correctly:
 test.write('foo.in', '"Foo", I say!\n')
 
 test.run(arguments='foo.out')
-test.fail_test(test.read(test.workpath('foo.out')) != '"Foo", I say!\n')
+test.must_match(test.workpath('foo.out'), '"Foo", I say!\n')
 
 test.write('SConstruct', """
 B = Builder(action = r'%s build.py $TARGETS $SOURCES')
 """%python)
 
 test.run(arguments='-c foo.out')
-test.fail_test(os.path.exists(test.workpath('foo.out')))
+test.must_not_exist(test.workpath('foo.out'))
 
 test.write('SConstruct', """
 B = Builder(action = r'%s build.py $TARGETS $SOURCES')
 """%python)
 
 test.run(arguments='foo.out')
-test.fail_test(test.read(test.workpath('foo.out')) != '"Foo", I say!\n')
+test.must_match(test.workpath('foo.out'), '"Foo", I say!\n')
 
 test.write('SConstruct', """
 B = Builder(action = r'%s build.py $TARGETS $SOURCES')
 """%python)
 
 test.run(arguments='foo.out')
-test.fail_test(os.path.exists(test.workpath('foo.out')))
+test.must_not_exist(test.workpath('foo.out'))
 
 test.pass_test()