updated copyright and added csv results output to bench.py
[scons.git] / test / Errors / non-executable-file.py
blob0363ab7d4b6c97a08545c949fc0ab3ff048ab45a
1 #!/usr/bin/env python
3 # __COPYRIGHT__
5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
27 import os
29 import TestSCons
31 test = TestSCons.TestSCons()
33 not_executable = test.workpath("not_executable")
35 test.write(not_executable, "\n")
37 test.write("f1.in", "\n")
39 bad_command = """\
40 Bad command or file name
41 """
43 unrecognized = """\
44 '.+' is not recognized as an internal or external command,
45 operable program or batch file.
46 scons: \\*\\*\\* \\[%s\\] Error 1
47 """
49 unspecified = """\
50 The name specified is not recognized as an
51 internal or external command, operable program or batch file.
52 scons: \\*\\*\\* \\[%s\\] Error 1
53 """
55 cannot_execute = """\
56 (sh: )*.+: cannot execute(( -)? \\[?Permission denied\\]?)?
57 scons: \\*\\*\\* \\[%s\\] Error %s
58 """
60 permission_denied = """\
61 .+: (p|P)ermission denied
62 scons: \\*\\*\\* \\[%s\\] Error %s
63 """
65 konnte_nicht_gefunden_werden = """\
66 Der Befehl ".+" ist entweder falsch geschrieben oder
67 konnte nicht gefunden werden.
68 scons: \\*\\*\\* \\[%s\\] Error %s
69 """
71 test.write('SConstruct', r"""
72 bld = Builder(action = '%s $SOURCES $TARGET')
73 env = Environment(BUILDERS = { 'bld': bld })
74 env.bld(target = 'f1', source = 'f1.in')
75 """ % not_executable.replace('\\', '\\\\'))
77 test.run(arguments='.',
78 stdout = test.wrap_stdout("%s f1.in f1\n" % not_executable, error=1),
79 stderr = None,
80 status = 2)
82 test.description_set("Incorrect STDERR:\n%s\n" % test.stderr())
83 if os.name == 'nt':
84 errs = [
85 bad_command,
86 unrecognized % 'f1',
87 konnte_nicht_gefunden_werden % ('f1', 1),
88 unspecified % 'f1'
90 else:
91 errs = [
92 cannot_execute % ('f1', 126),
93 permission_denied % ('f1', 126),
96 test.must_contain_any_line(test.stderr(), errs, find=TestSCons.search_re)
98 test.pass_test()
100 # Local Variables:
101 # tab-width:4
102 # indent-tabs-mode:nil
103 # End:
104 # vim: set expandtab tabstop=4 shiftwidth=4: