Make -c work with -n: don't remove the files!
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sun, 31 Mar 2002 06:03:14 +0000 (06:03 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sun, 31 Mar 2002 06:03:14 +0000 (06:03 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@316 fdb21ef1-2011-0410-befe-b5e4ea1792b1

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

index c78106bf22ee5e1c74d4ddb30fa538bdd1ef081c..0fc473cdfb220aa4d668a1e5316c786973e98a0c 100644 (file)
@@ -8,6 +8,14 @@
 
 
 
+RELEASE 0.07 - 
+
+  From Steven Knight:
+
+  - Fix so that -c -n does *not* remove the targets!
+
+
+
 RELEASE 0.06 - Thu, 28 Mar 2002 01:24:29 -0600
 
   From Charles Crain:
index 6866e35f5281fb579863b1f866425bbf20264049..bd4f2ae853d7010d50f4696b9d91dc2534182702 100644 (file)
@@ -103,7 +103,11 @@ class BuildTask(SCons.Taskmaster.Task):
 
 class CleanTask(SCons.Taskmaster.Task):
     """An SCons clean task."""
-    def execute(self):
+    def show(self):
+        if self.targets[0].builder:
+            print "Removed " + self.targets[0].path
+
+    def remove(self):
         if self.targets[0].builder:
             try:
                 os.unlink(self.targets[0].path)
@@ -120,6 +124,8 @@ class CleanTask(SCons.Taskmaster.Task):
             except IndexError:
                 pass
 
+    execute = remove
+
 class QuestionTask(SCons.Taskmaster.Task):
     """An SCons task for the -q (question) option."""
     def execute(self):
@@ -494,6 +500,7 @@ def options_init():
 
     def opt_n(opt, arg):
        SCons.Action.execute_actions = None
+       CleanTask.execute = CleanTask.show
 
     Option(func = opt_n,
        short = 'n', long = ['no-exec', 'just-print', 'dry-run', 'recon'],
index c93a4d39eacbf682092b193407e1fa6f84a3f141..1a240de226c85ac1436094ca477b5e519e5f2256 100644 (file)
@@ -104,5 +104,22 @@ 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.run(arguments = 'foo1.out foo2.out foo3.out')
+
+expect = """Removed foo1.out
+Removed foo2.xxx
+Removed foo2.out
+Removed foo3.out
+"""
+
+test.run(arguments = '-c -n foo1.out foo2.out foo3.out', stdout = expect)
+
+test.run(arguments = '-n -c foo1.out foo2.out foo3.out', 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.pass_test()
  
index f0f6e11562bca9951a01eff63cc47f8c4e30b1de..f436dd255a41bddb4688f437e9e59f139f55ccbb 100644 (file)
@@ -81,5 +81,18 @@ test.run(arguments = '--recon ' + args, stdout = expect)
 test.fail_test(os.path.exists(test.workpath('f1.out')))
 test.fail_test(os.path.exists(test.workpath('f2.out')))
 
+test.run(arguments = args)
+test.fail_test(not os.path.exists(test.workpath('f1.out')))
+test.fail_test(not os.path.exists(test.workpath('f2.out')))
+
+expect = "Removed f1.out\nRemoved f2.out\n"
+
+test.run(arguments = '-n -c ' + args, stdout = expect)
+
+test.run(arguments = '-c -n ' + args, stdout = expect)
+
+test.fail_test(not os.path.exists(test.workpath('f1.out')))
+test.fail_test(not os.path.exists(test.workpath('f2.out')))
+
 test.pass_test()