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__"
28 Test the explicit Exit() function.
35 test = TestSCons.TestSCons()
39 subdir_foo_in = os.path.join('subdir', 'foo.in')
40 subdir_foo_out = os.path.join('subdir', 'foo.out')
42 test.write('SConstruct', """\
43 print "SConstruct, Exit()"
47 test.run(stdout = """\
48 scons: Reading SConscript files ...
52 test.write('SConstruct', """\
54 print "SConstruct, env.Exit()"
58 test.run(stdout = """\
59 scons: Reading SConscript files ...
60 SConstruct, env.Exit()
63 test.write('SConstruct', """\
68 test.run(status = 7, stdout = """\
69 scons: Reading SConscript files ...
73 test.write('SConstruct', """\
75 SConscript('subdir/SConscript')
78 test.write(['subdir', 'SConscript'], """\
79 print "subdir/SConscript"
83 test.run(stdout = """\
84 scons: Reading SConscript files ...
89 test.write(['subdir', 'SConscript'], """\
90 print "subdir/SConscript"
94 test.run(status = 17, stdout = """\
95 scons: Reading SConscript files ...
100 test.write('SConstruct', """\
101 SConscript('subdir/SConscript')
104 test.write(['subdir', 'SConscript'], """\
105 def exit_builder(env, source, target):
106 target = str(target[0])
107 source = map(str, source)
108 f = open(target, "wb")
110 f.write(open(src, "rb").read())
113 env = Environment(BUILDERS = {'my_exit' : Builder(action=exit_builder)})
114 env.my_exit('foo.out', 'foo.in')
117 test.write(['subdir', 'foo.in'], "subdir/foo.in\n")
119 test.run(status = 27,
120 stdout = test.wrap_stdout("""\
121 exit_builder(["%s"], ["%s"])
122 """ % (subdir_foo_out, subdir_foo_in), error=1),
124 scons: *** [%s] Explicit exit, status 27
125 """ % (subdir_foo_out))
127 test.must_match(['subdir', 'foo.out'], "subdir/foo.in\n")
129 test.write('SConstruct', """\
130 def exit_scanner(node, env, target):
133 exitscan = Scanner(function = exit_scanner, skeys = ['.k'])
135 def cat(env, source, target):
136 target = str(target[0])
137 source = map(str, source)
139 outf = open(target, 'wb')
141 outf.write(open(src, "rb").read())
144 env = Environment(BUILDERS={'Cat':Builder(action=cat)})
145 env.Append(SCANNERS = [exitscan])
147 env.Cat('foo', 'foo.k')
150 test.write('foo.k', "foo.k\n")
152 test.run(status = 37,
153 stdout = test.wrap_stdout("", error=1),
154 stderr = "scons: *** [foo] Explicit exit, status 37\n")
161 # indent-tabs-mode:nil
163 # vim: set expandtab tabstop=4 shiftwidth=4: