[ci skip] update generated files
[scons.git] / test / Interactive / cache-debug.py
blobe1856bb71e04074d6277fc9740b9d468d45161c1
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 the --interactive command line option to build a target when the
28 --cache-debug option is used.
29 """
31 import TestCmd
32 import TestSCons
34 test = TestSCons.TestSCons()
36 test.write('SConstruct', """\
37 CacheDir('cache')
38 Command('foo.out', 'foo.in', Copy('$TARGET', '$SOURCE'))
39 Command('1', [], Touch('$TARGET'))
40 Command('2', [], Touch('$TARGET'))
41 Command('3', [], Touch('$TARGET'))
42 Command('4', [], Touch('$TARGET'))
43 Command('5', [], Touch('$TARGET'))
44 """)
46 test.write('foo.in', "foo.in\n")
50 scons = test.start(arguments = '-Q --interactive')
52 scons.send("build foo.out\n")
54 scons.send("build 1\n")
56 test.wait_for(test.workpath('1'), popen=scons)
58 test.must_match(test.workpath('foo.out'), "foo.in\n")
60 scons.send("clean foo.out\n")
62 scons.send("build 2\n")
64 test.wait_for(test.workpath('2'), popen=scons)
66 test.must_not_exist(test.workpath('foo.out'))
70 scons.send("build foo.out\n")
72 scons.send("build 3\n")
74 test.wait_for(test.workpath('3'), popen=scons)
76 test.must_match(test.workpath('foo.out'), "foo.in\n")
78 scons.send("clean foo.out\n")
80 scons.send("build 4\n")
82 test.wait_for(test.workpath('4'), popen=scons)
84 test.must_not_exist(test.workpath('foo.out'))
88 scons.send("build --cache-debug=- foo.out\n")
90 scons.send("build 5\n")
92 test.wait_for(test.workpath('5'), popen=scons)
94 test.must_match(test.workpath('foo.out'), "foo.in\n")
98 expect_stdout = \
99 r"""scons>>> Copy\("foo.out", "foo.in"\)
100 scons>>> Touch\("1"\)
101 scons>>> Removed foo.out
102 scons>>> Touch\("2"\)
103 scons>>> Retrieved `foo.out' from cache
104 scons>>> Touch\("3"\)
105 scons>>> Removed foo.out
106 scons>>> Touch\("4"\)
107 scons>>> Retrieved `foo.out' from cache
108 CacheRetrieve\(foo.out\): retrieving from [0-9A-za-z]+
109 requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}%
110 scons>>> Touch\("5"\)
111 scons>>>
114 test.finish(scons, stdout = expect_stdout, match=TestCmd.match_re)
118 test.pass_test()
120 # Local Variables:
121 # tab-width:4
122 # indent-tabs-mode:nil
123 # End:
124 # vim: set expandtab tabstop=4 shiftwidth=4: