summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2005-03-04 02:44:26 (GMT)
committerSteven Knight <knight@baldmt.com>2005-03-04 02:44:26 (GMT)
commit3bf4475522d2a24910b147a607dcd9f0d980097f (patch)
treef84f598ecc6c449fd1784b76ca52b7330d88f230
parent101ccb287767fbe9509726a4af66f46d4caf2ea9 (diff)
downloadSCons-3bf4475522d2a24910b147a607dcd9f0d980097f.zip
SCons-3bf4475522d2a24910b147a607dcd9f0d980097f.tar.gz
SCons-3bf4475522d2a24910b147a607dcd9f0d980097f.tar.bz2
Fix Fedora Core 3 test portability.
-rw-r--r--etc/TestSCons.py71
-rw-r--r--src/engine/SCons/Tool/javac.py3
-rw-r--r--test/Builder-factories.py4
-rw-r--r--test/Java/JAR.py36
-rw-r--r--test/Java/JARFLAGS.py36
-rw-r--r--test/Java/JAVAC.py21
-rw-r--r--test/Java/JAVACFLAGS.py18
-rw-r--r--test/SWIG/SWIG.py8
-rw-r--r--test/TAR/TARFLAGS.py4
9 files changed, 120 insertions, 81 deletions
diff --git a/etc/TestSCons.py b/etc/TestSCons.py
index 28f882b..f3f3959 100644
--- a/etc/TestSCons.py
+++ b/etc/TestSCons.py
@@ -138,7 +138,21 @@ class TestSCons(TestCommon):
kw['workdir'] = ''
apply(TestCommon.__init__, [self], kw)
- def detect(self, var, prog=None):
+ def Environment(self, ENV=None, *args, **kw):
+ """
+ Return a construction Environment that optionally overrides
+ the default external environment with the specified ENV.
+ """
+ import SCons.Environment
+ import SCons.Errors
+ if not ENV is None:
+ kw['ENV'] = ENV
+ try:
+ return apply(SCons.Environment.Environment, args, kw)
+ except (SCons.Errors.UserError, SCons.Errors.InternalError):
+ return None
+
+ def detect(self, var, prog=None, ENV=None):
"""
Detect a program named 'prog' by first checking the construction
variable named 'var' and finally searching the path used by
@@ -147,9 +161,7 @@ class TestSCons(TestCommon):
prog is None, then the value of the environment variable will be
used as prog.
"""
-
- import SCons.Environment
- env = SCons.Environment.Environment()
+ env = self.Environment(ENV)
try:
if prog is None:
prog = env[var]
@@ -157,26 +169,34 @@ class TestSCons(TestCommon):
except KeyError:
return None
- def detect_tool(self, tool, prog=None):
+ def detect_tool(self, tool, prog=None, ENV=None):
"""
Given a tool (i.e., tool specification that would be passed
- to the "tools=" parameter of Environment()) and one a program that
+ to the "tools=" parameter of Environment()) and a program that
corresponds to that tool, return true if and only if we can find
that tool using Environment.Detect().
- By default, progs is set to the value passed into the tools parameter.
+ By default, prog is set to the value passed into the tools parameter.
"""
if not prog:
prog = tool
- import SCons.Environment
- import SCons.Errors
- try:
- env=SCons.Environment.Environment(tools=[tool])
- except (SCons.Errors.UserError, SCons.Errors.InternalError):
+ env = self.Environment(ENV, tools=[tool])
+ if env is None:
return None
return env.Detect([prog])
+ def where_is(self, prog, path=None):
+ """
+ Given a program, search for it in the specified external PATH,
+ or in the actual external PATH is none is specified.
+ """
+ import SCons.Environment
+ env = SCons.Environment.Environment()
+ if path is None:
+ path = os.environ['PATH']
+ return env.WhereIs(prog, path)
+
def wrap_stdout(self, build_str = "", read_str = "", error = 0, cleaning = 0):
"""Wraps standard output string(s) in the normal
"Reading ... done" and "Building ... done" strings
@@ -222,6 +242,33 @@ class TestSCons(TestCommon):
kw['match'] = self.match_re_dotall
apply(self.run, [], kw)
+ def java_ENV(self):
+ """
+ Return a default external environment that uses a local Java SDK
+ in preference to whatever's found in the default PATH.
+ """
+ import SCons.Environment
+ env = SCons.Environment.Environment()
+ java_path = [
+ '/usr/local/j2sdk1.4.2/bin',
+ '/usr/local/j2sdk1.4.1/bin',
+ '/usr/local/j2sdk1.3.1/bin',
+ '/usr/local/j2sdk1.3.0/bin',
+ '/usr/local/j2sdk1.2.2/bin',
+ '/usr/local/j2sdk1.2/bin',
+ '/usr/local/j2sdk1.1.8/bin',
+ '/usr/local/j2sdk1.1.7/bin',
+ '/usr/local/j2sdk1.1.6/bin',
+ '/usr/local/j2sdk1.1.5/bin',
+ '/usr/local/j2sdk1.1.4/bin',
+ '/usr/local/j2sdk1.1.3/bin',
+ '/usr/local/j2sdk1.1.2/bin',
+ '/usr/local/j2sdk1.1.1/bin',
+ env['ENV']['PATH'],
+ ]
+ env['ENV']['PATH'] = string.join(java_path, os.pathsep)
+ return env['ENV']
+
# In some environments, $AR will generate a warning message to stderr
# if the library doesn't previously exist and is being created. One
# way to fix this is to tell AR to be quiet (sometimes the 'c' flag),
diff --git a/src/engine/SCons/Tool/javac.py b/src/engine/SCons/Tool/javac.py
index e6a0fc3..8741c23 100644
--- a/src/engine/SCons/Tool/javac.py
+++ b/src/engine/SCons/Tool/javac.py
@@ -61,6 +61,9 @@ def emit_java_classes(target, source, env):
java_files = filter(lambda n, js=js:
_my_normcase(n[-len(js):]) == js,
names)
+ # The on-disk entries come back in arbitrary order. Sort them
+ # so our target and source lists are determinate.
+ java_files.sort()
mydir = dirnode.Dir(dirname)
java_paths = map(lambda f, d=mydir: d.File(f), java_files)
arg.extend(java_paths)
diff --git a/test/Builder-factories.py b/test/Builder-factories.py
index 8bdcd3a..41f83a2 100644
--- a/test/Builder-factories.py
+++ b/test/Builder-factories.py
@@ -48,7 +48,9 @@ MakeDirectory = Builder(action=mkdir, target_factory=Dir)
def collect(env, source, target):
out = open(str(target[0]), 'wb')
dir = str(source[0])
- for f in os.listdir(dir):
+ files = os.listdir(dir)
+ files.sort()
+ for f in files:
f = os.path.join(dir, f)
out.write(open(f, 'r').read())
out.close()
diff --git a/test/Java/JAR.py b/test/Java/JAR.py
index ea51213..42f2c5a 100644
--- a/test/Java/JAR.py
+++ b/test/Java/JAR.py
@@ -119,29 +119,23 @@ test.run(arguments='classes.jar')
test.must_match('classes.jar',
'cvfm classes.jar foo.mf -C testdir bar.class\n')
-if test.detect_tool('javac'):
- where_javac = test.detect('JAVAC', 'javac')
+ENV = test.java_ENV()
+
+if test.detect_tool('javac', ENV=ENV):
+ where_javac = test.detect('JAVAC', 'javac', ENV=ENV)
else:
- import SCons.Environment
- env = SCons.Environment.Environment()
- where_javac = env.WhereIs('javac', os.environ['PATH'])
- if not where_javac:
- where_javac = env.WhereIs('javac', '/usr/local/j2sdk1.3.1/bin')
- if not where_javac:
- print "Could not find Java javac, skipping test(s)."
- test.pass_test(1)
-
-if test.detect_tool('jar'):
- where_jar = test.detect('JAR', 'jar')
+ where_javac = test.where_is('javac')
+if not where_javac:
+ print "Could not find Java javac, skipping test(s)."
+ test.pass_test(1)
+
+if test.detect_tool('jar', ENV=ENV):
+ where_jar = test.detect('JAR', 'jar', ENV=ENV)
else:
- import SCons.Environment
- env = SCons.Environment.Environment()
- where_jar = env.WhereIs('jar', os.environ['PATH'])
- if not where_jar:
- where_jar = env.WhereIs('jar', '/usr/local/j2sdk1.3.1/bin')
- if not where_jar:
- print "Could not find Java jar, skipping test(s)."
- test.pass_test(1)
+ where_jar = test.where_is('jar')
+if not where_jar:
+ print "Could not find Java jar, skipping test(s)."
+ test.pass_test(1)
test.write("wrapper.py", """\
diff --git a/test/Java/JARFLAGS.py b/test/Java/JARFLAGS.py
index 7e3669d..9a846ec 100644
--- a/test/Java/JARFLAGS.py
+++ b/test/Java/JARFLAGS.py
@@ -32,29 +32,23 @@ test = TestSCons.TestSCons()
test.subdir('src')
-if test.detect_tool('javac'):
- where_javac = test.detect('JAVAC', 'javac')
+ENV = test.java_ENV()
+
+if test.detect_tool('javac', ENV=ENV):
+ where_javac = test.detect('JAVAC', 'javac', ENV=ENV)
else:
- import SCons.Environment
- env = SCons.Environment.Environment()
- where_javac = env.WhereIs('javac', os.environ['PATH'])
- if not where_javac:
- where_javac = env.WhereIs('javac', '/usr/local/j2sdk1.3.1/bin')
- if not where_javac:
- print "Could not find Java javac, skipping test(s)."
- test.pass_test(1)
-
-if test.detect_tool('jar'):
- where_jar = test.detect('JAR', 'jar')
+ where_javac = test.where_is('javac')
+if not where_javac:
+ print "Could not find Java javac, skipping test(s)."
+ test.pass_test(1)
+
+if test.detect_tool('jar', ENV=ENV):
+ where_jar = test.detect('JAR', 'jar', ENV=ENV)
else:
- import SCons.Environment
- env = SCons.Environment.Environment()
- where_jar = env.WhereIs('jar', os.environ['PATH'])
- if not where_jar:
- where_jar = env.WhereIs('jar', '/usr/local/j2sdk1.3.1/bin')
- if not where_jar:
- print "Could not find Java jar, skipping test(s)."
- test.pass_test(1)
+ where_javac = test.where_is('jar')
+if not where_jar:
+ print "Could not find Java jar, skipping test(s)."
+ test.pass_test(1)
test.write('SConstruct', """
env = Environment(tools = ['javac', 'jar'],
diff --git a/test/Java/JAVAC.py b/test/Java/JAVAC.py
index 779045f..a89ed52 100644
--- a/test/Java/JAVAC.py
+++ b/test/Java/JAVAC.py
@@ -91,18 +91,17 @@ line 3
test.must_match('test2.class', "test2.JAVA\nline 3\n")
-if test.detect_tool('javac'):
- where_javac = test.detect('JAVAC', 'javac')
+
+ENV = test.java_ENV()
+
+if test.detect_tool('javac', ENV=ENV):
+ where_javac = test.detect('JAVAC', 'javac', ENV=ENV)
else:
- import SCons.Environment
- env = SCons.Environment.Environment()
- where_javac = env.WhereIs('javac', os.environ['PATH'])
- if not where_javac:
- where_javac = env.WhereIs('javac', '/usr/local/j2sdk1.3.1/bin')
- if not where_javac:
- print "Could not find Java, skipping test(s)."
- test.pass_test(1)
-
+ where_javac = test.where_is('javac')
+if not where_javac:
+ print "Could not find Java javac, skipping test(s)."
+ test.pass_test(1)
+
test.write("wrapper.py", """\
diff --git a/test/Java/JAVACFLAGS.py b/test/Java/JAVACFLAGS.py
index ef084cd..d0ab847 100644
--- a/test/Java/JAVACFLAGS.py
+++ b/test/Java/JAVACFLAGS.py
@@ -30,17 +30,15 @@ import TestSCons
test = TestSCons.TestSCons()
-if test.detect_tool('javac'):
- where_javac = test.detect('JAVAC', 'javac')
+ENV = test.java_ENV()
+
+if test.detect_tool('javac', ENV=ENV):
+ where_javac = test.detect('JAVAC', 'javac', ENV=ENV)
else:
- import SCons.Environment
- env = SCons.Environment.Environment()
- where_javac = env.WhereIs('javac', os.environ['PATH'])
- if not where_javac:
- where_javac = env.WhereIs('javac', '/usr/local/j2sdk1.3.1/bin')
- if not where_javac:
- print "Could not find Java javac, skipping test(s)."
- test.pass_test(1)
+ where_javac = test.where_is('javac')
+if not where_javac:
+ print "Could not find Java javac, skipping test(s)."
+ test.pass_test(1)
test.subdir('src')
diff --git a/test/SWIG/SWIG.py b/test/SWIG/SWIG.py
index af76d6c..21a6a18 100644
--- a/test/SWIG/SWIG.py
+++ b/test/SWIG/SWIG.py
@@ -121,15 +121,15 @@ if swig:
version = sys.version[:3] # see also sys.prefix documentation
# handle testing on other platforms:
+ ldmodule_prefix = '_'
+
frameworks = ''
- ldmodule_prefix = ''
platform_sys_prefix = sys.prefix
if sys.platform == 'darwin':
# OS X has a built-in Python but no static libpython
# so you should link to it using apple's 'framework' scheme.
# (see top of file for further explanation)
frameworks = '-framework Python'
- ldmodule_prefix = '_'
platform_sys_prefix = '/System/Library/Frameworks/Python.framework/Versions/%s/' % version
test.write("wrapper.py",
@@ -191,7 +191,7 @@ extern char *bar_string();
test.run(arguments = ldmodule_prefix+'foo' + _dll)
- test.fail_test(os.path.exists(test.workpath('wrapper.out')))
+ test.must_not_exist(test.workpath('wrapper.out'))
test.run(program = python, stdin = """\
import foo
@@ -204,7 +204,7 @@ This is foo.c!
test.run(arguments = ldmodule_prefix+'bar' + _dll)
- test.fail_test(test.read('wrapper.out') != "wrapper.py\n")
+ test.must_match('wrapper.out', "wrapper.py\n")
test.run(program = python, stdin = """\
import foo
diff --git a/test/TAR/TARFLAGS.py b/test/TAR/TARFLAGS.py
index 5864241..fcf7394 100644
--- a/test/TAR/TARFLAGS.py
+++ b/test/TAR/TARFLAGS.py
@@ -49,7 +49,9 @@ for opt, arg in cmd_opts:
else: opt_string = opt_string + ' ' + opt
def process(outfile, name):
if os.path.isdir(name):
- for entry in os.listdir(name):
+ entries = os.listdir(name)
+ entries.sort()
+ for entry in entries:
process(outfile, os.path.join(name, entry))
else:
outfile.write(open(name, 'rb').read())