From d23e503a2499c58c9826b3b341ff33f79bc20b10 Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Wed, 25 Sep 2002 16:56:41 +0000 Subject: Windows portability --- runtest.py | 8 ++++-- src/engine/SCons/EnvironmentTests.py | 55 ++++++++++++++++++++++++++---------- src/engine/SCons/Script/__init__.py | 2 ++ src/engine/SCons/Tool/__init__.py | 2 +- test/BuildDir.py | 1 - test/TAR.py | 6 ++-- test/TARFLAGS.py | 8 ++++-- 7 files changed, 56 insertions(+), 26 deletions(-) diff --git a/runtest.py b/runtest.py index 6d15490..497668f 100644 --- a/runtest.py +++ b/runtest.py @@ -41,6 +41,7 @@ # import getopt +import glob import os import os.path import re @@ -62,7 +63,7 @@ else: # not an executable, so it's all right. lib_dir = os.path.join(sys.exec_prefix, "lib", "python" + sys.version[0:3]) -opts, tests = getopt.getopt(sys.argv[1:], "adqp:Xx:", +opts, args = getopt.getopt(sys.argv[1:], "adqp:Xx:", ['all', 'debug', 'exec=', 'quiet', 'package=']) for o, a in opts: @@ -75,8 +76,9 @@ for o, a in opts: cwd = os.getcwd() -if tests: - map(os.path.abspath, tests) +if args: + for a in args: + tests.extend(glob.glob(os.path.abspath(a))) elif all: def find_Test_py(arg, dirname, names): global tests diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index 33c14e5..1b2cd3b 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -586,27 +586,52 @@ class EnvironmentTestCase(unittest.TestCase): """Test Detect()ing tools""" test = TestCmd.TestCmd(workdir = '') test.subdir('sub1', 'sub2') - test.write(['sub1', 'xxx.exe'], "sub1/xxx.exe\n") - test.write(['sub2', 'xxx.exe'], "sub2/xxx.exe\n") - sub1 = test.workpath('sub1') sub2 = test.workpath('sub2') - env = Environment(ENV = { 'PATH' : [sub1, sub2] }) - x = env.Detect('xxx.exe') - assert x is None, x - sub2_xxx_exe = test.workpath('sub2', 'xxx.exe') - os.chmod(sub2_xxx_exe, 0755) + if sys.platform == 'win32': + test.write(['sub1', 'xxx'], "sub1/xxx\n") + test.write(['sub2', 'xxx'], "sub2/xxx\n") - env = Environment(ENV = { 'PATH' : [sub1, sub2] }) - x = env.Detect('xxx.exe') - assert x == 'xxx.exe' + env = Environment(ENV = { 'PATH' : [sub1, sub2] }) - sub1_xxx_exe = test.workpath('sub1', 'xxx.exe') - os.chmod(sub1_xxx_exe, 0755) + x = env.Detect('xxx.exe') + assert x is None, x - x = env.Detect('xxx.exe') - assert x == 'xxx.exe' + test.write(['sub2', 'xxx.exe'], "sub2/xxx.exe\n") + + env = Environment(ENV = { 'PATH' : [sub1, sub2] }) + + x = env.Detect('xxx.exe') + assert x == 'xxx.exe', x + + test.write(['sub1', 'xxx.exe'], "sub1/xxx.exe\n") + + x = env.Detect('xxx.exe') + assert x == 'xxx.exe', x + + else: + test.write(['sub1', 'xxx.exe'], "sub1/xxx.exe\n") + test.write(['sub2', 'xxx.exe'], "sub2/xxx.exe\n") + + env = Environment(ENV = { 'PATH' : [sub1, sub2] }) + + x = env.Detect('xxx.exe') + assert x is None, x + + sub2_xxx_exe = test.workpath('sub2', 'xxx.exe') + os.chmod(sub2_xxx_exe, 0755) + + env = Environment(ENV = { 'PATH' : [sub1, sub2] }) + + x = env.Detect('xxx.exe') + assert x == 'xxx.exe', x + + sub1_xxx_exe = test.workpath('sub1', 'xxx.exe') + os.chmod(sub1_xxx_exe, 0755) + + x = env.Detect('xxx.exe') + assert x == 'xxx.exe', x env = Environment(ENV = { 'PATH' : [] }) x = env.Detect('xxx.exe') diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py index 365a0b1..f0ac039 100644 --- a/src/engine/SCons/Script/__init__.py +++ b/src/engine/SCons/Script/__init__.py @@ -992,6 +992,8 @@ def _main(): sys.stderr.write(string + " Stop.\n") sys.exit(2) sys.stderr.write(string + "\n") + global exit_status + exit_status = 2 node = None if top and not node.is_under(top): if isinstance(node, SCons.Node.FS.Dir) and top.is_under(node): diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index 6b78faf..661ea96 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -144,7 +144,7 @@ def tool_list(platform, env): "prefer Microsoft tools on Windows" linkers = ['mslink', 'gnulink', 'ilink'] c_compilers = ['msvc', 'gcc', 'icc'] - assemblers = ['nasm', 'masm', 'gas'] + assemblers = ['masm', 'nasm', 'gas'] fortran_compilers = ['g77', 'ifl'] ars = ['lib', 'ar'] elif str(platform) == 'os2': diff --git a/test/BuildDir.py b/test/BuildDir.py index 8e79de9..b8e073b 100644 --- a/test/BuildDir.py +++ b/test/BuildDir.py @@ -212,7 +212,6 @@ def equal_stats(x,y): x = os.stat(x) y = os.stat(y) return (stat.S_IMODE(x[stat.ST_MODE]) == stat.S_IMODE(y[stat.ST_MODE]) and - x[stat.ST_ATIME] == y[stat.ST_ATIME] and x[stat.ST_MTIME] == y[stat.ST_MTIME]) # Make sure we did duplicate the source files in build/var2, and that their stats are the same: diff --git a/test/TAR.py b/test/TAR.py index 0d6f857..ee9e7d4 100644 --- a/test/TAR.py +++ b/test/TAR.py @@ -58,7 +58,7 @@ sys.exit(0) """) test.write('SConstruct', """ -env = Environment(TAR = r'%s mytar.py') +env = Environment(tools = ['tar'], TAR = r'%s mytar.py') env.Tar(target = 'aaa.tar', source = ['file1', 'file2']) env.Tar(target = 'aaa.tar', source = 'file3') env.Tar(target = 'bbb', source = 'sub1') @@ -95,9 +95,9 @@ os.system(string.join(sys.argv[1:], " ")) """ % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) test.write('SConstruct', """ -foo = Environment() +foo = Environment(tools = ['tar']) tar = foo.Dictionary('TAR') -bar = Environment(TAR = r'%s wrapper.py ' + tar) +bar = Environment(tools = ['tar'], TAR = r'%s wrapper.py ' + tar) foo.Tar(target = 'foo.tar', source = ['file10', 'file11']) foo.Tar(target = 'foo.tar', source = 'file12') bar.Tar(target = 'bar.tar', source = ['file13', 'file14']) diff --git a/test/TARFLAGS.py b/test/TARFLAGS.py index 6fcff43..9bf1359 100644 --- a/test/TARFLAGS.py +++ b/test/TARFLAGS.py @@ -62,7 +62,7 @@ sys.exit(0) """) test.write('SConstruct', """ -env = Environment(TAR = r'%s mytar.py', TARFLAGS = '-x') +env = Environment(tools = ['tar'], TAR = r'%s mytar.py', TARFLAGS = '-x') env.Tar(target = 'aaa.tar', source = ['file1', 'file2']) env.Tar(target = 'aaa.tar', source = 'file3') env.Tar(target = 'bbb', source = 'sub1') @@ -99,9 +99,11 @@ os.system(string.join(sys.argv[1:], " ")) """ % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) test.write('SConstruct', """ -foo = Environment() +foo = Environment(tools = ['tar']) tar = foo['TAR'] -bar = Environment(TAR = '', TARFLAGS = '%s wrapper.py ' + tar + ' -c -b 1') +bar = Environment(tools = ['tar'], + TAR = '', + TARFLAGS = '%s wrapper.py ' + tar + ' -c -b 1') foo.Tar(target = 'foo.tar', source = ['file10', 'file11']) foo.Tar(target = 'foo.tar', source = 'file12') bar.Tar(target = 'bar.tar', source = ['file13', 'file14']) -- cgit v0.12