summaryrefslogtreecommitdiffstats
path: root/test/Configure.py
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2003-05-16 17:40:05 (GMT)
committerSteven Knight <knight@baldmt.com>2003-05-16 17:40:05 (GMT)
commit178bb4ca29174ac1913693343f5d1eb1a3c18237 (patch)
tree9304278fee8d8e867662dfbb5276e7827a504297 /test/Configure.py
parent487877ee4058bf8586c3a44b44202d161ec2441f (diff)
downloadSCons-178bb4ca29174ac1913693343f5d1eb1a3c18237.zip
SCons-178bb4ca29174ac1913693343f5d1eb1a3c18237.tar.gz
SCons-178bb4ca29174ac1913693343f5d1eb1a3c18237.tar.bz2
SConf fixes. (Christoph Wiedemann)
Diffstat (limited to 'test/Configure.py')
-rw-r--r--test/Configure.py123
1 files changed, 101 insertions, 22 deletions
diff --git a/test/Configure.py b/test/Configure.py
index b78cdcb..97333ab 100644
--- a/test/Configure.py
+++ b/test/Configure.py
@@ -36,23 +36,48 @@ if sys.platform == 'win32':
else:
lib = 'm'
-test = TestSCons.TestSCons()
+# to use cygwin compilers on cmd.exe -> uncomment following line
+#lib = 'm'
+
+oldPwd = os.getcwd()
python = TestSCons.python
+test = None
+
+def reset(dot = 1):
+ global test, oldPwd
+ os.chdir( oldPwd )
+ TestSCons.scons = None
+ test = TestSCons.TestSCons()
+ if dot == 1:
+ test.match_func = TestCmd.match_re_dotall
+
+
+def checkFiles(test, files):
+ for f in files:
+ test.fail_test( not os.path.isfile( test.workpath(f) ) )
+
def checkLog( test, logfile, numUpToDate, numCache ):
- test.fail_test(not os.path.exists(test.workpath('config.log')))
+ test.fail_test(not os.path.exists(test.workpath(logfile)))
log = test.read(test.workpath(logfile))
- test.fail_test( len( re.findall( "is up to date", log ) ) != numUpToDate )
- test.fail_test( len( re.findall( "\(cached\): Building \S+ failed in a previous run.", log ) ) != numCache )
-
+ try:
+ test.fail_test( len( re.findall( "is up to date", log ) ) != numUpToDate )
+ test.fail_test( len( re.findall( "\(cached\): Building \S+ failed in a previous run.", log ) ) != numCache )
+ except:
+ #print "contents of log ", test.workpath(logfile), "\n", log
+ raise
try:
# 1.1 if checks are ok, the cache mechanism should work
+ reset(dot=0)
+
test.write( 'SConstruct', """
env = Environment()
+import os
+env['ENV']['PATH'] = os.environ['PATH']
conf = Configure(env)
r1 = conf.CheckLibWithHeader( '%s', 'math.h', 'c' )
r2 = conf.CheckLibWithHeader( None, 'math.h', 'c' )
@@ -63,16 +88,16 @@ r6 = conf.CheckCXXHeader( 'vector' )
env = conf.Finish()
if not (r1 and r2 and r3 and r4 and r5 and r6):
Exit(1)
-""" % (lib, lib))
+""" % (lib,lib))
required_stdout = test.wrap_stdout(build_str='scons: "." is up to date.\n',
read_str=
"""Checking for main(); in library %s (header math.h) ... ok
Checking for main(); in library None (header math.h) ... ok
-Checking for main in library %s... ok
-Checking for main in library None... ok
-Checking for C header math.h... ok
-Checking for C header vector... ok
+Checking for main in library %s ... ok
+Checking for main in library None ... ok
+Checking for C header math.h ... ok
+Checking for C++ header vector ... ok
""" % (lib, lib))
test.run(stdout = required_stdout)
@@ -83,9 +108,13 @@ Checking for C header vector... ok
# 1.2 if checks are not ok, the cache mechanism should work as well
# (via explicit cache)
+ reset()
+
test.write( 'SConstruct', """
env = Environment()
+import os
+env['ENV']['PATH'] = os.environ['PATH']
conf = Configure(env)
r1 = conf.CheckCHeader( 'no_std_c_header.h' ) # leads to compile error
r2 = conf.CheckLib( 'no_c_library_SAFFDG' ) # leads to link error
@@ -97,8 +126,8 @@ if not (not r1 and not r2):
required_stdout = test.wrap_stdout(build_str='scons: "." is up to date.\n',
read_str=
- """Checking for C header no_std_c_header.h... failed
-Checking for main in library no_c_library_SAFFDG... failed
+ """Checking for C header no_std_c_header.h ... failed
+Checking for main in library no_c_library_SAFFDG ... failed
""")
test.run(stdout = required_stdout)
@@ -109,8 +138,13 @@ Checking for main in library no_c_library_SAFFDG... failed
# 2.1 test that normal builds work together with Sconf
+ reset()
+
+
test.write( 'SConstruct', """
env = Environment()
+import os
+env['ENV']['PATH'] = os.environ['PATH']
conf = Configure(env)
r1 = conf.CheckCHeader( 'math.h' )
r2 = conf.CheckCHeader( 'no_std_c_header.h' ) # leads to compile error
@@ -132,8 +166,8 @@ int main() {
test.match_func = TestCmd.match_re_dotall
required_stdout = test.wrap_stdout(build_str='.*',
read_str=
- """Checking for C header math.h... ok
-Checking for C header no_std_c_header.h... failed
+ """Checking for C header math.h ... ok
+Checking for C header no_std_c_header.h ... failed
""")
test.run( stdout = required_stdout )
checkLog( test, 'config.log', 0, 0 )
@@ -143,8 +177,13 @@ Checking for C header no_std_c_header.h... failed
# 2.2 test that BuildDir builds work together with Sconf
+ reset()
+
+
test.write( 'SConstruct', """
env = Environment()
+import os
+env['ENV']['PATH'] = os.environ['PATH']
BuildDir( 'build', '.' )
conf = Configure(env, conf_dir='build/config.tests', log_file='build/config.log')
r1 = conf.CheckCHeader( 'math.h' )
@@ -167,8 +206,8 @@ int main() {
""")
required_stdout = test.wrap_stdout(build_str='.*',
read_str=
- """Checking for C header math.h... ok
-Checking for C header no_std_c_header.h... failed
+ """Checking for C header math.h ... ok
+Checking for C header no_std_c_header.h ... failed
""")
test.run( stdout = required_stdout )
checkLog( test, 'build/config.log', 0, 0 )
@@ -176,26 +215,64 @@ Checking for C header no_std_c_header.h... failed
test.run( stdout = required_stdout )
checkLog( test, 'build/config.log', 3, 1 )
+ # 2.3 test that Configure calls in SConscript files work
+ # even if BuildDir is set
+ reset()
+
+
+ test.subdir( 'sub' )
+ test.write( 'SConstruct', """
+BuildDir( 'build', '.' )
+SConscript( 'build/SConscript' )
+""")
+ test.write( 'SConscript', """
+SConscript( 'sub/SConscript' )
+""")
+ test.write( 'sub/SConscript', """
+env = Environment()
+import os
+env['ENV']['PATH'] = os.environ['PATH']
+conf = Configure( env )
+conf.CheckCHeader( 'math.h' )
+env = conf.Finish()
+env.Program( 'TestProgram', 'TestProgram.c' )
+""")
+ test.write( 'sub/TestProgram.h', """
+/* Just a test header */
+""")
+ test.write( 'sub/TestProgram.c', """
+#include "TestProgram.h"
+#include <stdio.h>
+
+int main() {
+ printf( "Hello\\n" );
+}
+""")
+ test.run()
+ checkFiles( test, [".sconf_temp/.cache", "config.log"] )
# 3.1 test custom tests
+ reset()
+
+
compileOK = '#include <stdio.h>\\nint main() {printf("Hello");return 0;}'
compileFAIL = "syntax error"
linkOK = compileOK
linkFAIL = "void myFunc(); int main() { myFunc(); }"
runOK = compileOK
runFAIL = "int main() { return 1; }"
- test.write( 'pyAct.py', 'import sys\nopen(sys.argv[1], "w").write(sys.argv[2] + "\\n"),\nsys.exit(int(sys.argv[2]))\n' )
- test.write( 'SConstruct', """
+ test.write('pyAct.py', 'import sys\nprint sys.argv[1]\nsys.exit(int(sys.argv[1]))\n')
+ test.write('SConstruct', """
def CheckCustom(test):
- test.Message( 'Executing MyTest...' )
+ test.Message( 'Executing MyTest ... ' )
retCompileOK = test.TryCompile( '%s', '.c' )
retCompileFAIL = test.TryCompile( '%s', '.c' )
retLinkOK = test.TryLink( '%s', '.c' )
retLinkFAIL = test.TryLink( '%s', '.c' )
(retRunOK, outputRunOK) = test.TryRun( '%s', '.c' )
(retRunFAIL, outputRunFAIL) = test.TryRun( '%s', '.c' )
- (retActOK, outputActOK) = test.TryAction( '%s pyAct.py $TARGET 0' )
- (retActFAIL, outputActFAIL) = test.TryAction( '%s pyAct.py $TARGET 1' )
+ (retActOK, outputActOK) = test.TryAction( '%s pyAct.py 0 > $TARGET' )
+ (retActFAIL, outputActFAIL) = test.TryAction( '%s pyAct.py 1 > $TARGET' )
resOK = retCompileOK and retLinkOK and retRunOK and outputRunOK=="Hello"
resOK = resOK and retActOK and int(outputActOK)==0
resFAIL = retCompileFAIL or retLinkFAIL or retRunFAIL or outputRunFAIL!=""
@@ -204,13 +281,15 @@ def CheckCustom(test):
return resOK and not resFAIL
env = Environment()
+import os
+env['ENV']['PATH'] = os.environ['PATH']
conf = Configure( env, custom_tests={'CheckCustom' : CheckCustom} )
conf.CheckCustom()
env = conf.Finish()
""" % (compileOK, compileFAIL, linkOK, linkFAIL, runOK, runFAIL,
python, python ) )
required_stdout = test.wrap_stdout(build_str='.*',
- read_str="Executing MyTest...ok\n")
+ read_str="Executing MyTest ... ok\n")
test.run(stdout = required_stdout)
checkLog( test, 'config.log', 0, 0 )