Add emacs and vim editing settings to the bottom of *.py files.
[scons.git] / test / option-j.py
index fdf7b8392b5d39b26461c5dccb43676e5bbdcf77..316340e54b7d9bc150cdaed47c0bb6c85e9cde0d 100644 (file)
@@ -34,7 +34,7 @@ import string
 import sys
 import TestSCons
 
-python = TestSCons.python
+_python_ = TestSCons._python_
 
 try:
     import threading
@@ -64,8 +64,9 @@ foo you
 """)
 
 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')
 
@@ -80,7 +81,7 @@ t = env.Command(target=['foo/foo1.out', 'foo/foo2.out'],
                 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"""
@@ -145,7 +146,7 @@ warn = \
 """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"))
@@ -160,8 +161,9 @@ os.environ['PYTHONPATH'] = save_pythonpath
 
 # 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')
 
@@ -178,7 +180,7 @@ env.Install('out', t)
 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
@@ -188,8 +190,9 @@ test.fail_test(not (start2 < finish1))
 
 # 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')
 
@@ -206,7 +209,7 @@ env.Install('out', t)
 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
@@ -215,42 +218,11 @@ start2, finish1 = RunTest('-j 1 f1 f2', "fourth")
 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: