summaryrefslogtreecommitdiff
path: root/QMTest
diff options
context:
space:
mode:
authorWilliam Deegan <bill@baddogconsulting.com>2016-09-30 15:04:09 -0400
committerWilliam Deegan <bill@baddogconsulting.com>2016-09-30 15:04:09 -0400
commite5ddcd4463a87b74f4d4efd32e57c771fcaa8cd5 (patch)
tree9783594e71e74327c1c82dea4315e1df3aac1606 /QMTest
parent3aa8f51e75048d4b751311f5be7f66aac2071bf4 (diff)
parentfd8260b1ea1ec158bcabc8030d3a47eadf7c1255 (diff)
downloadscons-e5ddcd4463a87b74f4d4efd32e57c771fcaa8cd5.tar.gz
update from upstream
Diffstat (limited to 'QMTest')
-rw-r--r--QMTest/TestCmd.py41
-rw-r--r--QMTest/TestCommon.py2
-rw-r--r--QMTest/TestSCons.py34
-rw-r--r--QMTest/scons_tdb.py2
4 files changed, 37 insertions, 42 deletions
diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py
index b0a456b9..370101bb 100644
--- a/QMTest/TestCmd.py
+++ b/QMTest/TestCmd.py
@@ -328,12 +328,24 @@ __all__ = [
'match_re_dotall',
'python',
'_python_',
- 'TestCmd'
+ 'TestCmd',
+ 'to_bytes',
+ 'to_str',
]
def is_List(e):
return isinstance(e, (list, UserList))
+def to_bytes (s):
+ if isinstance (s, bytes) or bytes is str:
+ return s
+ return bytes (s, 'utf-8')
+
+def to_str (s):
+ if bytes is str or is_String(s):
+ return s
+ return str (s, 'utf-8')
+
try:
eval('unicode')
except NameError:
@@ -513,6 +525,8 @@ def simple_diff(a, b, fromfile='', tofile='',
(diff -c) and difflib.unified_diff (diff -u) but which prints
output like the simple, unadorned 'diff" command.
"""
+ a = [to_str(q) for q in a]
+ b = [to_str(q) for q in b]
sm = difflib.SequenceMatcher(None, a, b)
def comma(x1, x2):
return x1+1 == x2 and str(x2) or '%s,%s' % (x1+1, x2)
@@ -910,7 +924,7 @@ class TestCmd(object):
self.condition = 'no_result'
self.workdir_set(workdir)
self.subdir(subdir)
- self.script_srcdir = None
+ self.fixture_dirs = []
def __del__(self):
self.cleanup()
@@ -1234,10 +1248,15 @@ class TestCmd(object):
assumed to be under the temporary working directory, it gets
created automatically, if it does not already exist.
"""
- if srcdir and self.script_srcdir and not os.path.isabs(srcdir):
- spath = os.path.join(self.script_srcdir, srcdir)
+
+ if srcdir and self.fixture_dirs and not os.path.isabs(srcdir):
+ for dir in self.fixture_dirs:
+ spath = os.path.join(dir, srcdir)
+ if os.path.isdir(spath):
+ break
else:
spath = srcdir
+
if dstdir:
dstdir = self.canonicalize(dstdir)
else:
@@ -1271,13 +1290,15 @@ class TestCmd(object):
automatically, if it does not already exist.
"""
srcpath, srctail = os.path.split(srcfile)
- if srcpath:
- if self.script_srcdir and not os.path.isabs(srcpath):
- spath = os.path.join(self.script_srcdir, srcfile)
- else:
- spath = srcfile
+
+ if srcpath and (not self.fixture_dirs or os.path.isabs(srcpath)):
+ spath = srcfile
else:
- spath = os.path.join(self.script_srcdir, srcfile)
+ for dir in self.fixture_dirs:
+ spath = os.path.join(dir, srcfile)
+ if os.path.isfile(spath):
+ break
+
if not dstfile:
if srctail:
dpath = os.path.join(self.workdir, srctail)
diff --git a/QMTest/TestCommon.py b/QMTest/TestCommon.py
index f878636a..9093cc99 100644
--- a/QMTest/TestCommon.py
+++ b/QMTest/TestCommon.py
@@ -479,7 +479,7 @@ class TestCommon(TestCmd):
if not match:
match = self.match
try:
- self.fail_test(not match(file_contents, expect))
+ self.fail_test(not match(to_str(file_contents), to_str(expect)))
except KeyboardInterrupt:
raise
except:
diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py
index 69e1bbb7..80499309 100644
--- a/QMTest/TestSCons.py
+++ b/QMTest/TestSCons.py
@@ -269,7 +269,7 @@ class TestSCons(TestCommon):
SCons.Node.FS.default_fs = SCons.Node.FS.FS()
try:
- self.script_srcdir = os.environ['PYTHON_SCRIPT_DIR']
+ self.fixture_dirs = (os.environ['FIXTURE_DIRS']).split(':')
except KeyError:
pass
@@ -959,32 +959,6 @@ SConscript( sconscript )
# to use cygwin compilers on cmd.exe -> uncomment following line
#Configure_lib = 'm'
- def gccFortranLibs(self):
- """Test which gcc Fortran startup libraries are required.
- This should probably move into SCons itself, but is kind of hacky.
- """
- if sys.platform.find('irix') != -1:
- return ['ftn']
-
- libs = ['g2c']
- cmd = ['gcc','-v']
-
- try:
- p = Popen(cmd, stdout=PIPE, stderr=PIPE)
- stdout, stderr = p.communicate()
- except:
- return libs
-
- m = re.search('(gcc\s+version|gcc-Version)\s+(\d\.\d)', stderr)
- if m:
- gcc_version = m.group(2)
- if re.match('4.[^0]', gcc_version):
- libs = ['gfortranbegin']
- elif gcc_version in ('3.1', '4.0'):
- libs = ['frtbegin'] + libs
-
- return libs
-
def skip_if_not_msvc(self, check_platform=True):
""" Check whether we are on a Windows platform and skip the
test if not. This check can be omitted by setting
@@ -1260,7 +1234,7 @@ class TimeSCons(TestSCons):
self.variables = kw.get('variables')
default_calibrate_variables = []
if self.variables is not None:
- for variable, value in self.variables.items():
+ for variable, value in list(self.variables.items()):
value = os.environ.get(variable, value)
try:
value = int(value)
@@ -1316,7 +1290,7 @@ class TimeSCons(TestSCons):
"""
if 'options' not in kw and self.variables:
options = []
- for variable, value in self.variables.items():
+ for variable, value in list(self.variables.items()):
options.append('%s=%s' % (variable, value))
kw['options'] = ' '.join(options)
if self.calibrate:
@@ -1342,7 +1316,7 @@ class TimeSCons(TestSCons):
self.elapsed_time(),
"seconds",
sort=0)
- for name, args in stats.items():
+ for name, args in list(stats.items()):
self.trace(name, trace, **args)
def uptime(self):
diff --git a/QMTest/scons_tdb.py b/QMTest/scons_tdb.py
index 76c7fe10..f5c0ae51 100644
--- a/QMTest/scons_tdb.py
+++ b/QMTest/scons_tdb.py
@@ -92,7 +92,7 @@ def get_explicit_arguments(e):
# Determine which subset of the 'arguments' have been set
# explicitly.
explicit_arguments = {}
- for name, field in arguments.items():
+ for name, field in list(arguments.items()):
# Do not record computed fields.
if field.IsComputed():
continue