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 that Configure calls in SConscript files work when used
38 test = TestSCons.TestSCons(match = TestSCons.match_re_dotall)
40 test.subdir( 'sub', ['sub', 'local'] )
42 NCR = test.NCR # non-cached rebuild
43 CR = test.CR # cached rebuild (up to date)
44 NCF = test.NCF # non-cached build failure
45 CF = test.CF # cached build failure
47 test.write('SConstruct', """\
50 env = Environment(options=opts)
51 if env['chdir'] == 'yes':
55 VariantDir( 'build', '.' )
56 SConscript( 'build/SConscript' )
59 test.write(['sub', 'local', 'local_header.h'], "/* Hello World */" )
61 test.write('SConscript', """\
62 SConscript( 'sub/SConscript' )
65 test.write(['sub', 'SConscript'], """\
66 def CustomTest(context):
67 context.Message('Executing Custom Test ... ')
68 ret = context.TryCompile('#include "local_header.h"', '.c')
72 env = Environment(FOO='fff')
73 env.Append( CPPPATH='local' )
75 env.AppendENVPath('PATH', os.environ['PATH'])
76 conf = Configure( env, custom_tests = {'CustomTest' : CustomTest,
77 '$FOO' : CustomTest} )
78 if hasattr(conf, 'fff'):
79 conf.Message('$FOO should not have been expanded!')
81 if not conf.CheckCHeader( 'math.h' ):
83 if conf.CheckCHeader( 'no_std_c_header.h' ):
85 if not conf.CustomTest():
88 env.Program( 'TestProgram', 'TestProgram.c' )
91 test.write(['sub', 'TestProgram.h'], """\
92 /* Just a test header */
95 test.write(['sub', 'TestProgram.c'], """\
96 #include "TestProgram.h"
100 printf( "Hello\\n" );
104 # first with SConscriptChdir(0)
105 test.run(arguments='chdir=no')
106 test.checkLogAndStdout( ["Checking for C header file math.h... ",
107 "Checking for C header file no_std_c_header.h... ",
108 "Executing Custom Test ... "],
109 ["yes", "no", "yes"],
110 [[((".c", NCR), (_obj, NCR))],
111 [((".c", NCR), (_obj, NCF))],
112 [((".c", NCR), (_obj, NCR))]],
115 os.path.join("build", "sub", "SConscript"))
117 test.run(arguments='chdir=no')
118 test.checkLogAndStdout( ["Checking for C header file math.h... ",
119 "Checking for C header file no_std_c_header.h... ",
120 "Executing Custom Test ... "],
121 ["yes", "no", "yes"],
122 [[((".c", CR), (_obj, CR))],
123 [((".c", CR), (_obj, CF))],
124 [((".c", CR), (_obj, CR))]],
127 os.path.join("build", "sub", "SConscript"))
130 shutil.rmtree(test.workpath(".sconf_temp"))
131 test.unlink(".sconsign.dblite")
133 # now with SConscriptChdir(1)
134 test.run(arguments='chdir=yes')
135 test.checkLogAndStdout( ["Checking for C header file math.h... ",
136 "Checking for C header file no_std_c_header.h... ",
137 "Executing Custom Test ... "],
138 ["yes", "no", "yes"],
139 [[((".c", NCR), (_obj, NCR))],
140 [((".c", NCR), (_obj, NCF))],
141 [((".c", NCR), (_obj, NCR))]],
144 os.path.join("build", "sub", "SConscript"))
146 test.run(arguments='chdir=yes')
147 test.checkLogAndStdout( ["Checking for C header file math.h... ",
148 "Checking for C header file no_std_c_header.h... ",
149 "Executing Custom Test ... "],
150 ["yes", "no", "yes"],
151 [[((".c", CR), (_obj, CR))],
152 [((".c", CR), (_obj, CF))],
153 [((".c", CR), (_obj, CR))]],
156 os.path.join("build", "sub", "SConscript"))