From: stevenknight Date: Sun, 31 Mar 2002 06:03:14 +0000 (+0000) Subject: Make -c work with -n: don't remove the files! X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3785be621ace6d15227ded2764d2e15e7ff9f10d;p=scons.git Make -c work with -n: don't remove the files! git-svn-id: http://scons.tigris.org/svn/scons/trunk@316 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/CHANGES.txt b/src/CHANGES.txt index c78106bf..0fc473cd 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -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: diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py index 6866e35f..bd4f2ae8 100644 --- a/src/engine/SCons/Script/__init__.py +++ b/src/engine/SCons/Script/__init__.py @@ -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'], diff --git a/test/option-c.py b/test/option-c.py index c93a4d39..1a240de2 100644 --- a/test/option-c.py +++ b/test/option-c.py @@ -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() diff --git a/test/option-n.py b/test/option-n.py index f0f6e115..f436dd25 100644 --- a/test/option-n.py +++ b/test/option-n.py @@ -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()