diff options
author | William Deegan <bill@baddogconsulting.com> | 2016-09-30 19:04:09 (GMT) |
---|---|---|
committer | William Deegan <bill@baddogconsulting.com> | 2016-09-30 19:04:09 (GMT) |
commit | 696af9192158271e5167e6227a5dfaa614a2fb06 (patch) | |
tree | 9783594e71e74327c1c82dea4315e1df3aac1606 /QMTest | |
parent | f3a1b325d4baf5f4bc554a596b676e2029046b7c (diff) | |
parent | 6dd3fd8b838d18d65edd6e7adabf3a363437f8a9 (diff) | |
download | SCons-696af9192158271e5167e6227a5dfaa614a2fb06.zip SCons-696af9192158271e5167e6227a5dfaa614a2fb06.tar.gz SCons-696af9192158271e5167e6227a5dfaa614a2fb06.tar.bz2 |
update from upstream
Diffstat (limited to 'QMTest')
-rw-r--r-- | QMTest/TestCmd.py | 41 | ||||
-rw-r--r-- | QMTest/TestCommon.py | 2 | ||||
-rw-r--r-- | QMTest/TestSCons.py | 34 | ||||
-rw-r--r-- | QMTest/scons_tdb.py | 2 |
4 files changed, 37 insertions, 42 deletions
diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index b0a456b..370101b 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 f878636..9093cc9 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 69e1bbb..8049930 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 76c7fe1..f5c0ae5 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 |