import sys
import TestSCons
-python = TestSCons.python
+_python_ = TestSCons._python_
try:
import threading
""")
test.write('SConstruct', """
-MyBuild = Builder(action = r'%s build.py $TARGETS')
+MyBuild = Builder(action = r'%(_python_)s build.py $TARGETS')
env = Environment(BUILDERS = { 'MyBuild' : MyBuild })
+env.Tool('install')
env.MyBuild(target = 'f1', source = 'f1.in')
env.MyBuild(target = 'f2', source = 'f2.in')
source='foo/foo.in',
action=copyn)
env.Install('out', t)
-""" % python)
+""" % locals())
def RunTest(args, extra):
"""extra is used to make scons rebuild the output file"""
"""scons: warning: parallel builds are unsupported by this version of Python;
\tignoring -j or num_jobs option.
"""
-test.fail_test(string.find(test.stderr(), warn) == -1)
+test.must_contain_all_lines(test.stderr(), [warn])
str = test.read("f1")
start1,finish1 = map(float, string.split(str, "\n"))
# Test SetJobs() with no -j:
test.write('SConstruct', """
-MyBuild = Builder(action = r'%s build.py $TARGETS')
+MyBuild = Builder(action = r'%(_python_)s build.py $TARGETS')
env = Environment(BUILDERS = { 'MyBuild' : MyBuild })
+env.Tool('install')
env.MyBuild(target = 'f1', source = 'f1.in')
env.MyBuild(target = 'f2', source = 'f2.in')
assert GetOption('num_jobs') == 1
SetOption('num_jobs', 2)
assert GetOption('num_jobs') == 2
-""" % python)
+""" % locals())
# This should be a parallel build because the SConscript sets jobs to 2.
# fail if the second file was not started
# Test SetJobs() with -j:
test.write('SConstruct', """
-MyBuild = Builder(action = r'%s build.py $TARGETS')
+MyBuild = Builder(action = r'%(_python_)s build.py $TARGETS')
env = Environment(BUILDERS = { 'MyBuild' : MyBuild })
+env.Tool('install')
env.MyBuild(target = 'f1', source = 'f1.in')
env.MyBuild(target = 'f2', source = 'f2.in')
assert GetOption('num_jobs') == 1
SetOption('num_jobs', 2)
assert GetOption('num_jobs') == 1
-""" % python)
+""" % locals())
# This should be a serial build since -j 1 overrides the call to SetJobs().
# fail if the second file was started
test.fail_test(start2 < finish1)
-# Test that a failed build with -j works properly.
-
-test.write('mycopy.py', r"""\
-import sys
-import time
-time.sleep(1)
-open(sys.argv[1], 'wb').write(open(sys.argv[2], 'rb').read())
-""")
-
-test.write('myfail.py', r"""\
-import sys
-sys.exit(1)
-""")
-
-test.write('SConstruct', """
-MyCopy = Builder(action = r'%s mycopy.py $TARGET $SOURCE')
-Fail = Builder(action = r'%s myfail.py $TARGETS $SOURCE')
-env = Environment(BUILDERS = { 'MyCopy' : MyCopy, 'Fail' : Fail })
-env.Fail(target = 'f3', source = 'f3.in')
-env.MyCopy(target = 'f4', source = 'f4.in')
-env.MyCopy(target = 'f5', source = 'f5.in')
-env.MyCopy(target = 'f6', source = 'f6.in')
-""" % (python, python))
-
-test.write('f3.in', "f3.in\n")
-test.write('f4.in', "f4.in\n")
-test.write('f5.in', "f5.in\n")
-test.write('f6.in', "f6.in\n")
-
-test.run(arguments = '-j 2 .',
- status = 2,
- stderr = "scons: *** [f3] Error 1\n")
-
-test.fail_test(os.path.exists(test.workpath('f3')))
-test.fail_test(test.read(test.workpath('f4')) != 'f4.in\n')
-test.fail_test(os.path.exists(test.workpath('f5')))
-test.fail_test(os.path.exists(test.workpath('f6')))
test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4: