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 Verify use of the --config=<auto|force|cache> option.
33 from TestSCons
import TestSCons
, ConfigCheckInfo
, _obj
34 from TestCmd
import IS_WINDOWS
35 from SCons
.Util
import get_current_hash_algorithm_used
39 test
.subdir('include')
41 NCR
= test
.NCR
# non-cached rebuild
42 CR
= test
.CR
# cached rebuild (up to date)
43 NCF
= test
.NCF
# non-cached build failure
44 CF
= test
.CF
# cached build failure
46 # as this test is somewhat complicated, skip it if the library doesn't support md5
47 # as the default hashing algorithm.
48 if get_current_hash_algorithm_used() != 'md5':
49 test
.skip_test('Skipping test as could not continue without the hash algorithm set to md5!')
51 SConstruct_path
= test
.workpath('SConstruct')
53 test
.write(SConstruct_path
, """
54 env = Environment(CPPPATH='#/include')
56 env.AppendENVPath('PATH', os.environ['PATH'])
58 conf.CheckCHeader('non_system_header0.h')
59 conf.CheckCHeader('non_system_header1.h')
63 test
.write(['include', 'non_system_header0.h'], """
67 conftest_0_c_hash
= 'cda36b76729ffb03bf36a48d13b2d98d'
68 conftest_1_c_hash
= 'acc476a565a3f6d5d67ddc21f187d062'
71 conftest_0_obj_suffix
= '_213c72f9eb682c6f27f2eb78ed8bd57a'+_obj
72 conftest_1_obj_suffix
= '_7c505229a64dccfea6e7cfdffe76bd2a'+_obj
74 conftest_0_obj_suffix
= '_9b191e4c46e9d6ba17c8cd4d730900cf'+_obj
75 conftest_1_obj_suffix
= '_b9da1a844a8707269188b28a62c0d83e'+_obj
77 conftest_0_base
= os
.path
.join(".sconf_temp", "conftest_%s_0%%s"%conftest
_0_c
_hash
)
78 conftest_0_c
= conftest_0_base
%'.c'
79 conftest_1_base
= os
.path
.join(".sconf_temp", "conftest_%s_0%%s"%conftest
_1_c
_hash
)
81 SConstruct_file_line
= test
.python_file_line(SConstruct_path
, 6)[:-1]
84 scons: *** "%(conftest_0_c)s" is not yet built and cache is forced.
85 %(SConstruct_file_line)s
88 test
.run(arguments
='--config=cache', status
=2, stderr
=expect
)
90 test
.run(arguments
='--config=auto')
91 test
.checkConfigureLogAndStdout(checks
=[
92 ConfigCheckInfo("Checking for C header file non_system_header0.h... ",
98 ConfigCheckInfo("Checking for C header file non_system_header1.h... ",
105 test
.run(arguments
='--config=auto')
106 test
.checkConfigureLogAndStdout(checks
=[
107 ConfigCheckInfo("Checking for C header file non_system_header0.h... ",
110 (conftest_0_obj_suffix
, CR
))],
113 ConfigCheckInfo("Checking for C header file non_system_header1.h... ",
116 (conftest_1_obj_suffix
, CF
))],
121 test
.run(arguments
='--config=force')
122 test
.checkConfigureLogAndStdout(checks
=[
123 ConfigCheckInfo("Checking for C header file non_system_header0.h... ",
126 (conftest_0_obj_suffix
, NCR
))],
129 ConfigCheckInfo("Checking for C header file non_system_header1.h... ",
132 (conftest_1_obj_suffix
, NCF
))],
137 test
.run(arguments
='--config=cache')
138 test
.checkConfigureLogAndStdout(checks
=[
139 ConfigCheckInfo("Checking for C header file non_system_header0.h... ",
142 (conftest_0_obj_suffix
, CR
))],
145 ConfigCheckInfo("Checking for C header file non_system_header1.h... ",
148 (conftest_1_obj_suffix
, CF
))],
153 test
.write(['include', 'non_system_header1.h'], """
156 test
.unlink(['include', 'non_system_header0.h'])
158 test
.run(arguments
='--config=cache')
160 test
.checkConfigureLogAndStdout(checks
=[
161 ConfigCheckInfo("Checking for C header file non_system_header0.h... ",
164 (conftest_0_obj_suffix
, CR
))],
167 ConfigCheckInfo("Checking for C header file non_system_header1.h... ",
170 (conftest_1_obj_suffix
, CF
))],
174 test
.run(arguments
='--config=auto')
175 test
.checkConfigureLogAndStdout(checks
=[
176 ConfigCheckInfo("Checking for C header file non_system_header0.h... ",
179 (conftest_0_obj_suffix
, NCF
))],
182 ConfigCheckInfo("Checking for C header file non_system_header1.h... ",
185 (conftest_1_obj_suffix
, NCR
))],
189 test
.file_fixture('test_main.c')
191 # Check the combination of --config=force and Decider('MD5-timestamp')
192 SConstruct_path
= test
.workpath('SConstruct')
193 test
.write(SConstruct_path
, """
195 env.Decider('MD5-timestamp')
196 conf = Configure(env)
197 conf.TryLink('int main(){return 0;}','.c')
199 env.Program('test_main.c')
201 test
.run(arguments
='--config=force')
202 # On second run the sconsign is loaded and decider doesn't just indicate need to rebuild
203 test
.run(arguments
='--config=force')
204 test
.must_not_contain(test
.workpath('config.log'), "TypeError: 'NoneType' object is not callable", mode
='r')
206 # Now check to check that test_main.c didn't rebuild on second run above.
207 # This fixes an issue where --config=force overwrites the Environments decider and is not reset when
208 # the configure context is done.
209 # https://github.com/SCons/scons/issues/3303
210 test
.fail_test('test_main.o' in test
.stdout())
216 # indent-tabs-mode:nil
218 # vim: set expandtab tabstop=4 shiftwidth=4: