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.
42 test = TestSCons.TestSCons()
47 test.write('SConstruct', """\
50 BoolOption('view_all_dependencies', 'View all dependencies', True),
51 BoolOption('duplicate', 'Duplicate sources to variant dir', True)
54 env = Environment(options=opts)
57 SConscript(dirs='.', variant_dir='build', duplicate=env['duplicate'])
61 test.write('SConscript', """\
64 if env['view_all_dependencies']:
65 SConscript(dirs='dir1')
67 SConscript(dirs='dir2')
70 test.write('dir1/SConscript', """\
73 env.Command('x.cpp', '', Touch('$TARGET'))
75 env.Object(env.File('x.cpp'))
78 test.write('dir2/SConscript', """\
81 env.Object(env.File('#/build/dir1/x.cpp'))
84 test.must_not_exist('build/dir1/x.cpp')
87 ############################################################
89 # Test without duplication
92 # Build everything first.
93 test.run(arguments = 'duplicate=False view_all_dependencies=True .')
94 test.must_exist('build/dir1/x.cpp')
95 test.fail_test(string.find(test.stdout(), "`.' is up to date.") != -1)
97 # Double check that targets are not rebuilt.
98 test.run(arguments = 'duplicate=False view_all_dependencies=True .')
99 test.must_exist('build/dir1/x.cpp')
100 test.fail_test(string.find(test.stdout(), "`.' is up to date.") == -1)
102 # Clean-up only the object file
103 test.run(arguments = 'duplicate=False view_all_dependencies=False -c .')
104 test.must_exist('build/dir1/x.cpp')
106 # Rebuild the only object file without seeing all the dependencies.
107 test.run(arguments = 'duplicate=False view_all_dependencies=False .')
108 test.must_exist('build/dir1/x.cpp')
109 test.fail_test(string.find(test.stdout(), "`.' is up to date.") != -1)
111 # Double check that targets are not rebuilt without and with all the
113 test.run(arguments = 'duplicate=False view_all_dependencies=False .')
114 test.must_exist('build/dir1/x.cpp')
115 test.fail_test(string.find(test.stdout(), "`.' is up to date.") == -1)
117 test.run(arguments = 'duplicate=False view_all_dependencies=True .')
118 test.must_exist('build/dir1/x.cpp')
119 test.fail_test(string.find(test.stdout(), "`.' is up to date.") == -1)
121 # Clean-up everything.
122 test.run(arguments = 'duplicate=False view_all_dependencies=True -c .')
123 test.must_not_exist('build/dir1/x.cpp')
126 ############################################################
128 # Test with duplication
130 # FIXME: This can not work for now because there is no way that SCons
131 # can differentiate between a source that no longer exists and a file
132 # that has a builder that scons does not know about because scons has
133 # not parsed all the SConscript of a given project.
136 # # Build everything first.
137 # test.run(arguments = 'duplicate=True view_all_dependencies=True .')
138 # test.must_exist('build/dir1/x.cpp')
139 # test.fail_test(string.find(test.stdout(), "`.' is up to date.") != -1)
141 # # Double check that targets are not rebuilt.
142 # test.run(arguments = 'duplicate=True view_all_dependencies=True .')
143 # test.must_exist('build/dir1/x.cpp')
144 # test.fail_test(string.find(test.stdout(), "`.' is up to date.") == -1)
146 # # Clean-up only the object file
147 # test.run(arguments = 'duplicate=True view_all_dependencies=False -c .')
148 # test.must_exist('build/dir1/x.cpp')
150 # # Rebuild the only object file without seeing all the dependencies.
151 # test.run(arguments = 'duplicate=True view_all_dependencies=False .')
152 # test.must_exist('build/dir1/x.cpp')
153 # test.fail_test(string.find(test.stdout(), "`.' is up to date.") != -1)
155 # # Double check that targets are not rebuilt without and with all the
157 # test.run(arguments = 'duplicate=True view_all_dependencies=False .')
158 # test.must_exist('build/dir1/x.cpp')
159 # test.fail_test(string.find(test.stdout(), "`.' is up to date.") == -1)
161 # test.run(arguments = 'duplicate=True view_all_dependencies=True .')
162 # test.must_exist('build/dir1/x.cpp')
163 # test.fail_test(string.find(test.stdout(), "`.' is up to date.") == -1)
165 # # Clean-up everything.
166 # test.run(arguments = 'duplicate=True view_all_dependencies=True -c .')
167 # test.must_not_exist('build/dir1/x.cpp')