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.
28 test
= TestSCons
.TestSCons(match
= TestSCons
.match_re_dotall
)
30 test
.write('SConstruct', """\
31 def foo(env, target, source):
33 with open(str(target[0]), 'wt') as f:
36 def exit(env, target, source):
37 raise Exception('exit')
39 env = Environment(BUILDERS = { 'foo' : Builder(action=foo),
40 'exit' : Builder(action=exit) })
42 env.foo('foo.out', 'foo.in')
43 env.exit('exit.out', 'exit.in')
46 test
.write('foo.in', 'foo\n')
48 test
.write('exit.in', 'exit\n')
50 # print_exception doesn't always show a source line if the source file
51 # no longer exists or that line in the source file no longer exists,
52 # so make sure the proper variations are supported in the following
54 expect
= r
"""scons: \*\*\* \[exit.out\] Exception : exit
55 Traceback \(most recent call last\):
56 ( File ".+", line \d+, in \S+
58 )*( File ".+", line \d+, in \S+
59 )*( File ".+", line \d+, in \S+
64 # Build foo.out first, and expect an error when we try to build exit.out.
65 test
.run(arguments
='foo.out exit.out', stderr
=expect
, status
=2)
67 # Rebuild. foo.out should be up to date, and we should get the
68 # expected error building exit.out.
69 test
.run(arguments
='foo.out exit.out', stderr
=expect
, status
=2)
71 stdout
= test
.stdout()
73 expect
= "scons: `foo.out' is up to date."
74 test
.must_contain_all_lines(test
.stdout(), [expect
])
80 # indent-tabs-mode:nil
82 # vim: set expandtab tabstop=4 shiftwidth=4: