added release.txt blurb. Fixed spelling typo in Defaults.xml
[scons.git] / test / chained-build.py
blob10d0b46854191e39ccfe5a6d95de7a58bbf8fd84
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 import TestSCons
28 test = TestSCons.TestSCons()
30 # During the development of 0.96, there was a --save-explain-info
31 # option for a brief moment that would surpress storing extra
32 # info in the .sconsign file(s). At that time, this test used two
33 # working subdirectories to test both with and without the saved info.
34 # We eliminated the --save-explain-info option and the second working
35 # subdirectory here, but didn't go back and change all the filenames.
36 test.subdir('w1')
38 SConstruct1_contents = """\
39 def build(env, target, source):
40 with open(str(target[0]), 'wt') as fo, open(str(source[0]), 'rt') as fi:
41 fo.write(fi.read())
43 env=Environment(BUILDERS={'B' : Builder(action=build)})
44 env.B('foo.mid', 'foo.in')
45 """
47 SConstruct2_contents = """\
48 def build(env, target, source):
49 with open(str(target[0]), 'wt') as fo, open(str(source[0]), 'rt') as fi:
50 fo.write(fi.read())
52 env=Environment(BUILDERS={'B' : Builder(action=build)})
53 env.B('foo.out', 'foo.mid')
54 """
56 test.write(['w1', 'SConstruct1'], SConstruct1_contents)
57 test.write(['w1', 'SConstruct2'], SConstruct2_contents)
58 test.write(['w1', 'foo.in'], "foo.in 1")
60 test.run(
61 chdir='w1',
62 arguments="--max-drift=0 -f SConstruct1 foo.mid",
63 stdout=test.wrap_stdout('build(["foo.mid"], ["foo.in"])\n'),
65 test.run(
66 chdir='w1',
67 arguments="--max-drift=0 -f SConstruct2 foo.out",
68 stdout=test.wrap_stdout('build(["foo.out"], ["foo.mid"])\n'),
70 test.up_to_date(chdir='w1', options="--max-drift=0 -f SConstruct1", arguments="foo.mid")
71 test.up_to_date(chdir='w1', options="--max-drift=0 -f SConstruct2", arguments="foo.out")
73 test.sleep() # delay for timestamps
74 test.write(['w1', 'foo.in'], "foo.in 2")
76 # Because we're using --max-drift=0, we use the cached csig value
77 # and think that foo.in hasn't changed even though it has on disk.
78 test.up_to_date(chdir='w1',
79 options="--max-drift=0 -f SConstruct1",
80 arguments="foo.mid")
82 # Now try with --max-drift disabled. The build of foo.out should still
83 # be considered up-to-date, but the build of foo.mid now detects the
84 # change and rebuilds, too, which then causes a rebuild of foo.out.
85 test.up_to_date(
86 chdir='w1', options="--max-drift=-1 -f SConstruct2", arguments="foo.out"
88 test.run(
89 chdir='w1',
90 arguments="--max-drift=-1 -f SConstruct1 foo.mid",
91 stdout=test.wrap_stdout('build(["foo.mid"], ["foo.in"])\n'),
93 test.run(
94 chdir='w1',
95 arguments="--max-drift=-1 -f SConstruct2 foo.out",
96 stdout=test.wrap_stdout('build(["foo.out"], ["foo.mid"])\n'),
99 test.pass_test()
101 # Local Variables:
102 # tab-width:4
103 # indent-tabs-mode:nil
104 # End:
105 # vim: set expandtab tabstop=4 shiftwidth=4: