return None
return env.Detect([prog])
- def wrap_stdout(self, build_str = "", read_str = "", error = 0):
+ def wrap_stdout(self, build_str = "", read_str = "", error = 0, cleaning = 0):
"""Wraps standard output string(s) in the normal
"Reading ... done" and "Building ... done" strings
"""
+ cap,lc = [ ('Build','build'),
+ ('Clean','clean') ][cleaning]
if error:
- term = "scons: building terminated because of errors.\n"
+ term = "scons: %sing terminated because of errors.\n" % lc
else:
- term = "scons: done building targets.\n"
+ term = "scons: done %sing targets.\n" % lc
return "scons: Reading SConscript files ...\n" + \
read_str + \
"scons: done reading SConscript files.\n" + \
- "scons: Building targets ...\n" + \
+ "scons: %sing targets ...\n" % cap + \
build_str + \
term
test.fail_test(test.read(test.workpath('foo2.out')) != "foo2.in\n")
test.fail_test(test.read(test.workpath('foo3.out')) != "foo3.in\n")
-def wrap_clean_stdout(string):
- return "scons: Reading SConscript files ...\n" + \
- "scons: done reading SConscript files.\n" + \
- "scons: Cleaning targets ...\n" + \
- string + \
- "scons: done cleaning targets.\n"
-
test.run(arguments = '-c foo1.out',
- stdout = wrap_clean_stdout("Removed foo1.out\n"))
+ 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('foo3.out')))
test.run(arguments = '--clean foo2.out foo2.xxx',
- stdout = wrap_clean_stdout("Removed foo2.xxx\nRemoved foo2.out\n"))
+ 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(not os.path.exists(test.workpath('foo3.out')))
test.run(arguments = '--remove foo3.out',
- stdout = wrap_clean_stdout("Removed foo3.out\n"))
+ 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(not os.path.islink(test.workpath('symlink2')))
test.run(arguments = '-c foo2.xxx',
- stdout = wrap_clean_stdout("Removed foo2.xxx\n"))
+ 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.run(arguments = 'foo1.out foo2.out foo3.out')
-expect = wrap_clean_stdout("""Removed foo1.out
+expect = test.wrap_stdout("""Removed foo1.out
Removed foo2.xxx
Removed foo2.out
Removed foo3.out
-""")
+""", cleaning=1)
test.run(arguments = '-c -n foo1.out foo2.out foo3.out', stdout = expect)
test.writable('.', 0)
f = open(test.workpath('foo1.out'))
test.run(arguments = '-c foo1.out',
- stdout = wrap_clean_stdout("scons: Could not remove 'foo1.out': Permission denied\n"))
+ 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')))
f.close()
test.writable('.', 1)
Clean('.', 'foox.in')
""")
-expect = wrap_clean_stdout("""Removed foo2.xxx
+expect = test.wrap_stdout("""Removed foo2.xxx
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")
-expect = wrap_clean_stdout("Removed %s\n" % os.path.join('subd', 'foox.in'))
+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')))
-expect = wrap_clean_stdout("""Removed foo1.out
+expect = test.wrap_stdout("""Removed foo1.out
Removed foo2.xxx
Removed foo2.out
Removed foo3.out
Removed %s
Removed %s
Removed directory subd
-""" % (os.path.join('subd','SConscript'), os.path.join('subd', 'foon.in')))
+""" % (os.path.join('subd','SConscript'), os.path.join('subd', 'foon.in')),
+ cleaning = 1)
test.run(arguments = '-c -n .', stdout=expect)
-expect = wrap_clean_stdout("""Removed foo1.out
+expect = test.wrap_stdout("""Removed foo1.out
Removed foo2.out
Removed foo3.out
Removed %s
Removed %s
Removed directory subd
-""" % (os.path.join('subd','SConscript'), os.path.join('subd', 'foon.in')))
+""" % (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')))