From 77568a787451a72ef62198db424ac62bbaf50294 Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Fri, 2 May 2003 04:09:02 +0000 Subject: Fix regression tests that use test.whereis(). (Anthony Roach) --- etc/TestSCons.py | 17 +++++++++++------ src/CHANGES.txt | 3 +++ src/setupTests.py | 4 +++- test/BuildDir.py | 12 ++---------- test/F77.py | 2 +- test/F77FLAGS.py | 2 +- test/F77PATH.py | 2 +- test/SHF77.py | 2 +- test/SHF77FLAGS.py | 2 +- test/build-errors.py | 12 ++++++------ 10 files changed, 30 insertions(+), 28 deletions(-) diff --git a/etc/TestSCons.py b/etc/TestSCons.py index 4fe8b5b..a87b55a 100644 --- a/etc/TestSCons.py +++ b/etc/TestSCons.py @@ -182,17 +182,22 @@ class TestSCons(TestCmd.TestCmd): 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 diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 196c28d..0c23939 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -98,6 +98,9 @@ RELEASE 0.14 - XXX - 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 diff --git a/src/setupTests.py b/src/setupTests.py index 055475e..6457fff 100644 --- a/src/setupTests.py +++ b/src/setupTests.py @@ -32,6 +32,7 @@ import os import os.path import shutil import string +import sys import TestSCons @@ -68,7 +69,8 @@ test.subdir('root') 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) diff --git a/test/BuildDir.py b/test/BuildDir.py index 1f04c92..c10ef3e 100644 --- a/test/BuildDir.py +++ b/test/BuildDir.py @@ -37,15 +37,7 @@ else: 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) @@ -139,7 +131,7 @@ try: 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') diff --git a/test/F77.py b/test/F77.py index 0346765..b4ef9bf 100644 --- a/test/F77.py +++ b/test/F77.py @@ -144,7 +144,7 @@ test.fail_test(test.read('test6' + _exe) != "This is a .FPP file.\n") -g77 = test.where_is('g77') +g77 = test.detect('F77', 'g77') FTN_LIB = TestSCons.fortran_lib if g77: diff --git a/test/F77FLAGS.py b/test/F77FLAGS.py index b72c618..6b9253b 100644 --- a/test/F77FLAGS.py +++ b/test/F77FLAGS.py @@ -147,7 +147,7 @@ test.fail_test(test.read('test6' + _exe) != " -x -c\nThis is a .FPP file.\n") -g77 = test.where_is('g77') +g77 = test.detect('F77', 'g77') FTN_LIB = TestSCons.fortran_lib if g77: diff --git a/test/F77PATH.py b/test/F77PATH.py index f64abb0..f3dd483 100644 --- a/test/F77PATH.py +++ b/test/F77PATH.py @@ -43,7 +43,7 @@ args = prog + ' ' + subdir_prog + ' ' + variant_prog 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') diff --git a/test/SHF77.py b/test/SHF77.py index d78ef82..24ab0ec 100644 --- a/test/SHF77.py +++ b/test/SHF77.py @@ -102,7 +102,7 @@ test.fail_test(test.read('test6' + _obj) != "This is a .FPP file.\n") -g77 = test.where_is('g77') +g77 = test.detect('F77', 'g77') if g77: diff --git a/test/SHF77FLAGS.py b/test/SHF77FLAGS.py index 444f106..27c6603 100644 --- a/test/SHF77FLAGS.py +++ b/test/SHF77FLAGS.py @@ -113,7 +113,7 @@ test.fail_test(test.read('test6' + _obj) != " -x -c\nThis is a .FPP file.\n") -g77 = test.where_is('g77') +g77 = test.detect('F77', 'g77') FTN_LIB = TestSCons.fortran_lib if g77: diff --git a/test/build-errors.py b/test/build-errors.py index ac6e066..e4e1666 100644 --- a/test/build-errors.py +++ b/test/build-errors.py @@ -77,9 +77,9 @@ elif string.find(sys.platform, 'irix') != -1: 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""" @@ -106,9 +106,9 @@ elif string.find(sys.platform, 'irix') != -1: 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') @@ -134,8 +134,8 @@ elif string.find(sys.platform, 'irix') != -1: 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() -- cgit v0.12