[ci skip] update generated files
[scons.git] / test / CacheDir / up-to-date-q.py
blob5c71ab97ae7f06872a73cdae9ddb095bcd375f24
1 #!/usr/bin/env python
3 # MIT License
5 # Copyright The SCons Foundation
7 # Permission is hereby granted, free of charge, to any person obtaining
8 # a copy of this software and associated documentation files (the
9 # "Software"), to deal in the Software without restriction, including
10 # without limitation the rights to use, copy, modify, merge, publish,
11 # distribute, sublicense, and/or sell copies of the Software, and to
12 # permit persons to whom the Software is furnished to do so, subject to
13 # the following conditions:
15 # The above copyright notice and this permission notice shall be included
16 # in all copies or substantial portions of the Software.
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE._"
26 """
27 Verify that targets retrieved from CacheDir() are reported as
28 up-to-date by the -q option.
30 Thanks to dvitek for the test case.
31 """
33 # Demonstrate a regression between 0.96.1 and 0.96.93.
35 # SCons would incorrectly believe files are stale if they were retrieved
36 # from the cache in a previous invocation.
38 # What this script does:
39 # 1. Set up two identical C project directories called 'alpha' and
40 # 'beta', which use the same cache
41 # 2. Invoke scons on 'alpha'
42 # 3. Invoke scons on 'beta', which successfully draws output
43 # files from the cache
44 # 4. Invoke scons again, asserting (with -q) that 'beta' is up to date
46 # Step 4 failed in 0.96.93. In practice, this problem would lead to
47 # lots of unecessary fetches from the cache during incremental
48 # builds (because they behaved like non-incremental builds).
50 import TestSCons
52 test = TestSCons.TestSCons()
54 test.subdir('alpha', 'beta')
56 foo_c = """
57 int main(void){ return 0; }
58 """
60 sconstruct = """
61 CacheDir(r'%s')
62 Program('foo', 'foo.c')
63 """ % test.workpath('cache')
65 test.write('alpha/foo.c', foo_c)
66 test.write('alpha/SConstruct', sconstruct)
68 test.write('beta/foo.c', foo_c)
69 test.write('beta/SConstruct', sconstruct)
71 # First build, populates the cache
72 test.run(chdir = 'alpha', arguments = '.')
74 # Second build, everything is a cache hit
75 test.run(chdir = 'beta', arguments = '.')
77 # Since we just built 'beta', it ought to be up to date.
78 test.run(chdir = 'beta', arguments = '. -q')
80 test.pass_test()
82 # Local Variables:
83 # tab-width:4
84 # indent-tabs-mode:nil
85 # End:
86 # vim: set expandtab tabstop=4 shiftwidth=4: