Fix bug in Clean() functionality. (Steve Leblanc)
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Thu, 16 Jan 2003 10:13:42 +0000 (10:13 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Thu, 16 Jan 2003 10:13:42 +0000 (10:13 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@551 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Script/SConscript.py
test/option-c.py

index fcb08cf668f8763200db9810e42867fbc36fbee9..29338a6732f2743290fa1111efef9eb1437288c3 100644 (file)
@@ -317,19 +317,24 @@ def SetJobs(num):
         raise SCons.Errors.UserError, "A positive integer is required: %s"%repr(num)
     
 def Clean(target, files):
-    target = str(target)
+    if not isinstance(target, SCons.Node.Node):
+        target = SCons.Node.FS.default_fs.Entry(target, create=1)
+
     if not SCons.Util.is_List(files):
         files = [files]
+
     nodes = []
     for f in files:
         if isinstance(f, SCons.Node.Node):
             nodes.append(f)
         else:
             nodes.extend(SCons.Node.arg2nodes(f, SCons.Node.FS.default_fs.Entry))
-    if clean_targets.has_key(target):
-        clean_targets[target].extend(nodes)
+
+    s = str(target)
+    if clean_targets.has_key(s):
+        clean_targets[s].extend(nodes)
     else:
-        clean_targets[target] = nodes
+        clean_targets[s] = nodes
 
 def BuildDefaultGlobals():
     """
index f406574aedd825e487dc62cbf571d1b488968375..15a33f3de100a756eb897f8351e3248adec1ef43 100644 (file)
@@ -152,6 +152,7 @@ test.writable('.', 1)
 
 test.subdir('subd')
 test.write(['subd', 'foon.in'], "foon.in\n")
+test.write(['subd', 'foox.in'], "foox.in\n")
 test.write('aux1.x', "aux1.x\n")
 test.write('aux2.x', "aux2.x\n")
 test.write('SConstruct', """
@@ -161,11 +162,16 @@ env.B(target = 'foo1.out', source = 'foo1.in')
 env.B(target = 'foo2.out', source = 'foo2.xxx')
 env.B(target = 'foo2.xxx', source = 'foo2.in')
 env.B(target = 'foo3.out', source = 'foo3.in')
+SConscript('subd/SConscript')
 Clean('foo2.xxx', ['aux1.x'])
 Clean('foo2.xxx', ['aux2.x'])
 Clean('.', ['subd'])
 """ % python)
 
+test.write(['subd', 'SConscript'], """
+Clean('.', 'foox.in')
+""")
+
 expect = test.wrap_stdout("""Removed foo2.xxx
 Removed aux1.x
 Removed aux2.x
@@ -176,10 +182,16 @@ 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")
 
+expect = test.wrap_stdout("""Removed subd/foox.in
+""")
+test.run(arguments = '-c subd', stdout=expect)
+test.fail_test(os.path.exists(test.workpath('foox.in')))
+
 expect = test.wrap_stdout("""Removed foo1.out
 Removed foo2.out
 Removed foo3.out
 Removed %s
+Removed subd/SConscript
 Removed directory subd
 """ % os.path.join('subd','foon.in'))
 test.run(arguments = '-c .', stdout=expect)