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 writing XML output to a file.
36 test
= TestRuntest
.TestRuntest(match
=TestCmd
.match_re
, diff
=TestCmd
.diff_re
)
38 pythonstring
= re
.escape(TestRuntest
.pythonstring
)
39 pythonflags
= TestRuntest
.pythonflags
40 test_fail_py
= re
.escape(os
.path
.join('test', 'fail.py'))
41 test_no_result_py
= re
.escape(os
.path
.join('test', 'no_result.py'))
42 test_pass_py
= re
.escape(os
.path
.join('test', 'pass.py'))
45 test
.write_fake_scons_source_tree()
46 test
.write_failing_test(['test', 'fail.py'])
47 test
.write_no_result_test(['test', 'no_result.py'])
48 test
.write_passing_test(['test', 'pass.py'])
50 test
.run(arguments
='--xml xml.out test', status
=1)
55 <file_name>{test_fail_py}</file_name>
56 <command_line>{pythonstring}{pythonflags} {test_fail_py}</command_line>
57 <exit_status>1</exit_status>
58 <stdout>FAILING TEST STDOUT
60 <stderr>FAILING TEST STDERR
62 <time>\\d+\\.\\d</time>
65 <file_name>{test_no_result_py}</file_name>
66 <command_line>{pythonstring}{pythonflags} {test_no_result_py}</command_line>
67 <exit_status>2</exit_status>
68 <stdout>NO RESULT TEST STDOUT
70 <stderr>NO RESULT TEST STDERR
72 <time>\\d+\\.\\d</time>
75 <file_name>{test_pass_py}</file_name>
76 <command_line>{pythonstring}{pythonflags} {test_pass_py}</command_line>
77 <exit_status>0</exit_status>
78 <stdout>PASSING TEST STDOUT
80 <stderr>PASSING TEST STDERR
82 <time>\\d+\\.\\d</time>
84 <time>\\d+\\.\\d</time>
88 # Just strip carriage returns so the regular expression matching works.
89 contents
= test
.read('xml.out')
90 contents
= contents
.replace(b
'\r', b
'')
91 test
.write('xml.out', contents
)
93 test
.must_match('xml.out', expect
)
99 # indent-tabs-mode:nil
101 # vim: set expandtab tabstop=4 shiftwidth=4: