summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--QMTest/TestCmd.py16
-rw-r--r--QMTest/TestCommon.py2
-rw-r--r--QMTest/TestSCons.py6
-rw-r--r--QMTest/scons_tdb.py2
-rw-r--r--bench/bench.py2
-rw-r--r--bin/SConsDoc.py2
-rw-r--r--bin/SConsExamples.py4
-rw-r--r--bin/caller-tree.py2
-rw-r--r--bin/memoicmp.py8
-rw-r--r--bin/objcounts.py4
-rw-r--r--bin/scons-diff.py2
-rw-r--r--bin/scons-proc.py2
-rw-r--r--src/engine/SCons/Action.py6
-rw-r--r--src/engine/SCons/ActionTests.py6
-rw-r--r--src/engine/SCons/Builder.py2
-rw-r--r--src/engine/SCons/BuilderTests.py4
-rw-r--r--src/engine/SCons/Debug.py4
-rw-r--r--src/engine/SCons/Defaults.py2
-rw-r--r--src/engine/SCons/Environment.py34
-rw-r--r--src/engine/SCons/EnvironmentTests.py2
-rw-r--r--src/engine/SCons/Node/Alias.py2
-rw-r--r--src/engine/SCons/Node/FS.py8
-rw-r--r--src/engine/SCons/Node/Python.py2
-rw-r--r--src/engine/SCons/Node/__init__.py16
-rw-r--r--src/engine/SCons/SConf.py4
-rw-r--r--src/engine/SCons/SConsign.py10
-rw-r--r--src/engine/SCons/Scanner/LaTeX.py4
-rw-r--r--src/engine/SCons/Script/Interactive.py4
-rw-r--r--src/engine/SCons/Script/Main.py2
-rw-r--r--src/engine/SCons/Script/SConsOptions.py2
-rw-r--r--src/engine/SCons/Script/SConscript.py2
-rw-r--r--src/engine/SCons/Taskmaster.py2
-rw-r--r--src/engine/SCons/Tool/MSCommon/common.py4
-rw-r--r--src/engine/SCons/Tool/MSCommon/vc.py2
-rw-r--r--src/engine/SCons/Tool/MSCommon/vs.py2
-rw-r--r--src/engine/SCons/Tool/aixlink.py2
-rw-r--r--src/engine/SCons/Tool/docbook/__init__.py2
-rw-r--r--src/engine/SCons/Tool/gnulink.py2
-rw-r--r--src/engine/SCons/Tool/install.py2
-rw-r--r--src/engine/SCons/Tool/intelc.py4
-rw-r--r--src/engine/SCons/Tool/msvs.py26
-rw-r--r--src/engine/SCons/Tool/msvsTests.py10
-rw-r--r--src/engine/SCons/Tool/packaging/__init__.py2
-rw-r--r--src/engine/SCons/Tool/packaging/ipk.py2
-rw-r--r--src/engine/SCons/Tool/packaging/msi.py6
-rw-r--r--src/engine/SCons/Tool/packaging/rpm.py4
-rw-r--r--src/engine/SCons/Tool/rpmutils.py2
-rw-r--r--src/engine/SCons/Tool/swig.py2
-rw-r--r--src/engine/SCons/Util.py30
-rw-r--r--src/engine/SCons/Variables/EnumVariableTests.py4
-rw-r--r--src/engine/SCons/Variables/__init__.py2
-rw-r--r--src/engine/SCons/cpp.py8
-rw-r--r--src/engine/SCons/dblite.py9
-rw-r--r--src/script/scons-configure-cache.py276
-rw-r--r--src/script/scons-time.py4
-rw-r--r--src/test_files.py2
-rw-r--r--src/test_interrupts.py2
-rw-r--r--test/AR/AR.py6
-rw-r--r--test/AR/ARCOM.py2
-rw-r--r--test/AR/ARCOMSTR.py2
-rw-r--r--test/AR/ARFLAGS.py6
-rw-r--r--test/ARGUMENTS.py4
-rw-r--r--test/AS/AS.py8
-rw-r--r--test/AS/ASCOM.py18
-rw-r--r--test/AS/ASCOMSTR.py10
-rw-r--r--test/AS/ASPPCOM.py10
-rw-r--r--test/AS/ASPPCOMSTR.py6
-rw-r--r--test/AS/as-live.py2
-rw-r--r--test/AS/ml.py2
-rw-r--r--test/AS/nasm.py2
-rw-r--r--test/Actions/actions.py10
-rw-r--r--test/Actions/addpost-link-fixture/.exclude_tests1
-rw-r--r--test/Actions/addpost-link-fixture/strip.py2
-rw-r--r--test/Actions/addpost-link-fixture/test1.c5
-rw-r--r--test/Actions/addpost-link-fixture/test_lib.c5
-rw-r--r--test/Actions/addpost-link.py21
-rw-r--r--test/Actions/append-fixture/foo.c7
-rw-r--r--test/Actions/append.py21
-rw-r--r--test/Actions/pre-post-fixture/work1/bar.c7
-rw-r--r--test/Actions/pre-post-fixture/work1/foo.c7
-rw-r--r--test/Actions/pre-post-fixture/work2/SConstruct26
-rw-r--r--test/Actions/pre-post-fixture/work3/SConstruct10
-rw-r--r--test/Actions/pre-post-fixture/work4/.exclude_tests1
-rw-r--r--test/Actions/pre-post-fixture/work4/file.in1
-rw-r--r--test/Actions/pre-post.py98
-rw-r--r--test/Actions/unicode-signature-fixture/SConstruct11
-rw-r--r--test/Actions/unicode-signature.py14
-rw-r--r--test/CC/CC-fixture/bar.c10
-rw-r--r--test/CC/CC-fixture/foo.c10
-rw-r--r--test/CC/CC-fixture/test1.c3
-rw-r--r--test/CC/CC-fixture/test2.C3
-rw-r--r--test/CC/CC.py57
-rw-r--r--test/CC/CCCOM.py16
-rw-r--r--test/CC/CCCOMSTR.py16
-rw-r--r--test/CC/CCVERSION-fixture/.exclude_tests1
-rw-r--r--test/CC/CCVERSION-fixture/versioned.py12
-rw-r--r--test/CC/CCVERSION.py29
-rw-r--r--test/CC/SHCC.py6
-rw-r--r--test/CC/SHCCCOM.py16
-rw-r--r--test/CC/SHCCCOMSTR.py16
-rw-r--r--test/CC/shared-fixture/.exclude_tests1
-rw-r--r--test/CC/shared-fixture/mycc.py6
-rw-r--r--test/CC/shared-fixture/test1.c2
-rw-r--r--test/CFILESUFFIX.py2
-rw-r--r--test/QT/QTFLAGS.py2
-rw-r--r--test/SWIG/SWIGCOM.py2
-rw-r--r--test/SWIG/SWIGCOMSTR.py2
-rw-r--r--test/YACC/YACC-fixture/.exclude_tests1
-rw-r--r--test/YACC/YACC-fixture/aaa.y2
-rw-r--r--test/YACC/YACC-fixture/bbb.yacc2
-rw-r--r--test/YACC/YACC-fixture/ccc.yy2
-rw-r--r--test/YACC/YACC-fixture/ddd.ym2
-rw-r--r--test/YACC/YACC-fixture/myyacc.py13
-rw-r--r--test/YACC/YACC.py25
-rw-r--r--test/YACC/YACCCOM-fixture/.exclude_tests1
-rw-r--r--test/YACC/YACCCOM-fixture/myyacc.py7
-rw-r--r--test/YACC/YACCCOM.py16
-rw-r--r--test/YACC/YACCCOMSTR.py16
-rw-r--r--test/YACC/YACCFLAGS-fixture/.exclude_tests1
-rw-r--r--test/YACC/YACCFLAGS-fixture/myyacc.py17
-rw-r--r--test/YACC/YACCFLAGS.py22
-rw-r--r--test/YACC/YACCHFILESUFFIX.py4
-rw-r--r--test/YACC/YACCHXXFILESUFFIX.py4
-rw-r--r--test/YACC/YACCVCGFILESUFFIX.py4
-rw-r--r--test/YACC/shared-fixture/.exclude_tests1
-rw-r--r--test/YACC/shared-fixture/aaa.y2
-rw-r--r--test/YACC/shared-fixture/bbb.yacc2
-rw-r--r--test/ZIP/ZIP.py16
-rw-r--r--test/ZIP/ZIPCOM-fixture/.exclude_tests1
-rw-r--r--test/ZIP/ZIPCOM-fixture/myzip.py6
-rw-r--r--test/ZIP/ZIPCOM-fixture/test1.in2
-rw-r--r--test/ZIP/ZIPCOM.py18
-rw-r--r--test/ZIP/ZIPCOMSTR-fixture/.exclude_tests1
-rw-r--r--test/ZIP/ZIPCOMSTR-fixture/aaa.in2
-rw-r--r--test/ZIP/ZIPCOMSTR-fixture/myzip.py7
-rw-r--r--test/ZIP/ZIPCOMSTR.py16
-rw-r--r--test/file-names.py6
137 files changed, 608 insertions, 729 deletions
diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py
index b0a456b..bff0d6a 100644
--- a/QMTest/TestCmd.py
+++ b/QMTest/TestCmd.py
@@ -328,12 +328,24 @@ __all__ = [
'match_re_dotall',
'python',
'_python_',
- 'TestCmd'
+ 'TestCmd',
+ 'to_bytes',
+ 'to_str',
]
def is_List(e):
return isinstance(e, (list, UserList))
+def to_bytes (s):
+ if isinstance (s, bytes) or bytes is str:
+ return s
+ return bytes (s, 'utf-8')
+
+def to_str (s):
+ if bytes is str or is_String(s):
+ return s
+ return str (s, 'utf-8')
+
try:
eval('unicode')
except NameError:
@@ -513,6 +525,8 @@ def simple_diff(a, b, fromfile='', tofile='',
(diff -c) and difflib.unified_diff (diff -u) but which prints
output like the simple, unadorned 'diff" command.
"""
+ a = [to_str(q) for q in a]
+ b = [to_str(q) for q in b]
sm = difflib.SequenceMatcher(None, a, b)
def comma(x1, x2):
return x1+1 == x2 and str(x2) or '%s,%s' % (x1+1, x2)
diff --git a/QMTest/TestCommon.py b/QMTest/TestCommon.py
index f878636..9093cc9 100644
--- a/QMTest/TestCommon.py
+++ b/QMTest/TestCommon.py
@@ -479,7 +479,7 @@ class TestCommon(TestCmd):
if not match:
match = self.match
try:
- self.fail_test(not match(file_contents, expect))
+ self.fail_test(not match(to_str(file_contents), to_str(expect)))
except KeyboardInterrupt:
raise
except:
diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py
index 98b2f00..0d5dc90 100644
--- a/QMTest/TestSCons.py
+++ b/QMTest/TestSCons.py
@@ -1233,7 +1233,7 @@ class TimeSCons(TestSCons):
self.variables = kw.get('variables')
default_calibrate_variables = []
if self.variables is not None:
- for variable, value in self.variables.items():
+ for variable, value in list(self.variables.items()):
value = os.environ.get(variable, value)
try:
value = int(value)
@@ -1289,7 +1289,7 @@ class TimeSCons(TestSCons):
"""
if 'options' not in kw and self.variables:
options = []
- for variable, value in self.variables.items():
+ for variable, value in list(self.variables.items()):
options.append('%s=%s' % (variable, value))
kw['options'] = ' '.join(options)
if self.calibrate:
@@ -1315,7 +1315,7 @@ class TimeSCons(TestSCons):
self.elapsed_time(),
"seconds",
sort=0)
- for name, args in stats.items():
+ for name, args in list(stats.items()):
self.trace(name, trace, **args)
def uptime(self):
diff --git a/QMTest/scons_tdb.py b/QMTest/scons_tdb.py
index 76c7fe1..f5c0ae5 100644
--- a/QMTest/scons_tdb.py
+++ b/QMTest/scons_tdb.py
@@ -92,7 +92,7 @@ def get_explicit_arguments(e):
# Determine which subset of the 'arguments' have been set
# explicitly.
explicit_arguments = {}
- for name, field in arguments.items():
+ for name, field in list(arguments.items()):
# Do not record computed fields.
if field.IsComputed():
continue
diff --git a/bench/bench.py b/bench/bench.py
index f1d18c6..cfdac2d 100644
--- a/bench/bench.py
+++ b/bench/bench.py
@@ -94,7 +94,7 @@ exec(open(args[0], 'rU').read())
try:
FunctionList
except NameError:
- function_names = sorted([x for x in locals().keys() if x[:4] == FunctionPrefix])
+ function_names = sorted([x for x in list(locals().keys()) if x[:4] == FunctionPrefix])
l = [locals()[f] for f in function_names]
FunctionList = [f for f in l if isinstance(f, types.FunctionType)]
diff --git a/bin/SConsDoc.py b/bin/SConsDoc.py
index d566644..2fe4f73 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 self.nsmap.items():
+ for key, val in list(self.nsmap.items()):
self.xpath_context.xpathRegisterNs(key, val)
def __del__(self):
diff --git a/bin/SConsExamples.py b/bin/SConsExamples.py
index dd9bfaf..a86968d 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 examples.items():
+ for key, value in list(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 examples.items():
+ for key, value in list(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/caller-tree.py b/bin/caller-tree.py
index 21cda4b..18cd9e1 100644
--- a/bin/caller-tree.py
+++ b/bin/caller-tree.py
@@ -87,7 +87,7 @@ def print_entry(e, level, calls):
else:
print()
-for e in [ e for e in AllCalls.values() if not e.calls ]:
+for e in [ e for e in list(AllCalls.values()) if not e.calls ]:
print_entry(e, 0, '')
# Local Variables:
diff --git a/bin/memoicmp.py b/bin/memoicmp.py
index 7f0369e..63f6538 100644
--- a/bin/memoicmp.py
+++ b/bin/memoicmp.py
@@ -31,14 +31,14 @@ def memoize_cmp(filea, fileb):
ma_o = []
mb_o = []
mab = []
- for k in ma.keys():
- if k in mb.keys():
+ for k in list(ma.keys()):
+ if k in list(mb.keys()):
if k not in mab:
mab.append(k)
else:
ma_o.append(k)
- for k in mb.keys():
- if k in ma.keys():
+ for k in list(mb.keys()):
+ if k in list(ma.keys()):
if k not in mab:
mab.append(k)
else:
diff --git a/bin/objcounts.py b/bin/objcounts.py
index 2bd8923..8b550d1 100644
--- a/bin/objcounts.py
+++ b/bin/objcounts.py
@@ -48,7 +48,7 @@ c1 = fetch_counts(sys.argv[1])
c2 = fetch_counts(sys.argv[2])
common = {}
-for k in c1.keys():
+for k in list(c1.keys()):
try:
common[k] = (c1[k], c2[k])
except KeyError:
@@ -59,7 +59,7 @@ for k in c1.keys():
if not '.' in k:
s = '.'+k
l = len(s)
- for k2 in c2.keys():
+ for k2 in list(c2.keys()):
if k2[-l:] == s:
common[k2] = (c1[k], c2[k2])
del c1[k]
diff --git a/bin/scons-diff.py b/bin/scons-diff.py
index 8597501..687e7fa 100644
--- a/bin/scons-diff.py
+++ b/bin/scons-diff.py
@@ -174,7 +174,7 @@ def diff_dir(left, right):
u[l] = 1
for r in rlist:
u[r] = 1
- for x in sorted([ x for x in u.keys() if x[-4:] != '.pyc' ]):
+ for x in sorted([ x for x in list(u.keys()) if x[-4:] != '.pyc' ]):
if x in llist:
if x in rlist:
do_diff(os.path.join(left, x),
diff --git a/bin/scons-proc.py b/bin/scons-proc.py
index e09c853..0747b2c 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 kw.items():
+ for k, v in list(kw.items()):
setattr(self, k, v)
def fopen(self, name):
diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py
index 7e1f8f1..de9bf5c 100644
--- a/src/engine/SCons/Action.py
+++ b/src/engine/SCons/Action.py
@@ -645,7 +645,7 @@ def _subproc(scons_env, cmd, error = 'ignore', **kw):
# Ensure that the ENV values are all strings:
new_env = {}
- for key, value in ENV.items():
+ for key, value in list(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
@@ -772,7 +772,7 @@ class CommandAction(_ActionAction):
ENV = get_default_ENV(env)
# Ensure that the ENV values are all strings:
- for key, value in ENV.items():
+ for key, value in list(ENV.items()):
if not is_String(value):
if is_List(value):
# If the value is a list, then we assume it is a
@@ -1206,7 +1206,7 @@ class ActionCaller(object):
def subst_kw(self, target, source, env):
kw = {}
- for key in self.kw.keys():
+ for key in list(self.kw.keys()):
kw[key] = self.subst(self.kw[key], target, source, env)
return kw
diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py
index 9007183..b790ccc 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 kw.items():
+ for k, v in list(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 kw.items():
+ for k, v in list(kw.items()):
res.d[k] = v
return res
def sig_dict(self):
d = {}
- for k,v in self.items(): d[k] = v
+ for k,v in list(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/Builder.py b/src/engine/SCons/Builder.py
index 50e85ec..c7bce3a 100644
--- a/src/engine/SCons/Builder.py
+++ b/src/engine/SCons/Builder.py
@@ -229,7 +229,7 @@ class OverrideWarner(collections.UserDict):
def warn(self):
if self.already_warned:
return
- for k in self.keys():
+ for k in list(self.keys()):
if k in misleading_keywords:
alt = misleading_keywords[k]
msg = "Did you mean to use `%s' instead of `%s'?" % (alt, k)
diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py
index 1e544a1..ca35abc 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 kw.items():
+ for k, v in list(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 self.items(): d[k] = v
+ for k,v in list(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 9e520ff..6ac5f27 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 obj.__dict__.items():
+ for key, value in list(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 caller_dicts[key].items()]):
+ for v,c in sorted([(-v,c) for c,v in list(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 f1d5bca..f095982 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 d.items():
+ for macro,value in list(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 d979005..ed8ef78 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 value.items():
+ for k, v in list(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 dict.items():
+ for i, v in list(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 kw.items():
+ for k, v in list(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 o.items():
+ for key, value in list(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 args.items():
+ for key, value in list(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 save.items():
+ for key, val in list(save.items()):
self._dict[key] = val
# Finally, apply any flags to be merged in
@@ -1185,7 +1185,7 @@ class Base(SubstitutionEnvironment):
if SCons.Util.is_List(val):
if key == 'CPPDEFINES':
tmp = []
- for (k, v) in orig.iteritems():
+ for (k, v) in orig.items():
if v is not None:
tmp.append((k, v))
else:
@@ -1247,7 +1247,7 @@ class Base(SubstitutionEnvironment):
values move to end.
"""
kw = copy_non_reserved_keywords(kw)
- for key, val in kw.items():
+ for key, val in list(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):
@@ -1273,7 +1273,7 @@ class Base(SubstitutionEnvironment):
# Construct a list of (key, value) tuples.
if SCons.Util.is_Dict(dk):
tmp = []
- for (k, v) in dk.iteritems():
+ for (k, v) in dk.items():
if v is not None:
tmp.append((k, v))
else:
@@ -1321,7 +1321,7 @@ class Base(SubstitutionEnvironment):
# Construct a list of (key, value) tuples.
if SCons.Util.is_Dict(val):
tmp = []
- for (k, v) in val.iteritems():
+ for (k, v) in val.items():
if v is not None:
tmp.append((k, v))
else:
@@ -1350,7 +1350,7 @@ class Base(SubstitutionEnvironment):
dk = [dk]
elif SCons.Util.is_Dict(dk):
tmp = []
- for (k, v) in dk.iteritems():
+ for (k, v) in dk.items():
if v is not None:
tmp.append((k, v))
else:
@@ -1363,7 +1363,7 @@ class Base(SubstitutionEnvironment):
val = [val]
elif SCons.Util.is_Dict(val):
tmp = []
- for i,j in val.items():
+ for i,j in list(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 kw.items():
+ for key, value in list(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 kw.items():
+ for key, val in list(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"
@@ -1696,7 +1696,7 @@ class Base(SubstitutionEnvironment):
values move to front.
"""
kw = copy_non_reserved_keywords(kw)
- for key, val in kw.items():
+ for key, val in list(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):
@@ -1833,7 +1833,7 @@ class Base(SubstitutionEnvironment):
uniq = {}
for executor in [n.get_executor() for n in nodes]:
uniq[executor] = 1
- for executor in uniq.keys():
+ for executor in list(uniq.keys()):
executor.add_pre_action(action)
return nodes
@@ -1843,7 +1843,7 @@ class Base(SubstitutionEnvironment):
uniq = {}
for executor in [n.get_executor() for n in nodes]:
uniq[executor] = 1
- for executor in uniq.keys():
+ for executor in list(uniq.keys()):
executor.add_post_action(action)
return nodes
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py
index 4b57763..e3259d4 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 default_keys.items():
+ for key, value in list(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 a035816..f229a9f 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 state.items():
+ for key, value in list(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 71511b5..9b7e105 100644
--- a/src/engine/SCons/Node/FS.py
+++ b/src/engine/SCons/Node/FS.py
@@ -1607,7 +1607,7 @@ class Dir(Base):
This clears any cached information that is invalidated by changing
the repository."""
- for node in self.entries.values():
+ for node in list(self.entries.values()):
if node != self.dir:
if node != self and isinstance(node, Dir):
node.__clearRepositoryCache(duplicate)
@@ -2179,7 +2179,7 @@ class Dir(Base):
for x in excludeList:
r = self.glob(x, ondisk, source, strings)
excludes.extend(r)
- result = filter(lambda x: not any(fnmatch.fnmatch(str(x), str(e)) for e in SCons.Util.flatten(excludes)), result)
+ result = [x for x in result if not any(fnmatch.fnmatch(str(x), str(e)) for e in SCons.Util.flatten(excludes))]
return sorted(result, key=lambda a: str(a))
def _glob1(self, pattern, ondisk=True, source=False, strings=False):
@@ -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 dir.entries.items()
+ node_names = [ v.name for k, v in list(dir.entries.items())
if k not in ('.', '..') ]
names.extend(node_names)
if not strings:
@@ -2481,7 +2481,7 @@ class FileNodeInfo(SCons.Node.NodeInfoBase):
"""
# TODO check or discard version
del state['_version_id']
- for key, value in state.items():
+ for key, value in list(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 f151fc5..92cc320 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 state.items():
+ for key, value in list(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 00ddf2f..2bf38c2 100644
--- a/src/engine/SCons/Node/__init__.py
+++ b/src/engine/SCons/Node/__init__.py
@@ -382,7 +382,7 @@ class NodeInfoBase(object):
try:
field_list = self.field_list
except AttributeError:
- field_list = getattr(self, '__dict__', {}).keys()
+ field_list = list(getattr(self, '__dict__', {}).keys())
for obj in type(self).mro():
for slot in getattr(obj, '__slots__', ()):
if slot not in ('__weakref__', '__dict__'):
@@ -427,7 +427,7 @@ class NodeInfoBase(object):
# TODO check or discard version
del state['_version_id']
- for key, value in state.items():
+ for key, value in list(state.items()):
if key not in ('__weakref__',):
setattr(self, key, value)
@@ -488,7 +488,7 @@ class BuildInfoBase(object):
"""
# TODO check or discard version
del state['_version_id']
- for key, value in state.items():
+ for key, value in list(state.items()):
if key not in ('__weakref__',):
setattr(self, key, value)
@@ -1338,7 +1338,7 @@ class Node(object, with_metaclass(NoSlotsPyPy)):
# dictionary patterns I found all ended up using "not in"
# internally anyway...)
if self.ignore_set:
- iter = chain.from_iterable(filter(None, [self.sources, self.depends, self.implicit]))
+ iter = chain.from_iterable([_f for _f in [self.sources, self.depends, self.implicit] if _f])
children = []
for i in iter:
@@ -1372,7 +1372,7 @@ class Node(object, with_metaclass(NoSlotsPyPy)):
# using dictionary keys, lose the order, and the only ordered
# dictionary patterns I found all ended up using "not in"
# internally anyway...)
- return list(chain.from_iterable(filter(None, [self.sources, self.depends, self.implicit])))
+ return list(chain.from_iterable([_f for _f in [self.sources, self.depends, self.implicit] if _f]))
def children(self, scan=1):
"""Return a list of the node's direct children, minus those
@@ -1396,7 +1396,7 @@ class Node(object, with_metaclass(NoSlotsPyPy)):
def Decider(self, function):
foundkey = None
- for k, v in _decider_map.iteritems():
+ for k, v in _decider_map.items():
if v == function:
foundkey = k
break
@@ -1609,8 +1609,8 @@ class Node(object, with_metaclass(NoSlotsPyPy)):
new_bkids = new.bsources + new.bdepends + new.bimplicit
new_bkidsigs = new.bsourcesigs + new.bdependsigs + new.bimplicitsigs
- osig = dict(zip(old_bkids, old_bkidsigs))
- nsig = dict(zip(new_bkids, new_bkidsigs))
+ osig = dict(list(zip(old_bkids, old_bkidsigs)))
+ nsig = dict(list(zip(new_bkids, new_bkidsigs)))
# The sources and dependencies we'll want to report are all stored
# as relative paths to this target's directory, but we want to
diff --git a/src/engine/SCons/SConf.py b/src/engine/SCons/SConf.py
index d56b333..c68d1c6 100644
--- a/src/engine/SCons/SConf.py
+++ b/src/engine/SCons/SConf.py
@@ -132,7 +132,7 @@ def CreateConfigHBuilder(env):
_stringConfigH)
sconfigHBld = SCons.Builder.Builder(action=action)
env.Append( BUILDERS={'SConfigHBuilder':sconfigHBld} )
- for k in _ac_config_hs.keys():
+ for k in list(_ac_config_hs.keys()):
env.SConfigHBuilder(k, env.Value(_ac_config_hs[k]))
@@ -671,7 +671,7 @@ class SConfBase(object):
"""Adds all the tests given in the tests dictionary to this SConf
instance
"""
- for name in tests.keys():
+ for name in list(tests.keys()):
self.AddTest(name, tests[name])
def _createDir( self, node ):
diff --git a/src/engine/SCons/SConsign.py b/src/engine/SCons/SConsign.py
index 3a5e5c0..75d2c41 100644
--- a/src/engine/SCons/SConsign.py
+++ b/src/engine/SCons/SConsign.py
@@ -155,7 +155,7 @@ class SConsignEntry(object):
return state
def __setstate__(self, state):
- for key, value in state.items():
+ for key, value in list(state.items()):
if key not in ('_version_id','__weakref__'):
setattr(self, key, value)
@@ -199,7 +199,7 @@ class Base(object):
pass
def merge(self):
- for key, node in self.to_be_merged.items():
+ for key, node in list(self.to_be_merged.items()):
entry = node.get_stored_info()
try:
ninfo = entry.ninfo
@@ -245,7 +245,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 self.entries.items():
+ for key, entry in list(self.entries.items()):
entry.convert_from_sconsign(dir, key)
if mode == "r":
@@ -272,7 +272,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 self.entries.items():
+ for key, entry in list(self.entries.items()):
entry.convert_to_sconsign()
db[path] = pickle.dumps(self.entries, PICKLE_PROTOCOL)
@@ -360,7 +360,7 @@ class DirFile(Dir):
fname = self.sconsign
except IOError:
return
- for key, entry in self.entries.items():
+ for key, entry in list(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 2cb1ed5..1e0fea1 100644
--- a/src/engine/SCons/Scanner/LaTeX.py
+++ b/src/engine/SCons/Scanner/LaTeX.py
@@ -200,14 +200,14 @@ class LaTeX(SCons.Scanner.Base):
"""
def __init__(self, dictionary):
self.dictionary = {}
- for k,n in dictionary.items():
+ for k,n in list(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 self.dictionary.items():
+ for k,(c,cENV) in list(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 e7a0658..3c3d23a 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 kw.items():
+ for key, val in list(kw.items()):
setattr(self, key, val)
if sys.platform == 'win32':
@@ -250,7 +250,7 @@ class SConsInteractiveCmd(cmd.Cmd):
while n:
n = walker.get_next()
- for node in seen_nodes.keys():
+ for node in list(seen_nodes.keys()):
# Call node.clear() to clear most of the state
node.clear()
# node.clear() doesn't reset node.state, so call
diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py
index c0b22a7..f8cb24c 100644
--- a/src/engine/SCons/Script/Main.py
+++ b/src/engine/SCons/Script/Main.py
@@ -727,7 +727,7 @@ def _load_site_scons_dir(topdir, site_dir_name=None):
modname = os.path.basename(pathname)[:-len(sfx)]
site_m = {"__file__": pathname, "__name__": modname, "__doc__": None}
re_special = re.compile("__[^_]+__")
- for k in m.__dict__.keys():
+ for k in list(m.__dict__.keys()):
if not re_special.match(k):
site_m[k] = m.__dict__[k]
diff --git a/src/engine/SCons/Script/SConsOptions.py b/src/engine/SCons/Script/SConsOptions.py
index b2f2858..501e4ce 100644
--- a/src/engine/SCons/Script/SConsOptions.py
+++ b/src/engine/SCons/Script/SConsOptions.py
@@ -638,7 +638,7 @@ def Parser(version):
for value in value__.split(','):
if value in debug_options:
parser.values.debug.append(value)
- elif value in deprecated_debug_options.keys():
+ elif value in list(deprecated_debug_options.keys()):
parser.values.debug.append(value)
try:
parser.values.delayed_warnings
diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py
index 6480ace..a7c8a37 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 kw.items():
+ for key, val in list(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 0f4fd21..461a556 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 parents.items():
+ for p, subtract in list(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 bcfee2b..b14eba1 100644
--- a/src/engine/SCons/Tool/MSCommon/common.py
+++ b/src/engine/SCons/Tool/MSCommon/common.py
@@ -114,7 +114,7 @@ def normalize_env(env, keys, force=False):
Note: the environment is copied."""
normenv = {}
if env:
- for k in env.keys():
+ for k in list(env.keys()):
normenv[k] = copy.deepcopy(env[k])
for k in keys:
@@ -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 rdk.items():
+ for k,v in list(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 f96b8ca..baa4025 100644
--- a/src/engine/SCons/Tool/MSCommon/vc.py
+++ b/src/engine/SCons/Tool/MSCommon/vc.py
@@ -514,7 +514,7 @@ def msvc_setup_env(env):
SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning, warn_msg)
return None
- for k, v in d.items():
+ for k, v in list(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 31197ef..4bda406 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 vars.items():
+ for k, v in list(vars.items()):
env.PrependENVPath(k, v, delete_existing=1)
def query_versions():
diff --git a/src/engine/SCons/Tool/aixlink.py b/src/engine/SCons/Tool/aixlink.py
index bfddf0a..3117c55 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 linkers.items():
+ for langvar, linktools in list(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/docbook/__init__.py b/src/engine/SCons/Tool/docbook/__init__.py
index 2b22e17..8a7b2e7 100644
--- a/src/engine/SCons/Tool/docbook/__init__.py
+++ b/src/engine/SCons/Tool/docbook/__init__.py
@@ -461,7 +461,7 @@ def DocbookEpub(env, target, source=None, *args, **kw):
# Create xpath context
xpath_context = doc.xpathNewContext()
# Register namespaces
- for key, val in nsmap.iteritems():
+ for key, val in nsmap.items():
xpath_context.xpathRegisterNs(key, val)
if hasattr(opf, 'xpathEval') and xpath_context:
diff --git a/src/engine/SCons/Tool/gnulink.py b/src/engine/SCons/Tool/gnulink.py
index b1d5088..cf1ce85 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 linkers.items():
+ for langvar, linktools in list(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/install.py b/src/engine/SCons/Tool/install.py
index e16bb5f..ee15753 100644
--- a/src/engine/SCons/Tool/install.py
+++ b/src/engine/SCons/Tool/install.py
@@ -244,7 +244,7 @@ def add_versioned_targets_to_INSTALLED_FILES(target, source, env):
Verbose = False
_INSTALLED_FILES.extend(target)
if Verbose:
- print("add_versioned_targets_to_INSTALLED_FILES: target={:r}".format(map(str, target)))
+ print("add_versioned_targets_to_INSTALLED_FILES: target={:r}".format(list(map(str, target))))
symlinks = listShlibLinksToInstall(target[0], source, env)
if symlinks:
SCons.Tool.EmitLibSymlinks(env, symlinks, target[0])
diff --git a/src/engine/SCons/Tool/intelc.py b/src/engine/SCons/Tool/intelc.py
index 185db9e..8ae02ef 100644
--- a/src/engine/SCons/Tool/intelc.py
+++ b/src/engine/SCons/Tool/intelc.py
@@ -500,14 +500,14 @@ def generate(env, version=None, abi=None, topdir=None, verbose=0):
'LIB' : libdir,
'PATH' : bindir,
'LD_LIBRARY_PATH' : libdir}
- for p in paths.keys():
+ for p in list(paths.keys()):
env.PrependENVPath(p, os.path.join(topdir, paths[p]))
if is_mac:
paths={'INCLUDE' : 'include',
'LIB' : libdir,
'PATH' : bindir,
'LD_LIBRARY_PATH' : libdir}
- for p in paths.keys():
+ for p in list(paths.keys()):
env.PrependENVPath(p, os.path.join(topdir, paths[p]))
if is_windows:
# env key reg valname default subdir of top
diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py
index 8166d7d..50f6b27 100644
--- a/src/engine/SCons/Tool/msvs.py
+++ b/src/engine/SCons/Tool/msvs.py
@@ -210,11 +210,11 @@ class _UserGenerator(object):
dbg_settings and bool([ds for ds in dbg_settings if ds])
if self.createfile:
- dbg_settings = dict(zip(variants, dbg_settings))
- for var, src in dbg_settings.items():
+ dbg_settings = dict(list(zip(variants, dbg_settings)))
+ for var, src in list(dbg_settings.items()):
# Update only expected keys
trg = {}
- for key in [k for k in self.usrdebg.keys() if k in src]:
+ for key in [k for k in list(self.usrdebg.keys()) if k in src]:
trg[key] = str(src[key])
self.configs[var].debug = trg
@@ -301,7 +301,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 debug.items()
+ for key, value in list(debug.items())
if value is not None])
self.usrfile.write(self.usrconf % locals())
self.usrfile.write('\t</Configurations>\n</VisualStudioUserFile>')
@@ -363,7 +363,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 debug.items()
+ for key, value in list(debug.items())
if value is not None])
self.usrfile.write(self.usrconf % locals())
self.usrfile.write('</Project>')
@@ -533,7 +533,7 @@ class _DSPGenerator(object):
AddConfig(self, variants[i], buildtarget[i], outdir[i], runfile[i], cmdargs[i])
self.platforms = []
- for key in self.configs.keys():
+ for key in list(self.configs.keys()):
platform = self.configs[key].platform
if not platform in self.platforms:
self.platforms.append(platform)
@@ -656,7 +656,7 @@ class _GenerateV6DSP(_DSPGenerator):
'Resource Files': 'r|rc|ico|cur|bmp|dlg|rc2|rct|bin|cnt|rtf|gif|jpg|jpeg|jpe',
'Other Files': ''}
- for kind in sorted(categories.keys(), key=lambda a: a.lower()):
+ for kind in sorted(list(categories.keys()), key=lambda a: a.lower()):
if not self.sources[kind]:
continue # skip empty groups
@@ -922,7 +922,7 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User):
self.file.write(pdata + '-->\n')
def printSources(self, hierarchy, commonprefix):
- sorteditems = sorted(hierarchy.items(), key=lambda a: a[0].lower())
+ sorteditems = sorted(list(hierarchy.items()), key=lambda a: a[0].lower())
# First folders, then files
for key, value in sorteditems:
@@ -952,7 +952,7 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User):
self.file.write('\t<Files>\n')
- cats = sorted([k for k in categories.keys() if self.sources[k]],
+ cats = sorted([k for k in list(categories.keys()) if self.sources[k]],
key=lambda a: a.lower())
for kind in cats:
if len(cats) > 1:
@@ -1241,7 +1241,7 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User):
self.file.write(pdata + '-->\n')
def printFilters(self, hierarchy, name):
- sorteditems = sorted(hierarchy.items(), key = lambda a: a[0].lower())
+ sorteditems = sorted(list(hierarchy.items()), key = lambda a: a[0].lower())
for key, value in sorteditems:
if SCons.Util.is_Dict(value):
@@ -1258,7 +1258,7 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User):
'Resource Files': 'None',
'Other Files': 'None'}
- sorteditems = sorted(hierarchy.items(), key = lambda a: a[0].lower())
+ sorteditems = sorted(list(hierarchy.items()), key = lambda a: a[0].lower())
# First folders, then files
for key, value in sorteditems:
@@ -1284,7 +1284,7 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User):
'Resource Files': 'r;rc;ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe',
'Other Files': ''}
- cats = sorted([k for k in categories.keys() if self.sources[k]],
+ cats = sorted([k for k in list(categories.keys()) if self.sources[k]],
key = lambda a: a.lower())
# print vcxproj.filters file first
@@ -1442,7 +1442,7 @@ class _GenerateV7DSW(_DSWGenerator):
AddConfig(self, variant)
self.platforms = []
- for key in self.configs.keys():
+ for key in list(self.configs.keys()):
platform = self.configs[key].platform
if not platform in self.platforms:
self.platforms.append(platform)
diff --git a/src/engine/SCons/Tool/msvsTests.py b/src/engine/SCons/Tool/msvsTests.py
index 2bd640f..bf82114 100644
--- a/src/engine/SCons/Tool/msvsTests.py
+++ b/src/engine/SCons/Tool/msvsTests.py
@@ -624,7 +624,7 @@ class msvsTestCase(unittest.TestCase):
tests_cmdargs = [(None, dict.fromkeys(list_variant, '')),
('', dict.fromkeys(list_variant, '')),
(list_cmdargs[0], dict.fromkeys(list_variant, list_cmdargs[0])),
- (list_cmdargs, dict(zip(list_variant, list_cmdargs)))]
+ (list_cmdargs, dict(list(zip(list_variant, list_cmdargs))))]
# Run the test for each test case
for param_cmdargs, expected_cmdargs in tests_cmdargs:
@@ -651,8 +651,8 @@ class msvsTestCase(unittest.TestCase):
'cmdargs': expected_cmdargs[variant_platform]}
# Create parameter environment with final parameter dictionary
- param_dict = dict(zip(('variant', 'runfile', 'buildtarget', 'outdir'),
- [list(l) for l in zip(*param_configs)]))
+ param_dict = dict(list(zip(('variant', 'runfile', 'buildtarget', 'outdir'),
+ [list(l) for l in zip(*param_configs)])))
param_dict['cmdargs'] = param_cmdargs
# Hack to be able to run the test with a 'DummyEnv'
@@ -668,8 +668,8 @@ class msvsTestCase(unittest.TestCase):
genDSP = function_test(dspfile, source, env)
# Check expected result
- self.assertListEqual(genDSP.configs.keys(), expected_configs.keys())
- for key in genDSP.configs.keys():
+ self.assertListEqual(list(genDSP.configs.keys()), list(expected_configs.keys()))
+ for key in list(genDSP.configs.keys()):
self.assertDictEqual(genDSP.configs[key].__dict__, expected_configs[key])
class msvs6aTestCase(msvsTestCase):
diff --git a/src/engine/SCons/Tool/packaging/__init__.py b/src/engine/SCons/Tool/packaging/__init__.py
index 1a95abe..1727938 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 kw_tags.items():
+ for (k,v) in list(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/ipk.py b/src/engine/SCons/Tool/packaging/ipk.py
index c666033..ad4fe0f 100644
--- a/src/engine/SCons/Tool/packaging/ipk.py
+++ b/src/engine/SCons/Tool/packaging/ipk.py
@@ -169,7 +169,7 @@ Description: $X_IPK_DESCRIPTION
#
# close all opened files
- for f in opened_files.values():
+ for f in list(opened_files.values()):
f.close()
# call a user specified function
diff --git a/src/engine/SCons/Tool/packaging/msi.py b/src/engine/SCons/Tool/packaging/msi.py
index c25f856..73d3567 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 needs_id.items():
+ for (key,value) in list(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 h.items() if not hasattr(file, k) ]:
+ for k,v in [ (k, v) for (k,v) in list(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 create_feature_dict(files).items():
+ for (feature, files) in list(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 99124ed..0c3e1ed 100644
--- a/src/engine/SCons/Tool/packaging/rpm.py
+++ b/src/engine/SCons/Tool/packaging/rpm.py
@@ -272,7 +272,7 @@ def build_specfile_filesection(spec, files):
for file in files:
# build the tagset
tags = {}
- for k in supported_tags.keys():
+ for k in list(supported_tags.keys()):
try:
v = file.GetTag(k)
if v:
@@ -333,7 +333,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 values.items() if strip_country_code(t[0]) == key]
+ x = [t for t in list(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 3eeed1d..d4db417 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 data.items():
+ for key, entries in list(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/Tool/swig.py b/src/engine/SCons/Tool/swig.py
index fa86174..9935de8 100644
--- a/src/engine/SCons/Tool/swig.py
+++ b/src/engine/SCons/Tool/swig.py
@@ -143,7 +143,7 @@ def _get_swig_version(env, swig):
# MAYBE: out = SCons.Util.to_str (pipe.stdout.read())
out = pipe.stdout.read()
- match = re.search(r'SWIG Version\s+(\S+).*', out, re.MULTILINE)
+ match = re.search(b'SWIG Version\s+(\S+).*', out, re.MULTILINE)
if match:
if verbose: print("Version is:%s"%match.group(1))
return match.group(1)
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py
index 0be6196..7653acd 100644
--- a/src/engine/SCons/Util.py
+++ b/src/engine/SCons/Util.py
@@ -477,7 +477,7 @@ _semi_deepcopy_dispatch = d = {}
def semi_deepcopy_dict(x, exclude = [] ):
copy = {}
- for key, val in x.items():
+ for key, val in list(x.items()):
# The regular Python copy.deepcopy() also deepcopies the key,
# as follows:
#
@@ -1037,7 +1037,7 @@ class OrderedDict(UserDict):
if key not in self._keys: self._keys.append(key)
def update(self, dict):
- for (key, val) in dict.items():
+ for (key, val) in list(dict.items()):
self.__setitem__(key, val)
def values(self):
@@ -1059,7 +1059,7 @@ class Selector(OrderedDict):
# Try to perform Environment substitution on the keys of
# the dictionary before giving up.
s_dict = {}
- for (k,v) in self.items():
+ for (k,v) in list(self.items()):
if k is not None:
s_k = env.subst(k)
if s_k in s_dict:
@@ -1425,14 +1425,22 @@ def AddMethod(obj, function, name=None):
else:
function = RenameFunction(function, name)
+ # Note the Python version checks - WLB
+ # Python 3.3 dropped the 3rd parameter from types.MethodType
if hasattr(obj, '__class__') and obj.__class__ is not type:
# "obj" is an instance, so it gets a bound method.
- method = MethodType(function, obj, obj.__class__)
- setattr(obj, name, method)
+ if sys.version_info[:2] > (3, 2):
+ method = MethodType(function, obj)
+ else:
+ method = MethodType(function, obj, obj.__class__)
else:
# "obj" is a class, so it gets an unbound method.
- function = MethodType(function, None, obj)
- setattr(obj, name, function)
+ if sys.version_info[:2] > (3, 2):
+ method = MethodType(function, None)
+ else:
+ method = MethodType(function, None, obj)
+
+ setattr(obj, name, method)
def RenameFunction(function, name):
"""
@@ -1553,14 +1561,12 @@ del __revision__
def to_bytes (s):
if isinstance (s, bytes) or bytes is str:
return s
- else:
- return bytes (s, 'utf-8')
+ return bytes (s, 'utf-8')
def to_str (s):
- if bytes is str:
+ if bytes is str or is_String(s):
return s
- else:
- return str (s, 'utf-8')
+ return str (s, 'utf-8')
# Local Variables:
# tab-width:4
diff --git a/src/engine/SCons/Variables/EnumVariableTests.py b/src/engine/SCons/Variables/EnumVariableTests.py
index 931dfe2..edc2973 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 table.items():
+ for k, l in list(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 table.items():
+ for v, l in list(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 b03e5b5..ce3541c 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 args.items():
+ for arg, value in list(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 60cfcea..18f154a 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 cpp_lines_dict.items():
+for op_list, expr in list(cpp_lines_dict.items()):
e = re.compile(expr)
for op in op_list:
Table[op] = e
@@ -87,7 +87,7 @@ del op_list
override = {
'if' : 'if(?!def)',
}
-l = [override.get(x, x) for x in Table.keys()]
+l = [override.get(x, x) for x in list(Table.keys())]
# Turn the list of expressions into one big honkin' regular expression
@@ -130,7 +130,7 @@ CPP_to_Python_Ops_Sub = lambda m: CPP_to_Python_Ops_Dict[m.group(0)]
# re module, as late as version 2.2.2, empirically matches the
# "!" in "!=" first, instead of finding the longest match.
# What's up with that?
-l = sorted(CPP_to_Python_Ops_Dict.keys(), key=lambda a: len(a), reverse=True)
+l = sorted(list(CPP_to_Python_Ops_Dict.keys()), key=lambda a: len(a), reverse=True)
# Turn the list of keys into one regular expression that will allow us
# to substitute all of the operators at once.
@@ -266,7 +266,7 @@ class PreProcessor(object):
d = {
'scons_current_file' : self.scons_current_file
}
- for op in Table.keys():
+ for op in list(Table.keys()):
d[op] = getattr(self, 'do_' + op)
self.default_table = d
diff --git a/src/engine/SCons/dblite.py b/src/engine/SCons/dblite.py
index c32f494..588a7ab 100644
--- a/src/engine/SCons/dblite.py
+++ b/src/engine/SCons/dblite.py
@@ -2,15 +2,13 @@
# Extended for Unicode by Steven Knight.
from __future__ import print_function
-import SCons.compat
-
-from SCons.compat import PICKLE_PROTOCOL
-
import os
import pickle
import shutil
import time
+from SCons.compat import PICKLE_PROTOCOL
+
keep_all_files = 00000
ignore_corrupt_dbfiles = 0
@@ -50,6 +48,7 @@ class dblite(object):
_open = open
_pickle_dump = staticmethod(pickle.dump)
+ _pickle_protocol = PICKLE_PROTOCOL
_os_chmod = os.chmod
try:
_os_chown = os.chown
@@ -121,7 +120,7 @@ class dblite(object):
def sync(self):
self._check_writable()
f = self._open(self._tmp_name, "wb", self._mode)
- self._pickle_dump(self._dict, f, PICKLE_PROTOCOL)
+ self._pickle_dump(self._dict, f, self._pickle_protocol)
f.close()
# Windows doesn't allow renaming if the file exists, so unlink
# it first, chmod'ing it to make sure we can do so. On UNIX, we
diff --git a/src/script/scons-configure-cache.py b/src/script/scons-configure-cache.py
index c1b7d59..2648acd 100644
--- a/src/script/scons-configure-cache.py
+++ b/src/script/scons-configure-cache.py
@@ -1,139 +1,139 @@
-#! /usr/bin/env python
-#
-# SCons - a Software Constructor
-#
-# __COPYRIGHT__
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
-# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-
-__version__ = "__VERSION__"
-
-__build__ = "__BUILD__"
-
-__buildsys__ = "__BUILDSYS__"
-
-__date__ = "__DATE__"
-
-__developer__ = "__DEVELOPER__"
-
-import argparse
-import glob
-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
- 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
- old_dirs.add(dir)
- dir = name[:new_prefix_len].upper()
- if dir not in dirs:
- os.mkdir(dir)
- dirs.add(dir)
- os.rename(file, os.path.join(dir, name))
-
- # Now delete the original directories
- for dir in old_dirs:
- os.rmdir(dir)
-
-# This dictionary should have one entry per entry in the cache config
-# Each entry should have the following:
-# implicit - (optional) This is to allow adding a new config entry and also
-# changing the behaviour of the system at the same time. This
-# indicates the value the config entry would have had if it had been
-# specified.
-# default - The value the config entry should have if it wasn't previously
-# specified
-# command-line - parameters to pass to ArgumentParser.add_argument
-# converter - (optional) Function to call if it's necessary to do some work
-# if this configuration entry changes
-config_entries = {
- 'prefix_len' : {
- 'implicit' : 1,
- 'default' : 2 ,
- 'command-line' : {
- 'help' : 'Length of cache file name used as subdirectory prefix',
- 'metavar' : '<number>',
- 'type' : int
- },
- 'converter' : rearrange_cache_entries
- }
-}
-parser = argparse.ArgumentParser(
- description = 'Modify the configuration of an scons cache directory',
- epilog = '''
- Unless you specify an option, it will not be changed (if it is
- already set in the cache config), or changed to an appropriate
- default (it it is not set).
- '''
- )
-
-parser.add_argument('cache-dir', help='Path to scons cache directory')
-for param in config_entries:
- parser.add_argument('--' + param.replace('_', '-'),
- **config_entries[param]['command-line'])
-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(filter(lambda x: x[1], vars(parser.parse_args()).items()))
-
-# It seems somewhat strange to me, but positional arguments don't get the -
-# in the name changed to _, whereas optional arguments do...
-os.chdir(args['cache-dir'])
-del args['cache-dir']
-
-if not os.path.exists('config'):
- # Validate the only files in the directory are directories 0-9, a-f
- expected = [ '{:X}'.format(x) for x in range(0, 16) ]
- if not set(os.listdir('.')).issubset(expected):
- raise RuntimeError("This doesn't look like a version 1 cache directory")
- config = dict()
-else:
- with open('config') as conf:
- config = json.load(conf)
-
-# Find any keys that aren't currently set but should be
-for key in config_entries:
- if key not in config:
- if 'implicit' in config_entries[key]:
- config[key] = config_entries[key]['implicit']
- else:
- config[key] = config_entries[key]['default']
- if key not in args:
- args[key] = config_entries[key]['default']
-
-#Now we go through each entry in args to see if it changes an existing config
-#setting.
-for key in args:
- if args[key] != config[key]:
- if 'converter' in config_entries[key]:
- config_entries[key]['converter'](config[key], args[key])
- config[key] = args[key]
-
-# and write the updated config file
-with open('config', 'w') as conf:
+#! /usr/bin/env python
+#
+# SCons - a Software Constructor
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+__version__ = "__VERSION__"
+
+__build__ = "__BUILD__"
+
+__buildsys__ = "__BUILDSYS__"
+
+__date__ = "__DATE__"
+
+__developer__ = "__DEVELOPER__"
+
+import argparse
+import glob
+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
+ 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
+ old_dirs.add(dir)
+ dir = name[:new_prefix_len].upper()
+ if dir not in dirs:
+ os.mkdir(dir)
+ dirs.add(dir)
+ os.rename(file, os.path.join(dir, name))
+
+ # Now delete the original directories
+ for dir in old_dirs:
+ os.rmdir(dir)
+
+# This dictionary should have one entry per entry in the cache config
+# Each entry should have the following:
+# implicit - (optional) This is to allow adding a new config entry and also
+# changing the behaviour of the system at the same time. This
+# indicates the value the config entry would have had if it had been
+# specified.
+# default - The value the config entry should have if it wasn't previously
+# specified
+# command-line - parameters to pass to ArgumentParser.add_argument
+# converter - (optional) Function to call if it's necessary to do some work
+# if this configuration entry changes
+config_entries = {
+ 'prefix_len' : {
+ 'implicit' : 1,
+ 'default' : 2 ,
+ 'command-line' : {
+ 'help' : 'Length of cache file name used as subdirectory prefix',
+ 'metavar' : '<number>',
+ 'type' : int
+ },
+ 'converter' : rearrange_cache_entries
+ }
+}
+parser = argparse.ArgumentParser(
+ description = 'Modify the configuration of an scons cache directory',
+ epilog = '''
+ Unless you specify an option, it will not be changed (if it is
+ already set in the cache config), or changed to an appropriate
+ default (it it is not set).
+ '''
+ )
+
+parser.add_argument('cache-dir', help='Path to scons cache directory')
+for param in config_entries:
+ parser.add_argument('--' + param.replace('_', '-'),
+ **config_entries[param]['command-line'])
+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]])
+
+# It seems somewhat strange to me, but positional arguments don't get the -
+# in the name changed to _, whereas optional arguments do...
+os.chdir(args['cache-dir'])
+del args['cache-dir']
+
+if not os.path.exists('config'):
+ # Validate the only files in the directory are directories 0-9, a-f
+ expected = [ '{:X}'.format(x) for x in range(0, 16) ]
+ if not set(os.listdir('.')).issubset(expected):
+ raise RuntimeError("This doesn't look like a version 1 cache directory")
+ config = dict()
+else:
+ with open('config') as conf:
+ config = json.load(conf)
+
+# Find any keys that aren't currently set but should be
+for key in config_entries:
+ if key not in config:
+ if 'implicit' in config_entries[key]:
+ config[key] = config_entries[key]['implicit']
+ else:
+ config[key] = config_entries[key]['default']
+ if key not in args:
+ args[key] = config_entries[key]['default']
+
+#Now we go through each entry in args to see if it changes an existing config
+#setting.
+for key in args:
+ if args[key] != config[key]:
+ if 'converter' in config_entries[key]:
+ config_entries[key]['converter'](config[key], args[key])
+ config[key] = args[key]
+
+# and write the updated config file
+with open('config', 'w') as conf:
json.dump(config, conf) \ No newline at end of file
diff --git a/src/script/scons-time.py b/src/script/scons-time.py
index ebdaf08..edb9dad 100644
--- a/src/script/scons-time.py
+++ b/src/script/scons-time.py
@@ -652,7 +652,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 statistics.items() if e[0][2] == function ]
+ matches = [ e for e in list(statistics.items()) if e[0][2] == function ]
r = matches[0]
return r[0][0], r[0][1], r[0][2], r[1][3]
@@ -1422,7 +1422,7 @@ class SConsTimer(object):
elif o in ('--title',):
self.title = a
elif o in ('--which',):
- if not a in self.time_strings.keys():
+ if not a in list(self.time_strings.keys()):
sys.stderr.write('%s: time: Unrecognized timer "%s".\n' % (self.name, a))
sys.stderr.write('%s Type "%s help time" for help.\n' % (self.name_spaces, self.name))
sys.exit(1)
diff --git a/src/test_files.py b/src/test_files.py
index 1eee11d..ef27606 100644
--- a/src/test_files.py
+++ b/src/test_files.py
@@ -78,7 +78,7 @@ check = {
missing = []
no_result = []
-for directory, check_list in check.items():
+for directory, check_list in list(check.items()):
if os.path.exists(directory):
for c in check_list:
f = os.path.join(directory, c)
diff --git a/src/test_interrupts.py b/src/test_interrupts.py
index b81ef3f..0fd8ba7 100644
--- a/src/test_interrupts.py
+++ b/src/test_interrupts.py
@@ -104,7 +104,7 @@ for f in files:
indent_list.append( (line_num, match.group('try_or_except') ) )
try_except_lines[match.group('indent')] = indent_list
uncaught_this_file = []
- for indent in try_except_lines.keys():
+ for indent in list(try_except_lines.keys()):
exc_keyboardint_seen = 0
exc_all_seen = 0
for (l,statement) in try_except_lines[indent] + [(-1,indent + 'try')]:
diff --git a/test/AR/AR.py b/test/AR/AR.py
index 8fb8073..eb4c507 100644
--- a/test/AR/AR.py
+++ b/test/AR/AR.py
@@ -36,7 +36,7 @@ test = TestSCons.TestSCons()
test.write("wrapper.py",
"""import os
import sys
-open('%s', 'wb').write("wrapper.py\\n")
+open('%s', 'wb').write(b"wrapper.py\\n")
os.system(" ".join(sys.argv[1:]))
""" % test.workpath('wrapper.out').replace('\\', '\\\\'))
@@ -94,13 +94,13 @@ test.run(arguments = 'f' + _exe,
stderr=TestSCons.noisy_ar,
match=TestSCons.match_re_dotall)
-test.fail_test(os.path.exists(test.workpath('wrapper.out')))
+test.must_not_exist(test.workpath('wrapper.out'))
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')
test.pass_test()
diff --git a/test/AR/ARCOM.py b/test/AR/ARCOM.py
index f26ced6..bf2830e 100644
--- a/test/AR/ARCOM.py
+++ b/test/AR/ARCOM.py
@@ -41,7 +41,7 @@ import sys
outfile = open(sys.argv[1], 'wb')
for f in sys.argv[2:]:
infile = open(f, 'rb')
- for l in [l for l in infile.readlines() if l != '/*ar*/\\n']:
+ for l in [l for l in infile.readlines() if l != b'/*ar*/\\n']:
outfile.write(l)
sys.exit(0)
""")
diff --git a/test/AR/ARCOMSTR.py b/test/AR/ARCOMSTR.py
index 4c0bb85..1b1a9fb 100644
--- a/test/AR/ARCOMSTR.py
+++ b/test/AR/ARCOMSTR.py
@@ -42,7 +42,7 @@ import sys
outfile = open(sys.argv[1], 'wb')
for f in sys.argv[2:]:
infile = open(f, 'rb')
- for l in [l for l in infile.readlines() if l != '/*ar*/\\n']:
+ for l in [l for l in infile.readlines() if l != b'/*ar*/\\n']:
outfile.write(l)
sys.exit(0)
""")
diff --git a/test/AR/ARFLAGS.py b/test/AR/ARFLAGS.py
index be4e8bd..0a9f36e 100644
--- a/test/AR/ARFLAGS.py
+++ b/test/AR/ARFLAGS.py
@@ -36,7 +36,7 @@ test = TestSCons.TestSCons()
test.write("wrapper.py",
"""import os
import sys
-open('%s', 'wb').write("wrapper.py\\n")
+open('%s', 'wb').write(b"wrapper.py\\n")
os.system(" ".join(sys.argv[1:]))
""" % test.workpath('wrapper.out').replace('\\', '\\\\'))
@@ -93,13 +93,13 @@ test.run(arguments = 'f' + _exe,
stderr=TestSCons.noisy_ar,
match=TestSCons.match_re_dotall)
-test.fail_test(os.path.exists(test.workpath('wrapper.out')))
+test.must_not_exist(test.workpath('wrapper.out'))
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')
test.pass_test()
diff --git a/test/ARGUMENTS.py b/test/ARGUMENTS.py
index 4bd2f78..97c97c8 100644
--- a/test/ARGUMENTS.py
+++ b/test/ARGUMENTS.py
@@ -31,13 +31,13 @@ test = TestSCons.TestSCons()
test.write('SConstruct', """
foo = open('foo.out', 'wb')
for k in sorted(ARGUMENTS.keys()):
- foo.write(k + " = " + ARGUMENTS[k] + "\\n")
+ foo.write((k + " = " + ARGUMENTS[k] + "\\n").encode())
foo.close()
""")
test.run(arguments='a=1 bz=3 xx=sd zzz=foo=bar .')
-test.fail_test(test.read('foo.out') != """a = 1
+test.must_match('foo.out', """a = 1
bz = 3
xx = sd
zzz = foo=bar
diff --git a/test/AS/AS.py b/test/AS/AS.py
index e0ffbf4..6ccf0cb 100644
--- a/test/AS/AS.py
+++ b/test/AS/AS.py
@@ -58,7 +58,7 @@ while args:
infile = open(args[0], 'rb')
outfile = open(out, 'wb')
for l in infile.readlines():
- if l[:5] != '#link':
+ if l[:5] != b'#link':
outfile.write(l)
sys.exit(0)
""")
@@ -82,7 +82,7 @@ while args:
infile = open(inf, 'rb')
outfile = open(out, 'wb')
for l in infile.readlines():
- if l[:3] != '#as':
+ if l[:3] != b'#as':
outfile.write(l)
sys.exit(0)
""")
@@ -98,7 +98,7 @@ for opt, arg in opts:
infile = open(args[0], 'rb')
outfile = open(out, 'wb')
for l in infile.readlines():
- if l[:5] != '#link':
+ if l[:5] != b'#link':
outfile.write(l)
sys.exit(0)
""")
@@ -112,7 +112,7 @@ for opt, arg in opts:
infile = open(args[0], 'rb')
outfile = open(out, 'wb')
for l in infile.readlines():
- if l[:3] != '#as':
+ if l[:3] != b'#as':
outfile.write(l)
sys.exit(0)
""")
diff --git a/test/AS/ASCOM.py b/test/AS/ASCOM.py
index 568bd00..8f91404 100644
--- a/test/AS/ASCOM.py
+++ b/test/AS/ASCOM.py
@@ -42,7 +42,7 @@ test.write('myas.py', r"""
import sys
infile = open(sys.argv[2], 'rb')
outfile = open(sys.argv[1], 'wb')
-for l in [l for l in infile.readlines() if l != "#as\n"]:
+for l in [l for l in infile.readlines() if l != b"#as\n"]:
outfile.write(l)
sys.exit(0)
""")
@@ -80,14 +80,14 @@ test.write('test8'+alt_asm_suffix, "test8.ASM\n#as\n")
test.run(arguments = '.')
-test.fail_test(test.read('test1.obj') != "test1.s\n")
-test.fail_test(test.read('test2.obj') != "test2.S\n")
-test.fail_test(test.read('test3.obj') != "test3.asm\n")
-test.fail_test(test.read('test4.obj') != "test4.ASM\n")
-test.fail_test(test.read('test5.shobj') != "test5.s\n")
-test.fail_test(test.read('test6.shobj') != "test6.S\n")
-test.fail_test(test.read('test7.shobj') != "test7.asm\n")
-test.fail_test(test.read('test8.shobj') != "test8.ASM\n")
+test.must_match('test1.obj', "test1.s\n")
+test.must_match('test2.obj', "test2.S\n")
+test.must_match('test3.obj', "test3.asm\n")
+test.must_match('test4.obj', "test4.ASM\n")
+test.must_match('test5.shobj', "test5.s\n")
+test.must_match('test6.shobj', "test6.S\n")
+test.must_match('test7.shobj', "test7.asm\n")
+test.must_match('test8.shobj', "test8.ASM\n")
diff --git a/test/AS/ASCOMSTR.py b/test/AS/ASCOMSTR.py
index f7cc34e..39b963f 100644
--- a/test/AS/ASCOMSTR.py
+++ b/test/AS/ASCOMSTR.py
@@ -43,7 +43,7 @@ test.write('myas.py', r"""
import sys
infile = open(sys.argv[2], 'rb')
outfile = open(sys.argv[1], 'wb')
-for l in [l for l in infile.readlines() if l != "#as\n"]:
+for l in [l for l in infile.readlines() if l != b"#as\n"]:
outfile.write(l)
sys.exit(0)
""")
@@ -77,10 +77,10 @@ Assembling test3.obj from test3.asm
Assembling test4.obj from test4%(alt_asm_suffix)s
""" % locals()))
-test.fail_test(test.read('test1.obj') != "test1.s\n")
-test.fail_test(test.read('test2.obj') != "test2.S\n")
-test.fail_test(test.read('test3.obj') != "test3.asm\n")
-test.fail_test(test.read('test4.obj') != "test4.ASM\n")
+test.must_match('test1.obj', "test1.s\n")
+test.must_match('test2.obj', "test2.S\n")
+test.must_match('test3.obj', "test3.asm\n")
+test.must_match('test4.obj', "test4.ASM\n")
diff --git a/test/AS/ASPPCOM.py b/test/AS/ASPPCOM.py
index f89306e..62f859a 100644
--- a/test/AS/ASPPCOM.py
+++ b/test/AS/ASPPCOM.py
@@ -40,7 +40,7 @@ test.write('myas.py', r"""
import sys
infile = open(sys.argv[2], 'rb')
outfile = open(sys.argv[1], 'wb')
-for l in [l for l in infile.readlines() if l != "#as\n"]:
+for l in [l for l in infile.readlines() if l != b"#as\n"]:
outfile.write(l)
sys.exit(0)
""")
@@ -63,10 +63,10 @@ test.write('test4.SPP', "test4.SPP\n#as\n")
test.run(arguments = '.')
-test.fail_test(test.read('test1.obj') != "test1.spp\n")
-test.fail_test(test.read('test2.obj') != "test2.SPP\n")
-test.fail_test(test.read('test3.shobj') != "test3.spp\n")
-test.fail_test(test.read('test4.shobj') != "test4.SPP\n")
+test.must_match('test1.obj', "test1.spp\n")
+test.must_match('test2.obj', "test2.SPP\n")
+test.must_match('test3.shobj', "test3.spp\n")
+test.must_match('test4.shobj', "test4.SPP\n")
diff --git a/test/AS/ASPPCOMSTR.py b/test/AS/ASPPCOMSTR.py
index 7de3b12..0497470 100644
--- a/test/AS/ASPPCOMSTR.py
+++ b/test/AS/ASPPCOMSTR.py
@@ -41,7 +41,7 @@ test.write('myas.py', r"""
import sys
infile = open(sys.argv[2], 'rb')
outfile = open(sys.argv[1], 'wb')
-for l in [l for l in infile.readlines() if l != "#as\n"]:
+for l in [l for l in infile.readlines() if l != b"#as\n"]:
outfile.write(l)
sys.exit(0)
""")
@@ -62,8 +62,8 @@ Assembling test1.obj from test1.spp
Assembling test2.obj from test2.SPP
"""))
-test.fail_test(test.read('test1.obj') != "test1.spp\n")
-test.fail_test(test.read('test2.obj') != "test2.SPP\n")
+test.must_match('test1.obj', "test1.spp\n")
+test.must_match('test2.obj', "test2.SPP\n")
diff --git a/test/AS/as-live.py b/test/AS/as-live.py
index 801eeca..879e7b2 100644
--- a/test/AS/as-live.py
+++ b/test/AS/as-live.py
@@ -58,7 +58,7 @@ if sys.platform == "win32":
test.write("wrapper.py", """\
import os
import sys
-open('%s', 'wb').write("wrapper.py: %%s\\n" %% sys.argv[-1])
+open('%s', 'wb').write(("wrapper.py: %%s\\n" %% sys.argv[-1]).encode())
cmd = " ".join(sys.argv[1:])
os.system(cmd)
""" % test.workpath('wrapper.out').replace('\\', '\\\\'))
diff --git a/test/AS/ml.py b/test/AS/ml.py
index 9491e36..c377172 100644
--- a/test/AS/ml.py
+++ b/test/AS/ml.py
@@ -48,7 +48,7 @@ if not ml:
test.write("wrapper.py",
"""import os
import sys
-open('%s', 'wb').write("wrapper.py\\n")
+open('%s', 'wb').write(b"wrapper.py\\n")
os.system(" ".join(sys.argv[1:]))
""" % test.workpath('wrapper.out').replace('\\', '\\\\'))
diff --git a/test/AS/nasm.py b/test/AS/nasm.py
index be7db3e..551a5ab 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 format_map.items():
+for k, v in list(format_map.items()):
if sys.platform.find(k) != -1:
nasm_format = v
break
diff --git a/test/Actions/actions.py b/test/Actions/actions.py
index 785a0cb..e69cdd7 100644
--- a/test/Actions/actions.py
+++ b/test/Actions/actions.py
@@ -33,7 +33,7 @@ test = TestSCons.TestSCons()
test.write('build.py', r"""
import sys
file = open(sys.argv[1], 'wb')
-file.write(sys.argv[2] + "\n")
+file.write((sys.argv[2] + "\n").encode())
file.write(open(sys.argv[3], 'rb').read())
file.close
sys.exit(0)
@@ -49,7 +49,7 @@ test.write('foo.in', "foo.in\n")
test.run(arguments = '.')
-test.fail_test(test.read('foo.out') != "1\nfoo.in\n")
+test.must_match('foo.out', '1\nfoo.in\n')
test.up_to_date(arguments = '.')
@@ -61,7 +61,7 @@ env.B(target = 'foo.out', source = 'foo.in')
test.run(arguments = '.')
-test.fail_test(test.read('foo.out') != "2\nfoo.in\n")
+test.must_match('foo.out', '2\nfoo.in\n')
test.up_to_date(arguments = '.')
@@ -79,7 +79,7 @@ env.B(target = 'foo.out', source = 'foo.in')
test.run(arguments = '.', stderr = None)
-test.fail_test(test.read('foo.out') != "3\nfoo.in\n")
+test.must_match('foo.out', '3\nfoo.in\n')
test.up_to_date(arguments = '.')
@@ -103,7 +103,7 @@ env.B(target = 'foo.out', source = 'foo.in')
test.run(arguments = '.')
-test.fail_test(test.read('foo.out') != "4\nfoo.in\n")
+test.must_match('foo.out', '4\nfoo.in\n')
test.up_to_date(arguments = '.')
diff --git a/test/Actions/addpost-link-fixture/.exclude_tests b/test/Actions/addpost-link-fixture/.exclude_tests
new file mode 100644
index 0000000..03cc8e0
--- /dev/null
+++ b/test/Actions/addpost-link-fixture/.exclude_tests
@@ -0,0 +1 @@
+strip.py
diff --git a/test/Actions/addpost-link-fixture/strip.py b/test/Actions/addpost-link-fixture/strip.py
new file mode 100644
index 0000000..88242f2
--- /dev/null
+++ b/test/Actions/addpost-link-fixture/strip.py
@@ -0,0 +1,2 @@
+import sys
+print("strip.py: %s" % " ".join(sys.argv[1:]))
diff --git a/test/Actions/addpost-link-fixture/test1.c b/test/Actions/addpost-link-fixture/test1.c
new file mode 100644
index 0000000..333f5c7
--- /dev/null
+++ b/test/Actions/addpost-link-fixture/test1.c
@@ -0,0 +1,5 @@
+extern void test_lib_fn();
+int main(int argc, char **argv) {
+ test_lib_fn();
+ return 0;
+}
diff --git a/test/Actions/addpost-link-fixture/test_lib.c b/test/Actions/addpost-link-fixture/test_lib.c
new file mode 100644
index 0000000..0ac1076
--- /dev/null
+++ b/test/Actions/addpost-link-fixture/test_lib.c
@@ -0,0 +1,5 @@
+#include <stdio.h>
+
+void test_lib_fn() {
+ printf("Hello world\n");
+}
diff --git a/test/Actions/addpost-link.py b/test/Actions/addpost-link.py
index 04cd68d..0a238e1 100644
--- a/test/Actions/addpost-link.py
+++ b/test/Actions/addpost-link.py
@@ -38,10 +38,7 @@ _python_ = TestSCons._python_
test = TestSCons.TestSCons()
-test.write('strip.py', """\
-import sys
-print "strip.py: %s" % " ".join(sys.argv[1:])
-""")
+test.dir_fixture('addpost-link-fixture')
test.write('SConstruct', """\
env = Environment()
@@ -57,22 +54,6 @@ if ARGUMENTS['case']=='2':
AddPostAction(myprog, Action(r'%(_python_)s strip.py ' + myprog[0].get_abspath()))
""" % locals())
-test.write('test1.c', """\
-extern void test_lib_fn();
-int main(int argc, char **argv) {
- test_lib_fn();
- return 0;
-}
-""")
-
-test.write('test_lib.c', r"""\
-#include <stdio.h>
-
-void test_lib_fn() {
- printf("Hello world\n");
-}
-""")
-
test.run(arguments="-Q case=1", stderr=None)
test.run(arguments="-Q -c case=1")
diff --git a/test/Actions/append-fixture/foo.c b/test/Actions/append-fixture/foo.c
new file mode 100644
index 0000000..e6428b5
--- /dev/null
+++ b/test/Actions/append-fixture/foo.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+int main(void)
+{
+ printf("Foo\n");
+ return 0;
+}
diff --git a/test/Actions/append.py b/test/Actions/append.py
index f617280..68646b3 100644
--- a/test/Actions/append.py
+++ b/test/Actions/append.py
@@ -33,22 +33,11 @@ import stat
import sys
import TestSCons
-if sys.platform == 'win32':
- _exe = '.exe'
-else:
- _exe = ''
+_exe = TestSCons._exe
test = TestSCons.TestSCons()
-test.write('foo.c', r"""
-#include <stdio.h>
-
-int main(void)
-{
- printf("Foo\n");
- return 0;
-}
-""")
+test.dir_fixture('append-fixture')
test.write('SConstruct', """
@@ -56,10 +45,10 @@ env=Environment()
def before(env, target, source):
f=open(str(target[0]), "wb")
- f.write("Foo\\n")
+ f.write(b"Foo\\n")
f.close()
f=open("before.txt", "wb")
- f.write("Bar\\n")
+ f.write(b"Bar\\n")
f.close()
def after(env, target, source):
@@ -77,7 +66,7 @@ env.Program(source='foo.c', target='foo')
after_exe = test.workpath('after' + _exe)
test.run(arguments='.')
-test.fail_test(open('before.txt', 'rb').read() != "Bar\n")
+test.must_match('before.txt', 'Bar\n')
os.chmod(after_exe, os.stat(after_exe)[stat.ST_MODE] | stat.S_IXUSR)
test.run(program=after_exe, stdout="Foo\n")
test.pass_test()
diff --git a/test/Actions/pre-post-fixture/work1/bar.c b/test/Actions/pre-post-fixture/work1/bar.c
new file mode 100644
index 0000000..eb3fd78
--- /dev/null
+++ b/test/Actions/pre-post-fixture/work1/bar.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+int main(void)
+{
+ printf("bar.c\n");
+ return 0;
+}
diff --git a/test/Actions/pre-post-fixture/work1/foo.c b/test/Actions/pre-post-fixture/work1/foo.c
new file mode 100644
index 0000000..32f2a3e
--- /dev/null
+++ b/test/Actions/pre-post-fixture/work1/foo.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+int main(void)
+{
+ printf("foo.c\n");
+ return 0;
+}
diff --git a/test/Actions/pre-post-fixture/work2/SConstruct b/test/Actions/pre-post-fixture/work2/SConstruct
new file mode 100644
index 0000000..61f739f
--- /dev/null
+++ b/test/Actions/pre-post-fixture/work2/SConstruct
@@ -0,0 +1,26 @@
+def b(target, source, env):
+ open(str(target[0]), 'wb').write((env['X'] + '\n').encode())
+env1 = Environment(X='111')
+env2 = Environment(X='222')
+B = Builder(action = b, env = env1, multi=1)
+print("B =", B)
+print("B.env =", B.env)
+env1.Append(BUILDERS = {'B' : B})
+env2.Append(BUILDERS = {'B' : B})
+env3 = env1.Clone(X='333')
+print("env1 =", env1)
+print("env2 =", env2)
+print("env3 =", env3)
+f1 = env1.B(File('file1.out'), [])
+f2 = env2.B('file2.out', [])
+f3 = env3.B('file3.out', [])
+def do_nothing(env, target, source):
+ pass
+AddPreAction(f2[0], do_nothing)
+AddPostAction(f3[0], do_nothing)
+print("f1[0].builder =", f1[0].builder)
+print("f2[0].builder =", f2[0].builder)
+print("f3[0].builder =", f3[0].builder)
+print("f1[0].env =", f1[0].env)
+print("f2[0].env =", f2[0].env)
+print("f3[0].env =", f3[0].env)
diff --git a/test/Actions/pre-post-fixture/work3/SConstruct b/test/Actions/pre-post-fixture/work3/SConstruct
new file mode 100644
index 0000000..0e13fa2
--- /dev/null
+++ b/test/Actions/pre-post-fixture/work3/SConstruct
@@ -0,0 +1,10 @@
+def pre(target, source, env):
+ pass
+def post(target, source, env):
+ pass
+def build(target, source, env):
+ open(str(target[0]), 'wb').write(b'build()\n')
+env = Environment()
+AddPreAction('dir', pre)
+AddPostAction('dir', post)
+env.Command('dir/file', [], build)
diff --git a/test/Actions/pre-post-fixture/work4/.exclude_tests b/test/Actions/pre-post-fixture/work4/.exclude_tests
new file mode 100644
index 0000000..3fb299e
--- /dev/null
+++ b/test/Actions/pre-post-fixture/work4/.exclude_tests
@@ -0,0 +1 @@
+build.py
diff --git a/test/Actions/pre-post-fixture/work4/file.in b/test/Actions/pre-post-fixture/work4/file.in
new file mode 100644
index 0000000..1912927
--- /dev/null
+++ b/test/Actions/pre-post-fixture/work4/file.in
@@ -0,0 +1 @@
+file.in
diff --git a/test/Actions/pre-post.py b/test/Actions/pre-post.py
index f6997e2..a5acbfb 100644
--- a/test/Actions/pre-post.py
+++ b/test/Actions/pre-post.py
@@ -37,9 +37,7 @@ _python_ = TestSCons._python_
test = TestSCons.TestSCons()
-test.subdir('work1', 'work2', 'work3', 'work4')
-
-
+test.dir_fixture('pre-post-fixture')
test.write(['work1', 'SConstruct'], """
import os.path
@@ -50,11 +48,11 @@ env = Environment(XXX='bar%(_exe)s')
def before(env, target, source):
a=str(target[0])
f=open(a, "wb")
- f.write("Foo\\n")
+ f.write(b"Foo\\n")
f.close()
os.chmod(a, os.stat(a)[stat.ST_MODE] | stat.S_IXUSR)
f=open("before.txt", "ab")
- f.write(os.path.splitext(str(target[0]))[0] + "\\n")
+ f.write((os.path.splitext(str(target[0]))[0] + "\\n").encode())
f.close()
def after(env, target, source):
@@ -76,26 +74,6 @@ env.AddPreAction('$XXX', before)
env.AddPostAction('$XXX', after)
""" % locals())
-test.write(['work1', 'foo.c'], r"""
-#include <stdio.h>
-
-int main(void)
-{
- printf("foo.c\n");
- return 0;
-}
-""")
-
-test.write(['work1', 'bar.c'], r"""
-#include <stdio.h>
-
-int main(void)
-{
- printf("bar.c\n");
- return 0;
-}
-""")
-
test.run(chdir='work1', arguments='.')
test.run(program=test.workpath('work1', 'foo'+ _exe), stdout="foo.c\n")
@@ -109,59 +87,14 @@ test.run(program=after_foo_exe, stdout="foo.c\n")
after_bar_exe = test.workpath('work1', 'after_bar' + _exe)
test.run(program=after_bar_exe, stdout="bar.c\n")
-
-
-
-test.write(['work2', 'SConstruct'], """\
-def b(target, source, env):
- open(str(target[0]), 'wb').write(env['X'] + '\\n')
-env1 = Environment(X='111')
-env2 = Environment(X='222')
-B = Builder(action = b, env = env1, multi=1)
-print("B =", B)
-print("B.env =", B.env)
-env1.Append(BUILDERS = {'B' : B})
-env2.Append(BUILDERS = {'B' : B})
-env3 = env1.Clone(X='333')
-print("env1 =", env1)
-print("env2 =", env2)
-print("env3 =", env3)
-f1 = env1.B(File('file1.out'), [])
-f2 = env2.B('file2.out', [])
-f3 = env3.B('file3.out', [])
-def do_nothing(env, target, source):
- pass
-AddPreAction(f2[0], do_nothing)
-AddPostAction(f3[0], do_nothing)
-print("f1[0].builder =", f1[0].builder)
-print("f2[0].builder =", f2[0].builder)
-print("f3[0].builder =", f3[0].builder)
-print("f1[0].env =", f1[0].env)
-print("f2[0].env =", f2[0].env)
-print("f3[0].env =", f3[0].env)
-""")
-
+# work2 start
test.run(chdir='work2', arguments = '.')
test.must_match(['work2', 'file1.out'], "111\n")
test.must_match(['work2', 'file2.out'], "222\n")
test.must_match(['work2', 'file3.out'], "333\n")
-
-
-test.write(['work3', 'SConstruct'], """\
-def pre(target, source, env):
- pass
-def post(target, source, env):
- pass
-def build(target, source, env):
- open(str(target[0]), 'wb').write('build()\\n')
-env = Environment()
-AddPreAction('dir', pre)
-AddPostAction('dir', post)
-env.Command('dir/file', [], build)
-""")
-
+# work3 start
test.run(chdir = 'work3', arguments = 'dir/file', stdout=test.wrap_stdout("""\
pre(["dir"], [])
post(["dir"], [])
@@ -170,21 +103,12 @@ build(["%s"], [])
test.must_match(['work3', 'dir', 'file'], "build()\n")
-
-
-test.write(['work4', 'build.py'], """\
-import sys
-outfp = open(sys.argv[1], 'wb')
-for f in sys.argv[2:]:
- outfp.write(open(f, 'rb').read())
-outfp.close()
-""")
-
+# work4 start
test.write(['work4', 'SConstruct'], """\
def pre_action(target, source, env):
- open(str(target[0]), 'ab').write('pre %%s\\n' %% source[0])
+ open(str(target[0]), 'ab').write(('pre %%s\\n' %% source[0]).encode())
def post_action(target, source, env):
- open(str(target[0]), 'ab').write('post %%s\\n' %% source[0])
+ open(str(target[0]), 'ab').write(('post %%s\\n' %% source[0]).encode())
env = Environment()
o = env.Command(['pre-post', 'file.out'],
'file.in',
@@ -193,8 +117,6 @@ env.AddPreAction(o, pre_action)
env.AddPostAction(o, post_action)
""" % locals())
-test.write(['work4', 'file.in'], "file.in\n")
-
test.run(chdir='work4', arguments='.')
test.must_match(['work4', 'file.out'], "file.in\n")
@@ -202,10 +124,6 @@ test.must_match(['work4', 'pre-post'], "pre file.in\npost file.in\n")
test.pass_test()
-
-
-test.pass_test()
-
# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
diff --git a/test/Actions/unicode-signature-fixture/SConstruct b/test/Actions/unicode-signature-fixture/SConstruct
new file mode 100644
index 0000000..9c0f03d
--- /dev/null
+++ b/test/Actions/unicode-signature-fixture/SConstruct
@@ -0,0 +1,11 @@
+fnode = File(u'foo.txt')
+
+def funcact(target, source, env):
+ open(str(target[0]), 'wb').write(b"funcact\n")
+ for i in range(300):
+ pass
+ return 0
+
+env = Environment()
+
+env.Command(fnode, [], ["echo $TARGET", funcact])
diff --git a/test/Actions/unicode-signature.py b/test/Actions/unicode-signature.py
index d91bfa8..ef8c888 100644
--- a/test/Actions/unicode-signature.py
+++ b/test/Actions/unicode-signature.py
@@ -42,19 +42,7 @@ test = TestSCons.TestSCons()
## msg = "Unicode not supported by Python version %s; skipping test\n"
## test.skip_test(msg % sys.version[:3])
-test.write('SConstruct', """
-fnode = File(u'foo.txt')
-
-def funcact(target, source, env):
- open(str(target[0]), 'wb').write("funcact\\n")
- for i in range(300):
- pass
- return 0
-
-env = Environment()
-
-env.Command(fnode, [], ["echo $TARGET", funcact])
-""")
+test.dir_fixture('unicode-signature-fixture')
test.run(arguments = '.')
diff --git a/test/CC/CC-fixture/bar.c b/test/CC/CC-fixture/bar.c
new file mode 100644
index 0000000..de1e6e5
--- /dev/null
+++ b/test/CC/CC-fixture/bar.c
@@ -0,0 +1,10 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+ printf("foo.c\n");
+ exit (0);
+}
diff --git a/test/CC/CC-fixture/foo.c b/test/CC/CC-fixture/foo.c
new file mode 100644
index 0000000..de1e6e5
--- /dev/null
+++ b/test/CC/CC-fixture/foo.c
@@ -0,0 +1,10 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+ printf("foo.c\n");
+ exit (0);
+}
diff --git a/test/CC/CC-fixture/test1.c b/test/CC/CC-fixture/test1.c
new file mode 100644
index 0000000..7535b0a
--- /dev/null
+++ b/test/CC/CC-fixture/test1.c
@@ -0,0 +1,3 @@
+This is a .c file.
+/*cc*/
+/*link*/
diff --git a/test/CC/CC-fixture/test2.C b/test/CC/CC-fixture/test2.C
new file mode 100644
index 0000000..a1ee9e3
--- /dev/null
+++ b/test/CC/CC-fixture/test2.C
@@ -0,0 +1,3 @@
+This is a .C file.
+/*cc*/
+/*link*/
diff --git a/test/CC/CC.py b/test/CC/CC.py
index 9500088..7478cbe 100644
--- a/test/CC/CC.py
+++ b/test/CC/CC.py
@@ -33,7 +33,7 @@ _exe = TestSCons._exe
test = TestSCons.TestSCons()
-
+test.dir_fixture('CC-fixture')
if sys.platform == 'win32':
@@ -53,7 +53,7 @@ while args:
infile = open(args[0], 'rb')
outfile = open(out, 'wb')
for l in infile.readlines():
- if l[:8] != '/*link*/':
+ if l[:8] != b'/*link*/':
outfile.write(l)
sys.exit(0)
""")
@@ -77,7 +77,7 @@ while args:
infile = open(inf, 'rb')
outfile = open(out, 'wb')
for l in infile.readlines():
- if l[:6] != '/*cc*/':
+ if l[:6] != b'/*cc*/':
outfile.write(l)
sys.exit(0)
""")
@@ -93,7 +93,7 @@ for opt, arg in opts:
infile = open(args[0], 'rb')
outfile = open(out, 'wb')
for l in infile.readlines():
- if l[:8] != '/*link*/':
+ if l[:8] != b'/*link*/':
outfile.write(l)
sys.exit(0)
""")
@@ -107,7 +107,7 @@ for opt, arg in opts:
infile = open(args[0], 'rb')
outfile = open(out, 'wb')
for l in infile.readlines():
- if l[:6] != '/*cc*/':
+ if l[:6] != b'/*cc*/':
outfile.write(l)
sys.exit(0)
""")
@@ -122,14 +122,9 @@ env = Environment(LINK = r'%(_python_)s mylink.py',
env.Program(target = 'test1', source = 'test1.c')
""" % locals())
-test.write('test1.c', r"""This is a .c file.
-/*cc*/
-/*link*/
-""")
-
test.run(arguments = '.', stderr = None)
-test.fail_test(test.read('test1' + _exe) != "This is a .c file.\n")
+test.must_match('test1' + _exe, "This is a .c file.\n")
if os.path.normcase('.c') == os.path.normcase('.C'):
@@ -141,23 +136,14 @@ env = Environment(LINK = r'%(_python_)s mylink.py',
env.Program(target = 'test2', source = 'test2.C')
""" % locals())
- test.write('test2.C', r"""This is a .C file.
-/*cc*/
-/*link*/
-""")
-
test.run(arguments = '.', stderr = None)
-
- test.fail_test(test.read('test2' + _exe) != "This is a .C file.\n")
-
-
-
+ test.must_match('test2' + _exe, "This is a .C file.\n")
test.write("wrapper.py",
"""import os
import sys
if '--version' not in sys.argv and '-dumpversion' not in sys.argv:
- open('%s', 'wb').write("wrapper.py\\n")
+ open('%s', 'wb').write(b"wrapper.py\\n")
os.system(" ".join(sys.argv[1:]))
""" % test.workpath('wrapper.out').replace('\\', '\\\\'))
@@ -169,33 +155,6 @@ foo.Program(target = 'foo', source = 'foo.c')
bar.Program(target = 'bar', source = 'bar.c')
""" % locals())
-test.write('foo.c', r"""
-#include <stdio.h>
-#include <stdlib.h>
-
-int
-main(int argc, char *argv[])
-{
- argv[argc++] = "--";
- printf("foo.c\n");
- exit (0);
-}
-""")
-
-test.write('bar.c', r"""
-#include <stdio.h>
-#include <stdlib.h>
-
-int
-main(int argc, char *argv[])
-{
- argv[argc++] = "--";
- printf("foo.c\n");
- exit (0);
-}
-""")
-
-
test.run(arguments = 'foo' + _exe)
test.must_not_exist(test.workpath('wrapper.out'))
diff --git a/test/CC/CCCOM.py b/test/CC/CCCOM.py
index 8d06942..f930ecd 100644
--- a/test/CC/CCCOM.py
+++ b/test/CC/CCCOM.py
@@ -37,16 +37,7 @@ _exe = TestSCons._exe
test = TestSCons.TestSCons()
-
-
-test.write('mycc.py', r"""
-import sys
-outfile = open(sys.argv[1], 'wb')
-infile = open(sys.argv[2], 'rb')
-for l in [l for l in infile.readlines() if l[:6] != '/*cc*/']:
- outfile.write(l)
-sys.exit(0)
-""")
+test.dir_fixture('shared-fixture')
if os.path.normcase('.c') == os.path.normcase('.C'):
alt_c_suffix = '.C'
@@ -60,11 +51,6 @@ env.Object(target = 'test1', source = 'test1.c')
env.Object(target = 'test2', source = 'test2%(alt_c_suffix)s')
""" % locals())
-test.write('test1.c', """\
-test1.c
-/*cc*/
-""")
-
test.write('test2'+alt_c_suffix, """\
test2.C
/*cc*/
diff --git a/test/CC/CCCOMSTR.py b/test/CC/CCCOMSTR.py
index 6874406..0be9971 100644
--- a/test/CC/CCCOMSTR.py
+++ b/test/CC/CCCOMSTR.py
@@ -38,16 +38,7 @@ _exe = TestSCons._exe
test = TestSCons.TestSCons()
-
-
-test.write('mycc.py', r"""
-import sys
-outfile = open(sys.argv[1], 'wb')
-infile = open(sys.argv[2], 'rb')
-for l in [l for l in infile.readlines() if l[:6] != '/*cc*/']:
- outfile.write(l)
-sys.exit(0)
-""")
+test.dir_fixture('shared-fixture')
if os.path.normcase('.c') == os.path.normcase('.C'):
alt_c_suffix = '.C'
@@ -62,11 +53,6 @@ env.Object(target = 'test1', source = 'test1.c')
env.Object(target = 'test2', source = 'test2%(alt_c_suffix)s')
""" % locals())
-test.write('test1.c', """\
-test1.c
-/*cc*/
-""")
-
test.write('test2'+alt_c_suffix, """\
test2.C
/*cc*/
diff --git a/test/CC/CCVERSION-fixture/.exclude_tests b/test/CC/CCVERSION-fixture/.exclude_tests
new file mode 100644
index 0000000..775816e
--- /dev/null
+++ b/test/CC/CCVERSION-fixture/.exclude_tests
@@ -0,0 +1 @@
+versioned.py
diff --git a/test/CC/CCVERSION-fixture/versioned.py b/test/CC/CCVERSION-fixture/versioned.py
new file mode 100644
index 0000000..d6c7ae8
--- /dev/null
+++ b/test/CC/CCVERSION-fixture/versioned.py
@@ -0,0 +1,12 @@
+import os
+import sys
+if '-dumpversion' in sys.argv:
+ print('3.9.9')
+ sys.exit(0)
+if '--version' in sys.argv:
+ print('this is version 2.9.9 wrapping', sys.argv[2])
+ sys.exit(0)
+if sys.argv[1] not in [ '2.9.9', '3.9.9' ]:
+ print('wrong version', sys.argv[1], 'when wrapping', sys.argv[2])
+ sys.exit(1)
+os.system(" ".join(sys.argv[2:]))
diff --git a/test/CC/CCVERSION.py b/test/CC/CCVERSION.py
index f785ddc..20d8616 100644
--- a/test/CC/CCVERSION.py
+++ b/test/CC/CCVERSION.py
@@ -36,20 +36,8 @@ test = TestSCons.TestSCons()
if sys.platform == 'win32':
test.skip_test('CCVERSION not set with MSVC, skipping test.')
-test.write("versioned.py",
-"""import os
-import sys
-if '-dumpversion' in sys.argv:
- print '3.9.9'
- sys.exit(0)
-if '--version' in sys.argv:
- print 'this is version 2.9.9 wrapping', sys.argv[2]
- sys.exit(0)
-if sys.argv[1] not in [ '2.9.9', '3.9.9' ]:
- print 'wrong version', sys.argv[1], 'when wrapping', sys.argv[2]
- sys.exit(1)
-os.system(" ".join(sys.argv[2:]))
-""")
+test.dir_fixture('CCVERSION-fixture')
+test.file_fixture(os.path.join('CC-fixture', 'foo.c'))
test.write('SConstruct', """
cc = Environment().Dictionary('CC')
@@ -57,19 +45,6 @@ foo = Environment(CC = r'%(_python_)s versioned.py "${CCVERSION}" ' + cc)
foo.Program(target = 'foo', source = 'foo.c')
""" % locals())
-test.write('foo.c', r"""
-#include <stdio.h>
-#include <stdlib.h>
-
-int
-main(int argc, char *argv[])
-{
- argv[argc++] = "--";
- printf("foo.c\n");
- exit (0);
-}
-""")
-
test.run(arguments = 'foo' + _exe)
test.up_to_date(arguments = 'foo' + _exe)
diff --git a/test/CC/SHCC.py b/test/CC/SHCC.py
index b624bf2..5f121fc 100644
--- a/test/CC/SHCC.py
+++ b/test/CC/SHCC.py
@@ -35,7 +35,7 @@ test = TestSCons.TestSCons()
test.write("wrapper.py",
"""import os
import sys
-open('%s', 'wb').write("wrapper.py\\n")
+open('%s', 'wb').write(b"wrapper.py\\n")
os.system(" ".join(sys.argv[1:]))
""" % test.workpath('wrapper.out').replace('\\', '\\\\'))
@@ -76,11 +76,11 @@ main(int argc, char *argv[])
test.run(arguments = 'foo')
-test.fail_test(os.path.exists(test.workpath('wrapper.out')))
+test.must_not_exist(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")
test.pass_test()
diff --git a/test/CC/SHCCCOM.py b/test/CC/SHCCCOM.py
index 006a80e..689b6e7 100644
--- a/test/CC/SHCCCOM.py
+++ b/test/CC/SHCCCOM.py
@@ -36,16 +36,7 @@ _python_ = TestSCons._python_
test = TestSCons.TestSCons()
-
-
-test.write('mycc.py', r"""
-import sys
-outfile = open(sys.argv[1], 'wb')
-infile = open(sys.argv[2], 'rb')
-for l in [l for l in infile.readlines() if l[:6] != '/*cc*/']:
- outfile.write(l)
-sys.exit(0)
-""")
+test.dir_fixture('shared-fixture')
if os.path.normcase('.c') == os.path.normcase('.C'):
alt_c_suffix = '.C'
@@ -60,11 +51,6 @@ env.SharedObject(target = 'test1', source = 'test1.c')
env.SharedObject(target = 'test2', source = 'test2%(alt_c_suffix)s')
""" % locals())
-test.write('test1.c', """\
-test1.c
-/*cc*/
-""")
-
test.write('test2'+alt_c_suffix, """\
test2.C
/*cc*/
diff --git a/test/CC/SHCCCOMSTR.py b/test/CC/SHCCCOMSTR.py
index 15bfa85..0983a67 100644
--- a/test/CC/SHCCCOMSTR.py
+++ b/test/CC/SHCCCOMSTR.py
@@ -38,16 +38,7 @@ _exe = TestSCons._exe
test = TestSCons.TestSCons()
-
-
-test.write('mycc.py', r"""
-import sys
-outfile = open(sys.argv[1], 'wb')
-infile = open(sys.argv[2], 'rb')
-for l in [l for l in infile.readlines() if l[:6] != '/*cc*/']:
- outfile.write(l)
-sys.exit(0)
-""")
+test.dir_fixture('shared-fixture')
if os.path.normcase('.c') == os.path.normcase('.C'):
alt_c_suffix = '.C'
@@ -63,11 +54,6 @@ env.SharedObject(target = 'test1', source = 'test1.c')
env.SharedObject(target = 'test2', source = 'test2%(alt_c_suffix)s')
""" % locals())
-test.write('test1.c', """\
-test1.c
-/*cc*/
-""")
-
test.write('test2'+alt_c_suffix, """\
test2.C
/*cc*/
diff --git a/test/CC/shared-fixture/.exclude_tests b/test/CC/shared-fixture/.exclude_tests
new file mode 100644
index 0000000..3f2bc0f
--- /dev/null
+++ b/test/CC/shared-fixture/.exclude_tests
@@ -0,0 +1 @@
+mycc.py
diff --git a/test/CC/shared-fixture/mycc.py b/test/CC/shared-fixture/mycc.py
new file mode 100644
index 0000000..b96c31c
--- /dev/null
+++ b/test/CC/shared-fixture/mycc.py
@@ -0,0 +1,6 @@
+import sys
+outfile = open(sys.argv[1], 'wb')
+infile = open(sys.argv[2], 'rb')
+for l in [l for l in infile.readlines() if l[:6] != b'/*cc*/']:
+ outfile.write(l)
+sys.exit(0)
diff --git a/test/CC/shared-fixture/test1.c b/test/CC/shared-fixture/test1.c
new file mode 100644
index 0000000..9c281d7
--- /dev/null
+++ b/test/CC/shared-fixture/test1.c
@@ -0,0 +1,2 @@
+test1.c
+/*cc*/
diff --git a/test/CFILESUFFIX.py b/test/CFILESUFFIX.py
index 1a81240..0a3a81a 100644
--- a/test/CFILESUFFIX.py
+++ b/test/CFILESUFFIX.py
@@ -42,7 +42,7 @@ import sys
cmd_opts, args = getopt.getopt(sys.argv[1:], 't', [])
for a in args:
contents = open(a, 'rb').read()
- sys.stdout.write(contents.replace('LEX', 'mylex.py'))
+ sys.stdout.write((contents.replace(b'LEX', b'mylex.py')).decode())
sys.exit(0)
""")
diff --git a/test/QT/QTFLAGS.py b/test/QT/QTFLAGS.py
index f6aa00f..e29ee80 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 fileToContentsStart.items():
+ for f,c in list(fileToContentsStart.items()):
if test.read(test.workpath('work1', f)).find(c) != 0:
return 1
return 0
diff --git a/test/SWIG/SWIGCOM.py b/test/SWIG/SWIGCOM.py
index 44602fd..ee3ff64 100644
--- a/test/SWIG/SWIGCOM.py
+++ b/test/SWIG/SWIGCOM.py
@@ -41,7 +41,7 @@ import sys
outfile = open(sys.argv[1], 'wb')
for f in sys.argv[2:]:
infile = open(f, 'rb')
- for l in [l for l in infile.readlines() if l != '/*swig*/\\n']:
+ for l in [l for l in infile.readlines() if l != b'/*swig*/\\n']:
outfile.write(l)
sys.exit(0)
""")
diff --git a/test/SWIG/SWIGCOMSTR.py b/test/SWIG/SWIGCOMSTR.py
index 1df3499..24db13e 100644
--- a/test/SWIG/SWIGCOMSTR.py
+++ b/test/SWIG/SWIGCOMSTR.py
@@ -42,7 +42,7 @@ import sys
outfile = open(sys.argv[1], 'wb')
for f in sys.argv[2:]:
infile = open(f, 'rb')
- for l in [l for l in infile.readlines() if l != '/*swig*/\\n']:
+ for l in [l for l in infile.readlines() if l != b'/*swig*/\\n']:
outfile.write(l)
sys.exit(0)
""")
diff --git a/test/YACC/YACC-fixture/.exclude_tests b/test/YACC/YACC-fixture/.exclude_tests
new file mode 100644
index 0000000..f12c4d0
--- /dev/null
+++ b/test/YACC/YACC-fixture/.exclude_tests
@@ -0,0 +1 @@
+myyacc.py
diff --git a/test/YACC/YACC-fixture/aaa.y b/test/YACC/YACC-fixture/aaa.y
new file mode 100644
index 0000000..dab6e40
--- /dev/null
+++ b/test/YACC/YACC-fixture/aaa.y
@@ -0,0 +1,2 @@
+aaa.y
+YACC
diff --git a/test/YACC/YACC-fixture/bbb.yacc b/test/YACC/YACC-fixture/bbb.yacc
new file mode 100644
index 0000000..ca4ab73
--- /dev/null
+++ b/test/YACC/YACC-fixture/bbb.yacc
@@ -0,0 +1,2 @@
+bbb.yacc
+YACC
diff --git a/test/YACC/YACC-fixture/ccc.yy b/test/YACC/YACC-fixture/ccc.yy
new file mode 100644
index 0000000..c7ec552
--- /dev/null
+++ b/test/YACC/YACC-fixture/ccc.yy
@@ -0,0 +1,2 @@
+ccc.yacc
+YACC
diff --git a/test/YACC/YACC-fixture/ddd.ym b/test/YACC/YACC-fixture/ddd.ym
new file mode 100644
index 0000000..c8962be
--- /dev/null
+++ b/test/YACC/YACC-fixture/ddd.ym
@@ -0,0 +1,2 @@
+ddd.yacc
+YACC
diff --git a/test/YACC/YACC-fixture/myyacc.py b/test/YACC/YACC-fixture/myyacc.py
new file mode 100644
index 0000000..c2e1abf
--- /dev/null
+++ b/test/YACC/YACC-fixture/myyacc.py
@@ -0,0 +1,13 @@
+import getopt
+import sys
+cmd_opts, args = getopt.getopt(sys.argv[1:], 'o:', [])
+output = None
+opt_string = ''
+for opt, arg in cmd_opts:
+ if opt == '-o': output = open(arg, 'wb')
+ else: opt_string = opt_string + ' ' + opt
+for a in args:
+ contents = open(a, 'rb').read()
+ output.write(contents.replace(b'YACC', b'myyacc.py'))
+output.close()
+sys.exit(0)
diff --git a/test/YACC/YACC.py b/test/YACC/YACC.py
index 59067f3..3fc1f7c 100644
--- a/test/YACC/YACC.py
+++ b/test/YACC/YACC.py
@@ -41,25 +41,7 @@ else:
test = TestSCons.TestSCons()
-
-
-test.write('myyacc.py', """
-import getopt
-import sys
-cmd_opts, args = getopt.getopt(sys.argv[1:], 'o:', [])
-output = None
-opt_string = ''
-for opt, arg in cmd_opts:
- if opt == '-o': output = open(arg, 'wb')
- else: opt_string = opt_string + ' ' + opt
-for a in args:
- contents = open(a, 'rb').read()
- output.write(contents.replace('YACC', 'myyacc.py'))
-output.close()
-sys.exit(0)
-""")
-
-
+test.dir_fixture('YACC-fixture')
test.write('SConstruct', """
env = Environment(YACC = r'%(_python_)s myyacc.py', tools=['default', 'yacc'])
@@ -69,11 +51,6 @@ env.CXXFile(target = 'ccc', source = 'ccc.yy')
env.CFile(target = 'ddd', source = 'ddd.ym')
""" % locals())
-test.write('aaa.y', "aaa.y\nYACC\n")
-test.write('bbb.yacc', "bbb.yacc\nYACC\n")
-test.write('ccc.yy', "ccc.yacc\nYACC\n")
-test.write('ddd.ym', "ddd.yacc\nYACC\n")
-
test.run(arguments = '.', stderr = None)
test.must_match('aaa.c', "aaa.y\nmyyacc.py\n")
diff --git a/test/YACC/YACCCOM-fixture/.exclude_tests b/test/YACC/YACCCOM-fixture/.exclude_tests
new file mode 100644
index 0000000..f12c4d0
--- /dev/null
+++ b/test/YACC/YACCCOM-fixture/.exclude_tests
@@ -0,0 +1 @@
+myyacc.py
diff --git a/test/YACC/YACCCOM-fixture/myyacc.py b/test/YACC/YACCCOM-fixture/myyacc.py
new file mode 100644
index 0000000..1502800
--- /dev/null
+++ b/test/YACC/YACCCOM-fixture/myyacc.py
@@ -0,0 +1,7 @@
+import sys
+outfile = open(sys.argv[1], 'wb')
+for f in sys.argv[2:]:
+ infile = open(f, 'rb')
+ for l in [l for l in infile.readlines() if l != b'/*yacc*/\n']:
+ outfile.write(l)
+sys.exit(0)
diff --git a/test/YACC/YACCCOM.py b/test/YACC/YACCCOM.py
index 4e43676..70ffa72 100644
--- a/test/YACC/YACCCOM.py
+++ b/test/YACC/YACCCOM.py
@@ -34,17 +34,8 @@ _python_ = TestSCons._python_
test = TestSCons.TestSCons()
-
-
-test.write('myyacc.py', """
-import sys
-outfile = open(sys.argv[1], 'wb')
-for f in sys.argv[2:]:
- infile = open(f, 'rb')
- for l in [l for l in infile.readlines() if l != '/*yacc*/\\n']:
- outfile.write(l)
-sys.exit(0)
-""")
+test.dir_fixture('shared-fixture')
+test.dir_fixture('YACCCOM-fixture')
test.write('SConstruct', """
env = Environment(tools=['default', 'yacc'],
@@ -53,9 +44,6 @@ env.CFile(target = 'aaa', source = 'aaa.y')
env.CFile(target = 'bbb', source = 'bbb.yacc')
""" % locals())
-test.write('aaa.y', "aaa.y\n/*yacc*/\n")
-test.write('bbb.yacc', "bbb.yacc\n/*yacc*/\n")
-
test.run(arguments = '.')
test.must_match('aaa.c', "aaa.y\n")
diff --git a/test/YACC/YACCCOMSTR.py b/test/YACC/YACCCOMSTR.py
index eaf3fde..344b715 100644
--- a/test/YACC/YACCCOMSTR.py
+++ b/test/YACC/YACCCOMSTR.py
@@ -35,17 +35,8 @@ _python_ = TestSCons._python_
test = TestSCons.TestSCons()
-
-
-test.write('myyacc.py', """
-import sys
-outfile = open(sys.argv[1], 'wb')
-for f in sys.argv[2:]:
- infile = open(f, 'rb')
- for l in [l for l in infile.readlines() if l != '/*yacc*/\\n']:
- outfile.write(l)
-sys.exit(0)
-""")
+test.dir_fixture('shared-fixture')
+test.dir_fixture('YACCCOM-fixture')
test.write('SConstruct', """
env = Environment(tools=['default', 'yacc'],
@@ -55,9 +46,6 @@ env.CFile(target = 'aaa', source = 'aaa.y')
env.CFile(target = 'bbb', source = 'bbb.yacc')
""" % locals())
-test.write('aaa.y', "aaa.y\n/*yacc*/\n")
-test.write('bbb.yacc', "bbb.yacc\n/*yacc*/\n")
-
test.run(stdout = test.wrap_stdout("""\
Yaccing aaa.c from aaa.y
Yaccing bbb.c from bbb.yacc
diff --git a/test/YACC/YACCFLAGS-fixture/.exclude_tests b/test/YACC/YACCFLAGS-fixture/.exclude_tests
new file mode 100644
index 0000000..f12c4d0
--- /dev/null
+++ b/test/YACC/YACCFLAGS-fixture/.exclude_tests
@@ -0,0 +1 @@
+myyacc.py
diff --git a/test/YACC/YACCFLAGS-fixture/myyacc.py b/test/YACC/YACCFLAGS-fixture/myyacc.py
new file mode 100644
index 0000000..ffd9031
--- /dev/null
+++ b/test/YACC/YACCFLAGS-fixture/myyacc.py
@@ -0,0 +1,17 @@
+import getopt
+import sys
+cmd_opts, args = getopt.getopt(sys.argv[1:], 'o:I:x', [])
+output = None
+opt_string = ''
+i_arguments = ''
+for opt, arg in cmd_opts:
+ if opt == '-o': output = open(arg, 'wb')
+ elif opt == '-I': i_arguments = i_arguments + ' ' + arg
+ else: opt_string = opt_string + ' ' + opt
+for a in args:
+ contents = open(a, 'rb').read()
+ contents = contents.replace(b'YACCFLAGS', opt_string.encode())
+ contents = contents.replace(b'I_ARGS', i_arguments.encode())
+ output.write(contents)
+output.close()
+sys.exit(0)
diff --git a/test/YACC/YACCFLAGS.py b/test/YACC/YACCFLAGS.py
index f0b698b..b3f86fe 100644
--- a/test/YACC/YACCFLAGS.py
+++ b/test/YACC/YACCFLAGS.py
@@ -43,27 +43,7 @@ test = TestSCons.TestSCons()
test.subdir('in')
-
-
-test.write('myyacc.py', """
-import getopt
-import sys
-cmd_opts, args = getopt.getopt(sys.argv[1:], 'o:I:x', [])
-output = None
-opt_string = ''
-i_arguments = ''
-for opt, arg in cmd_opts:
- if opt == '-o': output = open(arg, 'wb')
- elif opt == '-I': i_arguments = i_arguments + ' ' + arg
- else: opt_string = opt_string + ' ' + opt
-for a in args:
- contents = open(a, 'rb').read()
- contents = contents.replace('YACCFLAGS', opt_string)
- contents = contents.replace('I_ARGS', i_arguments)
- output.write(contents)
-output.close()
-sys.exit(0)
-""")
+test.dir_fixture('YACCFLAGS-fixture')
test.write('SConstruct', """
env = Environment(YACC = r'%(_python_)s myyacc.py',
diff --git a/test/YACC/YACCHFILESUFFIX.py b/test/YACC/YACCHFILESUFFIX.py
index 8801aea..f205473 100644
--- a/test/YACC/YACCHFILESUFFIX.py
+++ b/test/YACC/YACCHFILESUFFIX.py
@@ -47,11 +47,11 @@ for o, a in opts:
outfile = open(a, 'wb')
for f in args:
infile = open(f, 'rb')
- for l in [l for l in infile.readlines() if l != '/*yacc*/\\n']:
+ for l in [l for l in infile.readlines() if l != b'/*yacc*/\\n']:
outfile.write(l)
outfile.close()
base, ext = os.path.splitext(args[0])
-open(base+'.hsuffix', 'wb').write(" ".join(sys.argv)+'\\n')
+open(base+'.hsuffix', 'wb').write((" ".join(sys.argv)+'\\n').encode())
sys.exit(0)
""")
diff --git a/test/YACC/YACCHXXFILESUFFIX.py b/test/YACC/YACCHXXFILESUFFIX.py
index 6664356..6418189 100644
--- a/test/YACC/YACCHXXFILESUFFIX.py
+++ b/test/YACC/YACCHXXFILESUFFIX.py
@@ -47,11 +47,11 @@ for o, a in opts:
outfile = open(a, 'wb')
for f in args:
infile = open(f, 'rb')
- for l in [l for l in infile.readlines() if l != '/*yacc*/\\n']:
+ for l in [l for l in infile.readlines() if l != b'/*yacc*/\\n']:
outfile.write(l)
outfile.close()
base, ext = os.path.splitext(args[0])
-open(base+'.hxxsuffix', 'wb').write(" ".join(sys.argv)+'\\n')
+open(base+'.hxxsuffix', 'wb').write((" ".join(sys.argv)+'\\n').encode())
sys.exit(0)
""")
diff --git a/test/YACC/YACCVCGFILESUFFIX.py b/test/YACC/YACCVCGFILESUFFIX.py
index 0327d8a..5306076 100644
--- a/test/YACC/YACCVCGFILESUFFIX.py
+++ b/test/YACC/YACCVCGFILESUFFIX.py
@@ -49,12 +49,12 @@ for o, a in opts:
outfile = open(a, 'wb')
for f in args:
infile = open(f, 'rb')
- for l in [l for l in infile.readlines() if l != '/*yacc*/\\n']:
+ for l in [l for l in infile.readlines() if l != b'/*yacc*/\\n']:
outfile.write(l)
outfile.close()
if vcg:
base, ext = os.path.splitext(args[0])
- open(base+'.vcgsuffix', 'wb').write(" ".join(sys.argv)+'\\n')
+ open(base+'.vcgsuffix', 'wb').write((" ".join(sys.argv)+'\\n').encode())
sys.exit(0)
""")
diff --git a/test/YACC/shared-fixture/.exclude_tests b/test/YACC/shared-fixture/.exclude_tests
new file mode 100644
index 0000000..f12c4d0
--- /dev/null
+++ b/test/YACC/shared-fixture/.exclude_tests
@@ -0,0 +1 @@
+myyacc.py
diff --git a/test/YACC/shared-fixture/aaa.y b/test/YACC/shared-fixture/aaa.y
new file mode 100644
index 0000000..f7f4cc7
--- /dev/null
+++ b/test/YACC/shared-fixture/aaa.y
@@ -0,0 +1,2 @@
+aaa.y
+/*yacc*/
diff --git a/test/YACC/shared-fixture/bbb.yacc b/test/YACC/shared-fixture/bbb.yacc
new file mode 100644
index 0000000..b3c856f
--- /dev/null
+++ b/test/YACC/shared-fixture/bbb.yacc
@@ -0,0 +1,2 @@
+bbb.yacc
+/*yacc*/
diff --git a/test/ZIP/ZIP.py b/test/ZIP/ZIP.py
index f2acad8..f842caf 100644
--- a/test/ZIP/ZIP.py
+++ b/test/ZIP/ZIP.py
@@ -91,7 +91,7 @@ marker_out = test.workpath('marker.out').replace('\\', '\\\\')
test.write('SConstruct', """\
def marker(target, source, env):
- open(r'%s', 'wb').write("marker\\n")
+ open(r'%s', 'wb').write(b"marker\\n")
f1 = Environment()
zipcom = f1.Dictionary('ZIPCOM')
if not isinstance(zipcom, list):
@@ -117,24 +117,24 @@ f1.Zip(target = 'f4deflated.zip', source = sources,
for f in ['file10', 'file11', 'file12',
'file13', 'file14', 'file15',
'file16', 'file17', 'file18']:
- test.write(f, f + "\n")
+ test.write(f, (f + "\n").encode())
test.run(arguments = 'f1.zip', stderr = None)
-test.fail_test(os.path.exists(test.workpath('marker.out')))
+test.must_not_exist(test.workpath('marker.out'))
-test.fail_test(not os.path.exists(test.workpath('f1.zip')))
+test.must_exist(test.workpath('f1.zip'))
test.run(arguments = 'f2.zip', stderr = None)
-test.fail_test(test.read('marker.out') != 'marker\n')
+test.must_match('marker.out', 'marker\n')
-test.fail_test(not os.path.exists(test.workpath('f2.zip')))
+test.must_exist(test.workpath('f2.zip'))
test.run(arguments = '.', stderr = None)
-test.fail_test(os.path.exists(test.workpath('f3.zip')))
-test.fail_test(not os.path.exists(test.workpath('f3.xyzzy')))
+test.must_not_exist(test.workpath('f3.zip'))
+test.must_exist(test.workpath('f3.xyzzy'))
test.fail_test(zipfile_files("f1.zip") != ['file10', 'file11', 'file12'])
diff --git a/test/ZIP/ZIPCOM-fixture/.exclude_tests b/test/ZIP/ZIPCOM-fixture/.exclude_tests
new file mode 100644
index 0000000..dae6f60
--- /dev/null
+++ b/test/ZIP/ZIPCOM-fixture/.exclude_tests
@@ -0,0 +1 @@
+myzip.py
diff --git a/test/ZIP/ZIPCOM-fixture/myzip.py b/test/ZIP/ZIPCOM-fixture/myzip.py
new file mode 100644
index 0000000..adbc6ac
--- /dev/null
+++ b/test/ZIP/ZIPCOM-fixture/myzip.py
@@ -0,0 +1,6 @@
+import sys
+outfile = open(sys.argv[1], 'wb')
+infile = open(sys.argv[2], 'rb')
+for l in [l for l in infile.readlines() if l != b'/*zip*/\n']:
+ outfile.write(l)
+sys.exit(0)
diff --git a/test/ZIP/ZIPCOM-fixture/test1.in b/test/ZIP/ZIPCOM-fixture/test1.in
new file mode 100644
index 0000000..0546626
--- /dev/null
+++ b/test/ZIP/ZIPCOM-fixture/test1.in
@@ -0,0 +1,2 @@
+test1.in
+/*zip*/
diff --git a/test/ZIP/ZIPCOM.py b/test/ZIP/ZIPCOM.py
index e982c58..4d84ccf 100644
--- a/test/ZIP/ZIPCOM.py
+++ b/test/ZIP/ZIPCOM.py
@@ -34,16 +34,7 @@ _python_ = TestSCons._python_
test = TestSCons.TestSCons()
-
-
-test.write('myzip.py', r"""
-import sys
-outfile = open(sys.argv[1], 'wb')
-infile = open(sys.argv[2], 'rb')
-for l in [l for l in infile.readlines() if l != '/*zip*/\n']:
- outfile.write(l)
-sys.exit(0)
-""")
+test.dir_fixture('ZIPCOM-fixture')
test.write('SConstruct', """
env = Environment(TOOLS = ['zip'],
@@ -51,17 +42,10 @@ env = Environment(TOOLS = ['zip'],
env.Zip('test1.zip', 'test1.in')
""" % locals())
-test.write('test1.in', """\
-test1.in
-/*zip*/
-""")
-
test.run()
test.must_match('test1.zip', "test1.in\n")
-
-
test.pass_test()
# Local Variables:
diff --git a/test/ZIP/ZIPCOMSTR-fixture/.exclude_tests b/test/ZIP/ZIPCOMSTR-fixture/.exclude_tests
new file mode 100644
index 0000000..dae6f60
--- /dev/null
+++ b/test/ZIP/ZIPCOMSTR-fixture/.exclude_tests
@@ -0,0 +1 @@
+myzip.py
diff --git a/test/ZIP/ZIPCOMSTR-fixture/aaa.in b/test/ZIP/ZIPCOMSTR-fixture/aaa.in
new file mode 100644
index 0000000..8474a29
--- /dev/null
+++ b/test/ZIP/ZIPCOMSTR-fixture/aaa.in
@@ -0,0 +1,2 @@
+aaa.in
+/*zip*/
diff --git a/test/ZIP/ZIPCOMSTR-fixture/myzip.py b/test/ZIP/ZIPCOMSTR-fixture/myzip.py
new file mode 100644
index 0000000..f0fcc51
--- /dev/null
+++ b/test/ZIP/ZIPCOMSTR-fixture/myzip.py
@@ -0,0 +1,7 @@
+import sys
+outfile = open(sys.argv[1], 'wb')
+for f in sys.argv[2:]:
+ infile = open(f, 'rb')
+ for l in [l for l in infile.readlines() if l != b'/*zip*/\n']:
+ outfile.write(l)
+sys.exit(0)
diff --git a/test/ZIP/ZIPCOMSTR.py b/test/ZIP/ZIPCOMSTR.py
index d91a48d..a26ed49 100644
--- a/test/ZIP/ZIPCOMSTR.py
+++ b/test/ZIP/ZIPCOMSTR.py
@@ -35,17 +35,7 @@ _python_ = TestSCons._python_
test = TestSCons.TestSCons()
-
-
-test.write('myzip.py', """
-import sys
-outfile = open(sys.argv[1], 'wb')
-for f in sys.argv[2:]:
- infile = open(f, 'rb')
- for l in [l for l in infile.readlines() if l != '/*zip*/\\n']:
- outfile.write(l)
-sys.exit(0)
-""")
+test.dir_fixture('ZIPCOMSTR-fixture')
test.write('SConstruct', """
env = Environment(tools=['zip'],
@@ -54,16 +44,12 @@ env = Environment(tools=['zip'],
env.Zip('aaa.zip', 'aaa.in')
""" % locals())
-test.write('aaa.in', "aaa.in\n/*zip*/\n")
-
test.run(stdout = test.wrap_stdout("""\
Zipping aaa.zip from aaa.in
"""))
test.must_match('aaa.zip', "aaa.in\n")
-
-
test.pass_test()
# Local Variables:
diff --git a/test/file-names.py b/test/file-names.py
index d9f9c63..4b89126 100644
--- a/test/file-names.py
+++ b/test/file-names.py
@@ -119,10 +119,10 @@ for c in goodChars:
c_str = ("%d"%ord(c[-1]))+c
if not invalid_leading_char(c):
- test.fail_test(test.read(c_str + "out") != contents(c))
- test.fail_test(test.read("out" + c_str + "out") != contents(c))
+ test.must_match(c_str + "out", contents(c))
+ test.must_match("out" + c_str + "out", contents(c))
if not invalid_trailing_char(c):
- test.fail_test(test.read("out" + c_str) != contents(c))
+ test.must_match("out" + c_str, contents(c))
test.pass_test()