Report removal of multiple targets correctly when using -n -c. (Patrick Mezard)
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sun, 2 Oct 2005 22:59:58 +0000 (22:59 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sun, 2 Oct 2005 22:59:58 +0000 (22:59 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@1355 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/engine/SCons/Script/Main.py
test/option-c.py

index 906f31f0c55e675a761c848f74c3a7da46b14d93..fd264e0ac5496d5dd6d9f36f332f599c57b2efe1 100644 (file)
@@ -381,6 +381,9 @@ RELEASE 0.97 - XXX
     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
index a5e07b41c5a5b795bad3bd50332a9e6a5479d1ae..2ffe97bf258fb02fb4aaa708ebda5813da7f2631 100644 (file)
@@ -224,8 +224,10 @@ class CleanTask(SCons.Taskmaster.Task):
 
     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:
index 30ec6f8ebe07c8e6a783304ce7462725bb8ce3d8..fbad75cff1100b8d4dbae8244ae7a6c8b1f3acb4 100644 (file)
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
+"""
+Test various uses of the -c (clean) option.
+"""
+
 import os.path
 import sys
 import TestSCons
@@ -57,6 +61,10 @@ if hasattr(os, 'symlink'):
         # 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")
@@ -67,42 +75,45 @@ test.write('foo3.in', "foo3.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')))
@@ -111,43 +122,54 @@ if hasattr(os, 'symlink'):
 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 = '-c -n ' + args, stdout = expect)
 
-test.run(arguments = '-n -c foo1.out foo2.out foo3.out', stdout = expect)
+test.run(arguments = '-n -c ' + 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.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)
 
@@ -178,15 +200,15 @@ Removed aux1.x
 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
@@ -208,8 +230,8 @@ Removed directory subd
 """ % (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:
@@ -224,7 +246,7 @@ assert not GetOption('clean')
 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')
@@ -237,7 +259,7 @@ assert GetOption('clean')
 """%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')
@@ -246,7 +268,7 @@ env.B(target = 'foo.out', source = 'foo.in')
 """%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')
@@ -259,7 +281,7 @@ assert GetOption('clean')
 """%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()