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:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
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.
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
28 Test that files are correctly located in the variant directory even when
29 Scons does not have a global view of all targets.
31 Sometimes, it might be interesting to not tell scons about every
32 targets. For example, one might not read in all the SConscipts of a
33 hierarchical build for a particular invocation of scons. This would be
34 done to speed-up a partial rebuild when the developer knows that only
35 a subset of the targets need to be rebuilt.
40 test = TestSCons.TestSCons()
45 test.write('SConstruct', """\
48 BoolVariable('view_all_dependencies', 'View all dependencies', True),
49 BoolVariable('duplicate', 'Duplicate sources to variant dir', True)
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: