5 # Copyright The SCons Foundation
7 # Permission is hereby granted, free of charge, to any person obtaining
8 # a copy of this software and associated documentation files (the
9 # "Software"), to deal in the Software without restriction, including
10 # without limitation the rights to use, copy, modify, merge, publish,
11 # distribute, sublicense, and/or sell copies of the Software, and to
12 # permit persons to whom the Software is furnished to do so, subject to
13 # the following conditions:
15 # The above copyright notice and this permission notice shall be included
16 # in all copies or substantial portions of the Software.
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 Verify that a failed build action with -k works as expected.
32 _python_
= TestSCons
._python
_
37 # if threads are not supported, then
38 # there is nothing to test
43 test
= TestSCons
.TestSCons()
47 if 'mypass.py' in sys.argv[0]:
48 with open(sys.argv[3], 'wb') as ofp, open(sys.argv[4], 'rb') as ifp:
51 elif 'myfail.py' in sys.argv[0]:
56 test
.write('mypass.py', contents
)
57 test
.write('myfail.py', contents
)
59 test
.write('SConstruct', """\
60 DefaultEnvironment(tools=[])
61 Command('f3', 'f3.in', r'@%(_python_)s mypass.py - f3 $TARGET $SOURCE')
62 Command('f4', 'f4.in', r'@%(_python_)s myfail.py f3 f4 $TARGET $SOURCE')
63 Command('f5', 'f5.in', r'@%(_python_)s myfail.py f4 f5 $TARGET $SOURCE')
64 Command('f6', 'f6.in', r'@%(_python_)s mypass.py f5 - $TARGET $SOURCE')
66 def print_build_failures():
67 from SCons.Script import GetBuildFailures
68 for bf in sorted(GetBuildFailures(), key=lambda a: a.filename or 'None'):
69 print("%%s failed: %%s" %% (bf.node, bf.errstr))
72 atexit.register(print_build_failures)
75 test
.write('f3.in', "f3.in\n")
76 test
.write('f4.in', "f4.in\n")
77 test
.write('f5.in', "f5.in\n")
78 test
.write('f6.in', "f6.in\n")
81 scons: Reading SConscript files ...
82 scons: done reading SConscript files.
83 scons: Building targets ...
84 scons: done building targets (errors occurred during build).
90 scons: *** [f4] Error 1
91 scons: *** [f5] Error 1
94 test
.run(arguments
= '-k .', status
= 2, stdout
=None, stderr
=None)
95 test
.must_contain_exactly_lines(test
.stdout(), expect_stdout
, title
='stdout')
96 test
.must_contain_exactly_lines(test
.stderr(), expect_stderr
, title
='stderr')
98 test
.must_match(test
.workpath('f3'), 'f3.in\n')
99 test
.must_not_exist(test
.workpath('f4'))
100 test
.must_not_exist(test
.workpath('f5'))
101 test
.must_match(test
.workpath('f6'), 'f6.in\n')
108 # indent-tabs-mode:nil
110 # vim: set expandtab tabstop=4 shiftwidth=4: