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 populating a CacheDir with the --cache-force option.
36 test = TestSCons.TestSCons()
38 test.subdir('cache', 'src')
40 test.write(['src', 'SConstruct'], """
41 def cat(env, source, target):
42 target = str(target[0])
43 open('cat.out', 'ab').write(target + "\\n")
44 source = map(str, source)
45 f = open(target, "wb")
47 f.write(open(src, "rb").read())
49 env = Environment(BUILDERS={'Cat':Builder(action=cat)})
50 env.Cat('aaa.out', 'aaa.in')
51 env.Cat('bbb.out', 'bbb.in')
52 env.Cat('ccc.out', 'ccc.in')
53 env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out'])
55 """ % test.workpath('cache'))
57 test.write(['src', 'aaa.in'], "aaa.in\n")
58 test.write(['src', 'bbb.in'], "bbb.in\n")
59 test.write(['src', 'ccc.in'], "ccc.in\n")
61 # Verify that a normal build works correctly, and clean up.
62 # This should populate the cache with our derived files.
63 test.run(chdir = 'src', arguments = '.')
65 test.fail_test(test.read(['src', 'all']) != "aaa.in\nbbb.in\nccc.in\n")
66 test.fail_test(test.read(['src', 'cat.out']) != "aaa.out\nbbb.out\nccc.out\nall\n")
68 test.up_to_date(chdir = 'src', arguments = '.')
70 test.run(chdir = 'src', arguments = '-c .')
71 test.unlink(['src', 'cat.out'])
73 # Verify that we now retrieve the derived files from cache,
74 # not rebuild them. DO NOT CLEAN UP.
75 test.run(chdir = 'src', arguments = '.', stdout = test.wrap_stdout("""\
76 Retrieved `aaa.out' from cache
77 Retrieved `bbb.out' from cache
78 Retrieved `ccc.out' from cache
79 Retrieved `all' from cache
82 test.fail_test(os.path.exists(test.workpath('src', 'cat.out')))
84 test.up_to_date(chdir = 'src', arguments = '.')
86 # Blow away and recreate the CacheDir, then verify that --cache-force
87 # repopulates the cache with the local built targets. DO NOT CLEAN UP.
88 shutil.rmtree(test.workpath('cache'))
91 test.run(chdir = 'src', arguments = '--cache-force .')
93 test.run(chdir = 'src', arguments = '-c .')
95 test.run(chdir = 'src', arguments = '.', stdout = test.wrap_stdout("""\
96 Retrieved `aaa.out' from cache
97 Retrieved `bbb.out' from cache
98 Retrieved `ccc.out' from cache
99 Retrieved `all' from cache
102 test.fail_test(os.path.exists(test.workpath('src', 'cat.out')))
104 # Blow away and recreate the CacheDir, then verify that --cache-populate
105 # repopulates the cache with the local built targets. DO NOT CLEAN UP.
106 shutil.rmtree(test.workpath('cache'))
109 test.run(chdir = 'src', arguments = '--cache-populate .')
111 test.run(chdir = 'src', arguments = '-c .')
113 test.run(chdir = 'src', arguments = '.', stdout = test.wrap_stdout("""\
114 Retrieved `aaa.out' from cache
115 Retrieved `bbb.out' from cache
116 Retrieved `ccc.out' from cache
117 Retrieved `all' from cache
120 test.fail_test(os.path.exists(test.workpath('src', 'cat.out')))
127 # indent-tabs-mode:nil
129 # vim: set expandtab tabstop=4 shiftwidth=4: