summaryrefslogtreecommitdiffstats
path: root/test/GetBuildFailures/option-k.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/GetBuildFailures/option-k.py')
-rw-r--r--test/GetBuildFailures/option-k.py112
1 files changed, 112 insertions, 0 deletions
diff --git a/test/GetBuildFailures/option-k.py b/test/GetBuildFailures/option-k.py
new file mode 100644
index 0000000..5246f31
--- /dev/null
+++ b/test/GetBuildFailures/option-k.py
@@ -0,0 +1,112 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+"""
+Verify that a failed build action with -j works as expected.
+"""
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import TestSCons
+
+_python_ = TestSCons._python_
+
+try:
+ import threading
+except ImportError:
+ # if threads are not supported, then
+ # there is nothing to test
+ TestCmd.no_result()
+ sys.exit()
+
+
+test = TestSCons.TestSCons()
+
+contents = r"""\
+import sys
+if sys.argv[0] == 'mypass.py':
+ open(sys.argv[3], 'wb').write(open(sys.argv[4], 'rb').read())
+ exit_value = 0
+elif sys.argv[0] == 'myfail.py':
+ exit_value = 1
+sys.exit(exit_value)
+"""
+
+test.write('mypass.py', contents)
+test.write('myfail.py', contents)
+
+test.write('SConstruct', """\
+Command('f3', 'f3.in', r'@%(_python_)s mypass.py - f3 $TARGET $SOURCE')
+Command('f4', 'f4.in', r'@%(_python_)s myfail.py f3 f4 $TARGET $SOURCE')
+Command('f5', 'f5.in', r'@%(_python_)s myfail.py f4 f5 $TARGET $SOURCE')
+Command('f6', 'f6.in', r'@%(_python_)s mypass.py f5 - $TARGET $SOURCE')
+
+def print_build_failures():
+ from SCons.Script import GetBuildFailures
+ bf_list = GetBuildFailures()
+ bf_list.sort(lambda a,b: cmp(a.filename, b.filename))
+ for bf in bf_list:
+ print "%%s failed: %%s" %% (bf.node, bf.errstr)
+
+try:
+ import atexit
+except ImportError:
+ import sys
+ sys.exitfunc = print_build_failures
+else:
+ atexit.register(print_build_failures)
+""" % locals())
+
+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")
+
+expect_stdout = """\
+scons: Reading SConscript files ...
+scons: done reading SConscript files.
+scons: Building targets ...
+scons: done building targets (errors occurred during build).
+f4 failed: Error 1
+f5 failed: Error 1
+""" % locals()
+
+expect_stderr = """\
+scons: *** [f4] Error 1
+scons: *** [f5] Error 1
+"""
+
+test.run(arguments = '-k .',
+ status = 2,
+ stdout = expect_stdout,
+ stderr = expect_stderr)
+
+test.must_match(test.workpath('f3'), 'f3.in\n')
+test.must_not_exist(test.workpath('f4'))
+test.must_not_exist(test.workpath('f5'))
+test.must_match(test.workpath('f6'), 'f6.in\n')
+
+
+
+test.pass_test()