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 --cache-disable option when retrieving derived files from a
37 test = TestSCons.TestSCons()
39 test.subdir('cache', 'src')
41 test.write(['src', 'SConstruct'], """
42 def cat(env, source, target):
43 target = str(target[0])
44 open('cat.out', 'ab').write(target + "\\n")
45 source = map(str, source)
46 f = open(target, "wb")
48 f.write(open(src, "rb").read())
50 env = Environment(BUILDERS={'Cat':Builder(action=cat)})
51 env.Cat('aaa.out', 'aaa.in')
52 env.Cat('bbb.out', 'bbb.in')
53 env.Cat('ccc.out', 'ccc.in')
54 env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out'])
56 """ % test.workpath('cache'))
58 test.write(['src', 'aaa.in'], "aaa.in\n")
59 test.write(['src', 'bbb.in'], "bbb.in\n")
60 test.write(['src', 'ccc.in'], "ccc.in\n")
62 # Verify that a normal build works correctly, and clean up.
63 # This should populate the cache with our derived files.
64 test.run(chdir = 'src', arguments = '.')
66 test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n")
67 test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n")
69 test.up_to_date(chdir = 'src', arguments = '.')
71 test.run(chdir = 'src', arguments = '-c .')
72 test.unlink(['src', 'cat.out'])
74 # Verify that we now retrieve the derived files from cache,
75 # not rebuild them. Then clean up.
76 test.run(chdir = 'src', arguments = '.', stdout = test.wrap_stdout("""\
77 Retrieved `aaa.out' from cache
78 Retrieved `bbb.out' from cache
79 Retrieved `ccc.out' from cache
80 Retrieved `all' from cache
83 test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n")
84 test.must_not_exist(test.workpath('src', 'cat.out'))
86 test.up_to_date(chdir = 'src', arguments = '.')
88 test.run(chdir = 'src', arguments = '-c .')
90 # Verify that when run with --cache-disable, we rebuild the files even
91 # though they're available from the cache. Then clean up.
92 test.run(chdir = 'src',
93 arguments = '--cache-disable .',
94 stdout = test.wrap_stdout("""\
95 cat(["aaa.out"], ["aaa.in"])
96 cat(["bbb.out"], ["bbb.in"])
97 cat(["ccc.out"], ["ccc.in"])
98 cat(["all"], ["aaa.out", "bbb.out", "ccc.out"])
101 test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n")
102 test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n")
104 test.up_to_date(chdir = 'src', arguments = '.')
106 test.run(chdir = 'src', arguments = '-c .')
107 test.unlink(['src', 'cat.out'])
109 # Verify that when run with --no-cache, we rebuild the files even
110 # though they're available from the cache. Then clean up.
111 test.run(chdir = 'src',
112 arguments = '--no-cache .',
113 stdout = test.wrap_stdout("""\
114 cat(["aaa.out"], ["aaa.in"])
115 cat(["bbb.out"], ["bbb.in"])
116 cat(["ccc.out"], ["ccc.in"])
117 cat(["all"], ["aaa.out", "bbb.out", "ccc.out"])
120 test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n")
121 test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n")
123 test.up_to_date(chdir = 'src', arguments = '.')
125 test.run(chdir = 'src', arguments = '-c .')
126 test.unlink(['src', 'cat.out'])