Merged revisions 1907-1940,1942-1967 via svnmerge from
[scons.git] / test / Configure / ConfigureDryRunError.py
1 #!/usr/bin/env python
2 #
3 # __COPYRIGHT__
4 #
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:
12 #
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
15 #
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.
23 #
24
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
26
27 """
28 Verify the ConfigureDryRunError.
29 """
30
31 import os.path
32
33 import TestSCons
34
35 _obj = TestSCons._obj
36
37 test = TestSCons.TestSCons()
38
39 lib = test.Configure_lib
40
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
45
46 SConstruct_path = test.workpath('SConstruct')
47
48 test.write(SConstruct_path, """
49 env = Environment()
50 import os
51 env.AppendENVPath('PATH', os.environ['PATH'])
52 conf = Configure(env)
53 r1 = conf.CheckLib('%s') # will pass
54 r2 = conf.CheckLib('hopefullynolib') # will fail
55 env = conf.Finish()
56 if not (r1 and not r2):
57  Exit(1)
58 """ % (lib))
59
60 test.run(arguments='-n', status=2, stderr="""
61 scons: *** Cannot create configure directory ".sconf_temp" within a dry-run.
62 File "%(SConstruct_path)s", line 5, in ?
63 """ % locals())
64
65 test.must_not_exist('config.log')
66 test.subdir('.sconf_temp')
67
68 conftest_0_c = os.path.join(".sconf_temp", "conftest_0.c")
69
70 test.run(arguments='-n', status=2, stderr="""
71 scons: *** Cannot update configure test "%(conftest_0_c)s" within a dry-run.
72 File "%(SConstruct_path)s", line 6, in ?
73 """ % locals())
74
75 test.run()
76 test.checkLogAndStdout( ["Checking for C library %s... " % lib,
77                     "Checking for C library hopefullynolib... "],
78                     ["yes", "no"],
79                     [[((".c", NCR), (_obj, NCR))],
80                      [((".c", NCR), (_obj, NCF))]],
81                     "config.log", ".sconf_temp", "SConstruct")
82
83 oldLog = test.read(test.workpath('config.log'))
84
85 test.run(arguments='-n')
86 test.checkLogAndStdout( ["Checking for C library %s... " % lib,
87                     "Checking for C library hopefullynolib... "],
88                     ["yes", "no"],
89                     [[((".c", CR), (_obj, CR))],
90                      [((".c", CR), (_obj, CF))]],
91                     "config.log", ".sconf_temp", "SConstruct",
92                     doCheckLog=0)
93
94 newLog = test.read(test.workpath('config.log'))
95 if newLog != oldLog:
96     print "Unexpected update of log file within a dry run"
97     test.fail_test()
98
99 test.pass_test()