summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Noel <GregNoel@tigris.org>2010-04-21 15:13:26 (GMT)
committerGreg Noel <GregNoel@tigris.org>2010-04-21 15:13:26 (GMT)
commit57f9a905465a6022db0f0033c956afaecadc5d70 (patch)
treeed317ae6759a0bb9ba2e8a20a93a5f2b6981c876
parentfcd10ca3c39538542594aec5f894fc00fa58bdb1 (diff)
downloadSCons-57f9a905465a6022db0f0033c956afaecadc5d70.zip
SCons-57f9a905465a6022db0f0033c956afaecadc5d70.tar.gz
SCons-57f9a905465a6022db0f0033c956afaecadc5d70.tar.bz2
http://scons.tigris.org/issues/show_bug.cgi?id=2345
Pass the python executable from the -P option to runtest to TestCmd.py. Create the escaped executable name in TestCmd.py as well. Pass those two values into derived test modules. Fix cascade problems in test scripts due to incorrect assumptions about the name of the executable.
-rw-r--r--QMTest/TestCmd.py56
-rw-r--r--QMTest/TestCommon.py3
-rw-r--r--QMTest/TestRuntest.py5
-rw-r--r--QMTest/TestSCons.py2
-rw-r--r--QMTest/TestSCons_time.py13
-rw-r--r--runtest.py1
-rw-r--r--src/engine/SCons/Util.py2
-rw-r--r--src/engine/SCons/compat/_scons_subprocess.py2
-rw-r--r--test/Builder/multi/same-overrides.py4
-rw-r--r--test/VariantDir/reflect.py8
-rw-r--r--test/scons-time/run/option/verbose.py3
11 files changed, 40 insertions, 59 deletions
diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py
index e715acc..0d07be6 100644
--- a/QMTest/TestCmd.py
+++ b/QMTest/TestCmd.py
@@ -253,7 +253,8 @@ __all__ = [
'match_exact',
'match_re',
'match_re_dotall',
- 'python_executable',
+ 'python',
+ '_python_',
'TestCmd'
]
@@ -512,13 +513,31 @@ def diff_re(a, b, fromfile='', tofile='',
i = i+1
return result
-if os.name == 'java':
-
- python_executable = os.path.join(sys.prefix, 'jython')
-
+if os.name == 'posix':
+ def escape(arg):
+ "escape shell special characters"
+ slash = '\\'
+ special = '"$'
+ arg = arg.replace(slash, slash+slash)
+ for c in special:
+ arg = arg.replace(c, slash+c)
+ if re_space.search(arg):
+ arg = '"' + arg + '"'
+ return arg
else:
+ # Windows does not allow special characters in file names
+ # anyway, so no need for an escape function, we will just quote
+ # the arg.
+ def escape(arg):
+ if re_space.search(arg):
+ arg = '"' + arg + '"'
+ return arg
- python_executable = sys.executable
+if os.name == 'java':
+ python = os.path.join(sys.prefix, 'jython')
+else:
+ python = os.environ.get("python_executable", sys.executable)
+_python_ = escape(python)
if sys.platform == 'win32':
@@ -913,30 +932,7 @@ class TestCmd(object):
width = self.banner_width
return s + self.banner_char * (width - len(s))
- if os.name == 'posix':
-
- def escape(self, arg):
- "escape shell special characters"
- slash = '\\'
- special = '"$'
-
- arg = arg.replace(slash, slash+slash)
- for c in special:
- arg = arg.replace(c, slash+c)
-
- if re_space.search(arg):
- arg = '"' + arg + '"'
- return arg
-
- else:
-
- # Windows does not allow special characters in file names
- # anyway, so no need for an escape function, we will just quote
- # the arg.
- def escape(self, arg):
- if re_space.search(arg):
- arg = '"' + arg + '"'
- return arg
+ escape = staticmethod(escape)
def canonicalize(self, path):
if is_List(path):
diff --git a/QMTest/TestCommon.py b/QMTest/TestCommon.py
index 6b452f7..0bc2429 100644
--- a/QMTest/TestCommon.py
+++ b/QMTest/TestCommon.py
@@ -60,7 +60,8 @@ provided by the TestCommon class:
The TestCommon module also provides the following variables
- TestCommon.python_executable
+ TestCommon.python
+ TestCommon._python_
TestCommon.exe_suffix
TestCommon.obj_suffix
TestCommon.shobj_prefix
diff --git a/QMTest/TestRuntest.py b/QMTest/TestRuntest.py
index 11f8ab2..c8b5893 100644
--- a/QMTest/TestRuntest.py
+++ b/QMTest/TestRuntest.py
@@ -26,14 +26,9 @@ from TestCommon import *
from TestCommon import __all__
__all__.extend([ 'TestRuntest',
- 'python',
'pythonstring',
- '_python_',
])
-python = python_executable
-_python_ = '"' + python_executable + '"'
-
if re.search('\s', python):
pythonstring = _python_
else:
diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py
index fa3163b..a8bfd46 100644
--- a/QMTest/TestSCons.py
+++ b/QMTest/TestSCons.py
@@ -73,8 +73,6 @@ else:
machine = uname()[4]
machine = machine_map.get(machine, machine)
-python = python_executable
-_python_ = '"' + python_executable + '"'
_exe = exe_suffix
_obj = obj_suffix
_shobj = shobj_suffix
diff --git a/QMTest/TestSCons_time.py b/QMTest/TestSCons_time.py
index e846ab5..ce9e0df 100644
--- a/QMTest/TestSCons_time.py
+++ b/QMTest/TestSCons_time.py
@@ -22,20 +22,9 @@ import sys
from TestCommon import *
from TestCommon import __all__
-__all__.extend([ 'TestSCons',
- 'python',
- '_exe',
- '_obj',
- '_shobj',
- 'lib_',
- '_lib',
- 'dll_',
- '_dll'
+__all__.extend([ 'TestSCons_time',
])
-python = python_executable
-_python_ = '"' + python_executable + '"'
-
SConstruct = """\
import os
print "SConstruct file directory:", os.getcwd()
diff --git a/runtest.py b/runtest.py
index 32e99d6..e62ce92 100644
--- a/runtest.py
+++ b/runtest.py
@@ -773,6 +773,7 @@ if not python:
python = os.path.join(sys.prefix, 'jython')
else:
python = sys.executable
+os.environ["python_executable"] = python
# time.clock() is the suggested interface for doing benchmarking timings,
# but time.time() does a better job on Linux systems, so let that be
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py
index 20be4e4..1167f3a 100644
--- a/src/engine/SCons/Util.py
+++ b/src/engine/SCons/Util.py
@@ -474,7 +474,7 @@ else:
# Profiling shows that there is an impressive speed-up of 2x
# when explicitely checking for strings instead of just not
# sequence when the argument (i.e. obj) is already a string.
- # But, if obj is a not string than it is twice as fast to
+ # But, if obj is a not string then it is twice as fast to
# check only for 'not sequence'. The following code therefore
# assumes that the obj argument is a string must of the time.
return isinstance(obj, StringTypes) or not isinstance(obj, SequenceTypes)
diff --git a/src/engine/SCons/compat/_scons_subprocess.py b/src/engine/SCons/compat/_scons_subprocess.py
index 97eb498..2106636 100644
--- a/src/engine/SCons/compat/_scons_subprocess.py
+++ b/src/engine/SCons/compat/_scons_subprocess.py
@@ -809,7 +809,7 @@ class Popen(object):
startupinfo.wShowWindow = SW_HIDE
comspec = os.environ.get("COMSPEC", "cmd.exe")
args = comspec + " /c " + args
- if (GetVersion() >= 0x80000000 or
+ if (GetVersion() >= 0x80000000L or
os.path.basename(comspec).lower() == "command.com"):
# Win9x, or using command.com on NT. We need to
# use the w9xpopen intermediate program. For more
diff --git a/test/Builder/multi/same-overrides.py b/test/Builder/multi/same-overrides.py
index 9a428a2..707a7e7 100644
--- a/test/Builder/multi/same-overrides.py
+++ b/test/Builder/multi/same-overrides.py
@@ -54,8 +54,8 @@ env.B(target = 'file4.out', source = 'file4b.in', foo=3)
test.write('file4a.in', 'file4a.in\n')
test.write('file4b.in', 'file4b.in\n')
-python_expr = TestSCons.python.replace('\\', '\\\\')
-act = TestSCons.re_escape('"%s" build.py \$foo \$TARGET \$SOURCES' % python_expr)
+python_expr = _python_.replace('\\', '\\\\')
+act = TestSCons.re_escape('%s build.py \$foo \$TARGET \$SOURCES' % python_expr)
expect = ("""
scons: warning: Two different environments were specified for target file4.out,
diff --git a/test/VariantDir/reflect.py b/test/VariantDir/reflect.py
index 51a1bc8..e7ff6db 100644
--- a/test/VariantDir/reflect.py
+++ b/test/VariantDir/reflect.py
@@ -90,9 +90,9 @@ INC_CNI = re.escape(os.path.join('INC_dir1', 'dir2', 'dir1', 'dir2_CNI'))
# The .+ after mycc\\.py below handles /nologo flags from Visual C/C++.
expect = test.wrap_stdout("""\
scons: building associated VariantDir targets: %(targets)s
-"%(re_python)s" mycc\\.py.* %(INC_CNI)s.*
+%(re_python)s mycc\\.py.* %(INC_CNI)s.*
Compile
-"%(re_python)s" mylink\\.py .+
+%(re_python)s mylink\\.py .+
Link
""" % locals())
@@ -120,9 +120,9 @@ INC_CNI = re.escape(os.path.join('INC_dir1', 'dir2_CNI'))
test.run(arguments = '',
stdout=test.wrap_stdout("""\
scons: building associated VariantDir targets: %(targets)s
-"%(re_python)s" mycc\\.py.* %(INC_CNI)s.*
+%(re_python)s mycc\\.py.* %(INC_CNI)s.*
Compile
-"%(re_python)s" mylink\\.py .+
+%(re_python)s mylink\\.py .+
Link
""" % locals()),
match=TestSCons.match_re,
diff --git a/test/scons-time/run/option/verbose.py b/test/scons-time/run/option/verbose.py
index 7f693d1..5fc6d64 100644
--- a/test/scons-time/run/option/verbose.py
+++ b/test/scons-time/run/option/verbose.py
@@ -28,11 +28,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
Verify that the run -v and --verbose options display command output.
"""
+import sys
import re
import TestSCons_time
-_python_ = re.escape(TestSCons_time._python_)
+_python_ = re.escape('"' + sys.executable + '"')
test = TestSCons_time.TestSCons_time(match = TestSCons_time.match_re,