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 _ = DefaultEnvironment(tools=[])
52 env = Environment(options=opts)
55 SConscript(dirs='.', variant_dir='build', duplicate=env['duplicate'])
59 test
.write('SConscript', """\
62 if env['view_all_dependencies']:
63 SConscript(dirs='dir1')
65 SConscript(dirs='dir2')
68 test
.write('dir1/SConscript', """\
71 env.Command('x.cpp', '', Touch('$TARGET'))
73 env.Object(env.File('x.cpp'))
76 test
.write('dir2/SConscript', """\
79 env.Object(env.File('#/build/dir1/x.cpp'))
82 test
.must_not_exist('build/dir1/x.cpp')
85 ############################################################
87 # Test without duplication
90 # Build everything first.
91 test
.run(arguments
='duplicate=False view_all_dependencies=True .')
92 test
.must_exist('build/dir1/x.cpp')
93 test
.must_not_contain_any_line(test
.stdout(), ["`.' is up to date."])
95 # Double check that targets are not rebuilt.
96 test
.run(arguments
='duplicate=False view_all_dependencies=True .')
97 test
.must_exist('build/dir1/x.cpp')
98 test
.must_contain_all_lines(test
.stdout(), ["`.' is up to date."])
100 # Clean-up only the object file
101 test
.run(arguments
='duplicate=False view_all_dependencies=False -c .')
102 test
.must_exist('build/dir1/x.cpp')
104 # Rebuild the only object file without seeing all the dependencies.
105 test
.run(arguments
='duplicate=False view_all_dependencies=False .')
106 test
.must_exist('build/dir1/x.cpp')
107 test
.must_not_contain_any_line(test
.stdout(), ["`.' is up to date."])
109 # Double check that targets are not rebuilt without and with all the
111 test
.run(arguments
='duplicate=False view_all_dependencies=False .')
112 test
.must_exist('build/dir1/x.cpp')
113 test
.must_contain_all_lines(test
.stdout(), ["`.' is up to date."])
115 test
.run(arguments
='duplicate=False view_all_dependencies=True .')
116 test
.must_exist('build/dir1/x.cpp')
117 test
.must_contain_all_lines(test
.stdout(), ["`.' is up to date."])
119 # Clean-up everything.
120 test
.run(arguments
='duplicate=False view_all_dependencies=True -c .')
121 test
.must_not_exist('build/dir1/x.cpp')
124 ############################################################
126 # Test with duplication
128 # FIXME: This can not work for now because there is no way that SCons
129 # can differentiate between a source that no longer exists and a file
130 # that has a builder that scons does not know about because scons has
131 # not parsed all the SConscript of a given project.
134 # # Build everything first.
135 # test.run(arguments='duplicate=True view_all_dependencies=True .')
136 # test.must_exist('build/dir1/x.cpp')
137 # test.must_not_contain_any_line(test.stdout(), ["`.' is up to date."])
139 # # Double check that targets are not rebuilt.
140 # test.run(arguments='duplicate=True view_all_dependencies=True .')
141 # test.must_exist('build/dir1/x.cpp')
142 # test.must_contain_all_lines(test.stdout(), ["`.' is up to date."])
144 # # Clean-up only the object file
145 # test.run(arguments='duplicate=True view_all_dependencies=False -c .')
146 # test.must_exist('build/dir1/x.cpp')
148 # # Rebuild the only object file without seeing all the dependencies.
149 # test.run(arguments='duplicate=True view_all_dependencies=False .')
150 # test.must_exist('build/dir1/x.cpp')
151 # test.must_not_contain_any_line(test.stdout(), ["`.' is up to date."])
153 # # Double check that targets are not rebuilt without and with all the
155 # test.run(arguments='duplicate=True view_all_dependencies=False .')
156 # test.must_exist('build/dir1/x.cpp')
157 # test.must_contain_all_lines(test.stdout(), ["`.' is up to date."])
159 # test.run(arguments='duplicate=True view_all_dependencies=True .')
160 # test.must_exist('build/dir1/x.cpp')
161 # test.must_contain_all_lines(test.stdout(), ["`.' is up to date."])
163 # # Clean-up everything.
164 # test.run(arguments='duplicate=True view_all_dependencies=True -c .')
165 # test.must_not_exist('build/dir1/x.cpp')
172 # indent-tabs-mode:nil
174 # vim: set expandtab tabstop=4 shiftwidth=4: