Added fix for TeX includes with same name as subdirs.
[scons.git] / test / chained-build.py
1 #!/usr/bin/env python
2 #
3 # __COPYRIGHT__
4 #
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:
12 #
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
15 #
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.
23 #
24
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
26
27 import TestSCons
28
29 test = TestSCons.TestSCons()
30
31 # During the development of 0.96, there was a --save-explain-info
32 # option for a brief moment that would surpress storing extra
33 # info in the .sconsign file(s).  At that time, this test used two
34 # working subdirectories to test both with and without the saved info.
35 # We eliminated the --save-explain-info option and the second working
36 # subdirectory here, but didn't go back and change all the filenames.
37 test.subdir('w1')
38
39 SConstruct1_contents = """\
40 def build(env, target, source):
41     open(str(target[0]), 'wt').write(open(str(source[0]), 'rt').read())
42
43 env=Environment(BUILDERS={'B' : Builder(action=build)})
44 env.B('foo.mid', 'foo.in')
45 """
46
47 SConstruct2_contents = """\
48 def build(env, target, source):
49     open(str(target[0]), 'wt').write(open(str(source[0]), 'rt').read())
50
51 env=Environment(BUILDERS={'B' : Builder(action=build)})
52 env.B('foo.out', 'foo.mid')
53 """
54
55 test.write(['w1', 'SConstruct1'], SConstruct1_contents)
56 test.write(['w1', 'SConstruct2'], SConstruct2_contents)
57 test.write(['w1', 'foo.in'], "foo.in 1")
58
59 test.run(chdir='w1',
60          arguments="--max-drift=0 -f SConstruct1 foo.mid",
61          stdout = test.wrap_stdout('build(["foo.mid"], ["foo.in"])\n'))
62
63 test.run(chdir='w1',
64          arguments="--max-drift=0 -f SConstruct2 foo.out",
65          stdout = test.wrap_stdout('build(["foo.out"], ["foo.mid"])\n'))
66
67 test.up_to_date(chdir='w1',
68                 options="--max-drift=0 -f SConstruct1",
69                 arguments="foo.mid")
70
71 test.up_to_date(chdir='w1',
72                 options="--max-drift=0 -f SConstruct2",
73                 arguments="foo.out")
74
75 test.sleep()  # make sure foo.in rewrite has new mod-time
76 test.write(['w1', 'foo.in'], "foo.in 2")
77
78 # Because we're using --max-drift=0, we use the cached csig value
79 # and think that foo.in hasn't changed even though it has on disk.
80 test.up_to_date(chdir='w1',
81          options="--max-drift=0 -f SConstruct1",
82          arguments="foo.mid")
83
84 # Now try with --max-drift disabled.  The build of foo.out should still
85 # be considered up-to-date, but the build of foo.mid now detects the
86 # change and rebuilds, too, which then causes a rebuild of foo.out.
87 test.up_to_date(chdir='w1',
88                 options="--max-drift=-1 -f SConstruct2",
89                 arguments="foo.out")
90
91 test.run(chdir='w1',
92          arguments="--max-drift=-1 -f SConstruct1 foo.mid",
93          stdout = test.wrap_stdout('build(["foo.mid"], ["foo.in"])\n'))
94
95 test.run(chdir='w1',
96          arguments="--max-drift=-1 -f SConstruct2 foo.out",
97          stdout = test.wrap_stdout('build(["foo.out"], ["foo.mid"])\n'))
98
99 test.pass_test()
100
101 # Local Variables:
102 # tab-width:4
103 # indent-tabs-mode:nil
104 # End:
105 # vim: set expandtab tabstop=4 shiftwidth=4: