[ci skip] update generated files
[scons.git] / test / Interactive / failure.py
blob122d875c4533cca7c4f4042f0e4e5e55fc041169
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.
24 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
26 """
27 Verify that when a build fails, later builds correctly report
28 that their builds succeeded, and that we don't get "stuck" on
29 reporting the earlier build failure.
30 """
32 import TestSCons
34 test = TestSCons.TestSCons()
36 test.write('SConstruct', """\
37 def fail(target, source, env):
38 return 1
39 Command('f1.out', 'f1.in', Action(fail))
40 Command('f2.out', 'f2.in', Copy('$TARGET', '$SOURCE'))
41 Command('1', [], Touch('$TARGET'))
42 Command('2', [], Touch('$TARGET'))
43 Command('3', [], Touch('$TARGET'))
44 Command('4', [], Touch('$TARGET'))
45 """)
47 test.write('f1.in', "f1.in 1\n")
48 test.write('f2.in', "f2.in 1\n")
52 scons = test.start(arguments = '--interactive')
54 scons.send("build f1.out\n")
56 scons.send("build 1\n")
58 test.wait_for(test.workpath('1'))
60 test.must_not_exist(test.workpath('f1.out'))
64 scons.send("build f2.out\n")
66 scons.send("build 2\n")
68 test.wait_for(test.workpath('2'))
70 test.must_match(test.workpath('f2.out'), "f2.in 1\n")
74 scons.send("build f1.out\n")
76 scons.send("build 3\n")
78 test.wait_for(test.workpath('3'))
80 test.must_not_exist(test.workpath('f1.out'))
84 test.write('f2.in', "f2.in 2\n")
86 scons.send("build f2.out\n")
88 scons.send("build 4\n")
90 test.wait_for(test.workpath('4'))
92 test.must_match(test.workpath('f2.out'), "f2.in 2\n")
96 expect_stdout = """\
97 scons: Reading SConscript files ...
98 scons: done reading SConscript files.
99 scons>>> scons: Building targets ...
100 fail(["f1.out"], ["f1.in"])
101 scons: building terminated because of errors.
102 scons: Clearing cached node information ...
103 scons: done clearing node information.
104 scons>>> scons: Building targets ...
105 Touch("1")
106 scons: done building targets.
107 scons: Clearing cached node information ...
108 scons: done clearing node information.
109 scons>>> scons: Building targets ...
110 Copy("f2.out", "f2.in")
111 scons: done building targets.
112 scons: Clearing cached node information ...
113 scons: done clearing node information.
114 scons>>> scons: Building targets ...
115 Touch("2")
116 scons: done building targets.
117 scons: Clearing cached node information ...
118 scons: done clearing node information.
119 scons>>> scons: Building targets ...
120 fail(["f1.out"], ["f1.in"])
121 scons: building terminated because of errors.
122 scons: Clearing cached node information ...
123 scons: done clearing node information.
124 scons>>> scons: Building targets ...
125 Touch("3")
126 scons: done building targets.
127 scons: Clearing cached node information ...
128 scons: done clearing node information.
129 scons>>> scons: Building targets ...
130 Copy("f2.out", "f2.in")
131 scons: done building targets.
132 scons: Clearing cached node information ...
133 scons: done clearing node information.
134 scons>>> scons: Building targets ...
135 Touch("4")
136 scons: done building targets.
137 scons: Clearing cached node information ...
138 scons: done clearing node information.
139 scons>>>
142 expect_stderr = """\
143 scons: *** [f1.out] Error 1
144 scons: *** [f1.out] Error 1
147 test.finish(scons, stdout = expect_stdout, stderr = expect_stderr)
151 test.pass_test()
153 # Local Variables:
154 # tab-width:4
155 # indent-tabs-mode:nil
156 # End:
157 # vim: set expandtab tabstop=4 shiftwidth=4: