print self.stderr()
raise TestFailed
- def detect(self, var, prog):
+ def detect(self, var, prog=None):
"""
- Detect a program named 'prog' by first checking the construction
- variable named 'var' and finally searching the path. If either method
- fails to detect the program, then false is returned, otherwise
- the programs full path is returned.
+ Detect a program named 'prog' by first checking the construction
+ variable named 'var' and finally searching the path used by
+ SCons. If either method fails to detect the program, then false
+ is returned, otherwise the full path to prog is returned. If
+ prog is None, then the value of the environment variable will be
+ used as prog.
"""
import SCons.Environment
+ env = SCons.Environment.Environment()
try:
- return SCons.Environment.Environment()[var] == prog and self.where_is(prog)
+ if prog is None:
+ prog = env[var]
+ return env[var] == prog and env.WhereIs(prog)
except KeyError:
return None
- Deprecate the old SetJobs() and GetJobs() functions in favor of
using the new generic {Set,Get}Option() functions.
+ - Fix a number of tests that searched for a Fortran compiler using the
+ external PATH instead of what SCons would use.
+
From David Snopek:
- Contribute the "Autoscons" code for Autoconf-like checking for
import os.path
import shutil
import string
+import sys
import TestSCons
root = test.workpath('root')
-standard_lib = '%s/usr/lib/python1.5/site-packages/' % root
+v = string.split(string.split(sys.version)[0], '.')
+standard_lib = '%s/usr/lib/python%s.%s/site-packages/' % (root, v[0], v[1])
standalone_lib = '%s/usr/lib/scons' % root
version_lib = '%s/usr/lib/%s' % (root, scons_version)
test = TestSCons.TestSCons()
-test.write('SConstruct', """
-try:
- print Environment()['F77']
-except:
- print 'There is no fortran compiler.'
-""")
-test.run(arguments = ".")
-f77 = test.where_is(test.stdout()[:-1])
-test.unlink('SConstruct')
+f77 = test.detect('F77')
foo11 = test.workpath('test', 'build', 'var1', 'foo1' + _exe)
foo12 = test.workpath('test', 'build', 'var1', 'foo2' + _exe)
except:
f77 = None
-if f77 and WhereIs(env['F77']):
+if f77 and env.Detect(env['F77']):
env.Command(target='b2.f', source='b2.in', action=buildIt)
env.Copy(LIBS = [r'%s']).Program(target='bar2', source='b2.f')
env.Copy(LIBS = [r'%s']).Program(target='bar1', source='b1.f')
-g77 = test.where_is('g77')
+g77 = test.detect('F77', 'g77')
FTN_LIB = TestSCons.fortran_lib
if g77:
-g77 = test.where_is('g77')
+g77 = test.detect('F77', 'g77')
FTN_LIB = TestSCons.fortran_lib
if g77:
test = TestSCons.TestSCons()
-if not test.where_is('g77'):
+if not test.detect('F77', 'g77'):
test.pass_test()
test.subdir('include', 'subdir', ['subdir', 'include'], 'inc2')
-g77 = test.where_is('g77')
+g77 = test.detect('F77', 'g77')
if g77:
-g77 = test.where_is('g77')
+g77 = test.detect('F77', 'g77')
FTN_LIB = TestSCons.fortran_lib
if g77:
scons: *** [f1] Error 127
""" % no_such_file)
else:
- test.fail_test(test.stderr() != """sh: %s: No such file or directory
+ test.fail_test(string.find(test.stderr(), """%s: No such file or directory
scons: *** [f1] Error 127
-""" % no_such_file)
+""" % no_such_file) == -1)
test.write('SConstruct2', r"""
scons: *** [f2] Error 126
""" % not_executable)
else:
- test.fail_test(test.stderr() != """sh: %s: Permission denied
+ test.fail_test(string.find(test.stderr(), """%s: Permission denied
scons: *** [f2] Error 126
-""" % not_executable)
+""" % not_executable) == -1)
test.write('SConstruct3', r"""
bld = Builder(action = '%s $SOURCES $TARGET')
scons: *** [f3] Error 126
""" % test.workdir)
else:
- test.fail_test(test.stderr() != """sh: %s: is a directory
+ test.fail_test(string.find(test.stderr(), """%s: is a directory
scons: *** [f3] Error 126
-""" % test.workdir)
+""" % test.workdir) == -1)
test.pass_test()