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.
28 Verify the ConfigureDryRunError.
35 from SCons
.Util
import get_current_hash_algorithm_used
39 test
= TestSCons
.TestSCons()
41 lib
= test
.Configure_lib
43 NCR
= test
.NCR
# non-cached rebuild
44 CR
= test
.CR
# cached rebuild (up to date)
45 NCF
= test
.NCF
# non-cached build failure
46 CF
= test
.CF
# cached build failure
48 SConstruct_path
= test
.workpath('SConstruct')
50 test
.write(SConstruct_path
, """
53 DefaultEnvironment(tools=[])
56 env.AppendENVPath('PATH', os.environ['PATH'])
58 r1 = conf.CheckLib('%s') # will pass
59 r2 = conf.CheckLib('hopefullynolib') # will fail
61 if not (r1 and not r2):
66 scons: *** Cannot create configure directory ".sconf_temp" within a dry-run.
67 """ + test
.python_file_line(SConstruct_path
, 8)
69 test
.run(arguments
='-n', status
=2, stderr
=expect
)
71 test
.must_not_exist('config.log')
72 test
.subdir('.sconf_temp')
74 # depending on which default hash function we're using, we'd expect one
75 # of the following filenames. The filenames are generated by the conftest
76 # changes in #3543 : https://github.com/SCons/scons/pull/3543
77 # Note if the code generated for CheckLib(Configure_lib) changes, we need
78 # to recompute the hashes of the generated file - even though it won't
79 # even be built for this test.
80 possible_filenames
= {
81 'md5': 'conftest_e492448966d6e04631c094ba6d6e8a32_0.c',
82 'sha1': 'conftest_f0a9e7fe48f48687797dbafb5d07071d35f86dd2_0.c',
83 'sha256': 'conftest_e856bf0bdb229b16823f193eee68254b885340d0b2f0277ff2eaca78aa0ba7aa_0.c',
85 test_filename
= possible_filenames
[get_current_hash_algorithm_used()]
87 conftest_0_c
= os
.path
.join(".sconf_temp", test_filename
)
88 SConstruct_file_line
= test
.python_file_line(SConstruct_path
, 9)[:-1]
91 scons: *** Cannot update configure test "%(conftest_0_c)s" within a dry-run.
92 %(SConstruct_file_line)s
95 test
.run(arguments
='-n', status
=2, stderr
=expect
)
98 test
.checkLogAndStdout(["Checking for C library %s... " % lib
,
99 "Checking for C library hopefullynolib... "],
101 [[((".c", NCR
), (_obj
, NCR
))],
102 [((".c", NCR
), (_obj
, NCF
))]],
103 "config.log", ".sconf_temp", "SConstruct")
105 oldLog
= test
.read(test
.workpath('config.log'), mode
='r')
107 test
.run(arguments
='-n')
108 test
.checkLogAndStdout(["Checking for C library %s... " % lib
,
109 "Checking for C library hopefullynolib... "],
111 [[((".c", CR
), (_obj
, CR
))],
112 [((".c", CR
), (_obj
, CF
))]],
113 "config.log", ".sconf_temp", "SConstruct",
116 newLog
= test
.read(test
.workpath('config.log'), mode
='r')
118 print("Unexpected update of log file within a dry run")
125 # indent-tabs-mode:nil
127 # vim: set expandtab tabstop=4 shiftwidth=4: