diff options
129 files changed, 570 insertions, 521 deletions
diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index 96e07a98..e76b2e31 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -499,7 +499,7 @@ def match_re(lines = None, res = None): msg = "Regular expression error in %s: %s" raise re.error(msg % (repr(s), e.args[0])) if not expr.search(lines[i]): - print("match_re: mismatch at line %d:\n search re='%s'\n line='%s'"%(i,s,lines[i])) + print("match_re: mismatch at line %d:\n search re='%s'\n line='%s'"%(i, s, lines[i])) return return 1 @@ -672,7 +672,7 @@ except AttributeError: PIPE = subprocess.PIPE -if sys.platform == 'win32' and subprocess.mswindows: +if sys.platform == 'win32':# and subprocess.mswindows: try: from win32file import ReadFile, WriteFile from win32pipe import PeekNamedPipe @@ -734,7 +734,7 @@ class Popen(subprocess.Popen): getattr(self, which).close() setattr(self, which, None) - if sys.platform == 'win32' and subprocess.mswindows: + if sys.platform == 'win32':# and subprocess.mswindows: def send(self, input): if not self.stdin: return None diff --git a/QMTest/TestCommonTests.py b/QMTest/TestCommonTests.py index 30b7d6a3..7949cb84 100644 --- a/QMTest/TestCommonTests.py +++ b/QMTest/TestCommonTests.py @@ -168,10 +168,11 @@ class __init__TestCase(TestCommonTestCase): os.chdir(run_env.workdir) script = lstrip("""\ + from __future__ import print_function from TestCommon import TestCommon tc = TestCommon(workdir='') import os - print os.getcwd() + print(os.getcwd()) """) run_env.run(program=sys.executable, stdin=script) stdout = run_env.stdout()[:-1] @@ -2285,14 +2286,16 @@ class variables_TestCase(TestCommonTestCase): 'dll_suffix', ] - script = "import TestCommon\n" + \ - '\n'.join([ "print TestCommon.%s\n" % v for v in variables ]) + script = "from __future__ import print_function" + \ + "import TestCommon\n" + \ + '\n'.join([ "print(TestCommon.%s)\n" % v for v in variables ]) run_env.run(program=sys.executable, stdin=script) stderr = run_env.stderr() assert stderr == "", stderr - script = "from TestCommon import *\n" + \ - '\n'.join([ "print %s" % v for v in variables ]) + script = "from __future__ import print_function" + \ + "from TestCommon import *\n" + \ + '\n'.join([ "print(%s)" % v for v in variables ]) run_env.run(program=sys.executable, stdin=script) stderr = run_env.stderr() assert stderr == "", stderr diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index e7175fbf..f75a3ccc 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -1239,7 +1239,7 @@ class TimeSCons(TestSCons): self.variables = kw.get('variables') default_calibrate_variables = [] if self.variables is not None: - for variable, value in list(self.variables.items()): + for variable, value in self.variables.items(): value = os.environ.get(variable, value) try: value = int(value) @@ -1295,7 +1295,7 @@ class TimeSCons(TestSCons): """ if 'options' not in kw and self.variables: options = [] - for variable, value in list(self.variables.items()): + for variable, value in self.variables.items(): options.append('%s=%s' % (variable, value)) kw['options'] = ' '.join(options) if self.calibrate: @@ -1321,7 +1321,7 @@ class TimeSCons(TestSCons): self.elapsed_time(), "seconds", sort=0) - for name, args in list(stats.items()): + for name, args in stats.items(): self.trace(name, trace, **args) def uptime(self): diff --git a/QMTest/scons_tdb.py b/QMTest/scons_tdb.py index f5c0ae51..76c7fe10 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 list(arguments.items()): + for name, field in arguments.items(): # Do not record computed fields. if field.IsComputed(): continue diff --git a/bench/env.__setitem__.py b/bench/env.__setitem__.py index 9c27b6d5..510dcc7d 100644 --- a/bench/env.__setitem__.py +++ b/bench/env.__setitem__.py @@ -4,6 +4,8 @@ # env.__setitem__() method(s) in the src/engine/SCons/Environment.py # module. +from __future__ import print_function + import os.path import re import sys diff --git a/bin/SConsDoc.py b/bin/SConsDoc.py index 2fe4f73e..d5666443 100644 --- a/bin/SConsDoc.py +++ b/bin/SConsDoc.py @@ -598,7 +598,7 @@ class SConsDocTree: # Create xpath context self.xpath_context = self.doc.xpathNewContext() # Register namespaces - for key, val in list(self.nsmap.items()): + for key, val in self.nsmap.items(): self.xpath_context.xpathRegisterNs(key, val) def __del__(self): diff --git a/bin/SConsExamples.py b/bin/SConsExamples.py index a86968d1..dd9bfaf8 100644 --- a/bin/SConsExamples.py +++ b/bin/SConsExamples.py @@ -267,7 +267,7 @@ def ensureExampleOutputsExist(dpath): os.mkdir(generated_examples) examples = readAllExampleInfos(dpath) - for key, value in list(examples.items()): + for key, value in examples.items(): # Process all scons_output tags for o in value.outputs: cpath = os.path.join(generated_examples, @@ -305,7 +305,7 @@ def createAllExampleOutputs(dpath): examples = readAllExampleInfos(dpath) total = len(examples) idx = 0 - for key, value in list(examples.items()): + for key, value in examples.items(): # Process all scons_output tags print("%.2f%s (%d/%d) %s" % (float(idx + 1) * 100.0 / float(total), perc, idx + 1, total, key)) diff --git a/bin/scons-proc.py b/bin/scons-proc.py index 0747b2cc..e09c8538 100644 --- a/bin/scons-proc.py +++ b/bin/scons-proc.py @@ -104,7 +104,7 @@ Link_Entities_Header = """\ class SCons_XML(object): def __init__(self, entries, **kw): self.values = entries - for k, v in list(kw.items()): + for k, v in kw.items(): setattr(self, k, v) def fopen(self, name): diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 4a7576e0..d6eed684 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -13,6 +13,9 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER RELEASE VERSION/DATE TO BE FILLED IN LATER + From Russel Winder: + - Reordered the default D tools from "dmd, gdc, ldc" to "dmd, ldc, gdc". + From William Blevins: - Updated D language scanner support to latest: 2.071.1. (PR #1924) https://dlang.org/spec/module.html accessed 11 August 2016 @@ -146,7 +149,7 @@ RELEASE 2.4.1 - Mon, 07 Nov 2015 10:37:21 -0700 and continuing. From Hiroaki Itoh : - - Add support `Microsoft Visual C++ Compiler for Python 2.7' + - Add support `Microsoft Visual C++ Compiler for Python 2.7' Compiler can be obtained at: https://www.microsoft.com/en-us/download/details.aspx?id=44266 From Florian Miedniak: diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index be70293e..fa45f107 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -727,7 +727,7 @@ def _subproc(scons_env, cmd, error = 'ignore', **kw): # Ensure that the ENV values are all strings: new_env = {} - for key, value in list(ENV.items()): + for key, value in ENV.items(): if is_List(value): # If the value is a list, then we assume it is a path list, # because that's a pretty common list-like value to stick @@ -855,7 +855,7 @@ class CommandAction(_ActionAction): ENV = get_default_ENV(env) # Ensure that the ENV values are all strings: - for key, value in list(ENV.items()): + for key, value in ENV.items(): if not is_String(value): if is_List(value): # If the value is a list, then we assume it is a diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py index 4a233f1c..e437c51d 100644 --- a/src/engine/SCons/ActionTests.py +++ b/src/engine/SCons/ActionTests.py @@ -132,7 +132,7 @@ class Environment(object): self.d['SPAWN'] = scons_env['SPAWN'] self.d['PSPAWN'] = scons_env['PSPAWN'] self.d['ESCAPE'] = scons_env['ESCAPE'] - for k, v in list(kw.items()): + for k, v in kw.items(): self.d[k] = v # Just use the underlying scons_subst*() utility methods. def subst(self, strSubst, raw=0, target=[], source=[], conv=None): @@ -157,12 +157,12 @@ class Environment(object): def Clone(self, **kw): res = Environment() res.d = SCons.Util.semi_deepcopy(self.d) - for k, v in list(kw.items()): + for k, v in kw.items(): res.d[k] = v return res def sig_dict(self): d = {} - for k,v in list(self.items()): d[k] = v + for k,v in self.items(): d[k] = v d['TARGETS'] = ['__t1__', '__t2__', '__t3__', '__t4__', '__t5__', '__t6__'] d['TARGET'] = d['TARGETS'][0] d['SOURCES'] = ['__s1__', '__s2__', '__s3__', '__s4__', '__s5__', '__s6__'] diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py index ca35abc0..1e544a13 100644 --- a/src/engine/SCons/BuilderTests.py +++ b/src/engine/SCons/BuilderTests.py @@ -79,7 +79,7 @@ class Environment(object): self.d['SHELL'] = scons_env['SHELL'] self.d['SPAWN'] = scons_env['SPAWN'] self.d['ESCAPE'] = scons_env['ESCAPE'] - for k, v in list(kw.items()): + for k, v in kw.items(): self.d[k] = v global env_arg2nodes_called env_arg2nodes_called = None @@ -140,7 +140,7 @@ class Environment(object): return list(self.d.items()) def sig_dict(self): d = {} - for k,v in list(self.items()): d[k] = v + for k,v in self.items(): d[k] = v d['TARGETS'] = ['__t1__', '__t2__', '__t3__', '__t4__', '__t5__', '__t6__'] d['TARGET'] = d['TARGETS'][0] d['SOURCES'] = ['__s1__', '__s2__', '__s3__', '__s4__', '__s5__', '__s6__'] diff --git a/src/engine/SCons/Debug.py b/src/engine/SCons/Debug.py index 6ac5f27d..9e520ff9 100644 --- a/src/engine/SCons/Debug.py +++ b/src/engine/SCons/Debug.py @@ -89,7 +89,7 @@ def dumpLoggedInstances(classes, file=sys.stdout): obj = ref() if obj is not None: file.write(' %s:\n' % obj) - for key, value in list(obj.__dict__.items()): + for key, value in obj.__dict__.items(): file.write(' %20s : %s\n' % (key, value)) @@ -163,7 +163,7 @@ def caller_trace(back=0): # print a single caller and its callers, if any def _dump_one_caller(key, file, level=0): leader = ' '*level - for v,c in sorted([(-v,c) for c,v in list(caller_dicts[key].items())]): + for v,c in sorted([(-v,c) for c,v in caller_dicts[key].items()]): file.write("%s %6d %s:%d(%s)\n" % ((leader,-v) + func_shorten(c[-3:]))) if c in caller_dicts: _dump_one_caller(c, file, level+1) diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py index f0959829..f1d5bcab 100644 --- a/src/engine/SCons/Defaults.py +++ b/src/engine/SCons/Defaults.py @@ -459,7 +459,7 @@ def processDefines(defs): else: l.append(str(d[0])) elif SCons.Util.is_Dict(d): - for macro,value in list(d.items()): + for macro,value in d.items(): if value is not None: l.append(str(macro) + '=' + str(value)) else: diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index ed8ef786..85f9fa77 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -152,7 +152,7 @@ def _set_BUILDERS(env, key, value): except KeyError: bd = BuilderDict(kwbd, env) env._dict[key] = bd - for k, v in list(value.items()): + for k, v in value.items(): if not SCons.Builder.is_a_Builder(v): raise SCons.Errors.UserError('%s is not a Builder.' % repr(v)) bd.update(value) @@ -324,7 +324,7 @@ class BuilderDict(UserDict): delattr(self.env, item) def update(self, dict): - for i, v in list(dict.items()): + for i, v in dict.items(): self.__setitem__(i, v) @@ -515,7 +515,7 @@ class SubstitutionEnvironment(object): def subst_kw(self, kw, raw=0, target=None, source=None): nkw = {} - for k, v in list(kw.items()): + for k, v in kw.items(): k = self.subst(k, raw, target, source) if SCons.Util.is_String(v): v = self.subst(v, raw, target, source) @@ -627,7 +627,7 @@ class SubstitutionEnvironment(object): if not o: return self overrides = {} merges = None - for key, value in list(o.items()): + for key, value in o.items(): if key == 'parse_flags': merges = value else: @@ -815,7 +815,7 @@ class SubstitutionEnvironment(object): if not unique: self.Append(**args) return self - for key, value in list(args.items()): + for key, value in args.items(): if not value: continue try: @@ -984,7 +984,7 @@ class Base(SubstitutionEnvironment): # Now restore the passed-in and customized variables # to the environment, since the values the user set explicitly # should override any values set by the tools. - for key, val in list(save.items()): + for key, val in save.items(): self._dict[key] = val # Finally, apply any flags to be merged in @@ -1131,7 +1131,7 @@ class Base(SubstitutionEnvironment): in an Environment. """ kw = copy_non_reserved_keywords(kw) - for key, val in list(kw.items()): + for key, val in kw.items(): # It would be easier on the eyes to write this using # "continue" statements whenever we finish processing an item, # but Python 1.5.2 apparently doesn't let you use "continue" @@ -1201,7 +1201,7 @@ class Base(SubstitutionEnvironment): update_dict(val) except (AttributeError, TypeError, ValueError): if SCons.Util.is_Dict(val): - for k, v in list(val.items()): + for k, v in val.items(): orig[k] = v else: orig[val] = None @@ -1247,7 +1247,7 @@ class Base(SubstitutionEnvironment): values move to end. """ kw = copy_non_reserved_keywords(kw) - for key, val in list(kw.items()): + for key, val in kw.items(): if SCons.Util.is_List(val): val = _delete_duplicates(val, delete_existing) if key not in self._dict or self._dict[key] in ('', None): @@ -1363,7 +1363,7 @@ class Base(SubstitutionEnvironment): val = [val] elif SCons.Util.is_Dict(val): tmp = [] - for i,j in list(val.items()): + for i,j in val.items(): if j is not None: tmp.append((i,j)) else: @@ -1405,7 +1405,7 @@ class Base(SubstitutionEnvironment): # so the tools can use the new variables kw = copy_non_reserved_keywords(kw) new = {} - for key, value in list(kw.items()): + for key, value in kw.items(): new[key] = SCons.Subst.scons_subst_once(value, self, key) clone.Replace(**new) @@ -1605,7 +1605,7 @@ class Base(SubstitutionEnvironment): in an Environment. """ kw = copy_non_reserved_keywords(kw) - for key, val in list(kw.items()): + for key, val in kw.items(): # It would be easier on the eyes to write this using # "continue" statements whenever we finish processing an item, # but Python 1.5.2 apparently doesn't let you use "continue" @@ -1659,7 +1659,7 @@ class Base(SubstitutionEnvironment): update_dict(val) except (AttributeError, TypeError, ValueError): if SCons.Util.is_Dict(val): - for k, v in list(val.items()): + for k, v in val.items(): orig[k] = v else: orig[val] = None @@ -1696,7 +1696,7 @@ class Base(SubstitutionEnvironment): values move to front. """ kw = copy_non_reserved_keywords(kw) - for key, val in list(kw.items()): + for key, val in kw.items(): if SCons.Util.is_List(val): val = _delete_duplicates(val, not delete_existing) if key not in self._dict or self._dict[key] in ('', None): diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index c51dd308..5a14ffcc 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -164,7 +164,7 @@ class TestEnvironmentFixture(object): default_keys = { 'CC' : 'cc', 'CCFLAGS' : '-DNDEBUG', 'ENV' : { 'TMP' : '/tmp' } } - for key, value in list(default_keys.items()): + for key, value in default_keys.items(): if key not in kw: kw[key] = value if 'BUILDERS' not in kw: diff --git a/src/engine/SCons/Node/Alias.py b/src/engine/SCons/Node/Alias.py index f229a9fa..a035816c 100644 --- a/src/engine/SCons/Node/Alias.py +++ b/src/engine/SCons/Node/Alias.py @@ -89,7 +89,7 @@ class AliasNodeInfo(SCons.Node.NodeInfoBase): """ # TODO check or discard version del state['_version_id'] - for key, value in list(state.items()): + for key, value in state.items(): if key not in ('__weakref__',): setattr(self, key, value) diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 9b057be2..907bc75d 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -2203,7 +2203,7 @@ class Dir(Base): # We use the .name attribute from the Node because the keys of # the dir.entries dictionary are normalized (that is, all upper # case) on case-insensitive systems like Windows. - node_names = [ v.name for k, v in list(dir.entries.items()) + node_names = [ v.name for k, v in dir.entries.items() if k not in ('.', '..') ] names.extend(node_names) if not strings: @@ -2482,7 +2482,7 @@ class FileNodeInfo(SCons.Node.NodeInfoBase): """ # TODO check or discard version del state['_version_id'] - for key, value in list(state.items()): + for key, value in state.items(): if key not in ('__weakref__',): setattr(self, key, value) diff --git a/src/engine/SCons/Node/Python.py b/src/engine/SCons/Node/Python.py index 92cc3204..f151fc5e 100644 --- a/src/engine/SCons/Node/Python.py +++ b/src/engine/SCons/Node/Python.py @@ -67,7 +67,7 @@ class ValueNodeInfo(SCons.Node.NodeInfoBase): """ # TODO check or discard version del state['_version_id'] - for key, value in list(state.items()): + for key, value in state.items(): if key not in ('__weakref__',): setattr(self, key, value) diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 8e00fdbd..f7d20824 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -430,7 +430,7 @@ class NodeInfoBase(object): # TODO check or discard version del state['_version_id'] - for key, value in list(state.items()): + for key, value in state.items(): if key not in ('__weakref__',): setattr(self, key, value) @@ -493,7 +493,7 @@ class BuildInfoBase(object): """ # TODO check or discard version del state['_version_id'] - for key, value in list(state.items()): + for key, value in state.items(): if key not in ('__weakref__',): setattr(self, key, value) diff --git a/src/engine/SCons/SConsign.py b/src/engine/SCons/SConsign.py index 3bd4b71f..5042aa1d 100644 --- a/src/engine/SCons/SConsign.py +++ b/src/engine/SCons/SConsign.py @@ -160,7 +160,7 @@ class SConsignEntry(object): return state def __setstate__(self, state): - for key, value in list(state.items()): + for key, value in state.items(): if key not in ('_version_id','__weakref__'): setattr(self, key, value) @@ -205,7 +205,7 @@ class Base(object): pass def merge(self): - for key, node in list(self.to_be_merged.items()): + for key, node in self.to_be_merged.items(): entry = node.get_stored_info() try: ninfo = entry.ninfo @@ -252,7 +252,7 @@ class DB(Base): except Exception as e: SCons.Warnings.warn(SCons.Warnings.CorruptSConsignWarning, "Ignoring corrupt sconsign entry : %s (%s)\n"%(self.dir.get_tpath(), e)) - for key, entry in list(self.entries.items()): + for key, entry in self.entries.items(): entry.convert_from_sconsign(dir, key) if mode == "r": @@ -279,7 +279,7 @@ class DB(Base): # the Repository; we only write to our own .sconsign file, # not to .sconsign files in Repositories. path = normcase(self.dir.get_internal_path()) - for key, entry in list(self.entries.items()): + for key, entry in self.entries.items(): entry.convert_to_sconsign() db[path] = pickle.dumps(self.entries, PICKLE_PROTOCOL) @@ -309,7 +309,7 @@ class Dir(Base): raise TypeError if dir: - for key, entry in list(self.entries.items()): + for key, entry in self.entries.items(): entry.convert_from_sconsign(dir, key) @@ -369,7 +369,7 @@ class DirFile(Dir): fname = self.sconsign except IOError: return - for key, entry in list(self.entries.items()): + for key, entry in self.entries.items(): entry.convert_to_sconsign() pickle.dump(self.entries, file, PICKLE_PROTOCOL) file.close() diff --git a/src/engine/SCons/Scanner/LaTeX.py b/src/engine/SCons/Scanner/LaTeX.py index cb89cf0c..0c54bf30 100644 --- a/src/engine/SCons/Scanner/LaTeX.py +++ b/src/engine/SCons/Scanner/LaTeX.py @@ -224,14 +224,14 @@ class LaTeX(SCons.Scanner.Base): """ def __init__(self, dictionary): self.dictionary = {} - for k,n in list(dictionary.items()): + for k,n in dictionary.items(): self.dictionary[k] = ( SCons.Scanner.FindPathDirs(n), FindENVPathDirs(n) ) def __call__(self, env, dir=None, target=None, source=None, argument=None): di = {} - for k,(c,cENV) in list(self.dictionary.items()): + for k,(c,cENV) in self.dictionary.items(): di[k] = ( c(env, dir=None, target=None, source=None, argument=None) , cENV(env, dir=None, target=None, source=None, diff --git a/src/engine/SCons/Script/Interactive.py b/src/engine/SCons/Script/Interactive.py index cf6e2474..6be7b270 100644 --- a/src/engine/SCons/Script/Interactive.py +++ b/src/engine/SCons/Script/Interactive.py @@ -121,7 +121,7 @@ class SConsInteractiveCmd(cmd.Cmd): def __init__(self, **kw): cmd.Cmd.__init__(self) - for key, val in list(kw.items()): + for key, val in kw.items(): setattr(self, key, val) if sys.platform == 'win32': diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py index 4e63f6c1..8609892a 100644 --- a/src/engine/SCons/Script/SConscript.py +++ b/src/engine/SCons/Script/SConscript.py @@ -526,7 +526,7 @@ class SConsEnvironment(SCons.Environment.Base): return x ls = list(map(subst_element, ls)) subst_kw = {} - for key, val in list(kw.items()): + for key, val in kw.items(): if SCons.Util.is_String(val): val = self.subst(val) elif SCons.Util.is_List(val): diff --git a/src/engine/SCons/Taskmaster.py b/src/engine/SCons/Taskmaster.py index 47a4c908..bd94972d 100644 --- a/src/engine/SCons/Taskmaster.py +++ b/src/engine/SCons/Taskmaster.py @@ -479,7 +479,7 @@ class Task(object): if p.ref_count == 0: self.tm.candidates.append(p) - for p, subtract in list(parents.items()): + for p, subtract in parents.items(): p.ref_count = p.ref_count - subtract if T: T.write(self.trace_message(u'Task.postprocess()', p, diff --git a/src/engine/SCons/Tool/MSCommon/common.py b/src/engine/SCons/Tool/MSCommon/common.py index b14eba18..41cd8892 100644 --- a/src/engine/SCons/Tool/MSCommon/common.py +++ b/src/engine/SCons/Tool/MSCommon/common.py @@ -219,7 +219,7 @@ def parse_output(output, keep = ("INCLUDE", "LIB", "LIBPATH", "PATH")): dkeep[key].append(p) for line in output.splitlines(): - for k,v in list(rdk.items()): + for k,v in rdk.items(): m = v.match(line) if m: add_env(m, k) diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py index 588fe98c..7b8dd9d1 100644 --- a/src/engine/SCons/Tool/MSCommon/vc.py +++ b/src/engine/SCons/Tool/MSCommon/vc.py @@ -515,7 +515,7 @@ def msvc_setup_env(env): SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning, warn_msg) return None - for k, v in list(d.items()): + for k, v in d.items(): debug('vc.py:msvc_setup_env() env:%s -> %s'%(k,v)) env.PrependENVPath(k, v, delete_existing=True) diff --git a/src/engine/SCons/Tool/MSCommon/vs.py b/src/engine/SCons/Tool/MSCommon/vs.py index 4bda4060..31197ef0 100644 --- a/src/engine/SCons/Tool/MSCommon/vs.py +++ b/src/engine/SCons/Tool/MSCommon/vs.py @@ -545,7 +545,7 @@ def msvs_setup_env(env): env['ENV'] = save_ENV vars = parse_output(output, vars) - for k, v in list(vars.items()): + for k, v in vars.items(): env.PrependENVPath(k, v, delete_existing=1) def query_versions(): diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index 0e5f3644..dbc6d0ce 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -291,7 +291,7 @@ def _call_linker_cb(env, callback, args, result = None): if Verbose: print('_call_linker_cb: args=%r' % args) print('_call_linker_cb: callback=%r' % callback) - + try: cbfun = env['LINKCALLBACKS'][callback] except (KeyError, TypeError): @@ -423,7 +423,7 @@ class _LibInfoGeneratorBase(object): def generate_versioned_lib_info(self, env, args, result = None, **kw): callback = self.get_versioned_lib_info_generator(**kw) - return _call_linker_cb(env, callback, args, result) + return _call_linker_cb(env, callback, args, result) class _LibPrefixGenerator(_LibInfoGeneratorBase): """Library prefix generator, used as target_prefix in SharedLibrary and @@ -534,7 +534,7 @@ ImpLibSymlinkGenerator = _LibSymlinkGenerator('ImpLib') class _LibNameGenerator(_LibInfoGeneratorBase): """Generates "unmangled" library name from a library file node. - + Generally, it's thought to revert modifications done by prefix/suffix generators (_LibPrefixGenerator/_LibSuffixGenerator) used by a library builder. For example, on gnulink the suffix generator used by SharedLibrary @@ -544,7 +544,7 @@ class _LibNameGenerator(_LibInfoGeneratorBase): "$SHLIBSUFFIX" in the node's basename. So that, if $SHLIBSUFFIX is ".so", $SHLIBVERSION is "0.1.2" and the node path is "/foo/bar/libfoo.so.0.1.2", the _LibNameGenerator shall return "libfoo.so". Other link tools may - implement it's own way of library name unmangling. + implement it's own way of library name unmangling. """ def __init__(self, libtype): super(_LibNameGenerator, self).__init__(libtype, 'Name') @@ -585,7 +585,7 @@ LdModNameGenerator = _LibNameGenerator('LdMod') ImpLibNameGenerator = _LibNameGenerator('ImpLib') class _LibSonameGenerator(_LibInfoGeneratorBase): - """Library soname generator. Returns library soname (e.g. libfoo.so.0) for + """Library soname generator. Returns library soname (e.g. libfoo.so.0) for a given node (e.g. /foo/bar/libfoo.so.0.1.2)""" def __init__(self, libtype): super(_LibSonameGenerator, self).__init__(libtype, 'Soname') @@ -648,7 +648,7 @@ def EmitLibSymlinks(env, symlinks, libnode, **kw): clean_targets = kw.get('clean_targets', []) if not SCons.Util.is_List(clean_targets): clean_targets = [ clean_targets ] - + for link, linktgt in symlinks: env.SideEffect(link, linktgt) if(Verbose): @@ -663,7 +663,7 @@ def CreateLibSymlinks(env, symlinks): form [ (link, linktarget), ... ], where link and linktarget are SCons nodes. """ - + Verbose = False for link, linktgt in symlinks: linktgt = link.get_dir().rel_path(linktgt) @@ -705,7 +705,7 @@ def LibSymlinksStrFun(target, source, env, *args): else: cmd += ": %s" % linkstr return cmd - + LibSymlinksAction = SCons.Action.Action(LibSymlinksActionFunction, LibSymlinksStrFun) @@ -1137,7 +1137,7 @@ def tool_list(platform, env): fortran_compiler = FindTool(fortran_compilers, env) or fortran_compilers[0] ar = FindTool(ars, env) or ars[0] - d_compilers = ['dmd', 'gdc', 'ldc'] + d_compilers = ['dmd', 'ldc', 'gdc'] d_compiler = FindTool(d_compilers, env) or d_compilers[0] other_tools = FindAllTools(other_plat_tools + [ @@ -1172,4 +1172,3 @@ def tool_list(platform, env): # indent-tabs-mode:nil # End: # vim: set expandtab tabstop=4 shiftwidth=4: - diff --git a/src/engine/SCons/Tool/aixlink.py b/src/engine/SCons/Tool/aixlink.py index 3117c551..bfddf0ac 100644 --- a/src/engine/SCons/Tool/aixlink.py +++ b/src/engine/SCons/Tool/aixlink.py @@ -65,7 +65,7 @@ def exists(env): # TODO: sync with link.smart_link() to choose a linker linkers = { 'CXX': ['aixc++'], 'CC': ['aixcc'] } alltools = [] - for langvar, linktools in list(linkers.items()): + for langvar, linktools in linkers.items(): if langvar in env: # use CC over CXX when user specified CC but not CXX return SCons.Tool.FindTool(linktools, env) alltools.extend(linktools) diff --git a/src/engine/SCons/Tool/gnulink.py b/src/engine/SCons/Tool/gnulink.py index cf1ce859..b1d50886 100644 --- a/src/engine/SCons/Tool/gnulink.py +++ b/src/engine/SCons/Tool/gnulink.py @@ -67,7 +67,7 @@ def exists(env): # TODO: sync with link.smart_link() to choose a linker linkers = { 'CXX': ['g++'], 'CC': ['gcc'] } alltools = [] - for langvar, linktools in list(linkers.items()): + for langvar, linktools in linkers.items(): if langvar in env: # use CC over CXX when user specified CC but not CXX return SCons.Tool.FindTool(linktools, env) alltools.extend(linktools) diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py index 939668e9..67f9ada9 100644 --- a/src/engine/SCons/Tool/msvs.py +++ b/src/engine/SCons/Tool/msvs.py @@ -213,7 +213,7 @@ class _UserGenerator(object): if self.createfile: dbg_settings = dict(list(zip(variants, dbg_settings))) - for var, src in list(dbg_settings.items()): + for var, src in dbg_settings.items(): # Update only expected keys trg = {} for key in [k for k in list(self.usrdebg.keys()) if k in src]: @@ -303,7 +303,7 @@ class _GenerateV7User(_UserGenerator): debug = self.configs[kind].debug if debug: debug_settings = '\n'.join(['\t\t\t\t%s="%s"' % (key, xmlify(value)) - for key, value in list(debug.items()) + for key, value in debug.items() if value is not None]) self.usrfile.write(self.usrconf % locals()) self.usrfile.write('\t</Configurations>\n</VisualStudioUserFile>') @@ -365,7 +365,7 @@ class _GenerateV10User(_UserGenerator): debug = self.configs[kind].debug if debug: debug_settings = '\n'.join(['\t\t<%s>%s</%s>' % (key, xmlify(value), key) - for key, value in list(debug.items()) + for key, value in debug.items() if value is not None]) self.usrfile.write(self.usrconf % locals()) self.usrfile.write('</Project>') @@ -924,7 +924,7 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User): self.file.write(pdata + '-->\n') def printSources(self, hierarchy, commonprefix): - sorteditems = sorted(list(hierarchy.items()), key=lambda a: a[0].lower()) + sorteditems = sorted(hierarchy.items(), key=lambda a: a[0].lower()) # First folders, then files for key, value in sorteditems: @@ -1243,7 +1243,7 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): self.file.write(pdata + '-->\n') def printFilters(self, hierarchy, name): - sorteditems = sorted(list(hierarchy.items()), key = lambda a: a[0].lower()) + sorteditems = sorted(hierarchy.items(), key = lambda a: a[0].lower()) for key, value in sorteditems: if SCons.Util.is_Dict(value): @@ -1260,7 +1260,7 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): 'Resource Files': 'None', 'Other Files': 'None'} - sorteditems = sorted(list(hierarchy.items()), key = lambda a: a[0].lower()) + sorteditems = sorted(hierarchy.items(), key = lambda a: a[0].lower()) # First folders, then files for key, value in sorteditems: diff --git a/src/engine/SCons/Tool/packaging/__init__.py b/src/engine/SCons/Tool/packaging/__init__.py index 8aa4787b..dc4b80da 100644 --- a/src/engine/SCons/Tool/packaging/__init__.py +++ b/src/engine/SCons/Tool/packaging/__init__.py @@ -72,7 +72,7 @@ def Tag(env, target, source, *more_tags, **kw_tags): target=env.Flatten(target) for t in target: - for (k,v) in list(kw_tags.items()): + for (k,v) in kw_tags.items(): # all file tags have to start with PACKAGING_, so we can later # differentiate between "normal" object attributes and the # packaging attributes. As the user should not be bothered with diff --git a/src/engine/SCons/Tool/packaging/msi.py b/src/engine/SCons/Tool/packaging/msi.py index 73d3567e..c25f856b 100644 --- a/src/engine/SCons/Tool/packaging/msi.py +++ b/src/engine/SCons/Tool/packaging/msi.py @@ -172,7 +172,7 @@ def generate_guids(root): # find all XMl nodes matching the key, retrieve their attribute, hash their # subtree, convert hash to string and add as a attribute to the xml node. - for (key,value) in list(needs_id.items()): + for (key,value) in needs_id.items(): node_list = root.getElementsByTagName(key) attribute = value for node in node_list: @@ -335,7 +335,7 @@ def build_wxsfile_file_section(root, files, NAME, VERSION, VENDOR, filename_set, } # fill in the default tags given above. - for k,v in [ (k, v) for (k,v) in list(h.items()) if not hasattr(file, k) ]: + for k,v in [ (k, v) for (k,v) in h.items() if not hasattr(file, k) ]: setattr( file, k, v ) File = factory.createElement( 'File' ) @@ -382,7 +382,7 @@ def build_wxsfile_features_section(root, files, NAME, VERSION, SUMMARY, id_set): Feature.attributes['Description'] = escape( SUMMARY ) Feature.attributes['Display'] = 'expand' - for (feature, files) in list(create_feature_dict(files).items()): + for (feature, files) in create_feature_dict(files).items(): SubFeature = factory.createElement('Feature') SubFeature.attributes['Level'] = '1' diff --git a/src/engine/SCons/Tool/packaging/rpm.py b/src/engine/SCons/Tool/packaging/rpm.py index 0931c77b..a3481a43 100644 --- a/src/engine/SCons/Tool/packaging/rpm.py +++ b/src/engine/SCons/Tool/packaging/rpm.py @@ -332,7 +332,7 @@ class SimpleTagCompiler(object): international = [t for t in replacements if is_international(t[0])] for key, replacement in international: try: - x = [t for t in list(values.items()) if strip_country_code(t[0]) == key] + x = [t for t in values.items() if strip_country_code(t[0]) == key] int_values_for_key = [(get_country_code(t[0]),t[1]) for t in x] for v in int_values_for_key: str = str + replacement % v diff --git a/src/engine/SCons/Tool/rpmutils.py b/src/engine/SCons/Tool/rpmutils.py index d4db4178..3eeed1df 100644 --- a/src/engine/SCons/Tool/rpmutils.py +++ b/src/engine/SCons/Tool/rpmutils.py @@ -520,7 +520,7 @@ def updateRpmDicts(rpmrc, pyfile): if l.startswith('# Start of rpmrc dictionaries'): pm = 1 # Write data sections to single dictionaries - for key, entries in list(data.items()): + for key, entries in data.items(): out.write("%s = {\n" % key) for arch in sorted(entries.keys()): out.write(" '%s' : ['%s'],\n" % (arch, "','".join(entries[arch]))) diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index d6f18cc2..52d7a50b 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -271,6 +271,7 @@ def render_tree(root, child_func, prune=0, margin=[0], visited=None): IDX = lambda N: N and 1 or 0 + def print_tree(root, child_func, prune=0, showtags=0, margin=[0], visited=None): """ Print a tree of nodes. This is like render_tree, except it prints @@ -307,7 +308,7 @@ def print_tree(root, child_func, prune=0, showtags=0, margin=[0], visited=None): ' N = no clean\n' + ' H = no cache\n' + '\n') - sys.stdout.write(unicode(legend)) + sys.stdout.write(u(legend)) tags = ['['] tags.append(' E'[IDX(root.exists())]) @@ -514,7 +515,7 @@ _semi_deepcopy_dispatch = d = {} def semi_deepcopy_dict(x, exclude = [] ): copy = {} - for key, val in list(x.items()): + for key, val in x.items(): # The regular Python copy.deepcopy() also deepcopies the key, # as follows: # @@ -1074,7 +1075,7 @@ class OrderedDict(UserDict): if key not in self._keys: self._keys.append(key) def update(self, dict): - for (key, val) in list(dict.items()): + for (key, val) in dict.items(): self.__setitem__(key, val) def values(self): @@ -1096,7 +1097,7 @@ class Selector(OrderedDict): # Try to perform Environment substitution on the keys of # the dictionary before giving up. s_dict = {} - for (k,v) in list(self.items()): + for (k,v) in self.items(): if k is not None: s_k = env.subst(k) if s_k in s_dict: @@ -1453,9 +1454,9 @@ def AddMethod(obj, function, name=None): self.z = x + y AddMethod(f, A, "add") a.add(2, 4) - print a.z + print(a.z) AddMethod(lambda self, i: self.l[i], a, "listIndex") - print a.listIndex(5) + print(a.listIndex(5)) """ if name is None: name = function.__name__ diff --git a/src/engine/SCons/Variables/EnumVariableTests.py b/src/engine/SCons/Variables/EnumVariableTests.py index edc29738..931dfe2b 100644 --- a/src/engine/SCons/Variables/EnumVariableTests.py +++ b/src/engine/SCons/Variables/EnumVariableTests.py @@ -124,7 +124,7 @@ class EnumVariableTestCase(unittest.TestCase): 'C' : ['C', 'three', 'three'], } - for k, l in list(table.items()): + for k, l in table.items(): x = o0.converter(k) assert x == l[0], "o0 got %s, expected %s" % (x, l[0]) x = o1.converter(k) @@ -188,7 +188,7 @@ class EnumVariableTestCase(unittest.TestCase): 'no_v' : [invalid, invalid, invalid], } - for v, l in list(table.items()): + for v, l in table.items(): l[0](o0, v) l[1](o1, v) l[2](o2, v) diff --git a/src/engine/SCons/Variables/__init__.py b/src/engine/SCons/Variables/__init__.py index 54b97a44..cd666042 100644 --- a/src/engine/SCons/Variables/__init__.py +++ b/src/engine/SCons/Variables/__init__.py @@ -185,7 +185,7 @@ class Variables(object): if args is None: args = self.args - for arg, value in list(args.items()): + for arg, value in args.items(): added = False for option in self.options: if arg in list(option.aliases) + [ option.key ]: diff --git a/src/engine/SCons/cpp.py b/src/engine/SCons/cpp.py index 8212cc16..f282ba78 100644 --- a/src/engine/SCons/cpp.py +++ b/src/engine/SCons/cpp.py @@ -72,7 +72,7 @@ cpp_lines_dict = { # the corresponding compiled regular expression that fetches the arguments # we care about. Table = {} -for op_list, expr in list(cpp_lines_dict.items()): +for op_list, expr in cpp_lines_dict.items(): e = re.compile(expr) for op in op_list: Table[op] = e diff --git a/src/script/scons-configure-cache.py b/src/script/scons-configure-cache.py index 2648acda..0fc7b48a 100644 --- a/src/script/scons-configure-cache.py +++ b/src/script/scons-configure-cache.py @@ -23,6 +23,8 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +from __future__ import print_function + __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" __version__ = "__VERSION__" @@ -41,14 +43,14 @@ import json import os def rearrange_cache_entries(current_prefix_len, new_prefix_len): - print 'Changing prefix length from', current_prefix_len, 'to', new_prefix_len + print('Changing prefix length from', current_prefix_len, 'to', new_prefix_len) dirs = set() old_dirs = set() for file in glob.iglob(os.path.join('*', '*')): name = os.path.basename(file) dir = name[:current_prefix_len].upper() if dir not in old_dirs: - print 'Migrating', dir + print('Migrating', dir) old_dirs.add(dir) dir = name[:new_prefix_len].upper() if dir not in dirs: @@ -99,7 +101,7 @@ for param in config_entries: parser.add_argument('--version', action='version', version='%(prog)s 1.0') # Get the command line as a dict without any of the unspecified entries. -args = dict([x for x in list(vars(parser.parse_args()).items()) if x[1]]) +args = dict([x for x in vars(parser.parse_args()).items() if x[1]]) # It seems somewhat strange to me, but positional arguments don't get the - # in the name changed to _, whereas optional arguments do... @@ -136,4 +138,4 @@ for key in args: # and write the updated config file with open('config', 'w') as conf: - json.dump(config, conf)
\ No newline at end of file + json.dump(config, conf) diff --git a/src/script/scons-time.py b/src/script/scons-time.py index b4db35f3..aa875f14 100644 --- a/src/script/scons-time.py +++ b/src/script/scons-time.py @@ -654,7 +654,7 @@ class SConsTimer(object): sys.stderr.write('%s Cannot use the "func" subcommand.\n' % self.name_spaces) sys.exit(1) statistics = pstats.Stats(file).stats - matches = [ e for e in list(statistics.items()) if e[0][2] == function ] + matches = [ e for e in statistics.items() if e[0][2] == function ] r = matches[0] return r[0][0], r[0][1], r[0][2], r[1][3] diff --git a/src/test_files.py b/src/test_files.py index ef276069..1eee11d9 100644 --- a/src/test_files.py +++ b/src/test_files.py @@ -78,7 +78,7 @@ check = { missing = [] no_result = [] -for directory, check_list in list(check.items()): +for directory, check_list in check.items(): if os.path.exists(directory): for c in check_list: f = os.path.join(directory, c) diff --git a/test/AS/nasm.py b/test/AS/nasm.py index b436a75e..1733789d 100644 --- a/test/AS/nasm.py +++ b/test/AS/nasm.py @@ -69,7 +69,7 @@ else: # anyway...). nasm_format = 'elf' format_map = {} -for k, v in list(format_map.items()): +for k, v in format_map.items(): if sys.platform.find(k) != -1: nasm_format = v break diff --git a/test/CPPSUFFIXES.py b/test/CPPSUFFIXES.py index 6aa55960..141df290 100644 --- a/test/CPPSUFFIXES.py +++ b/test/CPPSUFFIXES.py @@ -49,6 +49,7 @@ sys.exit(0) """) test.write('SConstruct', """ +DefaultEnvironment(tools=[]) env = Environment(CPPPATH = ['.'], CC = r'%(_python_)s mycc.py', CCFLAGS = [], @@ -94,7 +95,7 @@ test1.h 1 foo.h 1 test1.x 1 foo.h 1 -""") +""", mode='r') test.up_to_date(arguments='.') @@ -112,7 +113,7 @@ test1.h 1 foo.h 2 test1.x 1 foo.h 2 -""") +""", mode='r') test.up_to_date(arguments='.') @@ -134,7 +135,7 @@ test1.h 1 foo.h 2 test1.x 2 foo.h 2 -""") +""", mode='r') test.up_to_date(arguments='.') @@ -156,7 +157,7 @@ test1.h 2 foo.h 2 test1.x 2 foo.h 2 -""") +""", mode='r') test.up_to_date(arguments='.') diff --git a/test/CXX/CXX.py b/test/CXX/CXX.py index 1a07b093..83c4285a 100644 --- a/test/CXX/CXX.py +++ b/test/CXX/CXX.py @@ -151,15 +151,15 @@ test.write('test5.C++', r"""This is a .C++ file. test.run(arguments = '.', stderr = None) -test.must_match('test1' + _exe, "This is a .cc file.\n") +test.must_match('test1' + _exe, "This is a .cc file.\n", mode='r') -test.must_match('test2' + _exe, "This is a .cpp file.\n") +test.must_match('test2' + _exe, "This is a .cpp file.\n", mode='r') -test.must_match('test3' + _exe, "This is a .cxx file.\n") +test.must_match('test3' + _exe, "This is a .cxx file.\n", mode='r') -test.must_match('test4' + _exe, "This is a .c++ file.\n") +test.must_match('test4' + _exe, "This is a .c++ file.\n", mode='r') -test.must_match('test5' + _exe, "This is a .C++ file.\n") +test.must_match('test5' + _exe, "This is a .C++ file.\n", mode='r') if TestSCons.case_sensitive_suffixes('.c', '.C'): diff --git a/test/CXX/SHCXX.py b/test/CXX/SHCXX.py index d6a314ec..0d1ad366 100644 --- a/test/CXX/SHCXX.py +++ b/test/CXX/SHCXX.py @@ -73,7 +73,8 @@ test.fail_test(os.path.exists(test.workpath('wrapper.out'))) test.run(arguments = 'bar') -test.fail_test(test.read('wrapper.out') != "wrapper.py\n") +test.must_match('wrapper.out', "wrapper.py\n", mode='r') +# test.fail_test(test.read('wrapper.out') != "wrapper.py\n") test.pass_test() diff --git a/test/CacheDir/CacheDir.py b/test/CacheDir/CacheDir.py index fe73cad7..45c5db5e 100644 --- a/test/CacheDir/CacheDir.py +++ b/test/CacheDir/CacheDir.py @@ -89,8 +89,8 @@ test.fail_test(os.listdir(cache) != ['config']) # This should populate the cache with our derived files. test.run(chdir = 'src', arguments = '.') -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") -test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') +test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') @@ -130,7 +130,7 @@ test.must_not_exist(src_all) # even though it doesn't report anything. test.run(chdir = 'src', arguments = '-s .', stdout = "") -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') test.must_not_exist(src_cat_out) test.up_to_date(chdir = 'src', arguments = '.') @@ -148,8 +148,8 @@ Retrieved `ccc.out' from cache cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) """)) -test.must_match(['src', 'all'], "aaa.in\nbbb.in 2\nccc.in\n") -test.must_match(['src', 'cat.out'], "bbb.out\nall\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in 2\nccc.in\n", mode='r') +test.must_match(['src', 'cat.out'], "bbb.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') diff --git a/test/CacheDir/SideEffect.py b/test/CacheDir/SideEffect.py index 386b16a8..2ddba31e 100644 --- a/test/CacheDir/SideEffect.py +++ b/test/CacheDir/SideEffect.py @@ -69,7 +69,7 @@ f1.in -> f1.out f2.in -> f2.out """ -test.must_match(['work', 'log.txt'], expect) +test.must_match(['work', 'log.txt'], expect, mode='r') @@ -84,7 +84,7 @@ f2.in -> f2.out f3.in -> f3.out """ -test.must_match(['work', 'log.txt'], expect) +test.must_match(['work', 'log.txt'], expect, mode='r') @@ -100,7 +100,7 @@ f3.in -> f3.out f1.in -> f1.out """ -test.must_match(['work', 'log.txt'], expect) +test.must_match(['work', 'log.txt'], expect, mode='r') diff --git a/test/CacheDir/VariantDir.py b/test/CacheDir/VariantDir.py index 30325d21..d31b9ed0 100644 --- a/test/CacheDir/VariantDir.py +++ b/test/CacheDir/VariantDir.py @@ -75,8 +75,8 @@ SConscript('build/SConscript') # This should populate the cache with our derived files. test.run() -test.must_match(['build', 'all'], "aaa.in\nbbb.in\nccc.in\n") -test.must_match('cat.out', "%s\n%s\n%s\n%s\n" % (build_aaa_out, build_bbb_out, build_ccc_out, build_all)) +test.must_match(['build', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') +test.must_match('cat.out', "%s\n%s\n%s\n%s\n" % (build_aaa_out, build_bbb_out, build_ccc_out, build_all), mode='r') test.up_to_date(arguments = '.') @@ -116,7 +116,7 @@ test.must_not_exist(test.workpath('build', 'all')) # even though it doesn't report anything. test.run(arguments = '-s .', stdout = "") -test.must_match(['build', 'all'], "aaa.in\nbbb.in\nccc.in\n") +test.must_match(['build', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') test.must_not_exist(cat_out) test.up_to_date(arguments = '.') @@ -137,8 +137,8 @@ cat(["%s"], ["%s", "%s", "%s"]) build_ccc_out, build_all, build_aaa_out, build_bbb_out, build_ccc_out))) -test.must_match(['build', 'all'], "aaa.in\nbbb.in 2\nccc.in\n") -test.must_match('cat.out', "%s\n%s\n" % (build_bbb_out, build_all)) +test.must_match(['build', 'all'], "aaa.in\nbbb.in 2\nccc.in\n", mode='r') +test.must_match('cat.out', "%s\n%s\n" % (build_bbb_out, build_all), mode='r') test.up_to_date(arguments = '.') diff --git a/test/CacheDir/environment.py b/test/CacheDir/environment.py index eb28c19d..e37b9993 100644 --- a/test/CacheDir/environment.py +++ b/test/CacheDir/environment.py @@ -92,8 +92,8 @@ test.fail_test(os.listdir(cache) != ['config']) # This should populate the cache with our derived files. test.run(chdir = 'src', arguments = '.') -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") -test.must_match(src_cat_out, "aaa.out\nbbb.out\nccc.out\nall\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') +test.must_match(src_cat_out, "aaa.out\nbbb.out\nccc.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') @@ -109,7 +109,7 @@ Retrieved `ccc.out' from cache cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) """)) -test.must_match(src_cat_out, "bbb.out\nall\n") +test.must_match(src_cat_out, "bbb.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') @@ -134,9 +134,9 @@ test.must_not_exist(src_all) # even though it doesn't report anything. test.run(chdir = 'src', arguments = '-s .', stdout = "") -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') -test.must_match(src_cat_out, "bbb.out\nall\n") +test.must_match(src_cat_out, "bbb.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') @@ -154,8 +154,8 @@ Retrieved `ccc.out' from cache cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) """)) -test.must_match(['src', 'all'], "aaa.in\nbbb.in 2\nccc.in\n") -test.must_match(src_cat_out, "bbb.out\nall\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in 2\nccc.in\n", mode='r') +test.must_match(src_cat_out, "bbb.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') diff --git a/test/CacheDir/option--cd.py b/test/CacheDir/option--cd.py index efcf8434..fad5add7 100644 --- a/test/CacheDir/option--cd.py +++ b/test/CacheDir/option--cd.py @@ -62,8 +62,8 @@ test.write(['src', 'ccc.in'], "ccc.in\n") # This should populate the cache with our derived files. test.run(chdir = 'src', arguments = '.') -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") -test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') +test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') @@ -79,7 +79,7 @@ Retrieved `ccc.out' from cache Retrieved `all' from cache """)) -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') test.must_not_exist(test.workpath('src', 'cat.out')) test.up_to_date(chdir = 'src', arguments = '.') @@ -97,8 +97,8 @@ cat(["ccc.out"], ["ccc.in"]) cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) """)) -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") -test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') +test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') @@ -116,8 +116,8 @@ cat(["ccc.out"], ["ccc.in"]) cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) """)) -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") -test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') +test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') diff --git a/test/CacheDir/option--cf.py b/test/CacheDir/option--cf.py index ace0df6b..bb9d1cc7 100644 --- a/test/CacheDir/option--cf.py +++ b/test/CacheDir/option--cf.py @@ -38,6 +38,7 @@ test = TestSCons.TestSCons() test.subdir('cache', 'src') test.write(['src', 'SConstruct'], """ +DefaultEnvironment(tools=[]) def cat(env, source, target): target = str(target[0]) open('cat.out', 'a').write(target + "\\n") @@ -61,8 +62,10 @@ test.write(['src', 'ccc.in'], "ccc.in\n") # This should populate the cache with our derived files. test.run(chdir = 'src', arguments = '.') -test.fail_test(test.read(['src', 'all']) != "aaa.in\nbbb.in\nccc.in\n") -test.fail_test(test.read(['src', 'cat.out']) != "aaa.out\nbbb.out\nccc.out\nall\n") +test.must_match(['src','all'],"aaa.in\nbbb.in\nccc.in\n", mode='r') +# test.fail_test(test.read(['src', 'all']) != "aaa.in\nbbb.in\nccc.in\n") +test.must_match(['src','cat.out'],"aaa.out\nbbb.out\nccc.out\nall\n", mode='r') +# test.fail_test(test.read(['src', 'cat.out']) != "aaa.out\nbbb.out\nccc.out\nall\n") test.up_to_date(chdir = 'src', arguments = '.') diff --git a/test/CacheDir/option--cr.py b/test/CacheDir/option--cr.py index 165e0496..792dede9 100644 --- a/test/CacheDir/option--cr.py +++ b/test/CacheDir/option--cr.py @@ -62,8 +62,8 @@ test.write(['src', 'ccc.in'], "ccc.in\n") # This should populate the cache with our derived files. test.run(chdir = 'src', arguments = '.') -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") -test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') +test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') @@ -80,7 +80,7 @@ Retrieved `ccc.out' from cache Retrieved `all' from cache """)) -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') test.must_not_exist(test.workpath('src', 'cat.out')) test.up_to_date(chdir = 'src', arguments = '.') @@ -100,9 +100,9 @@ Retrieved `ccc.out' from cache cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) """)) -test.must_match(['src', 'all'], "aaa.rebuild\nbbb.in\nccc.in\n") +test.must_match(['src', 'all'], "aaa.rebuild\nbbb.in\nccc.in\n", mode='r') # cat.out contains only the things we built (not got from cache) -test.must_match(['src', 'cat.out'], "aaa.out\nall\n") +test.must_match(['src', 'cat.out'], "aaa.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') @@ -120,8 +120,8 @@ Retrieved `ccc.out' from cache cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) """)) -test.must_match(['src', 'all'], "aaa.rebuild\nbbb.in\nccc.in\n") -test.must_match(['src', 'cat.out'], "aaa.out\nall\n") +test.must_match(['src', 'all'], "aaa.rebuild\nbbb.in\nccc.in\n", mode='r') +test.must_match(['src', 'cat.out'], "aaa.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') diff --git a/test/CacheDir/option--cs.py b/test/CacheDir/option--cs.py index bff585d6..2e37e5af 100644 --- a/test/CacheDir/option--cs.py +++ b/test/CacheDir/option--cs.py @@ -79,9 +79,9 @@ test.write(['src1', 'ccc.in'], "ccc.in\n") # This should populate the cache with our derived files. test.run(chdir = 'src1', arguments = '.') -test.must_match(['src1', 'all'], "aaa.in\nbbb.in\nccc.in\n") +test.must_match(['src1', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') -test.must_match(['src1', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n") +test.must_match(['src1', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n", mode='r') test.up_to_date(chdir = 'src1', arguments = '.') @@ -145,7 +145,7 @@ test.run(chdir = 'src1', arguments = '--cache-show -s .', stdout = "") -test.must_match(['src1', 'all'], "aaa.in\nbbb.in\nccc.in\n") +test.must_match(['src1', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') test.must_not_exist(test.workpath('src1', 'cat.out')) # diff --git a/test/CacheDir/symlink.py b/test/CacheDir/symlink.py index ca3bbe24..e23c25eb 100644 --- a/test/CacheDir/symlink.py +++ b/test/CacheDir/symlink.py @@ -21,6 +21,10 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +import os +import sys + +import TestSCons __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -29,13 +33,13 @@ Verify that we push and retrieve a built symlink to/from a CacheDir() as an actualy symlink, not by copying the file contents. """ -import os -import TestSCons + test = TestSCons.TestSCons() -if not hasattr(os, 'symlink'): +if not hasattr(os, 'symlink') or sys.platform == 'win32': + # Skip test on windows as well, because this requires permissions which aren't default import sys test.skip_test('%s has no os.symlink() method; skipping test\n' % sys.executable) diff --git a/test/Command.py b/test/Command.py index 5f72c94b..38aceb58 100644 --- a/test/Command.py +++ b/test/Command.py @@ -35,8 +35,8 @@ test.subdir('sub') test.write('build.py', r""" import sys -contents = open(sys.argv[2], 'rb').read() -file = open(sys.argv[1], 'wb') +contents = open(sys.argv[2], 'r').read() +file = open(sys.argv[1], 'w') file.write(contents) file.close() """) @@ -45,8 +45,8 @@ test.write('SConstruct', """ import os def buildIt(env, target, source): - contents = open(str(source[0]), 'rb').read() - file = open(str(target[0]), 'wb') + contents = open(str(source[0]), 'r').read() + file = open(str(target[0]), 'w') xyzzy = env.get('XYZZY', '') if xyzzy: file.write(xyzzy + '\\n') @@ -57,9 +57,9 @@ def buildIt(env, target, source): def sub(env, target, source): target = str(target[0]) source = str(source[0]) - t = open(target, 'wb') + t = open(target, 'w') for f in sorted(os.listdir(source)): - t.write(open(os.path.join(source, f), 'rb').read()) + t.write(open(os.path.join(source, f), 'r').read()) t.close() return 0 @@ -103,16 +103,16 @@ test.write('f10.in', "f10.in\n") test.run(arguments = '.') -test.must_match('f1.out', "f1.in\n") -test.must_match('f2.out', "f2.in\n") -test.must_match('f3.out', "f3.in\n") -test.must_match('f4.out', "sub/f4a\nsub/f4b\nsub/f4c\n") -test.must_match('f5.out', "XYZZY is set\nf5.in\n") -test.must_match('f6.out', "f6.in\n") -test.must_match('f7.out', "f7.in\n") -test.must_match('f8.out', "f8.in\n") -test.must_match('f9.out', "f9.in\n") -test.must_match('f10.out', "f10.in\n") +test.must_match('f1.out', "f1.in\n", mode='r') +test.must_match('f2.out', "f2.in\n", mode='r') +test.must_match('f3.out', "f3.in\n", mode='r') +test.must_match('f4.out', "sub/f4a\nsub/f4b\nsub/f4c\n", mode='r') +test.must_match('f5.out', "XYZZY is set\nf5.in\n", mode='r') +test.must_match('f6.out', "f6.in\n", mode='r') +test.must_match('f7.out', "f7.in\n", mode='r') +test.must_match('f8.out', "f8.in\n", mode='r') +test.must_match('f9.out', "f9.in\n", mode='r') +test.must_match('f10.out', "f10.in\n", mode='r') test.pass_test() diff --git a/test/CommandGenerator.py b/test/CommandGenerator.py index 063999df..a3a995b5 100644 --- a/test/CommandGenerator.py +++ b/test/CommandGenerator.py @@ -34,8 +34,8 @@ test = TestSCons.TestSCons() test.write('build.py', r""" import sys -contents = open(sys.argv[2], 'rb').read() -file = open(sys.argv[1], 'wb') +contents = open(sys.argv[2], 'r').read() +file = open(sys.argv[1], 'w') file.write(contents) file.close() sys.exit(0) @@ -64,9 +64,9 @@ test.write('foo3.in', "foo3.in\n") test.run(arguments = 'foo1.out foo2.out foo3.out') -test.fail_test(test.read(test.workpath('foo1.out')) != "foo1.in\n") -test.fail_test(test.read(test.workpath('foo2.out')) != "foo2.in\n") -test.fail_test(test.read(test.workpath('foo3.out')) != "foo3.in\n") +test.must_match('foo1.out','foo1.in\n', mode='r') +test.must_match('foo2.out','foo2.in\n', mode='r') +test.must_match('foo3.out','foo3.in\n', mode='r') test.pass_test() diff --git a/test/Configure/custom-tests.py b/test/Configure/custom-tests.py index 503eb4e4..7bb23662 100644 --- a/test/Configure/custom-tests.py +++ b/test/Configure/custom-tests.py @@ -49,8 +49,10 @@ runOK = compileOK runFAIL = "int main() { return 1; }" test.write('pyAct.py', """\ +from __future__ import print_function + import sys -print sys.argv[1] +print(sys.argv[1]) sys.exit(int(sys.argv[1])) """) diff --git a/test/DVIPDF/DVIPDFFLAGS.py b/test/DVIPDF/DVIPDFFLAGS.py index 51a4c42a..b8c53c96 100644 --- a/test/DVIPDF/DVIPDFFLAGS.py +++ b/test/DVIPDF/DVIPDFFLAGS.py @@ -100,9 +100,9 @@ test.write('test2.tex', r"""This is a .tex test. test.run(arguments = '.', stderr = None) -test.must_match('test1.pdf', " -x\nThis is a .dvi test.\n") +test.must_match('test1.pdf', " -x\nThis is a .dvi test.\n", mode='r') -test.must_match('test2.pdf', " -x\nThis is a .tex test.\n") +test.must_match('test2.pdf', " -x\nThis is a .tex test.\n", mode='r') @@ -149,21 +149,21 @@ This is the %s LaTeX file. test.write('bar.tex', tex % 'bar.tex') - test.run(arguments = 'foo.pdf', stderr = None) + test.run(arguments='foo.pdf', stderr=None) test.must_not_exist(test.workpath('wrapper.out')) test.must_exist(test.workpath('foo.pdf')) - test.run(arguments = 'xxx.pdf', stderr = None) + test.run(arguments='xxx.pdf', stderr=None) test.must_not_exist(test.workpath('wrapper.out')) test.must_not_exist(test.workpath('xxx.dvi')) - test.run(arguments = 'bar.pdf', stderr = None) + test.run(arguments='bar.pdf', stderr=None) - test.must_match('wrapper.out', "dvipdf bar.dvi bar.pdf\n") + test.must_match('wrapper.out', "dvipdf bar.dvi bar.pdf\n", mode='r') test.must_exist(test.workpath('bar.pdf')) diff --git a/test/DVIPS/DVIPSFLAGS.py b/test/DVIPS/DVIPSFLAGS.py index 7aedf240..814c8aaa 100644 --- a/test/DVIPS/DVIPSFLAGS.py +++ b/test/DVIPS/DVIPSFLAGS.py @@ -112,13 +112,13 @@ test.write('test4.latex', r"""This is a .latex test. test.run(arguments = '.', stderr = None) -test.must_match('test1.ps', " -x\nThis is a .dvi test.\n") +test.must_match('test1.ps', " -x\nThis is a .dvi test.\n", mode='r') -test.must_match('test2.ps', " -x\nThis is a .tex test.\n") +test.must_match('test2.ps', " -x\nThis is a .tex test.\n", mode='r') -test.must_match('test3.ps', " -x\nThis is a .ltx test.\n") +test.must_match('test3.ps', " -x\nThis is a .ltx test.\n", mode='r') -test.must_match('test4.ps', " -x\nThis is a .latex test.\n") +test.must_match('test4.ps', " -x\nThis is a .latex test.\n", mode='r') dvips = test.where_is('dvips') @@ -161,20 +161,20 @@ This is the %s LaTeX file. test.write('bar2.ltx', latex % 'bar2.ltx') test.write('bar3.latex', latex % 'bar3.latex') - test.run(arguments = 'foo.dvi', stderr = None) + test.run(arguments='foo.dvi', stderr=None) test.must_not_exist(test.workpath('wrapper.out')) test.must_exist(test.workpath('foo.dvi')) - test.run(arguments = 'bar1.ps bar2.ps bar3.ps', stderr = None) + test.run(arguments='bar1.ps bar2.ps bar3.ps', stderr=None) expect = """dvips -o bar1.ps bar1.dvi dvips -o bar2.ps bar2.dvi dvips -o bar3.ps bar3.dvi """ - test.must_match('wrapper.out', expect) + test.must_match('wrapper.out', expect, mode='r') test.must_exist(test.workpath('bar1.ps')) test.must_exist(test.workpath('bar2.ps')) diff --git a/test/Deprecated/Options/Options.py b/test/Deprecated/Options/Options.py index 6c021f02..e415739e 100644 --- a/test/Deprecated/Options/Options.py +++ b/test/Deprecated/Options/Options.py @@ -29,6 +29,7 @@ import TestSCons test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) test.write('SConstruct', """ +DefaultEnvironment(tools=[]) env = Environment() print(env['CC']) print(" ".join(env['CCFLAGS'])) @@ -38,6 +39,7 @@ test.run() cc, ccflags = test.stdout().split('\n')[1:3] test.write('SConstruct', """ +DefaultEnvironment(tools=[]) # test validator. Change a key and add a new one to the environment def validator(key, value, environ): environ[key] = "v" @@ -208,6 +210,8 @@ Use scons -H for help about command-line options. # Test saving of options and multi loading # test.write('SConstruct', """ +DefaultEnvironment(tools=[]) + opts = Options(['custom.py', 'options.saved']) opts.Add('RELEASE_BUILD', 'Set to 1 to build a release build', @@ -259,6 +263,8 @@ checkSave('options.saved', {'DEBUG_BUILD':3, 'RELEASE_BUILD':1}) # Load no options from file(s) # Used to test for correct output in save option file test.write('SConstruct', """ +DefaultEnvironment(tools=[]) + opts = Options() opts.Add('RELEASE_BUILD', 'Set to 1 to build a release build', @@ -305,6 +311,8 @@ check(['0','0']) checkSave('options.saved',{'DEBUG_BUILD':0, 'LISTOPTION_TEST':'a,b'}) test.write('SConstruct', """ +DefaultEnvironment(tools=[]) + opts = Options('custom.py') opts.Add('RELEASE_BUILD', 'Set to 1 to build a release build', @@ -326,7 +334,10 @@ opts.Add('UNSPECIFIED', env = Environment(options=opts) -Help('Variables settable in custom.py or on the command line:\\n' + opts.GenerateHelpText(env,sort=cmp)) +def compare(a,b): + return a < b + +Help('Variables settable in custom.py or on the command line:\\n' + opts.GenerateHelpText(env,sort=compare)) """) @@ -357,6 +368,8 @@ Use scons -H for help about command-line options. stderr=warnings) test.write('SConstruct', """ +DefaultEnvironment(tools=[]) + import SCons.Options env1 = Environment(options = Options()) env2 = Environment(options = SCons.Options.Options()) diff --git a/test/Dir/source.py b/test/Dir/source.py index 8dbee1af..c272c8f4 100644 --- a/test/Dir/source.py +++ b/test/Dir/source.py @@ -43,7 +43,7 @@ test.subdir('tstamp', [ 'tstamp', 'subdir' ], test.write('SConstruct', """\ def writeTarget(target, source, env): - f=open(str(target[0]), 'wb') + f=open(str(target[0]), 'w') f.write("stuff\\n") f.close() return 0 @@ -92,12 +92,12 @@ test.write([ 'cmd-content', 'subdir', '#hash.txt' ], 'hash.txt 1\n') test.write('junk.txt', 'junk.txt\n') test.run(arguments=".", stderr=None) -test.must_match('tstamp.out', 'stuff\n') -test.must_match('content.out', 'stuff\n') -test.must_match('cmd-tstamp.out', 'stuff\n') -test.must_match('cmd-content.out', 'stuff\n') -test.must_match('cmd-tstamp-noscan.out', 'stuff\n') -test.must_match('cmd-content-noscan.out', 'stuff\n') +test.must_match('tstamp.out', 'stuff\n', mode='r') +test.must_match('content.out', 'stuff\n', mode='r') +test.must_match('cmd-tstamp.out', 'stuff\n', mode='r') +test.must_match('cmd-content.out', 'stuff\n', mode='r') +test.must_match('cmd-tstamp-noscan.out', 'stuff\n', mode='r') +test.must_match('cmd-content-noscan.out', 'stuff\n', mode='r') test.up_to_date(arguments='tstamp.out') test.up_to_date(arguments='content.out') diff --git a/test/ENV.py b/test/ENV.py index dc97ec82..59b1cdb2 100644 --- a/test/ENV.py +++ b/test/ENV.py @@ -50,16 +50,16 @@ test.write('build.py', r"""#!/usr/bin/env python import os import sys -contents = open(sys.argv[2], 'rb').read() -open(sys.argv[1], 'wb').write("build.py %s\n%s" % (os.environ['X'], contents)) +contents = open(sys.argv[2], 'r').read() +open(sys.argv[1], 'w').write("build.py %s\n%s" % (os.environ['X'], contents)) """) test.write('input', "input file\n") test.run(arguments = '.') -test.fail_test(test.read('env1.out') != "build.py env1\ninput file\n") -test.fail_test(test.read('env2.out') != "build.py env2\ninput file\n") +test.must_match('env1.out', "build.py env1\ninput file\n", mode='r') +test.must_match('env2.out', "build.py env2\ninput file\n", mode='r') test.write('SConstruct', """ @@ -71,9 +71,10 @@ env['ENV']['FOO'] = foo test.write('build.py', r""" +from __future__ import print_function import os -print 'LIST:', os.environ['LIST'] -print 'FOO:', os.environ['FOO'] +print('LIST:', os.environ['LIST']) +print('FOO:', os.environ['FOO']) """) test.run() diff --git a/test/Ghostscript/GSFLAGS.py b/test/Ghostscript/GSFLAGS.py index c8e0668c..e1471fa0 100644 --- a/test/Ghostscript/GSFLAGS.py +++ b/test/Ghostscript/GSFLAGS.py @@ -44,10 +44,10 @@ opt_string = '' for opt, arg in cmd_opts: if opt == '-s': if arg[:11] == 'OutputFile=': - out_file = open(arg[11:], 'wb') + out_file = open(arg[11:], 'w') else: opt_string = opt_string + ' ' + opt -infile = open(args[0], 'rb') +infile = open(args[0], 'r') out_file.write(opt_string + "\n") for l in infile.readlines(): if l[:3] != '#ps': @@ -68,7 +68,7 @@ This is a .ps test. test.run(arguments = '.', stderr = None) -test.fail_test(test.read('test1.pdf') != " -x\nThis is a .ps test.\n") +test.must_match('test1.pdf', " -x\nThis is a .ps test.\n", mode='r') diff --git a/test/HeaderGen.py b/test/HeaderGen.py index 5a7fdbe0..2763b342 100644 --- a/test/HeaderGen.py +++ b/test/HeaderGen.py @@ -35,7 +35,7 @@ test = TestSCons.TestSCons() test.write('SConstruct', """\ def writeFile(target, contents): - file = open(str(target[0]), 'wb') + file = open(str(target[0]), 'w') file.write(contents) file.close() return 0 @@ -60,8 +60,8 @@ test.write('SConstruct', """\ env = Environment() def gen_a_h(target, source, env): - t = open(str(target[0]), 'wb') - s = open(str(source[0]), 'rb') + t = open(str(target[0]), 'w') + s = open(str(source[0]), 'r') s.readline() t.write(s.readline()[:-1] + ';\\n') diff --git a/test/IDL/MIDLCOM.py b/test/IDL/MIDLCOM.py index 05255923..a478da00 100644 --- a/test/IDL/MIDLCOM.py +++ b/test/IDL/MIDLCOM.py @@ -39,12 +39,12 @@ test = TestSCons.TestSCons() test.write('mymidl.py', """ import os.path import sys -out_tlb = open(sys.argv[1], 'wb') +out_tlb = open(sys.argv[1], 'w') base = os.path.splitext(sys.argv[1])[0] -out_h = open(base + '.h', 'wb') -out_c = open(base + '_i.c', 'wb') +out_h = open(base + '.h', 'w') +out_c = open(base + '_i.c', 'w') for f in sys.argv[2:]: - infile = open(f, 'rb') + infile = open(f, 'r') for l in [l for l in infile.readlines() if l != '/*midl*/\\n']: out_tlb.write(l) out_h.write(l) @@ -62,9 +62,9 @@ test.write('aaa.idl', "aaa.idl\n/*midl*/\n") test.run(arguments = '.') -test.must_match('aaa.tlb', "aaa.idl\n") -test.must_match('aaa.h', "aaa.idl\n") -test.must_match('aaa_i.c', "aaa.idl\n") +test.must_match('aaa.tlb', "aaa.idl\n", mode='r') +test.must_match('aaa.h', "aaa.idl\n", mode='r') +test.must_match('aaa_i.c', "aaa.idl\n", mode='r') test.up_to_date(options = '--debug=explain', arguments = 'aaa.tlb') diff --git a/test/Install/Install.py b/test/Install/Install.py index d66660ba..d039d78c 100644 --- a/test/Install/Install.py +++ b/test/Install/Install.py @@ -50,15 +50,15 @@ _SUBDIR_f4_out = os.path.join('$SUBDIR', 'f4.out') test.write(['work', 'SConstruct'], """\ def cat(env, source, target): target = str(target[0]) - f = open(target, "wb") + f = open(target, "w") for src in source: - f.write(open(str(src), "rb").read()) + f.write(open(str(src), "r").read()) f.close() def my_install(dest, source, env): import shutil shutil.copy2(source, dest) - open('my_install.out', 'ab').write(dest) + open('my_install.out', 'a').write(dest) env1 = Environment() env1.Append(BUILDERS={'Cat':Builder(action=cat)}) @@ -122,7 +122,7 @@ test.fail_test(oldtime1 == os.path.getmtime(f1_out)) test.fail_test(oldtime2 != os.path.getmtime(f2_out)) # Verify that we didn't link to the Installed file. -open(f2_out, 'wb').write("xyzzy\n") +open(f2_out, 'w').write("xyzzy\n") test.must_match(['work', 'f2.out'], "f2.in\n") # Verify that scons prints an error message diff --git a/test/Interactive/shell.py b/test/Interactive/shell.py index 842a12e5..40df86fa 100644 --- a/test/Interactive/shell.py +++ b/test/Interactive/shell.py @@ -40,7 +40,9 @@ shell_command_py = test.workpath('shell_command.py') _shell_command_py_ = '"%s"' % shell_command_py.replace('\\', '\\\\') test.write(shell_command_py, """\ -print 'hello from shell_command.py' +from __future__ import print_function + +print('hello from shell_command.py') """) test.write('SConstruct', """\ diff --git a/test/Java/JAR.py b/test/Java/JAR.py index 98dfa38a..476bfcda 100644 --- a/test/Java/JAR.py +++ b/test/Java/JAR.py @@ -43,9 +43,9 @@ while args: else: break args = args[1:] -outfile = open(out, 'wb') +outfile = open(out, 'w') for file in args: - infile = open(file, 'rb') + infile = open(file, 'r') for l in infile.readlines(): if l[:7] != '/*jar*/': outfile.write(l) @@ -64,9 +64,9 @@ test1.class line 3 """) -test.run(arguments = '.', stderr = None) +test.run(arguments='.', stderr=None) -test.must_match('test1.jar', "test1.class\nline 3\n") +test.must_match('test1.jar', "test1.class\nline 3\n", mode='r') if os.path.normcase('.class') == os.path.normcase('.CLASS'): @@ -82,13 +82,13 @@ test2.CLASS line 3 """) - test.run(arguments = '.', stderr = None) + test.run(arguments='.', stderr=None) - test.must_match('test2.jar', "test2.CLASS\nline 3\n") + test.must_match('test2.jar', "test2.CLASS\nline 3\n", mode='r') test.write('myjar2.py', r""" import sys -f=open(sys.argv[2], 'wb') +f=open(sys.argv[2], 'w') f.write(" ".join(sys.argv[1:])) f.write("\n") f.close() @@ -106,7 +106,7 @@ env.Jar(target = 'classes.jar', source = [ 'testdir/bar.class', """ % locals()) test.subdir('testdir') -test.write([ 'testdir', 'bar.class' ], 'foo') +test.write(['testdir', 'bar.class'], 'foo') test.write('foo.mf', """Manifest-Version : 1.0 blah @@ -115,7 +115,7 @@ test.write('foo.mf', """) test.run(arguments='classes.jar') test.must_match('classes.jar', - 'cvfm classes.jar foo.mf -C testdir bar.class\n') + 'cvfm classes.jar foo.mf -C testdir bar.class\n', mode='r') @@ -124,14 +124,14 @@ where_jar = test.java_where_jar() -test.file_fixture('wrapper.py') +test.file_fixture('wrapper_with_args.py') test.write('SConstruct', """ foo = Environment(tools = ['javac', 'jar'], JAVAC = r'%(where_javac)s', JAR = r'%(where_jar)s') jar = foo.Dictionary('JAR') -bar = foo.Clone(JAR = r'%(_python_)s wrapper.py ' + jar) +bar = foo.Clone(JAR = r'%(_python_)s wrapper_with_args.py ' + jar) foo.Java(target = 'classes', source = 'com/sub/foo') bar.Java(target = 'classes', source = 'com/sub/bar') foo.Jar(target = 'foo', source = 'classes/com/sub/foo') @@ -229,10 +229,10 @@ public class Example6 test.run(arguments = '.') -expected_wrapper_out = "wrapper.py %(where_jar)s cf bar.jar classes/com/sub/bar\n" +expected_wrapper_out = "wrapper_with_args.py %(where_jar)s cf bar.jar classes/com/sub/bar\n" expected_wrapper_out = expected_wrapper_out.replace('/', os.sep) test.must_match('wrapper.out', - expected_wrapper_out % locals()) + expected_wrapper_out % locals(), mode='r') test.must_exist('foo.jar') test.must_exist('bar.jar') diff --git a/test/Java/JAVAC.py b/test/Java/JAVAC.py index 06b19697..aaaa8f5d 100644 --- a/test/Java/JAVAC.py +++ b/test/Java/JAVAC.py @@ -51,8 +51,8 @@ while args: break args = args[1:] for file in args: - infile = open(file, 'rb') - outfile = open(file[:-5] + '.class', 'wb') + infile = open(file, 'r') + outfile = open(file[:-5] + '.class', 'w') for l in infile.readlines(): if l[:9] != '/*javac*/': outfile.write(l) @@ -71,9 +71,9 @@ test1.java line 3 """) -test.run(arguments = '.', stderr = None) +test.run(arguments='.', stderr=None) -test.must_match('test1.class', "test1.java\nline 3\n") +test.must_match('test1.class', "test1.java\nline 3\n", mode='r') if os.path.normcase('.java') == os.path.normcase('.JAVA'): @@ -89,9 +89,9 @@ test2.JAVA line 3 """) - test.run(arguments = '.', stderr = None) + test.run(arguments='.', stderr=None) - test.must_match('test2.class', "test2.JAVA\nline 3\n") + test.must_match('test2.class', "test2.JAVA\nline 3\n", mode='r') diff --git a/test/Java/JAVAH.py b/test/Java/JAVAH.py index f647b030..f07ebb9d 100644 --- a/test/Java/JAVAH.py +++ b/test/Java/JAVAH.py @@ -41,7 +41,7 @@ while args: outdir = args[1] args = args[1:] elif a == '-o': - outfile = open(args[1], 'wb') + outfile = open(args[1], 'w') args = args[1:] elif a == '-classpath': args = args[1:] @@ -51,7 +51,7 @@ while args: break args = args[1:] for file in args: - infile = open(file, 'rb') + infile = open(file, 'r') for l in infile.readlines(): if l[:9] != '/*javah*/': outfile.write(l) @@ -70,9 +70,9 @@ test1.java line 3 """) -test.run(arguments = '.', stderr = None) +test.run(arguments='.', stderr=None) -test.must_match('test1.h', "test1.java\nline 3\n") +test.must_match('test1.h', "test1.java\nline 3\n", mode='r') if os.path.normcase('.java') == os.path.normcase('.JAVA'): @@ -88,9 +88,9 @@ test2.JAVA line 3 """) - test.run(arguments = '.', stderr = None) + test.run(arguments='.', stderr=None) - test.must_match('test2.h', "test2.JAVA\nline 3\n") + test.must_match('test2.h', "test2.JAVA\nline 3\n", mode='r') where_javac, java_version = test.java_where_javac() @@ -105,7 +105,7 @@ if java_version: if test.javac_is_gcj: test.skip_test('Test not valid for gcj (gnu java); skipping test(s).\n') -test.file_fixture('wrapper.py') +test.file_fixture('wrapper_with_args.py') test.write('SConstruct', """ foo = Environment(tools = ['javac', 'javah', 'install'], @@ -115,7 +115,7 @@ jv = %(java_version)s if jv: foo['JAVAVERSION'] = jv javah = foo.Dictionary('JAVAH') -bar = foo.Clone(JAVAH = r'%(_python_)s wrapper.py ' + javah) +bar = foo.Clone(JAVAH = r'%(_python_)s wrapper_with_args.py ' + javah) foo.Java(target = 'class1', source = 'com/sub/foo') bar_classes = bar.Java(target = 'class2', source = 'com/sub/bar') foo_classes = foo.Java(target = 'class3', source = 'src') @@ -282,7 +282,8 @@ class Private { test.run(arguments = '.') -test.fail_test(test.read('wrapper.out') != "wrapper.py %(where_javah)s -d outdir2 -classpath class2 com.sub.bar.Example4 com.other.Example5 com.sub.bar.Example6\n" % locals()) +test.must_match('wrapper.out', "wrapper_with_args.py %(where_javah)s -d outdir2 -classpath class2 com.sub.bar.Example4 com.other.Example5 com.sub.bar.Example6\n" % locals(), + mode='r') test.must_exist(['outdir1', 'com_sub_foo_Example1.h']) test.must_exist(['outdir1', 'com_other_Example2.h']) diff --git a/test/Java/RMIC.py b/test/Java/RMIC.py index 5f5decd4..b29a466f 100644 --- a/test/Java/RMIC.py +++ b/test/Java/RMIC.py @@ -49,8 +49,8 @@ while args: break args = args[1:] for file in args: - infile = open(file, 'rb') - outfile = open(os.path.join(outdir, file[:-5] + '.class'), 'wb') + infile = open(file, 'r') + outfile = open(os.path.join(outdir, file[:-5] + '.class'), 'w') for l in infile.readlines(): if l[:8] != '/*rmic*/': outfile.write(l) @@ -71,7 +71,7 @@ line 3 test.run(arguments = '.', stderr = None) -test.fail_test(test.read(['outdir', 'test1.class']) != "test1.java\nline 3\n") +test.must_match(['outdir', 'test1.class'], "test1.java\nline 3\n", mode='r') if os.path.normcase('.java') == os.path.normcase('.JAVA'): @@ -89,7 +89,7 @@ line 3 test.run(arguments = '.', stderr = None) - test.fail_test(test.read(['outdir', 'test2.class']) != "test2.JAVA\nline 3\n") + test.must_match(['outdir', 'test2.class'], "test2.JAVA\nline 3\n", mode='r') where_javac, java_version = test.java_where_javac() where_rmic = test.java_where_rmic() @@ -111,7 +111,7 @@ if java_version.count('.') == 1: # Note, how we allow simple version strings like "5" and # "6" to successfully pass this test. if curver < (1, 8): - test.file_fixture('wrapper.py') + test.file_fixture('wrapper_with_args.py') test.write('SConstruct', """ foo = Environment(tools = ['javac', 'rmic'], @@ -124,7 +124,7 @@ foo.RMIC(target = 'outdir1', JAVACLASSDIR = 'class1') rmic = foo.Dictionary('RMIC') -bar = foo.Clone(RMIC = r'%(_python_)s wrapper.py ' + rmic) +bar = foo.Clone(RMIC = r'%(_python_)s wrapper_with_args.py ' + rmic) bar_classes = bar.Java(target = 'class2', source = 'com/sub/bar') # XXX This is kind of a Python brute-force way to do what Ant # does with its "excludes" attribute. We should probably find @@ -321,7 +321,9 @@ public class Example4 extends UnicastRemoteObject implements Hello { test.run(arguments = '.') - test.fail_test(test.read('wrapper.out') != "wrapper.py %s -d outdir2 -classpath class2 com.sub.bar.Example3 com.sub.bar.Example4\n" % where_rmic) + test.must_match('wrapper.out', + "wrapper_with_args.py %s -d outdir2 -classpath class2 com.sub.bar.Example3 com.sub.bar.Example4\n" % where_rmic, + mode='r') test.must_exist(test.workpath('outdir1', 'com', 'sub', 'foo', 'Example1_Stub.class')) test.must_exist(test.workpath('outdir1', 'com', 'sub', 'foo', 'Example2_Stub.class')) diff --git a/test/MSVC/batch.py b/test/MSVC/batch.py index 86482926..8b7945b4 100644 --- a/test/MSVC/batch.py +++ b/test/MSVC/batch.py @@ -55,20 +55,20 @@ else: # Delay writing the .log output until here so any trailing slash or # backslash has been stripped, and the output comparisons later in this # script don't have to account for the difference. -open('fake_cl.log', 'ab').write(" ".join(sys.argv[1:]) + '\\n') +open('fake_cl.log', 'a').write(" ".join(sys.argv[1:]) + '\\n') for infile in input_files: if dir: outfile = os.path.join(dir, infile.replace('.c', '.obj')) else: outfile = output - open(outfile, 'wb').write(open(infile, 'rb').read()) + open(outfile, 'w').write(open(infile, 'r').read()) """) test.write('fake_link.py', """\ import sys -ofp = open(sys.argv[1], 'wb') +ofp = open(sys.argv[1], 'w') for infile in sys.argv[2:]: - ofp.write(open(infile, 'rb').read()) + ofp.write(open(infile, 'r').read()) """) test.write('SConstruct', """ @@ -94,10 +94,10 @@ test.write('f2.c', "f2.c\n") test.run(arguments = 'MSVC_BATCH=1 .') -test.must_match('prog.exe', "prog.c\nf1.c\nf2.c\n") +test.must_match('prog.exe', "prog.c\nf1.c\nf2.c\n", mode='r') test.must_match('fake_cl.log', """\ /Fo. prog.c f1.c f2.c -""") +""", mode='r') test.up_to_date(options = 'MSVC_BATCH=1', arguments = '.') @@ -107,11 +107,11 @@ test.write('f1.c', "f1.c 2\n") test.run(arguments = 'MSVC_BATCH=1 .') -test.must_match('prog.exe', "prog.c\nf1.c 2\nf2.c\n") +test.must_match('prog.exe', "prog.c\nf1.c 2\nf2.c\n", mode='r') test.must_match('fake_cl.log', """\ /Fo. prog.c f1.c f2.c /Fo. f1.c -""") +""", mode='r') test.up_to_date(options = 'MSVC_BATCH=1', arguments = '.') @@ -125,12 +125,12 @@ test.unlink('fake_cl.log') test.run(arguments = '. MSVC_BATCH=0') -test.must_match('prog.exe', "prog.c\nf1.c 2\nf2.c\n") +test.must_match('prog.exe', "prog.c\nf1.c 2\nf2.c\n", mode='r') test.must_match('fake_cl.log', """\ /Fof1.obj f1.c /Fof2.obj f2.c /Foprog.obj prog.c -""") +""", mode='r') test.run(arguments = '-c .') test.unlink('fake_cl.log') @@ -138,12 +138,12 @@ test.unlink('fake_cl.log') test.run(arguments = '. MSVC_BATCH=False') -test.must_match('prog.exe', "prog.c\nf1.c 2\nf2.c\n") +test.must_match('prog.exe', "prog.c\nf1.c 2\nf2.c\n", mode='r') test.must_match('fake_cl.log', """\ /Fof1.obj f1.c /Fof2.obj f2.c /Foprog.obj prog.c -""") +""", mode='r') @@ -151,13 +151,13 @@ test.write('f1.c', "f1.c 3\n") test.run(arguments = '. MSVC_BATCH=0') -test.must_match('prog.exe', "prog.c\nf1.c 3\nf2.c\n") +test.must_match('prog.exe', "prog.c\nf1.c 3\nf2.c\n", mode='r') test.must_match('fake_cl.log', """\ /Fof1.obj f1.c /Fof2.obj f2.c /Foprog.obj prog.c /Fof1.obj f1.c -""") +""", mode='r') diff --git a/test/MSVC/embed-manifest.py b/test/MSVC/embed-manifest.py index 13f1defb..c0f84083 100644 --- a/test/MSVC/embed-manifest.py +++ b/test/MSVC/embed-manifest.py @@ -76,14 +76,14 @@ testdll(int argc, char *argv) }
""")
-test.run(arguments = '.')
+test.run(arguments='.')
test.must_exist('test%s' % _exe)
test.must_exist('test%s.manifest' % _exe)
-test.must_contain('exe-extracted.manifest', '</assembly>')
+test.must_contain('exe-extracted.manifest', '</assembly>', mode='r')
test.must_exist('testdll%s' % _dll)
test.must_exist('testdll%s.manifest' % _dll)
-test.must_contain('dll-extracted.manifest', '</assembly>')
+test.must_contain('dll-extracted.manifest', '</assembly>', mode='r')
test.pass_test()
diff --git a/test/MSVC/generate-rc.py b/test/MSVC/generate-rc.py index 40ef95e0..00e90902 100644 --- a/test/MSVC/generate-rc.py +++ b/test/MSVC/generate-rc.py @@ -39,15 +39,15 @@ fake_rc = test.workpath('fake_rc.py') test.write(fake_rc, """\ import sys -contents = open(sys.argv[2], 'rb').read() -open(sys.argv[1], 'wb').write("fake_rc.py\\n" + contents) +contents = open(sys.argv[2], 'r').read() +open(sys.argv[1], 'w').write("fake_rc.py\\n" + contents) """) test.write('SConstruct', """ def generate_rc(target, source, env): t = str(target[0]) s = str(source[0]) - tfp = open(t, 'wb') + tfp = open(t, 'w') tfp.write('generate_rc\\n' + open(s, 'r').read()) env = Environment(tools=['msvc'], @@ -64,8 +64,8 @@ test.write('my.in', "my.in\n") test.run(arguments = '.') -test.must_match('my.rc', "generate_rc\nmy.in\n") -test.must_match('my.res', "fake_rc.py\ngenerate_rc\nmy.in\n") +test.must_match('my.rc', "generate_rc\nmy.in\n", mode='r') +test.must_match('my.res', "fake_rc.py\ngenerate_rc\nmy.in\n", mode='r') test.pass_test() diff --git a/test/MSVC/msvc.py b/test/MSVC/msvc.py index a70ed67f..838922cf 100644 --- a/test/MSVC/msvc.py +++ b/test/MSVC/msvc.py @@ -43,6 +43,7 @@ test.skip_if_not_msvc() test.write('SConstruct',""" import os +DefaultEnvironment(tools=[]) # TODO: this is order-dependent (putting 'mssdk' second or third breaks), # and ideally we shouldn't need to specify the tools= list anyway. env = Environment(tools=['mssdk', 'msvc', 'mslink']) @@ -179,6 +180,8 @@ start = time.time() test.run(arguments='slow.obj', stderr=None) slow = time.time() - start + +# TODO: Reevaluate if having this part of the test makes sense any longer # using precompiled headers should be faster limit = slow*0.90 if fast >= limit: diff --git a/test/Parallel/ref_count.py b/test/Parallel/ref_count.py index ce59668c..7ce59109 100644 --- a/test/Parallel/ref_count.py +++ b/test/Parallel/ref_count.py @@ -74,9 +74,9 @@ while args: time.sleep(int(args.pop(0))) contents = '' for ifile in args: - contents = contents + open(ifile, 'rb').read() + contents = contents + open(ifile, 'r').read() for ofile in outputs: - ofp = open(ofile, 'wb') + ofp = open(ofile, 'w') ofp.write('%s: building from %s\\n' % (ofile, " ".join(args))) ofp.write(contents) ofp.close() @@ -136,7 +136,7 @@ test.run(arguments = '-j4 after.out') test.must_match('after.out', """\ after.out: building from after.in after.in -""") +""", mode='r') test.write('file5.c', "file5.c modified\n") @@ -147,7 +147,7 @@ test.run(arguments = '-j4 after.out') test.must_match('after.out', """\ after.out: building from after.in after.in modified -""") +""", mode='r') test.pass_test() diff --git a/test/QT/QTFLAGS.py b/test/QT/QTFLAGS.py index e29ee803..f6aa00fd 100644 --- a/test/QT/QTFLAGS.py +++ b/test/QT/QTFLAGS.py @@ -147,7 +147,7 @@ test.must_exist(['work1', 'mmmmocFromH.cxx'], ['work1', 'mmmanother_ui_file.cxx']) def _flagTest(test,fileToContentsStart): - for f,c in list(fileToContentsStart.items()): + for f,c in fileToContentsStart.items(): if test.read(test.workpath('work1', f)).find(c) != 0: return 1 return 0 diff --git a/test/RANLIB/RANLIBFLAGS.py b/test/RANLIB/RANLIBFLAGS.py index e13bac89..93a5abf3 100644 --- a/test/RANLIB/RANLIBFLAGS.py +++ b/test/RANLIB/RANLIBFLAGS.py @@ -101,7 +101,7 @@ test.run(arguments = 'b' + _exe, stderr=TestSCons.noisy_ar, match=TestSCons.match_re_dotall) -test.fail_test(test.read('wrapper.out') != "wrapper.py\n") +test.must_match('wrapper.out', "wrapper.py\n", mode='r') test.pass_test() diff --git a/test/Repository/Default.py b/test/Repository/Default.py index 44aecfb4..bd9d5f88 100644 --- a/test/Repository/Default.py +++ b/test/Repository/Default.py @@ -47,7 +47,7 @@ def copy(env, source, target): source = str(source[0]) target = str(target[0]) print('copy() < %s > %s' % (source, target)) - open(target, "wb").write(open(source, "rb").read()) + open(target, "w").write(open(source, "r").read()) Build = Builder(action=copy) env = Environment(BUILDERS={'Build':Build}) @@ -80,19 +80,19 @@ test.writable('repository', 0) test.run(chdir = 'work', options = opts, arguments = '') test.fail_test(os.path.exists(work_aaa_out)) -test.fail_test(test.read(work_bbb_out) != "repository/bbb.in\n") +test.must_match(work_bbb_out, "repository/bbb.in\n", mode='r') test.fail_test(os.path.exists(work_ccc_out)) test.fail_test(os.path.exists(work_subdir_ddd_out)) -test.fail_test(test.read(work_subdir_eee_out) != "repository/subdir/eee.in\n") +test.must_match(work_subdir_eee_out, "repository/subdir/eee.in\n", mode='r') test.fail_test(os.path.exists(work_subdir_fff_out)) # test.run(chdir = 'work', options = opts, arguments = '.') -test.fail_test(test.read(work_aaa_out) != "repository/aaa.in\n") -test.fail_test(test.read(work_ccc_out) != "repository/ccc.in\n") -test.fail_test(test.read(work_subdir_ddd_out) != "repository/subdir/ddd.in\n") -test.fail_test(test.read(work_subdir_fff_out) != "repository/subdir/fff.in\n") +test.must_match(work_aaa_out, "repository/aaa.in\n", mode='r') +test.must_match(work_ccc_out, "repository/ccc.in\n", mode='r') +test.must_match(work_subdir_ddd_out, "repository/subdir/ddd.in\n", mode='r') +test.must_match(work_subdir_fff_out, "repository/subdir/fff.in\n", mode='r') test.up_to_date(chdir = 'work', options = opts, arguments = '.') diff --git a/test/Repository/Install-Local.py b/test/Repository/Install-Local.py index 36310438..fe64feb6 100644 --- a/test/Repository/Install-Local.py +++ b/test/Repository/Install-Local.py @@ -51,8 +51,8 @@ test.write(['repository', 'file2'], "repository/file2\n") test.run(chdir = 'repository', options = opts, arguments = 'install') -test.fail_test(test.read(repository_install_file1) != "repository/file1\n") -test.fail_test(test.read(repository_install_file2) != "repository/file2\n") +test.must_match(repository_install_file1, "repository/file1\n", mode='r') +test.must_match(repository_install_file2, "repository/file2\n", mode='r') test.up_to_date(chdir = 'repository', options = opts, arguments = 'install') @@ -62,8 +62,8 @@ test.writable('repository', 0) test.run(chdir = 'work', options = opts, arguments = 'install') -test.fail_test(test.read(work_install_file1) != "repository/file1\n") -test.fail_test(test.read(work_install_file2) != "repository/file2\n") +test.must_match(work_install_file1, "repository/file1\n", mode='r') +test.must_match(work_install_file2, "repository/file2\n", mode='r') test.up_to_date(chdir = 'work', options = opts, arguments = 'install') @@ -73,8 +73,8 @@ test.write(['work', 'file2'], "work/file2\n") test.run(chdir = 'work', options = opts, arguments = 'install') -test.fail_test(test.read(work_install_file1) != "work/file1\n") -test.fail_test(test.read(work_install_file2) != "work/file2\n") +test.must_match(work_install_file1, "work/file1\n", mode='r') +test.must_match(work_install_file2, "work/file2\n", mode='r') test.up_to_date(chdir = 'work', options = opts, arguments = 'install') diff --git a/test/Repository/Install.py b/test/Repository/Install.py index 5e64d55d..75052e78 100644 --- a/test/Repository/Install.py +++ b/test/Repository/Install.py @@ -51,7 +51,7 @@ test.writable('repository', 0) test.run(chdir = 'work', options = opts, arguments = install) -test.fail_test(test.read(install_file) != "repository/file\n") +test.must_match(install_file, "repository/file\n", mode='r') test.up_to_date(chdir = 'work', options = opts, arguments = install) diff --git a/test/Repository/InstallAs.py b/test/Repository/InstallAs.py index 0923d887..d717254d 100644 --- a/test/Repository/InstallAs.py +++ b/test/Repository/InstallAs.py @@ -56,9 +56,9 @@ test.writable('repository', 0) test.run(chdir = 'work', options = opts, arguments = install) -test.fail_test(test.read(install_file1_out) != "repository/file1.in\n") -test.fail_test(test.read(install_file2_out) != "repository/file2.in\n") -test.fail_test(test.read(install_file3_out) != "repository/file3.in\n") +test.must_match(install_file1_out, "repository/file1.in\n", mode='r') +test.must_match(install_file2_out, "repository/file2.in\n", mode='r') +test.must_match(install_file3_out, "repository/file3.in\n", mode='r') test.up_to_date(chdir = 'work', options = opts, arguments = install) diff --git a/test/Repository/LIBPATH.py b/test/Repository/LIBPATH.py index c95d29a1..8b396fa0 100644 --- a/test/Repository/LIBPATH.py +++ b/test/Repository/LIBPATH.py @@ -46,7 +46,7 @@ bbb_exe = env_yyy.Program('bbb', 'bbb.c') def write_LIBDIRFLAGS(env, target, source): pre = env.subst('$LIBDIRPREFIX') suf = env.subst('$LIBDIRSUFFIX') - f = open(str(target[0]), 'wb') + f = open(str(target[0]), 'w') for arg in env.subst('$_LIBDIRFLAGS', target=target).split(): if arg[:len(pre)] == pre: arg = arg[len(pre):] @@ -97,14 +97,12 @@ test.run(chdir = 'work', options = opts, arguments = ".") #dirs = ['.', workpath_foo, workpath_bar, workpath_foo_zzz] dirs = ['.', workpath_foo, workpath_bar, 'zzz', workpath_foo_zzz, workpath_bar_zzz] -test.fail_test(test.read(['work', 'zzz.out']) != - '\n'.join(dirs) + '\n') +test.must_match(['work', 'zzz.out'],'\n'.join(dirs) + '\n', mode='r') #dirs = [workpath_bar_yyy, '.', workpath_foo, workpath_bar] dirs = ['yyy', workpath_foo_yyy, workpath_bar_yyy, '.', workpath_foo, workpath_bar] -test.fail_test(test.read(['work', 'yyy.out']) != - '\n'.join(dirs) + '\n') +test.must_match(['work', 'yyy.out'], '\n'.join(dirs) + '\n', mode='r') # test.run(chdir = 'work', options = '-c', arguments = ".") @@ -117,14 +115,12 @@ test.run(chdir = 'work', options = opts, arguments = ".") #dirs = ['.', workpath_foo, workpath_bar, 'zzz', workpath_foo_zzz] dirs = ['.', workpath_foo, workpath_bar, 'zzz', workpath_foo_zzz, workpath_bar_zzz] -test.fail_test(test.read(['work', 'zzz.out']) != - '\n'.join(dirs) + '\n') +test.must_match(['work', 'zzz.out'], '\n'.join(dirs) + '\n', mode='r') #dirs = ['yyy', workpath_bar_yyy, '.', workpath_foo, workpath_bar] dirs = ['yyy', workpath_foo_yyy, workpath_bar_yyy, '.', workpath_foo, workpath_bar] -test.fail_test(test.read(['work', 'yyy.out']) != - '\n'.join(dirs) + '\n') +test.must_match(['work', 'yyy.out'], '\n'.join(dirs) + '\n', mode='r') # test.pass_test() diff --git a/test/Repository/Local.py b/test/Repository/Local.py index ea03281e..95fd8987 100644 --- a/test/Repository/Local.py +++ b/test/Repository/Local.py @@ -49,7 +49,7 @@ def copy(env, source, target): source = str(source[0]) target = str(target[0]) print('copy() < %s > %s' % (source, target)) - open(target, "wb").write(open(source, "rb").read()) + open(target, "w").write(open(source, "r").read()) Build = Builder(action=copy) env = Environment(BUILDERS={'Build':Build}, BBB='bbb') @@ -66,7 +66,7 @@ test.write(['repository', 'src', 'SConscript'], r""" def bbb_copy(env, source, target): target = str(target[0]) print('bbb_copy()') - open(target, "wb").write(open('build/bbb.1', "rb").read()) + open(target, "w").write(open('build/bbb.1', "r").read()) Import("env") env.Build('bbb.1', 'bbb.0') @@ -82,8 +82,8 @@ test.write(['repository', 'src', 'bbb.x'], "repository/src/bbb.x\n") # test.run(chdir = 'repository', options = opts, arguments = '.') -test.fail_test(test.read(repository_aaa_out) != "repository/aaa.in\n") -test.fail_test(test.read(repository_build_bbb_2) != "repository/src/bbb.0\n") +test.must_match(repository_aaa_out, "repository/aaa.in\n", mode='r') +test.must_match(repository_build_bbb_2, "repository/src/bbb.0\n", mode='r') test.up_to_date(chdir = 'repository', options = opts, arguments = '.') @@ -95,8 +95,8 @@ test.writable('repository', 0) test.run(chdir = 'work', options = opts, arguments = 'aaa.out build/bbb.2') test.fail_test(os.path.exists(work_aaa_mid)) -test.fail_test(test.read(work_aaa_out) != "repository/aaa.in\n") -test.fail_test(test.read(work_build_bbb_1) != "repository/src/bbb.0\n") +test.must_match(work_aaa_out, "repository/aaa.in\n", mode='r') +test.must_match(work_build_bbb_1, "repository/src/bbb.0\n", mode='r') test.fail_test(os.path.exists(work_build_bbb_2)) # @@ -105,8 +105,8 @@ test.write(['work', 'aaa.in'], "work/aaa.in\n") # test.run(chdir = 'work', options = opts, arguments = '.') -test.fail_test(test.read(work_aaa_mid) != "work/aaa.in\n") -test.fail_test(test.read(work_aaa_out) != "work/aaa.in\n") +test.must_match(work_aaa_mid, "work/aaa.in\n", mode='r') +test.must_match(work_aaa_out, "work/aaa.in\n", mode='r') test.up_to_date(chdir = 'work', options = opts, arguments = '.') diff --git a/test/Repository/SConscript.py b/test/Repository/SConscript.py index 22956acd..1b67c07d 100644 --- a/test/Repository/SConscript.py +++ b/test/Repository/SConscript.py @@ -61,9 +61,9 @@ SConscript('src/SConscript') test.write(['rep1', 'src', 'SConscript'], """\ def cat(env, source, target): target = str(target[0]) - f = open(target, "wb") + f = open(target, "w") for src in source: - f.write(open(str(src), "rb").read()) + f.write(open(str(src), "r").read()) f.close() env = Environment(BUILDERS={'Cat':Builder(action=cat)}) env.Cat(target = 'foo', source = ['aaa.in', 'bbb.in', 'ccc.in']) @@ -79,11 +79,11 @@ test.writable('rep1', 0) test.run(chdir = 'work', arguments = ".") -test.fail_test(test.read(['work', 'src', 'foo']) != """\ +test.must_match(['work', 'src', 'foo'], """\ rep1/src/aaa.in rep1/src/bbb.in rep1/src/ccc.in -""") +""", mode='r') test.up_to_date(chdir = 'work', arguments = ".") @@ -115,11 +115,11 @@ test.write(['rep2', 'src', 'ccc.in'], "rep2/src/ccc.in\n") test.run(chdir = 'rep2/build', arguments = ".") -test.fail_test(test.read(['rep2', 'build', 'src', 'foo']) != """\ +test.must_match(['rep2', 'build', 'src', 'foo'], """\ rep2/src/aaa.in rep2/src/bbb.in rep2/src/ccc.in -""") +""", mode='r') # test.pass_test() diff --git a/test/Repository/VariantDir.py b/test/Repository/VariantDir.py index 0258ff5e..8887f868 100644 --- a/test/Repository/VariantDir.py +++ b/test/Repository/VariantDir.py @@ -49,9 +49,9 @@ def cat(env, source, target): target = str(target[0]) source = list(map(str, source)) print('cat(%s) > %s' % (source, target)) - f = open(target, "wb") + f = open(target, "w") for src in source: - f.write(open(src, "rb").read()) + f.write(open(src, "r").read()) f.close() env = Environment(BUILDERS={'Build':Builder(action=cat)}) @@ -72,11 +72,11 @@ test.writable('repository', 0) # test.run(chdir = 'work1', options = opts, arguments = '.') -test.fail_test(test.read(['work1', 'build0', 'output']) != +test.must_match(['work1', 'build0', 'output'], """repository/src/aaa.in repository/src/bbb.in repository/src/ccc.in -""") +""", mode='r') test.fail_test(os.path.exists('work1/build0/aaa.in')) test.fail_test(os.path.exists('work1/build0/bbb.in')) @@ -85,11 +85,11 @@ test.fail_test(not os.path.exists('work1/build0/aaa.mid')) test.fail_test(not os.path.exists('work1/build0/bbb.mid')) test.fail_test(not os.path.exists('work1/build0/ccc.mid')) -test.fail_test(test.read(['work1', 'build1', 'output']) != +test.must_match(['work1', 'build1', 'output'], """repository/src/aaa.in repository/src/bbb.in repository/src/ccc.in -""") +""", mode='r') test.fail_test(not os.path.exists('work1/build1/aaa.in')) test.fail_test(not os.path.exists('work1/build1/bbb.in')) @@ -105,11 +105,11 @@ test.write(['work1', 'src', 'bbb.in'], "work1/src/bbb.in\n") test.run(chdir = 'work1', options = opts, arguments = '.') -test.fail_test(test.read(['work1', 'build0', 'output']) != +test.must_match(['work1', 'build0', 'output'], """repository/src/aaa.in work1/src/bbb.in repository/src/ccc.in -""") +""", mode='r') test.fail_test(os.path.exists('work1/build0/aaa.in')) test.fail_test(os.path.exists('work1/build0/bbb.in')) @@ -118,11 +118,11 @@ test.fail_test(not os.path.exists('work1/build0/aaa.mid')) test.fail_test(not os.path.exists('work1/build0/bbb.mid')) test.fail_test(not os.path.exists('work1/build0/ccc.mid')) -test.fail_test(test.read(['work1', 'build1', 'output']) != +test.must_match(['work1', 'build1', 'output'], """repository/src/aaa.in work1/src/bbb.in repository/src/ccc.in -""") +""", mode='r') test.fail_test(not os.path.exists('work1/build1/aaa.in')) test.fail_test(not os.path.exists('work1/build1/bbb.in')) @@ -167,11 +167,11 @@ test.write(['work2', 'src', 'bbb.in'], "work2/src/bbb.in\n") test.run(chdir = 'work2', options = opts, arguments = '.') -test.fail_test(test.read(['work2', 'build0', 'output']) != +test.must_match(['work2', 'build0', 'output'], """repository/src/aaa.in work2/src/bbb.in repository/src/ccc.in -""") +""", mode='r') test.fail_test(os.path.exists('work2/build0/aaa.in')) test.fail_test(os.path.exists('work2/build0/bbb.in')) @@ -180,11 +180,11 @@ test.fail_test(os.path.exists('work2/build0/aaa.mid')) test.fail_test(not os.path.exists('work2/build0/bbb.mid')) test.fail_test(os.path.exists('work2/build0/ccc.mid')) -test.fail_test(test.read(['work2', 'build1', 'output']) != +test.must_match(['work2', 'build1', 'output'], """repository/src/aaa.in work2/src/bbb.in repository/src/ccc.in -""") +""", mode='r') test.fail_test(not os.path.exists('work2/build1/aaa.in')) test.fail_test(not os.path.exists('work2/build1/bbb.in')) diff --git a/test/Repository/option-c.py b/test/Repository/option-c.py index c06c7d8e..b0d85334 100644 --- a/test/Repository/option-c.py +++ b/test/Repository/option-c.py @@ -66,7 +66,7 @@ def copy(env, source, target): source = str(source[0]) target = str(target[0]) print('copy() < %s > %s' % (source, target)) - open(target, "wb").write(open(source, "rb").read()) + open(target, "w").write(open(source, "r").read()) Build = Builder(action=copy) env = Environment(BUILDERS={'Build':Build}) @@ -100,14 +100,14 @@ test.writable('repository', 0) # copying them from the Repository. test.run(chdir = 'work', options = opts, arguments = '.') -test.fail_test(test.read(work_aaa_mid) != "repository/aaa.in\n") -test.fail_test(test.read(work_aaa_out) != "repository/aaa.in\n") -test.fail_test(test.read(work_bbb_mid) != "repository/bbb.in\n") -test.fail_test(test.read(work_bbb_out) != "repository/bbb.in\n") -test.fail_test(test.read(work_subdir_ccc_mid) != "repository/subdir/ccc.in\n") -test.fail_test(test.read(work_subdir_ccc_out) != "repository/subdir/ccc.in\n") -test.fail_test(test.read(work_subdir_ddd_mid) != "repository/subdir/ddd.in\n") -test.fail_test(test.read(work_subdir_ddd_out) != "repository/subdir/ddd.in\n") +test.must_match(work_aaa_mid, "repository/aaa.in\n", mode='r') +test.must_match(work_aaa_out, "repository/aaa.in\n", mode='r') +test.must_match(work_bbb_mid, "repository/bbb.in\n", mode='r') +test.must_match(work_bbb_out, "repository/bbb.in\n", mode='r') +test.must_match(work_subdir_ccc_mid, "repository/subdir/ccc.in\n", mode='r') +test.must_match(work_subdir_ccc_out, "repository/subdir/ccc.in\n", mode='r') +test.must_match(work_subdir_ddd_mid, "repository/subdir/ddd.in\n", mode='r') +test.must_match(work_subdir_ddd_out, "repository/subdir/ddd.in\n", mode='r') test.up_to_date(chdir = 'work', options = opts, arguments = '.') @@ -117,14 +117,14 @@ test.writable('repository', 1) # Now build everything in the repository. test.run(chdir = 'repository', options = opts, arguments = '.') -test.fail_test(test.read(repository_aaa_mid) != "repository/aaa.in\n") -test.fail_test(test.read(repository_aaa_out) != "repository/aaa.in\n") -test.fail_test(test.read(repository_bbb_mid) != "repository/bbb.in\n") -test.fail_test(test.read(repository_bbb_out) != "repository/bbb.in\n") -test.fail_test(test.read(repository_subdir_ccc_mid) != "repository/subdir/ccc.in\n") -test.fail_test(test.read(repository_subdir_ccc_out) != "repository/subdir/ccc.in\n") -test.fail_test(test.read(repository_subdir_ddd_mid) != "repository/subdir/ddd.in\n") -test.fail_test(test.read(repository_subdir_ddd_out) != "repository/subdir/ddd.in\n") +test.must_match(repository_aaa_mid, "repository/aaa.in\n", mode='r') +test.must_match(repository_aaa_out, "repository/aaa.in\n", mode='r') +test.must_match(repository_bbb_mid, "repository/bbb.in\n", mode='r') +test.must_match(repository_bbb_out, "repository/bbb.in\n", mode='r') +test.must_match(repository_subdir_ccc_mid, "repository/subdir/ccc.in\n", mode='r') +test.must_match(repository_subdir_ccc_out, "repository/subdir/ccc.in\n", mode='r') +test.must_match(repository_subdir_ddd_mid, "repository/subdir/ddd.in\n", mode='r') +test.must_match(repository_subdir_ddd_out, "repository/subdir/ddd.in\n", mode='r') test.up_to_date(chdir = 'repository', options = opts, arguments = '.') @@ -135,20 +135,20 @@ test.writable('repository', 0) # test.run(chdir = 'work', options = opts + ' -c', arguments = 'bbb.mid bbb.out') -test.fail_test(test.read(work_aaa_mid) != "repository/aaa.in\n") -test.fail_test(test.read(work_aaa_out) != "repository/aaa.in\n") +test.must_match(work_aaa_mid, "repository/aaa.in\n", mode='r') +test.must_match(work_aaa_out, "repository/aaa.in\n", mode='r') test.fail_test(os.path.exists(work_bbb_mid)) test.fail_test(os.path.exists(work_bbb_out)) -test.fail_test(test.read(work_subdir_ccc_mid) != "repository/subdir/ccc.in\n") -test.fail_test(test.read(work_subdir_ccc_out) != "repository/subdir/ccc.in\n") -test.fail_test(test.read(work_subdir_ddd_mid) != "repository/subdir/ddd.in\n") -test.fail_test(test.read(work_subdir_ddd_out) != "repository/subdir/ddd.in\n") +test.must_match(work_subdir_ccc_mid, "repository/subdir/ccc.in\n", mode='r') +test.must_match(work_subdir_ccc_out, "repository/subdir/ccc.in\n", mode='r') +test.must_match(work_subdir_ddd_mid, "repository/subdir/ddd.in\n", mode='r') +test.must_match(work_subdir_ddd_out, "repository/subdir/ddd.in\n", mode='r') # test.run(chdir = 'work', options = opts + ' -c', arguments = 'subdir') -test.fail_test(test.read(work_aaa_mid) != "repository/aaa.in\n") -test.fail_test(test.read(work_aaa_out) != "repository/aaa.in\n") +test.must_match(work_aaa_mid, "repository/aaa.in\n", mode='r') +test.must_match(work_aaa_out, "repository/aaa.in\n", mode='r') test.fail_test(os.path.exists(work_bbb_mid)) test.fail_test(os.path.exists(work_bbb_out)) test.fail_test(os.path.exists(work_subdir_ccc_mid)) @@ -169,14 +169,14 @@ test.fail_test(os.path.exists(work_subdir_ddd_mid)) test.fail_test(os.path.exists(work_subdir_ddd_out)) # Double-check that nothing in the repository got deleted. -test.fail_test(test.read(repository_aaa_mid) != "repository/aaa.in\n") -test.fail_test(test.read(repository_aaa_out) != "repository/aaa.in\n") -test.fail_test(test.read(repository_bbb_mid) != "repository/bbb.in\n") -test.fail_test(test.read(repository_bbb_out) != "repository/bbb.in\n") -test.fail_test(test.read(repository_subdir_ccc_mid) != "repository/subdir/ccc.in\n") -test.fail_test(test.read(repository_subdir_ccc_out) != "repository/subdir/ccc.in\n") -test.fail_test(test.read(repository_subdir_ddd_mid) != "repository/subdir/ddd.in\n") -test.fail_test(test.read(repository_subdir_ddd_out) != "repository/subdir/ddd.in\n") +test.must_match(repository_aaa_mid, "repository/aaa.in\n", mode='r') +test.must_match(repository_aaa_out, "repository/aaa.in\n", mode='r') +test.must_match(repository_bbb_mid, "repository/bbb.in\n", mode='r') +test.must_match(repository_bbb_out, "repository/bbb.in\n", mode='r') +test.must_match(repository_subdir_ccc_mid, "repository/subdir/ccc.in\n", mode='r') +test.must_match(repository_subdir_ccc_out, "repository/subdir/ccc.in\n", mode='r') +test.must_match(repository_subdir_ddd_mid, "repository/subdir/ddd.in\n", mode='r') +test.must_match(repository_subdir_ddd_out, "repository/subdir/ddd.in\n", mode='r') # test.pass_test() diff --git a/test/Repository/option-f.py b/test/Repository/option-f.py index 8511f6ac..c990f2fe 100644 --- a/test/Repository/option-f.py +++ b/test/Repository/option-f.py @@ -76,7 +76,7 @@ test.writable('repository', 0) # test.run(chdir = 'work', options = opts, arguments = 'aaa.out') -test.fail_test(test.read(['work', 'aaa.out']) != "repository/aaa.in\n") +test.must_match(['work', 'aaa.out'], "repository/aaa.in\n", mode='r') test.fail_test(os.path.exists(test.workpath('work', 'bbb.out'))) test.fail_test(os.path.exists(test.workpath('work', 'ccc.out'))) test.fail_test(os.path.exists(test.workpath('work', 'src', 'xxx.out'))) @@ -84,15 +84,15 @@ test.fail_test(os.path.exists(test.workpath('work', 'src', 'yyy.out'))) test.run(chdir = 'work', options = opts, arguments = 'bbb.out src') -test.fail_test(test.read(['work', 'bbb.out']) != "repository/bbb.in\n") +test.must_match(['work', 'bbb.out'], "repository/bbb.in\n", mode='r') test.fail_test(os.path.exists(test.workpath('work', 'ccc.out'))) -test.fail_test(test.read(['work', 'src', 'xxx.out']) != "repository/src/xxx.in\n") -test.fail_test(test.read(['work', 'src', 'yyy.out']) != "repository/src/yyy.in\n") +test.must_match(['work', 'src', 'xxx.out'], "repository/src/xxx.in\n", mode='r') +test.must_match(['work', 'src', 'yyy.out'], "repository/src/yyy.in\n", mode='r') # test.run(chdir = 'work', options = opts, arguments = '.') -test.fail_test(test.read(['work', 'ccc.out']) != "repository/ccc.in\n") +test.must_match(['work', 'ccc.out'], "repository/ccc.in\n", mode='r') # test.pass_test() diff --git a/test/Repository/option-n.py b/test/Repository/option-n.py index 2a0ae5d5..d23a200e 100644 --- a/test/Repository/option-n.py +++ b/test/Repository/option-n.py @@ -49,7 +49,7 @@ def copy(env, source, target): source = str(source[0]) target = str(target[0]) print('copy() < %s > %s' % (source, target)) - open(target, "wb").write(open(source, "rb").read()) + open(target, "w").write(open(source, "r").read()) Build = Builder(action=copy) env = Environment(BUILDERS={'Build':Build}) @@ -62,7 +62,7 @@ test.write(['repository', 'aaa.in'], "repository/aaa.in\n") # test.run(chdir = 'repository', options = opts, arguments = '.') -test.fail_test(test.read(repository_aaa_out) != "repository/aaa.in\n") +test.must_match(repository_aaa_out,"repository/aaa.in\n", mode='r') test.up_to_date(chdir = 'repository', options = opts, arguments = '.') @@ -88,7 +88,7 @@ test.run(chdir = 'work', arguments = 'aaa.out', stdout = expect) -test.fail_test(test.read(work_aaa_out) != "repository/aaa.in\n") +test.must_match(work_aaa_out, "repository/aaa.in\n", mode='r') # test.pass_test() diff --git a/test/Repository/targets.py b/test/Repository/targets.py index 0fbc8964..0bc625a9 100644 --- a/test/Repository/targets.py +++ b/test/Repository/targets.py @@ -44,9 +44,9 @@ def cat(env, source, target): target = str(target[0]) source = list(map(str, source)) print('cat(%s) > %s' % (source, target)) - f = open(target, "wb") + f = open(target, "w") for src in source: - f.write(open(src, "rb").read()) + f.write(open(src, "r").read()) f.close() env = Environment(BUILDERS={'Build':Builder(action=cat)}) @@ -77,7 +77,7 @@ test.writable('repository', 0) # test.run(chdir = 'work', options = opts, arguments = 'aaa.out') -test.fail_test(test.read(['work', 'aaa.out']) != "repository/aaa.in\n") +test.must_match(['work', 'aaa.out'], "repository/aaa.in\n", mode='r') test.fail_test(os.path.exists(test.workpath('work', 'bbb.out'))) test.fail_test(os.path.exists(test.workpath('work', 'ccc.out'))) test.fail_test(os.path.exists(test.workpath('work', 'src', 'xxx.out'))) @@ -85,15 +85,15 @@ test.fail_test(os.path.exists(test.workpath('work', 'src', 'yyy.out'))) test.run(chdir = 'work', options = opts, arguments = 'bbb.out src') -test.fail_test(test.read(['work', 'bbb.out']) != "repository/bbb.in\n") +test.must_match(['work', 'bbb.out'], "repository/bbb.in\n", mode='r') test.fail_test(os.path.exists(test.workpath('work', 'ccc.out'))) -test.fail_test(test.read(['work', 'src', 'xxx.out']) != "repository/src/xxx.in\n") -test.fail_test(test.read(['work', 'src', 'yyy.out']) != "repository/src/yyy.in\n") +test.must_match(['work', 'src', 'xxx.out'], "repository/src/xxx.in\n", mode='r') +test.must_match(['work', 'src', 'yyy.out'], "repository/src/yyy.in\n", mode='r') # test.run(chdir = 'work', options = opts, arguments = '.') -test.fail_test(test.read(['work', 'ccc.out']) != "repository/ccc.in\n") +test.must_match(['work', 'ccc.out'], "repository/ccc.in\n", mode='r') # test.pass_test() diff --git a/test/Requires/eval-order.py b/test/Requires/eval-order.py index 86002215..696b5e9d 100644 --- a/test/Requires/eval-order.py +++ b/test/Requires/eval-order.py @@ -53,10 +53,10 @@ test.write('prereq.in', "prereq.in 1\n") # not, we'll get an error when the build action tries to use it to # build file.out. -test.run(arguments = 'file.out') +test.run(arguments='file.out') -test.must_match('prereq.out', "prereq.in 1\n") -test.must_match('file.out', "file.in 1\n") +test.must_match('prereq.out', "prereq.in 1\n", mode='r') +test.must_match('file.out', "file.in 1\n", mode='r') test.pass_test() diff --git a/test/Rpcgen/RPCGEN.py b/test/Rpcgen/RPCGEN.py index f79e18e7..2f793e28 100644 --- a/test/Rpcgen/RPCGEN.py +++ b/test/Rpcgen/RPCGEN.py @@ -26,10 +26,10 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -_python_ = TestSCons._python_ -_exe = TestSCons._exe +_python_=TestSCons._python_ +_exe=TestSCons._exe -test = TestSCons.TestSCons() +test=TestSCons.TestSCons() @@ -68,10 +68,10 @@ expect_h = output % ('-h', test.workpath('rpcif.h')) expect_svc = output % ('-m', test.workpath('rpcif_svc.c')) expect_xdr = output % ('-c', test.workpath('rpcif_xdr.c')) -test.must_match('rpcif_clnt.c', expect_clnt) -test.must_match('rpcif.h', expect_h) -test.must_match('rpcif_svc.c', expect_svc) -test.must_match('rpcif_xdr.c', expect_xdr) +test.must_match('rpcif_clnt.c', expect_clnt, mode='r') +test.must_match('rpcif.h', expect_h, mode='r') +test.must_match('rpcif_svc.c', expect_svc, mode='r') +test.must_match('rpcif_xdr.c', expect_xdr, mode='r') diff --git a/test/Rpcgen/RPCGENCLIENTFLAGS.py b/test/Rpcgen/RPCGENCLIENTFLAGS.py index 9440d57f..96129527 100644 --- a/test/Rpcgen/RPCGENCLIENTFLAGS.py +++ b/test/Rpcgen/RPCGENCLIENTFLAGS.py @@ -71,10 +71,10 @@ expect_h = output % ('-h', test.workpath('rpcif.h')) expect_svc = output % ('-m', test.workpath('rpcif_svc.c')) expect_xdr = output % ('-c', test.workpath('rpcif_xdr.c')) -test.must_match('rpcif_clnt.c', expect_clnt) -test.must_match('rpcif.h', expect_h) -test.must_match('rpcif_svc.c', expect_svc) -test.must_match('rpcif_xdr.c', expect_xdr) +test.must_match('rpcif_clnt.c', expect_clnt, mode='r') +test.must_match('rpcif.h', expect_h, mode='r') +test.must_match('rpcif_svc.c', expect_svc, mode='r') +test.must_match('rpcif_xdr.c', expect_xdr, mode='r') diff --git a/test/Rpcgen/RPCGENFLAGS.py b/test/Rpcgen/RPCGENFLAGS.py index b94ffe51..d4be92c4 100644 --- a/test/Rpcgen/RPCGENFLAGS.py +++ b/test/Rpcgen/RPCGENFLAGS.py @@ -70,10 +70,10 @@ expect_h = output % ('-h', test.workpath('rpcif.h')) expect_svc = output % ('-m', test.workpath('rpcif_svc.c')) expect_xdr = output % ('-c', test.workpath('rpcif_xdr.c')) -test.must_match('rpcif_clnt.c', expect_clnt) -test.must_match('rpcif.h', expect_h) -test.must_match('rpcif_svc.c', expect_svc) -test.must_match('rpcif_xdr.c', expect_xdr) +test.must_match('rpcif_clnt.c', expect_clnt, mode='r') +test.must_match('rpcif.h', expect_h, mode='r') +test.must_match('rpcif_svc.c', expect_svc, mode='r') +test.must_match('rpcif_xdr.c', expect_xdr, mode='r') diff --git a/test/Rpcgen/RPCGENHEADERFLAGS.py b/test/Rpcgen/RPCGENHEADERFLAGS.py index f65da8e8..4beca643 100644 --- a/test/Rpcgen/RPCGENHEADERFLAGS.py +++ b/test/Rpcgen/RPCGENHEADERFLAGS.py @@ -71,10 +71,10 @@ expect_h = output_h % ('-h', test.workpath('rpcif.h')) expect_svc = output % ('-m', test.workpath('rpcif_svc.c')) expect_xdr = output % ('-c', test.workpath('rpcif_xdr.c')) -test.must_match('rpcif_clnt.c', expect_clnt) -test.must_match('rpcif.h', expect_h) -test.must_match('rpcif_svc.c', expect_svc) -test.must_match('rpcif_xdr.c', expect_xdr) +test.must_match('rpcif_clnt.c', expect_clnt, mode='r') +test.must_match('rpcif.h', expect_h, mode='r') +test.must_match('rpcif_svc.c', expect_svc, mode='r') +test.must_match('rpcif_xdr.c', expect_xdr, mode='r') diff --git a/test/Rpcgen/RPCGENSERVICEFLAGS.py b/test/Rpcgen/RPCGENSERVICEFLAGS.py index a956d4f9..7644485d 100644 --- a/test/Rpcgen/RPCGENSERVICEFLAGS.py +++ b/test/Rpcgen/RPCGENSERVICEFLAGS.py @@ -71,10 +71,10 @@ expect_h = output % ('-h', test.workpath('rpcif.h')) expect_svc = output_svc % ('-m', test.workpath('rpcif_svc.c')) expect_xdr = output % ('-c', test.workpath('rpcif_xdr.c')) -test.must_match('rpcif_clnt.c', expect_clnt) -test.must_match('rpcif.h', expect_h) -test.must_match('rpcif_svc.c', expect_svc) -test.must_match('rpcif_xdr.c', expect_xdr) +test.must_match('rpcif_clnt.c', expect_clnt, mode='r') +test.must_match('rpcif.h', expect_h, mode='r') +test.must_match('rpcif_svc.c', expect_svc, mode='r') +test.must_match('rpcif_xdr.c', expect_xdr, mode='r') diff --git a/test/Rpcgen/RPCGENXDRFLAGS.py b/test/Rpcgen/RPCGENXDRFLAGS.py index 0dc1366d..41da70c5 100644 --- a/test/Rpcgen/RPCGENXDRFLAGS.py +++ b/test/Rpcgen/RPCGENXDRFLAGS.py @@ -71,10 +71,10 @@ expect_h = output % ('-h', test.workpath('rpcif.h')) expect_svc = output % ('-m', test.workpath('rpcif_svc.c')) expect_xdr = output_xdr % ('-c', test.workpath('rpcif_xdr.c')) -test.must_match('rpcif_clnt.c', expect_clnt) -test.must_match('rpcif.h', expect_h) -test.must_match('rpcif_svc.c', expect_svc) -test.must_match('rpcif_xdr.c', expect_xdr) +test.must_match('rpcif_clnt.c', expect_clnt, mode='r') +test.must_match('rpcif.h', expect_h, mode='r') +test.must_match('rpcif_svc.c', expect_svc, mode='r') +test.must_match('rpcif_xdr.c', expect_xdr, mode='r') diff --git a/test/SConscript/Return.py b/test/SConscript/Return.py index 997de9d0..1f678afc 100644 --- a/test/SConscript/Return.py +++ b/test/SConscript/Return.py @@ -39,50 +39,50 @@ x = SConscript('SConscript2') y, z = SConscript('SConscript3') a4, b4 = SConscript('SConscript4') foo, bar = SConscript('SConscript5') -print ("x =", x) -print ("y =", y) -print ("z =", z) -print ("a4 =", a4) -print ("b4 =", b4) -print ("foo =", foo) -print ("bar =", bar) +print("x =", x) +print("y =", y) +print("z =", z) +print("a4 =", a4) +print("b4 =", b4) +print("foo =", foo) +print("bar =", bar) """) test.write('SConscript1', """\ -print ("line 1") +print("line 1") Return() -print ("line 2") +print("line 2") """) test.write('SConscript2', """\ -print ("line 3") +print("line 3") x = 7 Return('x') -print ("line 4") +print("line 4") """) test.write('SConscript3', """\ -print ("line 5") +print("line 5") y = 8 z = 9 Return('y z') -print ("line 6") +print("line 6") """) test.write('SConscript4', """\ a4 = 'aaa' b4 = 'bbb' -print ("line 7") +print("line 7") Return('a4', 'b4', stop=False) b4 = 'b-after' -print ("line 8") +print("line 8") """) test.write('SConscript5', """\ foo = 'foo' bar = 'bar' Return(["foo", "bar"]) -print ("line 9") +print("line 9") """) expect = """\ diff --git a/test/SConscript/SConscript.py b/test/SConscript/SConscript.py index d1e09ce4..2eeb2112 100644 --- a/test/SConscript/SConscript.py +++ b/test/SConscript/SConscript.py @@ -37,7 +37,7 @@ import foo assert foo.foo == 4 -print ("SConstruct", os.getcwd()) +print("SConstruct", os.getcwd()) SConscript('SConscript') x1 = "SConstruct x1" @@ -89,7 +89,7 @@ test.write('SConscript', """\ assert "os" not in globals() import os -print ("SConscript " + os.getcwd()) +print("SConscript " + os.getcwd()) """) test.write('SConscript1', """ diff --git a/test/SWIG/live.py b/test/SWIG/live.py index 5e95dc79..05971aab 100644 --- a/test/SWIG/live.py +++ b/test/SWIG/live.py @@ -131,8 +131,9 @@ test.run(arguments = ldmodule_prefix+'foo' + _dll) test.must_not_exist(test.workpath('wrapper.out')) test.run(program = python, stdin = """\ +from __future__ import print_function import foo -print foo.foo_string() +print(foo.foo_string()) """, stdout="""\ This is foo.c! """) @@ -144,10 +145,11 @@ test.run(arguments = ldmodule_prefix+'bar' + _dll) test.must_match('wrapper.out', "wrapper.py\n") test.run(program = python, stdin = """\ +from __future__ import print_function import foo import bar -print foo.foo_string() -print bar.bar_string() +print(foo.foo_string()) +print(bar.bar_string()) """, stdout="""\ This is foo.c! This is bar.c! diff --git a/test/Scanner/FindPathDirs.py b/test/Scanner/FindPathDirs.py index ef3ea46d..7f8b993e 100644 --- a/test/Scanner/FindPathDirs.py +++ b/test/Scanner/FindPathDirs.py @@ -41,14 +41,14 @@ test.write('build.py', r""" import os.path import sys path = sys.argv[1].split() -input = open(sys.argv[2], 'rb') -output = open(sys.argv[3], 'wb') +input = open(sys.argv[2], 'r') +output = open(sys.argv[3], 'w') def find_file(f): for dir in path: p = dir + os.sep + f if os.path.exists(p): - return open(p, 'rb') + return open(p, 'r') return None def process(infp, outfp): diff --git a/test/Scanner/Scanner.py b/test/Scanner/Scanner.py index 8d48b730..625b3729 100644 --- a/test/Scanner/Scanner.py +++ b/test/Scanner/Scanner.py @@ -32,14 +32,14 @@ test = TestSCons.TestSCons() test.write('build.py', r""" import sys -input = open(sys.argv[1], 'rb') -output = open(sys.argv[2], 'wb') +input = open(sys.argv[1], 'r') +output = open(sys.argv[2], 'w') def process(infp, outfp): for line in infp.readlines(): if line[:8] == 'include ': file = line[8:-1] - process(open(file, 'rb'), outfp) + process(open(file, 'r'), outfp) elif line[:8] == 'getfile ': outfp.write('include ') outfp.write(line[8:]) @@ -114,7 +114,7 @@ bar = env.BarBld(target='bar', source='bar.in') # automatically applied to targets generated from that Builder def blork(env, target, source): - open(str(target[0]), 'wb').write( + open(str(target[0]), 'w').write( source[0].get_text_contents().replace('getfile', 'MISSEDME')) kbld = Builder(action=r'%(_python_)s build.py $SOURCES $TARGET', diff --git a/test/Scanner/generated.py b/test/Scanner/generated.py index 7246cbe4..9dd2a86b 100644 --- a/test/Scanner/generated.py +++ b/test/Scanner/generated.py @@ -301,7 +301,7 @@ import os Scanned = {} def write_out(file, dict): - f = open(file, 'wb') + f = open(file, 'w') for k in sorted(dict.keys()): file = os.path.split(k)[1] f.write(file + ": " + str(dict[k]) + "\\n") diff --git a/test/Scanner/no-Dir-node.py b/test/Scanner/no-Dir-node.py index 3a918bff..123764e8 100644 --- a/test/Scanner/no-Dir-node.py +++ b/test/Scanner/no-Dir-node.py @@ -54,16 +54,16 @@ test.write('build.py', r""" import os.path import sys path = sys.argv[1].split() -input = open(sys.argv[2], 'rb') -output = open(sys.argv[3], 'wb') +input = open(sys.argv[2], 'r') +output = open(sys.argv[3], 'w') def find_file(f): if os.path.isabs(f): - return open(f, 'rb') + return open(f, 'r') for dir in path: p = dir + os.sep + f if os.path.exists(p): - return open(p, 'rb') + return open(p, 'r') return None def process(infp, outfp): @@ -81,7 +81,7 @@ sys.exit(0) test.write('SConstruct', """\ def foo(target, source, env): - fp = open(str(target[0]), 'wb') + fp = open(str(target[0]), 'w') for c in sorted(source[0].children(), key=lambda t: t.name): fp.write('%s\\n' % c) fp.close() diff --git a/test/TAR/TAR.py b/test/TAR/TAR.py index 8aa2747b..65e6182f 100644 --- a/test/TAR/TAR.py +++ b/test/TAR/TAR.py @@ -44,15 +44,11 @@ for opt, arg in opts: if opt == '-f': out = arg def process(outfile, name): if os.path.isdir(name): - ## TODO 2.4: the next three lines can be replaced by - #for entry in sorted(os.listdir(name)): - list = os.listdir(name) - list.sort() - for entry in list: + for entry in sorted(os.listdir(name)): process(outfile, os.path.join(name, entry)) else: - outfile.write(open(name, 'rb').read()) -outfile = open(out, 'wb') + outfile.write(open(name, 'r').read()) +outfile = open(out, 'w') for infile in args: process(outfile, infile) outfile.close() @@ -77,11 +73,11 @@ test.write(['sub1', 'file6'], "sub1/file6\n") test.run(arguments = 'aaa.tar', stderr = None) -test.fail_test(test.read('aaa.tar') != "file1\nfile2\nfile3\n") +test.must_match('aaa.tar', "file1\nfile2\nfile3\n", mode='r') test.run(arguments = 'bbb.tar', stderr = None) -test.fail_test(test.read('bbb.tar') != "sub1/file5\nsub1/file6\nfile4\n") +test.must_match('bbb.tar', "sub1/file5\nsub1/file6\nfile4\n", mode='r') tar = test.detect('TAR', 'tar') diff --git a/test/TAR/TARFLAGS.py b/test/TAR/TARFLAGS.py index 034539c2..e1eae0f4 100644 --- a/test/TAR/TARFLAGS.py +++ b/test/TAR/TARFLAGS.py @@ -46,15 +46,11 @@ for opt, arg in cmd_opts: else: opt_string = opt_string + ' ' + opt def process(outfile, name): if os.path.isdir(name): - ## TODO 2.5: the next three lines can be replaced by - #for entry in sorted(os.listdir(name)): - entries = os.listdir(name) - entries.sort() - for entry in entries: + for entry in sorted(os.listdir(name)): process(outfile, os.path.join(name, entry)) else: - outfile.write(open(name, 'rb').read()) -outfile = open(out, 'wb') + outfile.write(open(name, 'r').read()) +outfile = open(out, 'w') outfile.write('options: %s\\n' % opt_string) for infile in args: process(outfile, infile) @@ -82,11 +78,11 @@ test.write(['sub1', 'file6'], "sub1/file6\n") test.run(arguments = 'aaa.tar', stderr = None) -test.fail_test(test.read('aaa.tar') != "options: -x\nfile1\nfile2\nfile3\n") +test.must_match('aaa.tar', "options: -x\nfile1\nfile2\nfile3\n", mode='r') test.run(arguments = 'bbb.tar', stderr = None) -test.fail_test(test.read('bbb.tar') != "options: -x\nsub1/file5\nsub1/file6\nfile4\n") +test.must_match('bbb.tar', "options: -x\nsub1/file5\nsub1/file6\nfile4\n", mode='r') diff --git a/test/TEMPFILEPREFIX.py b/test/TEMPFILEPREFIX.py index 8e756afb..f0743e60 100644 --- a/test/TEMPFILEPREFIX.py +++ b/test/TEMPFILEPREFIX.py @@ -38,8 +38,9 @@ test = TestSCons.TestSCons(match = TestSCons.match_re) test.write('echo.py', """\ #!/usr/bin/env python +from __future__ import print_function import sys -print sys.argv +print(sys.argv) """) echo_py = test.workpath('echo.py') diff --git a/test/TEX/LATEXFLAGS.py b/test/TEX/LATEXFLAGS.py index 46e0479d..48cfa9c0 100644 --- a/test/TEX/LATEXFLAGS.py +++ b/test/TEX/LATEXFLAGS.py @@ -43,8 +43,8 @@ opt_string = '' for opt, arg in cmd_opts: opt_string = opt_string + ' ' + opt base_name = os.path.splitext(args[0])[0] -infile = open(args[0], 'rb') -out_file = open(base_name+'.dvi', 'wb') +infile = open(args[0], 'r') +out_file = open(base_name+'.dvi', 'w') out_file.write(opt_string + "\n") for l in infile.readlines(): if l[0] != '\\': @@ -70,9 +70,9 @@ test.write('test2.latex', r"""This is a .latex test. test.run(arguments = '.', stderr = None) -test.fail_test(test.read('test1.dvi') != " -x\nThis is a .ltx test.\n") +test.must_match('test1.dvi', " -x\nThis is a .ltx test.\n", mode='r') -test.fail_test(test.read('test2.dvi') != " -t\nThis is a .latex test.\n") +test.must_match('test2.dvi', " -t\nThis is a .latex test.\n", mode='r') @@ -111,7 +111,7 @@ This is the %s LaTeX file. test.run(arguments = 'bar.dvi', stderr = None) - test.fail_test(test.read('wrapper.out') != "wrapper.py\n") + test.must_match('wrapper.out', "wrapper.py\n", mode='r') test.fail_test(not os.path.exists(test.workpath('bar.dvi'))) diff --git a/test/Variables/Variables.py b/test/Variables/Variables.py index d08594db..17b33afa 100644 --- a/test/Variables/Variables.py +++ b/test/Variables/Variables.py @@ -320,7 +320,10 @@ opts.Add('UNSPECIFIED', env = Environment(variables=opts) -Help('Variables settable in custom.py or on the command line:\\n' + opts.GenerateHelpText(env,sort=cmp)) +def compare(a,b): + return a < b + +Help('Variables settable in custom.py or on the command line:\\n' + opts.GenerateHelpText(env,sort=compare)) """) diff --git a/test/VariantDir/Clean.py b/test/VariantDir/Clean.py index d1e0bb84..b2e93a33 100644 --- a/test/VariantDir/Clean.py +++ b/test/VariantDir/Clean.py @@ -43,8 +43,8 @@ VariantDir('build1', '.', duplicate=1) def build_sample(target, source, env): targetdir = str(target[0].dir) target = str(target[0]) - open(target, 'wb').write(open(str(source[0]), 'rb').read()) - open(targetdir+'/sample.junk', 'wb').write('Side effect!\\n') + open(target, 'w').write(open(str(source[0]), 'r').read()) + open(targetdir+'/sample.junk', 'w').write('Side effect!\\n') t0 = Command("build0/sample.out", "sample.in", build_sample) t1 = Command("build1/sample.out", "sample.in", build_sample) diff --git a/test/VariantDir/File-create.py b/test/VariantDir/File-create.py index 725404ce..50db618e 100644 --- a/test/VariantDir/File-create.py +++ b/test/VariantDir/File-create.py @@ -49,12 +49,12 @@ SConscript('src/SConscript', variant_dir='build1', chdir=1, duplicate=1) test.write(['src', 'SConscript'], """\ #f1_in = File('f1.in') #Command('f1.out', f1_in, Copy('$TARGET', '$SOURCE')) -#open('f1.in', 'wb').write("f1.in\\n") +#open('f1.in', 'w').write("f1.in\\n") f2_in = File('f2.in') str(f2_in) Command('f2.out', f2_in, Copy('$TARGET', '$SOURCE')) -open('f2.in', 'wb').write("f2.in\\n") +open('f2.in', 'w').write("f2.in\\n") """) test.run(arguments = '--tree=all .') diff --git a/test/VariantDir/errors.py b/test/VariantDir/errors.py index d1490d42..c74d1037 100644 --- a/test/VariantDir/errors.py +++ b/test/VariantDir/errors.py @@ -57,9 +57,9 @@ def fake_scan(node, env, target): def cat(env, source, target): target = str(target[0]) - f = open(target, "wb") + f = open(target, "w") for src in source: - f.write(open(str(src), "rb").read()) + f.write(open(str(src), "r").read()) f.close() env = Environment(BUILDERS={'Build':Builder(action=cat)}, @@ -77,7 +77,7 @@ env.Build('file.out', 'file.in') # Just verify that the normal case works fine. test.run(chdir = 'normal', arguments = ".") -test.fail_test(test.read(['normal', 'build', 'file.out']) != "normal/src/file.in\n") +test.must_match(['normal', 'build', 'file.out'], "normal/src/file.in\n", mode='r') # Verify the error when the VariantDir itself is read-only. Don't bother # to test this on Windows, because the ACL (I think) still allows the diff --git a/test/builderrors.py b/test/builderrors.py index 3d443bf7..a3e2f4de 100644 --- a/test/builderrors.py +++ b/test/builderrors.py @@ -38,8 +38,8 @@ test.write('build.py', r""" import sys exitval = int(sys.argv[1]) if exitval == 0: - contents = open(sys.argv[3], 'rb').read() - file = open(sys.argv[2], 'wb') + contents = open(sys.argv[3], 'r').read() + file = open(sys.argv[2], 'w') file.write(contents) file.close() sys.exit(exitval) @@ -81,7 +81,7 @@ test.write(['two', 'f3.in'], "two/f3.in\n") test.run(chdir = 'two', arguments = "f1.out f2.out f3.out", stderr = "scons: *** [f2.out] Error 1\n", status = 2) -test.fail_test(test.read(['two', 'f1.out']) != "two/f1.in\n") +test.must_match(['two', 'f1.out'], "two/f1.in\n", mode='r') test.fail_test(os.path.exists(test.workpath('f2.out'))) test.fail_test(os.path.exists(test.workpath('f3.out'))) @@ -101,8 +101,8 @@ test.write(['three', 'f3.in'], "three/f3.in\n") test.run(chdir = 'three', arguments = "f1.out f2.out f3.out", stderr = "scons: *** [f3.out] Error 1\n", status = 2) -test.fail_test(test.read(['three', 'f1.out']) != "three/f1.in\n") -test.fail_test(test.read(['three', 'f2.out']) != "three/f2.in\n") +test.must_match(['three', 'f1.out'], "three/f1.in\n", mode='r') +test.must_match(['three', 'f2.out'], "three/f2.in\n", mode='r') test.fail_test(os.path.exists(test.workpath('f3.out'))) test.write('SConstruct', """ @@ -171,6 +171,7 @@ test.must_not_contain_any_line(test.stderr(), ['Exception', 'Traceback']) # Should not give traceback; the task error should get converted # to a BuildError. test.write('SConstruct', """ +from __future__ import print_function import atexit env = Environment() @@ -182,7 +183,7 @@ env2.Install("target", "dir2/myFile") def print_build_failures(): from SCons.Script import GetBuildFailures for bf in GetBuildFailures(): - print bf.action + print(bf.action) atexit.register(print_build_failures) """) diff --git a/test/fixture/wrapper.py b/test/fixture/wrapper.py index f02ea03d..bd8187cc 100644 --- a/test/fixture/wrapper.py +++ b/test/fixture/wrapper.py @@ -2,5 +2,5 @@ import os import sys if '--version' not in sys.argv and '-dumpversion' not in sys.argv: path = os.path.join(os.path.dirname(os.path.relpath(__file__)), 'wrapper.out') - open(path, 'wb').write(b"wrapper.py\n") + open(path, 'w').write("wrapper.py\n") os.system(" ".join(sys.argv[1:])) diff --git a/test/fixture/wrapper_with_args.py b/test/fixture/wrapper_with_args.py new file mode 100644 index 00000000..fccab729 --- /dev/null +++ b/test/fixture/wrapper_with_args.py @@ -0,0 +1,7 @@ +import os +import sys + +path = os.path.join(os.path.dirname(os.path.relpath(__file__)), 'wrapper.out') + +open(path, 'a').write("wrapper_with_args.py %s\n" % " ".join(sys.argv[1:])) +os.system(" ".join(sys.argv[1:])) diff --git a/test/option--.py b/test/option--.py index 3c932c06..8e06260e 100644 --- a/test/option--.py +++ b/test/option--.py @@ -34,7 +34,7 @@ test = TestSCons.TestSCons() test.write('build.py', r""" import sys -file = open(sys.argv[1], 'wb') +file = open(sys.argv[1], 'w') file.write("build.py: %s\n" % sys.argv[1]) file.close() """) diff --git a/test/option--Q.py b/test/option--Q.py index 4322bcd0..da6d2e12 100644 --- a/test/option--Q.py +++ b/test/option--Q.py @@ -34,7 +34,7 @@ test = TestSCons.TestSCons() test.write('build.py', r""" import sys -file = open(sys.argv[1], 'wb') +file = open(sys.argv[1], 'w') file.write("build.py: %s\n" % sys.argv[1]) file.close() """) diff --git a/test/option-i.py b/test/option-i.py index b32bd9cd..9b5212d4 100644 --- a/test/option-i.py +++ b/test/option-i.py @@ -34,7 +34,7 @@ test = TestSCons.TestSCons() test.write('succeed.py', r""" import sys -file = open(sys.argv[1], 'wb') +file = open(sys.argv[1], 'w') file.write("succeed.py: %s\n" % sys.argv[1]) file.close() sys.exit(0) @@ -73,22 +73,21 @@ test.run(arguments = '-i aaa.1 aaa.out bbb.1 bbb.out', 'scons: *** [bbb.1] Error 1\n') test.fail_test(os.path.exists(test.workpath('aaa.1'))) -test.fail_test(test.read('aaa.out') != "succeed.py: aaa.out\n") +test.fail_test(test.read('aaa.out',mode='r') != "succeed.py: aaa.out\n") test.fail_test(os.path.exists(test.workpath('bbb.1'))) -test.fail_test(test.read('bbb.out') != "succeed.py: bbb.out\n") +test.fail_test(test.read('bbb.out',mode='r') != "succeed.py: bbb.out\n") test.unlink("aaa.out") test.unlink("bbb.out") -test.run(arguments = '--ignore-errors aaa.1 aaa.out bbb.1 bbb.out', - stderr = - 'scons: *** [aaa.1] Error 1\n' +test.run(arguments='--ignore-errors aaa.1 aaa.out bbb.1 bbb.out', + stderr='scons: *** [aaa.1] Error 1\n' 'scons: *** [bbb.1] Error 1\n') test.fail_test(os.path.exists(test.workpath('aaa.1'))) -test.fail_test(test.read('aaa.out') != "succeed.py: aaa.out\n") +test.fail_test(test.read('aaa.out', mode='r') != "succeed.py: aaa.out\n") test.fail_test(os.path.exists(test.workpath('bbb.1'))) -test.fail_test(test.read('bbb.out') != "succeed.py: bbb.out\n") +test.fail_test(test.read('bbb.out', mode='r') != "succeed.py: bbb.out\n") test.pass_test() diff --git a/test/option-j.py b/test/option-j.py index 69ef4142..acd97f8b 100644 --- a/test/option-j.py +++ b/test/option-j.py @@ -51,7 +51,7 @@ test = TestSCons.TestSCons() test.write('build.py', r""" import time import sys -file = open(sys.argv[1], 'wb') +file = open(sys.argv[1], 'w') file.write(str(time.time()) + '\n') time.sleep(1) file.write(str(time.time())) diff --git a/test/option-k.py b/test/option-k.py index a367c653..7a01ed3b 100644 --- a/test/option-k.py +++ b/test/option-k.py @@ -38,7 +38,7 @@ test.subdir('work1', 'work2', 'work3') test.write('succeed.py', r""" import sys -file = open(sys.argv[1], 'wb') +file = open(sys.argv[1], 'w') file.write("succeed.py: %s\n" % sys.argv[1]) file.close() sys.exit(0) @@ -55,6 +55,7 @@ sys.exit(1) # test.write(['work1', 'SConstruct'], """\ +DefaultEnvironment(tools=[]) Succeed = Builder(action = r'%(_python_)s ../succeed.py $TARGETS') Fail = Builder(action = r'%(_python_)s ../fail.py $TARGETS') env = Environment(BUILDERS = { 'Succeed' : Succeed, 'Fail' : Fail }) @@ -82,7 +83,7 @@ test.run(chdir = 'work1', test.must_not_exist(test.workpath('work1', 'aaa.1')) test.must_not_exist(test.workpath('work1', 'aaa.out')) -test.must_match(['work1', 'bbb.out'], "succeed.py: bbb.out\n") +test.must_match(['work1', 'bbb.out'], "succeed.py: bbb.out\n", mode='r') test.unlink(['work1', 'bbb.out']) @@ -93,7 +94,7 @@ test.run(chdir = 'work1', test.must_not_exist(test.workpath('work1', 'aaa.1')) test.must_not_exist(test.workpath('work1', 'aaa.out')) -test.must_match(['work1', 'bbb.out'], "succeed.py: bbb.out\n") +test.must_match(['work1', 'bbb.out'], "succeed.py: bbb.out\n", mode='r') expect = """\ scons: Reading SConscript files ... @@ -118,6 +119,7 @@ test.must_not_exist(test.workpath('work1', 'bbb.out')) # test.write(['work2', 'SConstruct'], """\ +DefaultEnvironment(tools=[]) Succeed = Builder(action = r'%(_python_)s ../succeed.py $TARGETS') Fail = Builder(action = r'%(_python_)s ../fail.py $TARGETS') env = Environment(BUILDERS = { 'Succeed' : Succeed, 'Fail' : Fail }) @@ -146,8 +148,8 @@ scons: done building targets (errors occurred during build). test.must_not_exist(['work2', 'aaa.out']) test.must_not_exist(['work2', 'bbb.out']) -test.must_match(['work2', 'ccc.out'], "succeed.py: ccc.out\n") -test.must_match(['work2', 'ddd.out'], "succeed.py: ddd.out\n") +test.must_match(['work2', 'ccc.out'], "succeed.py: ccc.out\n", mode='r') +test.must_match(['work2', 'ddd.out'], "succeed.py: ddd.out\n", mode='r') @@ -173,6 +175,7 @@ test.must_match(['work2', 'ddd.out'], "succeed.py: ddd.out\n") # test.write(['work3', 'SConstruct'], """\ +DefaultEnvironment(tools=[]) Succeed = Builder(action = r'%(_python_)s ../succeed.py $TARGETS') Fail = Builder(action = r'%(_python_)s ../fail.py $TARGETS') env = Environment(BUILDERS = { 'Succeed' : Succeed, 'Fail' : Fail }) diff --git a/test/option-n.py b/test/option-n.py index a32dfb72..0fd7bfe7 100644 --- a/test/option-n.py +++ b/test/option-n.py @@ -52,7 +52,7 @@ test.subdir('build', 'src') test.write('build.py', r""" import sys -file = open(sys.argv[1], 'wb') +file = open(sys.argv[1], 'w') file.write("build.py: %s\n" % sys.argv[1]) file.close() """) diff --git a/test/option-s.py b/test/option-s.py index f79c3470..bbde2d14 100644 --- a/test/option-s.py +++ b/test/option-s.py @@ -34,7 +34,7 @@ test = TestSCons.TestSCons() test.write('build.py', r""" import sys -file = open(sys.argv[1], 'wb') +file = open(sys.argv[1], 'w') file.write("build.py: %s\n" % sys.argv[1]) file.close() """) diff --git a/test/scons-time/run/config/python.py b/test/scons-time/run/config/python.py index 26609272..07347306 100644 --- a/test/scons-time/run/config/python.py +++ b/test/scons-time/run/config/python.py @@ -62,9 +62,9 @@ prof0 = test.workpath('foo-000-0.prof') prof1 = test.workpath('foo-000-1.prof') prof2 = test.workpath('foo-000-2.prof') -test.must_match('foo-000-0.log', "my_python.py: %s\n" % prof0) -test.must_match('foo-000-1.log', "my_python.py: %s\n" % prof1) -test.must_match('foo-000-2.log', "my_python.py: %s\n" % prof2) +test.must_match('foo-000-0.log', "my_python.py: %s\n" % prof0, mode='r') +test.must_match('foo-000-1.log', "my_python.py: %s\n" % prof1, mode='r') +test.must_match('foo-000-2.log', "my_python.py: %s\n" % prof2, mode='r') test.pass_test() diff --git a/test/scons-time/run/config/scons.py b/test/scons-time/run/config/scons.py index 0c8b6434..b782e839 100644 --- a/test/scons-time/run/config/scons.py +++ b/test/scons-time/run/config/scons.py @@ -58,9 +58,9 @@ prof0 = test.workpath('foo-000-0.prof') prof1 = test.workpath('foo-000-1.prof') prof2 = test.workpath('foo-000-2.prof') -test.must_match('foo-000-0.log', "my_scons.py: %s\n" % prof0) -test.must_match('foo-000-1.log', "my_scons.py: %s\n" % prof1) -test.must_match('foo-000-2.log', "my_scons.py: %s\n" % prof2) +test.must_match('foo-000-0.log', "my_scons.py: %s\n" % prof0, mode='r') +test.must_match('foo-000-1.log', "my_scons.py: %s\n" % prof1, mode='r') +test.must_match('foo-000-2.log', "my_scons.py: %s\n" % prof2, mode='r') test.pass_test() diff --git a/test/scons-time/run/option/python.py b/test/scons-time/run/option/python.py index 70feb70a..d0592b61 100644 --- a/test/scons-time/run/option/python.py +++ b/test/scons-time/run/option/python.py @@ -57,9 +57,9 @@ prof0 = test.workpath('foo-000-0.prof') prof1 = test.workpath('foo-000-1.prof') prof2 = test.workpath('foo-000-2.prof') -test.must_match('foo-000-0.log', "my_python.py: %s\n" % prof0) -test.must_match('foo-000-1.log', "my_python.py: %s\n" % prof1) -test.must_match('foo-000-2.log', "my_python.py: %s\n" % prof2) +test.must_match('foo-000-0.log', "my_python.py: %s\n" % prof0, mode='r') +test.must_match('foo-000-1.log', "my_python.py: %s\n" % prof1, mode='r') +test.must_match('foo-000-2.log', "my_python.py: %s\n" % prof2, mode='r') test.pass_test() diff --git a/test/scons-time/run/option/scons.py b/test/scons-time/run/option/scons.py index 71d8ca2b..e2479c3b 100644 --- a/test/scons-time/run/option/scons.py +++ b/test/scons-time/run/option/scons.py @@ -52,9 +52,9 @@ prof0 = test.workpath('foo-000-0.prof') prof1 = test.workpath('foo-000-1.prof') prof2 = test.workpath('foo-000-2.prof') -test.must_match('foo-000-0.log', "my_scons.py: %s\n" % prof0) -test.must_match('foo-000-1.log', "my_scons.py: %s\n" % prof1) -test.must_match('foo-000-2.log', "my_scons.py: %s\n" % prof2) +test.must_match('foo-000-0.log', "my_scons.py: %s\n" % prof0, mode='r') +test.must_match('foo-000-1.log', "my_scons.py: %s\n" % prof1, mode='r') +test.must_match('foo-000-2.log', "my_scons.py: %s\n" % prof2, mode='r') test.pass_test() diff --git a/test/subdivide.py b/test/subdivide.py index 770870dd..8c8eff02 100644 --- a/test/subdivide.py +++ b/test/subdivide.py @@ -80,6 +80,7 @@ test.chmod(fake_cc_py, 0o755) test.chmod(fake_link_py, 0o755) test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) SConsignFile(None) env = Environment(PROGSUFFIX = '.exe', OBJSUFFIX = '.obj', @@ -91,6 +92,7 @@ env.Object('foo.c') """ % locals()) test.write(['src', 'SConstruct'], """\ +DefaultEnvironment(tools=[]) SConsignFile(None) env = Environment(PROGSUFFIX = '.exe', OBJSUFFIX = '.obj', @@ -134,7 +136,7 @@ src/sub/bar.c if os.sep == '\\': expect = expect.replace('\\', '\\\\') -test.must_match(['src', 'prog.exe'], expect) +test.must_match(['src', 'prog.exe'], expect, mode='r') test.up_to_date(chdir='src', arguments = test.workpath()) |