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.
27 Test that files are correctly located in the variant directory even when
28 Scons does not have a global view of all targets.
30 Sometimes, it might be interesting to not tell scons about every
31 targets. For example, one might not read in all the SConscipts of a
32 hierarchical build for a particular invocation of scons. This would be
33 done to speed-up a partial rebuild when the developer knows that only
34 a subset of the targets need to be rebuilt.
39 test
= TestSCons
.TestSCons()
44 test
.write('SConstruct', """\
47 BoolVariable('view_all_dependencies', 'View all dependencies', True),
48 BoolVariable('duplicate', 'Duplicate sources to variant dir', True)
51 env = Environment(options=opts)
54 SConscript(dirs='.', variant_dir='build', duplicate=env['duplicate'])
58 test
.write('SConscript', """\
61 if env['view_all_dependencies']:
62 SConscript(dirs='dir1')
64 SConscript(dirs='dir2')
67 test
.write('dir1/SConscript', """\
70 env.Command('x.cpp', '', Touch('$TARGET'))
72 env.Object(env.File('x.cpp'))
75 test
.write('dir2/SConscript', """\
78 env.Object(env.File('#/build/dir1/x.cpp'))
81 test
.must_not_exist('build/dir1/x.cpp')
84 ############################################################
86 # Test without duplication
89 # Build everything first.
90 test
.run(arguments
= 'duplicate=False view_all_dependencies=True .')
91 test
.must_exist('build/dir1/x.cpp')
92 test
.must_not_contain_any_line(test
.stdout(), ["`.' is up to date."])
94 # Double check that targets are not rebuilt.
95 test
.run(arguments
= 'duplicate=False view_all_dependencies=True .')
96 test
.must_exist('build/dir1/x.cpp')
97 test
.must_contain_all_lines(test
.stdout(), ["`.' is up to date."])
99 # Clean-up only the object file
100 test
.run(arguments
= 'duplicate=False view_all_dependencies=False -c .')
101 test
.must_exist('build/dir1/x.cpp')
103 # Rebuild the only object file without seeing all the dependencies.
104 test
.run(arguments
= 'duplicate=False view_all_dependencies=False .')
105 test
.must_exist('build/dir1/x.cpp')
106 test
.must_not_contain_any_line(test
.stdout(), ["`.' is up to date."])
108 # Double check that targets are not rebuilt without and with all the
110 test
.run(arguments
= 'duplicate=False view_all_dependencies=False .')
111 test
.must_exist('build/dir1/x.cpp')
112 test
.must_contain_all_lines(test
.stdout(), ["`.' is up to date."])
114 test
.run(arguments
= 'duplicate=False view_all_dependencies=True .')
115 test
.must_exist('build/dir1/x.cpp')
116 test
.must_contain_all_lines(test
.stdout(), ["`.' is up to date."])
118 # Clean-up everything.
119 test
.run(arguments
= 'duplicate=False view_all_dependencies=True -c .')
120 test
.must_not_exist('build/dir1/x.cpp')
123 ############################################################
125 # Test with duplication
127 # FIXME: This can not work for now because there is no way that SCons
128 # can differentiate between a source that no longer exists and a file
129 # that has a builder that scons does not know about because scons has
130 # not parsed all the SConscript of a given project.
133 # # Build everything first.
134 # test.run(arguments = 'duplicate=True view_all_dependencies=True .')
135 # test.must_exist('build/dir1/x.cpp')
136 # test.must_not_contain_any_line(test.stdout(), ["`.' is up to date."])
138 # # Double check that targets are not rebuilt.
139 # test.run(arguments = 'duplicate=True view_all_dependencies=True .')
140 # test.must_exist('build/dir1/x.cpp')
141 # test.must_contain_all_lines(test.stdout(), ["`.' is up to date."])
143 # # Clean-up only the object file
144 # test.run(arguments = 'duplicate=True view_all_dependencies=False -c .')
145 # test.must_exist('build/dir1/x.cpp')
147 # # Rebuild the only object file without seeing all the dependencies.
148 # test.run(arguments = 'duplicate=True view_all_dependencies=False .')
149 # test.must_exist('build/dir1/x.cpp')
150 # test.must_not_contain_any_line(test.stdout(), ["`.' is up to date."])
152 # # Double check that targets are not rebuilt without and with all the
154 # test.run(arguments = 'duplicate=True view_all_dependencies=False .')
155 # test.must_exist('build/dir1/x.cpp')
156 # test.must_contain_all_lines(test.stdout(), ["`.' is up to date."])
158 # test.run(arguments = 'duplicate=True view_all_dependencies=True .')
159 # test.must_exist('build/dir1/x.cpp')
160 # test.must_contain_all_lines(test.stdout(), ["`.' is up to date."])
162 # # Clean-up everything.
163 # test.run(arguments = 'duplicate=True view_all_dependencies=True -c .')
164 # test.must_not_exist('build/dir1/x.cpp')
171 # indent-tabs-mode:nil
173 # vim: set expandtab tabstop=4 shiftwidth=4: