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 Test the --debug=stacktrace option.
32 test
= TestSCons
.TestSCons()
34 test
.write('SConstruct', """\
35 DefaultEnvironment(tools=[])
37 def kfile_scan(node, env, target):
38 raise Exception("kfile_scan error")
40 kscan = Scanner(name='kfile', function=kfile_scan, skeys=['.k'])
41 env = Environment(tools=[])
42 env.Append(SCANNERS = [kscan])
44 env.Command('foo', 'foo.k', Copy('$TARGET', '$SOURCE'))
46 test
.write('foo.k', "foo.k\n")
48 test
.run(status
= 2, stderr
= "scons: *** [foo] Exception : kfile_scan error\n")
49 test
.run(arguments
="--debug=stacktrace", status
=2, stderr
=None)
51 "scons: *** [foo] Exception : kfile_scan error",
52 "scons: internal stack trace:",
53 'raise Exception("kfile_scan error")',
55 test
.must_contain_all_lines(test
.stderr(), lines
)
57 # Test that --debug=stacktrace works for UserError exceptions,
58 # which are handled by different code than other exceptions.
60 test
.write('SConstruct', """\
62 raise SCons.Errors.UserError("explicit UserError!")
65 test
.run(arguments
='--debug=stacktrace', status
=2, stderr
=None)
67 'UserError: explicit UserError!',
68 'scons: *** explicit UserError!',
70 traceback_lines
= ["Traceback (most recent call last)",]
71 test
.must_contain_all_lines(test
.stderr(), user_error_lines
)
72 test
.must_contain_all_lines(test
.stderr(), traceback_lines
)
74 # Test that full path names to SConscript files show up in stack traces.
76 test
.write('SConstruct', """\
80 test
.run(arguments
='--debug=stacktrace', status
=2, stderr
=None)
81 lines
= [' File "%s", line 1:' % test
.workpath('SConstruct'),]
82 test
.must_contain_all_lines(test
.stderr(), lines
)
88 # indent-tabs-mode:nil
90 # vim: set expandtab tabstop=4 shiftwidth=4: