From 953dc41b8b720fdcec7955de67d23206214e5125 Mon Sep 17 00:00:00 2001 From: Gary Oberbrunner Date: Sun, 22 Sep 2013 13:08:12 -0400 Subject: Result of raw 2to3 run (2to3-2.7); checkpoint for python3 conversion. --- QMTest/TestCmd.py | 32 +- QMTest/TestCmdTests.py | 136 +- QMTest/TestCommon.py | 66 +- QMTest/TestSCons.py | 52 +- QMTest/TestSConsMSVS.py | 2 +- QMTest/TestSCons_time.py | 4 +- QMTest/TestSConsign.py | 2 +- QMTest/scons_tdb.py | 18 +- bench/bench.py | 8 +- bench/env.__setitem__.py | 16 +- bench/is_types.py | 12 +- bench/timeit.py | 24 +- bin/Command.py | 6 +- bin/SConsDoc.py | 28 +- bin/SConsExamples.py | 20 +- bin/calibrate.py | 8 +- bin/caller-tree.py | 10 +- bin/docs-create-example-outputs.py | 6 +- bin/docs-update-generated.py | 2 +- bin/docs-validate.py | 8 +- bin/install_python.py | 6 +- bin/install_scons.py | 10 +- bin/linecount.py | 30 +- bin/memlogs.py | 8 +- bin/memoicmp.py | 24 +- bin/objcounts.py | 13 +- bin/scons-diff.py | 14 +- bin/scons-proc.py | 14 +- bin/scons-test.py | 60 +- bin/scons-unzip.py | 2 +- bin/scons_dev_master.py | 6 +- bin/svn-bisect.py | 14 +- bin/update-release-info.py | 30 +- bin/xmlagenda.py | 2 +- review.py | 3611 ++++++++++---------- runtest.py | 24 +- src/engine/SCons/Action.py | 47 +- src/engine/SCons/ActionTests.py | 12 +- src/engine/SCons/Builder.py | 20 +- src/engine/SCons/BuilderTests.py | 28 +- src/engine/SCons/CacheDirTests.py | 2 +- src/engine/SCons/Debug.py | 4 +- src/engine/SCons/Defaults.py | 11 +- src/engine/SCons/DefaultsTests.py | 2 +- src/engine/SCons/Environment.py | 59 +- src/engine/SCons/EnvironmentTests.py | 44 +- src/engine/SCons/ErrorsTests.py | 12 +- src/engine/SCons/ExecutorTests.py | 2 +- src/engine/SCons/Job.py | 4 +- src/engine/SCons/Memoize.py | 4 +- src/engine/SCons/MemoizeTests.py | 4 +- src/engine/SCons/Node/FS.py | 23 +- src/engine/SCons/Node/FSTests.py | 34 +- src/engine/SCons/Node/__init__.py | 12 +- src/engine/SCons/Options/__init__.py | 10 +- src/engine/SCons/Platform/__init__.py | 4 +- src/engine/SCons/Platform/aix.py | 2 +- src/engine/SCons/Platform/cygwin.py | 2 +- src/engine/SCons/Platform/darwin.py | 2 +- src/engine/SCons/Platform/hpux.py | 2 +- src/engine/SCons/Platform/irix.py | 2 +- src/engine/SCons/Platform/os2.py | 2 +- src/engine/SCons/Platform/posix.py | 9 +- src/engine/SCons/Platform/sunos.py | 2 +- src/engine/SCons/Platform/win32.py | 4 +- src/engine/SCons/SConf.py | 10 +- src/engine/SCons/SConfTests.py | 2 +- src/engine/SCons/SConsign.py | 16 +- src/engine/SCons/Scanner/C.py | 2 +- src/engine/SCons/Scanner/Fortran.py | 3 +- src/engine/SCons/Scanner/LaTeX.py | 4 +- src/engine/SCons/Scanner/Prog.py | 3 +- src/engine/SCons/Scanner/ProgTests.py | 4 +- src/engine/SCons/Scanner/ScannerTests.py | 2 +- src/engine/SCons/Scanner/__init__.py | 5 +- src/engine/SCons/Script/Interactive.py | 12 +- src/engine/SCons/Script/Main.py | 61 +- src/engine/SCons/Script/SConsOptions.py | 8 +- src/engine/SCons/Script/SConscript.py | 22 +- src/engine/SCons/Script/__init__.py | 8 +- src/engine/SCons/Subst.py | 8 +- src/engine/SCons/SubstTests.py | 48 +- src/engine/SCons/Taskmaster.py | 44 +- src/engine/SCons/TaskmasterTests.py | 10 +- src/engine/SCons/Tool/FortranCommon.py | 2 +- src/engine/SCons/Tool/GettextCommon.py | 12 +- src/engine/SCons/Tool/MSCommon/common.py | 6 +- src/engine/SCons/Tool/MSCommon/netframework.py | 4 +- src/engine/SCons/Tool/MSCommon/sdk.py | 8 +- src/engine/SCons/Tool/MSCommon/vc.py | 24 +- src/engine/SCons/Tool/MSCommon/vs.py | 6 +- src/engine/SCons/Tool/__init__.py | 36 +- src/engine/SCons/Tool/aixcc.py | 2 +- src/engine/SCons/Tool/aixf77.py | 2 +- src/engine/SCons/Tool/aixlink.py | 4 +- src/engine/SCons/Tool/applelink.py | 2 +- src/engine/SCons/Tool/cvf.py | 2 +- src/engine/SCons/Tool/cyglink.py | 2 +- .../docbook-xsl-1.76.1/extensions/docbook.py | 10 +- .../docbook/docbook-xsl-1.76.1/extensions/xslt.py | 12 +- src/engine/SCons/Tool/dvipdf.py | 2 +- src/engine/SCons/Tool/f03.py | 2 +- src/engine/SCons/Tool/f95.py | 2 +- src/engine/SCons/Tool/filesystem.py | 2 +- src/engine/SCons/Tool/gcc.py | 2 +- src/engine/SCons/Tool/gfortran.py | 2 +- src/engine/SCons/Tool/gnulink.py | 2 +- src/engine/SCons/Tool/gs.py | 2 +- src/engine/SCons/Tool/hpcc.py | 2 +- src/engine/SCons/Tool/hplink.py | 2 +- src/engine/SCons/Tool/icc.py | 2 +- src/engine/SCons/Tool/ifl.py | 2 +- src/engine/SCons/Tool/ifort.py | 2 +- src/engine/SCons/Tool/install.py | 26 +- src/engine/SCons/Tool/intelc.py | 19 +- src/engine/SCons/Tool/latex.py | 4 +- src/engine/SCons/Tool/link.py | 18 +- src/engine/SCons/Tool/midl.py | 2 +- src/engine/SCons/Tool/msgfmt.py | 2 +- src/engine/SCons/Tool/msginit.py | 4 +- src/engine/SCons/Tool/msgmerge.py | 2 +- src/engine/SCons/Tool/mslib.py | 2 +- src/engine/SCons/Tool/mslink.py | 12 +- src/engine/SCons/Tool/mssdk.py | 2 +- src/engine/SCons/Tool/msvc.py | 2 +- src/engine/SCons/Tool/msvs.py | 44 +- src/engine/SCons/Tool/msvsTests.py | 2 +- src/engine/SCons/Tool/packaging/__init__.py | 10 +- src/engine/SCons/Tool/packaging/ipk.py | 2 +- src/engine/SCons/Tool/packaging/msi.py | 8 +- src/engine/SCons/Tool/packaging/rpm.py | 12 +- src/engine/SCons/Tool/pdflatex.py | 2 +- src/engine/SCons/Tool/pdftex.py | 2 +- src/engine/SCons/Tool/qt.py | 12 +- src/engine/SCons/Tool/rpmutils.py | 6 +- src/engine/SCons/Tool/sgicc.py | 2 +- src/engine/SCons/Tool/sgilink.py | 2 +- src/engine/SCons/Tool/suncc.py | 2 +- src/engine/SCons/Tool/sunf77.py | 2 +- src/engine/SCons/Tool/sunf90.py | 2 +- src/engine/SCons/Tool/sunf95.py | 2 +- src/engine/SCons/Tool/sunlink.py | 2 +- src/engine/SCons/Tool/tex.py | 94 +- src/engine/SCons/Tool/textfile.py | 5 +- src/engine/SCons/Tool/xgettext.py | 8 +- src/engine/SCons/Util.py | 39 +- src/engine/SCons/UtilTests.py | 28 +- src/engine/SCons/Variables/EnumVariableTests.py | 4 +- src/engine/SCons/Variables/PathVariableTests.py | 16 +- src/engine/SCons/Variables/VariablesTests.py | 2 +- src/engine/SCons/Variables/__init__.py | 18 +- src/engine/SCons/compat/__init__.py | 2 +- src/engine/SCons/compat/_scons_subprocess.py | 48 +- src/engine/SCons/cpp.py | 11 +- src/engine/SCons/cppTests.py | 2 +- src/engine/SCons/dblite.py | 42 +- src/script/scons-time.py | 47 +- src/script/sconsign.py | 40 +- src/test_files.py | 10 +- src/test_interrupts.py | 6 +- src/test_pychecker.py | 2 +- src/test_setup.py | 6 +- src/test_strings.py | 8 +- test/AS/nasm.py | 2 +- test/Actions/unicode-signature.py | 2 +- test/AddOption/help.py | 16 +- test/Batch/action-changed.py | 4 +- test/Chmod.py | 78 +- test/Configure/ConfigureDryRunError.py | 2 +- test/Configure/config-h.py | 52 +- test/Configure/implicit-cache.py | 10 +- test/Copy-Action.py | 4 +- test/Deprecated/Options/Options.py | 2 +- test/Deprecated/SourceCode/BitKeeper/BitKeeper.py | 6 +- test/Deprecated/SourceCode/Subversion.py | 2 +- test/GetBuildFailures/parallel.py | 8 +- test/Glob/glob-libpath.py | 4 +- test/Install/Install.py | 2 +- test/Interactive/version.py | 2 +- test/Java/multi-step.py | 2 +- test/MSVC/batch-longlines.py | 122 +- test/MSVC/msvc.py | 6 +- test/QT/QTFLAGS.py | 2 +- test/QT/copied-env.py | 4 +- test/QT/warnings.py | 4 +- test/SConsignFile/use-dbhash.py | 2 +- test/SConsignFile/use-dbm.py | 2 +- test/SConsignFile/use-dumbdbm.py | 2 +- test/SConsignFile/use-gdbm.py | 2 +- test/SHELL.py | 2 +- test/Scanner/unicode.py | 10 +- test/TEMPFILEPREFIX.py | 2 +- test/TEX/TEX.py | 8 +- test/Value.py | 2 +- test/Variables/Variables.py | 2 +- test/WhereIs.py | 4 +- test/Win32/bad-drive.py | 4 +- test/Win32/default-drive.py | 2 +- test/ZIP/ZIP.py | 2 +- test/ZIP/ZIPROOT.py | 196 +- test/gnutools.py | 2 +- test/import.py | 4 +- test/long-lines/signature.py | 2 +- test/option--random.py | 4 +- test/option-v.py | 4 +- test/option/debug-count.py | 8 +- test/option/debug-time.py | 10 +- test/option/help-options.py | 4 +- test/option/profile.py | 2 +- test/scons-time/run/config/python.py | 2 +- test/scons-time/run/option/python.py | 2 +- test/sconsign/nonwritable.py | 4 +- test/sconsign/script/SConsignFile.py | 4 +- test/sconsign/script/Signatures.py | 4 +- test/sconsign/script/no-SConsignFile.py | 4 +- test/site_scons/sysdirs.py | 142 +- test/spaces.py | 2 +- test/subdivide.py | 4 +- test/update-release-info/update-release-info.py | 2 +- timings/ElectricCloud/TimeSCons-run.py | 2 +- www/gen_sched_table.py | 12 +- 221 files changed, 3292 insertions(+), 3282 deletions(-) diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index 38e9cd3..4f08d1f 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -285,7 +285,7 @@ version. # PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, # AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. -from __future__ import division + __author__ = "Steven Knight " __revision__ = "TestCmd.py 1.3.D001 2010/06/03 12:58:27 knight" @@ -355,7 +355,7 @@ except NameError: return isinstance(e, (str, UserString)) else: def is_String(e): - return isinstance(e, (str, unicode, UserString)) + return isinstance(e, (str, UserString)) tempfile.template = 'testcmd.' if os.name in ('posix', 'nt'): @@ -490,17 +490,17 @@ def match_re(lines = None, res = None): if not is_List(res): res = res.split("\n") if len(lines) != len(res): - print "match_re: expected %d lines, found %d"%(len(res), len(lines)) + print("match_re: expected %d lines, found %d"%(len(res), len(lines))) return for i in range(len(lines)): s = "^" + res[i] + "$" try: expr = re.compile(s) - except re.error, e: + except re.error as e: msg = "Regular expression error in %s: %s" raise re.error(msg % (repr(s), e.args[0])) if not expr.search(lines[i]): - print "match_re: mismatch at line %d:\n search re='%s'\n line='%s'"%(i,s,lines[i]) + print("match_re: mismatch at line %d:\n search re='%s'\n line='%s'"%(i,s,lines[i])) return return 1 @@ -514,7 +514,7 @@ def match_re_dotall(lines = None, res = None): s = "^" + res + "$" try: expr = re.compile(s, re.DOTALL) - except re.error, e: + except re.error as e: msg = "Regular expression error in %s: %s" raise re.error(msg % (repr(s), e.args[0])) return expr.match(lines) @@ -564,7 +564,7 @@ def diff_re(a, b, fromfile='', tofile='', s = "^" + aline + "$" try: expr = re.compile(s) - except re.error, e: + except re.error as e: msg = "Regular expression error in %s: %s" raise re.error(msg % (repr(s), e.args[0])) if not expr.search(bline): @@ -640,7 +640,7 @@ else: st = os.stat(f) except OSError: continue - if stat.S_IMODE(st[stat.ST_MODE]) & 0111: + if stat.S_IMODE(st[stat.ST_MODE]) & 0o111: return f return None @@ -716,7 +716,7 @@ class Popen(subprocess.Popen): (errCode, written) = WriteFile(x, input) except ValueError: return self._close('stdin') - except (subprocess.pywintypes.error, Exception), why: + except (subprocess.pywintypes.error, Exception) as why: if why.args[0] in (109, errno.ESHUTDOWN): return self._close('stdin') raise @@ -737,7 +737,7 @@ class Popen(subprocess.Popen): (errCode, read) = ReadFile(x, nAvail, None) except ValueError: return self._close(which) - except (subprocess.pywintypes.error, Exception), why: + except (subprocess.pywintypes.error, Exception) as why: if why.args[0] in (109, errno.ESHUTDOWN): return self._close(which) raise @@ -756,7 +756,7 @@ class Popen(subprocess.Popen): try: written = os.write(self.stdin.fileno(), input) - except OSError, why: + except OSError as why: if why.args[0] == errno.EPIPE: #broken pipe return self._close('stdin') raise @@ -950,7 +950,7 @@ class TestCmd(object): condition = self.condition if self._preserve[condition]: for dir in self._dirlist: - print unicode("Preserved directory " + dir + "\n"), + print(str("Preserved directory " + dir + "\n"), end=' ') else: list = self._dirlist[:] list.reverse() @@ -1016,10 +1016,10 @@ class TestCmd(object): if diff_function is None: diff_function = self.simple_diff if name is not None: - print self.banner(name) + print(self.banner(name)) args = (a.splitlines(), b.splitlines()) + args for line in diff_function(*args, **kw): - print line + print(line) def diff_stderr(self, a, b, *args, **kw): """Compare actual and expected file contents. @@ -1645,12 +1645,12 @@ class TestCmd(object): def do_chmod(fname): try: st = os.stat(fname) except OSError: pass - else: os.chmod(fname, stat.S_IMODE(st[stat.ST_MODE]|0200)) + else: os.chmod(fname, stat.S_IMODE(st[stat.ST_MODE]|0o200)) else: def do_chmod(fname): try: st = os.stat(fname) except OSError: pass - else: os.chmod(fname, stat.S_IMODE(st[stat.ST_MODE]&~0200)) + else: os.chmod(fname, stat.S_IMODE(st[stat.ST_MODE]&~0o200)) if os.path.isfile(top): do_chmod(top) diff --git a/QMTest/TestCmdTests.py b/QMTest/TestCmdTests.py index 1044ed1..96e0cbf 100644 --- a/QMTest/TestCmdTests.py +++ b/QMTest/TestCmdTests.py @@ -26,13 +26,13 @@ import os import shutil import signal import stat -import StringIO +import io import sys import tempfile import time import types import unittest -import UserList +import collections # Strip the current directory so we get the right TestCmd.py module. sys.path = sys.path[1:] @@ -131,11 +131,11 @@ class TestCmdTestCase(unittest.TestCase): run_env.write(t.scriptout_path, textout) run_env.write(t.scripterr_path, texterr) - os.chmod(t.script_path, 0644) # XXX UNIX-specific - os.chmod(t.scriptx_path, 0755) # XXX UNIX-specific - os.chmod(t.script1_path, 0644) # XXX UNIX-specific - os.chmod(t.scriptout_path, 0644) # XXX UNIX-specific - os.chmod(t.scripterr_path, 0644) # XXX UNIX-specific + os.chmod(t.script_path, 0o644) # XXX UNIX-specific + os.chmod(t.scriptx_path, 0o755) # XXX UNIX-specific + os.chmod(t.script1_path, 0o644) # XXX UNIX-specific + os.chmod(t.scriptout_path, 0o644) # XXX UNIX-specific + os.chmod(t.scripterr_path, 0o644) # XXX UNIX-specific t.orig_cwd = os.getcwd() @@ -220,8 +220,8 @@ class cleanup_TestCase(TestCmdTestCase): test = TestCmd.TestCmd(workdir = '') wdir = test.workdir test.write('file2', "Test file #2\n") - os.chmod(test.workpath('file2'), 0400) - os.chmod(wdir, 0500) + os.chmod(test.workpath('file2'), 0o400) + os.chmod(wdir, 0o500) test.cleanup() assert not os.path.exists(wdir) @@ -286,35 +286,35 @@ class chmod_TestCase(TestCmdTestCase): test.chmod(['sub', 'file2'], stat.S_IWRITE) file1_mode = stat.S_IMODE(os.stat(wdir_file1)[stat.ST_MODE]) - assert file1_mode == 0444, '0%o' % file1_mode + assert file1_mode == 0o444, '0%o' % file1_mode file2_mode = stat.S_IMODE(os.stat(wdir_sub_file2)[stat.ST_MODE]) - assert file2_mode == 0666, '0%o' % file2_mode + assert file2_mode == 0o666, '0%o' % file2_mode test.chmod('file1', stat.S_IWRITE) test.chmod(wdir_sub_file2, stat.S_IREAD) file1_mode = stat.S_IMODE(os.stat(wdir_file1)[stat.ST_MODE]) - assert file1_mode == 0666, '0%o' % file1_mode + assert file1_mode == 0o666, '0%o' % file1_mode file2_mode = stat.S_IMODE(os.stat(wdir_sub_file2)[stat.ST_MODE]) - assert file2_mode == 0444, '0%o' % file2_mode + assert file2_mode == 0o444, '0%o' % file2_mode else: - test.chmod(wdir_file1, 0700) - test.chmod(['sub', 'file2'], 0760) + test.chmod(wdir_file1, 0o700) + test.chmod(['sub', 'file2'], 0o760) file1_mode = stat.S_IMODE(os.stat(wdir_file1)[stat.ST_MODE]) - assert file1_mode == 0700, '0%o' % file1_mode + assert file1_mode == 0o700, '0%o' % file1_mode file2_mode = stat.S_IMODE(os.stat(wdir_sub_file2)[stat.ST_MODE]) - assert file2_mode == 0760, '0%o' % file2_mode + assert file2_mode == 0o760, '0%o' % file2_mode - test.chmod('file1', 0765) - test.chmod(wdir_sub_file2, 0567) + test.chmod('file1', 0o765) + test.chmod(wdir_sub_file2, 0o567) file1_mode = stat.S_IMODE(os.stat(wdir_file1)[stat.ST_MODE]) - assert file1_mode == 0765, '0%o' % file1_mode + assert file1_mode == 0o765, '0%o' % file1_mode file2_mode = stat.S_IMODE(os.stat(wdir_sub_file2)[stat.ST_MODE]) - assert file2_mode == 0567, '0%o' % file2_mode + assert file2_mode == 0o567, '0%o' % file2_mode @@ -1032,14 +1032,14 @@ class match_exact_TestCase(TestCmdTestCase): assert test.match_exact("abcde\n", "abcde\n") assert not test.match_exact(["12345\n", "abcde\n"], ["1[0-9]*5\n", "a.*e\n"]) assert test.match_exact(["12345\n", "abcde\n"], ["12345\n", "abcde\n"]) - assert not test.match_exact(UserList.UserList(["12345\n", "abcde\n"]), + assert not test.match_exact(collections.UserList(["12345\n", "abcde\n"]), ["1[0-9]*5\n", "a.*e\n"]) - assert test.match_exact(UserList.UserList(["12345\n", "abcde\n"]), + assert test.match_exact(collections.UserList(["12345\n", "abcde\n"]), ["12345\n", "abcde\n"]) assert not test.match_exact(["12345\n", "abcde\n"], - UserList.UserList(["1[0-9]*5\n", "a.*e\n"])) + collections.UserList(["1[0-9]*5\n", "a.*e\n"])) assert test.match_exact(["12345\n", "abcde\n"], - UserList.UserList(["12345\n", "abcde\n"])) + collections.UserList(["12345\n", "abcde\n"])) assert not test.match_exact("12345\nabcde\n", "1[0-9]*5\na.*e\n") assert test.match_exact("12345\nabcde\n", "12345\nabcde\n") lines = ["vwxyz\n", "67890\n"] @@ -1098,26 +1098,26 @@ sys.exit(0) ["1.*j\n"]) assert test.match_re_dotall(["12345\n", "abcde\n", "fghij\n"], ["12345\n", "abcde\n", "fghij\n"]) - assert test.match_re_dotall(UserList.UserList(["12345\n", + assert test.match_re_dotall(collections.UserList(["12345\n", "abcde\n", "fghij\n"]), ["1[0-9]*5\n", "a.*e\n", "f.*j\n"]) - assert test.match_re_dotall(UserList.UserList(["12345\n", + assert test.match_re_dotall(collections.UserList(["12345\n", "abcde\n", "fghij\n"]), ["1.*j\n"]) - assert test.match_re_dotall(UserList.UserList(["12345\n", + assert test.match_re_dotall(collections.UserList(["12345\n", "abcde\n", "fghij\n"]), ["12345\n", "abcde\n", "fghij\n"]) assert test.match_re_dotall(["12345\n", "abcde\n", "fghij\n"], - UserList.UserList(["1[0-9]*5\n", + collections.UserList(["1[0-9]*5\n", "a.*e\n", "f.*j\n"])) assert test.match_re_dotall(["12345\n", "abcde\n", "fghij\n"], - UserList.UserList(["1.*j\n"])) + collections.UserList(["1.*j\n"])) assert test.match_re_dotall(["12345\n", "abcde\n", "fghij\n"], - UserList.UserList(["12345\n", + collections.UserList(["12345\n", "abcde\n", "fghij\n"])) assert test.match_re_dotall("12345\nabcde\nfghij\n", @@ -1176,14 +1176,14 @@ sys.exit(0) assert test.match_re("abcde\n", "abcde\n") assert test.match_re(["12345\n", "abcde\n"], ["1[0-9]*5\n", "a.*e\n"]) assert test.match_re(["12345\n", "abcde\n"], ["12345\n", "abcde\n"]) - assert test.match_re(UserList.UserList(["12345\n", "abcde\n"]), + assert test.match_re(collections.UserList(["12345\n", "abcde\n"]), ["1[0-9]*5\n", "a.*e\n"]) - assert test.match_re(UserList.UserList(["12345\n", "abcde\n"]), + assert test.match_re(collections.UserList(["12345\n", "abcde\n"]), ["12345\n", "abcde\n"]) assert test.match_re(["12345\n", "abcde\n"], - UserList.UserList(["1[0-9]*5\n", "a.*e\n"])) + collections.UserList(["1[0-9]*5\n", "a.*e\n"])) assert test.match_re(["12345\n", "abcde\n"], - UserList.UserList(["12345\n", "abcde\n"])) + collections.UserList(["12345\n", "abcde\n"])) assert test.match_re("12345\nabcde\n", "1[0-9]*5\na.*e\n") assert test.match_re("12345\nabcde\n", "12345\nabcde\n") lines = ["vwxyz\n", "67890\n"] @@ -1463,7 +1463,7 @@ class preserve_TestCase(TestCmdTestCase): def test_preserve(self): """Test preserve()""" def cleanup_test(test, cond=None, stdout=""): - io = StringIO.StringIO() + io = io.StringIO() save = sys.stdout sys.stdout = io try: @@ -1603,7 +1603,7 @@ class read_TestCase(TestCmdTestCase): _file_matches(wdir_foo_file3, test.read(['foo', 'file3']), "Test\nfile\n#3.\n") _file_matches(wdir_foo_file3, - test.read(UserList.UserList(['foo', 'file3'])), + test.read(collections.UserList(['foo', 'file3'])), "Test\nfile\n#3.\n") _file_matches(wdir_file4, test.read('file4', mode = 'r'), "Test\nfile\n#4.\n") @@ -1862,8 +1862,8 @@ class run_verbose_TestCase(TestCmdTestCase): workdir = '', verbose = 1) - sys.stdout = StringIO.StringIO() - sys.stderr = StringIO.StringIO() + sys.stdout = io.StringIO() + sys.stderr = io.StringIO() test.run(arguments = ['arg1 arg2']) o = sys.stdout.getvalue() @@ -1876,8 +1876,8 @@ class run_verbose_TestCase(TestCmdTestCase): workdir = '', verbose = 1) - sys.stdout = StringIO.StringIO() - sys.stderr = StringIO.StringIO() + sys.stdout = io.StringIO() + sys.stderr = io.StringIO() testx.run(arguments = ['arg1 arg2']) expect = '"%s" "arg1 arg2"\n' % t.scriptx_path @@ -1913,8 +1913,8 @@ class run_verbose_TestCase(TestCmdTestCase): workdir = '', verbose = 2) - sys.stdout = StringIO.StringIO() - sys.stderr = StringIO.StringIO() + sys.stdout = io.StringIO() + sys.stderr = io.StringIO() test.run(arguments = ['arg1 arg2']) @@ -1934,8 +1934,8 @@ class run_verbose_TestCase(TestCmdTestCase): workdir = '', verbose = 2) - sys.stdout = StringIO.StringIO() - sys.stderr = StringIO.StringIO() + sys.stdout = io.StringIO() + sys.stderr = io.StringIO() testx.run(arguments = ['arg1 arg2']) @@ -1958,8 +1958,8 @@ class run_verbose_TestCase(TestCmdTestCase): workdir = '', verbose = 2) - sys.stdout = StringIO.StringIO() - sys.stderr = StringIO.StringIO() + sys.stdout = io.StringIO() + sys.stderr = io.StringIO() test.run(arguments = ['arg1 arg2']) @@ -1978,8 +1978,8 @@ class run_verbose_TestCase(TestCmdTestCase): workdir = '', verbose = 3) - sys.stdout = StringIO.StringIO() - sys.stderr = StringIO.StringIO() + sys.stdout = io.StringIO() + sys.stderr = io.StringIO() test.run(arguments = ['arg1 arg2']) @@ -2002,8 +2002,8 @@ class run_verbose_TestCase(TestCmdTestCase): interpreter = 'python', workdir = '') - sys.stdout = StringIO.StringIO() - sys.stderr = StringIO.StringIO() + sys.stdout = io.StringIO() + sys.stderr = io.StringIO() test.run(arguments = ['arg1 arg2']) @@ -2022,8 +2022,8 @@ class run_verbose_TestCase(TestCmdTestCase): testx = TestCmd.TestCmd(program = t.scriptx, workdir = '') - sys.stdout = StringIO.StringIO() - sys.stderr = StringIO.StringIO() + sys.stdout = io.StringIO() + sys.stderr = io.StringIO() testx.run(arguments = ['arg1 arg2']) @@ -2048,8 +2048,8 @@ class run_verbose_TestCase(TestCmdTestCase): workdir = '', verbose = 1) - sys.stdout = StringIO.StringIO() - sys.stderr = StringIO.StringIO() + sys.stdout = io.StringIO() + sys.stderr = io.StringIO() test.run(arguments = ['arg1 arg2']) o = sys.stdout.getvalue() @@ -2062,8 +2062,8 @@ class run_verbose_TestCase(TestCmdTestCase): workdir = '', verbose = 1) - sys.stdout = StringIO.StringIO() - sys.stderr = StringIO.StringIO() + sys.stdout = io.StringIO() + sys.stderr = io.StringIO() testx.run(arguments = ['arg1 arg2']) expect = '"%s" "arg1 arg2"\n' % t.scriptx_path @@ -2347,7 +2347,7 @@ while 1: logfp.close() """ % t.recv_out_path t.run_env.write(t.recv_script_path, text) - os.chmod(t.recv_script_path, 0644) # XXX UNIX-specific + os.chmod(t.recv_script_path, 0o644) # XXX UNIX-specific return t def test_start(self): @@ -2765,11 +2765,11 @@ class subdir_TestCase(TestCmdTestCase): assert test.subdir('bar') == 1 assert test.subdir(['foo', 'succeed']) == 1 if os.name != "nt": - os.chmod(test.workpath('foo'), 0500) + os.chmod(test.workpath('foo'), 0o500) assert test.subdir(['foo', 'fail']) == 0 assert test.subdir(['sub', 'dir', 'ectory'], 'sub') == 1 assert test.subdir('one', - UserList.UserList(['one', 'two']), + collections.UserList(['one', 'two']), ['one', 'two', 'three']) == 3 assert os.path.isdir(test.workpath('foo')) assert os.path.isdir(test.workpath('bar')) @@ -2962,7 +2962,7 @@ class unlink_TestCase(TestCmdTestCase): test.unlink(['foo', 'file3a']) assert not os.path.exists(wdir_foo_file3a) - test.unlink(UserList.UserList(['foo', 'file3b'])) + test.unlink(collections.UserList(['foo', 'file3b'])) assert not os.path.exists(wdir_foo_file3b) test.unlink([test.workdir, 'foo', 'file4']) @@ -2971,8 +2971,8 @@ class unlink_TestCase(TestCmdTestCase): # Make it so we can't unlink file5. # For UNIX, remove write permission from the dir and the file. # For Windows, open the file. - os.chmod(test.workdir, 0500) - os.chmod(wdir_file5, 0400) + os.chmod(test.workdir, 0o500) + os.chmod(wdir_file5, 0o400) f = open(wdir_file5, 'r') try: @@ -2983,8 +2983,8 @@ class unlink_TestCase(TestCmdTestCase): except: raise finally: - os.chmod(test.workdir, 0700) - os.chmod(wdir_file5, 0600) + os.chmod(test.workdir, 0o700) + os.chmod(wdir_file5, 0o600) f.close() @@ -3208,11 +3208,11 @@ class executable_TestCase(TestCmdTestCase): def make_executable(fname): st = os.stat(fname) - os.chmod(fname, stat.S_IMODE(st[stat.ST_MODE]|0100)) + os.chmod(fname, stat.S_IMODE(st[stat.ST_MODE]|0o100)) def make_non_executable(fname): st = os.stat(fname) - os.chmod(fname, stat.S_IMODE(st[stat.ST_MODE]&~0100)) + os.chmod(fname, stat.S_IMODE(st[stat.ST_MODE]&~0o100)) test.executable(test.workdir, 0) # XXX skip these tests if euid == 0? @@ -3282,7 +3282,7 @@ class write_TestCase(TestCmdTestCase): test.write('file9', "Test file #9.\r\n", mode = 'wb') if os.name != "nt": - os.chmod(test.workdir, 0500) + os.chmod(test.workdir, 0o500) try: test.write('file10', "Test file #10 (should not get created).\n") except IOError: # expect "Permission denied" diff --git a/QMTest/TestCommon.py b/QMTest/TestCommon.py index 4e90e16..5a397ff 100644 --- a/QMTest/TestCommon.py +++ b/QMTest/TestCommon.py @@ -281,9 +281,9 @@ class TestCommon(TestCmd): existing, missing = separate_files(files) unwritable = [x for x in existing if not is_writable(x)] if missing: - print "Missing files: `%s'" % "', `".join(missing) + print("Missing files: `%s'" % "', `".join(missing)) if unwritable: - print "Unwritable files: `%s'" % "', `".join(unwritable) + print("Unwritable files: `%s'" % "', `".join(unwritable)) self.fail_test(missing + unwritable) def must_contain(self, file, required, mode = 'rb', find = None): @@ -298,11 +298,11 @@ class TestCommon(TestCmd): return None contains = find(file_contents, required) if not contains: - print "File `%s' does not contain required string." % file - print self.banner('Required string ') - print required - print self.banner('%s contents ' % file) - print file_contents + print("File `%s' does not contain required string." % file) + print(self.banner('Required string ')) + print(required) + print(self.banner('%s contents ' % file)) + print(file_contents) self.fail_test(not contains) def must_contain_all_lines(self, output, lines, title=None, find=None): @@ -437,7 +437,7 @@ class TestCommon(TestCmd): files = [is_List(x) and os.path.join(*x) or x for x in files] missing = [x for x in files if not os.path.exists(x) and not os.path.islink(x) ] if missing: - print "Missing files: `%s'" % "', `".join(missing) + print("Missing files: `%s'" % "', `".join(missing)) self.fail_test(missing) def must_exist_one_of(self, files): @@ -457,7 +457,7 @@ class TestCommon(TestCmd): if glob.glob(xpath): return missing.append(xpath) - print "Missing one of: `%s'" % "', `".join(missing) + print("Missing one of: `%s'" % "', `".join(missing)) self.fail_test(missing) def must_match(self, file, expect, mode = 'rb', match=None): @@ -474,7 +474,7 @@ class TestCommon(TestCmd): except KeyboardInterrupt: raise except: - print "Unexpected contents of `%s'" % file + print("Unexpected contents of `%s'" % file) self.diff(expect, file_contents, 'contents ') raise @@ -490,11 +490,11 @@ class TestCommon(TestCmd): return None contains = find(file_contents, banned) if contains: - print "File `%s' contains banned string." % file - print self.banner('Banned string ') - print banned - print self.banner('%s contents ' % file) - print file_contents + print("File `%s' contains banned string." % file) + print(self.banner('Banned string ')) + print(banned) + print(self.banner('%s contents ' % file)) + print(file_contents) self.fail_test(contains) def must_not_contain_any_line(self, output, lines, title=None, find=None): @@ -541,7 +541,7 @@ class TestCommon(TestCmd): files = [is_List(x) and os.path.join(*x) or x for x in files] existing = [x for x in files if os.path.exists(x) or os.path.islink(x)] if existing: - print "Unexpected files exist: `%s'" % "', `".join(existing) + print("Unexpected files exist: `%s'" % "', `".join(existing)) self.fail_test(existing) def must_not_exist_any_of(self, files): @@ -561,7 +561,7 @@ class TestCommon(TestCmd): if glob.glob(xpath): existing.append(xpath) if existing: - print "Unexpected files exist: `%s'" % "', `".join(existing) + print("Unexpected files exist: `%s'" % "', `".join(existing)) self.fail_test(existing) def must_not_be_writable(self, *files): @@ -575,9 +575,9 @@ class TestCommon(TestCmd): existing, missing = separate_files(files) writable = list(filter(is_writable, existing)) if missing: - print "Missing files: `%s'" % "', `".join(missing) + print("Missing files: `%s'" % "', `".join(missing)) if writable: - print "Writable files: `%s'" % "', `".join(writable) + print("Writable files: `%s'" % "', `".join(writable)) self.fail_test(missing + writable) def _complete(self, actual_stdout, expected_stdout, @@ -590,23 +590,23 @@ class TestCommon(TestCmd): expect = '' if status != 0: expect = " (expected %s)" % str(status) - print "%s returned %s%s" % (self.program, _status(self), expect) - print self.banner('STDOUT ') - print actual_stdout - print self.banner('STDERR ') - print actual_stderr + print("%s returned %s%s" % (self.program, _status(self), expect)) + print(self.banner('STDOUT ')) + print(actual_stdout) + print(self.banner('STDERR ')) + print(actual_stderr) self.fail_test() if (expected_stdout is not None and not match(actual_stdout, expected_stdout)): self.diff(expected_stdout, actual_stdout, 'STDOUT ') if actual_stderr: - print self.banner('STDERR ') - print actual_stderr + print(self.banner('STDERR ')) + print(actual_stderr) self.fail_test() if (expected_stderr is not None and not match(actual_stderr, expected_stderr)): - print self.banner('STDOUT ') - print actual_stdout + print(self.banner('STDOUT ')) + print(actual_stdout) self.diff(expected_stderr, actual_stderr, 'STDERR ') self.fail_test() @@ -626,15 +626,15 @@ class TestCommon(TestCmd): universal_newlines, **kw) except KeyboardInterrupt: raise - except Exception, e: - print self.banner('STDOUT ') + except Exception as e: + print(self.banner('STDOUT ')) try: - print self.stdout() + print(self.stdout()) except IndexError: pass - print self.banner('STDERR ') + print(self.banner('STDERR ')) try: - print self.stderr() + print(self.stderr()) except IndexError: pass cmd_args = self.command_args(program, interpreter, arguments) diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index 84cc60f..72624e6 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -13,7 +13,7 @@ attributes defined in this subclass. """ # __COPYRIGHT__ -from __future__ import division + __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -356,7 +356,7 @@ class TestSCons(TestCommon): # raised so as to not mask possibly serious disk or # network issues. continue - if stat.S_IMODE(st[stat.ST_MODE]) & 0111: + if stat.S_IMODE(st[stat.ST_MODE]) & 0o111: return os.path.normpath(f) else: import SCons.Environment @@ -503,9 +503,9 @@ class TestSCons(TestCommon): self.pass_test() else: # test failed; have to do this by hand... - print self.banner('STDOUT ') - print self.stdout() - print self.diff(warning, stderr, 'STDERR ') + print(self.banner('STDOUT ')) + print(self.stdout()) + print(self.diff(warning, stderr, 'STDERR ')) self.fail_test() return warning @@ -574,7 +574,7 @@ class TestSCons(TestCommon): We stick the requested file name and line number in the right places, abstracting out the version difference. """ - exec 'import traceback; x = traceback.format_stack()[-1]' + exec('import traceback; x = traceback.format_stack()[-1]') x = x.lstrip() x = x.replace('', file) x = x.replace('line 1,', 'line %s,' % line) @@ -721,7 +721,7 @@ class TestSCons(TestCommon): home = os.path.normpath('%s/..'%jar) if os.path.isdir(home): return home - print("Could not determine JAVA_HOME: %s is not a directory" % home) + print(("Could not determine JAVA_HOME: %s is not a directory" % home)) self.fail_test() def java_where_jar(self, version=None): @@ -1087,27 +1087,27 @@ SConscript( sconscript ) if doCheckLog and lastEnd != len(logfile): raise NoMatch(lastEnd) - except NoMatch, m: - print "Cannot match log file against log regexp." - print "log file: " - print "------------------------------------------------------" - print logfile[m.pos:] - print "------------------------------------------------------" - print "log regexp: " - print "------------------------------------------------------" - print log - print "------------------------------------------------------" + except NoMatch as m: + print("Cannot match log file against log regexp.") + print("log file: ") + print("------------------------------------------------------") + print(logfile[m.pos:]) + print("------------------------------------------------------") + print("log regexp: ") + print("------------------------------------------------------") + print(log) + print("------------------------------------------------------") self.fail_test() if doCheckStdout: exp_stdout = self.wrap_stdout(".*", rdstr) if not self.match_re_dotall(self.stdout(), exp_stdout): - print "Unexpected stdout: " - print "-----------------------------------------------------" - print repr(self.stdout()) - print "-----------------------------------------------------" - print repr(exp_stdout) - print "-----------------------------------------------------" + print("Unexpected stdout: ") + print("-----------------------------------------------------") + print(repr(self.stdout())) + print("-----------------------------------------------------") + print(repr(exp_stdout)) + print("-----------------------------------------------------") self.fail_test() def get_python_version(self): @@ -1241,7 +1241,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) @@ -1297,7 +1297,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: @@ -1323,7 +1323,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/TestSConsMSVS.py b/QMTest/TestSConsMSVS.py index c78b452..478438a 100644 --- a/QMTest/TestSConsMSVS.py +++ b/QMTest/TestSConsMSVS.py @@ -1039,7 +1039,7 @@ print "self._msvs_versions =", str(SCons.Tool.MSCommon.query_versions()) try: host = _ARCH_TO_CANONICAL[host_platform] - except KeyError, e: + except KeyError as e: # Default to x86 for all other platforms host = 'x86' diff --git a/QMTest/TestSCons_time.py b/QMTest/TestSCons_time.py index abe8ccf..ba7fbd8 100644 --- a/QMTest/TestSCons_time.py +++ b/QMTest/TestSCons_time.py @@ -225,7 +225,7 @@ class TestSCons_time(TestCommon): def write_fake_aegis_py(self, name): name = self.workpath(name) self.write(name, aegis_py) - os.chmod(name, 0755) + os.chmod(name, 0o755) return name def write_fake_scons_py(self): @@ -235,7 +235,7 @@ class TestSCons_time(TestCommon): def write_fake_svn_py(self, name): name = self.workpath(name) self.write(name, svn_py) - os.chmod(name, 0755) + os.chmod(name, 0o755) return name def write_sample_directory(self, archive, dir, files): diff --git a/QMTest/TestSConsign.py b/QMTest/TestSConsign.py index 700c242..665059c 100644 --- a/QMTest/TestSConsign.py +++ b/QMTest/TestSConsign.py @@ -68,7 +68,7 @@ class TestSConsign(TestSCons): elif os.path.exists(self.script_path('sconsign')): sconsign = 'sconsign' else: - print "Can find neither 'sconsign.py' nor 'sconsign' scripts." + print("Can find neither 'sconsign.py' nor 'sconsign' scripts.") self.no_result() self.set_sconsign(sconsign) diff --git a/QMTest/scons_tdb.py b/QMTest/scons_tdb.py index 6be4696..845e99c 100644 --- a/QMTest/scons_tdb.py +++ b/QMTest/scons_tdb.py @@ -20,7 +20,7 @@ # 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. -from __future__ import division + """ QMTest classes to support SCons' testing and Aegis-inspired workflow. @@ -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 @@ -337,14 +337,14 @@ class AegisChangeStream(AegisStream): # We'd like to use the _FormatStatistics() method to do # this, but it's wrapped around the list in Result.outcomes, # so it's simpler to just do it ourselves. - print " %6d tests total\n" % self._num_tests + print(" %6d tests total\n" % self._num_tests) for outcome in AegisTest.aegis_outcomes: if self._outcome_counts[outcome] != 0: - print " %6d (%3.0f%%) tests %s" % ( + print(" %6d (%3.0f%%) tests %s" % ( self._outcome_counts[outcome], self._percent(outcome), outcome - ) + )) class AegisBaselineStream(AegisStream): def WriteResult(self, result): @@ -368,19 +368,19 @@ class AegisBaselineStream(AegisStream): # this, but it's wrapped around the list in Result.outcomes, # so it's simpler to just do it ourselves. if self._outcome_counts[AegisTest.FAIL]: - print " %6d (%3.0f%%) tests as expected" % ( + print(" %6d (%3.0f%%) tests as expected" % ( self._outcome_counts[AegisTest.FAIL], self._percent(AegisTest.FAIL), - ) + )) non_fail_outcomes = list(AegisTest.aegis_outcomes[:]) non_fail_outcomes.remove(AegisTest.FAIL) for outcome in non_fail_outcomes: if self._outcome_counts[outcome] != 0: - print " %6d (%3.0f%%) tests unexpected %s" % ( + print(" %6d (%3.0f%%) tests unexpected %s" % ( self._outcome_counts[outcome], self._percent(outcome), outcome, - ) + )) class AegisBatchStream(FileResultStream): def __init__(self, arguments): diff --git a/bench/bench.py b/bench/bench.py index 74dbf12..1a98d8c 100644 --- a/bench/bench.py +++ b/bench/bench.py @@ -23,7 +23,7 @@ # # This will allow (as much as possible) us to time just the code itself, # not Python function call overhead. -from __future__ import division + import getopt import sys @@ -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)] @@ -113,12 +113,12 @@ def display(label, results): total = 0.0 for r in results: total += r - print " %8.3f" % ((total * 1e6) / len(results)), ':', label + print(" %8.3f" % ((total * 1e6) / len(results)), ':', label) for func in FunctionList: if func.__doc__: d = ' (' + func.__doc__ + ')' else: d = '' - print func.__name__ + d + ':' + print(func.__name__ + d + ':') for label, args, kw in Data: r = timer(func, *args, **kw) diff --git a/bench/env.__setitem__.py b/bench/env.__setitem__.py index b17b59e..284653e 100644 --- a/bench/env.__setitem__.py +++ b/bench/env.__setitem__.py @@ -33,15 +33,15 @@ class Timing(object): def times(num=1000000, init='', title='Results:', **statements): # time each statement timings = [] - for n, s in statements.items(): + for n, s in list(statements.items()): t = Timing(n, num, init, s) t.timeit() timings.append(t) - print - print title + print() + print(title) for i in sorted([(i.getResult(),i.name) for i in timings]): - print " %9.3f s %s" % i + print(" %9.3f s %s" % i) # Import the necessary local SCons.* modules used by some of our # alternative implementations below, first manipulating sys.path so @@ -287,7 +287,7 @@ else: # that the timer will use to get at these classes. class_names = [] -for n in locals().keys(): +for n in list(locals().keys()): #if n.startswith('env_'): if n[:4] == 'env_': class_names.append(n) @@ -339,9 +339,9 @@ def run_it(title, init): s['init'] = init times(**s) -print 'Environment __setitem__ benchmark using', -print 'Python', sys.version.split()[0], -print 'on', sys.platform, os.name +print('Environment __setitem__ benchmark using', end=' ') +print('Python', sys.version.split()[0], end=' ') +print('on', sys.platform, os.name) run_it('Results for re-adding an existing variable name 100 times:', common_imports + """ diff --git a/bench/is_types.py b/bench/is_types.py index 69c029f..b6da0d2 100644 --- a/bench/is_types.py +++ b/bench/is_types.py @@ -17,11 +17,11 @@ InstanceType = types.InstanceType DictType = dict ListType = list StringType = str -try: unicode +try: str except NameError: UnicodeType = None else: - UnicodeType = unicode + UnicodeType = str # The original implementations, pretty straightforward checks for the @@ -36,7 +36,7 @@ def original_is_List(e): if UnicodeType is not None: def original_is_String(e): - return isinstance(e, (str,unicode,UserString)) + return isinstance(e, (str,UserString)) else: def original_is_String(e): return isinstance(e, (str,UserString)) @@ -58,7 +58,7 @@ def checkInstanceType_is_List(e): if UnicodeType is not None: def checkInstanceType_is_String(e): return isinstance(e, str) \ - or isinstance(e, unicode) \ + or isinstance(e, str) \ or (isinstance(e, types.InstanceType) and isinstance(e, UserString)) else: def checkInstanceType_is_String(e): @@ -84,7 +84,7 @@ if UnicodeType is not None: def cache_type_e_is_String(e): t = type(e) return t is str \ - or t is unicode \ + or t is str \ or (t is types.InstanceType and isinstance(e, UserString)) else: def cache_type_e_is_String(e): @@ -136,7 +136,7 @@ if UnicodeType is not None: t = type(obj) if t is types.InstanceType: t = instanceTypeMap.get(obj.__class__, t) - elif t is unicode: + elif t is str: t = str return t else: diff --git a/bench/timeit.py b/bench/timeit.py index c5fef12..2840010 100644 --- a/bench/timeit.py +++ b/bench/timeit.py @@ -46,7 +46,7 @@ be aware of it. The baseline overhead can be measured by invoking the program without arguments. The baseline overhead differs between Python versions! """ -from __future__ import division + try: import gc @@ -122,7 +122,7 @@ class Timer(object): self.src = src # Save for traceback display code = compile(src, dummy_src_name, "exec") ns = {} - exec code in globals(), ns + exec(code, globals(), ns) self.inner = ns["inner"] def print_exc(self, file=None): @@ -216,9 +216,9 @@ def main(args=None): opts, args = getopt.getopt(args, "n:s:r:tcvh", ["number=", "setup=", "repeat=", "time", "clock", "verbose", "help"]) - except getopt.error, err: - print err - print "use -h/--help for command line help" + except getopt.error as err: + print(err) + print("use -h/--help for command line help") return 2 timer = default_timer stmt = "\n".join(args) or "pass" @@ -245,7 +245,7 @@ def main(args=None): precision = precision + 1 verbose = precision + 1 if o in ("-h", "--help"): - print __doc__, + print(__doc__, end=' ') return 0 setup = "\n".join(setup) or "pass" # Include the current directory, so that local imports work (sys.path @@ -264,7 +264,7 @@ def main(args=None): t.print_exc() return 1 if verbose: - print "%d loops -> %.*g secs" % (number, precision, x) + print("%d loops -> %.*g secs" % (number, precision, x)) if x >= 0.2: break try: @@ -274,18 +274,18 @@ def main(args=None): return 1 best = min(r) if verbose: - print "raw times:", ' '.join(["%.*g" % (precision, x) for x in r]) - print "%d loops," % number, + print("raw times:", ' '.join(["%.*g" % (precision, x) for x in r])) + print("%d loops," % number, end=' ') usec = best * 1e6 / number if usec < 1000: - print "best of %d: %.*g usec per loop" % (repeat, precision, usec) + print("best of %d: %.*g usec per loop" % (repeat, precision, usec)) else: msec = usec / 1000 if msec < 1000: - print "best of %d: %.*g msec per loop" % (repeat, precision, msec) + print("best of %d: %.*g msec per loop" % (repeat, precision, msec)) else: sec = msec / 1000 - print "best of %d: %.*g sec per loop" % (repeat, precision, sec) + print("best of %d: %.*g sec per loop" % (repeat, precision, sec)) return None if __name__ == "__main__": diff --git a/bin/Command.py b/bin/Command.py index 8702f51..768caed 100644 --- a/bin/Command.py +++ b/bin/Command.py @@ -109,18 +109,18 @@ Usage: script-template.py [-hnq] try: try: opts, args = getopt.getopt(argv[1:], short_options, long_options) - except getopt.error, msg: + except getopt.error as msg: raise Usage(msg) for o, a in opts: if o in ('-h', '--help'): - print helpstr + print(helpstr) sys.exit(0) elif o in ('-n', '--no-exec'): Command.execute = Command.do_not_execute elif o in ('-q', '--quiet'): Command.display = Command.do_not_display - except Usage, err: + except Usage as err: sys.stderr.write(err.msg) sys.stderr.write('use -h to get help') return 2 diff --git a/bin/SConsDoc.py b/bin/SConsDoc.py index dc9d161..453e241 100644 --- a/bin/SConsDoc.py +++ b/bin/SConsDoc.py @@ -210,12 +210,12 @@ class Libxml2ValidityHandler: def error(self, msg, data): if data != ARG: - raise Exception, "Error handler did not receive correct argument" + raise Exception("Error handler did not receive correct argument") self.errors.append(msg) def warning(self, msg, data): if data != ARG: - raise Exception, "Warning handler did not receive correct argument" + raise Exception("Warning handler did not receive correct argument") self.warnings.append(msg) @@ -332,16 +332,16 @@ if not has_libxml2: xmlschema = etree.XMLSchema(xmlschema_context) try: doc = etree.parse(fpath) - except Exception, e: - print "ERROR: %s fails to parse:"%fpath - print e + except Exception as e: + print("ERROR: %s fails to parse:"%fpath) + print(e) return False doc.xinclude() try: xmlschema.assertValid(doc) - except Exception, e: - print "ERROR: %s fails to validate:" % fpath - print e + except Exception as e: + print("ERROR: %s fails to validate:" % fpath) + print(e) return False return True @@ -477,8 +477,8 @@ else: if err or eh.errors: for e in eh.errors: - print e.rstrip("\n") - print "%s fails to validate" % fpath + print(e.rstrip("\n")) + print("%s fails to validate" % fpath) return False return True @@ -599,7 +599,7 @@ class SConsDocTree: # Create xpath context self.xpath_context = self.doc.xpathNewContext() # Register namespaces - for key, val in self.nsmap.iteritems(): + for key, val in self.nsmap.items(): self.xpath_context.xpathRegisterNs(key, val) def __del__(self): @@ -637,8 +637,8 @@ def validate_all_xml(dpaths, xsdfile=default_xsd): fails = [] for idx, fp in enumerate(fpaths): fpath = os.path.join(path, fp) - print "%.2f%s (%d/%d) %s" % (float(idx+1)*100.0/float(len(fpaths)), - perc, idx+1, len(fpaths),fp) + print("%.2f%s (%d/%d) %s" % (float(idx+1)*100.0/float(len(fpaths)), + perc, idx+1, len(fpaths),fp)) if not tf.validateXml(fp, xmlschema_context): fails.append(fp) @@ -810,7 +810,7 @@ def importfile(path): file = open(path, 'r') try: module = imp.load_module(name, file, path, (ext, 'r', kind)) - except ImportError, e: + except ImportError as e: sys.stderr.write("Could not import %s: %s\n" % (path, e)) return None file.close() diff --git a/bin/SConsExamples.py b/bin/SConsExamples.py index 9823a05..e3a7502 100644 --- a/bin/SConsExamples.py +++ b/bin/SConsExamples.py @@ -265,7 +265,7 @@ def ensureExampleOutputsExist(dpath): os.mkdir(generated_examples) examples = readAllExampleInfos(dpath) - for key, value in examples.iteritems(): + for key, value in examples.items(): # Process all scons_output tags for o in value.outputs: cpath = os.path.join(generated_examples, @@ -303,10 +303,10 @@ def createAllExampleOutputs(dpath): examples = readAllExampleInfos(dpath) total = len(examples) idx = 0 - for key, value in examples.iteritems(): + for key, value in examples.items(): # Process all scons_output tags - print "%.2f%s (%d/%d) %s" % (float(idx + 1) * 100.0 / float(total), - perc, idx + 1, total, key) + print("%.2f%s (%d/%d) %s" % (float(idx + 1) * 100.0 / float(total), + perc, idx + 1, total, key)) create_scons_output(value) # Process all scons_example_file tags @@ -344,7 +344,7 @@ def collectSConsExampleNames(fpath): if n not in suffixes: suffixes[n] = [] else: - print "Error: Example in file '%s' is missing a name!" % fpath + print("Error: Example in file '%s' is missing a name!" % fpath) failed_suffixes = True for o in stf.findAll(t.root, "scons_output", SConsDoc.dbxid, @@ -353,11 +353,11 @@ def collectSConsExampleNames(fpath): if stf.hasAttribute(o, 'example'): n = stf.getAttribute(o, 'example') else: - print "Error: scons_output in file '%s' is missing an example name!" % fpath + print("Error: scons_output in file '%s' is missing an example name!" % fpath) failed_suffixes = True if n not in suffixes: - print "Error: scons_output in file '%s' is referencing non-existent example '%s'!" % (fpath, n) + print("Error: scons_output in file '%s' is referencing non-existent example '%s'!" % (fpath, n)) failed_suffixes = True continue @@ -365,13 +365,13 @@ def collectSConsExampleNames(fpath): if stf.hasAttribute(o, 'suffix'): s = stf.getAttribute(o, 'suffix') else: - print "Error: scons_output in file '%s' (example '%s') is missing a suffix!" % (fpath, n) + print("Error: scons_output in file '%s' (example '%s') is missing a suffix!" % (fpath, n)) failed_suffixes = True if s not in suffixes[n]: suffixes[n].append(s) else: - print "Error: scons_output in file '%s' (example '%s') is using a duplicate suffix '%s'!" % (fpath, n, s) + print("Error: scons_output in file '%s' (example '%s') is using a duplicate suffix '%s'!" % (fpath, n, s)) failed_suffixes = True return names, failed_suffixes @@ -392,7 +392,7 @@ def exampleNamesAreUnique(dpath): unique = False i = allnames.intersection(names) if i: - print "Not unique in %s are: %s" % (fpath, ', '.join(i)) + print("Not unique in %s are: %s" % (fpath, ', '.join(i))) unique = False allnames |= names diff --git a/bin/calibrate.py b/bin/calibrate.py index 8ed2ece..31c04e8 100644 --- a/bin/calibrate.py +++ b/bin/calibrate.py @@ -20,7 +20,7 @@ # 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. -from __future__ import division + import optparse import os @@ -48,7 +48,7 @@ def main(argv=None): for arg in args: if len(args) > 1: - print arg + ':' + print(arg + ':') command = [sys.executable, 'runtest.py'] if opts.package: @@ -67,9 +67,9 @@ def main(argv=None): try: elapsed = float(em.group(1)) except AttributeError: - print output + print(output) raise - print "run %3d: %7.3f: %s" % (run, elapsed, ' '.join(vm.groups())) + print("run %3d: %7.3f: %s" % (run, elapsed, ' '.join(vm.groups()))) if opts.min < elapsed and elapsed < opts.max: good += 1 else: diff --git a/bin/caller-tree.py b/bin/caller-tree.py index 03c1616..327e6a1 100644 --- a/bin/caller-tree.py +++ b/bin/caller-tree.py @@ -74,19 +74,19 @@ for line in sys.stdin.readlines(): stack = [] def print_entry(e, level, calls): - print '%-72s%6s' % ((' '*2*level) + e.file_line_func, calls) + print('%-72s%6s' % ((' '*2*level) + e.file_line_func, calls)) if e in stack: - print (' '*2*(level+1))+'RECURSION' - print + print((' '*2*(level+1))+'RECURSION') + print() elif e.called_by: stack.append(e) for c in e.called_by: print_entry(c[0], level+1, c[1]) stack.pop() else: - print + 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/docs-create-example-outputs.py b/bin/docs-create-example-outputs.py index 30dc0ee..b2dfbea 100644 --- a/bin/docs-create-example-outputs.py +++ b/bin/docs-create-example-outputs.py @@ -9,11 +9,11 @@ import sys import SConsExamples if __name__ == "__main__": - print "Checking whether all example names are unique..." + print("Checking whether all example names are unique...") if SConsExamples.exampleNamesAreUnique(os.path.join('doc','user')): - print "OK" + print("OK") else: - print "Not all example names and suffixes are unique! Please correct the errors listed above and try again." + print("Not all example names and suffixes are unique! Please correct the errors listed above and try again.") sys.exit(0) SConsExamples.createAllExampleOutputs(os.path.join('doc','user')) diff --git a/bin/docs-update-generated.py b/bin/docs-update-generated.py index 66b22c0..2b419a4 100644 --- a/bin/docs-update-generated.py +++ b/bin/docs-update-generated.py @@ -38,7 +38,7 @@ def generate_all(): try: os.makedirs(gen_folder) except: - print "Couldn't create destination folder %s! Exiting..." % gen_folder + print("Couldn't create destination folder %s! Exiting..." % gen_folder) return # Call scons-proc.py os.system('python %s -b %s -f %s -t %s -v %s %s' % diff --git a/bin/docs-validate.py b/bin/docs-validate.py index c445c3f..e5d0659 100644 --- a/bin/docs-validate.py +++ b/bin/docs-validate.py @@ -10,9 +10,9 @@ import SConsDoc if __name__ == "__main__": if len(sys.argv)>1: if SConsDoc.validate_all_xml((sys.argv[1],)): - print "OK" + print("OK") else: - print "Validation failed! Please correct the errors above and try again." + print("Validation failed! Please correct the errors above and try again.") else: if SConsDoc.validate_all_xml(['src', os.path.join('doc','design'), @@ -22,6 +22,6 @@ if __name__ == "__main__": os.path.join('doc','reference'), os.path.join('doc','user') ]): - print "OK" + print("OK") else: - print "Validation failed! Please correct the errors above and try again." + print("Validation failed! Please correct the errors above and try again.") diff --git a/bin/install_python.py b/bin/install_python.py index 86807af..dca37d0 100644 --- a/bin/install_python.py +++ b/bin/install_python.py @@ -48,7 +48,7 @@ Usage: install_python.py [-ahnq] [-d DIR] [-p PREFIX] [VERSION ...] try: try: opts, args = getopt.getopt(argv[1:], short_options, long_options) - except getopt.error, msg: + except getopt.error as msg: raise Usage(msg) for o, a in opts: @@ -57,7 +57,7 @@ Usage: install_python.py [-ahnq] [-d DIR] [-p PREFIX] [VERSION ...] elif o in ('-d', '--downloads'): downloads_dir = a elif o in ('-h', '--help'): - print helpstr + print(helpstr) sys.exit(0) elif o in ('-n', '--no-exec'): CommandRunner.execute = CommandRunner.do_not_execute @@ -65,7 +65,7 @@ Usage: install_python.py [-ahnq] [-d DIR] [-p PREFIX] [VERSION ...] prefix = a elif o in ('-q', '--quiet'): CommandRunner.display = CommandRunner.do_not_display - except Usage, err: + except Usage as err: sys.stderr.write(str(err.msg) + '\n') sys.stderr.write('use -h to get help\n') return 2 diff --git a/bin/install_scons.py b/bin/install_scons.py index 00129f6..b732193 100644 --- a/bin/install_scons.py +++ b/bin/install_scons.py @@ -23,7 +23,7 @@ import os import shutil import sys import tarfile -import urllib +import urllib.request, urllib.parse, urllib.error from Command import CommandRunner, Usage @@ -129,7 +129,7 @@ Usage: install_scons.py [-ahnq] [-d DIR] [-p PREFIX] [VERSION ...] try: try: opts, args = getopt.getopt(argv[1:], short_options, long_options) - except getopt.error, msg: + except getopt.error as msg: raise Usage(msg) for o, a in opts: @@ -138,7 +138,7 @@ Usage: install_scons.py [-ahnq] [-d DIR] [-p PREFIX] [VERSION ...] elif o in ('-d', '--downloads'): downloads_dir = a elif o in ('-h', '--help'): - print helpstr + print(helpstr) sys.exit(0) elif o in ('-n', '--no-exec'): CommandRunner.execute = CommandRunner.do_not_execute @@ -146,7 +146,7 @@ Usage: install_scons.py [-ahnq] [-d DIR] [-p PREFIX] [VERSION ...] prefix = a elif o in ('-q', '--quiet'): CommandRunner.display = CommandRunner.do_not_display - except Usage, err: + except Usage as err: sys.stderr.write(str(err.msg) + '\n') sys.stderr.write('use -h to get help\n') return 2 @@ -171,7 +171,7 @@ Usage: install_scons.py [-ahnq] [-d DIR] [-p PREFIX] [VERSION ...] if not os.path.exists(tar_gz): if not os.path.exists(downloads_dir): cmd.run('mkdir %(downloads_dir)s') - cmd.run((urllib.urlretrieve, tar_gz_url, tar_gz), + cmd.run((urllib.request.urlretrieve, tar_gz_url, tar_gz), 'wget -O %(tar_gz)s %(tar_gz_url)s') def extract(tar_gz): diff --git a/bin/linecount.py b/bin/linecount.py index 6f49dca..2d478f0 100644 --- a/bin/linecount.py +++ b/bin/linecount.py @@ -21,7 +21,7 @@ # in each category, the number of non-blank lines, and the number of # non-comment lines. The last figure (non-comment) lines is the most # interesting one for most purposes. -from __future__ import division + __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -98,23 +98,23 @@ all_tests = Collection('all tests', src_tests.files + test_tests.files) def ratio(over, under): return "%.2f" % (float(len(over)) / float(len(under))) -print fmt % ('', '', '', '', '', 'non-blank') -print fmt % ('', 'files', 'lines', 'non-blank', 'non-comment', 'non-comment') -print -print fmt % src_Tests_py_tests.printables() -print fmt % src_test_tests.printables() -print -print fmt % src_tests.printables() -print fmt % test_tests.printables() -print -print fmt % all_tests.printables() -print fmt % sources.printables() -print -print fmt % ('ratio:', +print(fmt % ('', '', '', '', '', 'non-blank')) +print(fmt % ('', 'files', 'lines', 'non-blank', 'non-comment', 'non-comment')) +print() +print(fmt % src_Tests_py_tests.printables()) +print(fmt % src_test_tests.printables()) +print() +print(fmt % src_tests.printables()) +print(fmt % test_tests.printables()) +print() +print(fmt % all_tests.printables()) +print(fmt % sources.printables()) +print() +print(fmt % ('ratio:', ratio(all_tests, sources), ratio(all_tests.lines(), sources.lines()), ratio(all_tests.non_blank(), sources.non_blank()), ratio(all_tests.non_comment(), sources.non_comment()), ratio(all_tests.non_blank_non_comment(), sources.non_blank_non_comment()) - ) + )) diff --git a/bin/memlogs.py b/bin/memlogs.py index 9d957c9..0409dfe 100644 --- a/bin/memlogs.py +++ b/bin/memlogs.py @@ -27,20 +27,20 @@ import sys filenames = sys.argv[1:] if not filenames: - print """Usage: memlogs.py file [...] + print("""Usage: memlogs.py file [...] Summarizes the --debug=memory numbers from one or more build logs. -""" +""") sys.exit(0) fmt = "%12s %12s %12s %12s %s" -print fmt % ("pre-read", "post-read", "pre-build", "post-build", "") +print(fmt % ("pre-read", "post-read", "pre-build", "post-build", "")) for fname in sys.argv[1:]: lines = [l for l in open(fname).readlines() if l[:7] == 'Memory '] t = tuple([l.split()[-1] for l in lines]) + (fname,) - print fmt % t + print(fmt % t) # Local Variables: # tab-width:4 diff --git a/bin/memoicmp.py b/bin/memoicmp.py index 812af66..5021c41 100644 --- a/bin/memoicmp.py +++ b/bin/memoicmp.py @@ -23,20 +23,20 @@ def memoize_cmp(filea, fileb): ma = memoize_output(filea) mb = memoize_output(fileb) - print 'All output: %s / %s [delta]'%(filea, fileb) - print '----------HITS---------- ---------MISSES---------' + print('All output: %s / %s [delta]'%(filea, fileb)) + print('----------HITS---------- ---------MISSES---------') cfmt='%7d/%-7d [%d]' 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: @@ -49,26 +49,26 @@ def memoize_cmp(filea, fileb): for k in mab: hits = cfmt%(ma[k][0], mb[k][0], mb[k][0]-ma[k][0]) miss = cfmt%(ma[k][1], mb[k][1], mb[k][1]-ma[k][1]) - print '%-24s %-24s %s'%(hits, miss, k) + print('%-24s %-24s %s'%(hits, miss, k)) for k in ma_o: hits = '%7d/ --'%(ma[k][0]) miss = '%7d/ --'%(ma[k][1]) - print '%-24s %-24s %s'%(hits, miss, k) + print('%-24s %-24s %s'%(hits, miss, k)) for k in mb_o: hits = ' -- /%-7d'%(mb[k][0]) miss = ' -- /%-7d'%(mb[k][1]) - print '%-24s %-24s %s'%(hits, miss, k) + print('%-24s %-24s %s'%(hits, miss, k)) - print '-'*(24+24+1+20) + print('-'*(24+24+1+20)) if __name__ == "__main__": if len(sys.argv) != 3: - print """Usage: %s file1 file2 + print("""Usage: %s file1 file2 -Compares --debug=memomize output from file1 against file2."""%sys.argv[0] +Compares --debug=memomize output from file1 against file2."""%sys.argv[0]) sys.exit(1) memoize_cmp(sys.argv[1], sys.argv[2]) diff --git a/bin/objcounts.py b/bin/objcounts.py index 0662012..25b985b 100644 --- a/bin/objcounts.py +++ b/bin/objcounts.py @@ -27,10 +27,10 @@ import sys filenames = sys.argv[1:] if len(sys.argv) != 3: - print """Usage: objcounts.py file1 file2 + print("""Usage: objcounts.py file1 file2 Compare the --debug=object counts from two build logs. -""" +""") sys.exit(0) def fetch_counts(fname): @@ -47,7 +47,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: @@ -58,7 +58,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] @@ -81,10 +81,9 @@ def diffstr(c1, c2): return " %5s/%-5s %-8s" % (c1, c2, d) def printline(c1, c2, classname): - print \ - diffstr(c1[2], c2[2]) + \ + print(diffstr(c1[2], c2[2]) + \ diffstr(c1[3], c2[3]) + \ - ' ' + classname + ' ' + classname) for k in sorted(common.keys()): c = common[k] diff --git a/bin/scons-diff.py b/bin/scons-diff.py index 52bd51b..5181fa1 100644 --- a/bin/scons-diff.py +++ b/bin/scons-diff.py @@ -43,7 +43,7 @@ def diff_line(left, right): opts = ' ' + ' '.join(diff_options) else: opts = '' - print 'diff%s %s %s' % (opts, left, right) + print('diff%s %s %s' % (opts, left, right)) for o, a in opts: if o in ('-c', '-u'): @@ -51,7 +51,7 @@ for o, a in opts: context = int(a) diff_options.append(o) elif o in ('-h', '--help'): - print Usage + print(Usage) sys.exit(0) elif o in ('-n'): diff_options.append(o) @@ -161,9 +161,9 @@ def diff_file(left, right): else: if text: diff_line(left, right) - print text, + print(text, end=' ') elif report_same: - print 'Files %s and %s are identical' % (left, right) + print('Files %s and %s are identical' % (left, right)) def diff_dir(left, right): llist = os.listdir(left) @@ -173,16 +173,16 @@ 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), os.path.join(right, x), recursive) else: - print 'Only in %s: %s' % (left, x) + print('Only in %s: %s' % (left, x)) else: - print 'Only in %s: %s' % (right, x) + print('Only in %s: %s' % (right, x)) do_diff(left, right, True) diff --git a/bin/scons-proc.py b/bin/scons-proc.py index 9567db8..19be4c3 100644 --- a/bin/scons-proc.py +++ b/bin/scons-proc.py @@ -106,7 +106,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): @@ -344,25 +344,25 @@ def write_output_files(h, buildersfiles, functionsfiles, processor_class = SCons_XML # Step 1: Creating entity files for builders, functions,... -print "Generating entity files..." +print("Generating entity files...") h = parse_docs(args, False) write_output_files(h, buildersfiles, functionsfiles, toolsfiles, variablesfiles, SCons_XML.write_mod) # Step 2: Validating all input files -print "Validating files against SCons XSD..." +print("Validating files against SCons XSD...") if SConsDoc.validate_all_xml(['src']): - print "OK" + print("OK") else: - print "Validation failed! Please correct the errors above and try again." + print("Validation failed! Please correct the errors above and try again.") # Step 3: Creating actual documentation snippets, using the # fully resolved and updated entities from the *.mod files. -print "Updating documentation for builders, tools and functions..." +print("Updating documentation for builders, tools and functions...") h = parse_docs(args, True) write_output_files(h, buildersfiles, functionsfiles, toolsfiles, variablesfiles, SCons_XML.write) -print "Done" +print("Done") # Local Variables: # tab-width:4 diff --git a/bin/scons-test.py b/bin/scons-test.py index 046cf4b..788fc6d 100644 --- a/bin/scons-test.py +++ b/bin/scons-test.py @@ -60,7 +60,7 @@ for o, a in opts: outdir = a elif o == '-v' or o == '--verbose': def printname(x): - print x + print(x) elif o == '--xml': format = o @@ -148,34 +148,34 @@ else: if format == '--xml': - print "" - print " " + print("") + print(" ") sys_keys = ['byteorder', 'exec_prefix', 'executable', 'maxint', 'maxunicode', 'platform', 'prefix', 'version', 'version_info'] for k in sys_keys: - print " <%s>%s" % (k, sys.__dict__[k], k) - print " " + print(" <%s>%s" % (k, sys.__dict__[k], k)) + print(" ") fmt = '%a %b %d %H:%M:%S %Y' - print " " + print(" ") - print " %s" % tempdir + print(" %s" % tempdir) def print_version_info(tag, module): - print " <%s>" % tag - print " %s" % module.__version__ - print " %s" % module.__build__ - print " %s" % module.__buildsys__ - print " %s" % module.__date__ - print " %s" % module.__developer__ - print " " % tag - - print " " + print(" <%s>" % tag) + print(" %s" % module.__version__) + print(" %s" % module.__build__) + print(" %s" % module.__buildsys__) + print(" %s" % module.__date__) + print(" %s" % module.__developer__) + print(" " % tag) + + print(" ") print_version_info("script", scons) print_version_info("engine", SCons) - print " " + print(" ") environ_keys = [ 'PATH', @@ -213,32 +213,32 @@ if format == '--xml': 'USER', ] - print " " + print(" ") for key in sorted(environ_keys): value = os.environ.get(key) if value: - print " " - print " %s" % key - print " %s" % value - print " " - print " " + print(" ") + print(" %s" % key) + print(" %s" % value) + print(" ") + print(" ") command = '"%s" runtest.py -q -o - --xml %s' % (sys.executable, runtest_args) #print command os.system(command) - print "" + print("") else: def print_version_info(tag, module): - print "\t%s: v%s.%s, %s, by %s on %s" % (tag, + print("\t%s: v%s.%s, %s, by %s on %s" % (tag, module.__version__, module.__build__, module.__date__, module.__developer__, - module.__buildsys__) + module.__buildsys__)) - print "SCons by Steven Knight et al.:" + print("SCons by Steven Knight et al.:") print_version_info("script", scons) print_version_info("engine", SCons) diff --git a/bin/scons-unzip.py b/bin/scons-unzip.py index d4ec4bf..75d3281 100644 --- a/bin/scons-unzip.py +++ b/bin/scons-unzip.py @@ -32,7 +32,7 @@ for o, a in opts: outdir = a elif o == '-v' or o == '--verbose': def printname(x): - print x + print(x) if len(args) != 1: sys.stderr.write("scons-unzip.py: \n") diff --git a/bin/scons_dev_master.py b/bin/scons_dev_master.py index 3c41ac0..71034ad 100644 --- a/bin/scons_dev_master.py +++ b/bin/scons_dev_master.py @@ -131,12 +131,12 @@ Usage: scons_dev_master.py [-hnqy] [--password PASSWORD] [--username USER] try: try: opts, args = getopt.getopt(argv[1:], short_options, long_options) - except getopt.error, msg: + except getopt.error as msg: raise Usage(msg) for o, a in opts: if o in ('-h', '--help'): - print helpstr + print(helpstr) sys.exit(0) elif o in ('-n', '--no-exec'): CommandRunner.execute = CommandRunner.do_not_execute @@ -148,7 +148,7 @@ Usage: scons_dev_master.py [-hnqy] [--password PASSWORD] [--username USER] username = a elif o in ('-y', '--yes', '--assume-yes'): yesflag = o - except Usage, err: + except Usage as err: sys.stderr.write(str(err.msg) + '\n') sys.stderr.write('use -h to get help\n') return 2 diff --git a/bin/svn-bisect.py b/bin/svn-bisect.py index 77bda58..f262366 100755 --- a/bin/svn-bisect.py +++ b/bin/svn-bisect.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- Python -*- -from __future__ import division + import sys from math import log, ceil @@ -28,22 +28,22 @@ script = script_args[2:] # print an error message and quit def error(s): - print >>sys.stderr, "******", s, "******" + print("******", s, "******", file=sys.stderr) sys.exit(1) # update to the specified version and run test def testfail(revision): "Return true if test fails" - print "Updating to revision", revision + print("Updating to revision", revision) if subprocess.call(["svn","up","-qr",str(revision)]) != 0: m = "SVN did not update properly to revision %d" raise RuntimeError(m % revision) return subprocess.call(script,shell=False) != 0 # confirm that the endpoints are different -print "****** Checking upper bracket", upper +print("****** Checking upper bracket", upper) upperfails = testfail(upper) -print "****** Checking lower bracket", lower +print("****** Checking lower bracket", lower) lowerfails = testfail(lower) if upperfails == lowerfails: error("Upper and lower revisions must bracket the failure") @@ -51,7 +51,7 @@ if upperfails == lowerfails: # binary search for transition msg = "****** max %d revisions to test (bug bracketed by [%d,%d])" while upper-lower > 1: - print msg % (ceil(log(upper-lower,2)), lower, upper) + print(msg % (ceil(log(upper-lower,2)), lower, upper)) mid = (lower + upper)//2 midfails = testfail(mid) @@ -64,7 +64,7 @@ while upper-lower > 1: # show which revision was first to fail if upperfails != lowerfails: lower = upper -print "The error was caused by revision", lower +print("The error was caused by revision", lower) # Local Variables: # tab-width:4 diff --git a/bin/update-release-info.py b/bin/update-release-info.py index 338bba9..f60c187 100644 --- a/bin/update-release-info.py +++ b/bin/update-release-info.py @@ -73,14 +73,14 @@ if len(sys.argv) < 2: else: mode = sys.argv[1] if mode not in ['develop', 'release', 'post']: - print("""ERROR: `%s' as a parameter is invalid; it must be one of -\tdevelop, release, or post. The default is develop.""" % mode) + print(("""ERROR: `%s' as a parameter is invalid; it must be one of +\tdevelop, release, or post. The default is develop.""" % mode)) sys.exit(1) # Get configuration information config = dict() -exec open('ReleaseConfig').read() in globals(), config +exec(open('ReleaseConfig').read(), globals(), config) try: version_tuple = config['version_tuple'] @@ -90,9 +90,9 @@ except KeyError: print('''ERROR: Config file must contain at least version_tuple, \tunsupported_python_version, and deprecated_python_version.''') sys.exit(1) -if DEBUG: print 'version tuple', version_tuple -if DEBUG: print 'unsupported Python version', unsupported_version -if DEBUG: print 'deprecated Python version', deprecated_version +if DEBUG: print('version tuple', version_tuple) +if DEBUG: print('unsupported Python version', unsupported_version) +if DEBUG: print('deprecated Python version', deprecated_version) try: release_date = config['release_date'] @@ -102,9 +102,9 @@ else: if len(release_date) == 3: release_date = release_date + time.localtime()[3:6] if len(release_date) != 6: - print '''ERROR: Invalid release date''', release_date + print('''ERROR: Invalid release date''', release_date) sys.exit(1) -if DEBUG: print 'release date', release_date +if DEBUG: print('release date', release_date) if mode == 'develop' and version_tuple[3] != 'alpha': version_tuple == version_tuple[:3] + ('alpha', 0) @@ -119,11 +119,11 @@ if len(version_tuple) > 3: version_type = version_tuple[3] else: version_type = 'final' -if DEBUG: print 'version string', version_string +if DEBUG: print('version string', version_string) if version_type not in ['alpha', 'beta', 'candidate', 'final']: - print("""ERROR: `%s' is not a valid release type in version tuple; -\tit must be one of alpha, beta, candidate, or final""" % version_type) + print(("""ERROR: `%s' is not a valid release type in version tuple; +\tit must be one of alpha, beta, candidate, or final""" % version_type)) sys.exit(1) try: @@ -133,13 +133,13 @@ except KeyError: month_year = 'MONTH YEAR' else: month_year = time.strftime('%B %Y', release_date + (0,0,0)) -if DEBUG: print 'month year', month_year +if DEBUG: print('month year', month_year) try: copyright_years = config['copyright_years'] except KeyError: copyright_years = ', '.join(map(str, list(range(2001, release_date[0] + 1)))) -if DEBUG: print 'copyright years', copyright_years +if DEBUG: print('copyright years', copyright_years) class UpdateFile(object): """ @@ -218,7 +218,7 @@ class UpdateFile(object): XXX ''' if self.file is not None and self.content != self.orig: - print 'Updating ' + self.file + '...' + print('Updating ' + self.file + '...') open(self.file, 'w').write(self.content) if mode == 'post': @@ -332,7 +332,7 @@ t.replace_assign('deprecated_python_version', str(deprecated_version)) # Update doc/user/main.{in,xml} -docyears = ', '.join(map(str, iter(range(2004, release_date[0] + 1)))) +docyears = ', '.join(map(str, iter(list(range(2004, release_date[0] + 1))))) t = UpdateFile(os.path.join('doc', 'user', 'main.in')) if DEBUG: t.file = '/tmp/main.in' ## TODO debug these diff --git a/bin/xmlagenda.py b/bin/xmlagenda.py index b3cd520..40f5ca1 100755 --- a/bin/xmlagenda.py +++ b/bin/xmlagenda.py @@ -89,7 +89,7 @@ for issue in issues: writer.writerow(['','','','','','','']) for member in team: writer.writerow(['','',member,'','','','']) -print "Exported %d issues to editlist.csv. Ready to upload to Google."%len(issues) +print("Exported %d issues to editlist.csv. Ready to upload to Google."%len(issues)) # Local Variables: # tab-width:4 diff --git a/review.py b/review.py index 23e4b10..72e187e 100644 --- a/review.py +++ b/review.py @@ -1,1805 +1,1806 @@ -#!/usr/bin/env python -# -# Copyright 2007 Google Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Tool for uploading diffs from a version control system to the codereview app. - -Usage summary: upload.py [options] [-- diff_options] [path...] - -Diff options are passed to the diff command of the underlying system. - -Supported version control systems: - Git - Mercurial - Subversion - -It is important for Git/Mercurial users to specify a tree/node/branch to diff -against by using the '--rev' option. -""" -# This code is derived from appcfg.py in the App Engine SDK (open source), -# and from ASPN recipe #146306. - -import ConfigParser -import cookielib -import fnmatch -import getpass -import logging -import mimetypes -import optparse -import os -import re -import socket -import subprocess -import sys -import urllib -import urllib2 -import urlparse - -# The md5 module was deprecated in Python 2.5. -try: - from hashlib import md5 -except ImportError: - from md5 import md5 - -try: - import readline -except ImportError: - pass - -try: - import keyring -except ImportError: - keyring = None - -# The logging verbosity: -# 0: Errors only. -# 1: Status messages. -# 2: Info logs. -# 3: Debug logs. -verbosity = 1 - -# The account type used for authentication. -# This line could be changed by the review server (see handler for -# upload.py). -AUTH_ACCOUNT_TYPE = "GOOGLE" - -# URL of the default review server. As for AUTH_ACCOUNT_TYPE, this line could be -# changed by the review server (see handler for upload.py). -DEFAULT_REVIEW_SERVER = "codereview.appspot.com" - -# Max size of patch or base file. -MAX_UPLOAD_SIZE = 900 * 1024 - -# Constants for version control names. Used by GuessVCSName. -VCS_GIT = "Git" -VCS_MERCURIAL = "Mercurial" -VCS_SUBVERSION = "Subversion" -VCS_UNKNOWN = "Unknown" - -# whitelist for non-binary filetypes which do not start with "text/" -# .mm (Objective-C) shows up as application/x-freemind on my Linux box. -TEXT_MIMETYPES = ['application/javascript', 'application/x-javascript', - 'application/xml', 'application/x-freemind', - 'application/x-sh'] - -VCS_ABBREVIATIONS = { - VCS_MERCURIAL.lower(): VCS_MERCURIAL, - "hg": VCS_MERCURIAL, - VCS_SUBVERSION.lower(): VCS_SUBVERSION, - "svn": VCS_SUBVERSION, - VCS_GIT.lower(): VCS_GIT, -} - -# The result of parsing Subversion's [auto-props] setting. -svn_auto_props_map = None - -def GetEmail(prompt): - """Prompts the user for their email address and returns it. - - The last used email address is saved to a file and offered up as a suggestion - to the user. If the user presses enter without typing in anything the last - used email address is used. If the user enters a new address, it is saved - for next time we prompt. - - """ - last_email_file_name = os.path.expanduser("~/.last_codereview_email_address") - last_email = "" - if os.path.exists(last_email_file_name): - try: - last_email_file = open(last_email_file_name, "r") - last_email = last_email_file.readline().strip("\n") - last_email_file.close() - prompt += " [%s]" % last_email - except IOError, e: - pass - email = raw_input(prompt + ": ").strip() - if email: - try: - last_email_file = open(last_email_file_name, "w") - last_email_file.write(email) - last_email_file.close() - except IOError, e: - pass - else: - email = last_email - return email - - -def StatusUpdate(msg): - """Print a status message to stdout. - - If 'verbosity' is greater than 0, print the message. - - Args: - msg: The string to print. - """ - if verbosity > 0: - print msg - - -def ErrorExit(msg): - """Print an error message to stderr and exit.""" - print >>sys.stderr, msg - sys.exit(1) - - -class ClientLoginError(urllib2.HTTPError): - """Raised to indicate there was an error authenticating with ClientLogin.""" - - def __init__(self, url, code, msg, headers, args): - urllib2.HTTPError.__init__(self, url, code, msg, headers, None) - self.args = args - self.reason = args["Error"] - self.info = args.get("Info", None) - - -class AbstractRpcServer(object): - """Provides a common interface for a simple RPC server.""" - - def __init__(self, host, auth_function, host_override=None, extra_headers={}, - save_cookies=False, account_type=AUTH_ACCOUNT_TYPE): - """Creates a new HttpRpcServer. - - Args: - host: The host to send requests to. - auth_function: A function that takes no arguments and returns an - (email, password) tuple when called. Will be called if authentication - is required. - host_override: The host header to send to the server (defaults to host). - extra_headers: A dict of extra headers to append to every request. - save_cookies: If True, save the authentication cookies to local disk. - If False, use an in-memory cookiejar instead. Subclasses must - implement this functionality. Defaults to False. - account_type: Account type used for authentication. Defaults to - AUTH_ACCOUNT_TYPE. - """ - self.host = host - if (not self.host.startswith("http://") and - not self.host.startswith("https://")): - self.host = "http://" + self.host - self.host_override = host_override - self.auth_function = auth_function - self.authenticated = False - self.extra_headers = extra_headers - self.save_cookies = save_cookies - self.account_type = account_type - self.opener = self._GetOpener() - if self.host_override: - logging.info("Server: %s; Host: %s", self.host, self.host_override) - else: - logging.info("Server: %s", self.host) - - def _GetOpener(self): - """Returns an OpenerDirector for making HTTP requests. - - Returns: - A urllib2.OpenerDirector object. - """ - raise NotImplementedError() - - def _CreateRequest(self, url, data=None): - """Creates a new urllib request.""" - logging.debug("Creating request for: '%s' with payload:\n%s", url, data) - req = urllib2.Request(url, data=data) - if self.host_override: - req.add_header("Host", self.host_override) - for key, value in self.extra_headers.iteritems(): - req.add_header(key, value) - return req - - def _GetAuthToken(self, email, password): - """Uses ClientLogin to authenticate the user, returning an auth token. - - Args: - email: The user's email address - password: The user's password - - Raises: - ClientLoginError: If there was an error authenticating with ClientLogin. - HTTPError: If there was some other form of HTTP error. - - Returns: - The authentication token returned by ClientLogin. - """ - account_type = self.account_type - if self.host.endswith(".google.com"): - # Needed for use inside Google. - account_type = "HOSTED" - req = self._CreateRequest( - url="https://www.google.com/accounts/ClientLogin", - data=urllib.urlencode({ - "Email": email, - "Passwd": password, - "service": "ah", - "source": "rietveld-codereview-upload", - "accountType": account_type, - }), - ) - try: - response = self.opener.open(req) - response_body = response.read() - response_dict = dict(x.split("=") - for x in response_body.split("\n") if x) - return response_dict["Auth"] - except urllib2.HTTPError, e: - if e.code == 403: - body = e.read() - response_dict = dict(x.split("=", 1) for x in body.split("\n") if x) - raise ClientLoginError(req.get_full_url(), e.code, e.msg, - e.headers, response_dict) - else: - raise - - def _GetAuthCookie(self, auth_token): - """Fetches authentication cookies for an authentication token. - - Args: - auth_token: The authentication token returned by ClientLogin. - - Raises: - HTTPError: If there was an error fetching the authentication cookies. - """ - # This is a dummy value to allow us to identify when we're successful. - continue_location = "http://localhost/" - args = {"continue": continue_location, "auth": auth_token} - req = self._CreateRequest("%s/_ah/login?%s" % - (self.host, urllib.urlencode(args))) - try: - response = self.opener.open(req) - except urllib2.HTTPError, e: - response = e - if (response.code != 302 or - response.info()["location"] != continue_location): - raise urllib2.HTTPError(req.get_full_url(), response.code, response.msg, - response.headers, response.fp) - self.authenticated = True - - def _Authenticate(self): - """Authenticates the user. - - The authentication process works as follows: - 1) We get a username and password from the user - 2) We use ClientLogin to obtain an AUTH token for the user - (see http://code.google.com/apis/accounts/AuthForInstalledApps.html). - 3) We pass the auth token to /_ah/login on the server to obtain an - authentication cookie. If login was successful, it tries to redirect - us to the URL we provided. - - If we attempt to access the upload API without first obtaining an - authentication cookie, it returns a 401 response (or a 302) and - directs us to authenticate ourselves with ClientLogin. - """ - for i in range(3): - credentials = self.auth_function() - try: - auth_token = self._GetAuthToken(credentials[0], credentials[1]) - except ClientLoginError, e: - print >>sys.stderr, '' - if e.reason == "BadAuthentication": - if e.info == "InvalidSecondFactor": - print >>sys.stderr, ( - "Use an application-specific password instead " - "of your regular account password.\n" - "See http://www.google.com/" - "support/accounts/bin/answer.py?answer=185833") - else: - print >>sys.stderr, "Invalid username or password." - elif e.reason == "CaptchaRequired": - print >>sys.stderr, ( - "Please go to\n" - "https://www.google.com/accounts/DisplayUnlockCaptcha\n" - "and verify you are a human. Then try again.\n" - "If you are using a Google Apps account the URL is:\n" - "https://www.google.com/a/yourdomain.com/UnlockCaptcha") - elif e.reason == "NotVerified": - print >>sys.stderr, "Account not verified." - elif e.reason == "TermsNotAgreed": - print >>sys.stderr, "User has not agreed to TOS." - elif e.reason == "AccountDeleted": - print >>sys.stderr, "The user account has been deleted." - elif e.reason == "AccountDisabled": - print >>sys.stderr, "The user account has been disabled." - break - elif e.reason == "ServiceDisabled": - print >>sys.stderr, ("The user's access to the service has been " - "disabled.") - elif e.reason == "ServiceUnavailable": - print >>sys.stderr, "The service is not available; try again later." - else: - # Unknown error. - raise - print >>sys.stderr, '' - continue - self._GetAuthCookie(auth_token) - return - - def Send(self, request_path, payload=None, - content_type="application/octet-stream", - timeout=None, - extra_headers=None, - **kwargs): - """Sends an RPC and returns the response. - - Args: - request_path: The path to send the request to, eg /api/appversion/create. - payload: The body of the request, or None to send an empty request. - content_type: The Content-Type header to use. - timeout: timeout in seconds; default None i.e. no timeout. - (Note: for large requests on OS X, the timeout doesn't work right.) - extra_headers: Dict containing additional HTTP headers that should be - included in the request (string header names mapped to their values), - or None to not include any additional headers. - kwargs: Any keyword arguments are converted into query string parameters. - - Returns: - The response body, as a string. - """ - # TODO: Don't require authentication. Let the server say - # whether it is necessary. - if not self.authenticated: - self._Authenticate() - - old_timeout = socket.getdefaulttimeout() - socket.setdefaulttimeout(timeout) - try: - tries = 0 - while True: - tries += 1 - args = dict(kwargs) - url = "%s%s" % (self.host, request_path) - if args: - url += "?" + urllib.urlencode(args) - req = self._CreateRequest(url=url, data=payload) - req.add_header("Content-Type", content_type) - if extra_headers: - for header, value in extra_headers.items(): - req.add_header(header, value) - try: - f = self.opener.open(req) - response = f.read() - f.close() - return response - except urllib2.HTTPError, e: - if tries > 3: - raise - elif e.code == 401 or e.code == 302: - self._Authenticate() -## elif e.code >= 500 and e.code < 600: -## # Server Error - try again. -## continue - elif e.code == 301: - # Handle permanent redirect manually. - url = e.info()["location"] - url_loc = urlparse.urlparse(url) - self.host = '%s://%s' % (url_loc[0], url_loc[1]) - else: - raise - finally: - socket.setdefaulttimeout(old_timeout) - - -class HttpRpcServer(AbstractRpcServer): - """Provides a simplified RPC-style interface for HTTP requests.""" - - def _Authenticate(self): - """Save the cookie jar after authentication.""" - super(HttpRpcServer, self)._Authenticate() - if self.save_cookies: - StatusUpdate("Saving authentication cookies to %s" % self.cookie_file) - self.cookie_jar.save() - - def _GetOpener(self): - """Returns an OpenerDirector that supports cookies and ignores redirects. - - Returns: - A urllib2.OpenerDirector object. - """ - opener = urllib2.OpenerDirector() - opener.add_handler(urllib2.ProxyHandler()) - opener.add_handler(urllib2.UnknownHandler()) - opener.add_handler(urllib2.HTTPHandler()) - opener.add_handler(urllib2.HTTPDefaultErrorHandler()) - opener.add_handler(urllib2.HTTPSHandler()) - opener.add_handler(urllib2.HTTPErrorProcessor()) - if self.save_cookies: - self.cookie_file = os.path.expanduser("~/.codereview_upload_cookies") - self.cookie_jar = cookielib.MozillaCookieJar(self.cookie_file) - if os.path.exists(self.cookie_file): - try: - self.cookie_jar.load() - self.authenticated = True - StatusUpdate("Loaded authentication cookies from %s" % - self.cookie_file) - except (cookielib.LoadError, IOError): - # Failed to load cookies - just ignore them. - pass - else: - # Create an empty cookie file with mode 600 - fd = os.open(self.cookie_file, os.O_CREAT, 0600) - os.close(fd) - # Always chmod the cookie file - os.chmod(self.cookie_file, 0600) - else: - # Don't save cookies across runs of update.py. - self.cookie_jar = cookielib.CookieJar() - opener.add_handler(urllib2.HTTPCookieProcessor(self.cookie_jar)) - return opener - - -parser = optparse.OptionParser( - usage="%prog [options] [-- diff_options] [path...]") -parser.add_option("-y", "--assume_yes", action="store_true", - dest="assume_yes", default=False, - help="Assume that the answer to yes/no questions is 'yes'.") -# Logging -group = parser.add_option_group("Logging options") -group.add_option("-q", "--quiet", action="store_const", const=0, - dest="verbose", help="Print errors only.") -group.add_option("-v", "--verbose", action="store_const", const=2, - dest="verbose", default=1, - help="Print info level logs.") -group.add_option("--noisy", action="store_const", const=3, - dest="verbose", help="Print all logs.") -# Review server -group = parser.add_option_group("Review server options") -group.add_option("-s", "--server", action="store", dest="server", - default=DEFAULT_REVIEW_SERVER, - metavar="SERVER", - help=("The server to upload to. The format is host[:port]. " - "Defaults to '%default'.")) -group.add_option("-e", "--email", action="store", dest="email", - metavar="EMAIL", default=None, - help="The username to use. Will prompt if omitted.") -group.add_option("-H", "--host", action="store", dest="host", - metavar="HOST", default=None, - help="Overrides the Host header sent with all RPCs.") -group.add_option("--no_cookies", action="store_false", - dest="save_cookies", default=True, - help="Do not save authentication cookies to local disk.") -group.add_option("--account_type", action="store", dest="account_type", - metavar="TYPE", default=AUTH_ACCOUNT_TYPE, - choices=["GOOGLE", "HOSTED"], - help=("Override the default account type " - "(defaults to '%default', " - "valid choices are 'GOOGLE' and 'HOSTED').")) -# Issue -group = parser.add_option_group("Issue options") -group.add_option("-d", "--description", action="store", dest="description", - metavar="DESCRIPTION", default=None, - help="Optional description when creating an issue.") -group.add_option("-f", "--description_file", action="store", - dest="description_file", metavar="DESCRIPTION_FILE", - default=None, - help="Optional path of a file that contains " - "the description when creating an issue.") -group.add_option("-r", "--reviewers", action="store", dest="reviewers", - metavar="REVIEWERS", default=None, - help="Add reviewers (comma separated email addresses).") -group.add_option("--cc", action="store", dest="cc", - metavar="CC", default="dev@scons.tigris.org", - help="Add CC (comma separated email addresses).") -group.add_option("--private", action="store_true", dest="private", - default=False, - help="Make the issue restricted to reviewers and those CCed") -# Upload options -group = parser.add_option_group("Patch options") -group.add_option("-m", "--message", action="store", dest="message", - metavar="MESSAGE", default=None, - help="A message to identify the patch. " - "Will prompt if omitted.") -group.add_option("-i", "--issue", type="int", action="store", - metavar="ISSUE", default=None, - help="Issue number to which to add. Defaults to new issue.") -group.add_option("--base_url", action="store", dest="base_url", default=None, - help="Base repository URL (listed as \"Base URL\" when " - "viewing issue). If omitted, will be guessed automatically " - "for SVN repos and left blank for others.") -group.add_option("--download_base", action="store_true", - dest="download_base", default=False, - help="Base files will be downloaded by the server " - "(side-by-side diffs may not work on files with CRs).") -group.add_option("--rev", action="store", dest="revision", - metavar="REV", default=None, - help="Base revision/branch/tree to diff against. Use " - "rev1:rev2 range to review already committed changeset.") -group.add_option("--send_mail", action="store_true", - dest="send_mail", default=True, - help="Send notification email to reviewers.") -group.add_option("--vcs", action="store", dest="vcs", - metavar="VCS", default="svn", - help=("Version control system (optional, usually upload.py " - "already guesses the right VCS).")) -group.add_option("--emulate_svn_auto_props", action="store_true", - dest="emulate_svn_auto_props", default=False, - help=("Emulate Subversion's auto properties feature.")) - - -def GetRpcServer(server, email=None, host_override=None, save_cookies=True, - account_type=AUTH_ACCOUNT_TYPE): - """Returns an instance of an AbstractRpcServer. - - Args: - server: String containing the review server URL. - email: String containing user's email address. - host_override: If not None, string containing an alternate hostname to use - in the host header. - save_cookies: Whether authentication cookies should be saved to disk. - account_type: Account type for authentication, either 'GOOGLE' - or 'HOSTED'. Defaults to AUTH_ACCOUNT_TYPE. - - Returns: - A new AbstractRpcServer, on which RPC calls can be made. - """ - - rpc_server_class = HttpRpcServer - - # If this is the dev_appserver, use fake authentication. - host = (host_override or server).lower() - if re.match(r'(http://)?localhost([:/]|$)', host): - if email is None: - email = "test@example.com" - logging.info("Using debug user %s. Override with --email" % email) - server = rpc_server_class( - server, - lambda: (email, "password"), - host_override=host_override, - extra_headers={"Cookie": - 'dev_appserver_login="%s:False"' % email}, - save_cookies=save_cookies, - account_type=account_type) - # Don't try to talk to ClientLogin. - server.authenticated = True - return server - - def GetUserCredentials(): - """Prompts the user for a username and password.""" - # Create a local alias to the email variable to avoid Python's crazy - # scoping rules. - local_email = email - if local_email is None: - local_email = GetEmail("Email (login for uploading to %s)" % server) - password = None - if keyring: - password = keyring.get_password(host, local_email) - if password is not None: - print "Using password from system keyring." - else: - password = getpass.getpass("Password for %s: " % local_email) - if keyring: - answer = raw_input("Store password in system keyring?(y/N) ").strip() - if answer == "y": - keyring.set_password(host, local_email, password) - return (local_email, password) - - return rpc_server_class(server, - GetUserCredentials, - host_override=host_override, - save_cookies=save_cookies) - - -def EncodeMultipartFormData(fields, files): - """Encode form fields for multipart/form-data. - - Args: - fields: A sequence of (name, value) elements for regular form fields. - files: A sequence of (name, filename, value) elements for data to be - uploaded as files. - Returns: - (content_type, body) ready for httplib.HTTP instance. - - Source: - http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146306 - """ - BOUNDARY = '-M-A-G-I-C---B-O-U-N-D-A-R-Y-' - CRLF = '\r\n' - lines = [] - for (key, value) in fields: - lines.append('--' + BOUNDARY) - lines.append('Content-Disposition: form-data; name="%s"' % key) - lines.append('') - if isinstance(value, unicode): - value = value.encode('utf-8') - lines.append(value) - for (key, filename, value) in files: - lines.append('--' + BOUNDARY) - lines.append('Content-Disposition: form-data; name="%s"; filename="%s"' % - (key, filename)) - lines.append('Content-Type: %s' % GetContentType(filename)) - lines.append('') - if isinstance(value, unicode): - value = value.encode('utf-8') - lines.append(value) - lines.append('--' + BOUNDARY + '--') - lines.append('') - body = CRLF.join(lines) - content_type = 'multipart/form-data; boundary=%s' % BOUNDARY - return content_type, body - - -def GetContentType(filename): - """Helper to guess the content-type from the filename.""" - return mimetypes.guess_type(filename)[0] or 'application/octet-stream' - - -# Use a shell for subcommands on Windows to get a PATH search. -use_shell = sys.platform.startswith("win") - -def RunShellWithReturnCodeAndStderr(command, print_output=False, - universal_newlines=True, - env=os.environ): - """Executes a command and returns the output from stdout, stderr and the return code. - - Args: - command: Command to execute. - print_output: If True, the output is printed to stdout. - If False, both stdout and stderr are ignored. - universal_newlines: Use universal_newlines flag (default: True). - - Returns: - Tuple (stdout, stderr, return code) - """ - logging.info("Running %s", command) - env = env.copy() - env['LC_MESSAGES'] = 'C' - p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, - shell=use_shell, universal_newlines=universal_newlines, - env=env) - if print_output: - output_array = [] - while True: - line = p.stdout.readline() - if not line: - break - print line.strip("\n") - output_array.append(line) - output = "".join(output_array) - else: - output = p.stdout.read() - p.wait() - errout = p.stderr.read() - if print_output and errout: - print >>sys.stderr, errout - p.stdout.close() - p.stderr.close() - return output, errout, p.returncode - -def RunShellWithReturnCode(command, print_output=False, - universal_newlines=True, - env=os.environ): - """Executes a command and returns the output from stdout and the return code.""" - out, err, retcode = RunShellWithReturnCodeAndStderr(command, print_output, - universal_newlines, env) - return out, retcode - -def RunShell(command, silent_ok=False, universal_newlines=True, - print_output=False, env=os.environ): - data, retcode = RunShellWithReturnCode(command, print_output, - universal_newlines, env) - if retcode: - ErrorExit("Got error status from %s:\n%s" % (command, data)) - if not silent_ok and not data: - ErrorExit("No output from %s" % command) - return data - - -class VersionControlSystem(object): - """Abstract base class providing an interface to the VCS.""" - - def __init__(self, options): - """Constructor. - - Args: - options: Command line options. - """ - self.options = options - - def PostProcessDiff(self, diff): - """Return the diff with any special post processing this VCS needs, e.g. - to include an svn-style "Index:".""" - return diff - - def GenerateDiff(self, args): - """Return the current diff as a string. - - Args: - args: Extra arguments to pass to the diff command. - """ - raise NotImplementedError( - "abstract method -- subclass %s must override" % self.__class__) - - def GetUnknownFiles(self): - """Return a list of files unknown to the VCS.""" - raise NotImplementedError( - "abstract method -- subclass %s must override" % self.__class__) - - def CheckForUnknownFiles(self): - """Show an "are you sure?" prompt if there are unknown files.""" - unknown_files = self.GetUnknownFiles() - if unknown_files: - print "The following files are not added to version control:" - for line in unknown_files: - print line - prompt = "Are you sure to continue?(y/N) " - answer = raw_input(prompt).strip() - if answer != "y": - ErrorExit("User aborted") - - def GetBaseFile(self, filename): - """Get the content of the upstream version of a file. - - Returns: - A tuple (base_content, new_content, is_binary, status) - base_content: The contents of the base file. - new_content: For text files, this is empty. For binary files, this is - the contents of the new file, since the diff output won't contain - information to reconstruct the current file. - is_binary: True iff the file is binary. - status: The status of the file. - """ - - raise NotImplementedError( - "abstract method -- subclass %s must override" % self.__class__) - - - def GetBaseFiles(self, diff): - """Helper that calls GetBase file for each file in the patch. - - Returns: - A dictionary that maps from filename to GetBaseFile's tuple. Filenames - are retrieved based on lines that start with "Index:" or - "Property changes on:". - """ - files = {} - for line in diff.splitlines(True): - if line.startswith('Index:') or line.startswith('Property changes on:'): - unused, filename = line.split(':', 1) - # On Windows if a file has property changes its filename uses '\' - # instead of '/'. - filename = filename.strip().replace('\\', '/') - files[filename] = self.GetBaseFile(filename) - return files - - - def UploadBaseFiles(self, issue, rpc_server, patch_list, patchset, options, - files): - """Uploads the base files (and if necessary, the current ones as well).""" - - def UploadFile(filename, file_id, content, is_binary, status, is_base): - """Uploads a file to the server.""" - file_too_large = False - if is_base: - type = "base" - else: - type = "current" - if len(content) > MAX_UPLOAD_SIZE: - print ("Not uploading the %s file for %s because it's too large." % - (type, filename)) - file_too_large = True - content = "" - checksum = md5(content).hexdigest() - if options.verbose > 0 and not file_too_large: - print "Uploading %s file for %s" % (type, filename) - url = "/%d/upload_content/%d/%d" % (int(issue), int(patchset), file_id) - form_fields = [("filename", filename), - ("status", status), - ("checksum", checksum), - ("is_binary", str(is_binary)), - ("is_current", str(not is_base)), - ] - if file_too_large: - form_fields.append(("file_too_large", "1")) - if options.email: - form_fields.append(("user", options.email)) - ctype, body = EncodeMultipartFormData(form_fields, - [("data", filename, content)]) - response_body = rpc_server.Send(url, body, - content_type=ctype) - if not response_body.startswith("OK"): - StatusUpdate(" --> %s" % response_body) - sys.exit(1) - - patches = dict() - [patches.setdefault(v, k) for k, v in patch_list] - for filename in patches.keys(): - base_content, new_content, is_binary, status = files[filename] - file_id_str = patches.get(filename) - if file_id_str.find("nobase") != -1: - base_content = None - file_id_str = file_id_str[file_id_str.rfind("_") + 1:] - file_id = int(file_id_str) - if base_content != None: - UploadFile(filename, file_id, base_content, is_binary, status, True) - if new_content != None: - UploadFile(filename, file_id, new_content, is_binary, status, False) - - def IsImage(self, filename): - """Returns true if the filename has an image extension.""" - mimetype = mimetypes.guess_type(filename)[0] - if not mimetype: - return False - return mimetype.startswith("image/") - - def IsBinary(self, filename): - """Returns true if the guessed mimetyped isnt't in text group.""" - mimetype = mimetypes.guess_type(filename)[0] - if not mimetype: - return False # e.g. README, "real" binaries usually have an extension - # special case for text files which don't start with text/ - if mimetype in TEXT_MIMETYPES: - return False - return not mimetype.startswith("text/") - - -class SubversionVCS(VersionControlSystem): - """Implementation of the VersionControlSystem interface for Subversion.""" - - def __init__(self, options): - super(SubversionVCS, self).__init__(options) - if self.options.revision: - match = re.match(r"(\d+)(:(\d+))?", self.options.revision) - if not match: - ErrorExit("Invalid Subversion revision %s." % self.options.revision) - self.rev_start = match.group(1) - self.rev_end = match.group(3) - else: - self.rev_start = self.rev_end = None - # Cache output from "svn list -r REVNO dirname". - # Keys: dirname, Values: 2-tuple (ouput for start rev and end rev). - self.svnls_cache = {} - # Base URL is required to fetch files deleted in an older revision. - # Result is cached to not guess it over and over again in GetBaseFile(). - required = self.options.download_base or self.options.revision is not None - self.svn_base = self._GuessBase(required) - - def GuessBase(self, required): - """Wrapper for _GuessBase.""" - return self.svn_base - - def _GuessBase(self, required): - """Returns base URL for current diff. - - Args: - required: If true, exits if the url can't be guessed, otherwise None is - returned. - """ - info = RunShell(["svn", "info"]) - for line in info.splitlines(): - if line.startswith("URL: "): - url = line.split()[1] - scheme, netloc, path, params, query, fragment = urlparse.urlparse(url) - guess = "" - if netloc == "svn.python.org" and scheme == "svn+ssh": - path = "projects" + path - scheme = "http" - guess = "Python " - elif netloc.endswith(".googlecode.com"): - scheme = "http" - guess = "Google Code " - path = path + "/" - base = urlparse.urlunparse((scheme, netloc, path, params, - query, fragment)) - logging.info("Guessed %sbase = %s", guess, base) - return base - if required: - ErrorExit("Can't find URL in output from svn info") - return None - - def GenerateDiff(self, args): - cmd = ["svn", "diff"] - if self.options.revision: - cmd += ["-r", self.options.revision] - cmd.extend(args) - data = RunShell(cmd) - count = 0 - for line in data.splitlines(): - if line.startswith("Index:") or line.startswith("Property changes on:"): - count += 1 - logging.info(line) - if not count: - ErrorExit("No valid patches found in output from svn diff") - return data - - def _CollapseKeywords(self, content, keyword_str): - """Collapses SVN keywords.""" - # svn cat translates keywords but svn diff doesn't. As a result of this - # behavior patching.PatchChunks() fails with a chunk mismatch error. - # This part was originally written by the Review Board development team - # who had the same problem (http://reviews.review-board.org/r/276/). - # Mapping of keywords to known aliases - svn_keywords = { - # Standard keywords - 'Date': ['Date', 'LastChangedDate'], - 'Revision': ['Revision', 'LastChangedRevision', 'Rev'], - 'Author': ['Author', 'LastChangedBy'], - 'HeadURL': ['HeadURL', 'URL'], - 'Id': ['Id'], - - # Aliases - 'LastChangedDate': ['LastChangedDate', 'Date'], - 'LastChangedRevision': ['LastChangedRevision', 'Rev', 'Revision'], - 'LastChangedBy': ['LastChangedBy', 'Author'], - 'URL': ['URL', 'HeadURL'], - } - - def repl(m): - if m.group(2): - return "$%s::%s$" % (m.group(1), " " * len(m.group(3))) - return "$%s$" % m.group(1) - keywords = [keyword - for name in keyword_str.split(" ") - for keyword in svn_keywords.get(name, [])] - return re.sub(r"\$(%s):(:?)([^\$]+)\$" % '|'.join(keywords), repl, content) - - def GetUnknownFiles(self): - status = RunShell(["svn", "status", "--ignore-externals"], silent_ok=True) - unknown_files = [] - for line in status.split("\n"): - if line and line[0] == "?": - unknown_files.append(line) - return unknown_files - - def ReadFile(self, filename): - """Returns the contents of a file.""" - file = open(filename, 'rb') - result = "" - try: - result = file.read() - finally: - file.close() - return result - - def GetStatus(self, filename): - """Returns the status of a file.""" - if not self.options.revision: - status = RunShell(["svn", "status", "--ignore-externals", filename]) - if not status: - ErrorExit("svn status returned no output for %s" % filename) - status_lines = status.splitlines() - # If file is in a cl, the output will begin with - # "\n--- Changelist 'cl_name':\n". See - # http://svn.collab.net/repos/svn/trunk/notes/changelist-design.txt - if (len(status_lines) == 3 and - not status_lines[0] and - status_lines[1].startswith("--- Changelist")): - status = status_lines[2] - else: - status = status_lines[0] - # If we have a revision to diff against we need to run "svn list" - # for the old and the new revision and compare the results to get - # the correct status for a file. - else: - dirname, relfilename = os.path.split(filename) - if dirname not in self.svnls_cache: - cmd = ["svn", "list", "-r", self.rev_start, dirname or "."] - out, err, returncode = RunShellWithReturnCodeAndStderr(cmd) - if returncode: - # Directory might not yet exist at start revison - # svn: Unable to find repository location for 'abc' in revision nnn - if re.match('^svn: Unable to find repository location for .+ in revision \d+', err): - old_files = () - else: - ErrorExit("Failed to get status for %s:\n%s" % (filename, err)) - else: - old_files = out.splitlines() - args = ["svn", "list"] - if self.rev_end: - args += ["-r", self.rev_end] - cmd = args + [dirname or "."] - out, returncode = RunShellWithReturnCode(cmd) - if returncode: - ErrorExit("Failed to run command %s" % cmd) - self.svnls_cache[dirname] = (old_files, out.splitlines()) - old_files, new_files = self.svnls_cache[dirname] - if relfilename in old_files and relfilename not in new_files: - status = "D " - elif relfilename in old_files and relfilename in new_files: - status = "M " - else: - status = "A " - return status - - def GetBaseFile(self, filename): - status = self.GetStatus(filename) - base_content = None - new_content = None - - # If a file is copied its status will be "A +", which signifies - # "addition-with-history". See "svn st" for more information. We need to - # upload the original file or else diff parsing will fail if the file was - # edited. - if status[0] == "A" and status[3] != "+": - # We'll need to upload the new content if we're adding a binary file - # since diff's output won't contain it. - mimetype = RunShell(["svn", "propget", "svn:mime-type", filename], - silent_ok=True) - base_content = "" - is_binary = bool(mimetype) and not mimetype.startswith("text/") - if is_binary and self.IsImage(filename): - new_content = self.ReadFile(filename) - elif (status[0] in ("M", "D", "R") or - (status[0] == "A" and status[3] == "+") or # Copied file. - (status[0] == " " and status[1] == "M")): # Property change. - args = [] - if self.options.revision: - url = "%s/%s@%s" % (self.svn_base, filename, self.rev_start) - else: - # Don't change filename, it's needed later. - url = filename - args += ["-r", "BASE"] - cmd = ["svn"] + args + ["propget", "svn:mime-type", url] - mimetype, returncode = RunShellWithReturnCode(cmd) - if returncode: - # File does not exist in the requested revision. - # Reset mimetype, it contains an error message. - mimetype = "" - else: - mimetype = mimetype.strip() - get_base = False - is_binary = (bool(mimetype) and - not mimetype.startswith("text/") and - not mimetype in TEXT_MIMETYPES) - if status[0] == " ": - # Empty base content just to force an upload. - base_content = "" - elif is_binary: - if self.IsImage(filename): - get_base = True - if status[0] == "M": - if not self.rev_end: - new_content = self.ReadFile(filename) - else: - url = "%s/%s@%s" % (self.svn_base, filename, self.rev_end) - new_content = RunShell(["svn", "cat", url], - universal_newlines=True, silent_ok=True) - else: - base_content = "" - else: - get_base = True - - if get_base: - if is_binary: - universal_newlines = False - else: - universal_newlines = True - if self.rev_start: - # "svn cat -r REV delete_file.txt" doesn't work. cat requires - # the full URL with "@REV" appended instead of using "-r" option. - url = "%s/%s@%s" % (self.svn_base, filename, self.rev_start) - base_content = RunShell(["svn", "cat", url], - universal_newlines=universal_newlines, - silent_ok=True) - else: - base_content, ret_code = RunShellWithReturnCode( - ["svn", "cat", filename], universal_newlines=universal_newlines) - if ret_code and status[0] == "R": - # It's a replaced file without local history (see issue208). - # The base file needs to be fetched from the server. - url = "%s/%s" % (self.svn_base, filename) - base_content = RunShell(["svn", "cat", url], - universal_newlines=universal_newlines, - silent_ok=True) - elif ret_code: - ErrorExit("Got error status from 'svn cat %s'" % filename) - if not is_binary: - args = [] - if self.rev_start: - url = "%s/%s@%s" % (self.svn_base, filename, self.rev_start) - else: - url = filename - args += ["-r", "BASE"] - cmd = ["svn"] + args + ["propget", "svn:keywords", url] - keywords, returncode = RunShellWithReturnCode(cmd) - if keywords and not returncode: - base_content = self._CollapseKeywords(base_content, keywords) - else: - StatusUpdate("svn status returned unexpected output: %s" % status) - sys.exit(1) - return base_content, new_content, is_binary, status[0:5] - - -class GitVCS(VersionControlSystem): - """Implementation of the VersionControlSystem interface for Git.""" - - def __init__(self, options): - super(GitVCS, self).__init__(options) - # Map of filename -> (hash before, hash after) of base file. - # Hashes for "no such file" are represented as None. - self.hashes = {} - # Map of new filename -> old filename for renames. - self.renames = {} - - def PostProcessDiff(self, gitdiff): - """Converts the diff output to include an svn-style "Index:" line as well - as record the hashes of the files, so we can upload them along with our - diff.""" - # Special used by git to indicate "no such content". - NULL_HASH = "0"*40 - - def IsFileNew(filename): - return filename in self.hashes and self.hashes[filename][0] is None - - def AddSubversionPropertyChange(filename): - """Add svn's property change information into the patch if given file is - new file. - - We use Subversion's auto-props setting to retrieve its property. - See http://svnbook.red-bean.com/en/1.1/ch07.html#svn-ch-7-sect-1.3.2 for - Subversion's [auto-props] setting. - """ - if self.options.emulate_svn_auto_props and IsFileNew(filename): - svnprops = GetSubversionPropertyChanges(filename) - if svnprops: - svndiff.append("\n" + svnprops + "\n") - - svndiff = [] - filecount = 0 - filename = None - for line in gitdiff.splitlines(): - match = re.match(r"diff --git a/(.*) b/(.*)$", line) - if match: - # Add auto property here for previously seen file. - if filename is not None: - AddSubversionPropertyChange(filename) - filecount += 1 - # Intentionally use the "after" filename so we can show renames. - filename = match.group(2) - svndiff.append("Index: %s\n" % filename) - if match.group(1) != match.group(2): - self.renames[match.group(2)] = match.group(1) - else: - # The "index" line in a git diff looks like this (long hashes elided): - # index 82c0d44..b2cee3f 100755 - # We want to save the left hash, as that identifies the base file. - match = re.match(r"index (\w+)\.\.(\w+)", line) - if match: - before, after = (match.group(1), match.group(2)) - if before == NULL_HASH: - before = None - if after == NULL_HASH: - after = None - self.hashes[filename] = (before, after) - svndiff.append(line + "\n") - if not filecount: - ErrorExit("No valid patches found in output from git diff") - # Add auto property for the last seen file. - assert filename is not None - AddSubversionPropertyChange(filename) - return "".join(svndiff) - - def GenerateDiff(self, extra_args): - extra_args = extra_args[:] - if self.options.revision: - if ":" in self.options.revision: - extra_args = self.options.revision.split(":", 1) + extra_args - else: - extra_args = [self.options.revision] + extra_args - - # --no-ext-diff is broken in some versions of Git, so try to work around - # this by overriding the environment (but there is still a problem if the - # git config key "diff.external" is used). - env = os.environ.copy() - if 'GIT_EXTERNAL_DIFF' in env: del env['GIT_EXTERNAL_DIFF'] - return RunShell(["git", "diff", "--no-ext-diff", "--full-index", "-M"] - + extra_args, env=env) - - def GetUnknownFiles(self): - status = RunShell(["git", "ls-files", "--exclude-standard", "--others"], - silent_ok=True) - return status.splitlines() - - def GetFileContent(self, file_hash, is_binary): - """Returns the content of a file identified by its git hash.""" - data, retcode = RunShellWithReturnCode(["git", "show", file_hash], - universal_newlines=not is_binary) - if retcode: - ErrorExit("Got error status from 'git show %s'" % file_hash) - return data - - def GetBaseFile(self, filename): - hash_before, hash_after = self.hashes.get(filename, (None,None)) - base_content = None - new_content = None - is_binary = self.IsBinary(filename) - status = None - - if filename in self.renames: - status = "A +" # Match svn attribute name for renames. - if filename not in self.hashes: - # If a rename doesn't change the content, we never get a hash. - base_content = RunShell(["git", "show", "HEAD:" + filename]) - elif not hash_before: - status = "A" - base_content = "" - elif not hash_after: - status = "D" - else: - status = "M" - - is_image = self.IsImage(filename) - - # Grab the before/after content if we need it. - # We should include file contents if it's text or it's an image. - if not is_binary or is_image: - # Grab the base content if we don't have it already. - if base_content is None and hash_before: - base_content = self.GetFileContent(hash_before, is_binary) - # Only include the "after" file if it's an image; otherwise it - # it is reconstructed from the diff. - if is_image and hash_after: - new_content = self.GetFileContent(hash_after, is_binary) - - return (base_content, new_content, is_binary, status) - - -class MercurialVCS(VersionControlSystem): - """Implementation of the VersionControlSystem interface for Mercurial.""" - - def __init__(self, options, repo_dir): - super(MercurialVCS, self).__init__(options) - # Absolute path to repository (we can be in a subdir) - self.repo_dir = os.path.normpath(repo_dir) - # Compute the subdir - cwd = os.path.normpath(os.getcwd()) - assert cwd.startswith(self.repo_dir) - self.subdir = cwd[len(self.repo_dir):].lstrip(r"\/") - if self.options.revision: - self.base_rev = self.options.revision - else: - self.base_rev = RunShell(["hg", "parent", "-q"]).split(':')[1].strip() - - def _GetRelPath(self, filename): - """Get relative path of a file according to the current directory, - given its logical path in the repo.""" - assert filename.startswith(self.subdir), (filename, self.subdir) - return filename[len(self.subdir):].lstrip(r"\/") - - def GenerateDiff(self, extra_args): - cmd = ["hg", "diff", "--git", "-r", self.base_rev] + extra_args - data = RunShell(cmd, silent_ok=True) - svndiff = [] - filecount = 0 - for line in data.splitlines(): - m = re.match("diff --git a/(\S+) b/(\S+)", line) - if m: - # Modify line to make it look like as it comes from svn diff. - # With this modification no changes on the server side are required - # to make upload.py work with Mercurial repos. - # NOTE: for proper handling of moved/copied files, we have to use - # the second filename. - filename = m.group(2) - svndiff.append("Index: %s" % filename) - svndiff.append("=" * 67) - filecount += 1 - logging.info(line) - else: - svndiff.append(line) - if not filecount: - ErrorExit("No valid patches found in output from hg diff") - return "\n".join(svndiff) + "\n" - - def GetUnknownFiles(self): - """Return a list of files unknown to the VCS.""" - args = [] - status = RunShell(["hg", "status", "--rev", self.base_rev, "-u", "."], - silent_ok=True) - unknown_files = [] - for line in status.splitlines(): - st, fn = line.split(" ", 1) - if st == "?": - unknown_files.append(fn) - return unknown_files - - def GetBaseFile(self, filename): - # "hg status" and "hg cat" both take a path relative to the current subdir - # rather than to the repo root, but "hg diff" has given us the full path - # to the repo root. - base_content = "" - new_content = None - is_binary = False - oldrelpath = relpath = self._GetRelPath(filename) - # "hg status -C" returns two lines for moved/copied files, one otherwise - out = RunShell(["hg", "status", "-C", "--rev", self.base_rev, relpath]) - out = out.splitlines() - # HACK: strip error message about missing file/directory if it isn't in - # the working copy - if out[0].startswith('%s: ' % relpath): - out = out[1:] - status, _ = out[0].split(' ', 1) - if len(out) > 1 and status == "A": - # Moved/copied => considered as modified, use old filename to - # retrieve base contents - oldrelpath = out[1].strip() - status = "M" - if ":" in self.base_rev: - base_rev = self.base_rev.split(":", 1)[0] - else: - base_rev = self.base_rev - if status != "A": - base_content = RunShell(["hg", "cat", "-r", base_rev, oldrelpath], - silent_ok=True) - is_binary = "\0" in base_content # Mercurial's heuristic - if status != "R": - new_content = open(relpath, "rb").read() - is_binary = is_binary or "\0" in new_content - if is_binary and base_content: - # Fetch again without converting newlines - base_content = RunShell(["hg", "cat", "-r", base_rev, oldrelpath], - silent_ok=True, universal_newlines=False) - if not is_binary or not self.IsImage(relpath): - new_content = None - return base_content, new_content, is_binary, status - - -# NOTE: The SplitPatch function is duplicated in engine.py, keep them in sync. -def SplitPatch(data): - """Splits a patch into separate pieces for each file. - - Args: - data: A string containing the output of svn diff. - - Returns: - A list of 2-tuple (filename, text) where text is the svn diff output - pertaining to filename. - """ - patches = [] - filename = None - diff = [] - for line in data.splitlines(True): - new_filename = None - if line.startswith('Index:'): - unused, new_filename = line.split(':', 1) - new_filename = new_filename.strip() - elif line.startswith('Property changes on:'): - unused, temp_filename = line.split(':', 1) - # When a file is modified, paths use '/' between directories, however - # when a property is modified '\' is used on Windows. Make them the same - # otherwise the file shows up twice. - temp_filename = temp_filename.strip().replace('\\', '/') - if temp_filename != filename: - # File has property changes but no modifications, create a new diff. - new_filename = temp_filename - if new_filename: - if filename and diff: - patches.append((filename, ''.join(diff))) - filename = new_filename - diff = [line] - continue - if diff is not None: - diff.append(line) - if filename and diff: - patches.append((filename, ''.join(diff))) - return patches - - -def UploadSeparatePatches(issue, rpc_server, patchset, data, options): - """Uploads a separate patch for each file in the diff output. - - Returns a list of [patch_key, filename] for each file. - """ - patches = SplitPatch(data) - rv = [] - for patch in patches: - if len(patch[1]) > MAX_UPLOAD_SIZE: - print ("Not uploading the patch for " + patch[0] + - " because the file is too large.") - continue - form_fields = [("filename", patch[0])] - if not options.download_base: - form_fields.append(("content_upload", "1")) - files = [("data", "data.diff", patch[1])] - ctype, body = EncodeMultipartFormData(form_fields, files) - url = "/%d/upload_patch/%d" % (int(issue), int(patchset)) - print "Uploading patch for " + patch[0] - response_body = rpc_server.Send(url, body, content_type=ctype) - lines = response_body.splitlines() - if not lines or lines[0] != "OK": - StatusUpdate(" --> %s" % response_body) - sys.exit(1) - rv.append([lines[1], patch[0]]) - return rv - - -def GuessVCSName(): - """Helper to guess the version control system. - - This examines the current directory, guesses which VersionControlSystem - we're using, and returns an string indicating which VCS is detected. - - Returns: - A pair (vcs, output). vcs is a string indicating which VCS was detected - and is one of VCS_GIT, VCS_MERCURIAL, VCS_SUBVERSION, or VCS_UNKNOWN. - output is a string containing any interesting output from the vcs - detection routine, or None if there is nothing interesting. - """ - def RunDetectCommand(vcs_type, command): - """Helper to detect VCS by executing command. - - Returns: - A pair (vcs, output) or None. Throws exception on error. - """ - try: - out, returncode = RunShellWithReturnCode(command) - if returncode == 0: - return (vcs_type, out.strip()) - except OSError, (errcode, message): - if errcode != errno.ENOENT: # command not found code - raise - - # Mercurial has a command to get the base directory of a repository - # Try running it, but don't die if we don't have hg installed. - # NOTE: we try Mercurial first as it can sit on top of an SVN working copy. - res = RunDetectCommand(VCS_MERCURIAL, ["hg", "root"]) - if res != None: - return res - - # Subversion has a .svn in all working directories. - if os.path.isdir('.svn'): - logging.info("Guessed VCS = Subversion") - return (VCS_SUBVERSION, None) - - # Git has a command to test if you're in a git tree. - # Try running it, but don't die if we don't have git installed. - res = RunDetectCommand(VCS_GIT, ["git", "rev-parse", - "--is-inside-work-tree"]) - if res != None: - return res - - return (VCS_UNKNOWN, None) - - -def GuessVCS(options): - """Helper to guess the version control system. - - This verifies any user-specified VersionControlSystem (by command line - or environment variable). If the user didn't specify one, this examines - the current directory, guesses which VersionControlSystem we're using, - and returns an instance of the appropriate class. Exit with an error - if we can't figure it out. - - Returns: - A VersionControlSystem instance. Exits if the VCS can't be guessed. - """ - vcs = options.vcs - if not vcs: - vcs = os.environ.get("CODEREVIEW_VCS") - if vcs: - v = VCS_ABBREVIATIONS.get(vcs.lower()) - if v is None: - ErrorExit("Unknown version control system %r specified." % vcs) - (vcs, extra_output) = (v, None) - else: - (vcs, extra_output) = GuessVCSName() - - if vcs == VCS_MERCURIAL: - if extra_output is None: - extra_output = RunShell(["hg", "root"]).strip() - return MercurialVCS(options, extra_output) - elif vcs == VCS_SUBVERSION: - return SubversionVCS(options) - elif vcs == VCS_GIT: - return GitVCS(options) - - ErrorExit(("Could not guess version control system. " - "Are you in a working copy directory?")) - - -def CheckReviewer(reviewer): - """Validate a reviewer -- either a nickname or an email addres. - - Args: - reviewer: A nickname or an email address. - - Calls ErrorExit() if it is an invalid email address. - """ - if "@" not in reviewer: - return # Assume nickname - parts = reviewer.split("@") - if len(parts) > 2: - ErrorExit("Invalid email address: %r" % reviewer) - assert len(parts) == 2 - if "." not in parts[1]: - ErrorExit("Invalid email address: %r" % reviewer) - - -def LoadSubversionAutoProperties(): - """Returns the content of [auto-props] section of Subversion's config file as - a dictionary. - - Returns: - A dictionary whose key-value pair corresponds the [auto-props] section's - key-value pair. - In following cases, returns empty dictionary: - - config file doesn't exist, or - - 'enable-auto-props' is not set to 'true-like-value' in [miscellany]. - """ - if os.name == 'nt': - subversion_config = os.environ.get("APPDATA") + "\\Subversion\\config" - else: - subversion_config = os.path.expanduser("~/.subversion/config") - if not os.path.exists(subversion_config): - return {} - config = ConfigParser.ConfigParser() - config.read(subversion_config) - if (config.has_section("miscellany") and - config.has_option("miscellany", "enable-auto-props") and - config.getboolean("miscellany", "enable-auto-props") and - config.has_section("auto-props")): - props = {} - for file_pattern in config.options("auto-props"): - props[file_pattern] = ParseSubversionPropertyValues( - config.get("auto-props", file_pattern)) - return props - else: - return {} - -def ParseSubversionPropertyValues(props): - """Parse the given property value which comes from [auto-props] section and - returns a list whose element is a (svn_prop_key, svn_prop_value) pair. - - See the following doctest for example. - - >>> ParseSubversionPropertyValues('svn:eol-style=LF') - [('svn:eol-style', 'LF')] - >>> ParseSubversionPropertyValues('svn:mime-type=image/jpeg') - [('svn:mime-type', 'image/jpeg')] - >>> ParseSubversionPropertyValues('svn:eol-style=LF;svn:executable') - [('svn:eol-style', 'LF'), ('svn:executable', '*')] - """ - key_value_pairs = [] - for prop in props.split(";"): - key_value = prop.split("=") - assert len(key_value) <= 2 - if len(key_value) == 1: - # If value is not given, use '*' as a Subversion's convention. - key_value_pairs.append((key_value[0], "*")) - else: - key_value_pairs.append((key_value[0], key_value[1])) - return key_value_pairs - - -def GetSubversionPropertyChanges(filename): - """Return a Subversion's 'Property changes on ...' string, which is used in - the patch file. - - Args: - filename: filename whose property might be set by [auto-props] config. - - Returns: - A string like 'Property changes on |filename| ...' if given |filename| - matches any entries in [auto-props] section. None, otherwise. - """ - global svn_auto_props_map - if svn_auto_props_map is None: - svn_auto_props_map = LoadSubversionAutoProperties() - - all_props = [] - for file_pattern, props in svn_auto_props_map.items(): - if fnmatch.fnmatch(filename, file_pattern): - all_props.extend(props) - if all_props: - return FormatSubversionPropertyChanges(filename, all_props) - return None - - -def FormatSubversionPropertyChanges(filename, props): - """Returns Subversion's 'Property changes on ...' strings using given filename - and properties. - - Args: - filename: filename - props: A list whose element is a (svn_prop_key, svn_prop_value) pair. - - Returns: - A string which can be used in the patch file for Subversion. - - See the following doctest for example. - - >>> print FormatSubversionPropertyChanges('foo.cc', [('svn:eol-style', 'LF')]) - Property changes on: foo.cc - ___________________________________________________________________ - Added: svn:eol-style - + LF - - """ - prop_changes_lines = [ - "Property changes on: %s" % filename, - "___________________________________________________________________"] - for key, value in props: - prop_changes_lines.append("Added: " + key) - prop_changes_lines.append(" + " + value) - return "\n".join(prop_changes_lines) + "\n" - - -def RealMain(argv, data=None): - """The real main function. - - Args: - argv: Command line arguments. - data: Diff contents. If None (default) the diff is generated by - the VersionControlSystem implementation returned by GuessVCS(). - - Returns: - A 2-tuple (issue id, patchset id). - The patchset id is None if the base files are not uploaded by this - script (applies only to SVN checkouts). - """ - options, args = parser.parse_args(argv[1:]) - global verbosity - verbosity = options.verbose - if verbosity >= 3: - logging.getLogger().setLevel(logging.DEBUG) - elif verbosity >= 2: - logging.getLogger().setLevel(logging.INFO) - - vcs = GuessVCS(options) - - base = options.base_url - if isinstance(vcs, SubversionVCS): - # Guessing the base field is only supported for Subversion. - # Note: Fetching base files may become deprecated in future releases. - guessed_base = vcs.GuessBase(options.download_base) - if base: - if guessed_base and base != guessed_base: - print "Using base URL \"%s\" from --base_url instead of \"%s\"" % \ - (base, guessed_base) - else: - base = guessed_base - - if not base and options.download_base: - options.download_base = True - logging.info("Enabled upload of base file") - if not options.assume_yes: - vcs.CheckForUnknownFiles() - if data is None: - data = vcs.GenerateDiff(args) - data = vcs.PostProcessDiff(data) - files = vcs.GetBaseFiles(data) - if verbosity >= 1: - print "Upload server:", options.server, "(change with -s/--server)" - if options.issue: - prompt = "Message describing this patch set: " - else: - prompt = "New issue subject: " - message = options.message or raw_input(prompt).strip() - if not message: - ErrorExit("A non-empty message is required") - rpc_server = GetRpcServer(options.server, - options.email, - options.host, - options.save_cookies, - options.account_type) - form_fields = [("subject", message)] - if base: - b = urlparse.urlparse(base) - username, netloc = urllib.splituser(b.netloc) - if username: - logging.info("Removed username from base URL") - base = urlparse.urlunparse((b.scheme, netloc, b.path, b.params, - b.query, b.fragment)) - form_fields.append(("base", base)) - if options.issue: - form_fields.append(("issue", str(options.issue))) - if options.email: - form_fields.append(("user", options.email)) - if options.reviewers: - for reviewer in options.reviewers.split(','): - CheckReviewer(reviewer) - form_fields.append(("reviewers", options.reviewers)) - if options.cc: - for cc in options.cc.split(','): - CheckReviewer(cc) - form_fields.append(("cc", options.cc)) - description = options.description - if options.description_file: - if options.description: - ErrorExit("Can't specify description and description_file") - file = open(options.description_file, 'r') - description = file.read() - file.close() - if description: - form_fields.append(("description", description)) - # Send a hash of all the base file so the server can determine if a copy - # already exists in an earlier patchset. - base_hashes = "" - for file, info in files.iteritems(): - if not info[0] is None: - checksum = md5(info[0]).hexdigest() - if base_hashes: - base_hashes += "|" - base_hashes += checksum + ":" + file - form_fields.append(("base_hashes", base_hashes)) - if options.private: - if options.issue: - print "Warning: Private flag ignored when updating an existing issue." - else: - form_fields.append(("private", "1")) - # If we're uploading base files, don't send the email before the uploads, so - # that it contains the file status. - if options.send_mail and options.download_base: - form_fields.append(("send_mail", "1")) - if not options.download_base: - form_fields.append(("content_upload", "1")) - if len(data) > MAX_UPLOAD_SIZE: - print "Patch is large, so uploading file patches separately." - uploaded_diff_file = [] - form_fields.append(("separate_patches", "1")) - else: - uploaded_diff_file = [("data", "data.diff", data)] - ctype, body = EncodeMultipartFormData(form_fields, uploaded_diff_file) - response_body = rpc_server.Send("/upload", body, content_type=ctype) - patchset = None - if not options.download_base or not uploaded_diff_file: - lines = response_body.splitlines() - if len(lines) >= 2: - msg = lines[0] - patchset = lines[1].strip() - patches = [x.split(" ", 1) for x in lines[2:]] - else: - msg = response_body - else: - msg = response_body - StatusUpdate(msg) - if not response_body.startswith("Issue created.") and \ - not response_body.startswith("Issue updated."): - sys.exit(0) - issue = msg[msg.rfind("/")+1:] - - if not uploaded_diff_file: - result = UploadSeparatePatches(issue, rpc_server, patchset, data, options) - if not options.download_base: - patches = result - - if not options.download_base: - vcs.UploadBaseFiles(issue, rpc_server, patches, patchset, options, files) - if options.send_mail: - rpc_server.Send("/" + issue + "/mail", payload="") - return issue, patchset - - -def main(): - try: - logging.basicConfig(format=("%(asctime).19s %(levelname)s %(filename)s:" - "%(lineno)s %(message)s ")) - os.environ['LC_ALL'] = 'C' - RealMain(sys.argv) - except KeyboardInterrupt: - print - StatusUpdate("Interrupted.") - sys.exit(1) - - -if __name__ == "__main__": - main() - +#!/usr/bin/env python +# +# Copyright 2007 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tool for uploading diffs from a version control system to the codereview app. + +Usage summary: upload.py [options] [-- diff_options] [path...] + +Diff options are passed to the diff command of the underlying system. + +Supported version control systems: + Git + Mercurial + Subversion + +It is important for Git/Mercurial users to specify a tree/node/branch to diff +against by using the '--rev' option. +""" +# This code is derived from appcfg.py in the App Engine SDK (open source), +# and from ASPN recipe #146306. + +import configparser +import http.cookiejar +import fnmatch +import getpass +import logging +import mimetypes +import optparse +import os +import re +import socket +import subprocess +import sys +import urllib.request, urllib.parse, urllib.error +import urllib.request, urllib.error, urllib.parse +import urllib.parse + +# The md5 module was deprecated in Python 2.5. +try: + from hashlib import md5 +except ImportError: + from md5 import md5 + +try: + import readline +except ImportError: + pass + +try: + import keyring +except ImportError: + keyring = None + +# The logging verbosity: +# 0: Errors only. +# 1: Status messages. +# 2: Info logs. +# 3: Debug logs. +verbosity = 1 + +# The account type used for authentication. +# This line could be changed by the review server (see handler for +# upload.py). +AUTH_ACCOUNT_TYPE = "GOOGLE" + +# URL of the default review server. As for AUTH_ACCOUNT_TYPE, this line could be +# changed by the review server (see handler for upload.py). +DEFAULT_REVIEW_SERVER = "codereview.appspot.com" + +# Max size of patch or base file. +MAX_UPLOAD_SIZE = 900 * 1024 + +# Constants for version control names. Used by GuessVCSName. +VCS_GIT = "Git" +VCS_MERCURIAL = "Mercurial" +VCS_SUBVERSION = "Subversion" +VCS_UNKNOWN = "Unknown" + +# whitelist for non-binary filetypes which do not start with "text/" +# .mm (Objective-C) shows up as application/x-freemind on my Linux box. +TEXT_MIMETYPES = ['application/javascript', 'application/x-javascript', + 'application/xml', 'application/x-freemind', + 'application/x-sh'] + +VCS_ABBREVIATIONS = { + VCS_MERCURIAL.lower(): VCS_MERCURIAL, + "hg": VCS_MERCURIAL, + VCS_SUBVERSION.lower(): VCS_SUBVERSION, + "svn": VCS_SUBVERSION, + VCS_GIT.lower(): VCS_GIT, +} + +# The result of parsing Subversion's [auto-props] setting. +svn_auto_props_map = None + +def GetEmail(prompt): + """Prompts the user for their email address and returns it. + + The last used email address is saved to a file and offered up as a suggestion + to the user. If the user presses enter without typing in anything the last + used email address is used. If the user enters a new address, it is saved + for next time we prompt. + + """ + last_email_file_name = os.path.expanduser("~/.last_codereview_email_address") + last_email = "" + if os.path.exists(last_email_file_name): + try: + last_email_file = open(last_email_file_name, "r") + last_email = last_email_file.readline().strip("\n") + last_email_file.close() + prompt += " [%s]" % last_email + except IOError as e: + pass + email = input(prompt + ": ").strip() + if email: + try: + last_email_file = open(last_email_file_name, "w") + last_email_file.write(email) + last_email_file.close() + except IOError as e: + pass + else: + email = last_email + return email + + +def StatusUpdate(msg): + """Print a status message to stdout. + + If 'verbosity' is greater than 0, print the message. + + Args: + msg: The string to print. + """ + if verbosity > 0: + print(msg) + + +def ErrorExit(msg): + """Print an error message to stderr and exit.""" + print(msg, file=sys.stderr) + sys.exit(1) + + +class ClientLoginError(urllib.error.HTTPError): + """Raised to indicate there was an error authenticating with ClientLogin.""" + + def __init__(self, url, code, msg, headers, args): + urllib.error.HTTPError.__init__(self, url, code, msg, headers, None) + self.args = args + self.reason = args["Error"] + self.info = args.get("Info", None) + + +class AbstractRpcServer(object): + """Provides a common interface for a simple RPC server.""" + + def __init__(self, host, auth_function, host_override=None, extra_headers={}, + save_cookies=False, account_type=AUTH_ACCOUNT_TYPE): + """Creates a new HttpRpcServer. + + Args: + host: The host to send requests to. + auth_function: A function that takes no arguments and returns an + (email, password) tuple when called. Will be called if authentication + is required. + host_override: The host header to send to the server (defaults to host). + extra_headers: A dict of extra headers to append to every request. + save_cookies: If True, save the authentication cookies to local disk. + If False, use an in-memory cookiejar instead. Subclasses must + implement this functionality. Defaults to False. + account_type: Account type used for authentication. Defaults to + AUTH_ACCOUNT_TYPE. + """ + self.host = host + if (not self.host.startswith("http://") and + not self.host.startswith("https://")): + self.host = "http://" + self.host + self.host_override = host_override + self.auth_function = auth_function + self.authenticated = False + self.extra_headers = extra_headers + self.save_cookies = save_cookies + self.account_type = account_type + self.opener = self._GetOpener() + if self.host_override: + logging.info("Server: %s; Host: %s", self.host, self.host_override) + else: + logging.info("Server: %s", self.host) + + def _GetOpener(self): + """Returns an OpenerDirector for making HTTP requests. + + Returns: + A urllib2.OpenerDirector object. + """ + raise NotImplementedError() + + def _CreateRequest(self, url, data=None): + """Creates a new urllib request.""" + logging.debug("Creating request for: '%s' with payload:\n%s", url, data) + req = urllib.request.Request(url, data=data) + if self.host_override: + req.add_header("Host", self.host_override) + for key, value in self.extra_headers.items(): + req.add_header(key, value) + return req + + def _GetAuthToken(self, email, password): + """Uses ClientLogin to authenticate the user, returning an auth token. + + Args: + email: The user's email address + password: The user's password + + Raises: + ClientLoginError: If there was an error authenticating with ClientLogin. + HTTPError: If there was some other form of HTTP error. + + Returns: + The authentication token returned by ClientLogin. + """ + account_type = self.account_type + if self.host.endswith(".google.com"): + # Needed for use inside Google. + account_type = "HOSTED" + req = self._CreateRequest( + url="https://www.google.com/accounts/ClientLogin", + data=urllib.parse.urlencode({ + "Email": email, + "Passwd": password, + "service": "ah", + "source": "rietveld-codereview-upload", + "accountType": account_type, + }), + ) + try: + response = self.opener.open(req) + response_body = response.read() + response_dict = dict(x.split("=") + for x in response_body.split("\n") if x) + return response_dict["Auth"] + except urllib.error.HTTPError as e: + if e.code == 403: + body = e.read() + response_dict = dict(x.split("=", 1) for x in body.split("\n") if x) + raise ClientLoginError(req.get_full_url(), e.code, e.msg, + e.headers, response_dict) + else: + raise + + def _GetAuthCookie(self, auth_token): + """Fetches authentication cookies for an authentication token. + + Args: + auth_token: The authentication token returned by ClientLogin. + + Raises: + HTTPError: If there was an error fetching the authentication cookies. + """ + # This is a dummy value to allow us to identify when we're successful. + continue_location = "http://localhost/" + args = {"continue": continue_location, "auth": auth_token} + req = self._CreateRequest("%s/_ah/login?%s" % + (self.host, urllib.parse.urlencode(args))) + try: + response = self.opener.open(req) + except urllib.error.HTTPError as e: + response = e + if (response.code != 302 or + response.info()["location"] != continue_location): + raise urllib.error.HTTPError(req.get_full_url(), response.code, response.msg, + response.headers, response.fp) + self.authenticated = True + + def _Authenticate(self): + """Authenticates the user. + + The authentication process works as follows: + 1) We get a username and password from the user + 2) We use ClientLogin to obtain an AUTH token for the user + (see http://code.google.com/apis/accounts/AuthForInstalledApps.html). + 3) We pass the auth token to /_ah/login on the server to obtain an + authentication cookie. If login was successful, it tries to redirect + us to the URL we provided. + + If we attempt to access the upload API without first obtaining an + authentication cookie, it returns a 401 response (or a 302) and + directs us to authenticate ourselves with ClientLogin. + """ + for i in range(3): + credentials = self.auth_function() + try: + auth_token = self._GetAuthToken(credentials[0], credentials[1]) + except ClientLoginError as e: + print('', file=sys.stderr) + if e.reason == "BadAuthentication": + if e.info == "InvalidSecondFactor": + print(( + "Use an application-specific password instead " + "of your regular account password.\n" + "See http://www.google.com/" + "support/accounts/bin/answer.py?answer=185833"), file=sys.stderr) + else: + print("Invalid username or password.", file=sys.stderr) + elif e.reason == "CaptchaRequired": + print(( + "Please go to\n" + "https://www.google.com/accounts/DisplayUnlockCaptcha\n" + "and verify you are a human. Then try again.\n" + "If you are using a Google Apps account the URL is:\n" + "https://www.google.com/a/yourdomain.com/UnlockCaptcha"), file=sys.stderr) + elif e.reason == "NotVerified": + print("Account not verified.", file=sys.stderr) + elif e.reason == "TermsNotAgreed": + print("User has not agreed to TOS.", file=sys.stderr) + elif e.reason == "AccountDeleted": + print("The user account has been deleted.", file=sys.stderr) + elif e.reason == "AccountDisabled": + print("The user account has been disabled.", file=sys.stderr) + break + elif e.reason == "ServiceDisabled": + print(("The user's access to the service has been " + "disabled."), file=sys.stderr) + elif e.reason == "ServiceUnavailable": + print("The service is not available; try again later.", file=sys.stderr) + else: + # Unknown error. + raise + print('', file=sys.stderr) + continue + self._GetAuthCookie(auth_token) + return + + def Send(self, request_path, payload=None, + content_type="application/octet-stream", + timeout=None, + extra_headers=None, + **kwargs): + """Sends an RPC and returns the response. + + Args: + request_path: The path to send the request to, eg /api/appversion/create. + payload: The body of the request, or None to send an empty request. + content_type: The Content-Type header to use. + timeout: timeout in seconds; default None i.e. no timeout. + (Note: for large requests on OS X, the timeout doesn't work right.) + extra_headers: Dict containing additional HTTP headers that should be + included in the request (string header names mapped to their values), + or None to not include any additional headers. + kwargs: Any keyword arguments are converted into query string parameters. + + Returns: + The response body, as a string. + """ + # TODO: Don't require authentication. Let the server say + # whether it is necessary. + if not self.authenticated: + self._Authenticate() + + old_timeout = socket.getdefaulttimeout() + socket.setdefaulttimeout(timeout) + try: + tries = 0 + while True: + tries += 1 + args = dict(kwargs) + url = "%s%s" % (self.host, request_path) + if args: + url += "?" + urllib.parse.urlencode(args) + req = self._CreateRequest(url=url, data=payload) + req.add_header("Content-Type", content_type) + if extra_headers: + for header, value in list(extra_headers.items()): + req.add_header(header, value) + try: + f = self.opener.open(req) + response = f.read() + f.close() + return response + except urllib.error.HTTPError as e: + if tries > 3: + raise + elif e.code == 401 or e.code == 302: + self._Authenticate() +## elif e.code >= 500 and e.code < 600: +## # Server Error - try again. +## continue + elif e.code == 301: + # Handle permanent redirect manually. + url = e.info()["location"] + url_loc = urllib.parse.urlparse(url) + self.host = '%s://%s' % (url_loc[0], url_loc[1]) + else: + raise + finally: + socket.setdefaulttimeout(old_timeout) + + +class HttpRpcServer(AbstractRpcServer): + """Provides a simplified RPC-style interface for HTTP requests.""" + + def _Authenticate(self): + """Save the cookie jar after authentication.""" + super(HttpRpcServer, self)._Authenticate() + if self.save_cookies: + StatusUpdate("Saving authentication cookies to %s" % self.cookie_file) + self.cookie_jar.save() + + def _GetOpener(self): + """Returns an OpenerDirector that supports cookies and ignores redirects. + + Returns: + A urllib2.OpenerDirector object. + """ + opener = urllib.request.OpenerDirector() + opener.add_handler(urllib.request.ProxyHandler()) + opener.add_handler(urllib.request.UnknownHandler()) + opener.add_handler(urllib.request.HTTPHandler()) + opener.add_handler(urllib.request.HTTPDefaultErrorHandler()) + opener.add_handler(urllib.request.HTTPSHandler()) + opener.add_handler(urllib2.HTTPErrorProcessor()) + if self.save_cookies: + self.cookie_file = os.path.expanduser("~/.codereview_upload_cookies") + self.cookie_jar = http.cookiejar.MozillaCookieJar(self.cookie_file) + if os.path.exists(self.cookie_file): + try: + self.cookie_jar.load() + self.authenticated = True + StatusUpdate("Loaded authentication cookies from %s" % + self.cookie_file) + except (http.cookiejar.LoadError, IOError): + # Failed to load cookies - just ignore them. + pass + else: + # Create an empty cookie file with mode 600 + fd = os.open(self.cookie_file, os.O_CREAT, 0o600) + os.close(fd) + # Always chmod the cookie file + os.chmod(self.cookie_file, 0o600) + else: + # Don't save cookies across runs of update.py. + self.cookie_jar = http.cookiejar.CookieJar() + opener.add_handler(urllib.request.HTTPCookieProcessor(self.cookie_jar)) + return opener + + +parser = optparse.OptionParser( + usage="%prog [options] [-- diff_options] [path...]") +parser.add_option("-y", "--assume_yes", action="store_true", + dest="assume_yes", default=False, + help="Assume that the answer to yes/no questions is 'yes'.") +# Logging +group = parser.add_option_group("Logging options") +group.add_option("-q", "--quiet", action="store_const", const=0, + dest="verbose", help="Print errors only.") +group.add_option("-v", "--verbose", action="store_const", const=2, + dest="verbose", default=1, + help="Print info level logs.") +group.add_option("--noisy", action="store_const", const=3, + dest="verbose", help="Print all logs.") +# Review server +group = parser.add_option_group("Review server options") +group.add_option("-s", "--server", action="store", dest="server", + default=DEFAULT_REVIEW_SERVER, + metavar="SERVER", + help=("The server to upload to. The format is host[:port]. " + "Defaults to '%default'.")) +group.add_option("-e", "--email", action="store", dest="email", + metavar="EMAIL", default=None, + help="The username to use. Will prompt if omitted.") +group.add_option("-H", "--host", action="store", dest="host", + metavar="HOST", default=None, + help="Overrides the Host header sent with all RPCs.") +group.add_option("--no_cookies", action="store_false", + dest="save_cookies", default=True, + help="Do not save authentication cookies to local disk.") +group.add_option("--account_type", action="store", dest="account_type", + metavar="TYPE", default=AUTH_ACCOUNT_TYPE, + choices=["GOOGLE", "HOSTED"], + help=("Override the default account type " + "(defaults to '%default', " + "valid choices are 'GOOGLE' and 'HOSTED').")) +# Issue +group = parser.add_option_group("Issue options") +group.add_option("-d", "--description", action="store", dest="description", + metavar="DESCRIPTION", default=None, + help="Optional description when creating an issue.") +group.add_option("-f", "--description_file", action="store", + dest="description_file", metavar="DESCRIPTION_FILE", + default=None, + help="Optional path of a file that contains " + "the description when creating an issue.") +group.add_option("-r", "--reviewers", action="store", dest="reviewers", + metavar="REVIEWERS", default=None, + help="Add reviewers (comma separated email addresses).") +group.add_option("--cc", action="store", dest="cc", + metavar="CC", default="dev@scons.tigris.org", + help="Add CC (comma separated email addresses).") +group.add_option("--private", action="store_true", dest="private", + default=False, + help="Make the issue restricted to reviewers and those CCed") +# Upload options +group = parser.add_option_group("Patch options") +group.add_option("-m", "--message", action="store", dest="message", + metavar="MESSAGE", default=None, + help="A message to identify the patch. " + "Will prompt if omitted.") +group.add_option("-i", "--issue", type="int", action="store", + metavar="ISSUE", default=None, + help="Issue number to which to add. Defaults to new issue.") +group.add_option("--base_url", action="store", dest="base_url", default=None, + help="Base repository URL (listed as \"Base URL\" when " + "viewing issue). If omitted, will be guessed automatically " + "for SVN repos and left blank for others.") +group.add_option("--download_base", action="store_true", + dest="download_base", default=False, + help="Base files will be downloaded by the server " + "(side-by-side diffs may not work on files with CRs).") +group.add_option("--rev", action="store", dest="revision", + metavar="REV", default=None, + help="Base revision/branch/tree to diff against. Use " + "rev1:rev2 range to review already committed changeset.") +group.add_option("--send_mail", action="store_true", + dest="send_mail", default=True, + help="Send notification email to reviewers.") +group.add_option("--vcs", action="store", dest="vcs", + metavar="VCS", default="svn", + help=("Version control system (optional, usually upload.py " + "already guesses the right VCS).")) +group.add_option("--emulate_svn_auto_props", action="store_true", + dest="emulate_svn_auto_props", default=False, + help=("Emulate Subversion's auto properties feature.")) + + +def GetRpcServer(server, email=None, host_override=None, save_cookies=True, + account_type=AUTH_ACCOUNT_TYPE): + """Returns an instance of an AbstractRpcServer. + + Args: + server: String containing the review server URL. + email: String containing user's email address. + host_override: If not None, string containing an alternate hostname to use + in the host header. + save_cookies: Whether authentication cookies should be saved to disk. + account_type: Account type for authentication, either 'GOOGLE' + or 'HOSTED'. Defaults to AUTH_ACCOUNT_TYPE. + + Returns: + A new AbstractRpcServer, on which RPC calls can be made. + """ + + rpc_server_class = HttpRpcServer + + # If this is the dev_appserver, use fake authentication. + host = (host_override or server).lower() + if re.match(r'(http://)?localhost([:/]|$)', host): + if email is None: + email = "test@example.com" + logging.info("Using debug user %s. Override with --email" % email) + server = rpc_server_class( + server, + lambda: (email, "password"), + host_override=host_override, + extra_headers={"Cookie": + 'dev_appserver_login="%s:False"' % email}, + save_cookies=save_cookies, + account_type=account_type) + # Don't try to talk to ClientLogin. + server.authenticated = True + return server + + def GetUserCredentials(): + """Prompts the user for a username and password.""" + # Create a local alias to the email variable to avoid Python's crazy + # scoping rules. + local_email = email + if local_email is None: + local_email = GetEmail("Email (login for uploading to %s)" % server) + password = None + if keyring: + password = keyring.get_password(host, local_email) + if password is not None: + print("Using password from system keyring.") + else: + password = getpass.getpass("Password for %s: " % local_email) + if keyring: + answer = input("Store password in system keyring?(y/N) ").strip() + if answer == "y": + keyring.set_password(host, local_email, password) + return (local_email, password) + + return rpc_server_class(server, + GetUserCredentials, + host_override=host_override, + save_cookies=save_cookies) + + +def EncodeMultipartFormData(fields, files): + """Encode form fields for multipart/form-data. + + Args: + fields: A sequence of (name, value) elements for regular form fields. + files: A sequence of (name, filename, value) elements for data to be + uploaded as files. + Returns: + (content_type, body) ready for httplib.HTTP instance. + + Source: + http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146306 + """ + BOUNDARY = '-M-A-G-I-C---B-O-U-N-D-A-R-Y-' + CRLF = '\r\n' + lines = [] + for (key, value) in fields: + lines.append('--' + BOUNDARY) + lines.append('Content-Disposition: form-data; name="%s"' % key) + lines.append('') + if isinstance(value, str): + value = value.encode('utf-8') + lines.append(value) + for (key, filename, value) in files: + lines.append('--' + BOUNDARY) + lines.append('Content-Disposition: form-data; name="%s"; filename="%s"' % + (key, filename)) + lines.append('Content-Type: %s' % GetContentType(filename)) + lines.append('') + if isinstance(value, str): + value = value.encode('utf-8') + lines.append(value) + lines.append('--' + BOUNDARY + '--') + lines.append('') + body = CRLF.join(lines) + content_type = 'multipart/form-data; boundary=%s' % BOUNDARY + return content_type, body + + +def GetContentType(filename): + """Helper to guess the content-type from the filename.""" + return mimetypes.guess_type(filename)[0] or 'application/octet-stream' + + +# Use a shell for subcommands on Windows to get a PATH search. +use_shell = sys.platform.startswith("win") + +def RunShellWithReturnCodeAndStderr(command, print_output=False, + universal_newlines=True, + env=os.environ): + """Executes a command and returns the output from stdout, stderr and the return code. + + Args: + command: Command to execute. + print_output: If True, the output is printed to stdout. + If False, both stdout and stderr are ignored. + universal_newlines: Use universal_newlines flag (default: True). + + Returns: + Tuple (stdout, stderr, return code) + """ + logging.info("Running %s", command) + env = env.copy() + env['LC_MESSAGES'] = 'C' + p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, + shell=use_shell, universal_newlines=universal_newlines, + env=env) + if print_output: + output_array = [] + while True: + line = p.stdout.readline() + if not line: + break + print(line.strip("\n")) + output_array.append(line) + output = "".join(output_array) + else: + output = p.stdout.read() + p.wait() + errout = p.stderr.read() + if print_output and errout: + print(errout, file=sys.stderr) + p.stdout.close() + p.stderr.close() + return output, errout, p.returncode + +def RunShellWithReturnCode(command, print_output=False, + universal_newlines=True, + env=os.environ): + """Executes a command and returns the output from stdout and the return code.""" + out, err, retcode = RunShellWithReturnCodeAndStderr(command, print_output, + universal_newlines, env) + return out, retcode + +def RunShell(command, silent_ok=False, universal_newlines=True, + print_output=False, env=os.environ): + data, retcode = RunShellWithReturnCode(command, print_output, + universal_newlines, env) + if retcode: + ErrorExit("Got error status from %s:\n%s" % (command, data)) + if not silent_ok and not data: + ErrorExit("No output from %s" % command) + return data + + +class VersionControlSystem(object): + """Abstract base class providing an interface to the VCS.""" + + def __init__(self, options): + """Constructor. + + Args: + options: Command line options. + """ + self.options = options + + def PostProcessDiff(self, diff): + """Return the diff with any special post processing this VCS needs, e.g. + to include an svn-style "Index:".""" + return diff + + def GenerateDiff(self, args): + """Return the current diff as a string. + + Args: + args: Extra arguments to pass to the diff command. + """ + raise NotImplementedError( + "abstract method -- subclass %s must override" % self.__class__) + + def GetUnknownFiles(self): + """Return a list of files unknown to the VCS.""" + raise NotImplementedError( + "abstract method -- subclass %s must override" % self.__class__) + + def CheckForUnknownFiles(self): + """Show an "are you sure?" prompt if there are unknown files.""" + unknown_files = self.GetUnknownFiles() + if unknown_files: + print("The following files are not added to version control:") + for line in unknown_files: + print(line) + prompt = "Are you sure to continue?(y/N) " + answer = input(prompt).strip() + if answer != "y": + ErrorExit("User aborted") + + def GetBaseFile(self, filename): + """Get the content of the upstream version of a file. + + Returns: + A tuple (base_content, new_content, is_binary, status) + base_content: The contents of the base file. + new_content: For text files, this is empty. For binary files, this is + the contents of the new file, since the diff output won't contain + information to reconstruct the current file. + is_binary: True iff the file is binary. + status: The status of the file. + """ + + raise NotImplementedError( + "abstract method -- subclass %s must override" % self.__class__) + + + def GetBaseFiles(self, diff): + """Helper that calls GetBase file for each file in the patch. + + Returns: + A dictionary that maps from filename to GetBaseFile's tuple. Filenames + are retrieved based on lines that start with "Index:" or + "Property changes on:". + """ + files = {} + for line in diff.splitlines(True): + if line.startswith('Index:') or line.startswith('Property changes on:'): + unused, filename = line.split(':', 1) + # On Windows if a file has property changes its filename uses '\' + # instead of '/'. + filename = filename.strip().replace('\\', '/') + files[filename] = self.GetBaseFile(filename) + return files + + + def UploadBaseFiles(self, issue, rpc_server, patch_list, patchset, options, + files): + """Uploads the base files (and if necessary, the current ones as well).""" + + def UploadFile(filename, file_id, content, is_binary, status, is_base): + """Uploads a file to the server.""" + file_too_large = False + if is_base: + type = "base" + else: + type = "current" + if len(content) > MAX_UPLOAD_SIZE: + print(("Not uploading the %s file for %s because it's too large." % + (type, filename))) + file_too_large = True + content = "" + checksum = md5(content).hexdigest() + if options.verbose > 0 and not file_too_large: + print("Uploading %s file for %s" % (type, filename)) + url = "/%d/upload_content/%d/%d" % (int(issue), int(patchset), file_id) + form_fields = [("filename", filename), + ("status", status), + ("checksum", checksum), + ("is_binary", str(is_binary)), + ("is_current", str(not is_base)), + ] + if file_too_large: + form_fields.append(("file_too_large", "1")) + if options.email: + form_fields.append(("user", options.email)) + ctype, body = EncodeMultipartFormData(form_fields, + [("data", filename, content)]) + response_body = rpc_server.Send(url, body, + content_type=ctype) + if not response_body.startswith("OK"): + StatusUpdate(" --> %s" % response_body) + sys.exit(1) + + patches = dict() + [patches.setdefault(v, k) for k, v in patch_list] + for filename in list(patches.keys()): + base_content, new_content, is_binary, status = files[filename] + file_id_str = patches.get(filename) + if file_id_str.find("nobase") != -1: + base_content = None + file_id_str = file_id_str[file_id_str.rfind("_") + 1:] + file_id = int(file_id_str) + if base_content != None: + UploadFile(filename, file_id, base_content, is_binary, status, True) + if new_content != None: + UploadFile(filename, file_id, new_content, is_binary, status, False) + + def IsImage(self, filename): + """Returns true if the filename has an image extension.""" + mimetype = mimetypes.guess_type(filename)[0] + if not mimetype: + return False + return mimetype.startswith("image/") + + def IsBinary(self, filename): + """Returns true if the guessed mimetyped isnt't in text group.""" + mimetype = mimetypes.guess_type(filename)[0] + if not mimetype: + return False # e.g. README, "real" binaries usually have an extension + # special case for text files which don't start with text/ + if mimetype in TEXT_MIMETYPES: + return False + return not mimetype.startswith("text/") + + +class SubversionVCS(VersionControlSystem): + """Implementation of the VersionControlSystem interface for Subversion.""" + + def __init__(self, options): + super(SubversionVCS, self).__init__(options) + if self.options.revision: + match = re.match(r"(\d+)(:(\d+))?", self.options.revision) + if not match: + ErrorExit("Invalid Subversion revision %s." % self.options.revision) + self.rev_start = match.group(1) + self.rev_end = match.group(3) + else: + self.rev_start = self.rev_end = None + # Cache output from "svn list -r REVNO dirname". + # Keys: dirname, Values: 2-tuple (ouput for start rev and end rev). + self.svnls_cache = {} + # Base URL is required to fetch files deleted in an older revision. + # Result is cached to not guess it over and over again in GetBaseFile(). + required = self.options.download_base or self.options.revision is not None + self.svn_base = self._GuessBase(required) + + def GuessBase(self, required): + """Wrapper for _GuessBase.""" + return self.svn_base + + def _GuessBase(self, required): + """Returns base URL for current diff. + + Args: + required: If true, exits if the url can't be guessed, otherwise None is + returned. + """ + info = RunShell(["svn", "info"]) + for line in info.splitlines(): + if line.startswith("URL: "): + url = line.split()[1] + scheme, netloc, path, params, query, fragment = urllib.parse.urlparse(url) + guess = "" + if netloc == "svn.python.org" and scheme == "svn+ssh": + path = "projects" + path + scheme = "http" + guess = "Python " + elif netloc.endswith(".googlecode.com"): + scheme = "http" + guess = "Google Code " + path = path + "/" + base = urllib.parse.urlunparse((scheme, netloc, path, params, + query, fragment)) + logging.info("Guessed %sbase = %s", guess, base) + return base + if required: + ErrorExit("Can't find URL in output from svn info") + return None + + def GenerateDiff(self, args): + cmd = ["svn", "diff"] + if self.options.revision: + cmd += ["-r", self.options.revision] + cmd.extend(args) + data = RunShell(cmd) + count = 0 + for line in data.splitlines(): + if line.startswith("Index:") or line.startswith("Property changes on:"): + count += 1 + logging.info(line) + if not count: + ErrorExit("No valid patches found in output from svn diff") + return data + + def _CollapseKeywords(self, content, keyword_str): + """Collapses SVN keywords.""" + # svn cat translates keywords but svn diff doesn't. As a result of this + # behavior patching.PatchChunks() fails with a chunk mismatch error. + # This part was originally written by the Review Board development team + # who had the same problem (http://reviews.review-board.org/r/276/). + # Mapping of keywords to known aliases + svn_keywords = { + # Standard keywords + 'Date': ['Date', 'LastChangedDate'], + 'Revision': ['Revision', 'LastChangedRevision', 'Rev'], + 'Author': ['Author', 'LastChangedBy'], + 'HeadURL': ['HeadURL', 'URL'], + 'Id': ['Id'], + + # Aliases + 'LastChangedDate': ['LastChangedDate', 'Date'], + 'LastChangedRevision': ['LastChangedRevision', 'Rev', 'Revision'], + 'LastChangedBy': ['LastChangedBy', 'Author'], + 'URL': ['URL', 'HeadURL'], + } + + def repl(m): + if m.group(2): + return "$%s::%s$" % (m.group(1), " " * len(m.group(3))) + return "$%s$" % m.group(1) + keywords = [keyword + for name in keyword_str.split(" ") + for keyword in svn_keywords.get(name, [])] + return re.sub(r"\$(%s):(:?)([^\$]+)\$" % '|'.join(keywords), repl, content) + + def GetUnknownFiles(self): + status = RunShell(["svn", "status", "--ignore-externals"], silent_ok=True) + unknown_files = [] + for line in status.split("\n"): + if line and line[0] == "?": + unknown_files.append(line) + return unknown_files + + def ReadFile(self, filename): + """Returns the contents of a file.""" + file = open(filename, 'rb') + result = "" + try: + result = file.read() + finally: + file.close() + return result + + def GetStatus(self, filename): + """Returns the status of a file.""" + if not self.options.revision: + status = RunShell(["svn", "status", "--ignore-externals", filename]) + if not status: + ErrorExit("svn status returned no output for %s" % filename) + status_lines = status.splitlines() + # If file is in a cl, the output will begin with + # "\n--- Changelist 'cl_name':\n". See + # http://svn.collab.net/repos/svn/trunk/notes/changelist-design.txt + if (len(status_lines) == 3 and + not status_lines[0] and + status_lines[1].startswith("--- Changelist")): + status = status_lines[2] + else: + status = status_lines[0] + # If we have a revision to diff against we need to run "svn list" + # for the old and the new revision and compare the results to get + # the correct status for a file. + else: + dirname, relfilename = os.path.split(filename) + if dirname not in self.svnls_cache: + cmd = ["svn", "list", "-r", self.rev_start, dirname or "."] + out, err, returncode = RunShellWithReturnCodeAndStderr(cmd) + if returncode: + # Directory might not yet exist at start revison + # svn: Unable to find repository location for 'abc' in revision nnn + if re.match('^svn: Unable to find repository location for .+ in revision \d+', err): + old_files = () + else: + ErrorExit("Failed to get status for %s:\n%s" % (filename, err)) + else: + old_files = out.splitlines() + args = ["svn", "list"] + if self.rev_end: + args += ["-r", self.rev_end] + cmd = args + [dirname or "."] + out, returncode = RunShellWithReturnCode(cmd) + if returncode: + ErrorExit("Failed to run command %s" % cmd) + self.svnls_cache[dirname] = (old_files, out.splitlines()) + old_files, new_files = self.svnls_cache[dirname] + if relfilename in old_files and relfilename not in new_files: + status = "D " + elif relfilename in old_files and relfilename in new_files: + status = "M " + else: + status = "A " + return status + + def GetBaseFile(self, filename): + status = self.GetStatus(filename) + base_content = None + new_content = None + + # If a file is copied its status will be "A +", which signifies + # "addition-with-history". See "svn st" for more information. We need to + # upload the original file or else diff parsing will fail if the file was + # edited. + if status[0] == "A" and status[3] != "+": + # We'll need to upload the new content if we're adding a binary file + # since diff's output won't contain it. + mimetype = RunShell(["svn", "propget", "svn:mime-type", filename], + silent_ok=True) + base_content = "" + is_binary = bool(mimetype) and not mimetype.startswith("text/") + if is_binary and self.IsImage(filename): + new_content = self.ReadFile(filename) + elif (status[0] in ("M", "D", "R") or + (status[0] == "A" and status[3] == "+") or # Copied file. + (status[0] == " " and status[1] == "M")): # Property change. + args = [] + if self.options.revision: + url = "%s/%s@%s" % (self.svn_base, filename, self.rev_start) + else: + # Don't change filename, it's needed later. + url = filename + args += ["-r", "BASE"] + cmd = ["svn"] + args + ["propget", "svn:mime-type", url] + mimetype, returncode = RunShellWithReturnCode(cmd) + if returncode: + # File does not exist in the requested revision. + # Reset mimetype, it contains an error message. + mimetype = "" + else: + mimetype = mimetype.strip() + get_base = False + is_binary = (bool(mimetype) and + not mimetype.startswith("text/") and + not mimetype in TEXT_MIMETYPES) + if status[0] == " ": + # Empty base content just to force an upload. + base_content = "" + elif is_binary: + if self.IsImage(filename): + get_base = True + if status[0] == "M": + if not self.rev_end: + new_content = self.ReadFile(filename) + else: + url = "%s/%s@%s" % (self.svn_base, filename, self.rev_end) + new_content = RunShell(["svn", "cat", url], + universal_newlines=True, silent_ok=True) + else: + base_content = "" + else: + get_base = True + + if get_base: + if is_binary: + universal_newlines = False + else: + universal_newlines = True + if self.rev_start: + # "svn cat -r REV delete_file.txt" doesn't work. cat requires + # the full URL with "@REV" appended instead of using "-r" option. + url = "%s/%s@%s" % (self.svn_base, filename, self.rev_start) + base_content = RunShell(["svn", "cat", url], + universal_newlines=universal_newlines, + silent_ok=True) + else: + base_content, ret_code = RunShellWithReturnCode( + ["svn", "cat", filename], universal_newlines=universal_newlines) + if ret_code and status[0] == "R": + # It's a replaced file without local history (see issue208). + # The base file needs to be fetched from the server. + url = "%s/%s" % (self.svn_base, filename) + base_content = RunShell(["svn", "cat", url], + universal_newlines=universal_newlines, + silent_ok=True) + elif ret_code: + ErrorExit("Got error status from 'svn cat %s'" % filename) + if not is_binary: + args = [] + if self.rev_start: + url = "%s/%s@%s" % (self.svn_base, filename, self.rev_start) + else: + url = filename + args += ["-r", "BASE"] + cmd = ["svn"] + args + ["propget", "svn:keywords", url] + keywords, returncode = RunShellWithReturnCode(cmd) + if keywords and not returncode: + base_content = self._CollapseKeywords(base_content, keywords) + else: + StatusUpdate("svn status returned unexpected output: %s" % status) + sys.exit(1) + return base_content, new_content, is_binary, status[0:5] + + +class GitVCS(VersionControlSystem): + """Implementation of the VersionControlSystem interface for Git.""" + + def __init__(self, options): + super(GitVCS, self).__init__(options) + # Map of filename -> (hash before, hash after) of base file. + # Hashes for "no such file" are represented as None. + self.hashes = {} + # Map of new filename -> old filename for renames. + self.renames = {} + + def PostProcessDiff(self, gitdiff): + """Converts the diff output to include an svn-style "Index:" line as well + as record the hashes of the files, so we can upload them along with our + diff.""" + # Special used by git to indicate "no such content". + NULL_HASH = "0"*40 + + def IsFileNew(filename): + return filename in self.hashes and self.hashes[filename][0] is None + + def AddSubversionPropertyChange(filename): + """Add svn's property change information into the patch if given file is + new file. + + We use Subversion's auto-props setting to retrieve its property. + See http://svnbook.red-bean.com/en/1.1/ch07.html#svn-ch-7-sect-1.3.2 for + Subversion's [auto-props] setting. + """ + if self.options.emulate_svn_auto_props and IsFileNew(filename): + svnprops = GetSubversionPropertyChanges(filename) + if svnprops: + svndiff.append("\n" + svnprops + "\n") + + svndiff = [] + filecount = 0 + filename = None + for line in gitdiff.splitlines(): + match = re.match(r"diff --git a/(.*) b/(.*)$", line) + if match: + # Add auto property here for previously seen file. + if filename is not None: + AddSubversionPropertyChange(filename) + filecount += 1 + # Intentionally use the "after" filename so we can show renames. + filename = match.group(2) + svndiff.append("Index: %s\n" % filename) + if match.group(1) != match.group(2): + self.renames[match.group(2)] = match.group(1) + else: + # The "index" line in a git diff looks like this (long hashes elided): + # index 82c0d44..b2cee3f 100755 + # We want to save the left hash, as that identifies the base file. + match = re.match(r"index (\w+)\.\.(\w+)", line) + if match: + before, after = (match.group(1), match.group(2)) + if before == NULL_HASH: + before = None + if after == NULL_HASH: + after = None + self.hashes[filename] = (before, after) + svndiff.append(line + "\n") + if not filecount: + ErrorExit("No valid patches found in output from git diff") + # Add auto property for the last seen file. + assert filename is not None + AddSubversionPropertyChange(filename) + return "".join(svndiff) + + def GenerateDiff(self, extra_args): + extra_args = extra_args[:] + if self.options.revision: + if ":" in self.options.revision: + extra_args = self.options.revision.split(":", 1) + extra_args + else: + extra_args = [self.options.revision] + extra_args + + # --no-ext-diff is broken in some versions of Git, so try to work around + # this by overriding the environment (but there is still a problem if the + # git config key "diff.external" is used). + env = os.environ.copy() + if 'GIT_EXTERNAL_DIFF' in env: del env['GIT_EXTERNAL_DIFF'] + return RunShell(["git", "diff", "--no-ext-diff", "--full-index", "-M"] + + extra_args, env=env) + + def GetUnknownFiles(self): + status = RunShell(["git", "ls-files", "--exclude-standard", "--others"], + silent_ok=True) + return status.splitlines() + + def GetFileContent(self, file_hash, is_binary): + """Returns the content of a file identified by its git hash.""" + data, retcode = RunShellWithReturnCode(["git", "show", file_hash], + universal_newlines=not is_binary) + if retcode: + ErrorExit("Got error status from 'git show %s'" % file_hash) + return data + + def GetBaseFile(self, filename): + hash_before, hash_after = self.hashes.get(filename, (None,None)) + base_content = None + new_content = None + is_binary = self.IsBinary(filename) + status = None + + if filename in self.renames: + status = "A +" # Match svn attribute name for renames. + if filename not in self.hashes: + # If a rename doesn't change the content, we never get a hash. + base_content = RunShell(["git", "show", "HEAD:" + filename]) + elif not hash_before: + status = "A" + base_content = "" + elif not hash_after: + status = "D" + else: + status = "M" + + is_image = self.IsImage(filename) + + # Grab the before/after content if we need it. + # We should include file contents if it's text or it's an image. + if not is_binary or is_image: + # Grab the base content if we don't have it already. + if base_content is None and hash_before: + base_content = self.GetFileContent(hash_before, is_binary) + # Only include the "after" file if it's an image; otherwise it + # it is reconstructed from the diff. + if is_image and hash_after: + new_content = self.GetFileContent(hash_after, is_binary) + + return (base_content, new_content, is_binary, status) + + +class MercurialVCS(VersionControlSystem): + """Implementation of the VersionControlSystem interface for Mercurial.""" + + def __init__(self, options, repo_dir): + super(MercurialVCS, self).__init__(options) + # Absolute path to repository (we can be in a subdir) + self.repo_dir = os.path.normpath(repo_dir) + # Compute the subdir + cwd = os.path.normpath(os.getcwd()) + assert cwd.startswith(self.repo_dir) + self.subdir = cwd[len(self.repo_dir):].lstrip(r"\/") + if self.options.revision: + self.base_rev = self.options.revision + else: + self.base_rev = RunShell(["hg", "parent", "-q"]).split(':')[1].strip() + + def _GetRelPath(self, filename): + """Get relative path of a file according to the current directory, + given its logical path in the repo.""" + assert filename.startswith(self.subdir), (filename, self.subdir) + return filename[len(self.subdir):].lstrip(r"\/") + + def GenerateDiff(self, extra_args): + cmd = ["hg", "diff", "--git", "-r", self.base_rev] + extra_args + data = RunShell(cmd, silent_ok=True) + svndiff = [] + filecount = 0 + for line in data.splitlines(): + m = re.match("diff --git a/(\S+) b/(\S+)", line) + if m: + # Modify line to make it look like as it comes from svn diff. + # With this modification no changes on the server side are required + # to make upload.py work with Mercurial repos. + # NOTE: for proper handling of moved/copied files, we have to use + # the second filename. + filename = m.group(2) + svndiff.append("Index: %s" % filename) + svndiff.append("=" * 67) + filecount += 1 + logging.info(line) + else: + svndiff.append(line) + if not filecount: + ErrorExit("No valid patches found in output from hg diff") + return "\n".join(svndiff) + "\n" + + def GetUnknownFiles(self): + """Return a list of files unknown to the VCS.""" + args = [] + status = RunShell(["hg", "status", "--rev", self.base_rev, "-u", "."], + silent_ok=True) + unknown_files = [] + for line in status.splitlines(): + st, fn = line.split(" ", 1) + if st == "?": + unknown_files.append(fn) + return unknown_files + + def GetBaseFile(self, filename): + # "hg status" and "hg cat" both take a path relative to the current subdir + # rather than to the repo root, but "hg diff" has given us the full path + # to the repo root. + base_content = "" + new_content = None + is_binary = False + oldrelpath = relpath = self._GetRelPath(filename) + # "hg status -C" returns two lines for moved/copied files, one otherwise + out = RunShell(["hg", "status", "-C", "--rev", self.base_rev, relpath]) + out = out.splitlines() + # HACK: strip error message about missing file/directory if it isn't in + # the working copy + if out[0].startswith('%s: ' % relpath): + out = out[1:] + status, _ = out[0].split(' ', 1) + if len(out) > 1 and status == "A": + # Moved/copied => considered as modified, use old filename to + # retrieve base contents + oldrelpath = out[1].strip() + status = "M" + if ":" in self.base_rev: + base_rev = self.base_rev.split(":", 1)[0] + else: + base_rev = self.base_rev + if status != "A": + base_content = RunShell(["hg", "cat", "-r", base_rev, oldrelpath], + silent_ok=True) + is_binary = "\0" in base_content # Mercurial's heuristic + if status != "R": + new_content = open(relpath, "rb").read() + is_binary = is_binary or "\0" in new_content + if is_binary and base_content: + # Fetch again without converting newlines + base_content = RunShell(["hg", "cat", "-r", base_rev, oldrelpath], + silent_ok=True, universal_newlines=False) + if not is_binary or not self.IsImage(relpath): + new_content = None + return base_content, new_content, is_binary, status + + +# NOTE: The SplitPatch function is duplicated in engine.py, keep them in sync. +def SplitPatch(data): + """Splits a patch into separate pieces for each file. + + Args: + data: A string containing the output of svn diff. + + Returns: + A list of 2-tuple (filename, text) where text is the svn diff output + pertaining to filename. + """ + patches = [] + filename = None + diff = [] + for line in data.splitlines(True): + new_filename = None + if line.startswith('Index:'): + unused, new_filename = line.split(':', 1) + new_filename = new_filename.strip() + elif line.startswith('Property changes on:'): + unused, temp_filename = line.split(':', 1) + # When a file is modified, paths use '/' between directories, however + # when a property is modified '\' is used on Windows. Make them the same + # otherwise the file shows up twice. + temp_filename = temp_filename.strip().replace('\\', '/') + if temp_filename != filename: + # File has property changes but no modifications, create a new diff. + new_filename = temp_filename + if new_filename: + if filename and diff: + patches.append((filename, ''.join(diff))) + filename = new_filename + diff = [line] + continue + if diff is not None: + diff.append(line) + if filename and diff: + patches.append((filename, ''.join(diff))) + return patches + + +def UploadSeparatePatches(issue, rpc_server, patchset, data, options): + """Uploads a separate patch for each file in the diff output. + + Returns a list of [patch_key, filename] for each file. + """ + patches = SplitPatch(data) + rv = [] + for patch in patches: + if len(patch[1]) > MAX_UPLOAD_SIZE: + print(("Not uploading the patch for " + patch[0] + + " because the file is too large.")) + continue + form_fields = [("filename", patch[0])] + if not options.download_base: + form_fields.append(("content_upload", "1")) + files = [("data", "data.diff", patch[1])] + ctype, body = EncodeMultipartFormData(form_fields, files) + url = "/%d/upload_patch/%d" % (int(issue), int(patchset)) + print("Uploading patch for " + patch[0]) + response_body = rpc_server.Send(url, body, content_type=ctype) + lines = response_body.splitlines() + if not lines or lines[0] != "OK": + StatusUpdate(" --> %s" % response_body) + sys.exit(1) + rv.append([lines[1], patch[0]]) + return rv + + +def GuessVCSName(): + """Helper to guess the version control system. + + This examines the current directory, guesses which VersionControlSystem + we're using, and returns an string indicating which VCS is detected. + + Returns: + A pair (vcs, output). vcs is a string indicating which VCS was detected + and is one of VCS_GIT, VCS_MERCURIAL, VCS_SUBVERSION, or VCS_UNKNOWN. + output is a string containing any interesting output from the vcs + detection routine, or None if there is nothing interesting. + """ + def RunDetectCommand(vcs_type, command): + """Helper to detect VCS by executing command. + + Returns: + A pair (vcs, output) or None. Throws exception on error. + """ + try: + out, returncode = RunShellWithReturnCode(command) + if returncode == 0: + return (vcs_type, out.strip()) + except OSError as xxx_todo_changeme: + (errcode, message) = xxx_todo_changeme.args + if errcode != errno.ENOENT: # command not found code + raise + + # Mercurial has a command to get the base directory of a repository + # Try running it, but don't die if we don't have hg installed. + # NOTE: we try Mercurial first as it can sit on top of an SVN working copy. + res = RunDetectCommand(VCS_MERCURIAL, ["hg", "root"]) + if res != None: + return res + + # Subversion has a .svn in all working directories. + if os.path.isdir('.svn'): + logging.info("Guessed VCS = Subversion") + return (VCS_SUBVERSION, None) + + # Git has a command to test if you're in a git tree. + # Try running it, but don't die if we don't have git installed. + res = RunDetectCommand(VCS_GIT, ["git", "rev-parse", + "--is-inside-work-tree"]) + if res != None: + return res + + return (VCS_UNKNOWN, None) + + +def GuessVCS(options): + """Helper to guess the version control system. + + This verifies any user-specified VersionControlSystem (by command line + or environment variable). If the user didn't specify one, this examines + the current directory, guesses which VersionControlSystem we're using, + and returns an instance of the appropriate class. Exit with an error + if we can't figure it out. + + Returns: + A VersionControlSystem instance. Exits if the VCS can't be guessed. + """ + vcs = options.vcs + if not vcs: + vcs = os.environ.get("CODEREVIEW_VCS") + if vcs: + v = VCS_ABBREVIATIONS.get(vcs.lower()) + if v is None: + ErrorExit("Unknown version control system %r specified." % vcs) + (vcs, extra_output) = (v, None) + else: + (vcs, extra_output) = GuessVCSName() + + if vcs == VCS_MERCURIAL: + if extra_output is None: + extra_output = RunShell(["hg", "root"]).strip() + return MercurialVCS(options, extra_output) + elif vcs == VCS_SUBVERSION: + return SubversionVCS(options) + elif vcs == VCS_GIT: + return GitVCS(options) + + ErrorExit(("Could not guess version control system. " + "Are you in a working copy directory?")) + + +def CheckReviewer(reviewer): + """Validate a reviewer -- either a nickname or an email addres. + + Args: + reviewer: A nickname or an email address. + + Calls ErrorExit() if it is an invalid email address. + """ + if "@" not in reviewer: + return # Assume nickname + parts = reviewer.split("@") + if len(parts) > 2: + ErrorExit("Invalid email address: %r" % reviewer) + assert len(parts) == 2 + if "." not in parts[1]: + ErrorExit("Invalid email address: %r" % reviewer) + + +def LoadSubversionAutoProperties(): + """Returns the content of [auto-props] section of Subversion's config file as + a dictionary. + + Returns: + A dictionary whose key-value pair corresponds the [auto-props] section's + key-value pair. + In following cases, returns empty dictionary: + - config file doesn't exist, or + - 'enable-auto-props' is not set to 'true-like-value' in [miscellany]. + """ + if os.name == 'nt': + subversion_config = os.environ.get("APPDATA") + "\\Subversion\\config" + else: + subversion_config = os.path.expanduser("~/.subversion/config") + if not os.path.exists(subversion_config): + return {} + config = configparser.ConfigParser() + config.read(subversion_config) + if (config.has_section("miscellany") and + config.has_option("miscellany", "enable-auto-props") and + config.getboolean("miscellany", "enable-auto-props") and + config.has_section("auto-props")): + props = {} + for file_pattern in config.options("auto-props"): + props[file_pattern] = ParseSubversionPropertyValues( + config.get("auto-props", file_pattern)) + return props + else: + return {} + +def ParseSubversionPropertyValues(props): + """Parse the given property value which comes from [auto-props] section and + returns a list whose element is a (svn_prop_key, svn_prop_value) pair. + + See the following doctest for example. + + >>> ParseSubversionPropertyValues('svn:eol-style=LF') + [('svn:eol-style', 'LF')] + >>> ParseSubversionPropertyValues('svn:mime-type=image/jpeg') + [('svn:mime-type', 'image/jpeg')] + >>> ParseSubversionPropertyValues('svn:eol-style=LF;svn:executable') + [('svn:eol-style', 'LF'), ('svn:executable', '*')] + """ + key_value_pairs = [] + for prop in props.split(";"): + key_value = prop.split("=") + assert len(key_value) <= 2 + if len(key_value) == 1: + # If value is not given, use '*' as a Subversion's convention. + key_value_pairs.append((key_value[0], "*")) + else: + key_value_pairs.append((key_value[0], key_value[1])) + return key_value_pairs + + +def GetSubversionPropertyChanges(filename): + """Return a Subversion's 'Property changes on ...' string, which is used in + the patch file. + + Args: + filename: filename whose property might be set by [auto-props] config. + + Returns: + A string like 'Property changes on |filename| ...' if given |filename| + matches any entries in [auto-props] section. None, otherwise. + """ + global svn_auto_props_map + if svn_auto_props_map is None: + svn_auto_props_map = LoadSubversionAutoProperties() + + all_props = [] + for file_pattern, props in list(svn_auto_props_map.items()): + if fnmatch.fnmatch(filename, file_pattern): + all_props.extend(props) + if all_props: + return FormatSubversionPropertyChanges(filename, all_props) + return None + + +def FormatSubversionPropertyChanges(filename, props): + """Returns Subversion's 'Property changes on ...' strings using given filename + and properties. + + Args: + filename: filename + props: A list whose element is a (svn_prop_key, svn_prop_value) pair. + + Returns: + A string which can be used in the patch file for Subversion. + + See the following doctest for example. + + >>> print FormatSubversionPropertyChanges('foo.cc', [('svn:eol-style', 'LF')]) + Property changes on: foo.cc + ___________________________________________________________________ + Added: svn:eol-style + + LF + + """ + prop_changes_lines = [ + "Property changes on: %s" % filename, + "___________________________________________________________________"] + for key, value in props: + prop_changes_lines.append("Added: " + key) + prop_changes_lines.append(" + " + value) + return "\n".join(prop_changes_lines) + "\n" + + +def RealMain(argv, data=None): + """The real main function. + + Args: + argv: Command line arguments. + data: Diff contents. If None (default) the diff is generated by + the VersionControlSystem implementation returned by GuessVCS(). + + Returns: + A 2-tuple (issue id, patchset id). + The patchset id is None if the base files are not uploaded by this + script (applies only to SVN checkouts). + """ + options, args = parser.parse_args(argv[1:]) + global verbosity + verbosity = options.verbose + if verbosity >= 3: + logging.getLogger().setLevel(logging.DEBUG) + elif verbosity >= 2: + logging.getLogger().setLevel(logging.INFO) + + vcs = GuessVCS(options) + + base = options.base_url + if isinstance(vcs, SubversionVCS): + # Guessing the base field is only supported for Subversion. + # Note: Fetching base files may become deprecated in future releases. + guessed_base = vcs.GuessBase(options.download_base) + if base: + if guessed_base and base != guessed_base: + print("Using base URL \"%s\" from --base_url instead of \"%s\"" % \ + (base, guessed_base)) + else: + base = guessed_base + + if not base and options.download_base: + options.download_base = True + logging.info("Enabled upload of base file") + if not options.assume_yes: + vcs.CheckForUnknownFiles() + if data is None: + data = vcs.GenerateDiff(args) + data = vcs.PostProcessDiff(data) + files = vcs.GetBaseFiles(data) + if verbosity >= 1: + print("Upload server:", options.server, "(change with -s/--server)") + if options.issue: + prompt = "Message describing this patch set: " + else: + prompt = "New issue subject: " + message = options.message or input(prompt).strip() + if not message: + ErrorExit("A non-empty message is required") + rpc_server = GetRpcServer(options.server, + options.email, + options.host, + options.save_cookies, + options.account_type) + form_fields = [("subject", message)] + if base: + b = urllib.parse.urlparse(base) + username, netloc = urllib.parse.splituser(b.netloc) + if username: + logging.info("Removed username from base URL") + base = urllib.parse.urlunparse((b.scheme, netloc, b.path, b.params, + b.query, b.fragment)) + form_fields.append(("base", base)) + if options.issue: + form_fields.append(("issue", str(options.issue))) + if options.email: + form_fields.append(("user", options.email)) + if options.reviewers: + for reviewer in options.reviewers.split(','): + CheckReviewer(reviewer) + form_fields.append(("reviewers", options.reviewers)) + if options.cc: + for cc in options.cc.split(','): + CheckReviewer(cc) + form_fields.append(("cc", options.cc)) + description = options.description + if options.description_file: + if options.description: + ErrorExit("Can't specify description and description_file") + file = open(options.description_file, 'r') + description = file.read() + file.close() + if description: + form_fields.append(("description", description)) + # Send a hash of all the base file so the server can determine if a copy + # already exists in an earlier patchset. + base_hashes = "" + for file, info in files.items(): + if not info[0] is None: + checksum = md5(info[0]).hexdigest() + if base_hashes: + base_hashes += "|" + base_hashes += checksum + ":" + file + form_fields.append(("base_hashes", base_hashes)) + if options.private: + if options.issue: + print("Warning: Private flag ignored when updating an existing issue.") + else: + form_fields.append(("private", "1")) + # If we're uploading base files, don't send the email before the uploads, so + # that it contains the file status. + if options.send_mail and options.download_base: + form_fields.append(("send_mail", "1")) + if not options.download_base: + form_fields.append(("content_upload", "1")) + if len(data) > MAX_UPLOAD_SIZE: + print("Patch is large, so uploading file patches separately.") + uploaded_diff_file = [] + form_fields.append(("separate_patches", "1")) + else: + uploaded_diff_file = [("data", "data.diff", data)] + ctype, body = EncodeMultipartFormData(form_fields, uploaded_diff_file) + response_body = rpc_server.Send("/upload", body, content_type=ctype) + patchset = None + if not options.download_base or not uploaded_diff_file: + lines = response_body.splitlines() + if len(lines) >= 2: + msg = lines[0] + patchset = lines[1].strip() + patches = [x.split(" ", 1) for x in lines[2:]] + else: + msg = response_body + else: + msg = response_body + StatusUpdate(msg) + if not response_body.startswith("Issue created.") and \ + not response_body.startswith("Issue updated."): + sys.exit(0) + issue = msg[msg.rfind("/")+1:] + + if not uploaded_diff_file: + result = UploadSeparatePatches(issue, rpc_server, patchset, data, options) + if not options.download_base: + patches = result + + if not options.download_base: + vcs.UploadBaseFiles(issue, rpc_server, patches, patchset, options, files) + if options.send_mail: + rpc_server.Send("/" + issue + "/mail", payload="") + return issue, patchset + + +def main(): + try: + logging.basicConfig(format=("%(asctime).19s %(levelname)s %(filename)s:" + "%(lineno)s %(message)s ")) + os.environ['LC_ALL'] = 'C' + RealMain(sys.argv) + except KeyboardInterrupt: + print() + StatusUpdate("Interrupted.") + sys.exit(1) + + +if __name__ == "__main__": + main() + diff --git a/runtest.py b/runtest.py index 6beb4ba..65d7851 100755 --- a/runtest.py +++ b/runtest.py @@ -92,10 +92,10 @@ import time try: import threading - import Queue # 2to3: rename to queue + import queue # 2to3: rename to queue threading_ok = True except ImportError: - print "Can't import threading or queue" + print("Can't import threading or queue") threading_ok = False cwd = os.getcwd() @@ -187,12 +187,12 @@ class PassThroughOptionParser(OptionParser): def _process_long_opt(self, rargs, values): try: OptionParser._process_long_opt(self, rargs, values) - except BadOptionError, err: + except BadOptionError as err: self.largs.append(err.opt_str) def _process_short_opts(self, rargs, values): try: OptionParser._process_short_opts(self, rargs, values) - except BadOptionError, err: + except BadOptionError as err: self.largs.append(err.opt_str) parser = PassThroughOptionParser(add_help_option=False) @@ -240,7 +240,7 @@ for o, a in opts: a = os.path.join(cwd, a) testlistfile = a elif o in ['-h', '--help']: - print helpstr + print(helpstr) sys.exit(0) elif o in ['-j', '--jobs']: jobs = int(a) @@ -343,7 +343,7 @@ else: st = os.stat(f) except OSError: continue - if stat.S_IMODE(st[stat.ST_MODE]) & 0111: + if stat.S_IMODE(st[stat.ST_MODE]) & 0o111: return f return None @@ -590,7 +590,7 @@ else: base = os.path.join(base, os.path.split(url)[1]) if printcommand: - print command + print(command) if execute_tests: os.system(command) else: @@ -843,9 +843,9 @@ def run_test(t, io_lock, async=True): if suppress_stdout or suppress_stderr: sys.stdout.write(header) if not suppress_stdout and t.stdout: - print t.stdout + print(t.stdout) if not suppress_stderr and t.stderr: - print t.stderr + print(t.stderr) print_time_func("Test execution time: %.1f seconds\n", t.test_time) if io_lock: io_lock.release() @@ -863,9 +863,9 @@ class RunTest(threading.Thread): self.queue.task_done() if jobs > 1 and threading_ok: - print "Running tests using %d jobs"%jobs + print("Running tests using %d jobs"%jobs) # Start worker threads - queue = Queue.Queue() + queue = queue.Queue() io_lock = threading.Lock() for i in range(1, jobs): t = RunTest(queue, io_lock) @@ -878,7 +878,7 @@ if jobs > 1 and threading_ok: else: # Run tests serially if jobs > 1: - print "Ignoring -j%d option; no python threading module available."%jobs + print("Ignoring -j%d option; no python threading module available."%jobs) for t in tests: run_test(t, None, False) diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index c1eef75..e8574cb 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -114,6 +114,7 @@ import SCons.Errors import SCons.Executor import SCons.Util import SCons.Subst +import collections # we use these a lot, so try to optimize them is_String = SCons.Util.is_String @@ -165,12 +166,12 @@ def _callable_contents(obj): """ try: # Test if obj is a method. - return _function_contents(obj.im_func) + return _function_contents(obj.__func__) except AttributeError: try: # Test if obj is a callable object. - return _function_contents(obj.__call__.im_func) + return _function_contents(obj.__call__.__func__) except AttributeError: try: @@ -190,12 +191,12 @@ def _object_contents(obj): """ try: # Test if obj is a method. - return _function_contents(obj.im_func) + return _function_contents(obj.__func__) except AttributeError: try: # Test if obj is a callable object. - return _function_contents(obj.__call__.im_func) + return _function_contents(obj.__call__.__func__) except AttributeError: try: @@ -269,17 +270,17 @@ def _code_contents(code): def _function_contents(func): """Return the signature contents of a function.""" - contents = [_code_contents(func.func_code)] + contents = [_code_contents(func.__code__)] # The function contents depends on the value of defaults arguments - if func.func_defaults: - contents.append(',(' + ','.join(map(_object_contents,func.func_defaults)) + ')') + if func.__defaults__: + contents.append(',(' + ','.join(map(_object_contents,func.__defaults__)) + ')') else: contents.append(',()') # The function contents depends on the closure captured cell values. try: - closure = func.func_closure or [] + closure = func.__closure__ or [] except AttributeError: # Older versions of Python do not support closures. closure = [] @@ -328,7 +329,7 @@ def _do_create_keywords(args, kw): cmdstrfunc = args[0] if cmdstrfunc is None or is_String(cmdstrfunc): kw['cmdstr'] = cmdstrfunc - elif callable(cmdstrfunc): + elif isinstance(cmdstrfunc, collections.Callable): kw['strfunction'] = cmdstrfunc else: raise SCons.Errors.UserError( @@ -359,7 +360,7 @@ def _do_create_action(act, kw): if is_List(act): return CommandAction(act, **kw) - if callable(act): + if isinstance(act, collections.Callable): try: gen = kw['generator'] del kw['generator'] @@ -492,7 +493,7 @@ class _ActionAction(ActionBase): self.targets = targets if batch_key: - if not callable(batch_key): + if not isinstance(batch_key, collections.Callable): # They have set batch_key, but not to their own # callable. The default behavior here will batch # *all* targets+sources using this action, separated @@ -512,7 +513,7 @@ class _ActionAction(ActionBase): # This code assumes s is a regular string, but should # work if it's unicode too. try: - sys.stdout.write(unicode(s + "\n")) + sys.stdout.write(str(s + "\n")) except UnicodeDecodeError: sys.stdout.write(s + "\n") @@ -553,7 +554,7 @@ class _ActionAction(ActionBase): source = executor.get_all_sources() t = ' and '.join(map(str, target)) l = '\n '.join(self.presub_lines(env)) - out = u"Building %s with action:\n %s\n" % (t, l) + out = "Building %s with action:\n %s\n" % (t, l) sys.stdout.write(out) cmd = None if show and self.strfunction: @@ -653,7 +654,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 @@ -672,7 +673,7 @@ def _subproc(scons_env, cmd, error = 'ignore', **kw): try: return subprocess.Popen(cmd, **kw) - except EnvironmentError, e: + except EnvironmentError as e: if error == 'raise': raise # return a dummy Popen instance that only returns error class dummyPopen(object): @@ -779,7 +780,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 @@ -1038,7 +1039,7 @@ class FunctionAction(_ActionAction): else: if strfunc is None: return None - if callable(strfunc): + if isinstance(strfunc, collections.Callable): return strfunc(target, source, env) name = self.function_name() tstr = array(target) @@ -1060,11 +1061,11 @@ class FunctionAction(_ActionAction): rsources = list(map(rfile, source)) try: result = self.execfunction(target=target, source=rsources, env=env) - except KeyboardInterrupt, e: + except KeyboardInterrupt as e: raise - except SystemExit, e: + except SystemExit as e: raise - except Exception, e: + except Exception as e: result = e exc_info = sys.exc_info() @@ -1179,11 +1180,11 @@ class ActionCaller(object): actfunc = self.parent.actfunc try: # "self.actfunc" is a function. - contents = str(actfunc.func_code.co_code) + contents = str(actfunc.__code__.co_code) except AttributeError: # "self.actfunc" is a callable object. try: - contents = str(actfunc.__call__.im_func.func_code.co_code) + contents = str(actfunc.__call__.__func__.__code__.co_code) except AttributeError: # No __call__() method, so it might be a builtin # or something like that. Do the best we can. @@ -1214,7 +1215,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 13c3b6c..6edf373 100644 --- a/src/engine/SCons/ActionTests.py +++ b/src/engine/SCons/ActionTests.py @@ -133,7 +133,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): @@ -158,12 +158,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__'] @@ -270,7 +270,7 @@ def test_positional_args(pos_callback, cmd, **kw): try: #FUTURE a = SCons.Action.Action(cmd, [], **kw) a = SCons.Action.Action(cmd, [], **kw) - except SCons.Errors.UserError, e: + except SCons.Errors.UserError as e: s = str(e) m = 'Invalid command display variable' assert s.find(m) != -1, 'Unexpected string: %s' % s @@ -305,7 +305,7 @@ class ActionTestCase(unittest.TestCase): # a singleton list returns the contained action test_positional_args(cmd_action, ["string"]) - try: unicode + try: str except NameError: pass else: a2 = eval("SCons.Action.Action(u'string')") @@ -493,7 +493,7 @@ class _ActionActionTestCase(unittest.TestCase): def func(): pass try: a = SCons.Action.Action('foo', cmdstr='string', strfunction=func) - except SCons.Errors.UserError, e: + except SCons.Errors.UserError as e: s = str(e) m = 'Cannot have both strfunction and cmdstr args to Action()' assert s.find(m) != -1, 'Unexpected string: %s' % s diff --git a/src/engine/SCons/Builder.py b/src/engine/SCons/Builder.py index 6dc9e17..6abcbcf 100644 --- a/src/engine/SCons/Builder.py +++ b/src/engine/SCons/Builder.py @@ -167,7 +167,7 @@ class DictCmdGenerator(SCons.Util.Selector): try: ret = SCons.Util.Selector.__call__(self, env, source, ext) - except KeyError, e: + except KeyError as e: raise UserError("Ambiguous suffixes after environment substitution: %s == %s == %s" % (e.args[0], e.args[1], e.args[2])) if ret is None: raise UserError("While building `%s' from `%s': Don't know how to build from a source file with suffix `%s'. Expected a suffix in this list: %s." % \ @@ -179,7 +179,7 @@ class CallableSelector(SCons.Util.Selector): finds if it can.""" def __call__(self, env, source): value = SCons.Util.Selector.__call__(self, env, source) - if callable(value): + if isinstance(value, collections.Callable): value = value(env, source) return value @@ -230,7 +230,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) @@ -336,7 +336,7 @@ class EmitterProxy(object): # in strings. Maybe we should change that? while SCons.Util.is_String(emitter) and emitter in env: emitter = env[emitter] - if callable(emitter): + if isinstance(emitter, collections.Callable): target, source = emitter(target, source, env) elif SCons.Util.is_List(emitter): for e in emitter: @@ -426,7 +426,7 @@ class BuilderBase(object): src_builder = [ src_builder ] self.src_builder = src_builder - def __nonzero__(self): + def __bool__(self): raise InternalError("Do not test for the Node.builder attribute directly; use Node.has_builder() instead") def get_name(self, env): @@ -638,18 +638,18 @@ class BuilderBase(object): def get_prefix(self, env, sources=[]): prefix = self.prefix - if callable(prefix): + if isinstance(prefix, collections.Callable): prefix = prefix(env, sources) return env.subst(prefix) def set_suffix(self, suffix): - if not callable(suffix): + if not isinstance(suffix, collections.Callable): suffix = self.adjust_suffix(suffix) self.suffix = suffix def get_suffix(self, env, sources=[]): suffix = self.suffix - if callable(suffix): + if isinstance(suffix, collections.Callable): suffix = suffix(env, sources) return env.subst(suffix) @@ -658,7 +658,7 @@ class BuilderBase(object): src_suffix = [] elif not SCons.Util.is_List(src_suffix): src_suffix = [ src_suffix ] - self.src_suffix = [callable(suf) and suf or self.adjust_suffix(suf) for suf in src_suffix] + self.src_suffix = [isinstance(suf, collections.Callable) and suf or self.adjust_suffix(suf) for suf in src_suffix] def get_src_suffix(self, env): """Get the first src_suffix in the list of src_suffixes.""" @@ -868,7 +868,7 @@ def is_a_Builder(obj): """ return (isinstance(obj, BuilderBase) or isinstance(obj, CompositeBuilder) - or callable(obj)) + or isinstance(obj, collections.Callable)) # Local Variables: # tab-width:4 diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py index 766b8fe..da03a3c 100644 --- a/src/engine/SCons/BuilderTests.py +++ b/src/engine/SCons/BuilderTests.py @@ -77,7 +77,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 @@ -138,7 +138,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__'] @@ -305,11 +305,11 @@ class BuilderTestCase(unittest.TestCase): #be = target.get_build_env() #assert be['VAR'] == 'foo', be['VAR'] - try: unicode + try: str except NameError: uni = str else: - uni = unicode + uni = str target = builder(env, target = uni('n12 n13'), source = [uni('n14 n15')])[0] @@ -325,7 +325,7 @@ class BuilderTestCase(unittest.TestCase): flag = 0 try: target = builder(env, None, source=n20) - except SCons.Errors.UserError, e: + except SCons.Errors.UserError as e: flag = 1 assert flag, "UserError should be thrown if a source node can't create a target." @@ -341,7 +341,7 @@ class BuilderTestCase(unittest.TestCase): suffix = '.s') try: builder(env, target = 'n22', source = 'n22') - except SCons.Errors.UserError, e: + except SCons.Errors.UserError as e: pass else: raise Exception("Did not catch expected UserError.") @@ -1497,7 +1497,7 @@ class CompositeBuilderTestCase(unittest.TestCase): flag = 0 try: builder(env, target='test3', source=['test2.bar', 'test1.foo'])[0] - except SCons.Errors.UserError, e: + except SCons.Errors.UserError as e: flag = 1 assert flag, "UserError should be thrown when we call a builder with files of different suffixes." expect = "While building `['test3']' from `test1.foo': Cannot build multiple sources with different extensions: .bar, .foo" @@ -1528,8 +1528,8 @@ class CompositeBuilderTestCase(unittest.TestCase): try: tgt.build() flag = 1 - except SCons.Errors.UserError, e: - print e + except SCons.Errors.UserError as e: + print(e) flag = 0 assert flag, "It should be possible to define actions in composite builders using variables." env['FOO_SUFFIX'] = '.BAR2' @@ -1581,7 +1581,7 @@ class CompositeBuilderTestCase(unittest.TestCase): flag = 0 try: builder(env, target='t5', source=['test5a.foo', 'test5b.inb'])[0] - except SCons.Errors.UserError, e: + except SCons.Errors.UserError as e: flag = 1 assert flag, "UserError should be thrown when we call a builder with files of different suffixes." expect = "While building `['t5']' from `test5b.bar': Cannot build multiple sources with different extensions: .foo, .bar" @@ -1590,7 +1590,7 @@ class CompositeBuilderTestCase(unittest.TestCase): flag = 0 try: builder(env, target='t6', source=['test6a.bar', 'test6b.ina'])[0] - except SCons.Errors.UserError, e: + except SCons.Errors.UserError as e: flag = 1 assert flag, "UserError should be thrown when we call a builder with files of different suffixes." expect = "While building `['t6']' from `test6b.foo': Cannot build multiple sources with different extensions: .bar, .foo" @@ -1599,7 +1599,7 @@ class CompositeBuilderTestCase(unittest.TestCase): flag = 0 try: builder(env, target='t4', source=['test4a.ina', 'test4b.inb'])[0] - except SCons.Errors.UserError, e: + except SCons.Errors.UserError as e: flag = 1 assert flag, "UserError should be thrown when we call a builder with files of different suffixes." expect = "While building `['t4']' from `test4b.bar': Cannot build multiple sources with different extensions: .foo, .bar" @@ -1608,7 +1608,7 @@ class CompositeBuilderTestCase(unittest.TestCase): flag = 0 try: builder(env, target='t7', source=[env.fs.File('test7')])[0] - except SCons.Errors.UserError, e: + except SCons.Errors.UserError as e: flag = 1 assert flag, "UserError should be thrown when we call a builder with files of different suffixes." expect = "While building `['t7']': Cannot deduce file extension from source files: ['test7']" @@ -1617,7 +1617,7 @@ class CompositeBuilderTestCase(unittest.TestCase): flag = 0 try: builder(env, target='t8', source=['test8.unknown'])[0] - except SCons.Errors.UserError, e: + except SCons.Errors.UserError as e: flag = 1 assert flag, "UserError should be thrown when we call a builder target with an unknown suffix." expect = "While building `['t8']' from `['test8.unknown']': Don't know how to build from a source file with suffix `.unknown'. Expected a suffix in this list: ['.foo', '.bar']." diff --git a/src/engine/SCons/CacheDirTests.py b/src/engine/SCons/CacheDirTests.py index 21b435a..269040d 100644 --- a/src/engine/SCons/CacheDirTests.py +++ b/src/engine/SCons/CacheDirTests.py @@ -241,7 +241,7 @@ class FileTestCase(BaseTestCase): warn_caught = 0 try: f7.push_to_cache() - except SCons.Errors.BuildError, e: + except SCons.Errors.BuildError as e: assert e.exc_info[0] == SCons.Warnings.CacheWriteErrorWarning warn_caught = 1 assert warn_caught diff --git a/src/engine/SCons/Debug.py b/src/engine/SCons/Debug.py index 1c0c638..363c8b7 100644 --- a/src/engine/SCons/Debug.py +++ b/src/engine/SCons/Debug.py @@ -73,7 +73,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)) @@ -143,7 +143,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 a99bcc7..fe1f87b 100644 --- a/src/engine/SCons/Defaults.py +++ b/src/engine/SCons/Defaults.py @@ -31,7 +31,7 @@ from distutils.msvccompiler. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -from __future__ import division + __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -50,6 +50,7 @@ import SCons.Environment import SCons.PathList import SCons.Subst import SCons.Tool +import collections # A placeholder for a default Environment (for fetching source files # from source code management systems and the like). This must be @@ -221,7 +222,7 @@ def mkdir_func(dest): for entry in dest: try: os.makedirs(str(entry)) - except os.error, e: + except os.error as e: p = str(entry) if (e.args[0] == errno.EEXIST or (sys.platform=='win32' and e.args[0]==183)) \ @@ -325,9 +326,9 @@ def _stripixes(prefix, itms, suffix, stripprefixes, stripsuffixes, env, c=None): if not itms: return itms - if not callable(c): + if not isinstance(c, collections.Callable): env_c = env['_concat'] - if env_c != _concat and callable(env_c): + if env_c != _concat and isinstance(env_c, collections.Callable): # There's a custom _concat() method in the construction # environment, and we've allowed people to set that in # the past (see test/custom-concat.py), so preserve the @@ -381,7 +382,7 @@ def processDefines(defs): else: l.append(str(d[0])) elif SCons.Util.is_Dict(d): - for macro,value in d.iteritems(): + for macro,value in d.items(): if value is not None: l.append(str(macro) + '=' + str(value)) else: diff --git a/src/engine/SCons/DefaultsTests.py b/src/engine/SCons/DefaultsTests.py index fd10c12..a36ca7c 100644 --- a/src/engine/SCons/DefaultsTests.py +++ b/src/engine/SCons/DefaultsTests.py @@ -69,7 +69,7 @@ class DefaultsTestCase(unittest.TestCase): test.write(file, "test\n") try: mkdir_func(file) - except os.error, e: + except os.error as e: pass else: fail("expected os.error") diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index 55a8206..88b0553 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -58,6 +58,7 @@ import SCons.Subst import SCons.Tool import SCons.Util import SCons.Warnings +import collections class _Null(object): pass @@ -127,7 +128,7 @@ future_reserved_construction_var_names = [ def copy_non_reserved_keywords(dict): result = semi_deepcopy(dict) - for k in result.keys(): + for k in list(result.keys()): if k in reserved_construction_var_names: msg = "Ignoring attempt to set reserved variable `$%s'" SCons.Warnings.warn(SCons.Warnings.ReservedVariableWarning, msg % k) @@ -146,12 +147,12 @@ def _set_future_reserved(env, key, value): def _set_BUILDERS(env, key, value): try: bd = env._dict[key] - for k in bd.keys(): + for k in list(bd.keys()): del bd[k] 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) @@ -323,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) @@ -517,7 +518,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) @@ -591,7 +592,7 @@ class SubstitutionEnvironment(object): out,err = p.communicate() status = p.wait() if err: - sys.stderr.write(unicode(err)) + sys.stderr.write(str(err)) if status: raise OSError("'%s' exited %d" % (command, status)) return out @@ -629,7 +630,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: @@ -814,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: @@ -1004,7 +1005,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 @@ -1152,7 +1153,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" @@ -1205,7 +1206,7 @@ class Base(SubstitutionEnvironment): # based on what we think the value looks like. if SCons.Util.is_List(val): if key == 'CPPDEFINES': - orig = orig.items() + orig = list(orig.items()) orig += val self._dict[key] = orig else: @@ -1216,7 +1217,7 @@ class Base(SubstitutionEnvironment): update_dict(val) except (AttributeError, TypeError, ValueError): if SCons.Util.is_Dict(val): - for k, v in val.items(): + for k, v in list(val.items()): orig[k] = v else: orig[val] = None @@ -1262,7 +1263,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): @@ -1286,7 +1287,7 @@ class Base(SubstitutionEnvironment): tmp.append((i,)) val = tmp if SCons.Util.is_Dict(dk): - dk = dk.items() + dk = list(dk.items()) elif SCons.Util.is_String(dk): dk = [(dk,)] else: @@ -1327,11 +1328,11 @@ class Base(SubstitutionEnvironment): tmp.append((i,)) dk = tmp if SCons.Util.is_Dict(val): - val = val.items() + val = list(val.items()) elif SCons.Util.is_String(val): val = [(val,)] if delete_existing: - dk = filter(lambda x, val=val: x not in val, dk) + dk = list(filter(lambda x, val=val: x not in val, dk)) self._dict[key] = dk + val else: dk = [x for x in dk if x not in val] @@ -1340,7 +1341,7 @@ class Base(SubstitutionEnvironment): # By elimination, val is not a list. Since dk is a # list, wrap val in a list first. if delete_existing: - dk = filter(lambda x, val=val: x not in val, dk) + dk = list(filter(lambda x, val=val: x not in val, dk)) self._dict[key] = dk + [val] else: if not val in dk: @@ -1350,7 +1351,7 @@ class Base(SubstitutionEnvironment): if SCons.Util.is_String(dk): dk = [dk] elif SCons.Util.is_Dict(dk): - dk = dk.items() + dk = list(dk.items()) if SCons.Util.is_String(val): if val in dk: val = [] @@ -1358,7 +1359,7 @@ class Base(SubstitutionEnvironment): val = [val] elif SCons.Util.is_Dict(val): tmp = [] - for i,j in val.iteritems(): + for i,j in val.items(): if j is not None: tmp.append((i,j)) else: @@ -1402,7 +1403,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) @@ -1469,7 +1470,7 @@ class Base(SubstitutionEnvironment): copy_function = self._copy_from_cache elif function == 'timestamp-match': function = self._changed_timestamp_match - elif not callable(function): + elif not isinstance(function, collections.Callable): raise UserError("Unknown Decider value %s" % repr(function)) # We don't use AddMethod because we don't want to turn the @@ -1602,7 +1603,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" @@ -1656,7 +1657,7 @@ class Base(SubstitutionEnvironment): update_dict(val) except (AttributeError, TypeError, ValueError): if SCons.Util.is_Dict(val): - for k, v in val.items(): + for k, v in list(val.items()): orig[k] = v else: orig[val] = None @@ -1693,7 +1694,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): @@ -1768,7 +1769,7 @@ class Base(SubstitutionEnvironment): return os.path.join(dir, new_prefix+name+new_suffix) def SetDefault(self, **kw): - for k in kw.keys(): + for k in list(kw.keys()): if k in self._dict: del kw[k] self.Replace(**kw) @@ -1830,7 +1831,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 @@ -1840,7 +1841,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 @@ -2235,7 +2236,7 @@ class Base(SubstitutionEnvironment): while (node != node.srcnode()): node = node.srcnode() return node - sources = map( final_source, sources ); + sources = list(map( final_source, sources )); # remove duplicates return list(set(sources)) @@ -2378,7 +2379,7 @@ def NoSubstitutionProxy(subject): def __setattr__(self, name, value): return setattr(self.__dict__['__subject'], name, value) def executor_to_lvars(self, kwdict): - if kwdict.has_key('executor'): + if 'executor' in kwdict: kwdict['lvars'] = kwdict['executor'].get_lvars() del kwdict['executor'] else: diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index 45cf876..3af879a 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -160,7 +160,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: @@ -263,7 +263,7 @@ class SubstitutionTestCase(unittest.TestCase): assert isinstance(nodes[0], X) assert nodes[0].name == "Util.py UtilTests.py" - try: unicode + try: str except NameError: pass else: code = """if 1: @@ -272,7 +272,7 @@ class SubstitutionTestCase(unittest.TestCase): assert isinstance(nodes[0], X) assert nodes[0].name == u"Util.py UtilTests.py" \n""" - exec code in globals(), locals() + exec(code, globals(), locals()) nodes = env.arg2nodes(["Util.py", "UtilTests.py"], Factory) assert len(nodes) == 2, nodes @@ -655,7 +655,7 @@ sys.exit(0) cmd = '%s %s' % (python, test.workpath('fail.py')) try: env.backtick(cmd) - except OSError, e: + except OSError as e: assert str(e) == "'%s' exited 1" % cmd, str(e) else: self.fail("did not catch expected OSError") @@ -1586,17 +1586,17 @@ def exists(env): env['XXX'] = copy.copy(input) try: env.Append(XXX = append) - except Exception, e: - if failed == 0: print - print " %s Append %s exception: %s" % \ - (repr(input), repr(append), e) + except Exception as e: + if failed == 0: print() + print(" %s Append %s exception: %s" % \ + (repr(input), repr(append), e)) failed = failed + 1 else: result = env['XXX'] if result != expect: - if failed == 0: print - print " %s Append %s => %s did not match %s" % \ - (repr(input), repr(append), repr(result), repr(expect)) + if failed == 0: print() + print(" %s Append %s => %s did not match %s" % \ + (repr(input), repr(append), repr(result), repr(expect))) failed = failed + 1 del cases[:3] assert failed == 0, "%d Append() cases failed" % failed @@ -1935,7 +1935,7 @@ def generate(env): assert x is None, x sub2_xxx_exe = test.workpath('sub2', 'xxx.exe') - os.chmod(sub2_xxx_exe, 0755) + os.chmod(sub2_xxx_exe, 0o755) env = self.TestEnvironment(ENV = { 'PATH' : [sub1, sub2] }) @@ -1943,7 +1943,7 @@ def generate(env): assert x == 'xxx.exe', x sub1_xxx_exe = test.workpath('sub1', 'xxx.exe') - os.chmod(sub1_xxx_exe, 0755) + os.chmod(sub1_xxx_exe, 0o755) x = env.Detect('xxx.exe') assert x == 'xxx.exe', x @@ -2258,17 +2258,17 @@ f5: \ env['XXX'] = copy.copy(input) try: env.Prepend(XXX = prepend) - except Exception, e: - if failed == 0: print - print " %s Prepend %s exception: %s" % \ - (repr(input), repr(prepend), e) + except Exception as e: + if failed == 0: print() + print(" %s Prepend %s exception: %s" % \ + (repr(input), repr(prepend), e)) failed = failed + 1 else: result = env['XXX'] if result != expect: - if failed == 0: print - print " %s Prepend %s => %s did not match %s" % \ - (repr(input), repr(prepend), repr(result), repr(expect)) + if failed == 0: print() + print(" %s Prepend %s => %s did not match %s" % \ + (repr(input), repr(prepend), repr(result), repr(expect))) failed = failed + 1 del cases[:3] assert failed == 0, "%d Prepend() cases failed" % failed @@ -2506,10 +2506,10 @@ def generate(env): os.mkdir(sub2_xxx_exe) test.write(sub3_xxx_exe, "\n") - os.chmod(sub3_xxx_exe, 0777) + os.chmod(sub3_xxx_exe, 0o777) test.write(sub4_xxx_exe, "\n") - os.chmod(sub4_xxx_exe, 0777) + os.chmod(sub4_xxx_exe, 0o777) env_path = os.environ['PATH'] diff --git a/src/engine/SCons/ErrorsTests.py b/src/engine/SCons/ErrorsTests.py index 9c8b925..97c9d55 100644 --- a/src/engine/SCons/ErrorsTests.py +++ b/src/engine/SCons/ErrorsTests.py @@ -35,7 +35,7 @@ class ErrorsTestCase(unittest.TestCase): raise SCons.Errors.BuildError( errstr = "foo", status=57, filename="file", exc_info=(1,2,3), node = "n", executor="e", action="a", command="c") - except SCons.Errors.BuildError, e: + except SCons.Errors.BuildError as e: assert e.errstr == "foo" assert e.status == 57 assert e.exitstatus == 2, e.exitstatus @@ -50,7 +50,7 @@ class ErrorsTestCase(unittest.TestCase): try: raise SCons.Errors.BuildError("n", "foo", 57, 3, "file", "e", "a", "c", (1,2,3)) - except SCons.Errors.BuildError, e: + except SCons.Errors.BuildError as e: assert e.errstr == "foo", e.errstr assert e.status == 57, e.status assert e.exitstatus == 3, e.exitstatus @@ -64,7 +64,7 @@ class ErrorsTestCase(unittest.TestCase): try: raise SCons.Errors.BuildError() - except SCons.Errors.BuildError, e: + except SCons.Errors.BuildError as e: assert e.errstr == "Unknown error" assert e.status == 2 assert e.exitstatus == 2 @@ -80,21 +80,21 @@ class ErrorsTestCase(unittest.TestCase): """Test the InternalError exception.""" try: raise SCons.Errors.InternalError("test internal error") - except SCons.Errors.InternalError, e: + except SCons.Errors.InternalError as e: assert e.args == ("test internal error",) def test_UserError(self): """Test the UserError exception.""" try: raise SCons.Errors.UserError("test user error") - except SCons.Errors.UserError, e: + except SCons.Errors.UserError as e: assert e.args == ("test user error",) def test_ExplicitExit(self): """Test the ExplicitExit exception.""" try: raise SCons.Errors.ExplicitExit("node") - except SCons.Errors.ExplicitExit, e: + except SCons.Errors.ExplicitExit as e: assert e.node == "node" if __name__ == "__main__": diff --git a/src/engine/SCons/ExecutorTests.py b/src/engine/SCons/ExecutorTests.py index 6268984..3bc5bee 100644 --- a/src/engine/SCons/ExecutorTests.py +++ b/src/engine/SCons/ExecutorTests.py @@ -307,7 +307,7 @@ class ExecutorTestCase(unittest.TestCase): try: r = x.prepare() - except SCons.Errors.StopError, e: + except SCons.Errors.StopError as e: assert str(e) == "Source `s2' not found, needed by target `t1'.", e else: raise AssertionError("did not catch expected StopError: %s" % r) diff --git a/src/engine/SCons/Job.py b/src/engine/SCons/Job.py index 184f5ba..226a34e 100644 --- a/src/engine/SCons/Job.py +++ b/src/engine/SCons/Job.py @@ -278,14 +278,14 @@ else: try: prev_size = threading.stack_size(stack_size*1024) - except AttributeError, e: + except AttributeError as e: # Only print a warning if the stack size has been # explicitly set. if not explicit_stack_size is None: msg = "Setting stack size is unsupported by this version of Python:\n " + \ e.args[0] SCons.Warnings.warn(SCons.Warnings.StackSizeWarning, msg) - except ValueError, e: + except ValueError as e: msg = "Setting stack size failed:\n " + str(e) SCons.Warnings.warn(SCons.Warnings.StackSizeWarning, msg) diff --git a/src/engine/SCons/Memoize.py b/src/engine/SCons/Memoize.py index e77aacf..9fe6851 100644 --- a/src/engine/SCons/Memoize.py +++ b/src/engine/SCons/Memoize.py @@ -143,7 +143,7 @@ class Counter(object): CounterList.append(self) def display(self): fmt = " %7d hits %7d misses %s()" - print fmt % (self.hit, self.miss, self.name) + print(fmt % (self.hit, self.miss, self.name)) def __cmp__(self, other): try: return cmp(self.name, other.name) @@ -215,7 +215,7 @@ class Memoizer(object): def Dump(title=None): if title: - print title + print(title) CounterList.sort() for counter in CounterList: counter.display() diff --git a/src/engine/SCons/MemoizeTests.py b/src/engine/SCons/MemoizeTests.py index 9876c27..b6750e0 100644 --- a/src/engine/SCons/MemoizeTests.py +++ b/src/engine/SCons/MemoizeTests.py @@ -30,9 +30,7 @@ import SCons.Memoize -class FakeObject(object): - - __metaclass__ = SCons.Memoize.Memoized_Metaclass +class FakeObject(object, metaclass=SCons.Memoize.Memoized_Metaclass): memoizer_counters = [] diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index f31ca83..22dca1f 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -54,6 +54,7 @@ import SCons.Util import SCons.Warnings from SCons.Debug import Trace +import collections do_store_info = True print_duplicate = 0 @@ -550,7 +551,7 @@ class EntryProxy(SCons.Util.Proxy): except KeyError: try: attr = SCons.Util.Proxy.__getattr__(self, name) - except AttributeError, e: + except AttributeError as e: # Raise our own AttributeError subclass with an # overridden __str__() method that identifies the # name of the entry that caused the exception. @@ -1508,7 +1509,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) @@ -2055,7 +2056,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: @@ -2420,7 +2421,7 @@ class File(Base): fname = self.rfile().abspath try: contents = open(fname, "rb").read() - except EnvironmentError, e: + except EnvironmentError as e: if not e.filename: e.filename = fname raise @@ -2455,7 +2456,7 @@ class File(Base): try: cs = SCons.Util.MD5filesignature(fname, chunksize=SCons.Node.FS.File.md5_chunksize*1024) - except EnvironmentError, e: + except EnvironmentError as e: if not e.filename: e.filename = fname raise @@ -2793,7 +2794,7 @@ class File(Base): def _rmv_existing(self): self.clear_memoized_values() if print_duplicate: - print "dup: removing existing target %s"%self + print("dup: removing existing target %s"%self) e = Unlink(self, [], None) if isinstance(e, SCons.Errors.BuildError): raise e @@ -2817,7 +2818,7 @@ class File(Base): else: try: self._createDir() - except SCons.Errors.StopError, drive: + except SCons.Errors.StopError as drive: desc = "No drive `%s' for target `%s'." % (drive, self) raise SCons.Errors.StopError(desc) @@ -2835,7 +2836,7 @@ class File(Base): def do_duplicate(self, src): self._createDir() if print_duplicate: - print "dup: relinking variant '%s' from '%s'"%(self, src) + print("dup: relinking variant '%s' from '%s'"%(self, src)) Unlink(self, None, None) e = Link(self, src, None) if isinstance(e, SCons.Errors.BuildError): @@ -2870,7 +2871,7 @@ class File(Base): # The source file does not exist. Make sure no old # copy remains in the variant directory. if print_duplicate: - print "dup: no src for %s, unlinking old variant copy"%self + print("dup: no src for %s, unlinking old variant copy"%self) if Base.exists(self) or self.islink(): self.fs.unlink(self.path) # Return None explicitly because the Base.exists() call @@ -3196,10 +3197,10 @@ class FileFinder(object): except KeyError: pass - if verbose and not callable(verbose): + if verbose and not isinstance(verbose, collections.Callable): if not SCons.Util.is_String(verbose): verbose = "find_file" - _verbose = u' %s: ' % verbose + _verbose = ' %s: ' % verbose verbose = lambda s: sys.stdout.write(_verbose + s) filedir, filename = os.path.split(filename) diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index a60b8a4..e8442e9 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -20,7 +20,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -from __future__ import division + __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -567,13 +567,13 @@ class VariantDirTestCase(unittest.TestCase): dp = dnode.srcnode().path expect = os.path.normpath(srcnode_map.get(dir, dir)) if dp != expect: - print "Dir `%s' srcnode() `%s' != expected `%s'" % (dir, dp, expect) + print("Dir `%s' srcnode() `%s' != expected `%s'" % (dir, dp, expect)) errors = errors + 1 fp = fnode.srcnode().path expect = os.path.normpath(srcnode_map.get(f, f)) if fp != expect: - print "File `%s' srcnode() `%s' != expected `%s'" % (f, fp, expect) + print("File `%s' srcnode() `%s' != expected `%s'" % (f, fp, expect)) errors = errors + 1 for dir in dir_list: @@ -585,14 +585,14 @@ class VariantDirTestCase(unittest.TestCase): tp = t[0].path expect = os.path.normpath(alter_map.get(dir, dir)) if tp != expect: - print "Dir `%s' alter_targets() `%s' != expected `%s'" % (dir, tp, expect) + print("Dir `%s' alter_targets() `%s' != expected `%s'" % (dir, tp, expect)) errors = errors + 1 t, m = fnode.alter_targets() tp = t[0].path expect = os.path.normpath(alter_map.get(f, f)) if tp != expect: - print "File `%s' alter_targets() `%s' != expected `%s'" % (f, tp, expect) + print("File `%s' alter_targets() `%s' != expected `%s'" % (f, tp, expect)) errors = errors + 1 self.failIf(errors) @@ -1088,7 +1088,7 @@ class FSTestCase(_tempdirTestCase): try: f2 = fs.File(sep.join(['f1', 'f2']), directory = d1) - except TypeError, x: + except TypeError as x: assert str(x) == ("Tried to lookup File '%s' as a Dir." % d1_f1), x except: @@ -1096,7 +1096,7 @@ class FSTestCase(_tempdirTestCase): try: dir = fs.Dir(sep.join(['d1', 'f1'])) - except TypeError, x: + except TypeError as x: assert str(x) == ("Tried to lookup File '%s' as a Dir." % d1_f1), x except: @@ -1104,7 +1104,7 @@ class FSTestCase(_tempdirTestCase): try: f2 = fs.File('d1') - except TypeError, x: + except TypeError as x: assert str(x) == ("Tried to lookup Dir '%s' as a File." % 'd1'), x except: @@ -1305,7 +1305,7 @@ class FSTestCase(_tempdirTestCase): assert f1.get_contents() == "Foo\x1aBar", f1.get_contents() # This tests to make sure we can decode UTF-8 text files. - test_string = u"Foo\x1aBar" + test_string = "Foo\x1aBar" test.write("utf8_file", test_string.encode('utf-8')) f1 = fs.File(test.workpath("utf8_file")) assert eval('f1.get_text_contents() == u"Foo\x1aBar"'), \ @@ -1645,7 +1645,7 @@ class FSTestCase(_tempdirTestCase): def unc_workpath(dirs, test=test): import ntpath - x = apply(test.workpath, dirs) + x = test.workpath(*dirs) drive, path = ntpath.splitdrive(x) unc, path = ntpath.splitunc(path) path = strip_slash(path) @@ -1911,9 +1911,9 @@ class FSTestCase(_tempdirTestCase): del cases[:3] result = dir.rel_path(other) if result != expect: - if failed == 0: print + if failed == 0: print() fmt = " dir_path(%(dir)s, %(other)s) => '%(result)s' did not match '%(expect)s'" - print fmt % locals() + print(fmt % locals()) failed = failed + 1 assert failed == 0, "%d rel_path() cases failed" % failed @@ -2520,9 +2520,9 @@ class GlobTestCase(_tempdirTestCase): fmt = lambda n: n if r != result: import pprint - print "Glob(%s) expected:" % repr(input) + print("Glob(%s) expected:" % repr(input)) pprint.pprint(list(map(fmt, result))) - print "Glob(%s) got:" % repr(input) + print("Glob(%s) got:" % repr(input)) pprint.pprint(list(map(fmt, r))) self.fail() @@ -3621,7 +3621,7 @@ class SpecialAttrTestCase(unittest.TestCase): caught = None try: fs.Dir('ddd').get_subst_proxy().no_such_attr - except AttributeError, e: + except AttributeError as e: assert str(e) == "Dir instance 'ddd' has no attribute 'no_such_attr'", e caught = 1 assert caught, "did not catch expected AttributeError" @@ -3629,7 +3629,7 @@ class SpecialAttrTestCase(unittest.TestCase): caught = None try: fs.Entry('eee').get_subst_proxy().no_such_attr - except AttributeError, e: + except AttributeError as e: # Gets disambiguated to File instance by get_subst_proxy(). assert str(e) == "File instance 'eee' has no attribute 'no_such_attr'", e caught = 1 @@ -3638,7 +3638,7 @@ class SpecialAttrTestCase(unittest.TestCase): caught = None try: fs.File('fff').get_subst_proxy().no_such_attr - except AttributeError, e: + except AttributeError as e: assert str(e) == "File instance 'fff' has no attribute 'no_such_attr'", e caught = 1 assert caught, "did not catch expected AttributeError" diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 992284d..8f48d86 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -371,7 +371,7 @@ class Node(object): """ try: self.get_executor()(self, **kw) - except SCons.Errors.BuildError, e: + except SCons.Errors.BuildError as e: e.node = self raise @@ -827,7 +827,7 @@ class Node(object): """Adds dependencies.""" try: self._add_child(self.depends, self.depends_set, depend) - except TypeError, e: + except TypeError as e: e = e.args[0] if SCons.Util.is_List(e): s = list(map(str, e)) @@ -844,7 +844,7 @@ class Node(object): """Adds dependencies to ignore.""" try: self._add_child(self.ignore, self.ignore_set, depend) - except TypeError, e: + except TypeError as e: e = e.args[0] if SCons.Util.is_List(e): s = list(map(str, e)) @@ -858,7 +858,7 @@ class Node(object): return try: self._add_child(self.sources, self.sources_set, source) - except TypeError, e: + except TypeError as e: e = e.args[0] if SCons.Util.is_List(e): s = list(map(str, e)) @@ -1197,8 +1197,8 @@ class Node(object): 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/Options/__init__.py b/src/engine/SCons/Options/__init__.py index f6c8483..2544aec 100644 --- a/src/engine/SCons/Options/__init__.py +++ b/src/engine/SCons/Options/__init__.py @@ -33,11 +33,11 @@ and will then be removed entirely (some day). import SCons.Variables import SCons.Warnings -from BoolOption import BoolOption # okay -from EnumOption import EnumOption # okay -from ListOption import ListOption # naja -from PackageOption import PackageOption # naja -from PathOption import PathOption # okay +from .BoolOption import BoolOption # okay +from .EnumOption import EnumOption # okay +from .ListOption import ListOption # naja +from .PackageOption import PackageOption # naja +from .PathOption import PathOption # okay warned = False diff --git a/src/engine/SCons/Platform/__init__.py b/src/engine/SCons/Platform/__init__.py index 81a49e7..6ef8b05 100644 --- a/src/engine/SCons/Platform/__init__.py +++ b/src/engine/SCons/Platform/__init__.py @@ -223,8 +223,8 @@ class TempFileMunge(object): # purity get in the way of just being helpful, so we'll # reach into SCons.Action directly. if SCons.Action.print_actions: - print("Using tempfile "+native_tmp+" for command line:\n"+ - str(cmd[0]) + " " + " ".join(args)) + print(("Using tempfile "+native_tmp+" for command line:\n"+ + str(cmd[0]) + " " + " ".join(args))) return [ cmd[0], prefix + native_tmp + '\n' + rm, native_tmp ] def Platform(name = platform_default()): diff --git a/src/engine/SCons/Platform/aix.py b/src/engine/SCons/Platform/aix.py index 0229112..f6853b5 100644 --- a/src/engine/SCons/Platform/aix.py +++ b/src/engine/SCons/Platform/aix.py @@ -34,7 +34,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os -import posix +from . import posix def get_xlc(env, xlc=None, xlc_r=None, packages=[]): # Use the AIX package installer tool lslpp to figure out where a diff --git a/src/engine/SCons/Platform/cygwin.py b/src/engine/SCons/Platform/cygwin.py index a012682..e7c8b8a 100644 --- a/src/engine/SCons/Platform/cygwin.py +++ b/src/engine/SCons/Platform/cygwin.py @@ -32,7 +32,7 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import posix +from . import posix from SCons.Platform import TempFileMunge def generate(env): diff --git a/src/engine/SCons/Platform/darwin.py b/src/engine/SCons/Platform/darwin.py index 005673b..1cf4aeb 100644 --- a/src/engine/SCons/Platform/darwin.py +++ b/src/engine/SCons/Platform/darwin.py @@ -32,7 +32,7 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import posix +from . import posix import os def generate(env): diff --git a/src/engine/SCons/Platform/hpux.py b/src/engine/SCons/Platform/hpux.py index 43d284b..0e0bbcf 100644 --- a/src/engine/SCons/Platform/hpux.py +++ b/src/engine/SCons/Platform/hpux.py @@ -32,7 +32,7 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import posix +from . import posix def generate(env): posix.generate(env) diff --git a/src/engine/SCons/Platform/irix.py b/src/engine/SCons/Platform/irix.py index 2baee0b..2e5f217 100644 --- a/src/engine/SCons/Platform/irix.py +++ b/src/engine/SCons/Platform/irix.py @@ -32,7 +32,7 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import posix +from . import posix def generate(env): posix.generate(env) diff --git a/src/engine/SCons/Platform/os2.py b/src/engine/SCons/Platform/os2.py index 0fa4553..5ca26bc 100644 --- a/src/engine/SCons/Platform/os2.py +++ b/src/engine/SCons/Platform/os2.py @@ -31,7 +31,7 @@ selection method. # __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import win32 +from . import win32 def generate(env): if 'ENV' not in env: diff --git a/src/engine/SCons/Platform/posix.py b/src/engine/SCons/Platform/posix.py index ece48d7..d1f6c78 100644 --- a/src/engine/SCons/Platform/posix.py +++ b/src/engine/SCons/Platform/posix.py @@ -77,7 +77,7 @@ def exec_fork(l, env): exitval = 127 try: os.execvpe(l[0], l, env) - except OSError, e: + except OSError as e: exitval = exitvalmap.get(e[0], e[0]) sys.stderr.write("scons: %s: %s\n" % (l[0], e[1])) os._exit(exitval) @@ -92,7 +92,7 @@ def _get_env_command(sh, escape, cmd, args, env): s = ' '.join(args) if env: l = ['env', '-'] + \ - [escape(t[0])+'='+escape(t[1]) for t in env.items()] + \ + [escape(t[0])+'='+escape(t[1]) for t in list(env.items())] + \ [sh, '-c', escape(s)] s = ' '.join(l) return s @@ -125,7 +125,8 @@ def process_cmd_output(cmd_stdout, cmd_stderr, stdout, stderr): else: #sys.__stderr__.write( "str(stderr) = %s\n" % str ) stderr.write(str) - except select.error, (_errno, _strerror): + except select.error as xxx_todo_changeme: + (_errno, _strerror) = xxx_todo_changeme.args if _errno != errno.EINTR: raise @@ -164,7 +165,7 @@ def exec_piped_fork(l, env, stdout, stderr): exitval = 127 try: os.execvpe(l[0], l, env) - except OSError, e: + except OSError as e: exitval = exitvalmap.get(e[0], e[0]) stderr.write("scons: %s: %s\n" % (l[0], e[1])) os._exit(exitval) diff --git a/src/engine/SCons/Platform/sunos.py b/src/engine/SCons/Platform/sunos.py index d23d65c..057fddf 100644 --- a/src/engine/SCons/Platform/sunos.py +++ b/src/engine/SCons/Platform/sunos.py @@ -32,7 +32,7 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import posix +from . import posix def generate(env): posix.generate(env) diff --git a/src/engine/SCons/Platform/win32.py b/src/engine/SCons/Platform/win32.py index 5f20685..879817d 100644 --- a/src/engine/SCons/Platform/win32.py +++ b/src/engine/SCons/Platform/win32.py @@ -155,7 +155,7 @@ def piped_spawn(sh, escape, cmd, args, env, stdout, stderr): try: args = [sh, '/C', escape(' '.join(args)) ] ret = spawnve(os.P_WAIT, sh, args, env) - except OSError, e: + except OSError as e: # catch any error try: ret = exitvalmap[e[0]] @@ -183,7 +183,7 @@ def piped_spawn(sh, escape, cmd, args, env, stdout, stderr): def exec_spawn(l, env): try: result = spawnve(os.P_WAIT, l[0], l, env) - except OSError, e: + except OSError as e: try: result = exitvalmap[e[0]] sys.stderr.write("scons: %s: %s\n" % (l[0], e[1])) diff --git a/src/engine/SCons/SConf.py b/src/engine/SCons/SConf.py index f3a3545..987f88d 100644 --- a/src/engine/SCons/SConf.py +++ b/src/engine/SCons/SConf.py @@ -118,7 +118,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])) class SConfWarning(SCons.Warnings.Warning): @@ -239,7 +239,7 @@ class SConfBuildTask(SCons.Taskmaster.AlwaysTask): # Earlier versions of Python don't have sys.excepthook... def excepthook(type, value, tb): traceback.print_tb(tb) - print type, value + print(type, value) excepthook(*self.exc_info()) return SCons.Taskmaster.Task.failed(self) @@ -318,7 +318,7 @@ class SConfBuildTask(SCons.Taskmaster.AlwaysTask): env_decider=env.decide_source): env_decider(dependency, target, prev_ni) return True - if env.decide_source.func_code is not force_build.func_code: + if env.decide_source.__code__ is not force_build.__code__: env.Decider(force_build) env['PSTDOUT'] = env['PSTDERR'] = s try: @@ -332,7 +332,7 @@ class SConfBuildTask(SCons.Taskmaster.AlwaysTask): except SystemExit: exc_value = sys.exc_info()[1] raise SCons.Errors.ExplicitExit(self.targets[0],exc_value.code) - except Exception, e: + except Exception as e: for t in self.targets: binfo = t.get_binfo() binfo.__class__ = SConfBuildInfo @@ -652,7 +652,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/SConfTests.py b/src/engine/SCons/SConfTests.py index e604886..ba524fd 100644 --- a/src/engine/SCons/SConfTests.py +++ b/src/engine/SCons/SConfTests.py @@ -60,7 +60,7 @@ class SConfTestCase(unittest.TestCase): # We try to reset scons' state (including all global variables) import SCons.SConsign SCons.SConsign.write() # simulate normal scons-finish - for n in sys.modules.keys(): + for n in list(sys.modules.keys()): if n.split('.')[0] == 'SCons' and n[:12] != 'SCons.compat': m = sys.modules[n] if isinstance(m, ModuleType): diff --git a/src/engine/SCons/SConsign.py b/src/engine/SCons/SConsign.py index 6555fcb..5ce61be 100644 --- a/src/engine/SCons/SConsign.py +++ b/src/engine/SCons/SConsign.py @@ -84,7 +84,7 @@ def Get_DataBase(dir): DB_sync_list.append(db) return db, "c" except TypeError: - print "DataBase =", DataBase + print("DataBase =", DataBase) raise def Reset(): @@ -172,7 +172,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 @@ -215,10 +215,10 @@ class DB(Base): raise TypeError except KeyboardInterrupt: raise - except Exception, e: + except Exception as e: SCons.Warnings.warn(SCons.Warnings.CorruptSConsignWarning, "Ignoring corrupt sconsign entry : %s (%s)\n"%(self.dir.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": @@ -245,7 +245,7 @@ class DB(Base): # the Repository; we only write to our own .sconsign file, # not to .sconsign files in Repositories. path = normcase(self.dir.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, 1) @@ -274,7 +274,7 @@ class Dir(Base): raise TypeError if dir: - for key, entry in self.entries.items(): + for key, entry in list(self.entries.items()): entry.convert_from_sconsign(dir, key) class DirFile(Dir): @@ -333,14 +333,14 @@ 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, 1) file.close() if fname != self.sconsign: try: mode = os.stat(self.sconsign)[0] - os.chmod(self.sconsign, 0666) + os.chmod(self.sconsign, 0o666) os.unlink(self.sconsign) except (IOError, OSError): # Try to carry on in the face of either OSError diff --git a/src/engine/SCons/Scanner/C.py b/src/engine/SCons/Scanner/C.py index 3311a09..74b01a4 100644 --- a/src/engine/SCons/Scanner/C.py +++ b/src/engine/SCons/Scanner/C.py @@ -59,7 +59,7 @@ class SConsCPPScanner(SCons.cpp.PreProcessor): def read_file(self, file): try: fp = open(str(file.rfile())) - except EnvironmentError, e: + except EnvironmentError as e: self.missing.append((file, self.current_file)) return '' else: diff --git a/src/engine/SCons/Scanner/Fortran.py b/src/engine/SCons/Scanner/Fortran.py index 1b55130..5339ab2 100644 --- a/src/engine/SCons/Scanner/Fortran.py +++ b/src/engine/SCons/Scanner/Fortran.py @@ -35,6 +35,7 @@ import SCons.Node.FS import SCons.Scanner import SCons.Util import SCons.Warnings +import collections class F90Scanner(SCons.Scanner.Classic): """ @@ -109,7 +110,7 @@ class F90Scanner(SCons.Scanner.Classic): # is actually found in a Repository or locally. nodes = [] source_dir = node.get_dir() - if callable(path): + if isinstance(path, collections.Callable): path = path() for dep in mods_and_includes: n, i = self.find_include(dep, source_dir, path) 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/Scanner/Prog.py b/src/engine/SCons/Scanner/Prog.py index 49e93a5..6e2da21 100644 --- a/src/engine/SCons/Scanner/Prog.py +++ b/src/engine/SCons/Scanner/Prog.py @@ -27,6 +27,7 @@ import SCons.Node import SCons.Node.FS import SCons.Scanner import SCons.Util +import collections # global, set by --debug=findlibs print_find_libs = None @@ -76,7 +77,7 @@ def scan(node, env, libpath = ()): result = [] - if callable(libpath): + if isinstance(libpath, collections.Callable): libpath = libpath() find_file = SCons.Node.FS.find_file diff --git a/src/engine/SCons/Scanner/ProgTests.py b/src/engine/SCons/Scanner/ProgTests.py index 411e035..f564c91 100644 --- a/src/engine/SCons/Scanner/ProgTests.py +++ b/src/engine/SCons/Scanner/ProgTests.py @@ -230,7 +230,7 @@ def suite(): suite.addTest(ProgramScannerTestCase6()) suite.addTest(ProgramScannerTestCase7()) suite.addTest(ProgramScannerTestCase8()) - try: unicode + try: str except NameError: pass else: code = """if 1: @@ -245,7 +245,7 @@ def suite(): assert deps_match(deps, ['d1/l2.lib', 'd1/d2/l3.lib']), map(str, deps) suite.addTest(ProgramScannerTestCase4()) \n""" - exec code + exec(code) return suite if __name__ == "__main__": diff --git a/src/engine/SCons/Scanner/ScannerTests.py b/src/engine/SCons/Scanner/ScannerTests.py index ee26922..5a4639d 100644 --- a/src/engine/SCons/Scanner/ScannerTests.py +++ b/src/engine/SCons/Scanner/ScannerTests.py @@ -569,7 +569,7 @@ class ClassicCPPTestCase(unittest.TestCase): assert n == 'path/bbb', n assert i == 'bbb', i - n, i = s.find_include(('<', u'ccc'), 'foo', ('path',)) + n, i = s.find_include(('<', 'ccc'), 'foo', ('path',)) assert n == 'path/ccc', n assert i == 'ccc', i diff --git a/src/engine/SCons/Scanner/__init__.py b/src/engine/SCons/Scanner/__init__.py index 562a361..6ec8df9 100644 --- a/src/engine/SCons/Scanner/__init__.py +++ b/src/engine/SCons/Scanner/__init__.py @@ -33,6 +33,7 @@ import re import SCons.Node.FS import SCons.Util +import collections class _Null(object): @@ -178,7 +179,7 @@ class Base(object): self.node_class = node_class self.node_factory = node_factory self.scan_check = scan_check - if callable(recursive): + if isinstance(recursive, collections.Callable): self.recurse_nodes = recursive elif recursive: self.recurse_nodes = self._recurse_all_nodes @@ -369,7 +370,7 @@ class Classic(Current): # is actually found in a Repository or locally. nodes = [] source_dir = node.get_dir() - if callable(path): + if isinstance(path, collections.Callable): path = path() for include in includes: n, i = self.find_include(include, source_dir, path) diff --git a/src/engine/SCons/Script/Interactive.py b/src/engine/SCons/Script/Interactive.py index ffb5096..87fe1cf 100644 --- a/src/engine/SCons/Script/Interactive.py +++ b/src/engine/SCons/Script/Interactive.py @@ -120,7 +120,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': @@ -129,12 +129,12 @@ class SConsInteractiveCmd(cmd.Cmd): self.shell_variable = 'SHELL' def default(self, argv): - print "*** Unknown command: %s" % argv[0] + print("*** Unknown command: %s" % argv[0]) def onecmd(self, line): line = line.strip() if not line: - print self.lastcmd + print(self.lastcmd) return self.emptyline() self.lastcmd = line if line[0] == '!': @@ -249,7 +249,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 @@ -274,7 +274,7 @@ class SConsInteractiveCmd(cmd.Cmd): return self.do_build(['build', '--clean'] + argv[1:]) def do_EOF(self, argv): - print + print() self.do_exit(argv) def _do_one_help(self, arg): @@ -357,7 +357,7 @@ class SConsInteractiveCmd(cmd.Cmd): # Doing the right thing with an argument list currently # requires different shell= values on Windows and Linux. p = subprocess.Popen(argv, shell=(sys.platform=='win32')) - except EnvironmentError, e: + except EnvironmentError as e: sys.stderr.write('scons: %s: %s\n' % (argv[0], e.strerror)) else: p.wait() diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py index 837c103..9a52937 100644 --- a/src/engine/SCons/Script/Main.py +++ b/src/engine/SCons/Script/Main.py @@ -68,6 +68,7 @@ import SCons.Util import SCons.Warnings import SCons.Script.Interactive +import collections def fetch_win32_parallel_msg(): # A subsidiary function that exists solely to isolate this import @@ -104,7 +105,7 @@ class Progressor(object): self.interval = interval self.overwrite = overwrite - if callable(obj): + if isinstance(obj, collections.Callable): self.func = obj elif SCons.Util.is_List(obj): self.func = self.spinner @@ -224,7 +225,7 @@ class BuildTask(SCons.Taskmaster.OutOfDateTask): self.exception_set() self.do_failed() else: - print "scons: Nothing to be done for `%s'." % t + print("scons: Nothing to be done for `%s'." % t) SCons.Taskmaster.OutOfDateTask.executed(self) else: SCons.Taskmaster.OutOfDateTask.executed(self) @@ -290,8 +291,8 @@ class BuildTask(SCons.Taskmaster.OutOfDateTask): if self.options.debug_includes: tree = t.render_include_tree() if tree: - print - print tree + print() + print(tree) SCons.Taskmaster.OutOfDateTask.postprocess(self) def make_ready(self): @@ -326,10 +327,10 @@ class CleanTask(SCons.Taskmaster.AlwaysTask): else: errstr = "Path '%s' exists but isn't a file or directory." raise SCons.Errors.UserError(errstr % (pathstr)) - except SCons.Errors.UserError, e: - print e - except (IOError, OSError), e: - print "scons: Could not remove '%s':" % pathstr, e.strerror + except SCons.Errors.UserError as e: + print(e) + except (IOError, OSError) as e: + print("scons: Could not remove '%s':" % pathstr, e.strerror) def show(self): target = self.targets[0] @@ -348,13 +349,13 @@ class CleanTask(SCons.Taskmaster.AlwaysTask): for t in self.targets: try: removed = t.remove() - except OSError, e: + except OSError as e: # An OSError may indicate something like a permissions # issue, an IOError would indicate something like # the file not existing. In either case, print a # message and keep going to try to remove as many # targets aa possible. - print "scons: Could not remove '%s':" % str(t), e.strerror + print("scons: Could not remove '%s':" % str(t), e.strerror) else: if removed: display("Removed " + str(t)) @@ -595,7 +596,7 @@ def _scons_internal_error(): """Handle all errors but user errors. Print out a message telling the user what to do in this case and print a normal trace. """ - print 'internal error' + print('internal error') traceback.print_exc() sys.exit(2) @@ -707,7 +708,7 @@ def _load_site_scons_dir(topdir, site_dir_name=None): # the error checking makes it longer. try: m = sys.modules['SCons.Script'] - except Exception, e: + except Exception as e: fmt = 'cannot import site_init.py: missing SCons.Script module %s' raise SCons.Errors.InternalError(fmt % repr(e)) try: @@ -715,15 +716,15 @@ 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] # This is the magic. - exec fp in site_m + exec(fp, site_m) except KeyboardInterrupt: raise - except Exception, e: + except Exception as e: fmt = '*** Error loading site_init file %s:\n' sys.stderr.write(fmt % repr(site_init_file)) raise @@ -733,7 +734,7 @@ def _load_site_scons_dir(topdir, site_dir_name=None): m.__dict__[k] = site_m[k] except KeyboardInterrupt: raise - except ImportError, e: + except ImportError as e: fmt = '*** cannot import site init file %s:\n' sys.stderr.write(fmt % repr(site_init_file)) raise @@ -785,7 +786,7 @@ def _load_all_site_scons_dirs(topdir, verbose=None): dirs=sysdirs + [topdir] for d in dirs: if verbose: # this is used by unit tests. - print "Loading site dir ", d + print("Loading site dir ", d) _load_site_scons_dir(d) def test_load_all_site_scons_dirs(d): @@ -977,7 +978,7 @@ def _main(parser): try: for script in scripts: SCons.Script._SConscript._SConscript(fs, script) - except SCons.Errors.StopError, e: + except SCons.Errors.StopError as e: # We had problems reading an SConscript file, such as it # couldn't be copied in to the VariantDir. Since we're just # reading SConscript files and haven't started building @@ -1034,8 +1035,8 @@ def _main(parser): # SConscript files. Give them the options usage. raise SConsPrintHelpException else: - print help_text - print "Use scons -H for help about command-line options." + print(help_text) + print("Use scons -H for help about command-line options.") exit_status = 0 return @@ -1298,7 +1299,7 @@ def _exec_main(parser, values): prof = Profile() try: prof.runcall(_main, parser) - except SConsPrintHelpException, e: + except SConsPrintHelpException as e: prof.dump_stats(options.profile_file) raise e except SystemExit: @@ -1334,7 +1335,7 @@ def main(): parts.append("__COPYRIGHT__") version = ''.join(parts) - import SConsOptions + from . import SConsOptions parser = SConsOptions.Parser(version) values = SConsOptions.SConsValues(parser.get_default_values()) @@ -1342,22 +1343,22 @@ def main(): try: _exec_main(parser, values) - except SystemExit, s: + except SystemExit as s: if s: exit_status = s except KeyboardInterrupt: print("scons: Build interrupted.") sys.exit(2) - except SyntaxError, e: + except SyntaxError as e: _scons_syntax_error(e) except SCons.Errors.InternalError: _scons_internal_error() - except SCons.Errors.UserError, e: + except SCons.Errors.UserError as e: _scons_user_error(e) except SConsPrintHelpException: parser.print_help() exit_status = 0 - except SCons.Errors.BuildError, e: + except SCons.Errors.BuildError as e: exit_status = e.exitstatus except: # An exception here is likely a builtin Python exception Python @@ -1393,10 +1394,10 @@ def main(): else: ct = last_command_end - first_command_start scons_time = total_time - sconscript_time - ct - print "Total build time: %f seconds"%total_time - print "Total SConscript file execution time: %f seconds"%sconscript_time - print "Total SCons execution time: %f seconds"%scons_time - print "Total command execution time: %f seconds"%ct + print("Total build time: %f seconds"%total_time) + print("Total SConscript file execution time: %f seconds"%sconscript_time) + print("Total SCons execution time: %f seconds"%scons_time) + print("Total command execution time: %f seconds"%ct) sys.exit(exit_status) diff --git a/src/engine/SCons/Script/SConsOptions.py b/src/engine/SCons/Script/SConsOptions.py index 645ab11..559db97 100644 --- a/src/engine/SCons/Script/SConsOptions.py +++ b/src/engine/SCons/Script/SConsOptions.py @@ -161,7 +161,7 @@ class SConsValues(optparse.Values): elif name == 'diskcheck': try: value = diskcheck_convert(value) - except ValueError, v: + except ValueError as v: raise SCons.Errors.UserError("Not a valid diskcheck value: %s"%v) if 'diskcheck' not in self.__dict__: # No --diskcheck= option was specified on the command line. @@ -611,7 +611,7 @@ def Parser(version): deprecated_debug_options=deprecated_debug_options): 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 @@ -635,7 +635,7 @@ def Parser(version): def opt_diskcheck(option, opt, value, parser): try: diskcheck_value = diskcheck_convert(value) - except ValueError, e: + except ValueError as e: raise OptionValueError("`%s' is not a valid diskcheck type" % e) setattr(parser.values, option.dest, diskcheck_value) @@ -802,7 +802,7 @@ def Parser(version): tree_options = ["all", "derived", "prune", "status"] def opt_tree(option, opt, value, parser, tree_options=tree_options): - import Main + from . import Main tp = Main.TreePrinter() for o in value.split(','): if o == 'all': diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py index bd515d2..fefffef 100644 --- a/src/engine/SCons/Script/SConscript.py +++ b/src/engine/SCons/Script/SConscript.py @@ -26,7 +26,7 @@ files. # 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. -from __future__ import division + __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -113,7 +113,7 @@ def compute_exports(exports): retval[export] = loc[export] except KeyError: retval[export] = glob[export] - except KeyError, x: + except KeyError as x: raise SCons.Errors.UserError("Export of non-existent variable '%s'"%x) return retval @@ -145,7 +145,7 @@ def Return(*vars, **kw): for var in fvars: for v in var.split(): retval.append(call_stack[-1].globals[v]) - except KeyError, x: + except KeyError as x: raise SCons.Errors.UserError("Return of non-existent variable '%s'"%x) if len(retval) == 1: @@ -174,7 +174,7 @@ def _SConscript(fs, *files, **kw): try: SCons.Script.sconscript_reading = SCons.Script.sconscript_reading + 1 if fn == "-": - exec sys.stdin in call_stack[-1].globals + exec(sys.stdin, call_stack[-1].globals) else: if isinstance(fn, SCons.Node.Node): f = fn @@ -257,7 +257,7 @@ def _SConscript(fs, *files, **kw): pass try: try: - exec _file_ in call_stack[-1].globals + exec(_file_, call_stack[-1].globals) except SConscriptReturn: pass finally: @@ -282,7 +282,7 @@ def _SConscript(fs, *files, **kw): rdir._create() # Make sure there's a directory there. try: os.chdir(rdir.get_abspath()) - except OSError, e: + except OSError as e: # We still couldn't chdir there, so raise the error, # but only if actions are being executed. # @@ -467,15 +467,15 @@ class SConsEnvironment(SCons.Environment.Base): scons_ver_string = '%d.%d.%d' % (major, minor, revision) else: scons_ver_string = '%d.%d' % (major, minor) - print "SCons %s or greater required, but you have SCons %s" % \ - (scons_ver_string, SCons.__version__) + print("SCons %s or greater required, but you have SCons %s" % \ + (scons_ver_string, SCons.__version__)) sys.exit(2) def EnsurePythonVersion(self, major, minor): """Exit abnormally if the Python version is not late enough.""" if sys.version_info < (major, minor): v = sys.version.split()[0] - print "Python %d.%d or greater required, but you have Python %s" %(major,minor,v) + print("Python %d.%d or greater required, but you have Python %s" %(major,minor,v)) sys.exit(2) def Exit(self, value=0): @@ -514,7 +514,7 @@ class SConsEnvironment(SCons.Environment.Base): globals[v] = exports[v] else: globals[v] = global_exports[v] - except KeyError,x: + except KeyError as x: raise SCons.Errors.UserError("Import of non-existent variable '%s'"%x) def SConscript(self, *ls, **kw): @@ -529,7 +529,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/Script/__init__.py b/src/engine/SCons/Script/__init__.py index bb7b632..9f2837c 100644 --- a/src/engine/SCons/Script/__init__.py +++ b/src/engine/SCons/Script/__init__.py @@ -66,7 +66,7 @@ if "--debug=memoizer" in _args: except SCons.Warnings.Warning: # Some warning was thrown. Arrange for it to be displayed # or not after warnings are configured. - import Main + from . import Main exc_type, exc_value, tb = sys.exc_info() Main.delayed_warnings.append((exc_type, exc_value)) del _args @@ -85,7 +85,7 @@ import SCons.Util import SCons.Variables import SCons.Defaults -import Main +from . import Main main = Main.main @@ -128,7 +128,7 @@ GetBuildFailures = Main.GetBuildFailures #repositories = Main.repositories # -import SConscript +from . import SConscript _SConscript = SConscript call_stack = _SConscript.call_stack @@ -364,7 +364,7 @@ GlobalDefaultBuilders = [ ] for name in GlobalDefaultEnvironmentFunctions + GlobalDefaultBuilders: - exec "%s = _SConscript.DefaultEnvironmentCall(%s)" % (name, repr(name)) + exec("%s = _SConscript.DefaultEnvironmentCall(%s)" % (name, repr(name))) del name # There are a handful of variables that used to live in the diff --git a/src/engine/SCons/Subst.py b/src/engine/SCons/Subst.py index 98097dc..cca9bbc 100644 --- a/src/engine/SCons/Subst.py +++ b/src/engine/SCons/Subst.py @@ -438,7 +438,7 @@ def scons_subst(strSubst, env, mode=SUBST_RAW, target=None, source=None, gvars={ s = eval(key, self.gvars, lvars) except KeyboardInterrupt: raise - except Exception, e: + except Exception as e: if e.__class__ in AllowableExceptions: return '' raise_exception(e, lvars['TARGETS'], s) @@ -472,7 +472,7 @@ def scons_subst(strSubst, env, mode=SUBST_RAW, target=None, source=None, gvars={ def func(l, conv=self.conv, substitute=self.substitute, lvars=lvars): return conv(substitute(l, lvars)) return list(map(func, s)) - elif callable(s): + elif isinstance(s, collections.Callable): try: s = s(target=lvars['TARGETS'], source=lvars['SOURCES'], @@ -653,7 +653,7 @@ def scons_subst_list(strSubst, env, mode=SUBST_RAW, target=None, source=None, gv s = eval(key, self.gvars, lvars) except KeyboardInterrupt: raise - except Exception, e: + except Exception as e: if e.__class__ in AllowableExceptions: return raise_exception(e, lvars['TARGETS'], s) @@ -681,7 +681,7 @@ def scons_subst_list(strSubst, env, mode=SUBST_RAW, target=None, source=None, gv for a in s: self.substitute(a, lvars, 1) self.next_word() - elif callable(s): + elif isinstance(s, collections.Callable): try: s = s(target=lvars['TARGETS'], source=lvars['SOURCES'], diff --git a/src/engine/SCons/SubstTests.py b/src/engine/SCons/SubstTests.py index 420fd73..da21020 100644 --- a/src/engine/SCons/SubstTests.py +++ b/src/engine/SCons/SubstTests.py @@ -241,14 +241,14 @@ class SubstTestCase(unittest.TestCase): expect = convert(expect) try: result = function(input, env, **kwargs) - except Exception, e: + except Exception as e: fmt = " input %s generated %s (%s)" - print fmt % (repr(input), e.__class__.__name__, repr(e)) + print(fmt % (repr(input), e.__class__.__name__, repr(e))) failed = failed + 1 else: if result != expect: - if failed == 0: print - print " input %s => %s did not match %s" % (repr(input), repr(result), repr(expect)) + if failed == 0: print() + print(" input %s => %s did not match %s" % (repr(input), repr(result), repr(expect))) failed = failed + 1 del cases[:2] fmt = "%d %s() cases failed" @@ -460,18 +460,18 @@ class scons_subst_TestCase(SubstTestCase): input, eraw, ecmd, esig = subst_cases[:4] result = scons_subst(input, env, mode=SUBST_RAW, gvars=gvars) if result != eraw: - if failed == 0: print - print " input %s => RAW %s did not match %s" % (repr(input), repr(result), repr(eraw)) + if failed == 0: print() + print(" input %s => RAW %s did not match %s" % (repr(input), repr(result), repr(eraw))) failed = failed + 1 result = scons_subst(input, env, mode=SUBST_CMD, gvars=gvars) if result != ecmd: - if failed == 0: print - print " input %s => CMD %s did not match %s" % (repr(input), repr(result), repr(ecmd)) + if failed == 0: print() + print(" input %s => CMD %s did not match %s" % (repr(input), repr(result), repr(ecmd))) failed = failed + 1 result = scons_subst(input, env, mode=SUBST_SIG, gvars=gvars) if result != esig: - if failed == 0: print - print " input %s => SIG %s did not match %s" % (repr(input), repr(result), repr(esig)) + if failed == 0: print() + print(" input %s => SIG %s did not match %s" % (repr(input), repr(result), repr(esig))) failed = failed + 1 del subst_cases[:4] assert failed == 0, "%d subst() mode cases failed" % failed @@ -514,7 +514,7 @@ class scons_subst_TestCase(SubstTestCase): class Foo(object): pass scons_subst('${foo.bar}', env, gvars={'foo':Foo()}) - except SCons.Errors.UserError, e: + except SCons.Errors.UserError as e: expect = [ "AttributeError `bar' trying to evaluate `${foo.bar}'", "AttributeError `Foo instance has no attribute 'bar'' trying to evaluate `${foo.bar}'", @@ -530,7 +530,7 @@ class scons_subst_TestCase(SubstTestCase): env = DummyEnv(self.loc) try: scons_subst('$foo.bar.3.0', env) - except SCons.Errors.UserError, e: + except SCons.Errors.UserError as e: expect = [ # Python 2.3, 2.4 "SyntaxError `invalid syntax (line 1)' trying to evaluate `$foo.bar.3.0'", @@ -546,7 +546,7 @@ class scons_subst_TestCase(SubstTestCase): env = DummyEnv(self.loc) try: scons_subst("${NONE[2]}", env, gvars={'NONE':None}) - except SCons.Errors.UserError, e: + except SCons.Errors.UserError as e: expect = [ # Python 2.3, 2.4 "TypeError `unsubscriptable object' trying to evaluate `${NONE[2]}'", @@ -565,7 +565,7 @@ class scons_subst_TestCase(SubstTestCase): def func(a, b, c): pass scons_subst("${func(1)}", env, gvars={'func':func}) - except SCons.Errors.UserError, e: + except SCons.Errors.UserError as e: expect = [ # Python 2.3, 2.4, 2.5 "TypeError `func() takes exactly 3 arguments (1 given)' trying to evaluate `${func(1)}'" @@ -946,18 +946,18 @@ class scons_subst_list_TestCase(SubstTestCase): input, eraw, ecmd, esig = subst_list_cases[:4] result = scons_subst_list(input, env, mode=SUBST_RAW, gvars=gvars) if result != eraw: - if failed == 0: print - print " input %s => RAW %s did not match %s" % (repr(input), repr(result), repr(eraw)) + if failed == 0: print() + print(" input %s => RAW %s did not match %s" % (repr(input), repr(result), repr(eraw))) failed = failed + 1 result = scons_subst_list(input, env, mode=SUBST_CMD, gvars=gvars) if result != ecmd: - if failed == 0: print - print " input %s => CMD %s did not match %s" % (repr(input), repr(result), repr(ecmd)) + if failed == 0: print() + print(" input %s => CMD %s did not match %s" % (repr(input), repr(result), repr(ecmd))) failed = failed + 1 result = scons_subst_list(input, env, mode=SUBST_SIG, gvars=gvars) if result != esig: - if failed == 0: print - print " input %s => SIG %s did not match %s" % (repr(input), repr(result), repr(esig)) + if failed == 0: print() + print(" input %s => SIG %s did not match %s" % (repr(input), repr(result), repr(esig))) failed = failed + 1 del subst_list_cases[:4] assert failed == 0, "%d subst() mode cases failed" % failed @@ -969,7 +969,7 @@ class scons_subst_list_TestCase(SubstTestCase): class Foo(object): pass scons_subst_list('${foo.bar}', env, gvars={'foo':Foo()}) - except SCons.Errors.UserError, e: + except SCons.Errors.UserError as e: expect = [ "AttributeError `bar' trying to evaluate `${foo.bar}'", "AttributeError `Foo instance has no attribute 'bar'' trying to evaluate `${foo.bar}'", @@ -985,7 +985,7 @@ class scons_subst_list_TestCase(SubstTestCase): env = DummyEnv() try: scons_subst_list('$foo.bar.3.0', env) - except SCons.Errors.UserError, e: + except SCons.Errors.UserError as e: expect = [ "SyntaxError `invalid syntax' trying to evaluate `$foo.bar.3.0'", "SyntaxError `invalid syntax (line 1)' trying to evaluate `$foo.bar.3.0'", @@ -1093,8 +1093,8 @@ class scons_subst_once_TestCase(unittest.TestCase): input, key, expect = cases[:3] result = scons_subst_once(input, env, key) if result != expect: - if failed == 0: print - print " input %s (%s) => %s did not match %s" % (repr(input), repr(key), repr(result), repr(expect)) + if failed == 0: print() + print(" input %s (%s) => %s did not match %s" % (repr(input), repr(key), repr(result), repr(expect))) failed = failed + 1 del cases[:3] assert failed == 0, "%d subst() cases failed" % failed diff --git a/src/engine/SCons/Taskmaster.py b/src/engine/SCons/Taskmaster.py index 64ab84d..54d04a8 100644 --- a/src/engine/SCons/Taskmaster.py +++ b/src/engine/SCons/Taskmaster.py @@ -107,7 +107,7 @@ fmt = "%(considered)3d "\ def dump_stats(): for n in sorted(StatsNodes, key=lambda a: str(a)): - print (fmt % n.stats.__dict__) + str(n) + print((fmt % n.stats.__dict__) + str(n)) @@ -164,7 +164,7 @@ class Task(object): """ global print_prepare T = self.tm.trace - if T: T.write(self.trace_message(u'Task.prepare()', self.node)) + if T: T.write(self.trace_message('Task.prepare()', self.node)) # Now that it's the appropriate time, give the TaskMaster a # chance to raise any exceptions it encountered while preparing @@ -189,13 +189,13 @@ class Task(object): executor.prepare() for t in executor.get_action_targets(): if print_prepare: - print "Preparing target %s..."%t + print("Preparing target %s..."%t) for s in t.side_effects: - print "...with side-effect %s..."%s + print("...with side-effect %s..."%s) t.prepare() for s in t.side_effects: if print_prepare: - print "...Preparing side-effect %s..."%s + print("...Preparing side-effect %s..."%s) s.prepare() def get_target(self): @@ -224,7 +224,7 @@ class Task(object): prepare(), executed() or failed(). """ T = self.tm.trace - if T: T.write(self.trace_message(u'Task.execute()', self.node)) + if T: T.write(self.trace_message('Task.execute()', self.node)) try: cached_targets = [] @@ -254,7 +254,7 @@ class Task(object): raise except SCons.Errors.BuildError: raise - except Exception, e: + except Exception as e: buildError = SCons.Errors.convert_to_BuildError(e) buildError.node = self.targets[0] buildError.exc_info = sys.exc_info() @@ -383,7 +383,7 @@ class Task(object): This is the default behavior for building only what's necessary. """ T = self.tm.trace - if T: T.write(self.trace_message(u'Task.make_ready_current()', + if T: T.write(self.trace_message('Task.make_ready_current()', self.node)) self.out_of_date = [] @@ -393,7 +393,7 @@ class Task(object): t.disambiguate().make_ready() is_up_to_date = not t.has_builder() or \ (not t.always_build and t.is_up_to_date()) - except EnvironmentError, e: + except EnvironmentError as e: raise SCons.Errors.BuildError(node=t, errstr=e.strerror, filename=e.filename) if not is_up_to_date: @@ -428,7 +428,7 @@ class Task(object): that can be put back on the candidates list. """ T = self.tm.trace - if T: T.write(self.trace_message(u'Task.postprocess()', self.node)) + if T: T.write(self.trace_message('Task.postprocess()', self.node)) # We may have built multiple targets, some of which may have # common parents waiting for this build. Count up how many @@ -445,7 +445,7 @@ class Task(object): # A node can only be in the pending_children set if it has # some waiting_parents. if t.waiting_parents: - if T: T.write(self.trace_message(u'Task.postprocess()', + if T: T.write(self.trace_message('Task.postprocess()', t, 'removing')) pending_children.discard(t) @@ -462,9 +462,9 @@ 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()', + if T: T.write(self.trace_message('Task.postprocess()', p, 'adjusted parent ref count')) if p.ref_count == 0: @@ -524,7 +524,7 @@ class Task(object): except ValueError: exc_type, exc_value = exc exc_traceback = None - raise exc_type, exc_value, exc_traceback + raise exc_type(exc_value).with_traceback(exc_traceback) class AlwaysTask(Task): def needs_execute(self): @@ -748,12 +748,12 @@ class Taskmaster(object): self.ready_exc = None T = self.trace - if T: T.write(u'\n' + self.trace_message('Looking for a node to evaluate')) + if T: T.write('\n' + self.trace_message('Looking for a node to evaluate')) while True: node = self.next_candidate() if node is None: - if T: T.write(self.trace_message('No candidate anymore.') + u'\n') + if T: T.write(self.trace_message('No candidate anymore.') + '\n') return None node = node.disambiguate() @@ -776,7 +776,7 @@ class Taskmaster(object): else: S = None - if T: T.write(self.trace_message(u' Considering node %s and its children:' % self.trace_node(node))) + if T: T.write(self.trace_message(' Considering node %s and its children:' % self.trace_node(node))) if state == NODE_NO_STATE: # Mark this node as being on the execution stack: @@ -784,7 +784,7 @@ class Taskmaster(object): elif state > NODE_PENDING: # Skip this node if it has already been evaluated: if S: S.already_handled = S.already_handled + 1 - if T: T.write(self.trace_message(u' already handled (executed)')) + if T: T.write(self.trace_message(' already handled (executed)')) continue executor = node.get_executor() @@ -797,7 +797,7 @@ class Taskmaster(object): self.ready_exc = (SCons.Errors.ExplicitExit, e) if T: T.write(self.trace_message(' SystemExit')) return node - except Exception, e: + except Exception as e: # We had a problem just trying to figure out the # children (like a child couldn't be linked in to a # VariantDir, or a Scanner threw something). Arrange to @@ -815,7 +815,7 @@ class Taskmaster(object): for child in chain(executor.get_all_prerequisites(), children): childstate = child.get_state() - if T: T.write(self.trace_message(u' ' + self.trace_node(child))) + if T: T.write(self.trace_message(' ' + self.trace_node(child))) if childstate == NODE_NO_STATE: children_not_visited.append(child) @@ -874,7 +874,7 @@ class Taskmaster(object): # count so we can be put back on the list for # re-evaluation when they've all finished. node.ref_count = node.ref_count + child.add_to_waiting_parents(node) - if T: T.write(self.trace_message(u' adjusted ref count: %s, child %s' % + if T: T.write(self.trace_message(' adjusted ref count: %s, child %s' % (self.trace_node(node), repr(str(child))))) if T: @@ -900,7 +900,7 @@ class Taskmaster(object): # The default when we've gotten through all of the checks above: # this node is ready to be built. if S: S.build = S.build + 1 - if T: T.write(self.trace_message(u'Evaluating %s\n' % + if T: T.write(self.trace_message('Evaluating %s\n' % self.trace_node(node))) # For debugging only: diff --git a/src/engine/SCons/TaskmasterTests.py b/src/engine/SCons/TaskmasterTests.py index 85ade8d..0140278 100644 --- a/src/engine/SCons/TaskmasterTests.py +++ b/src/engine/SCons/TaskmasterTests.py @@ -20,7 +20,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -from __future__ import division + __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -692,7 +692,7 @@ class TaskmasterTestCase(unittest.TestCase): tm = SCons.Taskmaster.Taskmaster([n3]) try: t = tm.next_task() - except SCons.Errors.UserError, e: + except SCons.Errors.UserError as e: assert str(e) == "Dependency cycle: n3 -> n1 -> n2 -> n3", str(e) else: assert 'Did not catch expected UserError' @@ -846,7 +846,7 @@ class TaskmasterTestCase(unittest.TestCase): exc_caught = None try: t.prepare() - except MyException, e: + except MyException as e: exc_caught = 1 except: pass @@ -899,7 +899,7 @@ class TaskmasterTestCase(unittest.TestCase): t = tm.next_task() try: t.prepare() - except Exception, e: + except Exception as e: assert str(e) == "Executor.prepare() exception", e else: raise AssertionError("did not catch expected exception") @@ -953,7 +953,7 @@ class TaskmasterTestCase(unittest.TestCase): t = tm.next_task() try: t.execute() - except SCons.Errors.BuildError, e: + except SCons.Errors.BuildError as e: assert e.node == n4, e.node assert e.errstr == "OtherError : ", e.errstr assert len(e.exc_info) == 3, e.exc_info diff --git a/src/engine/SCons/Tool/FortranCommon.py b/src/engine/SCons/Tool/FortranCommon.py index 4c5730c..c21128e 100644 --- a/src/engine/SCons/Tool/FortranCommon.py +++ b/src/engine/SCons/Tool/FortranCommon.py @@ -61,7 +61,7 @@ def isfortran(env, source): def _fortranEmitter(target, source, env): node = source[0].rfile() if not node.exists() and not node.is_derived(): - print "Could not locate " + str(node.name) + print("Could not locate " + str(node.name)) return ([], []) mod_regex = """(?i)^\s*MODULE\s+(?!PROCEDURE)(\w+)""" cre = re.compile(mod_regex,re.M) diff --git a/src/engine/SCons/Tool/GettextCommon.py b/src/engine/SCons/Tool/GettextCommon.py index cd2f306..ea81f0d 100644 --- a/src/engine/SCons/Tool/GettextCommon.py +++ b/src/engine/SCons/Tool/GettextCommon.py @@ -196,7 +196,7 @@ class _POFileBuilder(BuilderBase): import SCons.Util import SCons.Node linguas_files = None - if env.has_key('LINGUAS_FILE') and env['LINGUAS_FILE']: + if 'LINGUAS_FILE' in env and env['LINGUAS_FILE']: linguas_files = env['LINGUAS_FILE'] # This prevents endless recursion loop (we'll be invoked once for # each target appended here, we must not extend the list again). @@ -341,7 +341,7 @@ class RPaths(object): def _init_po_files(target, source, env): """ Action function for `POInit` builder. """ nop = lambda target, source, env : 0 - if env.has_key('POAUTOINIT'): + if 'POAUTOINIT' in env: autoinit = env['POAUTOINIT'] else: autoinit = False @@ -365,7 +365,7 @@ def _init_po_files(target, source, env): ############################################################################# def _detect_xgettext(env): """ Detects *xgettext(1)* binary """ - if env.has_key('XGETTEXT'): + if 'XGETTEXT' in env: return env['XGETTEXT'] xgettext = env.Detect('xgettext'); if xgettext: @@ -380,7 +380,7 @@ def _xgettext_exists(env): ############################################################################# def _detect_msginit(env): """ Detects *msginit(1)* program. """ - if env.has_key('MSGINIT'): + if 'MSGINIT' in env: return env['MSGINIT'] msginit = env.Detect('msginit'); if msginit: @@ -395,7 +395,7 @@ def _msginit_exists(env): ############################################################################# def _detect_msgmerge(env): """ Detects *msgmerge(1)* program. """ - if env.has_key('MSGMERGE'): + if 'MSGMERGE' in env: return env['MSGMERGE'] msgmerge = env.Detect('msgmerge'); if msgmerge: @@ -410,7 +410,7 @@ def _msgmerge_exists(env): ############################################################################# def _detect_msgfmt(env): """ Detects *msgmfmt(1)* program. """ - if env.has_key('MSGFMT'): + if 'MSGFMT' in env: return env['MSGFMT'] msgfmt = env.Detect('msgfmt'); if msgfmt: diff --git a/src/engine/SCons/Tool/MSCommon/common.py b/src/engine/SCons/Tool/MSCommon/common.py index caf2b37..dcf69c8 100644 --- a/src/engine/SCons/Tool/MSCommon/common.py +++ b/src/engine/SCons/Tool/MSCommon/common.py @@ -38,7 +38,7 @@ import SCons.Util logfile = os.environ.get('SCONS_MSCOMMON_DEBUG') if logfile == '-': def debug(x): - print x + print(x) elif logfile: try: import logging @@ -113,7 +113,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]).encode('mbcs') for k in keys: @@ -217,7 +217,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/netframework.py b/src/engine/SCons/Tool/MSCommon/netframework.py index 6124e5b..1a6478f 100644 --- a/src/engine/SCons/Tool/MSCommon/netframework.py +++ b/src/engine/SCons/Tool/MSCommon/netframework.py @@ -28,7 +28,7 @@ __doc__ = """ import os import re -from common import read_reg, debug +from .common import read_reg, debug # Original value recorded by dcournapeau _FRAMEWORKDIR_HKEY_ROOT = r'Software\Microsoft\.NETFramework\InstallRoot' @@ -40,7 +40,7 @@ def find_framework_root(): try: froot = read_reg(_FRAMEWORKDIR_HKEY_ROOT) debug("Found framework install root in registry: %s" % froot) - except WindowsError, e: + except WindowsError as e: debug("Could not read reg key %s" % _FRAMEWORKDIR_HKEY_ROOT) return None diff --git a/src/engine/SCons/Tool/MSCommon/sdk.py b/src/engine/SCons/Tool/MSCommon/sdk.py index 2bf5eef..f71035b 100644 --- a/src/engine/SCons/Tool/MSCommon/sdk.py +++ b/src/engine/SCons/Tool/MSCommon/sdk.py @@ -33,7 +33,7 @@ import os import SCons.Errors import SCons.Util -import common +from . import common debug = common.debug @@ -80,7 +80,7 @@ class SDKDefinition(object): try: sdk_dir = common.read_reg(hkey) - except WindowsError, e: + except WindowsError as e: debug('find_sdk_dir(): no SDK registry key %s' % repr(hkey)) return None @@ -299,7 +299,7 @@ def get_cur_sdk_dir_from_reg(): try: val = common.read_reg(_CURINSTALLED_SDK_HKEY_ROOT) debug("Found current sdk dir in registry: %s" % val) - except WindowsError, e: + except WindowsError as e: debug("Did not find current sdk in registry") return None @@ -350,7 +350,7 @@ def mssdk_setup_env(env): debug('sdk.py:mssdk_setup_env thinks msvs_version is None') return msvs_version = env.subst(msvs_version) - import vs + from . import vs msvs = vs.get_vs_by_version(msvs_version) debug('sdk.py:mssdk_setup_env:msvs is :%s'%msvs) if not msvs: diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py index 1266ee8..35b95d5 100644 --- a/src/engine/SCons/Tool/MSCommon/vc.py +++ b/src/engine/SCons/Tool/MSCommon/vc.py @@ -42,11 +42,11 @@ from string import digits as string_digits import SCons.Warnings -import common +from . import common debug = common.debug -import sdk +from . import sdk get_installed_sdks = sdk.get_installed_sdks @@ -119,14 +119,14 @@ def get_host_target(env): try: host = _ARCH_TO_CANONICAL[host_platform.lower()] - except KeyError, e: + except KeyError as e: msg = "Unrecognized host architecture %s" raise ValueError(msg % repr(host_platform)) try: target = _ARCH_TO_CANONICAL[target_platform.lower()] - except KeyError, e: - all_archs = str(_ARCH_TO_CANONICAL.keys()) + except KeyError as e: + all_archs = str(list(_ARCH_TO_CANONICAL.keys())) raise ValueError("Unrecognized target architecture %s\n\tValid architectures: %s" % (target_platform, all_archs)) return (host, target,req_target_platform) @@ -168,7 +168,7 @@ def msvc_version_to_maj_min(msvc_version): maj = int(t[0]) min = int(t[1]) return maj, min - except ValueError, e: + except ValueError as e: raise ValueError("Unrecognized version %s (%s)" % (msvc_version,msvc_version_numeric)) def is_host_target_supported(host_target, msvc_version): @@ -217,7 +217,7 @@ def find_vc_pdir(msvc_version): key = root + key try: comps = common.read_reg(key) - except WindowsError, e: + except WindowsError as e: debug('find_vc_dir(): no VC registry key %s' % repr(key)) else: debug('find_vc_dir(): found VC in registry: %s' % comps) @@ -289,7 +289,7 @@ def get_installed_vcs(): installed_versions.append(ver) else: debug('find_vc_pdir return None for ver %s' % ver) - except VisualCException, e: + except VisualCException as e: debug('did not find VC %s: caught exception %s' % (ver, str(e))) return installed_versions @@ -393,7 +393,7 @@ def msvc_find_valid_batch_script(env,version): try: (vc_script,sdk_script) = find_batch_file(env,version,host_platform,tp) debug('vc.py:msvc_find_valid_batch_script() vc_script:%s sdk_script:%s'%(vc_script,sdk_script)) - except VisualCException, e: + except VisualCException as e: msg = str(e) debug('Caught exception while looking for batch file (%s)' % msg) warn_msg = "VC version %s not installed. " + \ @@ -408,7 +408,7 @@ def msvc_find_valid_batch_script(env,version): if vc_script: try: d = script_env(vc_script, args=arg) - except BatchFileExecutionError, e: + except BatchFileExecutionError as e: debug('vc.py:msvc_find_valid_batch_script() use_script 3: failed running VC script %s: %s: Error:%s'%(repr(vc_script),arg,e)) vc_script=None continue @@ -416,7 +416,7 @@ def msvc_find_valid_batch_script(env,version): debug('vc.py:msvc_find_valid_batch_script() use_script 4: trying sdk script: %s'%(sdk_script)) try: d = script_env(sdk_script,args=[]) - except BatchFileExecutionError,e: + except BatchFileExecutionError as e: debug('vc.py:msvc_find_valid_batch_script() use_script 5: failed running SDK script %s: Error:%s'%(repr(sdk_script),e)) continue elif not vc_script and not sdk_script: @@ -468,7 +468,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 d5bf2c3..3219719 100644 --- a/src/engine/SCons/Tool/MSCommon/vs.py +++ b/src/engine/SCons/Tool/MSCommon/vs.py @@ -31,7 +31,7 @@ import os import SCons.Errors import SCons.Util -from common import debug, \ +from .common import debug, \ get_output, \ is_win64, \ normalize_env, \ @@ -85,7 +85,7 @@ class VisualStudio(object): key = root + key try: comps = read_reg(key) - except WindowsError, e: + except WindowsError as e: debug('find_vs_dir_by_reg(): no VS registry key %s' % repr(key)) else: debug('find_vs_dir_by_reg(): found VS in registry: %s' % comps) @@ -536,7 +536,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/__init__.py b/src/engine/SCons/Tool/__init__.py index b80d6e4..ac180a9 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -113,7 +113,7 @@ class Tool(object): finally: if file: file.close() - except ImportError, e: + except ImportError as e: if str(e)!="No module named %s"%self.name: raise SCons.Errors.EnvironmentError(e) try: @@ -125,7 +125,7 @@ class Tool(object): try: importer = zipimport.zipimporter(aPath) return importer.load_module(self.name) - except ImportError, e: + except ImportError as e: pass finally: sys.path = oldpythonpath @@ -143,7 +143,7 @@ class Tool(object): if file: file.close() return module - except ImportError, e: + except ImportError as e: if str(e)!="No module named %s"%self.name: raise SCons.Errors.EnvironmentError(e) try: @@ -152,10 +152,10 @@ class Tool(object): module = importer.load_module(full_name) setattr(SCons.Tool, self.name, module) return module - except ImportError, e: + except ImportError as e: m = "No tool named '%s': %s" % (self.name, e) raise SCons.Errors.EnvironmentError(m) - except ImportError, e: + except ImportError as e: m = "No tool named '%s': %s" % (self.name, e) raise SCons.Errors.EnvironmentError(m) @@ -254,7 +254,7 @@ def VersionShLibLinkNames(version, libname, env): suffix_re = re.escape('.' + version + shlib_suffix) linkname = re.sub(suffix_re, shlib_suffix, libname) if Verbose: - print "VersionShLibLinkNames: linkname = ",linkname + print("VersionShLibLinkNames: linkname = ",linkname) linknames.append(linkname) elif platform == 'posix': # For libfoo.so.x.y.z, linknames libfoo.so libfoo.so.x.y libfoo.so.x @@ -262,7 +262,7 @@ def VersionShLibLinkNames(version, libname, env): # First linkname has no version number linkname = re.sub(suffix_re, shlib_suffix, libname) if Verbose: - print "VersionShLibLinkNames: linkname = ",linkname + print("VersionShLibLinkNames: linkname = ",linkname) linknames.append(linkname) versionparts = version.split('.') major_name = linkname + "." + versionparts[0] @@ -271,7 +271,7 @@ def VersionShLibLinkNames(version, libname, env): #for linkname in [major_name, minor_name]: for linkname in [major_name, ]: if Verbose: - print "VersionShLibLinkNames: linkname ",linkname, ", target ",libname + print("VersionShLibLinkNames: linkname ",linkname, ", target ",libname) linknames.append(linkname) # note: no Windows case here (win32 or cygwin); # MSVC doesn't support this type of versioned shared libs. @@ -294,10 +294,10 @@ symlinks for the platform we are on""" shlib_suffix = env.subst('$SHLIBSUFFIX') shlink_flags = SCons.Util.CLVar(env.subst('$SHLINKFLAGS')) if Verbose: - print "VersionShLib: libname = ",libname - print "VersionShLib: platform = ",platform - print "VersionShLib: shlib_suffix = ",shlib_suffix - print "VersionShLib: target = ",str(target[0]) + print("VersionShLib: libname = ",libname) + print("VersionShLib: platform = ",platform) + print("VersionShLib: shlib_suffix = ",shlib_suffix) + print("VersionShLib: target = ",str(target[0])) if version: # set the shared library link flags @@ -308,7 +308,7 @@ symlinks for the platform we are on""" soname = re.sub(suffix_re, shlib_suffix, libname) + '.' + major shlink_flags += [ '-Wl,-Bsymbolic', '-Wl,-soname=%s' % soname ] if Verbose: - print " soname ",soname,", shlink_flags ",shlink_flags + print(" soname ",soname,", shlink_flags ",shlink_flags) elif platform == 'cygwin': shlink_flags += [ '-Wl,-Bsymbolic', '-Wl,--out-implib,${TARGET.base}.a' ] @@ -317,7 +317,7 @@ symlinks for the platform we are on""" '-compatibility_version', '%s' % version, '-undefined', 'dynamic_lookup' ] if Verbose: - print "VersionShLib: shlink_flags = ",shlink_flags + print("VersionShLib: shlink_flags = ",shlink_flags) envlink = env.Clone() envlink['SHLINKFLAGS'] = shlink_flags else: @@ -330,7 +330,7 @@ symlinks for the platform we are on""" libname = target[0].path linknames = VersionShLibLinkNames(version, libname, env) if Verbose: - print "VerShLib: linknames ",linknames + print("VerShLib: linknames ",linknames) # Here we just need the file name w/o path as the target of the link lib_ver = target[0].name # make symlink of adjacent names in linknames @@ -343,7 +343,7 @@ symlinks for the platform we are on""" pass os.symlink(os.path.basename(linkname),lastlinkname) if Verbose: - print "VerShLib: made sym link of %s -> %s" % (lastlinkname,linkname) + print("VerShLib: made sym link of %s -> %s" % (lastlinkname,linkname)) lastlinkname = linkname # finish chain of sym links with link to the actual library if len(linknames)>0: @@ -353,7 +353,7 @@ symlinks for the platform we are on""" pass os.symlink(lib_ver,lastlinkname) if Verbose: - print "VerShLib: made sym link of %s -> %s" % (linkname, lib_ver) + print("VerShLib: made sym link of %s -> %s" % (linkname, lib_ver)) return result ShLibAction = SCons.Action.Action(VersionedSharedLibrary, None) @@ -631,7 +631,7 @@ class ToolInitializer(object): so we no longer copy and re-bind them when the construction environment gets cloned. """ - for method in self.methods.values(): + for method in list(self.methods.values()): env.RemoveMethod(method) def apply_tools(self, env): diff --git a/src/engine/SCons/Tool/aixcc.py b/src/engine/SCons/Tool/aixcc.py index 9668f79..b1da31e 100644 --- a/src/engine/SCons/Tool/aixcc.py +++ b/src/engine/SCons/Tool/aixcc.py @@ -36,7 +36,7 @@ import os.path import SCons.Platform.aix -import cc +from . import cc packages = ['vac.C', 'ibmcxx.cmp'] diff --git a/src/engine/SCons/Tool/aixf77.py b/src/engine/SCons/Tool/aixf77.py index a667e84..21786ee 100644 --- a/src/engine/SCons/Tool/aixf77.py +++ b/src/engine/SCons/Tool/aixf77.py @@ -36,7 +36,7 @@ import os.path #import SCons.Platform.aix -import f77 +from . import f77 # It would be good to look for the AIX F77 package the same way we're now # looking for the C and C++ packages. This should be as easy as supplying diff --git a/src/engine/SCons/Tool/aixlink.py b/src/engine/SCons/Tool/aixlink.py index 3512522..fc65afb 100644 --- a/src/engine/SCons/Tool/aixlink.py +++ b/src/engine/SCons/Tool/aixlink.py @@ -37,8 +37,8 @@ import os.path import SCons.Util -import aixcc -import link +from . import aixcc +from . import link cplusplus = __import__('c++', globals(), locals(), []) diff --git a/src/engine/SCons/Tool/applelink.py b/src/engine/SCons/Tool/applelink.py index 1939098..ba955a4 100644 --- a/src/engine/SCons/Tool/applelink.py +++ b/src/engine/SCons/Tool/applelink.py @@ -37,7 +37,7 @@ import SCons.Util # Even though the Mac is based on the GNU toolchain, it doesn't understand # the -rpath option, so we use the "link" tool instead of "gnulink". -import link +from . import link def generate(env): """Add Builders and construction variables for applelink to an diff --git a/src/engine/SCons/Tool/cvf.py b/src/engine/SCons/Tool/cvf.py index 2a28e6a..da2c910 100644 --- a/src/engine/SCons/Tool/cvf.py +++ b/src/engine/SCons/Tool/cvf.py @@ -29,7 +29,7 @@ Tool-specific initialization for the Compaq Visual Fortran compiler. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import fortran +from . import fortran compilers = ['f90'] diff --git a/src/engine/SCons/Tool/cyglink.py b/src/engine/SCons/Tool/cyglink.py index 87716cf..1685d7f 100644 --- a/src/engine/SCons/Tool/cyglink.py +++ b/src/engine/SCons/Tool/cyglink.py @@ -11,7 +11,7 @@ selection method. import SCons.Action import SCons.Util -import gnulink +from . import gnulink def shlib_generator(target, source, env, for_signature): cmd = SCons.Util.CLVar(['$SHLINK']) diff --git a/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/docbook.py b/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/docbook.py index c070602..ef03206 100644 --- a/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/docbook.py +++ b/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/docbook.py @@ -82,7 +82,7 @@ def adjustColumnWidths(ctx, nodeset): relParts.append(relPart) absParts.append(pixels) - col = col.next + col = col.__next__ # Ok, now we have the relative widths and absolute widths in # two parallel arrays. @@ -116,7 +116,7 @@ def adjustColumnWidths(ctx, nodeset): pixelWidth = convertLength(tableWidth) if pixelWidth <= absTotal: - print "Table is wider than table width" + print("Table is wider than table width") else: pixelWidth = pixelWidth - absTotal @@ -151,7 +151,7 @@ def adjustColumnWidths(ctx, nodeset): col.setProp("width", widths[count]) count = count+1 - col = col.next + col = col.__next__ return nodeset @@ -163,10 +163,10 @@ def convertLength(length): m = re.search('([+-]?[\d\.]+)(\S+)', length) if m != None and m.lastindex > 1: unit = pixelsPerInch - if unitHash.has_key(m.group(2)): + if m.group(2) in unitHash: unit = unitHash[m.group(2)] else: - print "Unrecognized length: " + m.group(2) + print("Unrecognized length: " + m.group(2)) pixels = unit * float(m.group(1)) else: diff --git a/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/xslt.py b/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/xslt.py index c712f65..8554dd1 100644 --- a/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/xslt.py +++ b/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/xslt.py @@ -18,7 +18,7 @@ try: xmlfile = sys.argv[1] xslfile = sys.argv[2] except IndexError: - print usage + print(usage) sys.exit(1) def quote(astring): @@ -38,12 +38,12 @@ try: while (sys.argv[count]): try: name, value = sys.argv[count].split("=", 2) - if params.has_key(name): - print "Warning: '%s' re-specified; replacing value" % name + if name in params: + print("Warning: '%s' re-specified; replacing value" % name) params[name] = quote(value) except ValueError: - print "Invalid parameter specification: '" + sys.argv[count] + "'" - print usage + print("Invalid parameter specification: '" + sys.argv[count] + "'") + print(usage) sys.exit(1) count = count+1 except IndexError: @@ -70,7 +70,7 @@ result = style.applyStylesheet(doc, params) if outfile: style.saveResultToFilename(outfile, result, 0) else: - print result + print(result) # Free things up style.freeStylesheet() diff --git a/src/engine/SCons/Tool/dvipdf.py b/src/engine/SCons/Tool/dvipdf.py index 7c41e9c..374b9c5 100644 --- a/src/engine/SCons/Tool/dvipdf.py +++ b/src/engine/SCons/Tool/dvipdf.py @@ -100,7 +100,7 @@ def generate(env): if DVIPDFAction is None: DVIPDFAction = SCons.Action.Action(DviPdfFunction, strfunction = DviPdfStrFunction) - import pdf + from . import pdf pdf.generate(env) bld = env['BUILDERS']['PDF'] diff --git a/src/engine/SCons/Tool/f03.py b/src/engine/SCons/Tool/f03.py index 3aab1c0..6c30971 100644 --- a/src/engine/SCons/Tool/f03.py +++ b/src/engine/SCons/Tool/f03.py @@ -36,7 +36,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.Defaults import SCons.Tool import SCons.Util -import fortran +from . import fortran from SCons.Tool.FortranCommon import add_all_to_env, add_f03_to_env compilers = ['f03'] diff --git a/src/engine/SCons/Tool/f95.py b/src/engine/SCons/Tool/f95.py index 5ce5e57..5baa31e 100644 --- a/src/engine/SCons/Tool/f95.py +++ b/src/engine/SCons/Tool/f95.py @@ -36,7 +36,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.Defaults import SCons.Tool import SCons.Util -import fortran +from . import fortran from SCons.Tool.FortranCommon import add_all_to_env, add_f95_to_env compilers = ['f95'] diff --git a/src/engine/SCons/Tool/filesystem.py b/src/engine/SCons/Tool/filesystem.py index 31c8abc..3b8ee4c 100644 --- a/src/engine/SCons/Tool/filesystem.py +++ b/src/engine/SCons/Tool/filesystem.py @@ -66,7 +66,7 @@ def generate(env): try: env['BUILDERS']['CopyTo'] env['BUILDERS']['CopyAs'] - except KeyError, e: + except KeyError as e: global copyToBuilder if copyToBuilder is None: copyToBuilder = SCons.Builder.Builder( diff --git a/src/engine/SCons/Tool/gcc.py b/src/engine/SCons/Tool/gcc.py index 71f60a3..4f87b24 100644 --- a/src/engine/SCons/Tool/gcc.py +++ b/src/engine/SCons/Tool/gcc.py @@ -33,7 +33,7 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import cc +from . import cc import os import re import subprocess diff --git a/src/engine/SCons/Tool/gfortran.py b/src/engine/SCons/Tool/gfortran.py index 4f3e7e4..7b05e68 100644 --- a/src/engine/SCons/Tool/gfortran.py +++ b/src/engine/SCons/Tool/gfortran.py @@ -36,7 +36,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.Util -import fortran +from . import fortran def generate(env): """Add Builders and construction variables for gfortran to an diff --git a/src/engine/SCons/Tool/gnulink.py b/src/engine/SCons/Tool/gnulink.py index bf71270..ea8d7bd 100644 --- a/src/engine/SCons/Tool/gnulink.py +++ b/src/engine/SCons/Tool/gnulink.py @@ -35,7 +35,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.Util -import link +from . import link linkers = ['g++', 'gcc'] diff --git a/src/engine/SCons/Tool/gs.py b/src/engine/SCons/Tool/gs.py index ada169a..c5506ce 100644 --- a/src/engine/SCons/Tool/gs.py +++ b/src/engine/SCons/Tool/gs.py @@ -57,7 +57,7 @@ def generate(env): if GhostscriptAction is None: GhostscriptAction = SCons.Action.Action('$GSCOM', '$GSCOMSTR') - import pdf + from . import pdf pdf.generate(env) bld = env['BUILDERS']['PDF'] diff --git a/src/engine/SCons/Tool/hpcc.py b/src/engine/SCons/Tool/hpcc.py index 30f4964..51d2e38 100644 --- a/src/engine/SCons/Tool/hpcc.py +++ b/src/engine/SCons/Tool/hpcc.py @@ -34,7 +34,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.Util -import cc +from . import cc def generate(env): """Add Builders and construction variables for aCC & cc to an Environment.""" diff --git a/src/engine/SCons/Tool/hplink.py b/src/engine/SCons/Tool/hplink.py index 17dbe05..10ef30b 100644 --- a/src/engine/SCons/Tool/hplink.py +++ b/src/engine/SCons/Tool/hplink.py @@ -37,7 +37,7 @@ import os.path import SCons.Util -import link +from . import link ccLinker = None diff --git a/src/engine/SCons/Tool/icc.py b/src/engine/SCons/Tool/icc.py index db15642..11ea075 100644 --- a/src/engine/SCons/Tool/icc.py +++ b/src/engine/SCons/Tool/icc.py @@ -33,7 +33,7 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import cc +from . import cc def generate(env): """Add Builders and construction variables for the OS/2 to an Environment.""" diff --git a/src/engine/SCons/Tool/ifl.py b/src/engine/SCons/Tool/ifl.py index 30b3672..865d2ba 100644 --- a/src/engine/SCons/Tool/ifl.py +++ b/src/engine/SCons/Tool/ifl.py @@ -35,7 +35,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.Defaults from SCons.Scanner.Fortran import FortranScan -from FortranCommon import add_all_to_env +from .FortranCommon import add_all_to_env def generate(env): """Add Builders and construction variables for ifl to an Environment.""" diff --git a/src/engine/SCons/Tool/ifort.py b/src/engine/SCons/Tool/ifort.py index 4b2fd65..638bd12 100644 --- a/src/engine/SCons/Tool/ifort.py +++ b/src/engine/SCons/Tool/ifort.py @@ -36,7 +36,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.Defaults from SCons.Scanner.Fortran import FortranScan -from FortranCommon import add_all_to_env +from .FortranCommon import add_all_to_env def generate(env): """Add Builders and construction variables for ifort to an Environment.""" diff --git a/src/engine/SCons/Tool/install.py b/src/engine/SCons/Tool/install.py index 0c81d05..4236e81 100644 --- a/src/engine/SCons/Tool/install.py +++ b/src/engine/SCons/Tool/install.py @@ -82,21 +82,21 @@ def scons_copytree(src, dst, symlinks=False): else: shutil.copy2(srcname, dstname) # XXX What about devices, sockets etc.? - except (IOError, os.error), why: + except (IOError, os.error) as why: errors.append((srcname, dstname, str(why))) # catch the CopytreeError from the recursive copytree so that we can # continue with other files - except CopytreeError, err: + except CopytreeError as err: errors.extend(err.args[0]) try: shutil.copystat(src, dst) except WindowsError: # can't copy file access times on Windows pass - except OSError, why: + except OSError as why: errors.extend((src, dst, str(why))) if errors: - raise CopytreeError, errors + raise CopytreeError(errors) # @@ -174,7 +174,7 @@ def versionedLibVersion(dest, env): version_File = version_re.findall(versioned_re.findall(libname)[-1])[-1] if Verbose: - print "install: version_File ", version_File + print("install: version_File ", version_File) # result is False if we did not find a versioned shared library name, so return and empty list if not result: return (None, libname, install_dir) @@ -188,7 +188,7 @@ def versionedLibVersion(dest, env): if version != version_File: #raise SCons.Errors.UserError("SHLIBVERSION '%s' does not match the version # '%s' in the filename" % (version, version_File) ) - print "SHLIBVERSION '%s' does not match the version # '%s' in the filename, proceeding based on file name" % (version, version_File) + print("SHLIBVERSION '%s' does not match the version # '%s' in the filename, proceeding based on file name" % (version, version_File)) version = version_File return (version, libname, install_dir) @@ -202,7 +202,7 @@ def versionedLibLinks(dest, source, env): # libname includes the version number if one was given linknames = SCons.Tool.VersionShLibLinkNames(version,libname,env) if Verbose: - print "versionedLibLinks: linknames ",linknames + print("versionedLibLinks: linknames ",linknames) # Here we just need the file name w/o path as the target of the link lib_ver = libname # make symlink of adjacent names in linknames @@ -210,7 +210,7 @@ def versionedLibLinks(dest, source, env): linkname = linknames[count] fulllinkname = os.path.join(install_dir, linkname) if Verbose: - print "full link name ",fulllinkname + print("full link name ",fulllinkname) if count > 0: try: os.remove(lastlinkname) @@ -218,7 +218,7 @@ def versionedLibLinks(dest, source, env): pass os.symlink(os.path.basename(fulllinkname),lastlinkname) if Verbose: - print "versionedLibLinks: made sym link of %s -> %s" % (lastlinkname,os.path.basename(fulllinkname)) + print("versionedLibLinks: made sym link of %s -> %s" % (lastlinkname,os.path.basename(fulllinkname))) lastlinkname = fulllinkname # finish chain of sym links with link to the actual library if len(linknames)>0: @@ -228,7 +228,7 @@ def versionedLibLinks(dest, source, env): pass os.symlink(lib_ver,lastlinkname) if Verbose: - print "versionedLibLinks: made sym link of %s -> %s" % (lib_ver,lastlinkname) + print("versionedLibLinks: made sym link of %s -> %s" % (lib_ver,lastlinkname)) return def installFunc(target, source, env): @@ -298,7 +298,7 @@ def add_versioned_targets_to_INSTALLED_FILES(target, source, env): Verbose = False _INSTALLED_FILES.extend(target) if Verbose: - print "ver lib emitter ",repr(target) + print("ver lib emitter ",repr(target)) # see if we have a versioned shared library, if so generate side effects version, libname, install_dir = versionedLibVersion(target[0].path, env) @@ -307,13 +307,13 @@ def add_versioned_targets_to_INSTALLED_FILES(target, source, env): linknames = SCons.Tool.VersionShLibLinkNames(version,libname,env) for linkname in linknames: if Verbose: - print "make side effect of %s" % os.path.join(install_dir, linkname) + print("make side effect of %s" % os.path.join(install_dir, linkname)) fulllinkname = os.path.join(install_dir, linkname) env.SideEffect(fulllinkname,target[0]) env.Clean(target[0],fulllinkname) _INSTALLED_FILES.append(fulllinkname) if Verbose: - print "installed list ", _INSTALLED_FILES + print("installed list ", _INSTALLED_FILES) _UNIQUE_INSTALLED_FILES = None return (target, source) diff --git a/src/engine/SCons/Tool/intelc.py b/src/engine/SCons/Tool/intelc.py index 4201092..8b178a7 100644 --- a/src/engine/SCons/Tool/intelc.py +++ b/src/engine/SCons/Tool/intelc.py @@ -30,7 +30,7 @@ selection method. # 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. -from __future__ import division + __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -206,17 +206,16 @@ def get_all_compiler_versions(): # Registry points to nonexistent dir. Ignore this # version. value = get_intel_registry_value('ProductDir', subkey, 'IA32') - except MissingRegistryError, e: + except MissingRegistryError as e: # Registry key is left dangling (potentially # after uninstalling). - print \ - "scons: *** Ignoring the registry key for the Intel compiler version %s.\n" \ + print("scons: *** Ignoring the registry key for the Intel compiler version %s.\n" \ "scons: *** It seems that the compiler was uninstalled and that the registry\n" \ - "scons: *** was not cleaned up properly.\n" % subkey + "scons: *** was not cleaned up properly.\n" % subkey) else: - print "scons: *** Ignoring "+str(value) + print("scons: *** Ignoring "+str(value)) i = i + 1 except EnvironmentError: @@ -424,8 +423,8 @@ def generate(env, version=None, abi=None, topdir=None, verbose=0): bindir="bin" libdir="lib" if verbose: - print "Intel C compiler: using version %s (%g), abi %s, in '%s/%s'"%\ - (repr(version), linux_ver_normalize(version),abi,topdir,bindir) + print("Intel C compiler: using version %s (%g), abi %s, in '%s/%s'"%\ + (repr(version), linux_ver_normalize(version),abi,topdir,bindir)) if is_linux: # Show the actual compiler version by running the compiler. os.system('%s/%s/icc --version'%(topdir,bindir)) @@ -439,14 +438,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/latex.py b/src/engine/SCons/Tool/latex.py index 1c71743..f30356b 100644 --- a/src/engine/SCons/Tool/latex.py +++ b/src/engine/SCons/Tool/latex.py @@ -55,10 +55,10 @@ def generate(env): env.AppendUnique(LATEXSUFFIXES=SCons.Tool.LaTeXSuffixes) - import dvi + from . import dvi dvi.generate(env) - import pdf + from . import pdf pdf.generate(env) bld = env['BUILDERS']['DVI'] diff --git a/src/engine/SCons/Tool/link.py b/src/engine/SCons/Tool/link.py index 3f20fe0..5539f62 100644 --- a/src/engine/SCons/Tool/link.py +++ b/src/engine/SCons/Tool/link.py @@ -81,7 +81,7 @@ def shlib_emitter(target, source, env): env.SideEffect(name, target[0]) env.Clean(target[0], name) if Verbose: - print "shlib_emitter: add side effect - ",name + print("shlib_emitter: add side effect - ",name) except KeyError: version = None return (target, source) @@ -104,16 +104,16 @@ def shlib_emitter_names(target, source, env): # generate library name with the version number version_name = target[0].name + '.' + version if Verbose: - print "shlib_emitter_names: target is ", version_name - print "shlib_emitter_names: side effect: ", name + print("shlib_emitter_names: target is ", version_name) + print("shlib_emitter_names: side effect: ", name) # add version_name to list of names to be a Side effect version_names.append(version_name) if Verbose: - print "shlib_emitter_names: versionparts ",versionparts + print("shlib_emitter_names: versionparts ",versionparts) for ver in versionparts[0:-1]: name = name + '.' + ver if Verbose: - print "shlib_emitter_names: side effect: ", name + print("shlib_emitter_names: side effect: ", name) # add name to list of names to be a Side effect version_names.append(name) elif platform == 'darwin': @@ -123,8 +123,8 @@ def shlib_emitter_names(target, source, env): suffix_re = re.escape(shlib_suffix) version_name = re.sub(suffix_re, '.' + version + shlib_suffix, name) if Verbose: - print "shlib_emitter_names: target is ", version_name - print "shlib_emitter_names: side effect: ", name + print("shlib_emitter_names: target is ", version_name) + print("shlib_emitter_names: side effect: ", name) # add version_name to list of names to be a Side effect version_names.append(version_name) elif platform == 'cygwin': @@ -134,8 +134,8 @@ def shlib_emitter_names(target, source, env): suffix_re = re.escape(shlib_suffix) version_name = re.sub(suffix_re, '-' + re.sub('\.', '-', version) + shlib_suffix, name) if Verbose: - print "shlib_emitter_names: target is ", version_name - print "shlib_emitter_names: side effect: ", name + print("shlib_emitter_names: target is ", version_name) + print("shlib_emitter_names: side effect: ", name) # add version_name to list of names to be a Side effect version_names.append(version_name) diff --git a/src/engine/SCons/Tool/midl.py b/src/engine/SCons/Tool/midl.py index 64b927a..7a59e33 100644 --- a/src/engine/SCons/Tool/midl.py +++ b/src/engine/SCons/Tool/midl.py @@ -39,7 +39,7 @@ import SCons.Defaults import SCons.Scanner.IDL import SCons.Util -from MSCommon import msvc_exists +from .MSCommon import msvc_exists def midl_emitter(target, source, env): """Produces a list of outputs from the MIDL compiler""" diff --git a/src/engine/SCons/Tool/msgfmt.py b/src/engine/SCons/Tool/msgfmt.py index 352ba77..4fe6afd 100644 --- a/src/engine/SCons/Tool/msgfmt.py +++ b/src/engine/SCons/Tool/msgfmt.py @@ -41,7 +41,7 @@ class _MOFileBuilder(BuilderBase): import SCons.Util from SCons.Tool.GettextCommon import _read_linguas_from_files linguas_files = None - if env.has_key('LINGUAS_FILE') and env['LINGUAS_FILE'] is not None: + if 'LINGUAS_FILE' in env and env['LINGUAS_FILE'] is not None: linguas_files = env['LINGUAS_FILE'] # This should prevent from endless recursion. env['LINGUAS_FILE'] = None diff --git a/src/engine/SCons/Tool/msginit.py b/src/engine/SCons/Tool/msginit.py index 5e9c0e4..39f460d 100644 --- a/src/engine/SCons/Tool/msginit.py +++ b/src/engine/SCons/Tool/msginit.py @@ -35,7 +35,7 @@ def _optional_no_translator_flag(env): """ Return '--no-translator' flag if we run *msginit(1)* in non-interactive mode.""" import SCons.Util - if env.has_key('POAUTOINIT'): + if 'POAUTOINIT' in env: autoinit = env['POAUTOINIT'] else: autoinit = False @@ -66,7 +66,7 @@ def _POInitBuilderWrapper(env, target=None, source=_null, **kw): if source is _null: if 'POTDOMAIN' in kw: domain = kw['POTDOMAIN'] - elif env.has_key('POTDOMAIN'): + elif 'POTDOMAIN' in env: domain = env['POTDOMAIN'] else: domain = 'messages' diff --git a/src/engine/SCons/Tool/msgmerge.py b/src/engine/SCons/Tool/msgmerge.py index f3710ab..11d7b48 100644 --- a/src/engine/SCons/Tool/msgmerge.py +++ b/src/engine/SCons/Tool/msgmerge.py @@ -58,7 +58,7 @@ def _POUpdateBuilderWrapper(env, target=None, source=_null, **kw): if source is _null: if 'POTDOMAIN' in kw: domain = kw['POTDOMAIN'] - elif env.has_key('POTDOMAIN') and env['POTDOMAIN']: + elif 'POTDOMAIN' in env and env['POTDOMAIN']: domain = env['POTDOMAIN'] else: domain = 'messages' diff --git a/src/engine/SCons/Tool/mslib.py b/src/engine/SCons/Tool/mslib.py index 8a4af57..df8d877 100644 --- a/src/engine/SCons/Tool/mslib.py +++ b/src/engine/SCons/Tool/mslib.py @@ -39,7 +39,7 @@ import SCons.Tool.msvs import SCons.Tool.msvc import SCons.Util -from MSCommon import msvc_exists, msvc_setup_env_once +from .MSCommon import msvc_exists, msvc_setup_env_once def generate(env): """Add Builders and construction variables for lib to an Environment.""" diff --git a/src/engine/SCons/Tool/mslink.py b/src/engine/SCons/Tool/mslink.py index 40f112b..b56d34a 100644 --- a/src/engine/SCons/Tool/mslink.py +++ b/src/engine/SCons/Tool/mslink.py @@ -44,7 +44,7 @@ import SCons.Tool.msvc import SCons.Tool.msvs import SCons.Util -from MSCommon import msvc_setup_env_once, msvc_exists +from .MSCommon import msvc_setup_env_once, msvc_exists def pdbGenerator(env, target, source, for_signature): try: @@ -195,7 +195,7 @@ def RegServerFunc(target, source, env): if ret: raise SCons.Errors.UserError("Unable to register %s" % target[0]) else: - print "Registered %s sucessfully" % target[0] + print("Registered %s sucessfully" % target[0]) return ret return 0 @@ -212,10 +212,10 @@ def embedManifestDllCheck(target, source, env): if os.path.exists(manifestSrc): ret = (embedManifestDllAction) ([target[0]],None,env) if ret: - raise SCons.Errors.UserError, "Unable to embed manifest into %s" % (target[0]) + raise SCons.Errors.UserError("Unable to embed manifest into %s" % (target[0])) return ret else: - print '(embed: no %s.manifest found; not embedding.)'%str(target[0]) + print('(embed: no %s.manifest found; not embedding.)'%str(target[0])) return 0 def embedManifestExeCheck(target, source, env): @@ -226,10 +226,10 @@ def embedManifestExeCheck(target, source, env): if os.path.exists(manifestSrc): ret = (embedManifestExeAction) ([target[0]],None,env) if ret: - raise SCons.Errors.UserError, "Unable to embed manifest into %s" % (target[0]) + raise SCons.Errors.UserError("Unable to embed manifest into %s" % (target[0])) return ret else: - print '(embed: no %s.manifest found; not embedding.)'%str(target[0]) + print('(embed: no %s.manifest found; not embedding.)'%str(target[0])) return 0 embedManifestDllCheckAction = SCons.Action.Action(embedManifestDllCheck, None) diff --git a/src/engine/SCons/Tool/mssdk.py b/src/engine/SCons/Tool/mssdk.py index 6103f30..f373002 100644 --- a/src/engine/SCons/Tool/mssdk.py +++ b/src/engine/SCons/Tool/mssdk.py @@ -33,7 +33,7 @@ It will usually be imported through the generic SCons.Tool.Tool() selection method. """ -from MSCommon import mssdk_exists, \ +from .MSCommon import mssdk_exists, \ mssdk_setup_env def generate(env): diff --git a/src/engine/SCons/Tool/msvc.py b/src/engine/SCons/Tool/msvc.py index d42c257..0bc296f 100644 --- a/src/engine/SCons/Tool/msvc.py +++ b/src/engine/SCons/Tool/msvc.py @@ -47,7 +47,7 @@ import SCons.Util import SCons.Warnings import SCons.Scanner.RC -from MSCommon import msvc_exists, msvc_setup_env_once +from .MSCommon import msvc_exists, msvc_setup_env_once CSuffixes = ['.c', '.C'] CXXSuffixes = ['.cc', '.cpp', '.cxx', '.c++', '.C++'] diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py index 06ce486..0879a28 100644 --- a/src/engine/SCons/Tool/msvs.py +++ b/src/engine/SCons/Tool/msvs.py @@ -51,7 +51,7 @@ import SCons.PathList import SCons.Util import SCons.Warnings -from MSCommon import msvc_exists, msvc_setup_env_once +from .MSCommon import msvc_exists, msvc_setup_env_once from SCons.Defaults import processDefines ############################################################################## @@ -351,13 +351,13 @@ class _DSPGenerator(object): config.platform = 'Win32' self.configs[variant] = config - print "Adding '" + self.name + ' - ' + config.variant + '|' + config.platform + "' to '" + str(dspfile) + "'" + print("Adding '" + self.name + ' - ' + config.variant + '|' + config.platform + "' to '" + str(dspfile) + "'") for i in range(len(variants)): AddConfig(self, variants[i], buildtarget[i], outdir[i], runfile[i], cmdargs) 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) @@ -480,7 +480,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 @@ -551,7 +551,7 @@ class _GenerateV6DSP(_DSPGenerator): def Build(self): try: self.file = open(self.dspabs,'w') - except IOError, detail: + except IOError as detail: raise SCons.Errors.InternalError('Unable to open "' + self.dspabs + '" for writing:' + str(detail)) else: self.PrintHeader() @@ -744,7 +744,7 @@ class _GenerateV7DSP(_DSPGenerator): 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: @@ -774,7 +774,7 @@ class _GenerateV7DSP(_DSPGenerator): self.file.write('\t\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: @@ -861,7 +861,7 @@ class _GenerateV7DSP(_DSPGenerator): def Build(self): try: self.file = open(self.dspabs,'w') - except IOError, detail: + except IOError as detail: raise SCons.Errors.InternalError('Unable to open "' + self.dspabs + '" for writing:' + str(detail)) else: self.PrintHeader() @@ -1029,7 +1029,7 @@ class _GenerateV10DSP(_DSPGenerator): self.filtersabs = self.dspabs + '.filters' try: self.filters_file = open(self.filtersabs, 'w') - except IOError, detail: + except IOError as detail: raise SCons.Errors.InternalError('Unable to open "' + self.filtersabs + '" for writing:' + str(detail)) self.filters_file.write('\n' @@ -1055,7 +1055,7 @@ class _GenerateV10DSP(_DSPGenerator): 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): @@ -1072,7 +1072,7 @@ class _GenerateV10DSP(_DSPGenerator): '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: @@ -1098,7 +1098,7 @@ class _GenerateV10DSP(_DSPGenerator): '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 @@ -1158,12 +1158,12 @@ class _GenerateV10DSP(_DSPGenerator): '\t\n' % str(self.sconscript)) def Parse(self): - print "_GenerateV10DSP.Parse()" + print("_GenerateV10DSP.Parse()") def Build(self): try: self.file = open(self.dspabs, 'w') - except IOError, detail: + except IOError as detail: raise SCons.Errors.InternalError('Unable to open "' + self.dspabs + '" for writing:' + str(detail)) else: self.PrintHeader() @@ -1242,7 +1242,7 @@ class _GenerateV7DSW(_DSWGenerator): config.platform = 'Win32' self.configs[variant] = config - print "Adding '" + self.name + ' - ' + config.variant + '|' + config.platform + "' to '" + str(dswfile) + "'" + print("Adding '" + self.name + ' - ' + config.variant + '|' + config.platform + "' to '" + str(dswfile) + "'") if 'variant' not in env: raise SCons.Errors.InternalError("You must specify a 'variant' argument (i.e. 'Debug' or " +\ @@ -1254,7 +1254,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) @@ -1424,7 +1424,7 @@ class _GenerateV7DSW(_DSWGenerator): def Build(self): try: self.file = open(self.dswfile,'w') - except IOError, detail: + except IOError as detail: raise SCons.Errors.InternalError('Unable to open "' + self.dswfile + '" for writing:' + str(detail)) else: self.PrintSolution() @@ -1473,7 +1473,7 @@ class _GenerateV6DSW(_DSWGenerator): def Build(self): try: self.file = open(self.dswfile,'w') - except IOError, detail: + except IOError as detail: raise SCons.Errors.InternalError('Unable to open "' + self.dswfile + '" for writing:' + str(detail)) else: self.PrintWorkspace() @@ -1530,8 +1530,8 @@ def GenerateProject(target, source, env): if not dspfile is builddspfile: try: bdsp = open(str(builddspfile), "w+") - except IOError, detail: - print 'Unable to open "' + str(dspfile) + '" for writing:',detail,'\n' + except IOError as detail: + print('Unable to open "' + str(dspfile) + '" for writing:',detail,'\n') raise bdsp.write("This is just a placeholder file.\nThe real project file is here:\n%s\n" % dspfile.get_abspath()) @@ -1546,8 +1546,8 @@ def GenerateProject(target, source, env): try: bdsw = open(str(builddswfile), "w+") - except IOError, detail: - print 'Unable to open "' + str(dspfile) + '" for writing:',detail,'\n' + except IOError as detail: + print('Unable to open "' + str(dspfile) + '" for writing:',detail,'\n') raise bdsw.write("This is just a placeholder file.\nThe real workspace file is here:\n%s\n" % dswfile.get_abspath()) diff --git a/src/engine/SCons/Tool/msvsTests.py b/src/engine/SCons/Tool/msvsTests.py index 7d966c1..1466db6 100644 --- a/src/engine/SCons/Tool/msvsTests.py +++ b/src/engine/SCons/Tool/msvsTests.py @@ -743,7 +743,7 @@ if __name__ == "__main__": ] for test_class in test_classes: - print "TEST: ", test_class.__doc__ + print("TEST: ", test_class.__doc__) back_osenv = copy.deepcopy(os.environ) try: # XXX: overriding the os.environ is bad, but doing it diff --git a/src/engine/SCons/Tool/packaging/__init__.py b/src/engine/SCons/Tool/packaging/__init__.py index 95311a2..c3de2aa 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 @@ -120,7 +120,7 @@ def Package(env, target=None, source=None, **kw): try: file,path,desc=imp.find_module(type, __path__) return imp.load_module(type, file, path, desc) - except ImportError, e: + except ImportError as e: raise EnvironmentError("packager %s not available: %s"%(type,str(e))) packagers=list(map(load_packager, PACKAGETYPE)) @@ -141,7 +141,7 @@ def Package(env, target=None, source=None, **kw): if 'PACKAGEROOT' not in kw: kw['PACKAGEROOT'] = default_name%kw - except KeyError, e: + except KeyError as e: raise SCons.Errors.UserError( "Missing Packagetag '%s'"%e.args[0] ) # setup the source files @@ -157,10 +157,10 @@ def Package(env, target=None, source=None, **kw): assert( len(target) == 0 ) - except KeyError, e: + except KeyError as e: raise SCons.Errors.UserError( "Missing Packagetag '%s' for %s packager"\ % (e.args[0],packager.__name__) ) - except TypeError, e: + except TypeError as e: # this exception means that a needed argument for the packager is # missing. As our packagers get their "tags" as named function # arguments we need to find out which one is missing. diff --git a/src/engine/SCons/Tool/packaging/ipk.py b/src/engine/SCons/Tool/packaging/ipk.py index 6549445..ad27a62 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 fe78c9c..70fdc48 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: @@ -216,7 +216,7 @@ def build_wxsfile(target, source, env): if 'CHANGE_SPECFILE' in env: env['CHANGE_SPECFILE'](target, source) - except KeyError, e: + except KeyError as e: raise SCons.Errors.UserError( '"%s" package field for MSI is missing.' % e.args[0] ) # @@ -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 07857d1..4958065 100644 --- a/src/engine/SCons/Tool/packaging/rpm.py +++ b/src/engine/SCons/Tool/packaging/rpm.py @@ -107,7 +107,7 @@ def collectintargz(target, source, env): try: #tarball = env['SOURCE_URL'].split('/')[-1] tarball = env['SOURCE_URL'].split('/')[-1] - except KeyError, e: + except KeyError as e: raise SCons.Errors.UserError( "Missing PackageTag '%s' for RPM packager" % e.args[0] ) tarball = src_targz.package(env, source=sources, target=tarball, @@ -143,7 +143,7 @@ def build_specfile(target, source, env): if 'CHANGE_SPECFILE' in env: env['CHANGE_SPECFILE'](target, source) - except KeyError, e: + except KeyError as e: raise SCons.Errors.UserError( '"%s" package field for RPM is missing.' % e.args[0] ) @@ -277,7 +277,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: tags[k]=getattr(file, k) except AttributeError: @@ -331,7 +331,7 @@ class SimpleTagCompiler(object): for key, replacement in domestic: try: str = str + replacement % values[key] - except KeyError, e: + except KeyError as e: if self.mandatory: raise e @@ -340,11 +340,11 @@ class SimpleTagCompiler(object): for key, replacement in international: try: #int_values_for_key = [ (get_country_code(k),v) for k,v in values.items() if strip_country_code(k) == key ] - 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 - except KeyError, e: + except KeyError as e: if self.mandatory: raise e diff --git a/src/engine/SCons/Tool/pdflatex.py b/src/engine/SCons/Tool/pdflatex.py index 922e718..fbffb23 100644 --- a/src/engine/SCons/Tool/pdflatex.py +++ b/src/engine/SCons/Tool/pdflatex.py @@ -62,7 +62,7 @@ def generate(env): env.AppendUnique(LATEXSUFFIXES=SCons.Tool.LaTeXSuffixes) - import pdf + from . import pdf pdf.generate(env) bld = env['BUILDERS']['PDF'] diff --git a/src/engine/SCons/Tool/pdftex.py b/src/engine/SCons/Tool/pdftex.py index 30c56af..e9a0bda 100644 --- a/src/engine/SCons/Tool/pdftex.py +++ b/src/engine/SCons/Tool/pdftex.py @@ -85,7 +85,7 @@ def generate(env): env.AppendUnique(LATEXSUFFIXES=SCons.Tool.LaTeXSuffixes) - import pdf + from . import pdf pdf.generate(env) bld = env['BUILDERS']['PDF'] diff --git a/src/engine/SCons/Tool/qt.py b/src/engine/SCons/Tool/qt.py index 716c7d5..fdfdd26 100644 --- a/src/engine/SCons/Tool/qt.py +++ b/src/engine/SCons/Tool/qt.py @@ -130,12 +130,12 @@ class _Automoc(object): if not obj.has_builder(): # binary obj file provided if debug: - print "scons: qt: '%s' seems to be a binary. Discarded." % str(obj) + print("scons: qt: '%s' seems to be a binary. Discarded." % str(obj)) continue cpp = obj.sources[0] if not splitext(str(cpp))[1] in cxx_suffixes: if debug: - print "scons: qt: '%s' is no cxx file. Discarded." % str(cpp) + print("scons: qt: '%s' is no cxx file. Discarded." % str(cpp)) # c or fortran source continue #cpp_contents = comment.sub('', cpp.get_text_contents()) @@ -148,12 +148,12 @@ class _Automoc(object): h = find_file(hname, (cpp.get_dir(),), env.File) if h: if debug: - print "scons: qt: Scanning '%s' (header of '%s')" % (str(h), str(cpp)) + print("scons: qt: Scanning '%s' (header of '%s')" % (str(h), str(cpp))) #h_contents = comment.sub('', h.get_text_contents()) h_contents = h.get_text_contents() break if not h and debug: - print "scons: qt: no header for '%s'." % (str(cpp)) + print("scons: qt: no header for '%s'." % (str(cpp))) if h and q_object_search.search(h_contents): # h file with the Q_OBJECT macro found -> add moc_cpp moc_cpp = env.Moc(h) @@ -161,14 +161,14 @@ class _Automoc(object): out_sources.append(moc_o) #moc_cpp.target_scanner = SCons.Defaults.CScan if debug: - print "scons: qt: found Q_OBJECT macro in '%s', moc'ing to '%s'" % (str(h), str(moc_cpp)) + print("scons: qt: found Q_OBJECT macro in '%s', moc'ing to '%s'" % (str(h), str(moc_cpp))) if cpp and q_object_search.search(cpp_contents): # cpp file with Q_OBJECT macro found -> add moc # (to be included in cpp) moc = env.Moc(cpp) env.Ignore(moc, moc) if debug: - print "scons: qt: found Q_OBJECT macro in '%s', moc'ing to '%s'" % (str(cpp), str(moc)) + print("scons: qt: found Q_OBJECT macro in '%s', moc'ing to '%s'" % (str(cpp), str(moc))) #moc.source_scanner = SCons.Defaults.CScan # restore the original env attributes (FIXME) objBuilder.env = objBuilderEnv diff --git a/src/engine/SCons/Tool/rpmutils.py b/src/engine/SCons/Tool/rpmutils.py index 90e3d74..e96c54c 100644 --- a/src/engine/SCons/Tool/rpmutils.py +++ b/src/engine/SCons/Tool/rpmutils.py @@ -491,7 +491,7 @@ def updateRpmDicts(rpmrc, pyfile): key = tokens[0] if key in sections: # Have we met this section before? - if not data.has_key(tokens[0]): + if tokens[0] not in data: # No, so insert it data[key] = {} # Insert data @@ -509,7 +509,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.iteritems(): + for key, entries in data.items(): out.write("%s = {\n" % key) for arch in sorted(entries.keys()): out.write(" '%s' : ['%s'],\n" % (arch, "','".join(entries[arch]))) @@ -519,7 +519,7 @@ def updateRpmDicts(rpmrc, pyfile): pass def usage(): - print "rpmutils.py rpmrc.in rpmutils.py" + print("rpmutils.py rpmrc.in rpmutils.py") def main(): import sys diff --git a/src/engine/SCons/Tool/sgicc.py b/src/engine/SCons/Tool/sgicc.py index 662eb7d..94a0497 100644 --- a/src/engine/SCons/Tool/sgicc.py +++ b/src/engine/SCons/Tool/sgicc.py @@ -33,7 +33,7 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import cc +from . import cc def generate(env): """Add Builders and construction variables for gcc to an Environment.""" diff --git a/src/engine/SCons/Tool/sgilink.py b/src/engine/SCons/Tool/sgilink.py index 6244141..b1e7921 100644 --- a/src/engine/SCons/Tool/sgilink.py +++ b/src/engine/SCons/Tool/sgilink.py @@ -35,7 +35,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.Util -import link +from . import link linkers = ['CC', 'cc'] diff --git a/src/engine/SCons/Tool/suncc.py b/src/engine/SCons/Tool/suncc.py index 458538b..4651219 100644 --- a/src/engine/SCons/Tool/suncc.py +++ b/src/engine/SCons/Tool/suncc.py @@ -34,7 +34,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.Util -import cc +from . import cc def generate(env): """ diff --git a/src/engine/SCons/Tool/sunf77.py b/src/engine/SCons/Tool/sunf77.py index d05ce54..20d1893 100644 --- a/src/engine/SCons/Tool/sunf77.py +++ b/src/engine/SCons/Tool/sunf77.py @@ -35,7 +35,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.Util -from FortranCommon import add_all_to_env +from .FortranCommon import add_all_to_env compilers = ['sunf77', 'f77'] diff --git a/src/engine/SCons/Tool/sunf90.py b/src/engine/SCons/Tool/sunf90.py index 93b89c0..ce1697c 100644 --- a/src/engine/SCons/Tool/sunf90.py +++ b/src/engine/SCons/Tool/sunf90.py @@ -35,7 +35,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.Util -from FortranCommon import add_all_to_env +from .FortranCommon import add_all_to_env compilers = ['sunf90', 'f90'] diff --git a/src/engine/SCons/Tool/sunf95.py b/src/engine/SCons/Tool/sunf95.py index c09026c..218569c 100644 --- a/src/engine/SCons/Tool/sunf95.py +++ b/src/engine/SCons/Tool/sunf95.py @@ -35,7 +35,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.Util -from FortranCommon import add_all_to_env +from .FortranCommon import add_all_to_env compilers = ['sunf95', 'f95'] diff --git a/src/engine/SCons/Tool/sunlink.py b/src/engine/SCons/Tool/sunlink.py index 5996a30..af13392 100644 --- a/src/engine/SCons/Tool/sunlink.py +++ b/src/engine/SCons/Tool/sunlink.py @@ -37,7 +37,7 @@ import os.path import SCons.Util -import link +from . import link ccLinker = None diff --git a/src/engine/SCons/Tool/tex.py b/src/engine/SCons/Tool/tex.py index 5f24df0..febec35 100644 --- a/src/engine/SCons/Tool/tex.py +++ b/src/engine/SCons/Tool/tex.py @@ -163,15 +163,15 @@ def FindFile(name,suffixes,paths,env,requireExt=False): if ext: name = name + ext if Verbose: - print " searching for '%s' with extensions: " % name,suffixes + print(" searching for '%s' with extensions: " % name,suffixes) for path in paths: testName = os.path.join(path,name) if Verbose: - print " look for '%s'" % testName + print(" look for '%s'" % testName) if os.path.isfile(testName): if Verbose: - print " found '%s'" % testName + print(" found '%s'" % testName) return env.fs.File(testName) else: name_ext = SCons.Util.splitext(testName)[1] @@ -182,14 +182,14 @@ def FindFile(name,suffixes,paths,env,requireExt=False): for suffix in suffixes: testNameExt = testName + suffix if Verbose: - print " look for '%s'" % testNameExt + print(" look for '%s'" % testNameExt) if os.path.isfile(testNameExt): if Verbose: - print " found '%s'" % testNameExt + print(" found '%s'" % testNameExt) return env.fs.File(testNameExt) if Verbose: - print " did not find '%s'" % name + print(" did not find '%s'" % name) return None def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None): @@ -249,7 +249,7 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None saved_hashes[suffix] = theNode.get_csig() if Verbose: - print "hashes: ",saved_hashes + print("hashes: ",saved_hashes) must_rerun_latex = True @@ -268,12 +268,12 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None if saved_hashes[suffix] == new_md5: if Verbose: - print "file %s not changed" % (targetbase+suffix) + print("file %s not changed" % (targetbase+suffix)) return False # unchanged saved_hashes[suffix] = new_md5 must_rerun_latex = True if Verbose: - print "file %s changed, rerunning Latex, new hash = " % (targetbase+suffix), new_md5 + print("file %s changed, rerunning Latex, new hash = " % (targetbase+suffix), new_md5) return True # changed # generate the file name that latex will generate @@ -322,8 +322,8 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None bcffiles = list(dups.keys()) if Verbose: - print "auxfiles ",auxfiles - print "bcffiles ",bcffiles + print("auxfiles ",auxfiles) + print("bcffiles ",bcffiles) # Now decide if bibtex will need to be run. # The information that bibtex reads from the .aux file is @@ -339,7 +339,7 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None content = open(target_aux, "rb").read() if content.find("bibdata") != -1: if Verbose: - print "Need to run bibtex on ",auxfilename + print("Need to run bibtex on ",auxfilename) bibfile = env.fs.File(SCons.Util.splitext(target_aux)[0]) result = BibTeXAction(bibfile, bibfile, env) if result != 0: @@ -362,7 +362,7 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None content = open(target_bcf, "rb").read() if content.find("bibdata") != -1: if Verbose: - print "Need to run biber on ",bcffilename + print("Need to run biber on ",bcffilename) bibfile = env.fs.File(SCons.Util.splitext(target_bcf)[0]) result = BiberAction(bibfile, bibfile, env) if result != 0: @@ -373,7 +373,7 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None if check_MD5(suffix_nodes['.idx'],'.idx') or (count == 1 and run_makeindex): # We must run makeindex if Verbose: - print "Need to run makeindex" + print("Need to run makeindex") idxfile = suffix_nodes['.idx'] result = MakeIndexAction(idxfile, idxfile, env) if result != 0: @@ -391,7 +391,7 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None if check_MD5(suffix_nodes['.nlo'],'.nlo') or (count == 1 and run_nomenclature): # We must run makeindex if Verbose: - print "Need to run makeindex for nomenclature" + print("Need to run makeindex for nomenclature") nclfile = suffix_nodes['.nlo'] result = MakeNclAction(nclfile, nclfile, env) if result != 0: @@ -403,7 +403,7 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None if check_MD5(suffix_nodes['.glo'],'.glo') or (count == 1 and run_glossaries) or (count == 1 and run_glossary): # We must run makeindex if Verbose: - print "Need to run makeindex for glossary" + print("Need to run makeindex for glossary") glofile = suffix_nodes['.glo'] result = MakeGlossaryAction(glofile, glofile, env) if result != 0: @@ -415,7 +415,7 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None if check_MD5(suffix_nodes['.acn'],'.acn') or (count == 1 and run_acronyms): # We must run makeindex if Verbose: - print "Need to run makeindex for acronyms" + print("Need to run makeindex for acronyms") acrfile = suffix_nodes['.acn'] result = MakeAcronymsAction(acrfile, acrfile, env) if result != 0: @@ -428,7 +428,7 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None if check_MD5(suffix_nodes[newglossary_suffix[ig][2]],newglossary_suffix[ig][2]) or (count == 1): # We must run makeindex if Verbose: - print "Need to run makeindex for newglossary" + print("Need to run makeindex for newglossary") newglfile = suffix_nodes[newglossary_suffix[ig][2]] MakeNewGlossaryAction = SCons.Action.Action("$MAKENEWGLOSSARY ${SOURCE.filebase}%s -s ${SOURCE.filebase}.ist -t ${SOURCE.filebase}%s -o ${SOURCE.filebase}%s" % (newglossary_suffix[ig][2],newglossary_suffix[ig][0],newglossary_suffix[ig][1]), "$MAKENEWGLOSSARYCOMSTR") @@ -442,26 +442,26 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None if warning_rerun_re.search(logContent): must_rerun_latex = True if Verbose: - print "rerun Latex due to latex or package rerun warning" + print("rerun Latex due to latex or package rerun warning") if rerun_citations_re.search(logContent): must_rerun_latex = True if Verbose: - print "rerun Latex due to 'Rerun to get citations correct' warning" + print("rerun Latex due to 'Rerun to get citations correct' warning") if undefined_references_re.search(logContent): must_rerun_latex = True if Verbose: - print "rerun Latex due to undefined references or citations" + print("rerun Latex due to undefined references or citations") if (count >= int(env.subst('$LATEXRETRIES')) and must_rerun_latex): - print "reached max number of retries on Latex ,",int(env.subst('$LATEXRETRIES')) + print("reached max number of retries on Latex ,",int(env.subst('$LATEXRETRIES'))) # end of while loop # rename Latex's output to what the target name is if not (str(target[0]) == resultfilename and os.path.isfile(resultfilename)): if os.path.isfile(resultfilename): - print "move %s to %s" % (resultfilename, str(target[0]), ) + print("move %s to %s" % (resultfilename, str(target[0]), )) shutil.move(resultfilename,str(target[0])) # Original comment (when TEXPICTS was not restored): @@ -515,27 +515,27 @@ def is_LaTeX(flist,env,abspath): else: env['ENV']['TEXINPUTS'] = savedpath if Verbose: - print "is_LaTeX search path ",paths - print "files to search :",flist + print("is_LaTeX search path ",paths) + print("files to search :",flist) # Now that we have the search path and file list, check each one for f in flist: if Verbose: - print " checking for Latex source ",str(f) + print(" checking for Latex source ",str(f)) content = f.get_text_contents() if LaTeX_re.search(content): if Verbose: - print "file %s is a LaTeX file" % str(f) + print("file %s is a LaTeX file" % str(f)) return 1 if Verbose: - print "file %s is not a LaTeX file" % str(f) + print("file %s is not a LaTeX file" % str(f)) # now find included files inc_files = [ ] inc_files.extend( include_re.findall(content) ) if Verbose: - print "files included by '%s': "%str(f),inc_files + print("files included by '%s': "%str(f),inc_files) # inc_files is list of file names as given. need to find them # using TEXINPUTS paths. @@ -545,7 +545,7 @@ def is_LaTeX(flist,env,abspath): # make this a list since is_LaTeX takes a list. fileList = [srcNode,] if Verbose: - print "FindFile found ",srcNode + print("FindFile found ",srcNode) if srcNode is not None: file_test = is_LaTeX(fileList, env, abspath) @@ -554,7 +554,7 @@ def is_LaTeX(flist,env,abspath): return file_test if Verbose: - print " done scanning ",str(f) + print(" done scanning ",str(f)) return 0 @@ -619,15 +619,15 @@ def ScanFiles(theFile, target, paths, file_tests, file_tests_search, env, graphi content = theFile.get_text_contents() if Verbose: - print " scanning ",str(theFile) + print(" scanning ",str(theFile)) for i in range(len(file_tests_search)): if file_tests[i][0] is None: if Verbose: - print "scan i ",i," files_tests[i] ",file_tests[i], file_tests[i][1] + print("scan i ",i," files_tests[i] ",file_tests[i], file_tests[i][1]) file_tests[i][0] = file_tests_search[i].search(content) if Verbose and file_tests[i][0]: - print " found match for ",file_tests[i][1][-1] + print(" found match for ",file_tests[i][1][-1]) # for newglossary insert the suffixes in file_tests[i] if file_tests[i][0] and file_tests[i][1][-1] == 'newglossary': findresult = file_tests_search[i].findall(content) @@ -638,19 +638,19 @@ def ScanFiles(theFile, target, paths, file_tests, file_tests_search, env, graphi suffix_list = ['.'+findresult[l][0],'.'+findresult[l][2],'.'+findresult[l][3] ] newglossary_suffix.append(suffix_list) if Verbose: - print " new suffixes for newglossary ",newglossary_suffix + print(" new suffixes for newglossary ",newglossary_suffix) incResult = includeOnly_re.search(content) if incResult: aux_files.append(os.path.join(targetdir, incResult.group(1))) if Verbose: - print "\include file names : ", aux_files + print("\include file names : ", aux_files) # recursively call this on each of the included files inc_files = [ ] inc_files.extend( include_re.findall(content) ) if Verbose: - print "files included by '%s': "%str(theFile),inc_files + print("files included by '%s': "%str(theFile),inc_files) # inc_files is list of file names as given. need to find them # using TEXINPUTS paths. @@ -659,7 +659,7 @@ def ScanFiles(theFile, target, paths, file_tests, file_tests_search, env, graphi if srcNode is not None: file_tests = ScanFiles(srcNode, target, paths, file_tests, file_tests_search, env, graphics_extensions, targetdir, aux_files) if Verbose: - print " done scanning ",str(theFile) + print(" done scanning ",str(theFile)) return file_tests def tex_emitter_core(target, source, env, graphics_extensions): @@ -689,7 +689,7 @@ def tex_emitter_core(target, source, env, graphics_extensions): env.SideEffect(logfilename,target[0]) env.SideEffect(flsfilename,target[0]) if Verbose: - print "side effect :",auxfilename,logfilename,flsfilename + print("side effect :",auxfilename,logfilename,flsfilename) env.Clean(target[0],auxfilename) env.Clean(target[0],logfilename) env.Clean(target[0],flsfilename) @@ -765,7 +765,7 @@ def tex_emitter_core(target, source, env, graphics_extensions): else: env['ENV']['TEXINPUTS'] = savedpath if Verbose: - print "search path ",paths + print("search path ",paths) # scan all sources for side effect files aux_files = [] @@ -774,7 +774,7 @@ def tex_emitter_core(target, source, env, graphics_extensions): for (theSearch,suffix_list) in file_tests: # add side effects if feature is present.If file is to be generated,add all side effects if Verbose and theSearch: - print "check side effects for ",suffix_list[-1] + print("check side effects for ",suffix_list[-1]) if (theSearch != None) or (not source[0].exists() ): file_list = [targetbase,] # for bibunit we need a list of files @@ -788,11 +788,11 @@ def tex_emitter_core(target, source, env, graphics_extensions): if suffix_list[-1] == 'multibib': for multibibmatch in multibib_re.finditer(content): if Verbose: - print "multibib match ",multibibmatch.group(1) + print("multibib match ",multibibmatch.group(1)) if multibibmatch != None: baselist = multibibmatch.group(1).split(',') if Verbose: - print "multibib list ", baselist + print("multibib list ", baselist) for i in range(len(baselist)): file_list.append(os.path.join(targetdir, baselist[i])) # now define the side effects @@ -800,14 +800,14 @@ def tex_emitter_core(target, source, env, graphics_extensions): for suffix in suffix_list[:-1]: env.SideEffect(file_name + suffix,target[0]) if Verbose: - print "side effect tst :",file_name + suffix, " target is ",str(target[0]) + print("side effect tst :",file_name + suffix, " target is ",str(target[0])) env.Clean(target[0],file_name + suffix) for aFile in aux_files: aFile_base = SCons.Util.splitext(aFile)[0] env.SideEffect(aFile_base + '.aux',target[0]) if Verbose: - print "side effect aux :",aFile_base + '.aux' + print("side effect aux :",aFile_base + '.aux') env.Clean(target[0],aFile_base + '.aux') # read fls file to get all other files that latex creates and will read on the next pass # remove files from list that we explicitly dealt with above @@ -820,7 +820,7 @@ def tex_emitter_core(target, source, env, graphics_extensions): out_files.remove(filename) env.SideEffect(out_files,target[0]) if Verbose: - print "side effect fls :",out_files + print("side effect fls :",out_files) env.Clean(target[0],out_files) return (target, source) @@ -840,7 +840,7 @@ def generate(env): generate_common(env) - import dvi + from . import dvi dvi.generate(env) bld = env['BUILDERS']['DVI'] diff --git a/src/engine/SCons/Tool/textfile.py b/src/engine/SCons/Tool/textfile.py index 8dc8f4b..4897113 100644 --- a/src/engine/SCons/Tool/textfile.py +++ b/src/engine/SCons/Tool/textfile.py @@ -54,6 +54,7 @@ import re from SCons.Node import Node from SCons.Node.Python import Value from SCons.Util import is_String, is_Sequence, is_Dict +import collections def _do_subst(node, subs): """ @@ -96,7 +97,7 @@ def _action(target, source, env): raise SCons.Errors.UserError('SUBST_DICT must be dict or sequence') subs = [] for (k,v) in d: - if callable(v): + if isinstance(v, collections.Callable): v = v() if is_String(v): v = env.subst(v) @@ -107,7 +108,7 @@ def _action(target, source, env): # write the file try: fd = open(target[0].get_path(), "wb") - except (OSError,IOError), e: + except (OSError,IOError) as e: raise SCons.Errors.UserError("Can't write target file %s" % target[0]) # separate lines by 'linesep' only if linesep is not empty lsep = None diff --git a/src/engine/SCons/Tool/xgettext.py b/src/engine/SCons/Tool/xgettext.py index 64436b8..489d4d7 100644 --- a/src/engine/SCons/Tool/xgettext.py +++ b/src/engine/SCons/Tool/xgettext.py @@ -55,7 +55,7 @@ class _CmdRunner(object): proc = SCons.Action._subproc(env, command, **kw) self.out, self.err = proc.communicate() self.status = proc.wait() - if self.err: sys.stderr.write(unicode(self.err)) + if self.err: sys.stderr.write(str(self.err)) return self.status def strfunction(self, target, source, env): @@ -153,7 +153,7 @@ from SCons.Builder import BuilderBase class _POTBuilder(BuilderBase): def _execute(self, env, target, source, *args): if not target: - if env.has_key('POTDOMAIN') and env['POTDOMAIN']: + if 'POTDOMAIN' in env and env['POTDOMAIN']: domain = env['POTDOMAIN'] else: domain = 'messages' @@ -175,7 +175,7 @@ def _scan_xgettext_from_files(target, source, env, files = None, path = None): files = [ files ] if path is None: - if env.has_key('XGETTEXTPATH'): + if 'XGETTEXTPATH' in env: path = env['XGETTEXTPATH'] else: path = [] @@ -222,7 +222,7 @@ def _pot_update_emitter(target, source, env): import SCons.Util import SCons.Node.FS - if env.has_key('XGETTEXTFROM'): + if 'XGETTEXTFROM' in env: xfrom = env['XGETTEXTFROM'] else: return target, source diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 822d524..f2e5325 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -33,15 +33,16 @@ import re import types from collections import UserDict, UserList, UserString +import collections # Don't "from types import ..." these because we need to get at the # types module later to look for UnicodeType. InstanceType = types.InstanceType MethodType = types.MethodType FunctionType = types.FunctionType -try: unicode +try: str except NameError: UnicodeType = None -else: UnicodeType = unicode +else: UnicodeType = str def dictify(keys, values, result={}): for k, v in zip(keys, values): @@ -111,7 +112,7 @@ class NodeList(UserList): >>> someList.strip() [ 'foo', 'bar' ] """ - def __nonzero__(self): + def __bool__(self): return len(self.data) != 0 def __str__(self): @@ -153,7 +154,7 @@ class DisplayEngine(object): return if append_newline: text = text + '\n' try: - sys.stdout.write(unicode(text)) + sys.stdout.write(str(text)) except IOError: # Stdout might be connected to a pipe that has been closed # by now. The most likely reason for the pipe being closed @@ -239,7 +240,7 @@ def print_tree(root, child_func, prune=0, showtags=0, margin=[0], visited={}): ' N = no clean\n' + ' H = no cache\n' + '\n') - sys.stdout.write(unicode(legend)) + sys.stdout.write(str(legend)) tags = ['['] tags.append(' E'[IDX(root.exists())]) @@ -264,10 +265,10 @@ def print_tree(root, child_func, prune=0, showtags=0, margin=[0], visited={}): children = child_func(root) if prune and rname in visited and children: - sys.stdout.write(''.join(tags + margins + ['+-[', rname, ']']) + u'\n') + sys.stdout.write(''.join(tags + margins + ['+-[', rname, ']']) + '\n') return - sys.stdout.write(''.join(tags + margins + ['+-', rname]) + u'\n') + sys.stdout.write(''.join(tags + margins + ['+-', rname]) + '\n') visited[rname] = 1 @@ -303,11 +304,11 @@ SequenceTypes = (list, tuple, UserList) # Note that profiling data shows a speed-up when comparing # explicitely with str and unicode instead of simply comparing # with basestring. (at least on Python 2.5.1) -StringTypes = (str, unicode, UserString) +StringTypes = (str, str, UserString) # Empirically, it is faster to check explicitely for str and # unicode than for basestring. -BaseStringTypes = (str, unicode) +BaseStringTypes = (str, str) def is_Dict(obj, isinstance=isinstance, DictTypes=DictTypes): return isinstance(obj, DictTypes) @@ -440,7 +441,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: # @@ -465,7 +466,7 @@ def semi_deepcopy(x): if copier: return copier(x) else: - if hasattr(x, '__semi_deepcopy__') and callable(x.__semi_deepcopy__): + if hasattr(x, '__semi_deepcopy__') and isinstance(x.__semi_deepcopy__, collections.Callable): return x.__semi_deepcopy__() elif isinstance(x, UserDict): return x.__class__(semi_deepcopy_dict(x)) @@ -718,7 +719,7 @@ else: # raised so as to not mask possibly serious disk or # network issues. continue - if stat.S_IMODE(st[stat.ST_MODE]) & 0111: + if stat.S_IMODE(st[stat.ST_MODE]) & 0o111: try: reject.index(f) except ValueError: @@ -979,7 +980,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): @@ -1001,7 +1002,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: @@ -1360,7 +1361,7 @@ def AddMethod(obj, function, name=None): print a.listIndex(5) """ if name is None: - name = function.func_name + name = function.__name__ else: function = RenameFunction(function, name) @@ -1376,10 +1377,10 @@ def RenameFunction(function, name): Returns a function identical to the specified function, but with the specified name. """ - return FunctionType(function.func_code, - function.func_globals, + return FunctionType(function.__code__, + function.__globals__, name, - function.func_defaults) + function.__defaults__) md5 = False @@ -1461,7 +1462,7 @@ class Null(object): return self def __repr__(self): return "Null(0x%08X)" % id(self) - def __nonzero__(self): + def __bool__(self): return False def __getattr__(self, name): return self diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py index a1e6756..a30404c 100644 --- a/src/engine/SCons/UtilTests.py +++ b/src/engine/SCons/UtilTests.py @@ -219,7 +219,7 @@ class UtilTestCase(unittest.TestCase): assert not is_Dict(()) assert not is_Dict("") if HasUnicode: - exec "assert not is_Dict(u'')" + exec("assert not is_Dict(u'')") def test_is_List(self): assert is_List([]) @@ -235,12 +235,12 @@ class UtilTestCase(unittest.TestCase): assert not is_List({}) assert not is_List("") if HasUnicode: - exec "assert not is_List(u'')" + exec("assert not is_List(u'')") def test_is_String(self): assert is_String("") if HasUnicode: - exec "assert is_String(u'')" + exec("assert is_String(u'')") assert is_String(UserString('')) try: class mystr(str): @@ -266,7 +266,7 @@ class UtilTestCase(unittest.TestCase): assert not is_Tuple({}) assert not is_Tuple("") if HasUnicode: - exec "assert not is_Tuple(u'')" + exec("assert not is_Tuple(u'')") def test_to_String(self): """Test the to_String() method.""" @@ -285,16 +285,16 @@ class UtilTestCase(unittest.TestCase): assert to_String(s2) == 'foo', s2 if HasUnicode: - s3=UserString(unicode('bar')) + s3=UserString(str('bar')) assert to_String(s3) == s3, s3 - assert to_String(s3) == unicode('bar'), s3 - assert isinstance(to_String(s3), unicode), \ + assert to_String(s3) == str('bar'), s3 + assert isinstance(to_String(s3), str), \ type(to_String(s3)) if HasUnicode: - s4 = unicode('baz') - assert to_String(s4) == unicode('baz'), to_String(s4) - assert isinstance(to_String(s4), unicode), \ + s4 = str('baz') + assert to_String(s4) == str('baz'), to_String(s4) + assert isinstance(to_String(s4), str), \ type(to_String(s4)) def test_WhereIs(self): @@ -313,10 +313,10 @@ class UtilTestCase(unittest.TestCase): os.mkdir(sub2_xxx_exe) test.write(sub3_xxx_exe, "\n") - os.chmod(sub3_xxx_exe, 0777) + os.chmod(sub3_xxx_exe, 0o777) test.write(sub4_xxx_exe, "\n") - os.chmod(sub4_xxx_exe, 0777) + os.chmod(sub4_xxx_exe, 0o777) env_path = os.environ['PATH'] @@ -681,7 +681,7 @@ bling fobj = io.StringIO(content) except TypeError: # Python 2.7 and beyond require unicode strings. - fobj = io.StringIO(unicode(content)) + fobj = io.StringIO(str(content)) lines = LogicalLines(fobj).readlines() assert lines == [ @@ -696,7 +696,7 @@ bling s1 = silent_intern("spam") # Python 3.x does not have a unicode() global function if sys.version[0] == '2': - s2 = silent_intern(unicode("unicode spam")) + s2 = silent_intern(str("unicode spam")) s3 = silent_intern(42) s4 = silent_intern("spam") assert id(s1) == id(s4) diff --git a/src/engine/SCons/Variables/EnumVariableTests.py b/src/engine/SCons/Variables/EnumVariableTests.py index f4b600d..4feb712 100644 --- a/src/engine/SCons/Variables/EnumVariableTests.py +++ b/src/engine/SCons/Variables/EnumVariableTests.py @@ -122,7 +122,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) @@ -186,7 +186,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/PathVariableTests.py b/src/engine/SCons/Variables/PathVariableTests.py index 084154b..2fa46eb 100644 --- a/src/engine/SCons/Variables/PathVariableTests.py +++ b/src/engine/SCons/Variables/PathVariableTests.py @@ -65,7 +65,7 @@ class PathVariableTestCase(unittest.TestCase): dne = test.workpath('does_not_exist') try: o.validator('X', dne, {}) - except SCons.Errors.UserError, e: + except SCons.Errors.UserError as e: assert str(e) == 'Path for option X does not exist: %s' % dne, e except: raise Exception("did not catch expected UserError") @@ -89,7 +89,7 @@ class PathVariableTestCase(unittest.TestCase): f = test.workpath('file') try: o.validator('X', f, {}) - except SCons.Errors.UserError, e: + except SCons.Errors.UserError as e: assert str(e) == 'Directory path for option X is a file: %s' % f, e except: raise Exception("did not catch expected UserError") @@ -97,7 +97,7 @@ class PathVariableTestCase(unittest.TestCase): dne = test.workpath('does_not_exist') try: o.validator('X', dne, {}) - except SCons.Errors.UserError, e: + except SCons.Errors.UserError as e: assert str(e) == 'Directory path for option X does not exist: %s' % dne, e except: raise Exception("did not catch expected UserError") @@ -122,7 +122,7 @@ class PathVariableTestCase(unittest.TestCase): f = test.workpath('file') try: o.validator('X', f, {}) - except SCons.Errors.UserError, e: + except SCons.Errors.UserError as e: assert str(e) == 'Path for option X is a file, not a directory: %s' % f, e except: raise Exception("did not catch expected UserError") @@ -146,7 +146,7 @@ class PathVariableTestCase(unittest.TestCase): d = test.workpath('d') try: o.validator('X', d, {}) - except SCons.Errors.UserError, e: + except SCons.Errors.UserError as e: assert str(e) == 'File path for option X does not exist: %s' % d, e except: raise Exception("did not catch expected UserError") @@ -154,7 +154,7 @@ class PathVariableTestCase(unittest.TestCase): dne = test.workpath('does_not_exist') try: o.validator('X', dne, {}) - except SCons.Errors.UserError, e: + except SCons.Errors.UserError as e: assert str(e) == 'File path for option X does not exist: %s' % dne, e except: raise Exception("did not catch expected UserError") @@ -198,7 +198,7 @@ class PathVariableTestCase(unittest.TestCase): dne = test.workpath('does_not_exist') try: o.validator('X', dne, {}) - except SCons.Errors.UserError, e: + except SCons.Errors.UserError as e: expect = 'Path for option X does not exist: %s' % dne assert str(e) == expect, e else: @@ -217,7 +217,7 @@ class PathVariableTestCase(unittest.TestCase): try: o.validator('Y', 'value', {}) - except Exception, e: + except Exception as e: assert str(e) == 'my_validator() got called for Y, value!', e else: raise Exception("did not catch expected exception from my_validator()") diff --git a/src/engine/SCons/Variables/VariablesTests.py b/src/engine/SCons/Variables/VariablesTests.py index ad46bd6..520c8e3 100644 --- a/src/engine/SCons/Variables/VariablesTests.py +++ b/src/engine/SCons/Variables/VariablesTests.py @@ -55,7 +55,7 @@ def check(key, value, env): def checkSave(file, expected): gdict = {} ldict = {} - exec open(file, 'rU').read() in gdict, ldict + exec(open(file, 'rU').read(), gdict, ldict) assert expected == ldict, "%s\n...not equal to...\n%s" % (expected, ldict) class VariablesTestCase(unittest.TestCase): diff --git a/src/engine/SCons/Variables/__init__.py b/src/engine/SCons/Variables/__init__.py index ede7480..8d15b8d 100644 --- a/src/engine/SCons/Variables/__init__.py +++ b/src/engine/SCons/Variables/__init__.py @@ -36,11 +36,11 @@ import SCons.Errors import SCons.Util import SCons.Warnings -from BoolVariable import BoolVariable # okay -from EnumVariable import EnumVariable # okay -from ListVariable import ListVariable # naja -from PackageVariable import PackageVariable # naja -from PathVariable import PathVariable # okay +from .BoolVariable import BoolVariable # okay +from .EnumVariable import EnumVariable # okay +from .ListVariable import ListVariable # naja +from .PackageVariable import PackageVariable # naja +from .PathVariable import PathVariable # okay class Variables(object): @@ -170,7 +170,7 @@ class Variables(object): sys.path.insert(0, dir) try: values['__name__'] = filename - exec open(filename, 'rU').read() in {}, values + exec(open(filename, 'rU').read(), {}, values) finally: if dir: del sys.path[0] @@ -180,7 +180,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 ]: @@ -206,7 +206,7 @@ class Variables(object): env[option.key] = option.converter(value) except TypeError: env[option.key] = option.converter(value, env) - except ValueError, x: + except ValueError as x: raise SCons.Errors.UserError('Error converting option: %s\n%s'%(option.key, x)) @@ -268,7 +268,7 @@ class Variables(object): finally: fh.close() - except IOError, x: + except IOError as x: raise SCons.Errors.UserError('Error writing options to file: %s\n%s' % (filename, x)) def GenerateHelpText(self, env, sort=None): diff --git a/src/engine/SCons/compat/__init__.py b/src/engine/SCons/compat/__init__.py index c870fbc..6f1a7ee 100644 --- a/src/engine/SCons/compat/__init__.py +++ b/src/engine/SCons/compat/__init__.py @@ -87,7 +87,7 @@ def rename_module(new, old): rename_module('builtins', '__builtin__') -import _scons_builtins +from . import _scons_builtins try: diff --git a/src/engine/SCons/compat/_scons_subprocess.py b/src/engine/SCons/compat/_scons_subprocess.py index eebe53d..72581f7 100644 --- a/src/engine/SCons/compat/_scons_subprocess.py +++ b/src/engine/SCons/compat/_scons_subprocess.py @@ -439,22 +439,22 @@ except TypeError: def is_int(obj): return isinstance(obj, type(1)) def is_int_or_long(obj): - return type(obj) in (type(1), type(1L)) + return type(obj) in (type(1), type(1)) else: def is_int(obj): return isinstance(obj, int) def is_int_or_long(obj): - return isinstance(obj, (int, long)) + return isinstance(obj, int) try: - types.StringTypes + str except AttributeError: try: - types.StringTypes = (str, unicode) + str = (str, str) except NameError: - types.StringTypes = (str,) + str = (str,) def is_string(obj): - return isinstance(obj, types.StringTypes) + return isinstance(obj, str) _active = [] @@ -785,7 +785,7 @@ class Popen(object): errread, errwrite): """Execute program (MS Windows version)""" - if not isinstance(args, types.StringTypes): + if not isinstance(args, str): args = list2cmdline(args) # Process startup details @@ -802,7 +802,7 @@ class Popen(object): startupinfo.wShowWindow = SW_HIDE comspec = os.environ.get("COMSPEC", "cmd.exe") args = comspec + " /c " + args - if (GetVersion() >= 0x80000000L or + if (GetVersion() >= 0x80000000 or os.path.basename(comspec).lower() == "command.com"): # Win9x, or using command.com on NT. We need to # use the w9xpopen intermediate program. For more @@ -830,7 +830,7 @@ class Popen(object): env, cwd, startupinfo) - except pywintypes.error, e: + except pywintypes.error as e: # Translate pywintypes.error to WindowsError, which is # a subclass of OSError. FIXME: We should really # translate errno using _sys_errlist (or simliar), but @@ -1215,8 +1215,8 @@ def _demo_posix(): # Example 1: Simple redirection: Get process list # plist = Popen(["ps"], stdout=PIPE).communicate()[0] - print "Process list:" - print plist + print("Process list:") + print(plist) # # Example 2: Change uid before executing child @@ -1228,25 +1228,25 @@ def _demo_posix(): # # Example 3: Connecting several subprocesses # - print "Looking for 'hda'..." + print("Looking for 'hda'...") p1 = Popen(["dmesg"], stdout=PIPE) p2 = Popen(["grep", "hda"], stdin=p1.stdout, stdout=PIPE) - print repr(p2.communicate()[0]) + print(repr(p2.communicate()[0])) # # Example 4: Catch execution error # - print - print "Trying a weird file..." + print() + print("Trying a weird file...") try: - print Popen(["/this/path/does/not/exist"]).communicate() - except OSError, e: + print(Popen(["/this/path/does/not/exist"]).communicate()) + except OSError as e: if e.errno == errno.ENOENT: - print "The file didn't exist. I thought so..." - print "Child traceback:" - print e.child_traceback + print("The file didn't exist. I thought so...") + print("Child traceback:") + print(e.child_traceback) else: - print "Error", e.errno + print("Error", e.errno) else: sys.stderr.write( "Gosh. No error.\n" ) @@ -1255,15 +1255,15 @@ def _demo_windows(): # # Example 1: Connecting several subprocesses # - print "Looking for 'PROMPT' in set output..." + print("Looking for 'PROMPT' in set output...") p1 = Popen("set", stdout=PIPE, shell=True) p2 = Popen('find "PROMPT"', stdin=p1.stdout, stdout=PIPE) - print repr(p2.communicate()[0]) + print(repr(p2.communicate()[0])) # # Example 2: Simple execution of program # - print "Executing calc..." + print("Executing calc...") p = Popen("calc") p.wait() diff --git a/src/engine/SCons/cpp.py b/src/engine/SCons/cpp.py index 0ba10f5..4cc771b 100644 --- a/src/engine/SCons/cpp.py +++ b/src/engine/SCons/cpp.py @@ -31,6 +31,7 @@ import SCons.compat import os import re +import collections # # First "subsystem" of regular expressions that we set up: @@ -72,7 +73,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 +88,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 +131,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 +267,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 @@ -552,7 +553,7 @@ class PreProcessor(object): except KeyError: m = function_name.search(s) s = self.cpp_namespace[m.group(1)] - if callable(s): + if isinstance(s, collections.Callable): args = function_arg_separator.split(m.group(2)) s = s(*args) if not s: diff --git a/src/engine/SCons/cppTests.py b/src/engine/SCons/cppTests.py index 2f2025b..5566e53 100644 --- a/src/engine/SCons/cppTests.py +++ b/src/engine/SCons/cppTests.py @@ -27,7 +27,7 @@ import atexit import sys import unittest -import cpp +from . import cpp diff --git a/src/engine/SCons/dblite.py b/src/engine/SCons/dblite.py index f4ba90a..89b9856 100644 --- a/src/engine/SCons/dblite.py +++ b/src/engine/SCons/dblite.py @@ -14,20 +14,20 @@ keep_all_files = 00000 ignore_corrupt_dbfiles = 0 def corruption_warning(filename): - print "Warning: Discarding corrupt database:", filename + print("Warning: Discarding corrupt database:", filename) -try: unicode +try: str except NameError: def is_string(s): return isinstance(s, str) else: def is_string(s): - return type(s) in (str, unicode) + return type(s) in (str, str) try: - unicode('a') + str('a') except NameError: - def unicode(s): return s + def str(s): return s dblite_suffix = '.dblite' tmp_suffix = '.tmp' @@ -77,7 +77,7 @@ class dblite(object): statinfo = os.stat(self._file_name) self._chown_to = statinfo.st_uid self._chgrp_to = statinfo.st_gid - except OSError, e: + except OSError as e: # db file doesn't exist yet. # Check os.environ for SUDO_UID, use if set self._chown_to = int(os.environ.get('SUDO_UID', -1)) @@ -90,7 +90,7 @@ class dblite(object): else: try: f = self._open(self._file_name, "rb") - except IOError, e: + except IOError as e: if (self._flag != "c"): raise e self._open(self._file_name, "wb", self._mode) @@ -122,7 +122,7 @@ class dblite(object): # (e.g. from a previous run as root). We should still be able to # unlink() the file if the directory's writable, though, so ignore # any OSError exception thrown by the chmod() call. - try: self._os_chmod(self._file_name, 0777) + try: self._os_chmod(self._file_name, 0o777) except OSError: pass self._os_unlink(self._file_name) self._os_rename(self._tmp_name, self._file_name) @@ -151,7 +151,7 @@ class dblite(object): if (not is_string(value)): raise TypeError("value `%s' must be a string but is %s" % (value, type(value))) self._dict[key] = value - self._needs_sync = 0001 + self._needs_sync = 0o001 def keys(self): return list(self._dict.keys()) @@ -171,7 +171,7 @@ class dblite(object): def __len__(self): return len(self._dict) -def open(file, flag=None, mode=0666): +def open(file, flag=None, mode=0o666): return dblite(file, flag, mode) def _exercise(): @@ -179,26 +179,26 @@ def _exercise(): assert len(db) == 0 db["foo"] = "bar" assert db["foo"] == "bar" - db[unicode("ufoo")] = unicode("ubar") - assert db[unicode("ufoo")] == unicode("ubar") + db[str("ufoo")] = str("ubar") + assert db[str("ufoo")] == str("ubar") db.sync() db = open("tmp", "c") assert len(db) == 2, len(db) assert db["foo"] == "bar" db["bar"] = "foo" assert db["bar"] == "foo" - db[unicode("ubar")] = unicode("ufoo") - assert db[unicode("ubar")] == unicode("ufoo") + db[str("ubar")] = str("ufoo") + assert db[str("ubar")] == str("ufoo") db.sync() db = open("tmp", "r") assert len(db) == 4, len(db) assert db["foo"] == "bar" assert db["bar"] == "foo" - assert db[unicode("ufoo")] == unicode("ubar") - assert db[unicode("ubar")] == unicode("ufoo") + assert db[str("ufoo")] == str("ubar") + assert db[str("ubar")] == str("ufoo") try: db.sync() - except IOError, e: + except IOError as e: assert str(e) == "Read-only database: tmp.dblite" else: raise RuntimeError("IOError expected.") @@ -208,13 +208,13 @@ def _exercise(): db.sync() try: db[(1,2)] = "tuple" - except TypeError, e: + except TypeError as e: assert str(e) == "key `(1, 2)' must be a string but is ", str(e) else: raise RuntimeError("TypeError exception expected") try: db["list"] = [1,2] - except TypeError, e: + except TypeError as e: assert str(e) == "value `[1, 2]' must be a string but is ", str(e) else: raise RuntimeError("TypeError exception expected") @@ -238,11 +238,11 @@ def _exercise(): os.unlink("tmp.dblite") try: db = open("tmp", "w") - except IOError, e: + except IOError as e: assert str(e) == "[Errno 2] No such file or directory: 'tmp.dblite'", str(e) else: raise RuntimeError("IOError expected.") - print "OK" + print("OK") if (__name__ == "__main__"): _exercise() diff --git a/src/script/scons-time.py b/src/script/scons-time.py index 3b215f9..4296192 100644 --- a/src/script/scons-time.py +++ b/src/script/scons-time.py @@ -29,8 +29,8 @@ # 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. -from __future__ import division -from __future__ import nested_scopes + + __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -42,6 +42,7 @@ import shutil import sys import tempfile import time +import collections try: sorted @@ -109,8 +110,8 @@ def HACK_for_exec(cmd, *args): internal functions. ''' if not args: exec(cmd) - elif len(args) == 1: exec cmd in args[0] - else: exec cmd in args[0], args[1] + elif len(args) == 1: exec(cmd, args[0]) + else: exec(cmd, args[0], args[1]) class Plotter(object): def increment_size(self, largest): @@ -146,7 +147,7 @@ class Line(object): def print_label(self, inx, x, y): if self.label: - print 'set label %s "%s" at %s,%s right' % (inx, self.label, x, y) + print('set label %s "%s" at %s,%s right' % (inx, self.label, x, y)) def plot_string(self): if self.title: @@ -159,15 +160,15 @@ class Line(object): if fmt is None: fmt = self.fmt if self.comment: - print '# %s' % self.comment + print('# %s' % self.comment) for x, y in self.points: # If y is None, it usually represents some kind of break # in the line's index number. We might want to represent # this some way rather than just drawing the line straight # between the two points on either side. if not y is None: - print fmt % (x, y) - print 'e' + print(fmt % (x, y)) + print('e') def get_x_values(self): return [ p[0] for p in self.points ] @@ -253,8 +254,8 @@ class Gnuplotter(Plotter): return if self.title: - print 'set title "%s"' % self.title - print 'set key %s' % self.key_location + print('set title "%s"' % self.title) + print('set key %s' % self.key_location) min_y = self.get_min_y() max_y = self.max_graph_value(self.get_max_y()) @@ -269,7 +270,7 @@ class Gnuplotter(Plotter): inx += 1 plot_strings = [ self.plot_string(l) for l in self.lines ] - print 'plot ' + ', \\\n '.join(plot_strings) + print('plot ' + ', \\\n '.join(plot_strings)) for line in self.lines: line.print_points() @@ -455,7 +456,7 @@ class SConsTimer(object): Each message is prepended with a standard prefix of our name plus the time. """ - if callable(msg): + if isinstance(msg, collections.Callable): msg = msg(*args) else: msg = msg % args @@ -474,7 +475,7 @@ class SConsTimer(object): The action is called if it's a callable Python function, and otherwise passed to os.system(). """ - if callable(action): + if isinstance(action, collections.Callable): action(*args) else: os.system(action % args) @@ -540,7 +541,7 @@ class SConsTimer(object): header_fmt = ' '.join(['%12s'] * len(columns)) line_fmt = header_fmt + ' %s' - print header_fmt % columns + print(header_fmt % columns) for file in files: t = line_function(file, *args, **kw) @@ -550,7 +551,7 @@ class SConsTimer(object): if diff > 0: t += [''] * diff t.append(file_function(file)) - print line_fmt % tuple(t) + print(line_fmt % tuple(t)) def collect_results(self, files, function, *args, **kw): results = {} @@ -690,13 +691,13 @@ class SConsTimer(object): """ try: import pstats - except ImportError, e: + except ImportError as e: sys.stderr.write('%s: func: %s\n' % (self.name, e)) sys.stderr.write('%s This version of Python is missing the profiler.\n' % self.name_spaces) 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] @@ -751,7 +752,7 @@ class SConsTimer(object): return self.default(argv) try: return func(argv) - except TypeError, e: + except TypeError as e: sys.stderr.write("%s %s: %s\n" % (self.name, cmdName, e)) import traceback traceback.print_exc(file=sys.stderr) @@ -856,7 +857,7 @@ class SConsTimer(object): self.title = a if self.config_file: - exec open(self.config_file, 'rU').read() in self.__dict__ + exec(open(self.config_file, 'rU').read(), self.__dict__) if self.chdir: os.chdir(self.chdir) @@ -889,13 +890,13 @@ class SConsTimer(object): try: f, line, func, time = \ self.get_function_profile(file, function_name) - except ValueError, e: + except ValueError as e: sys.stderr.write("%s: func: %s: %s\n" % (self.name, file, e)) else: if f.startswith(cwd_): f = f[len(cwd_):] - print "%.3f %s:%d(%s)" % (time, f, line, func) + print("%.3f %s:%d(%s)" % (time, f, line, func)) elif format == 'gnuplot': @@ -1233,7 +1234,7 @@ class SConsTimer(object): sys.exit(1) if self.config_file: - exec open(self.config_file, 'rU').read() in self.__dict__ + exec(open(self.config_file, 'rU').read(), self.__dict__) if args: self.archive_list = args @@ -1466,7 +1467,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/script/sconsign.py b/src/script/sconsign.py index e5e9d4f..323d1bf 100644 --- a/src/script/sconsign.py +++ b/src/script/sconsign.py @@ -171,7 +171,7 @@ sys.path = libs + sys.path import SCons.compat # so pickle will import cPickle instead -import whichdb +import dbm import time import pickle import imp @@ -189,8 +189,8 @@ def my_whichdb(filename): pass return _orig_whichdb(filename) -_orig_whichdb = whichdb.whichdb -whichdb.whichdb = my_whichdb +_orig_whichdb = dbm.whichdb +dbm.whichdb = my_whichdb def my_import(mname): if '.' in mname: @@ -310,14 +310,14 @@ def printfield(name, entry, prefix=""): outlist = field("implicit", entry, 0) if outlist: if Verbose: - print " implicit:" - print " " + outlist + print(" implicit:") + print(" " + outlist) outact = field("action", entry, 0) if outact: if Verbose: - print " action: " + outact + print(" action: " + outact) else: - print " " + outact + print(" " + outact) def printentries(entries, location): if Print_Entries: @@ -330,9 +330,9 @@ def printentries(entries, location): try: ninfo = entry.ninfo except AttributeError: - print name + ":" + print(name + ":") else: - print nodeinfo_string(name, entry.ninfo) + print(nodeinfo_string(name, entry.ninfo)) printfield(name, entry.binfo) else: for name in sorted(entries.keys()): @@ -340,9 +340,9 @@ def printentries(entries, location): try: ninfo = entry.ninfo except AttributeError: - print name + ":" + print(name + ":") else: - print nodeinfo_string(name, entry.ninfo) + print(nodeinfo_string(name, entry.ninfo)) printfield(name, entry.binfo) class Do_SConsignDB(object): @@ -361,7 +361,7 @@ class Do_SConsignDB(object): # .sconsign => .sconsign.dblite # .sconsign.dblite => .sconsign.dblite.dblite db = self.dbm.open(fname, "r") - except (IOError, OSError), e: + except (IOError, OSError) as e: print_e = e try: # That didn't work, so try opening the base name, @@ -375,7 +375,7 @@ class Do_SConsignDB(object): # suffix-mangling). try: open(fname, "r") - except (IOError, OSError), e: + except (IOError, OSError) as e: # Nope, that file doesn't even exist, so report that # fact back. print_e = e @@ -386,7 +386,7 @@ class Do_SConsignDB(object): except pickle.UnpicklingError: sys.stderr.write("sconsign: ignoring invalid `%s' file `%s'\n" % (self.dbm_name, fname)) return - except Exception, e: + except Exception as e: sys.stderr.write("sconsign: ignoring invalid `%s' file `%s': %s\n" % (self.dbm_name, fname, e)) return @@ -403,13 +403,13 @@ class Do_SConsignDB(object): self.printentries(dir, db[dir]) def printentries(self, dir, val): - print '=== ' + dir + ':' + print('=== ' + dir + ':') printentries(pickle.loads(val), dir) def Do_SConsignDir(name): try: fp = open(name, 'rb') - except (IOError, OSError), e: + except (IOError, OSError) as e: sys.stderr.write("sconsign: %s\n" % (e)) return try: @@ -419,7 +419,7 @@ def Do_SConsignDir(name): except pickle.UnpicklingError: sys.stderr.write("sconsign: ignoring invalid .sconsign file `%s'\n" % (name)) return - except Exception, e: + except Exception as e: sys.stderr.write("sconsign: ignoring invalid .sconsign file `%s': %s\n" % (name, e)) return printentries(sconsign.entries, args[0]) @@ -471,13 +471,13 @@ for o, a in opts: dbm = my_import(dbm_name) except: sys.stderr.write("sconsign: illegal file format `%s'\n" % a) - print helpstr + print(helpstr) sys.exit(2) Do_Call = Do_SConsignDB(a, dbm) else: Do_Call = Do_SConsignDir elif o in ('-h', '--help'): - print helpstr + print(helpstr) sys.exit(0) elif o in ('-i', '--implicit'): Print_Flags['implicit'] = 1 @@ -497,7 +497,7 @@ if Do_Call: Do_Call(a) else: for a in args: - dbm_name = whichdb.whichdb(a) + dbm_name = dbm.whichdb(a) if dbm_name: Map_Module = {'SCons.dblite' : 'dblite'} dbm = my_import(dbm_name) diff --git a/src/test_files.py b/src/test_files.py index 7d8e75e..d71329b 100644 --- a/src/test_files.py +++ b/src/test_files.py @@ -77,7 +77,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) @@ -87,13 +87,13 @@ for directory, check_list in check.items(): no_result.append(directory) if missing: - print "Missing the following files:\n" - print "\t" + "\n\t".join(missing) + print("Missing the following files:\n") + print("\t" + "\n\t".join(missing)) test.fail_test(1) if no_result: - print "Cannot check files, the following have apparently not been built:" - print "\t" + "\n\t".join(no_result) + print("Cannot check files, the following have apparently not been built:") + print("\t" + "\n\t".join(no_result)) test.no_result(1) test.pass_test() diff --git a/src/test_interrupts.py b/src/test_interrupts.py index fb12e2a..1e027a1 100644 --- a/src/test_interrupts.py +++ b/src/test_interrupts.py @@ -102,7 +102,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')]: @@ -129,9 +129,9 @@ for f in files: if expected_num != len(uncaught_this_file): uncaughtKeyboardInterrupt = 1 msg = "%s: expected %d uncaught interrupts, got %d:" - print msg % (f, expected_num, len(uncaught_this_file)) + print(msg % (f, expected_num, len(uncaught_this_file))) for line in uncaught_this_file: - print " File %s:%d: Uncaught KeyboardInterrupt!" % (f,line) + print(" File %s:%d: Uncaught KeyboardInterrupt!" % (f,line)) test.fail_test(uncaughtKeyboardInterrupt) diff --git a/src/test_pychecker.py b/src/test_pychecker.py index f87d303..24aa966 100644 --- a/src/test_pychecker.py +++ b/src/test_pychecker.py @@ -139,7 +139,7 @@ for file in files: mismatches.append(stderr) if mismatches: - print ''.join(mismatches[1:]) + print(''.join(mismatches[1:])) test.fail_test() test.pass_test() diff --git a/src/test_setup.py b/src/test_setup.py index 29d36bf..731fbe7 100644 --- a/src/test_setup.py +++ b/src/test_setup.py @@ -197,9 +197,9 @@ if not os.path.isdir(scons_version) and os.path.isfile(tar_gz): os.system("gunzip -c %s | tar xf -" % tar_gz) if not os.path.isdir(scons_version): - print "Cannot test package installation, found none of the following packages:" - print "\t" + tar_gz - print "\t" + zip + print("Cannot test package installation, found none of the following packages:") + print("\t" + tar_gz) + print("\t" + zip) test.no_result(1) # Verify that a virgin installation installs the version library, diff --git a/src/test_strings.py b/src/test_strings.py index 3288d5f..b57c714 100644 --- a/src/test_strings.py +++ b/src/test_strings.py @@ -248,13 +248,13 @@ for collector in check_list: not_built.append(collector.directory) if missing_strings: - print "Found the following files with missing strings:" - print "\t" + "\n\t".join(missing_strings) + print("Found the following files with missing strings:") + print("\t" + "\n\t".join(missing_strings)) test.fail_test(1) if not_built: - print "Cannot check all strings, the following have apparently not been built:" - print "\t" + "\n\t".join(not_built) + print("Cannot check all strings, the following have apparently not been built:") + print("\t" + "\n\t".join(not_built)) test.no_result(1) test.pass_test() 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/unicode-signature.py b/test/Actions/unicode-signature.py index 0d0c469..0ba50c3 100644 --- a/test/Actions/unicode-signature.py +++ b/test/Actions/unicode-signature.py @@ -36,7 +36,7 @@ import TestSCons test = TestSCons.TestSCons() try: - unicode + str except NameError: import sys msg = "Unicode not supported by Python version %s; skipping test\n" diff --git a/test/AddOption/help.py b/test/AddOption/help.py index d50e595..a3fd7be 100644 --- a/test/AddOption/help.py +++ b/test/AddOption/help.py @@ -57,10 +57,10 @@ lines = test.stdout().split('\n') missing = [e for e in expected_lines if e not in lines] if missing: - print "====== STDOUT:" - print test.stdout() - print "====== Missing the following lines in the above AddOption() help output:" - print "\n".join(missing) + print("====== STDOUT:") + print(test.stdout()) + print("====== Missing the following lines in the above AddOption() help output:") + print("\n".join(missing)) test.fail_test() test.unlink('SConstruct') @@ -70,10 +70,10 @@ lines = test.stdout().split('\n') unexpected = [e for e in expected_lines if e in lines] if unexpected: - print "====== STDOUT:" - print test.stdout() - print "====== Unexpected lines in the above non-AddOption() help output:" - print "\n".join(unexpected) + print("====== STDOUT:") + print(test.stdout()) + print("====== Unexpected lines in the above non-AddOption() help output:") + print("\n".join(unexpected)) test.fail_test() test.pass_test() diff --git a/test/Batch/action-changed.py b/test/Batch/action-changed.py index dc2805a..d031432 100644 --- a/test/Batch/action-changed.py +++ b/test/Batch/action-changed.py @@ -54,7 +54,7 @@ sys.exit(0) """ test.write('build.py', build_py_contents % (python, 'one')) -os.chmod(test.workpath('build.py'), 0755) +os.chmod(test.workpath('build.py'), 0o755) test.write('SConstruct', """ env = Environment() @@ -81,7 +81,7 @@ test.must_match('f3.out', "one\nf3.in\n") test.up_to_date(arguments = '.') test.write('build.py', build_py_contents % (python, 'two')) -os.chmod(test.workpath('build.py'), 0755) +os.chmod(test.workpath('build.py'), 0o755) test.not_up_to_date(arguments = '.') diff --git a/test/Chmod.py b/test/Chmod.py index c00aea0..8b5fbe0 100644 --- a/test/Chmod.py +++ b/test/Chmod.py @@ -87,19 +87,19 @@ test.write('f10', "f10\n") test.subdir('d11') test.subdir('d12') -os.chmod(test.workpath('f1'), 0444) -os.chmod(test.workpath('f1-File'), 0444) -os.chmod(test.workpath('d2'), 0555) -os.chmod(test.workpath('d2-Dir'), 0555) -os.chmod(test.workpath('f3'), 0444) -os.chmod(test.workpath('d4'), 0555) -os.chmod(test.workpath('f5'), 0444) -os.chmod(test.workpath('Chmod-f7.in'), 0444) -os.chmod(test.workpath('f7.out-Chmod'), 0444) -os.chmod(test.workpath('f9'), 0444) -os.chmod(test.workpath('f10'), 0444) -os.chmod(test.workpath('d11'), 0555) -os.chmod(test.workpath('d12'), 0555) +os.chmod(test.workpath('f1'), 0o444) +os.chmod(test.workpath('f1-File'), 0o444) +os.chmod(test.workpath('d2'), 0o555) +os.chmod(test.workpath('d2-Dir'), 0o555) +os.chmod(test.workpath('f3'), 0o444) +os.chmod(test.workpath('d4'), 0o555) +os.chmod(test.workpath('f5'), 0o444) +os.chmod(test.workpath('Chmod-f7.in'), 0o444) +os.chmod(test.workpath('f7.out-Chmod'), 0o444) +os.chmod(test.workpath('f9'), 0o444) +os.chmod(test.workpath('f10'), 0o444) +os.chmod(test.workpath('d11'), 0o555) +os.chmod(test.workpath('d12'), 0o555) expect = test.wrap_stdout(read_str = """\ Chmod("f1", 0666) @@ -123,68 +123,68 @@ cat(["f8.out"], ["f8.in"]) test.run(options = '-n', arguments = '.', stdout = expect) s = stat.S_IMODE(os.stat(test.workpath('f1'))[stat.ST_MODE]) -test.fail_test(s != 0444) +test.fail_test(s != 0o444) s = stat.S_IMODE(os.stat(test.workpath('f1-File'))[stat.ST_MODE]) -test.fail_test(s != 0444) +test.fail_test(s != 0o444) s = stat.S_IMODE(os.stat(test.workpath('d2'))[stat.ST_MODE]) -test.fail_test(s != 0555) +test.fail_test(s != 0o555) s = stat.S_IMODE(os.stat(test.workpath('d2-Dir'))[stat.ST_MODE]) -test.fail_test(s != 0555) +test.fail_test(s != 0o555) test.must_not_exist('bar.out') s = stat.S_IMODE(os.stat(test.workpath('f3'))[stat.ST_MODE]) -test.fail_test(s != 0444) +test.fail_test(s != 0o444) s = stat.S_IMODE(os.stat(test.workpath('d4'))[stat.ST_MODE]) -test.fail_test(s != 0555) +test.fail_test(s != 0o555) s = stat.S_IMODE(os.stat(test.workpath('f5'))[stat.ST_MODE]) -test.fail_test(s != 0444) +test.fail_test(s != 0o444) test.must_not_exist('f6.out') test.must_not_exist('f7.out') s = stat.S_IMODE(os.stat(test.workpath('Chmod-f7.in'))[stat.ST_MODE]) -test.fail_test(s != 0444) +test.fail_test(s != 0o444) s = stat.S_IMODE(os.stat(test.workpath('f7.out-Chmod'))[stat.ST_MODE]) -test.fail_test(s != 0444) +test.fail_test(s != 0o444) test.must_not_exist('f8.out') s = stat.S_IMODE(os.stat(test.workpath('f9'))[stat.ST_MODE]) -test.fail_test(s != 0444) +test.fail_test(s != 0o444) s = stat.S_IMODE(os.stat(test.workpath('f10'))[stat.ST_MODE]) -test.fail_test(s != 0444) +test.fail_test(s != 0o444) s = stat.S_IMODE(os.stat(test.workpath('d11'))[stat.ST_MODE]) -test.fail_test(s != 0555) +test.fail_test(s != 0o555) s = stat.S_IMODE(os.stat(test.workpath('d12'))[stat.ST_MODE]) -test.fail_test(s != 0555) +test.fail_test(s != 0o555) test.run() s = stat.S_IMODE(os.stat(test.workpath('f1'))[stat.ST_MODE]) -test.fail_test(s != 0666) +test.fail_test(s != 0o666) s = stat.S_IMODE(os.stat(test.workpath('f1-File'))[stat.ST_MODE]) -test.fail_test(s != 0666) +test.fail_test(s != 0o666) s = stat.S_IMODE(os.stat(test.workpath('d2'))[stat.ST_MODE]) -test.fail_test(s != 0777) +test.fail_test(s != 0o777) s = stat.S_IMODE(os.stat(test.workpath('d2-Dir'))[stat.ST_MODE]) -test.fail_test(s != 0777) +test.fail_test(s != 0o777) test.must_match('bar.out', "bar.in\n") s = stat.S_IMODE(os.stat(test.workpath('f3'))[stat.ST_MODE]) -test.fail_test(s != 0666) +test.fail_test(s != 0o666) s = stat.S_IMODE(os.stat(test.workpath('d4'))[stat.ST_MODE]) -test.fail_test(s != 0777) +test.fail_test(s != 0o777) s = stat.S_IMODE(os.stat(test.workpath('f5'))[stat.ST_MODE]) -test.fail_test(s != 0666) +test.fail_test(s != 0o666) test.must_match('f6.out', "f6.in\n") test.must_match('f7.out', "f7.in\n") s = stat.S_IMODE(os.stat(test.workpath('Chmod-f7.in'))[stat.ST_MODE]) -test.fail_test(s != 0666) +test.fail_test(s != 0o666) s = stat.S_IMODE(os.stat(test.workpath('f7.out-Chmod'))[stat.ST_MODE]) -test.fail_test(s != 0666) +test.fail_test(s != 0o666) test.must_match('f8.out', "f8.in\n") s = stat.S_IMODE(os.stat(test.workpath('f9'))[stat.ST_MODE]) -test.fail_test(s != 0666) +test.fail_test(s != 0o666) s = stat.S_IMODE(os.stat(test.workpath('f10'))[stat.ST_MODE]) -test.fail_test(s != 0666) +test.fail_test(s != 0o666) s = stat.S_IMODE(os.stat(test.workpath('d11'))[stat.ST_MODE]) -test.fail_test(s != 0777) +test.fail_test(s != 0o777) s = stat.S_IMODE(os.stat(test.workpath('d12'))[stat.ST_MODE]) -test.fail_test(s != 0777) +test.fail_test(s != 0o777) test.pass_test() diff --git a/test/Configure/ConfigureDryRunError.py b/test/Configure/ConfigureDryRunError.py index b4be67e..a8c6309 100644 --- a/test/Configure/ConfigureDryRunError.py +++ b/test/Configure/ConfigureDryRunError.py @@ -97,7 +97,7 @@ test.checkLogAndStdout( ["Checking for C library %s... " % lib, newLog = test.read(test.workpath('config.log')) if newLog != oldLog: - print "Unexpected update of log file within a dry run" + print("Unexpected update of log file within a dry run") test.fail_test() test.pass_test() diff --git a/test/Configure/config-h.py b/test/Configure/config-h.py index cda6c3b..6c70c9c 100644 --- a/test/Configure/config-h.py +++ b/test/Configure/config-h.py @@ -135,19 +135,19 @@ test.run(stdout=expected_stdout) config_h = test.read(test.workpath('config.h')) if expected_config_h != config_h: - print "Unexpected config.h" - print "Expected: " - print "---------------------------------------------------------" - print repr(expected_config_h) - print "---------------------------------------------------------" - print "Found: " - print "---------------------------------------------------------" - print repr(config_h) - print "---------------------------------------------------------" - print "Stdio: " - print "---------------------------------------------------------" - print test.stdout() - print "---------------------------------------------------------" + print("Unexpected config.h") + print("Expected: ") + print("---------------------------------------------------------") + print(repr(expected_config_h)) + print("---------------------------------------------------------") + print("Found: ") + print("---------------------------------------------------------") + print(repr(config_h)) + print("---------------------------------------------------------") + print("Stdio: ") + print("---------------------------------------------------------") + print(test.stdout()) + print("---------------------------------------------------------") test.fail_test() expected_read_str = re.sub(r'\b((yes)|(no))\b', @@ -162,19 +162,19 @@ test.run(stdout=expected_stdout) config_h = test.read(test.workpath('config.h')) if expected_config_h != config_h: - print "Unexpected config.h" - print "Expected: " - print "---------------------------------------------------------" - print repr(expected_config_h) - print "---------------------------------------------------------" - print "Found: " - print "---------------------------------------------------------" - print repr(config_h) - print "---------------------------------------------------------" - print "Stdio: " - print "---------------------------------------------------------" - print test.stdout() - print "---------------------------------------------------------" + print("Unexpected config.h") + print("Expected: ") + print("---------------------------------------------------------") + print(repr(expected_config_h)) + print("---------------------------------------------------------") + print("Found: ") + print("---------------------------------------------------------") + print(repr(config_h)) + print("---------------------------------------------------------") + print("Stdio: ") + print("---------------------------------------------------------") + print(test.stdout()) + print("---------------------------------------------------------") test.fail_test() test.pass_test() diff --git a/test/Configure/implicit-cache.py b/test/Configure/implicit-cache.py index 0f04b1e..059fd4c 100644 --- a/test/Configure/implicit-cache.py +++ b/test/Configure/implicit-cache.py @@ -93,11 +93,11 @@ test.run_sconsign('-d .sconf_temp -e conftest_0.c --raw .sconsign.dblite') new_sconsign_dblite = test.stdout() if old_sconsign_dblite != new_sconsign_dblite: - print ".sconsign.dblite did not match:" - print "FIRST RUN ==========" - print old_sconsign_dblite - print "SECOND RUN ==========" - print new_sconsign_dblite + print(".sconsign.dblite did not match:") + print("FIRST RUN ==========") + print(old_sconsign_dblite) + print("SECOND RUN ==========") + print(new_sconsign_dblite) test.fail_test() test.pass_test() diff --git a/test/Copy-Action.py b/test/Copy-Action.py index 51635c5..ded158a 100644 --- a/test/Copy-Action.py +++ b/test/Copy-Action.py @@ -84,8 +84,8 @@ test.subdir('d5') test.write(['d5', 'f12.in'], "f12.in\n") test.write('f 13.in', "f 13.in\n") -os.chmod('f1.in', 0646) -os.chmod('f4.in', 0644) +os.chmod('f1.in', 0o646) +os.chmod('f4.in', 0o644) test.sleep() diff --git a/test/Deprecated/Options/Options.py b/test/Deprecated/Options/Options.py index 8116a63..61a12f3 100644 --- a/test/Deprecated/Options/Options.py +++ b/test/Deprecated/Options/Options.py @@ -237,7 +237,7 @@ opts.Save('options.saved', env) def checkSave(file, expected): gdict = {} ldict = {} - exec open(file, 'rU').read() in gdict, ldict + exec(open(file, 'rU').read(), gdict, ldict) assert expected == ldict, "%s\n...not equal to...\n%s" % (expected, ldict) # First test with no command line options diff --git a/test/Deprecated/SourceCode/BitKeeper/BitKeeper.py b/test/Deprecated/SourceCode/BitKeeper/BitKeeper.py index 28b8761..9a36eac 100644 --- a/test/Deprecated/SourceCode/BitKeeper/BitKeeper.py +++ b/test/Deprecated/SourceCode/BitKeeper/BitKeeper.py @@ -67,7 +67,7 @@ test.subdir('BK', 'import', ['import', 'sub']) # Test using BitKeeper to fetch from SCCS/s.file files. sccs = test.where_is('sccs') if not sccs: - print "Could not find SCCS, skipping sub-test of BitKeeper using SCCS files." + print("Could not find SCCS, skipping sub-test of BitKeeper using SCCS files.") else: test.subdir('work1', ['work1', 'SCCS'], @@ -167,9 +167,9 @@ sub/fff.in 1.1 -> 1.2: 1 lines rcs = test.where_is('rcs') ci = test.where_is('ci') if not rcs: - print "Could not find RCS,\nskipping sub-test of BitKeeper using RCS files." + print("Could not find RCS,\nskipping sub-test of BitKeeper using RCS files.") elif not ci: - print "Could not find the RCS ci command,\nskipping sub-test of BitKeeper using RCS files." + print("Could not find the RCS ci command,\nskipping sub-test of BitKeeper using RCS files.") else: test.subdir('work2', ['work2', 'RCS'], diff --git a/test/Deprecated/SourceCode/Subversion.py b/test/Deprecated/SourceCode/Subversion.py index a97c86f..ac3eb57 100644 --- a/test/Deprecated/SourceCode/Subversion.py +++ b/test/Deprecated/SourceCode/Subversion.py @@ -50,7 +50,7 @@ svnadmin = test.where_is('svnadmin') if not svn: test.skip_test("Could not find 'svnadmin'; skipping test(s).\n") -print "Short-circuiting this test until we support Subversion" +print("Short-circuiting this test until we support Subversion") test.pass_test() test.subdir('Subversion', 'import', ['import', 'sub'], 'work1', 'work2') diff --git a/test/GetBuildFailures/parallel.py b/test/GetBuildFailures/parallel.py index b7576af..101c2e2 100644 --- a/test/GetBuildFailures/parallel.py +++ b/test/GetBuildFailures/parallel.py @@ -102,8 +102,8 @@ error_45 = f4_error + f5_error error_54 = f5_error + f4_error if test.stderr() not in [error_45, error_54]: - print "Did not find the following output in list of expected strings:" - print test.stderr(), + print("Did not find the following output in list of expected strings:") + print(test.stderr(), end=' ') test.fail_test() # We jump through hoops above to try to make sure that the individual @@ -121,8 +121,8 @@ failed_45 = f4_failed + f5_failed failed_54 = f5_failed + f4_failed if test.stdout() not in [failed_45, failed_54]: - print "Did not find the following output in list of expected strings:" - print test.stdout(), + print("Did not find the following output in list of expected strings:") + print(test.stdout(), end=' ') test.fail_test() test.must_match(test.workpath('f3'), 'f3.in\n') diff --git a/test/Glob/glob-libpath.py b/test/Glob/glob-libpath.py index b09aab9..6ee06e6 100644 --- a/test/Glob/glob-libpath.py +++ b/test/Glob/glob-libpath.py @@ -77,10 +77,10 @@ test.write(['src', 'util', 'util.cpp'], """int i=0; test.run(arguments = '-Q .') if not test.match_re_dotall(test.stdout(), r".*(-L|/LIBPATH:)build[/\\]util.*"): - print repr(test.stdout())+" should contain -Lbuild/util or /LIBPATH:build\\util" + print(repr(test.stdout())+" should contain -Lbuild/util or /LIBPATH:build\\util") test.fail_test() if test.match_re_dotall(test.stdout(), r".*(-L|/LIBPATH:)src[/\\]util.*"): - print repr(test.stdout())+" should not contain -Lsrc/util or /LIBPATH:src\\util" + print(repr(test.stdout())+" should not contain -Lsrc/util or /LIBPATH:src\\util") test.fail_test() test.pass_test() diff --git a/test/Install/Install.py b/test/Install/Install.py index adadfd9..d66660b 100644 --- a/test/Install/Install.py +++ b/test/Install/Install.py @@ -129,7 +129,7 @@ test.must_match(['work', 'f2.out'], "f2.in\n") # if a target can not be unlinked before building it: test.write(['work', 'f1.in'], "f1.in again again\n") -os.chmod(test.workpath('work', 'export'), 0555) +os.chmod(test.workpath('work', 'export'), 0o555) f = open(f1_out, 'rb') diff --git a/test/Interactive/version.py b/test/Interactive/version.py index bbca9ef..295b9d3 100644 --- a/test/Interactive/version.py +++ b/test/Interactive/version.py @@ -76,7 +76,7 @@ expect2 = r"""scons>>> SCons by Steven Knight et al\.: stdout = test.stdout() + '\n' if not test.match_re(stdout, expect1) and not test.match_re(stdout, expect2): - print repr(stdout) + print(repr(stdout)) test.fail_test() diff --git a/test/Java/multi-step.py b/test/Java/multi-step.py index a8efcd4..add4208 100644 --- a/test/Java/multi-step.py +++ b/test/Java/multi-step.py @@ -557,7 +557,7 @@ test.must_exist(['buildout', 'jni', 'SampleTest.java']) # it doesn't exist. p = test.workpath('buildout', 'jni', 'SampleTest.class') if not os.path.exists(p): - print 'Warning: %s does not exist' % p + print('Warning: %s does not exist' % p) test.up_to_date(arguments = '.') diff --git a/test/MSVC/batch-longlines.py b/test/MSVC/batch-longlines.py index ef7233b..c584aba 100644 --- a/test/MSVC/batch-longlines.py +++ b/test/MSVC/batch-longlines.py @@ -1,61 +1,61 @@ -#!/usr/bin/env python -# -# __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__" - -""" -Verify operation of Visual C/C++ batch builds with long lines. - -Only runs on Windows. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.skip_if_not_msvc() - -_python_ = TestSCons._python_ - -for i in xrange(1,200): - test.write('source-file-with-quite-a-long-name-maybe-unrealistic-but-who-cares-%05d.cxx'%i, - '/* source file %d */\nint var%d;\n'%(i,i)) - -test.write('SConstruct', """ -env = Environment(tools=['msvc', 'mslink'], - MSVC_BATCH=ARGUMENTS.get('MSVC_BATCH')) -env.SharedLibrary('mylib', Glob('source*.cxx')) -""" % locals()) - -test.run(arguments = 'MSVC_BATCH=1 .') - -test.must_exist('mylib.dll') - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: +#!/usr/bin/env python +# +# __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__" + +""" +Verify operation of Visual C/C++ batch builds with long lines. + +Only runs on Windows. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.skip_if_not_msvc() + +_python_ = TestSCons._python_ + +for i in range(1,200): + test.write('source-file-with-quite-a-long-name-maybe-unrealistic-but-who-cares-%05d.cxx'%i, + '/* source file %d */\nint var%d;\n'%(i,i)) + +test.write('SConstruct', """ +env = Environment(tools=['msvc', 'mslink'], + MSVC_BATCH=ARGUMENTS.get('MSVC_BATCH')) +env.SharedLibrary('mylib', Glob('source*.cxx')) +""" % locals()) + +test.run(arguments = 'MSVC_BATCH=1 .') + +test.must_exist('mylib.dll') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/MSVC/msvc.py b/test/MSVC/msvc.py index c68fb45..6f5c8d6 100644 --- a/test/MSVC/msvc.py +++ b/test/MSVC/msvc.py @@ -181,9 +181,9 @@ slow = time.time() - start # using precompiled headers should be faster limit = slow*0.90 if fast >= limit: - print "Using precompiled headers was not fast enough:" - print "slow.obj: %.3fs" % slow - print "fast.obj: %.3fs (expected less than %.3fs)" % (fast, limit) + print("Using precompiled headers was not fast enough:") + print("slow.obj: %.3fs" % slow) + print("fast.obj: %.3fs (expected less than %.3fs)" % (fast, limit)) test.fail_test() # Modifying resource.h should cause both the resource and precompiled header to be rebuilt: diff --git a/test/QT/QTFLAGS.py b/test/QT/QTFLAGS.py index 008397a..b7172fc 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/QT/copied-env.py b/test/QT/copied-env.py index efa91be..59a344d 100644 --- a/test/QT/copied-env.py +++ b/test/QT/copied-env.py @@ -70,8 +70,8 @@ moc_MyForm = [x for x in test.stdout().split('\n') if x.find('moc_MyForm') != -1 MYLIB_IMPL = [x for x in moc_MyForm if x.find('MYLIB_IMPL') != -1] if not MYLIB_IMPL: - print "Did not find MYLIB_IMPL on moc_MyForm compilation line:" - print test.stdout() + print("Did not find MYLIB_IMPL on moc_MyForm compilation line:") + print(test.stdout()) test.fail_test() test.pass_test() diff --git a/test/QT/warnings.py b/test/QT/warnings.py index a861b24..5e680f6 100644 --- a/test/QT/warnings.py +++ b/test/QT/warnings.py @@ -59,8 +59,8 @@ scons: warning: Generated moc file 'aaa.moc' is not included by 'aaa.cpp' """ + TestSCons.file_expr if not re.search(match12, test.stderr()): - print "Did not find expected regular expression in stderr:" - print test.stderr() + print("Did not find expected regular expression in stderr:") + print(test.stderr()) test.fail_test() os.environ['QTDIR'] = test.QT diff --git a/test/SConsignFile/use-dbhash.py b/test/SConsignFile/use-dbhash.py index 45e3e36..bd9b799 100644 --- a/test/SConsignFile/use-dbhash.py +++ b/test/SConsignFile/use-dbhash.py @@ -35,7 +35,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() try: - import dbhash + import dbm.bsd except ImportError: test.skip_test('No dbhash in this version of Python; skipping test.\n') diff --git a/test/SConsignFile/use-dbm.py b/test/SConsignFile/use-dbm.py index 75f088d..90983b3 100644 --- a/test/SConsignFile/use-dbm.py +++ b/test/SConsignFile/use-dbm.py @@ -35,7 +35,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() try: - import dbm + import dbm.ndbm except ImportError: test.skip_test('No dbm in this version of Python; skipping test.\n') diff --git a/test/SConsignFile/use-dumbdbm.py b/test/SConsignFile/use-dumbdbm.py index 9d48fe5..84f1dd4 100644 --- a/test/SConsignFile/use-dumbdbm.py +++ b/test/SConsignFile/use-dumbdbm.py @@ -35,7 +35,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() try: - import dumbdbm + import dbm.dumb except ImportError: test.skip_test('No dumbdbm in this version of Python; skipping test.\n') diff --git a/test/SConsignFile/use-gdbm.py b/test/SConsignFile/use-gdbm.py index 1eb3645..a7e4f59 100644 --- a/test/SConsignFile/use-gdbm.py +++ b/test/SConsignFile/use-gdbm.py @@ -35,7 +35,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() try: - import gdbm + import dbm.gnu except ImportError: test.skip_test('No gdbm in this version of Python; skipping test.\n') diff --git a/test/SHELL.py b/test/SHELL.py index 93ed0b1..faee27f 100644 --- a/test/SHELL.py +++ b/test/SHELL.py @@ -64,7 +64,7 @@ ofp.close() sys.exit(0) """ % locals()) -os.chmod(my_shell, 0755) +os.chmod(my_shell, 0o755) test.write('SConstruct', """\ env = Environment(SHELL = r'%(my_shell)s') diff --git a/test/Scanner/unicode.py b/test/Scanner/unicode.py index 55e22bd..7a72804 100644 --- a/test/Scanner/unicode.py +++ b/test/Scanner/unicode.py @@ -36,7 +36,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() try: - unicode + str except NameError: import sys msg = "Unicode not supported by Python version %s; skipping test\n" @@ -102,28 +102,28 @@ include utf16be.k foo.k 1 line 4 """) -contents = unicode("""\ +contents = str("""\ ascii.k 1 line 1 include ascii.inc ascii.k 1 line 3 """) test.write('ascii.k', contents.encode('ascii')) -contents = unicode("""\ +contents = str("""\ utf8.k 1 line 1 include utf8.inc utf8.k 1 line 3 """) test.write('utf8.k', codecs.BOM_UTF8 + contents.encode('utf-8')) -contents = unicode("""\ +contents = str("""\ utf16le.k 1 line 1 include utf16le.inc utf16le.k 1 line 3 """) test.write('utf16le.k', codecs.BOM_UTF16_LE + contents.encode('utf-16-le')) -contents = unicode("""\ +contents = str("""\ utf16be.k 1 line 1 include utf16be.inc utf16be.k 1 line 3 diff --git a/test/TEMPFILEPREFIX.py b/test/TEMPFILEPREFIX.py index f9b3240..8e756af 100644 --- a/test/TEMPFILEPREFIX.py +++ b/test/TEMPFILEPREFIX.py @@ -45,7 +45,7 @@ print sys.argv echo_py = test.workpath('echo.py') st = os.stat(echo_py) -os.chmod(echo_py, st[stat.ST_MODE]|0111) +os.chmod(echo_py, st[stat.ST_MODE]|0o111) test.write('SConstruct', """ import os diff --git a/test/TEX/TEX.py b/test/TEX/TEX.py index 24d4bdd..863144d 100644 --- a/test/TEX/TEX.py +++ b/test/TEX/TEX.py @@ -173,14 +173,14 @@ Run \texttt{latex}, then \texttt{bibtex}, then \texttt{latex} twice again \cite{ reruns = [x for x in output_lines if x.find('latex -interaction=nonstopmode -recorder rerun.tex') != -1] if len(reruns) != 2: - print "Expected 2 latex calls, got %s:" % len(reruns) - print '\n'.join(reruns) + print("Expected 2 latex calls, got %s:" % len(reruns)) + print('\n'.join(reruns)) test.fail_test() bibtex = [x for x in output_lines if x.find('bibtex bibtex-test') != -1] if len(bibtex) != 1: - print "Expected 1 bibtex call, got %s:" % len(bibtex) - print '\n'.join(bibtex) + print("Expected 1 bibtex call, got %s:" % len(bibtex)) + print('\n'.join(bibtex)) test.fail_test() test.pass_test() diff --git a/test/Value.py b/test/Value.py index f3ad458..025c6de 100644 --- a/test/Value.py +++ b/test/Value.py @@ -81,7 +81,7 @@ open(sys.argv[-1],'wb').write(" ".join(sys.argv[1:-2])) # to make sure there's no difference in behavior. for source_signature in ['MD5', 'timestamp-newer']: - print "Testing Value node with source signatures:", source_signature + print("Testing Value node with source signatures:", source_signature) test.write('SConstruct', SConstruct_content % locals()) diff --git a/test/Variables/Variables.py b/test/Variables/Variables.py index 454e32e..d0bf432 100644 --- a/test/Variables/Variables.py +++ b/test/Variables/Variables.py @@ -231,7 +231,7 @@ opts.Save('variables.saved', env) def checkSave(file, expected): gdict = {} ldict = {} - exec open(file, 'rU').read() in gdict, ldict + exec(open(file, 'rU').read(), gdict, ldict) assert expected == ldict, "%s\n...not equal to...\n%s" % (expected, ldict) # First test with no command line variables diff --git a/test/WhereIs.py b/test/WhereIs.py index dc127b6..07c3f6c 100644 --- a/test/WhereIs.py +++ b/test/WhereIs.py @@ -45,10 +45,10 @@ if sys.platform != 'win32': os.mkdir(sub2_xxx_exe) test.write(sub3_xxx_exe, "\n") -os.chmod(sub3_xxx_exe, 0777) +os.chmod(sub3_xxx_exe, 0o777) test.write(sub4_xxx_exe, "\n") -os.chmod(sub4_xxx_exe, 0777) +os.chmod(sub4_xxx_exe, 0o777) env_path = os.environ['PATH'] diff --git a/test/Win32/bad-drive.py b/test/Win32/bad-drive.py index f2a55b8..ff98b4e 100644 --- a/test/Win32/bad-drive.py +++ b/test/Win32/bad-drive.py @@ -50,8 +50,8 @@ for i in range(len(uppercase)-1, -1, -1): break if bad_drive is None: - print "All drive letters appear to be in use." - print "Cannot test SCons handling of invalid Windows drive letters." + print("All drive letters appear to be in use.") + print("Cannot test SCons handling of invalid Windows drive letters.") test.no_result(1); test.write('SConstruct', """ diff --git a/test/Win32/default-drive.py b/test/Win32/default-drive.py index f427a20..2bc14b1 100644 --- a/test/Win32/default-drive.py +++ b/test/Win32/default-drive.py @@ -59,7 +59,7 @@ test.write(['src', 'file.in'], "src/file.in\n") build_file_out = test.workpath('build', 'file.out') -print os.path.splitdrive(build_file_out)[1] +print(os.path.splitdrive(build_file_out)[1]) test.run(chdir = 'src', arguments = os.path.splitdrive(build_file_out)[1]) diff --git a/test/ZIP/ZIP.py b/test/ZIP/ZIP.py index af2450b..f2acad8 100644 --- a/test/ZIP/ZIP.py +++ b/test/ZIP/ZIP.py @@ -47,7 +47,7 @@ def zipfile_contains(zipfilename, names): for name in names: try: info=zf.getinfo(name) - except KeyError, e: # name not found + except KeyError as e: # name not found zf.close() return False return True diff --git a/test/ZIP/ZIPROOT.py b/test/ZIP/ZIPROOT.py index 96747a7..f3e4496 100644 --- a/test/ZIP/ZIPROOT.py +++ b/test/ZIP/ZIPROOT.py @@ -1,98 +1,98 @@ -#!/usr/bin/env python -# -# __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__" - -import os -import stat - -import TestSCons - -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons() - -import zipfile - -def zipfile_contains(zipfilename, names): - """Returns True if zipfilename contains all the names, False otherwise.""" - zf=zipfile.ZipFile(zipfilename, 'r') - if type(names)==type(''): - names=[names] - for name in names: - try: - info=zf.getinfo(name) - except KeyError, e: # name not found - zf.close() - return False - return True - -def zipfile_files(fname): - """Returns all the filenames in zip file fname.""" - zf = zipfile.ZipFile(fname, 'r') - return [x.filename for x in zf.infolist()] - -test.subdir('sub1') -test.subdir(['sub1', 'sub2']) - -test.write('SConstruct', """ -env = Environment(tools = ['zip']) -env.Zip(target = 'aaa.zip', source = ['sub1/file1'], ZIPROOT='sub1') -env.Zip(target = 'bbb.zip', source = ['sub1/file2', 'sub1/sub2/file2'], ZIPROOT='sub1') -""" % locals()) - -test.write(['sub1', 'file1'], "file1\n") -test.write(['sub1', 'file2'], "file2a\n") -test.write(['sub1', 'sub2', 'file2'], "file2b\n") - -test.run(arguments = 'aaa.zip', stderr = None) - -test.must_exist('aaa.zip') - -# TEST: Zip file should contain 'file1', not 'sub1/file1', because of ZIPROOT. -zf=zipfile.ZipFile('aaa.zip', 'r') -test.fail_test(zf.testzip() is not None) -zf.close() - -files=zipfile_files('aaa.zip') -test.fail_test(zipfile_files('aaa.zip') != ['file1'], - message='Zip file aaa.zip has wrong files: %s'%repr(files)) - -### - -test.run(arguments = 'bbb.zip', stderr = None) - -test.must_exist('bbb.zip') - -# TEST: Zip file should contain 'sub2/file2', not 'sub1/sub2/file2', because of ZIPROOT. -zf=zipfile.ZipFile('bbb.zip', 'r') -test.fail_test(zf.testzip() is not None) -zf.close() - -files=zipfile_files('bbb.zip') -test.fail_test(zipfile_files('bbb.zip') != ['file2', 'sub2/file2'], - message='Zip file bbb.zip has wrong files: %s'%repr(files)) - - -test.pass_test() +#!/usr/bin/env python +# +# __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__" + +import os +import stat + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +import zipfile + +def zipfile_contains(zipfilename, names): + """Returns True if zipfilename contains all the names, False otherwise.""" + zf=zipfile.ZipFile(zipfilename, 'r') + if type(names)==type(''): + names=[names] + for name in names: + try: + info=zf.getinfo(name) + except KeyError as e: # name not found + zf.close() + return False + return True + +def zipfile_files(fname): + """Returns all the filenames in zip file fname.""" + zf = zipfile.ZipFile(fname, 'r') + return [x.filename for x in zf.infolist()] + +test.subdir('sub1') +test.subdir(['sub1', 'sub2']) + +test.write('SConstruct', """ +env = Environment(tools = ['zip']) +env.Zip(target = 'aaa.zip', source = ['sub1/file1'], ZIPROOT='sub1') +env.Zip(target = 'bbb.zip', source = ['sub1/file2', 'sub1/sub2/file2'], ZIPROOT='sub1') +""" % locals()) + +test.write(['sub1', 'file1'], "file1\n") +test.write(['sub1', 'file2'], "file2a\n") +test.write(['sub1', 'sub2', 'file2'], "file2b\n") + +test.run(arguments = 'aaa.zip', stderr = None) + +test.must_exist('aaa.zip') + +# TEST: Zip file should contain 'file1', not 'sub1/file1', because of ZIPROOT. +zf=zipfile.ZipFile('aaa.zip', 'r') +test.fail_test(zf.testzip() is not None) +zf.close() + +files=zipfile_files('aaa.zip') +test.fail_test(zipfile_files('aaa.zip') != ['file1'], + message='Zip file aaa.zip has wrong files: %s'%repr(files)) + +### + +test.run(arguments = 'bbb.zip', stderr = None) + +test.must_exist('bbb.zip') + +# TEST: Zip file should contain 'sub2/file2', not 'sub1/sub2/file2', because of ZIPROOT. +zf=zipfile.ZipFile('bbb.zip', 'r') +test.fail_test(zf.testzip() is not None) +zf.close() + +files=zipfile_files('bbb.zip') +test.fail_test(zipfile_files('bbb.zip') != ['file2', 'sub2/file2'], + message='Zip file bbb.zip has wrong files: %s'%repr(files)) + + +test.pass_test() diff --git a/test/gnutools.py b/test/gnutools.py index e1b7e42..f79efe4 100644 --- a/test/gnutools.py +++ b/test/gnutools.py @@ -118,7 +118,7 @@ def testObject(test, obj, expect): line1 = contents.split('\n')[0] actual = ' '.join(line1.split()) if not expect == actual: - print "%s: %s != %s\n" % (obj, repr(expect), repr(actual)) + print("%s: %s != %s\n" % (obj, repr(expect), repr(actual))) test.fail_test() if sys.platform in ('win32', 'cygwin'): diff --git a/test/import.py b/test/import.py index ef5ee61..fb8a28c 100644 --- a/test/import.py +++ b/test/import.py @@ -185,8 +185,8 @@ for tool in tools: matched = 1 break if not matched: - print "Failed importing '%s', stderr:" % tool - print stderr + print("Failed importing '%s', stderr:" % tool) + print(stderr) failures.append(tool) test.fail_test(len(failures)) diff --git a/test/long-lines/signature.py b/test/long-lines/signature.py index bc5d11a..ce38bec 100644 --- a/test/long-lines/signature.py +++ b/test/long-lines/signature.py @@ -51,7 +51,7 @@ fp.write('FILEFLAG=%s\\n' % args[2]) fp.write('TIMESTAMP=%s\\n' % args[3]) """) -os.chmod(build_py, 0755) +os.chmod(build_py, 0o755) test.write('SConstruct', """\ arg = 'a_long_ignored_argument' diff --git a/test/option--random.py b/test/option--random.py index a9b9b9d..59592cb 100644 --- a/test/option--random.py +++ b/test/option--random.py @@ -66,7 +66,7 @@ tries = 0 max_tries = 10 while test.stdout() == non_random_output: if tries >= max_tries: - print "--random generated the non-random output %s times!" % max_tries + print("--random generated the non-random output %s times!" % max_tries) test.fail_test() tries = tries + 1 test.run(arguments = '-n -Q --random') @@ -84,7 +84,7 @@ tries = 0 max_tries = 10 while test.stdout() == non_random_output: if tries >= max_tries: - print "--random generated the non-random output %s times!" % max_tries + print("--random generated the non-random output %s times!" % max_tries) test.fail_test() tries = tries + 1 test.run(arguments = '-n -Q --random') diff --git a/test/option-v.py b/test/option-v.py index 680f541..8985db0 100644 --- a/test/option-v.py +++ b/test/option-v.py @@ -55,13 +55,13 @@ expect2 = r"""SCons by Steven Knight et al.: test.run(arguments = '-v') stdout = test.stdout() if not test.match_re(stdout, expect1) and not test.match_re(stdout, expect2): - print stdout + print(stdout) test.fail_test() test.run(arguments = '--version') stdout = test.stdout() if not test.match_re(stdout, expect1) and not test.match_re(stdout, expect2): - print stdout + print(stdout) test.fail_test() test.pass_test() diff --git a/test/option/debug-count.py b/test/option/debug-count.py index 3f8a23c..076d7fa 100644 --- a/test/option/debug-count.py +++ b/test/option/debug-count.py @@ -74,10 +74,10 @@ for args in ['-h --debug=count', '--debug=count']: missing = [o for o in objects if find_object_count(o, stdout) is None] if missing: - print "Missing the following object lines from '%s' output:" % args - print "\t", ' '.join(missing) - print "STDOUT ==========" - print stdout + print("Missing the following object lines from '%s' output:" % args) + print("\t", ' '.join(missing)) + print("STDOUT ==========") + print(stdout) test.fail_test(1) expect_warning = """ diff --git a/test/option/debug-time.py b/test/option/debug-time.py index 198d71d..7448e1c 100644 --- a/test/option/debug-time.py +++ b/test/option/debug-time.py @@ -20,7 +20,7 @@ # 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. -from __future__ import division + __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -164,7 +164,7 @@ outside of the 15%% tolerance. """ % locals()) if failures or warnings: - print '\n'.join([test.stdout()] + failures + warnings) + print('\n'.join([test.stdout()] + failures + warnings)) if failures: test.fail_test(1) @@ -172,7 +172,7 @@ test.run(arguments = "--debug=time . SLEEP=0") command_time = get_command_time(test.stdout()) if command_time != 0.0: - print "Up-to-date run received non-zero command time of %s" % command_time + print("Up-to-date run received non-zero command time of %s" % command_time) test.fail_test() @@ -201,14 +201,14 @@ outside of the 1%% tolerance. """ % locals()) if failures: - print '\n'.join([test.stdout()] + failures) + print('\n'.join([test.stdout()] + failures)) test.fail_test(1) test.run(arguments = "-j4 --debug=time . SLEEP=1") command_time = get_command_time(test.stdout()) if command_time != 0.0: - print "Up-to-date run received non-zero command time of %s" % command_time + print("Up-to-date run received non-zero command time of %s" % command_time) test.fail_test() diff --git a/test/option/help-options.py b/test/option/help-options.py index 45bbfa0..1b23cb3 100644 --- a/test/option/help-options.py +++ b/test/option/help-options.py @@ -60,8 +60,8 @@ options = [x[-1] == ',' and x[:-1] or x for x in options] lowered = [x.lower() for x in options] ordered = sorted(lowered) if lowered != ordered: - print "lowered =", lowered - print "sorted =", ordered + print("lowered =", lowered) + print("sorted =", ordered) test.fail_test() test.pass_test() diff --git a/test/option/profile.py b/test/option/profile.py index d53c690..513da47 100644 --- a/test/option/profile.py +++ b/test/option/profile.py @@ -36,7 +36,7 @@ else: # when we drop support for Python 2.6. class StringIO(_StringIO): def write(self, s): - _StringIO.write(self, unicode(s)) + _StringIO.write(self, str(s)) import TestSCons diff --git a/test/scons-time/run/config/python.py b/test/scons-time/run/config/python.py index 6cf965b..57b732d 100644 --- a/test/scons-time/run/config/python.py +++ b/test/scons-time/run/config/python.py @@ -53,7 +53,7 @@ for arg in sys.argv[1:]: print 'my_python.py: %s' % profile """) -os.chmod(my_python_py, 0755) +os.chmod(my_python_py, 0o755) test.run(arguments = 'run -f config foo.tar.gz') diff --git a/test/scons-time/run/option/python.py b/test/scons-time/run/option/python.py index a28e23f..70feb70 100644 --- a/test/scons-time/run/option/python.py +++ b/test/scons-time/run/option/python.py @@ -49,7 +49,7 @@ for arg in sys.argv[1:]: sys.stdout.write('my_python.py: %s\\n' % profile) """) -os.chmod(my_python_py, 0755) +os.chmod(my_python_py, 0o755) test.run(arguments = 'run --python %s foo.tar.gz' % my_python_py) diff --git a/test/sconsign/nonwritable.py b/test/sconsign/nonwritable.py index 913dcf1..5ae55bb 100644 --- a/test/sconsign/nonwritable.py +++ b/test/sconsign/nonwritable.py @@ -78,7 +78,7 @@ test.write(['work1', 'foo.in'], "work1/foo.in\n") test.write(work1__sconsign_dblite, "") -os.chmod(work1__sconsign_dblite, 0444) +os.chmod(work1__sconsign_dblite, 0o444) test.run(chdir='work1', arguments='.') @@ -95,7 +95,7 @@ test.write(['work2', 'foo.in'], "work2/foo.in\n") pickle.dump({}, open(work2_sub1__sconsign, 'wb'), 1) pickle.dump({}, open(work2_sub2__sconsign, 'wb'), 1) -os.chmod(work2_sub1__sconsign, 0444) +os.chmod(work2_sub1__sconsign, 0o444) test.run(chdir='work2', arguments='.') diff --git a/test/sconsign/script/SConsignFile.py b/test/sconsign/script/SConsignFile.py index a9f79f4..71a7e6d 100644 --- a/test/sconsign/script/SConsignFile.py +++ b/test/sconsign/script/SConsignFile.py @@ -86,8 +86,8 @@ output.write(input.read()) sys.exit(0) """) -test.chmod(fake_cc_py, 0755) -test.chmod(fake_link_py, 0755) +test.chmod(fake_cc_py, 0o755) +test.chmod(fake_link_py, 0o755) # Note: We don't use os.path.join() representations of the file names # in the expected output because paths in the .sconsign files are diff --git a/test/sconsign/script/Signatures.py b/test/sconsign/script/Signatures.py index cfd2a7f..5babe67 100644 --- a/test/sconsign/script/Signatures.py +++ b/test/sconsign/script/Signatures.py @@ -105,8 +105,8 @@ output.write(input.read()) sys.exit(0) """) -test.chmod(fake_cc_py, 0755) -test.chmod(fake_link_py, 0755) +test.chmod(fake_cc_py, 0o755) +test.chmod(fake_link_py, 0o755) test.write('SConstruct', """ SConsignFile(None) diff --git a/test/sconsign/script/no-SConsignFile.py b/test/sconsign/script/no-SConsignFile.py index 829d650..70b18c8 100644 --- a/test/sconsign/script/no-SConsignFile.py +++ b/test/sconsign/script/no-SConsignFile.py @@ -94,8 +94,8 @@ output.write(input.read()) sys.exit(0) """) -test.chmod(fake_cc_py, 0755) -test.chmod(fake_link_py, 0755) +test.chmod(fake_cc_py, 0o755) +test.chmod(fake_link_py, 0o755) # Note: We don't use os.path.join() representations of the file names # in the expected output because paths in the .sconsign files are diff --git a/test/site_scons/sysdirs.py b/test/site_scons/sysdirs.py index c05ef67..d05f6a4 100644 --- a/test/site_scons/sysdirs.py +++ b/test/site_scons/sysdirs.py @@ -1,71 +1,71 @@ -#!/usr/bin/env python -# -# __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__" - -import TestSCons - -""" -Verify site_scons system dirs are getting loaded. -Uses an internal test fixture to get at the site_scons dirs. - -TODO: it would be great to test if it can actually load site_scons -files from the system dirs, but the test harness can't put files in -those dirs (which may not even exist on a build system). -""" - -test = TestSCons.TestSCons() - -test.write('SConstruct', """ -import SCons.Script -SCons.Script.Main.test_load_all_site_scons_dirs(Dir('.').path) -""") - -test.run(arguments = '-Q .') - -import SCons.Platform -platform = SCons.Platform.platform_default() -if platform in ('win32', 'cygwin'): - dir_to_check_for='Application Data' -elif platform in ('darwin'): - dir_to_check_for='Library' -else: - dir_to_check_for='.scons' - -if 'Loading site dir' not in test.stdout(): - print test.stdout() - test.fail_test() -if dir_to_check_for not in test.stdout(): - print test.stdout() - test.fail_test() - -test.pass_test() - -# end of file - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: +#!/usr/bin/env python +# +# __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__" + +import TestSCons + +""" +Verify site_scons system dirs are getting loaded. +Uses an internal test fixture to get at the site_scons dirs. + +TODO: it would be great to test if it can actually load site_scons +files from the system dirs, but the test harness can't put files in +those dirs (which may not even exist on a build system). +""" + +test = TestSCons.TestSCons() + +test.write('SConstruct', """ +import SCons.Script +SCons.Script.Main.test_load_all_site_scons_dirs(Dir('.').path) +""") + +test.run(arguments = '-Q .') + +import SCons.Platform +platform = SCons.Platform.platform_default() +if platform in ('win32', 'cygwin'): + dir_to_check_for='Application Data' +elif platform in ('darwin'): + dir_to_check_for='Library' +else: + dir_to_check_for='.scons' + +if 'Loading site dir' not in test.stdout(): + print(test.stdout()) + test.fail_test() +if dir_to_check_for not in test.stdout(): + print(test.stdout()) + test.fail_test() + +test.pass_test() + +# end of file + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/spaces.py b/test/spaces.py index db1ae97..1309047 100644 --- a/test/spaces.py +++ b/test/spaces.py @@ -36,7 +36,7 @@ if sys.platform == 'win32': else: test.write('duplicate a file.sh', 'cp foo.in foo.out\n') copy = test.workpath('duplicate a file.sh') - os.chmod(test.workpath('duplicate a file.sh'), 0777) + os.chmod(test.workpath('duplicate a file.sh'), 0o777) test.write('SConstruct', r''' diff --git a/test/subdivide.py b/test/subdivide.py index 2978e08..44402c9 100644 --- a/test/subdivide.py +++ b/test/subdivide.py @@ -76,8 +76,8 @@ for s in sys.argv[2:]: ofp.write(open(s, 'rb').read()) """) -test.chmod(fake_cc_py, 0755) -test.chmod(fake_link_py, 0755) +test.chmod(fake_cc_py, 0o755) +test.chmod(fake_link_py, 0o755) test.write('SConstruct', """\ SConsignFile(None) diff --git a/test/update-release-info/update-release-info.py b/test/update-release-info/update-release-info.py index d3125c7..0db65ba 100644 --- a/test/update-release-info/update-release-info.py +++ b/test/update-release-info/update-release-info.py @@ -201,7 +201,7 @@ RELEASE 2.0.0.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE """, mode = 'r') -years = ', '.join(map(str, range(2001, this_year + 1))) +years = ', '.join(map(str, list(range(2001, this_year + 1)))) test.must_match(SConstruct, """ month_year = 'MONTH YEAR' copyright_years = %s diff --git a/timings/ElectricCloud/TimeSCons-run.py b/timings/ElectricCloud/TimeSCons-run.py index be75d12..fbe0028 100644 --- a/timings/ElectricCloud/TimeSCons-run.py +++ b/timings/ElectricCloud/TimeSCons-run.py @@ -87,7 +87,7 @@ test.run(program=test.workpath('genscons.pl'), arguments=' '.join(arguments)) # This print is nott for debugging, leave it alone! # We want to display the output from genscons.pl's generation the build # configuration, so the buildbot logs contain more info. -print test.stdout() +print(test.stdout()) test.main(chdir='sconsbld') diff --git a/www/gen_sched_table.py b/www/gen_sched_table.py index e67f0d7..9ac8acd 100755 --- a/www/gen_sched_table.py +++ b/www/gen_sched_table.py @@ -6,13 +6,13 @@ import datetime months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] -print '' +print('
') def row(*cells, **kw): td = kw.get('tr','td') - print ' ' + print(' ') for cell in cells: - print ' <%s>%s' % (td,cell,td) - print ' ' + print(' <%s>%s' % (td,cell,td)) + print(' ') row('Estimated date', 'Type', 'Comments', tr = 'th') if len(sys.argv) > 1: @@ -30,7 +30,7 @@ for line in f: incr,type,desc = line[1:].strip().split(None,2) now = now + datetime.timedelta(int(incr)) else: - print 'dunna understand code', line[0] + print('dunna understand code', line[0]) sys.exit(1) #name = current + '.d' + str(now).replace('-','') date = '%s-%s-%s' % (now.day,months[now.month-1],now.year) @@ -41,7 +41,7 @@ for line in f: else: category = current = type row(date, category, desc) -print '
' +print('') # Local Variables: # tab-width:4 -- cgit v0.12 From b554eb817c60f4e419bbc84efc02c7fbc62b7ced Mon Sep 17 00:00:00 2001 From: Gary Oberbrunner Date: Sun, 22 Sep 2013 13:10:51 -0400 Subject: Manual python3 post-2to3 fixes from Neal Becker --- review.py | 2 +- src/engine/SCons/Action.py | 32 +++++++++++++++++++------------- src/engine/SCons/Conftest.py | 1 - src/engine/SCons/Errors.py | 4 +--- src/engine/SCons/Executor.py | 2 +- src/engine/SCons/SConf.py | 16 +++++++++++----- src/engine/SCons/Scanner/__init__.py | 2 +- src/engine/SCons/Script/SConscript.py | 2 +- src/engine/SCons/Script/__init__.py | 2 +- src/engine/SCons/Taskmaster.py | 10 +++------- src/engine/SCons/Tool/__init__.py | 4 ++-- src/engine/SCons/Tool/g++.py | 5 ++--- src/engine/SCons/Tool/gas.py | 5 ++++- src/engine/SCons/Tool/gcc.py | 2 +- src/engine/SCons/Tool/link.py | 2 +- src/engine/SCons/Tool/swig.py | 2 +- src/engine/SCons/Util.py | 19 +++++++++++++++---- src/engine/SCons/dblite.py | 16 ++++++---------- src/script/scons.py | 10 +++++----- 19 files changed, 76 insertions(+), 62 deletions(-) diff --git a/review.py b/review.py index 72e187e..8d033ed 100644 --- a/review.py +++ b/review.py @@ -1627,7 +1627,7 @@ def FormatSubversionPropertyChanges(filename, props): See the following doctest for example. - >>> print FormatSubversionPropertyChanges('foo.cc', [('svn:eol-style', 'LF')]) + >>> print(FormatSubversionPropertyChanges('foo.cc', [('svn:eol-style', 'LF')])) Property changes on: foo.cc ___________________________________________________________________ Added: svn:eol-style diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index e8574cb..68c93b4 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -237,9 +237,9 @@ def _code_contents(code): # The code contents depends on the number of local variables # but not their actual names. - contents.append("%s,%s" % (code.co_argcount, len(code.co_varnames))) + contents.append(str.encode("%s,%s" % (code.co_argcount, len(code.co_varnames)))) try: - contents.append(",%s,%s" % (len(code.co_cellvars), len(code.co_freevars))) + contents.append(str.encode(",%s,%s" % (len(code.co_cellvars), len(code.co_freevars)))) except AttributeError: # Older versions of Python do not support closures. contents.append(",0,0") @@ -252,19 +252,19 @@ def _code_contents(code): # Note that we also always ignore the first entry of co_consts # which contains the function doc string. We assume that the # function does not access its doc string. - contents.append(',(' + ','.join(map(_object_contents,code.co_consts[1:])) + ')') + contents.append(b',(' + b','.join(map(_object_contents,code.co_consts[1:])) + b')') # The code contents depends on the variable names used to # accessed global variable, as changing the variable name changes # the variable actually accessed and therefore changes the # function result. - contents.append(',(' + ','.join(map(_object_contents,code.co_names)) + ')') + contents.append(b',(' + b','.join(map(_object_contents,code.co_names)) + b')') # The code contents depends on its actual code!!! - contents.append(',(' + str(remove_set_lineno_codes(code.co_code)) + ')') + contents.append(b',(' + remove_set_lineno_codes(code.co_code) + b')') - return ''.join(contents) + return b''.join(contents) def _function_contents(func): @@ -274,9 +274,9 @@ def _function_contents(func): # The function contents depends on the value of defaults arguments if func.__defaults__: - contents.append(',(' + ','.join(map(_object_contents,func.__defaults__)) + ')') + contents.append(b',(' + b','.join(map(_object_contents,func.__defaults__)) + b')') else: - contents.append(',()') + contents.append(b',()') # The function contents depends on the closure captured cell values. try: @@ -290,9 +290,9 @@ def _function_contents(func): xxx = [_object_contents(x.cell_contents) for x in closure] except AttributeError: xxx = [] - contents.append(',(' + ','.join(xxx) + ')') + contents.append(b',(' + b','.join(xxx) + b')') - return ''.join(contents) + return b''.join(contents) def _actionAppend(act1, act2): @@ -434,14 +434,20 @@ class ActionBase(object): def get_contents(self, target, source, env): result = [ self.get_presig(target, source, env) ] + def clean (u): + if isinstance (u, bytes): + return u + elif isinstance (u, str): + return bytes (u, 'utf-8') + result = [ clean(r) for r in result ] # This should never happen, as the Action() factory should wrap # the varlist, but just in case an action is created directly, # we duplicate this check here. vl = self.get_varlist(target, source, env) if is_String(vl): vl = (vl,) for v in vl: - result.append(env.subst('${'+v+'}')) - return ''.join(result) + result.append(bytes(env.subst('${'+v+'}'), 'utf-8')) + return b''.join(result) def __add__(self, other): return _actionAppend(self, other) @@ -1135,7 +1141,7 @@ class ListAction(ActionBase): Simple concatenation of the signatures of the elements. """ - return "".join([x.get_contents(target, source, env) for x in self.list]) + return b"".join([x.get_contents(target, source, env) for x in self.list]) def __call__(self, target, source, env, exitstatfunc=_null, presub=_null, show=_null, execute=_null, chdir=_null, executor=None): diff --git a/src/engine/SCons/Conftest.py b/src/engine/SCons/Conftest.py index d466278..4e2a3e8 100644 --- a/src/engine/SCons/Conftest.py +++ b/src/engine/SCons/Conftest.py @@ -101,7 +101,6 @@ Autoconf-like configuration support; low level implementation of tests. # import re -from types import IntType # # PUBLIC VARIABLES diff --git a/src/engine/SCons/Errors.py b/src/engine/SCons/Errors.py index 3b8c3f9..54e888c 100644 --- a/src/engine/SCons/Errors.py +++ b/src/engine/SCons/Errors.py @@ -32,8 +32,6 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.Util -import exceptions - class BuildError(Exception): """ Errors occuring while building. @@ -163,7 +161,7 @@ def convert_to_BuildError(status, exc_info=None): status=2, exitstatus=2, exc_info=exc_info) - elif isinstance(status, exceptions.EnvironmentError): + elif isinstance(status, EnvironmentError): # If an IOError/OSError happens, raise a BuildError. # Report the name of the file or directory that caused the # error, which might be different from the target being built diff --git a/src/engine/SCons/Executor.py b/src/engine/SCons/Executor.py index 6f2489b..68419b8 100644 --- a/src/engine/SCons/Executor.py +++ b/src/engine/SCons/Executor.py @@ -427,7 +427,7 @@ class Executor(object): except KeyError: pass env = self.get_build_env() - result = "".join([action.get_contents(self.get_all_targets(), + result = b"".join([action.get_contents(self.get_all_targets(), self.get_all_sources(), env) for action in self.get_action_list()]) diff --git a/src/engine/SCons/SConf.py b/src/engine/SCons/SConf.py index 987f88d..e14c5e0 100644 --- a/src/engine/SCons/SConf.py +++ b/src/engine/SCons/SConf.py @@ -175,13 +175,19 @@ class Streamer(object): """ def __init__(self, orig): self.orig = orig - self.s = io.StringIO() + try: + import StringIO + self.s = StringIO.StringIO() + except: + self.s = io.StringIO() def write(self, str): - if self.orig: - self.orig.write(str) - self.s.write(str) - + try: + if self.orig: + self.orig.write(str) + self.s.write(str) + except: + print ('oops') def writelines(self, lines): for l in lines: self.write(l + '\n') diff --git a/src/engine/SCons/Scanner/__init__.py b/src/engine/SCons/Scanner/__init__.py index 6ec8df9..8801094 100644 --- a/src/engine/SCons/Scanner/__init__.py +++ b/src/engine/SCons/Scanner/__init__.py @@ -325,7 +325,7 @@ class Classic(Current): def __init__(self, name, suffixes, path_variable, regex, *args, **kw): - self.cre = re.compile(regex, re.M) + self.cre = re.compile(SCons.Util.to_bytes(regex), re.M) def _scan(node, env, path=(), self=self): node = node.rfile() diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py index fefffef..05cb6a6 100644 --- a/src/engine/SCons/Script/SConscript.py +++ b/src/engine/SCons/Script/SConscript.py @@ -257,7 +257,7 @@ def _SConscript(fs, *files, **kw): pass try: try: - exec(_file_, call_stack[-1].globals) + exec(_file_.read(), call_stack[-1].globals) except SConscriptReturn: pass finally: diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py index 9f2837c..e9e8b71 100644 --- a/src/engine/SCons/Script/__init__.py +++ b/src/engine/SCons/Script/__init__.py @@ -364,7 +364,7 @@ GlobalDefaultBuilders = [ ] for name in GlobalDefaultEnvironmentFunctions + GlobalDefaultBuilders: - exec("%s = _SConscript.DefaultEnvironmentCall(%s)" % (name, repr(name))) + exec ("%s = _SConscript.DefaultEnvironmentCall(%s)" % (name, repr(name))) del name # There are a handful of variables that used to live in the diff --git a/src/engine/SCons/Taskmaster.py b/src/engine/SCons/Taskmaster.py index 54d04a8..14ffe8c 100644 --- a/src/engine/SCons/Taskmaster.py +++ b/src/engine/SCons/Taskmaster.py @@ -518,13 +518,9 @@ class Task(object): Raises a pending exception that was recorded while getting a Task ready for execution. """ - exc = self.exc_info()[:] - try: - exc_type, exc_value, exc_traceback = exc - except ValueError: - exc_type, exc_value = exc - exc_traceback = None - raise exc_type(exc_value).with_traceback(exc_traceback) + + import six + six.reraise(*self.exc_info()) class AlwaysTask(Task): def needs_execute(self): diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index ac180a9..1d5b504 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -114,7 +114,7 @@ class Tool(object): if file: file.close() except ImportError as e: - if str(e)!="No module named %s"%self.name: + if not str(e).startswith ("No module"): raise SCons.Errors.EnvironmentError(e) try: import zipimport @@ -144,7 +144,7 @@ class Tool(object): file.close() return module except ImportError as e: - if str(e)!="No module named %s"%self.name: + if not str(e).startswith("No module"): raise SCons.Errors.EnvironmentError(e) try: import zipimport diff --git a/src/engine/SCons/Tool/g++.py b/src/engine/SCons/Tool/g++.py index e4da5fe..0e1c181 100644 --- a/src/engine/SCons/Tool/g++.py +++ b/src/engine/SCons/Tool/g++.py @@ -40,8 +40,7 @@ import subprocess import SCons.Tool import SCons.Util -cplusplus = __import__('c++', globals(), locals(), []) - +cplusplus = __import__(__package__+'.c++', globals(), locals(), ['*']) compilers = ['g++'] def generate(env): @@ -75,7 +74,7 @@ def generate(env): #line = pipe.stdout.read().strip() #if line: # env['CXXVERSION'] = line - line = pipe.stdout.readline() + line = SCons.Util.to_str (pipe.stdout.readline()) match = re.search(r'[0-9]+(\.[0-9]+)+', line) if match: env['CXXVERSION'] = match.group(0) diff --git a/src/engine/SCons/Tool/gas.py b/src/engine/SCons/Tool/gas.py index 28f84db..d01bd60 100644 --- a/src/engine/SCons/Tool/gas.py +++ b/src/engine/SCons/Tool/gas.py @@ -33,7 +33,10 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -as_module = __import__('as', globals(), locals(), []) +try: + as_module = __import__('as', globals(), locals(), []) +except: + as_module = __import__(__package__+'.as', globals(), locals(), ['*']) assemblers = ['as', 'gas'] diff --git a/src/engine/SCons/Tool/gcc.py b/src/engine/SCons/Tool/gcc.py index 4f87b24..72f9bfd 100644 --- a/src/engine/SCons/Tool/gcc.py +++ b/src/engine/SCons/Tool/gcc.py @@ -65,7 +65,7 @@ def generate(env): #line = pipe.stdout.read().strip() #if line: # env['CCVERSION'] = line - line = pipe.stdout.readline() + line = SCons.Util.to_str (pipe.stdout.readline()) match = re.search(r'[0-9]+(\.[0-9]+)+', line) if match: env['CCVERSION'] = match.group(0) diff --git a/src/engine/SCons/Tool/link.py b/src/engine/SCons/Tool/link.py index 5539f62..864a018 100644 --- a/src/engine/SCons/Tool/link.py +++ b/src/engine/SCons/Tool/link.py @@ -42,7 +42,7 @@ import SCons.Warnings from SCons.Tool.FortranCommon import isfortran -cplusplus = __import__('c++', globals(), locals(), []) +cplusplus = __import__(__package__+'.c++', globals(), locals(), ['*']) issued_mixed_link_warning = False diff --git a/src/engine/SCons/Tool/swig.py b/src/engine/SCons/Tool/swig.py index d51a386..5d2264c 100644 --- a/src/engine/SCons/Tool/swig.py +++ b/src/engine/SCons/Tool/swig.py @@ -131,7 +131,7 @@ def _get_swig_version(env): stdout = subprocess.PIPE) if pipe.wait() != 0: return - out = pipe.stdout.read() + out = SCons.Util.to_str (pipe.stdout.read()) match = re.search(r'SWIG Version\s+(\S+)$', out, re.MULTILINE) if match: return match.group(1) diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index f2e5325..00fde6c 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -37,7 +37,6 @@ import collections # Don't "from types import ..." these because we need to get at the # types module later to look for UnicodeType. -InstanceType = types.InstanceType MethodType = types.MethodType FunctionType = types.FunctionType try: str @@ -1370,7 +1369,7 @@ def AddMethod(obj, function, name=None): setattr(obj, name, MethodType(function, obj, obj.__class__)) else: # "obj" is a class, so it gets an unbound method. - setattr(obj, name, MethodType(function, None, obj)) + setattr(obj, name, function) def RenameFunction(function, name): """ @@ -1402,7 +1401,7 @@ else: md5 = True def MD5signature(s): m = hashlib.md5() - m.update(str(s)) + m.update(to_bytes(str(s))) return m.hexdigest() def MD5filesignature(fname, chunksize=65536): @@ -1412,7 +1411,7 @@ else: blck = f.read(chunksize) if not blck: break - m.update(str(blck)) + m.update(to_bytes (str(blck))) f.close() return m.hexdigest() @@ -1486,6 +1485,18 @@ class NullSeq(Null): del __revision__ +def to_bytes (s): + if bytes is str: + return s + else: + return bytes (s, 'utf-8') + +def to_str (s): + if bytes is str: + return s + else: + return str (s, 'utf-8') + # Local Variables: # tab-width:4 # indent-tabs-mode:nil diff --git a/src/engine/SCons/dblite.py b/src/engine/SCons/dblite.py index 89b9856..99af54a 100644 --- a/src/engine/SCons/dblite.py +++ b/src/engine/SCons/dblite.py @@ -16,14 +16,10 @@ ignore_corrupt_dbfiles = 0 def corruption_warning(filename): print("Warning: Discarding corrupt database:", filename) -try: str -except NameError: - def is_string(s): - return isinstance(s, str) -else: - def is_string(s): - return type(s) in (str, str) - +def is_string(s): + return isinstance(s, str) +def is_bytes(s): + return isinstance (s, bytes) try: str('a') except NameError: @@ -148,8 +144,8 @@ class dblite(object): self._check_writable() if (not is_string(key)): raise TypeError("key `%s' must be a string but is %s" % (key, type(key))) - if (not is_string(value)): - raise TypeError("value `%s' must be a string but is %s" % (value, type(value))) + if (not is_bytes(value)): + raise TypeError("value `%s' must be a bytes but is %s" % (value, type(value))) self._dict[key] = value self._needs_sync = 0o001 diff --git a/src/script/scons.py b/src/script/scons.py index 46e6d2b..89eef34 100644 --- a/src/script/scons.py +++ b/src/script/scons.py @@ -55,11 +55,11 @@ import sys # engine modules if they're in either directory. -if sys.version_info >= (3,0,0): - msg = "scons: *** SCons version %s does not run under Python version %s.\n\ -Python 3 is not yet supported.\n" - sys.stderr.write(msg % (__version__, sys.version.split()[0])) - sys.exit(1) +## if sys.version_info >= (3,0,0): +## msg = "scons: *** SCons version %s does not run under Python version %s.\n\ +## Python 3 is not yet supported.\n" +## sys.stderr.write(msg % (__version__, sys.version.split()[0])) +## sys.exit(1) script_dir = sys.path[0] -- cgit v0.12 From 0727ee61d6ec6eeb099b0d179fa77a1a86046ee8 Mon Sep 17 00:00:00 2001 From: ndbecker2 Date: Mon, 9 Sep 2013 10:14:53 -0400 Subject: 2 minor issues (transplanted from 6711a6b819f61764bb82c0f32a251b91ec66a0b2) --- QMTest/TestCmd.py | 3 ++- src/engine/SCons/Action.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index 4f08d1f..26401ad 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -1,3 +1,4 @@ +from __future__ import print_function """ TestCmd.py: a testing framework for commands and scripts. @@ -950,7 +951,7 @@ class TestCmd(object): condition = self.condition if self._preserve[condition]: for dir in self._dirlist: - print(str("Preserved directory " + dir + "\n"), end=' ') + print("Preserved directory " + dir + "\n", end=' ') else: list = self._dirlist[:] list.reverse() diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index 68c93b4..7a97dae 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -446,7 +446,7 @@ class ActionBase(object): vl = self.get_varlist(target, source, env) if is_String(vl): vl = (vl,) for v in vl: - result.append(bytes(env.subst('${'+v+'}'), 'utf-8')) + result.append(SCons.Util.to_bytes(env.subst('${'+v+'}'))) return b''.join(result) def __add__(self, other): -- cgit v0.12 From 8473d8293b056663f8a3caf04550039b18690a70 Mon Sep 17 00:00:00 2001 From: ndbecker2 Date: Mon, 9 Sep 2013 10:39:46 -0400 Subject: minor cleanup (transplanted from 4feb1b15eb7a0c76cb020e09817c509a782d45b7) --- src/engine/SCons/Action.py | 7 +------ src/engine/SCons/Util.py | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index 7a97dae..66757a4 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -434,12 +434,7 @@ class ActionBase(object): def get_contents(self, target, source, env): result = [ self.get_presig(target, source, env) ] - def clean (u): - if isinstance (u, bytes): - return u - elif isinstance (u, str): - return bytes (u, 'utf-8') - result = [ clean(r) for r in result ] + result = [ SCons.Util.to_bytes(r) for r in result ] # This should never happen, as the Action() factory should wrap # the varlist, but just in case an action is created directly, # we duplicate this check here. diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 00fde6c..0c4daff 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -1486,7 +1486,7 @@ class NullSeq(Null): del __revision__ def to_bytes (s): - if bytes is str: + if isinstance (s, bytes) or bytes is str: return s else: return bytes (s, 'utf-8') -- cgit v0.12 From 7dd07e75f428379c90eb9bb486b79ad103283bf6 Mon Sep 17 00:00:00 2001 From: ndbecker2 Date: Mon, 9 Sep 2013 12:03:44 -0400 Subject: fix for cpp scanner (maybe) (transplanted from c68b1a5da5ad47befc3a7e802d8ae23372f0e1a8) --- src/engine/SCons/Scanner/__init__.py | 3 ++- src/engine/SCons/dblite.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/engine/SCons/Scanner/__init__.py b/src/engine/SCons/Scanner/__init__.py index 8801094..b947961 100644 --- a/src/engine/SCons/Scanner/__init__.py +++ b/src/engine/SCons/Scanner/__init__.py @@ -394,6 +394,7 @@ class ClassicCPP(Classic): the contained filename in group 1. """ def find_include(self, include, source_dir, path): + include = list (map (SCons.Util.to_str, include)) if include[0] == '"': paths = (source_dir,) + tuple(path) else: @@ -405,7 +406,7 @@ class ClassicCPP(Classic): return n, i def sort_key(self, include): - return SCons.Node.FS._my_normcase(' '.join(include)) + return SCons.Node.FS._my_normcase(b' '.join(include)) # Local Variables: # tab-width:4 diff --git a/src/engine/SCons/dblite.py b/src/engine/SCons/dblite.py index 99af54a..4b02239 100644 --- a/src/engine/SCons/dblite.py +++ b/src/engine/SCons/dblite.py @@ -26,6 +26,8 @@ except NameError: def str(s): return s dblite_suffix = '.dblite' +if bytes is not str: + dblite_suffix += '.p3' tmp_suffix = '.tmp' class dblite(object): @@ -238,7 +240,6 @@ def _exercise(): assert str(e) == "[Errno 2] No such file or directory: 'tmp.dblite'", str(e) else: raise RuntimeError("IOError expected.") - print("OK") if (__name__ == "__main__"): _exercise() -- cgit v0.12 From 9f36c5b899b8d2d54cae8d3da76b01308c144ed6 Mon Sep 17 00:00:00 2001 From: ndbecker2 Date: Tue, 10 Sep 2013 10:02:23 -0400 Subject: setup.py: don't error on py3 (transplanted from 16fc64cadd68f2f9032c14d04bc0bf94f99b71a4) --- src/setup.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/setup.py b/src/setup.py index a8b59a3..2c75c60 100644 --- a/src/setup.py +++ b/src/setup.py @@ -46,14 +46,6 @@ man_pages = [ 'scons-time.1', ] -# Exit with error if trying to install with Python >= 3.0 -if sys.version_info >= (3,0,0): - msg = "scons: *** SCons does not run under Python version %s.\n\ -Python 3 and above are not yet supported.\n" - sys.stderr.write(msg % (sys.version.split()[0])) - sys.exit(1) - - # change to setup.py directory if it was executed from other dir (head, tail) = os.path.split(sys.argv[0]) if head: -- cgit v0.12 From 1a1a11122ad28df19d305af879ba79a2b08ce7d4 Mon Sep 17 00:00:00 2001 From: Stefan Zimmermann Date: Mon, 31 Mar 2014 15:13:02 +0000 Subject: Made former 2to3 changes Python 2.7 compatible (or removed unneeded changes). --- QMTest/TestCmd.py | 7 +- QMTest/TestCmdTests.py | 109 ++++++++-------- QMTest/TestCommon.py | 1 + QMTest/TestSCons.py | 12 +- QMTest/TestSConsign.py | 1 + QMTest/scons_tdb.py | 4 +- SConstruct | 15 +-- bench/bench.py | 4 +- bench/env.__setitem__.py | 4 +- bench/is_types.py | 12 +- bench/timeit.py | 4 +- bin/Command.py | 1 + bin/SConsDoc.py | 9 +- bin/calibrate.py | 2 +- bin/caller-tree.py | 3 +- bin/docs-create-example-outputs.py | 1 + bin/docs-update-generated.py | 1 + bin/docs-validate.py | 1 + bin/install_python.py | 1 + bin/install_scons.py | 8 +- bin/linecount.py | 2 +- bin/memlogs.py | 1 + bin/memoicmp.py | 9 +- bin/objcounts.py | 5 +- bin/scons-diff.py | 5 +- bin/scons-proc.py | 4 +- bin/scons-test.py | 5 +- bin/scons-unzip.py | 1 + bin/scons_dev_master.py | 1 + bin/sfsum | 11 +- bin/svn-bisect.py | 2 +- bin/update-release-info.py | 3 +- bin/xmlagenda.py | 1 + doc/SConscript | 25 ++-- review.py | 139 ++++++++++++--------- runtest.py | 8 +- src/engine/SCons/Action.py | 19 ++- src/engine/SCons/ActionTests.py | 8 +- src/engine/SCons/Builder.py | 21 ++-- src/engine/SCons/BuilderTests.py | 9 +- src/engine/SCons/Conftest.py | 2 +- src/engine/SCons/Debug.py | 4 +- src/engine/SCons/Defaults.py | 7 +- src/engine/SCons/Environment.py | 33 +++-- src/engine/SCons/EnvironmentTests.py | 17 +-- src/engine/SCons/Executor.py | 4 +- src/engine/SCons/Memoize.py | 1 + src/engine/SCons/MemoizeTests.py | 5 +- src/engine/SCons/Node/FS.py | 10 +- src/engine/SCons/Node/FSTests.py | 4 +- src/engine/SCons/Node/__init__.py | 4 +- src/engine/SCons/Platform/__init__.py | 1 + src/engine/SCons/Platform/posix.py | 2 +- src/engine/SCons/SConf.py | 21 ++-- src/engine/SCons/SConfTests.py | 2 +- src/engine/SCons/SConsign.py | 9 +- src/engine/SCons/Scanner/Fortran.py | 3 +- src/engine/SCons/Scanner/LaTeX.py | 4 +- src/engine/SCons/Scanner/Prog.py | 3 +- src/engine/SCons/Scanner/ProgTests.py | 2 +- src/engine/SCons/Scanner/ScannerTests.py | 2 +- src/engine/SCons/Scanner/__init__.py | 5 +- src/engine/SCons/Script/Interactive.py | 5 +- src/engine/SCons/Script/Main.py | 7 +- src/engine/SCons/Script/SConsOptions.py | 2 +- src/engine/SCons/Script/SConscript.py | 4 +- src/engine/SCons/Subst.py | 4 +- src/engine/SCons/SubstTests.py | 1 + src/engine/SCons/Taskmaster.py | 29 ++--- src/engine/SCons/TaskmasterTests.py | 2 +- src/engine/SCons/Tool/FortranCommon.py | 5 +- src/engine/SCons/Tool/MSCommon/common.py | 5 +- src/engine/SCons/Tool/MSCommon/vc.py | 2 +- src/engine/SCons/Tool/MSCommon/vs.py | 2 +- src/engine/SCons/Tool/__init__.py | 3 +- .../docbook-xsl-1.76.1/extensions/docbook.py | 1 + .../docbook/docbook-xsl-1.76.1/extensions/xslt.py | 1 + src/engine/SCons/Tool/install.py | 1 + src/engine/SCons/Tool/intelc.py | 6 +- src/engine/SCons/Tool/link.py | 1 + src/engine/SCons/Tool/mslink.py | 3 +- src/engine/SCons/Tool/msvs.py | 17 +-- src/engine/SCons/Tool/msvsTests.py | 1 + src/engine/SCons/Tool/packaging/__init__.py | 2 +- src/engine/SCons/Tool/packaging/ipk.py | 2 +- src/engine/SCons/Tool/packaging/msi.py | 6 +- src/engine/SCons/Tool/packaging/rpm.py | 4 +- src/engine/SCons/Tool/qt.py | 1 + src/engine/SCons/Tool/rpmutils.py | 1 + src/engine/SCons/Tool/tex.py | 1 + src/engine/SCons/Tool/textfile.py | 3 +- src/engine/SCons/Tool/xgettext.py | 3 +- src/engine/SCons/Util.py | 61 ++++++--- src/engine/SCons/UtilTests.py | 17 +-- src/engine/SCons/Variables/EnumVariableTests.py | 4 +- src/engine/SCons/Variables/__init__.py | 2 +- src/engine/SCons/compat/_scons_subprocess.py | 12 +- src/engine/SCons/cpp.py | 11 +- src/engine/SCons/cppTests.py | 2 +- src/engine/SCons/dblite.py | 26 ++-- src/script/scons-time.py | 12 +- src/script/sconsign.py | 10 +- src/test_files.py | 3 +- src/test_interrupts.py | 2 +- src/test_pychecker.py | 1 + src/test_setup.py | 1 + src/test_strings.py | 1 + test/AS/nasm.py | 2 +- test/Actions/unicode-signature.py | 12 +- test/AddOption/help.py | 1 + test/Configure/ConfigureDryRunError.py | 1 + test/Configure/config-h.py | 1 + test/Configure/implicit-cache.py | 1 + test/Deprecated/SourceCode/BitKeeper/BitKeeper.py | 1 + test/Deprecated/SourceCode/Subversion.py | 1 + test/GetBuildFailures/parallel.py | 1 + test/Glob/glob-libpath.py | 1 + test/Interactive/version.py | 1 + test/Java/multi-step.py | 1 + test/MSVC/msvc.py | 1 + test/QT/QTFLAGS.py | 2 +- test/QT/copied-env.py | 1 + test/QT/warnings.py | 1 + test/Scanner/unicode.py | 20 +-- test/TEX/TEX.py | 1 + test/Value.py | 1 + test/Win32/bad-drive.py | 1 + test/Win32/default-drive.py | 1 + test/gnutools.py | 1 + test/import.py | 1 + test/option--random.py | 1 + test/option-v.py | 1 + test/option/debug-count.py | 1 + test/option/debug-time.py | 2 +- test/option/help-options.py | 1 + test/option/profile.py | 4 +- test/site_scons/sysdirs.py | 1 + test/update-release-info/update-release-info.py | 2 +- timings/ElectricCloud/TimeSCons-run.py | 1 + www/gen_sched_table.py | 1 + 140 files changed, 566 insertions(+), 418 deletions(-) diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index 26401ad..488d940 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -1,4 +1,3 @@ -from __future__ import print_function """ TestCmd.py: a testing framework for commands and scripts. @@ -286,7 +285,7 @@ version. # PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, # AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - +from __future__ import division, print_function __author__ = "Steven Knight " __revision__ = "TestCmd.py 1.3.D001 2010/06/03 12:58:27 knight" @@ -356,7 +355,7 @@ except NameError: return isinstance(e, (str, UserString)) else: def is_String(e): - return isinstance(e, (str, UserString)) + return isinstance(e, (str, unicode, UserString)) tempfile.template = 'testcmd.' if os.name in ('posix', 'nt'): @@ -951,7 +950,7 @@ class TestCmd(object): condition = self.condition if self._preserve[condition]: for dir in self._dirlist: - print("Preserved directory " + dir + "\n", end=' ') + print("Preserved directory " + dir + "\n") else: list = self._dirlist[:] list.reverse() diff --git a/QMTest/TestCmdTests.py b/QMTest/TestCmdTests.py index 96e0cbf..6611590 100644 --- a/QMTest/TestCmdTests.py +++ b/QMTest/TestCmdTests.py @@ -19,6 +19,8 @@ AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. """ +from six import PY3 + __author__ = "Steven Knight " __revision__ = "TestCmdTests.py 1.3.D001 2010/06/03 12:58:27 knight" @@ -26,13 +28,20 @@ import os import shutil import signal import stat -import io +if PY3: + from io import StringIO +else: + from StringIO import StringIO import sys import tempfile import time import types import unittest -import collections +if PY3: + from collections import UserList +else: + from UserList import UserList + # Strip the current directory so we get the right TestCmd.py module. sys.path = sys.path[1:] @@ -1032,14 +1041,14 @@ class match_exact_TestCase(TestCmdTestCase): assert test.match_exact("abcde\n", "abcde\n") assert not test.match_exact(["12345\n", "abcde\n"], ["1[0-9]*5\n", "a.*e\n"]) assert test.match_exact(["12345\n", "abcde\n"], ["12345\n", "abcde\n"]) - assert not test.match_exact(collections.UserList(["12345\n", "abcde\n"]), + assert not test.match_exact(UserList(["12345\n", "abcde\n"]), ["1[0-9]*5\n", "a.*e\n"]) - assert test.match_exact(collections.UserList(["12345\n", "abcde\n"]), + assert test.match_exact(UserList(["12345\n", "abcde\n"]), ["12345\n", "abcde\n"]) assert not test.match_exact(["12345\n", "abcde\n"], - collections.UserList(["1[0-9]*5\n", "a.*e\n"])) + UserList(["1[0-9]*5\n", "a.*e\n"])) assert test.match_exact(["12345\n", "abcde\n"], - collections.UserList(["12345\n", "abcde\n"])) + UserList(["12345\n", "abcde\n"])) assert not test.match_exact("12345\nabcde\n", "1[0-9]*5\na.*e\n") assert test.match_exact("12345\nabcde\n", "12345\nabcde\n") lines = ["vwxyz\n", "67890\n"] @@ -1098,28 +1107,28 @@ sys.exit(0) ["1.*j\n"]) assert test.match_re_dotall(["12345\n", "abcde\n", "fghij\n"], ["12345\n", "abcde\n", "fghij\n"]) - assert test.match_re_dotall(collections.UserList(["12345\n", - "abcde\n", - "fghij\n"]), + assert test.match_re_dotall(UserList(["12345\n", + "abcde\n", + "fghij\n"]), ["1[0-9]*5\n", "a.*e\n", "f.*j\n"]) - assert test.match_re_dotall(collections.UserList(["12345\n", - "abcde\n", - "fghij\n"]), + assert test.match_re_dotall(UserList(["12345\n", + "abcde\n", + "fghij\n"]), ["1.*j\n"]) - assert test.match_re_dotall(collections.UserList(["12345\n", - "abcde\n", - "fghij\n"]), + assert test.match_re_dotall(UserList(["12345\n", + "abcde\n", + "fghij\n"]), ["12345\n", "abcde\n", "fghij\n"]) assert test.match_re_dotall(["12345\n", "abcde\n", "fghij\n"], - collections.UserList(["1[0-9]*5\n", - "a.*e\n", - "f.*j\n"])) + UserList(["1[0-9]*5\n", + "a.*e\n", + "f.*j\n"])) assert test.match_re_dotall(["12345\n", "abcde\n", "fghij\n"], - collections.UserList(["1.*j\n"])) + UserList(["1.*j\n"])) assert test.match_re_dotall(["12345\n", "abcde\n", "fghij\n"], - collections.UserList(["12345\n", - "abcde\n", - "fghij\n"])) + UserList(["12345\n", + "abcde\n", + "fghij\n"])) assert test.match_re_dotall("12345\nabcde\nfghij\n", "1[0-9]*5\na.*e\nf.*j\n") assert test.match_re_dotall("12345\nabcde\nfghij\n", "1.*j\n") @@ -1176,14 +1185,14 @@ sys.exit(0) assert test.match_re("abcde\n", "abcde\n") assert test.match_re(["12345\n", "abcde\n"], ["1[0-9]*5\n", "a.*e\n"]) assert test.match_re(["12345\n", "abcde\n"], ["12345\n", "abcde\n"]) - assert test.match_re(collections.UserList(["12345\n", "abcde\n"]), + assert test.match_re(UserList(["12345\n", "abcde\n"]), ["1[0-9]*5\n", "a.*e\n"]) - assert test.match_re(collections.UserList(["12345\n", "abcde\n"]), + assert test.match_re(UserList(["12345\n", "abcde\n"]), ["12345\n", "abcde\n"]) assert test.match_re(["12345\n", "abcde\n"], - collections.UserList(["1[0-9]*5\n", "a.*e\n"])) + UserList(["1[0-9]*5\n", "a.*e\n"])) assert test.match_re(["12345\n", "abcde\n"], - collections.UserList(["12345\n", "abcde\n"])) + UserList(["12345\n", "abcde\n"])) assert test.match_re("12345\nabcde\n", "1[0-9]*5\na.*e\n") assert test.match_re("12345\nabcde\n", "12345\nabcde\n") lines = ["vwxyz\n", "67890\n"] @@ -1463,7 +1472,7 @@ class preserve_TestCase(TestCmdTestCase): def test_preserve(self): """Test preserve()""" def cleanup_test(test, cond=None, stdout=""): - io = io.StringIO() + io = StringIO() save = sys.stdout sys.stdout = io try: @@ -1603,7 +1612,7 @@ class read_TestCase(TestCmdTestCase): _file_matches(wdir_foo_file3, test.read(['foo', 'file3']), "Test\nfile\n#3.\n") _file_matches(wdir_foo_file3, - test.read(collections.UserList(['foo', 'file3'])), + test.read(UserList(['foo', 'file3'])), "Test\nfile\n#3.\n") _file_matches(wdir_file4, test.read('file4', mode = 'r'), "Test\nfile\n#4.\n") @@ -1862,8 +1871,8 @@ class run_verbose_TestCase(TestCmdTestCase): workdir = '', verbose = 1) - sys.stdout = io.StringIO() - sys.stderr = io.StringIO() + sys.stdout = StringIO() + sys.stderr = StringIO() test.run(arguments = ['arg1 arg2']) o = sys.stdout.getvalue() @@ -1876,8 +1885,8 @@ class run_verbose_TestCase(TestCmdTestCase): workdir = '', verbose = 1) - sys.stdout = io.StringIO() - sys.stderr = io.StringIO() + sys.stdout = StringIO() + sys.stderr = StringIO() testx.run(arguments = ['arg1 arg2']) expect = '"%s" "arg1 arg2"\n' % t.scriptx_path @@ -1913,8 +1922,8 @@ class run_verbose_TestCase(TestCmdTestCase): workdir = '', verbose = 2) - sys.stdout = io.StringIO() - sys.stderr = io.StringIO() + sys.stdout = StringIO() + sys.stderr = StringIO() test.run(arguments = ['arg1 arg2']) @@ -1934,8 +1943,8 @@ class run_verbose_TestCase(TestCmdTestCase): workdir = '', verbose = 2) - sys.stdout = io.StringIO() - sys.stderr = io.StringIO() + sys.stdout = StringIO() + sys.stderr = StringIO() testx.run(arguments = ['arg1 arg2']) @@ -1958,8 +1967,8 @@ class run_verbose_TestCase(TestCmdTestCase): workdir = '', verbose = 2) - sys.stdout = io.StringIO() - sys.stderr = io.StringIO() + sys.stdout = StringIO() + sys.stderr = StringIO() test.run(arguments = ['arg1 arg2']) @@ -1978,8 +1987,8 @@ class run_verbose_TestCase(TestCmdTestCase): workdir = '', verbose = 3) - sys.stdout = io.StringIO() - sys.stderr = io.StringIO() + sys.stdout = StringIO() + sys.stderr = StringIO() test.run(arguments = ['arg1 arg2']) @@ -2002,8 +2011,8 @@ class run_verbose_TestCase(TestCmdTestCase): interpreter = 'python', workdir = '') - sys.stdout = io.StringIO() - sys.stderr = io.StringIO() + sys.stdout = StringIO() + sys.stderr = StringIO() test.run(arguments = ['arg1 arg2']) @@ -2022,8 +2031,8 @@ class run_verbose_TestCase(TestCmdTestCase): testx = TestCmd.TestCmd(program = t.scriptx, workdir = '') - sys.stdout = io.StringIO() - sys.stderr = io.StringIO() + sys.stdout = StringIO() + sys.stderr = StringIO() testx.run(arguments = ['arg1 arg2']) @@ -2048,8 +2057,8 @@ class run_verbose_TestCase(TestCmdTestCase): workdir = '', verbose = 1) - sys.stdout = io.StringIO() - sys.stderr = io.StringIO() + sys.stdout = StringIO() + sys.stderr = StringIO() test.run(arguments = ['arg1 arg2']) o = sys.stdout.getvalue() @@ -2062,8 +2071,8 @@ class run_verbose_TestCase(TestCmdTestCase): workdir = '', verbose = 1) - sys.stdout = io.StringIO() - sys.stderr = io.StringIO() + sys.stdout = StringIO() + sys.stderr = StringIO() testx.run(arguments = ['arg1 arg2']) expect = '"%s" "arg1 arg2"\n' % t.scriptx_path @@ -2769,7 +2778,7 @@ class subdir_TestCase(TestCmdTestCase): assert test.subdir(['foo', 'fail']) == 0 assert test.subdir(['sub', 'dir', 'ectory'], 'sub') == 1 assert test.subdir('one', - collections.UserList(['one', 'two']), + UserList(['one', 'two']), ['one', 'two', 'three']) == 3 assert os.path.isdir(test.workpath('foo')) assert os.path.isdir(test.workpath('bar')) @@ -2962,7 +2971,7 @@ class unlink_TestCase(TestCmdTestCase): test.unlink(['foo', 'file3a']) assert not os.path.exists(wdir_foo_file3a) - test.unlink(collections.UserList(['foo', 'file3b'])) + test.unlink(UserList(['foo', 'file3b'])) assert not os.path.exists(wdir_foo_file3b) test.unlink([test.workdir, 'foo', 'file4']) diff --git a/QMTest/TestCommon.py b/QMTest/TestCommon.py index 5a397ff..f1a7407 100644 --- a/QMTest/TestCommon.py +++ b/QMTest/TestCommon.py @@ -90,6 +90,7 @@ The TestCommon module also provides the following variables # PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, # AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. +from __future__ import print_function __author__ = "Steven Knight " __revision__ = "TestCommon.py 1.3.D001 2010/06/03 12:58:27 knight" diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index 72624e6..5d0b4c6 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -13,7 +13,7 @@ attributes defined in this subclass. """ # __COPYRIGHT__ - +from __future__ import division, print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -721,7 +721,7 @@ class TestSCons(TestCommon): home = os.path.normpath('%s/..'%jar) if os.path.isdir(home): return home - print(("Could not determine JAVA_HOME: %s is not a directory" % home)) + print("Could not determine JAVA_HOME: %s is not a directory" % home) self.fail_test() def java_where_jar(self, version=None): @@ -1013,7 +1013,7 @@ SConscript( sconscript ) raise NoMatch(lastEnd) return m.end() + lastEnd try: - #print len(os.linesep) + #print(len(os.linesep)) ls = os.linesep nols = "(" for i in range(len(ls)): @@ -1241,7 +1241,7 @@ class TimeSCons(TestSCons): self.variables = kw.get('variables') default_calibrate_variables = [] if self.variables is not None: - for variable, value in list(self.variables.items()): + for variable, value in self.variables.items(): value = os.environ.get(variable, value) try: value = int(value) @@ -1297,7 +1297,7 @@ class TimeSCons(TestSCons): """ if 'options' not in kw and self.variables: options = [] - for variable, value in list(self.variables.items()): + for variable, value in self.variables.items(): options.append('%s=%s' % (variable, value)) kw['options'] = ' '.join(options) if self.calibrate: @@ -1323,7 +1323,7 @@ class TimeSCons(TestSCons): self.elapsed_time(), "seconds", sort=0) - for name, args in list(stats.items()): + for name, args in stats.items(): self.trace(name, trace, **args) def uptime(self): diff --git a/QMTest/TestSConsign.py b/QMTest/TestSConsign.py index 665059c..a48b648 100644 --- a/QMTest/TestSConsign.py +++ b/QMTest/TestSConsign.py @@ -1,4 +1,5 @@ # __COPYRIGHT__ +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/QMTest/scons_tdb.py b/QMTest/scons_tdb.py index 845e99c..76c7fe1 100644 --- a/QMTest/scons_tdb.py +++ b/QMTest/scons_tdb.py @@ -20,7 +20,7 @@ # 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. - +from __future__ import division, print_function """ QMTest classes to support SCons' testing and Aegis-inspired workflow. @@ -92,7 +92,7 @@ def get_explicit_arguments(e): # Determine which subset of the 'arguments' have been set # explicitly. explicit_arguments = {} - for name, field in list(arguments.items()): + for name, field in arguments.items(): # Do not record computed fields. if field.IsComputed(): continue diff --git a/SConstruct b/SConstruct index f289947..1a0aef0 100644 --- a/SConstruct +++ b/SConstruct @@ -2,6 +2,7 @@ # SConstruct file to build scons packages during development. # # See the README.rst file for an overview of how SCons is built and tested. +from __future__ import print_function # When this gets changed, you must also change the copyright_years string # in QMTest/TestSCons.py so the test scripts look for the right string. @@ -327,7 +328,7 @@ try: import zipfile def zipit(env, target, source): - print "Zipping %s:" % str(target[0]) + print("Zipping %s:" % str(target[0])) def visit(arg, dirname, names): for name in names: path = os.path.join(dirname, name) @@ -341,7 +342,7 @@ try: zf.close() def unzipit(env, target, source): - print "Unzipping %s:" % str(source[0]) + print("Unzipping %s:" % str(source[0])) zf = zipfile.ZipFile(str(source[0]), 'r') for name in zf.namelist(): dest = os.path.join(env['UNPACK_ZIP_DIR'], name) @@ -350,7 +351,7 @@ try: os.makedirs(dir) except: pass - print dest,name + print(dest,name) # if the file exists, then delete it before writing # to it so that we don't end up trying to write to a symlink: if os.path.isfile(dest) or os.path.islink(dest): @@ -558,7 +559,7 @@ else: i = install_egg_info(dist) i.finalize_options() import os.path - print os.path.split(i.outputs[0])[1] + print(os.path.split(i.outputs[0])[1]) """ % version try: @@ -853,7 +854,7 @@ for p in [ scons ]: AddPostAction(dist_distutils_targets, Chmod(dist_distutils_targets, 0644)) if not gzip: - print "gzip not found in %s; skipping .tar.gz package for %s." % (os.environ['PATH'], pkg) + print("gzip not found in %s; skipping .tar.gz package for %s." % (os.environ['PATH'], pkg)) else: distutils_formats.append('gztar') @@ -928,7 +929,7 @@ for p in [ scons ]: env.Command(digest, tar_gz, Digestify) if not zipit: - print "zip not found; skipping .zip package for %s." % pkg + print("zip not found; skipping .zip package for %s." % pkg) else: distutils_formats.append('zip') @@ -1211,7 +1212,7 @@ elif svn_status_lines: sentries = [l.split()[-1] for l in slines] sfiles = list(filter(os.path.isfile, sentries)) else: - print "Not building in a Mercurial or Subversion tree; skipping building src package." + print("Not building in a Mercurial or Subversion tree; skipping building src package.") if sfiles: remove_patterns = [ diff --git a/bench/bench.py b/bench/bench.py index 1a98d8c..f1d18c6 100644 --- a/bench/bench.py +++ b/bench/bench.py @@ -23,7 +23,7 @@ # # This will allow (as much as possible) us to time just the code itself, # not Python function call overhead. - +from __future__ import division, print_function import getopt import sys @@ -94,7 +94,7 @@ exec(open(args[0], 'rU').read()) try: FunctionList except NameError: - function_names = sorted([x for x in list(locals().keys()) if x[:4] == FunctionPrefix]) + function_names = sorted([x for x in 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/bench/env.__setitem__.py b/bench/env.__setitem__.py index 284653e..9c27b6d 100644 --- a/bench/env.__setitem__.py +++ b/bench/env.__setitem__.py @@ -33,7 +33,7 @@ class Timing(object): def times(num=1000000, init='', title='Results:', **statements): # time each statement timings = [] - for n, s in list(statements.items()): + for n, s in statements.items(): t = Timing(n, num, init, s) t.timeit() timings.append(t) @@ -287,7 +287,7 @@ else: # that the timer will use to get at these classes. class_names = [] -for n in list(locals().keys()): +for n in locals().keys(): #if n.startswith('env_'): if n[:4] == 'env_': class_names.append(n) diff --git a/bench/is_types.py b/bench/is_types.py index b6da0d2..69c029f 100644 --- a/bench/is_types.py +++ b/bench/is_types.py @@ -17,11 +17,11 @@ InstanceType = types.InstanceType DictType = dict ListType = list StringType = str -try: str +try: unicode except NameError: UnicodeType = None else: - UnicodeType = str + UnicodeType = unicode # The original implementations, pretty straightforward checks for the @@ -36,7 +36,7 @@ def original_is_List(e): if UnicodeType is not None: def original_is_String(e): - return isinstance(e, (str,UserString)) + return isinstance(e, (str,unicode,UserString)) else: def original_is_String(e): return isinstance(e, (str,UserString)) @@ -58,7 +58,7 @@ def checkInstanceType_is_List(e): if UnicodeType is not None: def checkInstanceType_is_String(e): return isinstance(e, str) \ - or isinstance(e, str) \ + or isinstance(e, unicode) \ or (isinstance(e, types.InstanceType) and isinstance(e, UserString)) else: def checkInstanceType_is_String(e): @@ -84,7 +84,7 @@ if UnicodeType is not None: def cache_type_e_is_String(e): t = type(e) return t is str \ - or t is str \ + or t is unicode \ or (t is types.InstanceType and isinstance(e, UserString)) else: def cache_type_e_is_String(e): @@ -136,7 +136,7 @@ if UnicodeType is not None: t = type(obj) if t is types.InstanceType: t = instanceTypeMap.get(obj.__class__, t) - elif t is str: + elif t is unicode: t = str return t else: diff --git a/bench/timeit.py b/bench/timeit.py index 2840010..7db0dd4 100644 --- a/bench/timeit.py +++ b/bench/timeit.py @@ -46,7 +46,7 @@ be aware of it. The baseline overhead can be measured by invoking the program without arguments. The baseline overhead differs between Python versions! """ - +from __future__ import division, print_function try: import gc @@ -245,7 +245,7 @@ def main(args=None): precision = precision + 1 verbose = precision + 1 if o in ("-h", "--help"): - print(__doc__, end=' ') + print(__doc__) return 0 setup = "\n".join(setup) or "pass" # Include the current directory, so that local imports work (sys.path diff --git a/bin/Command.py b/bin/Command.py index 768caed..dadd7a9 100644 --- a/bin/Command.py +++ b/bin/Command.py @@ -4,6 +4,7 @@ # # XXX Describe what the script does here. # +from __future__ import print_function import getopt import os diff --git a/bin/SConsDoc.py b/bin/SConsDoc.py index 453e241..80f41a5 100644 --- a/bin/SConsDoc.py +++ b/bin/SConsDoc.py @@ -24,6 +24,7 @@ # # Module for handling SCons documentation processing. # +from __future__ import print_function __doc__ = """ This module parses home-brew XML files that document various things @@ -51,7 +52,7 @@ Builder example: to indicate a new paragraph. - print "this is example code, it will be offset and indented" + print("this is example code, it will be offset and indented") @@ -71,7 +72,7 @@ Function example: &f-FUNCTION; element. It need not be on a line by itself. - print "this is example code, it will be offset and indented" + print("this is example code, it will be offset and indented") @@ -88,7 +89,7 @@ Construction variable example: &t-VARIABLE; element. It need not be on a line by itself. - print "this is example code, it will be offset and indented" + print("this is example code, it will be offset and indented") @@ -105,7 +106,7 @@ Tool example: &t-TOOL; element. It need not be on a line by itself. - print "this is example code, it will be offset and indented" + print("this is example code, it will be offset and indented") diff --git a/bin/calibrate.py b/bin/calibrate.py index 31c04e8..3f9104e 100644 --- a/bin/calibrate.py +++ b/bin/calibrate.py @@ -20,7 +20,7 @@ # 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. - +from __future__ import division, print_function import optparse import os diff --git a/bin/caller-tree.py b/bin/caller-tree.py index 327e6a1..21cda4b 100644 --- a/bin/caller-tree.py +++ b/bin/caller-tree.py @@ -39,6 +39,7 @@ # function at the same time, for example, their counts will intermix. # So use this to get a *general* idea of who's calling what, not for # fine-grained performance tuning. +from __future__ import print_function import sys @@ -86,7 +87,7 @@ def print_entry(e, level, calls): else: print() -for e in [ e for e in list(AllCalls.values()) if not e.calls ]: +for e in [ e for e in AllCalls.values() if not e.calls ]: print_entry(e, 0, '') # Local Variables: diff --git a/bin/docs-create-example-outputs.py b/bin/docs-create-example-outputs.py index b2dfbea..64dcf2e 100644 --- a/bin/docs-create-example-outputs.py +++ b/bin/docs-create-example-outputs.py @@ -3,6 +3,7 @@ # Searches through the whole doc/user tree and creates # all output files for the single examples. # +from __future__ import print_function import os import sys diff --git a/bin/docs-update-generated.py b/bin/docs-update-generated.py index 2b419a4..d22cc32 100644 --- a/bin/docs-update-generated.py +++ b/bin/docs-update-generated.py @@ -6,6 +6,7 @@ # as well as the entity declarations for them. # Uses scons-proc.py under the hood... # +from __future__ import print_function import os import SConsDoc diff --git a/bin/docs-validate.py b/bin/docs-validate.py index e5d0659..e53a89d 100644 --- a/bin/docs-validate.py +++ b/bin/docs-validate.py @@ -3,6 +3,7 @@ # Searches through the whole source tree and validates all # documentation files against our own XSD in docs/xsd. # +from __future__ import print_function import sys,os import SConsDoc diff --git a/bin/install_python.py b/bin/install_python.py index dca37d0..5c947ac 100644 --- a/bin/install_python.py +++ b/bin/install_python.py @@ -6,6 +6,7 @@ # This was written for a Linux system (specifically Ubuntu) but should # be reasonably generic to any POSIX-style system with a /usr/local # hierarchy. +from __future__ import print_function import getopt import os diff --git a/bin/install_scons.py b/bin/install_scons.py index b732193..7a39e96 100644 --- a/bin/install_scons.py +++ b/bin/install_scons.py @@ -17,13 +17,17 @@ # This was written for a Linux system (specifically Ubuntu) but should # be reasonably generic to any POSIX-style system with a /usr/local # hierarchy. +from __future__ import print_function import getopt import os import shutil import sys import tarfile -import urllib.request, urllib.parse, urllib.error +try: + from urllib.request import urlretrieve +except ImportError: # Python < 3 + from urllib import urlretrieve from Command import CommandRunner, Usage @@ -171,7 +175,7 @@ Usage: install_scons.py [-ahnq] [-d DIR] [-p PREFIX] [VERSION ...] if not os.path.exists(tar_gz): if not os.path.exists(downloads_dir): cmd.run('mkdir %(downloads_dir)s') - cmd.run((urllib.request.urlretrieve, tar_gz_url, tar_gz), + cmd.run((urlretrieve, tar_gz_url, tar_gz), 'wget -O %(tar_gz)s %(tar_gz_url)s') def extract(tar_gz): diff --git a/bin/linecount.py b/bin/linecount.py index 2d478f0..897f1e8 100644 --- a/bin/linecount.py +++ b/bin/linecount.py @@ -21,7 +21,7 @@ # in each category, the number of non-blank lines, and the number of # non-comment lines. The last figure (non-comment) lines is the most # interesting one for most purposes. - +from __future__ import division, print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/bin/memlogs.py b/bin/memlogs.py index 0409dfe..6e68ce0 100644 --- a/bin/memlogs.py +++ b/bin/memlogs.py @@ -20,6 +20,7 @@ # 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. +from future import print_function import getopt import sys diff --git a/bin/memoicmp.py b/bin/memoicmp.py index 5021c41..1106ac3 100644 --- a/bin/memoicmp.py +++ b/bin/memoicmp.py @@ -2,6 +2,7 @@ # # A script to compare the --debug=memoizer output found in # two different files. +from future import print_function import sys @@ -29,14 +30,14 @@ def memoize_cmp(filea, fileb): ma_o = [] mb_o = [] mab = [] - for k in list(ma.keys()): - if k in list(mb.keys()): + for k in ma.keys(): + if k in mb.keys(): if k not in mab: mab.append(k) else: ma_o.append(k) - for k in list(mb.keys()): - if k in list(ma.keys()): + for k in mb.keys(): + if k in ma.keys(): if k not in mab: mab.append(k) else: diff --git a/bin/objcounts.py b/bin/objcounts.py index 25b985b..2bd8923 100644 --- a/bin/objcounts.py +++ b/bin/objcounts.py @@ -20,6 +20,7 @@ # 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. +from __future__ import print_function import re import sys @@ -47,7 +48,7 @@ c1 = fetch_counts(sys.argv[1]) c2 = fetch_counts(sys.argv[2]) common = {} -for k in list(c1.keys()): +for k in c1.keys(): try: common[k] = (c1[k], c2[k]) except KeyError: @@ -58,7 +59,7 @@ for k in list(c1.keys()): if not '.' in k: s = '.'+k l = len(s) - for k2 in list(c2.keys()): + for k2 in 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 5181fa1..8597501 100644 --- a/bin/scons-diff.py +++ b/bin/scons-diff.py @@ -8,6 +8,7 @@ # etc. so that you can diff trees without having to ignore changes in # version lines. # +from __future__ import print_function import difflib import getopt @@ -161,7 +162,7 @@ def diff_file(left, right): else: if text: diff_line(left, right) - print(text, end=' ') + print(text) elif report_same: print('Files %s and %s are identical' % (left, right)) @@ -173,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 list(u.keys()) if x[-4:] != '.pyc' ]): + for x in sorted([ x for x in 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 19be4c3..b93b25a 100644 --- a/bin/scons-proc.py +++ b/bin/scons-proc.py @@ -9,6 +9,8 @@ # DocBook-formatted generated XML files containing the summary text # and/or .mod files containing the ENTITY definitions for each item. # +from __future__ import print_function + import getopt import os import re @@ -106,7 +108,7 @@ Link_Entities_Header = """\ class SCons_XML(object): def __init__(self, entries, **kw): self.values = entries - for k, v in list(kw.items()): + for k, v in kw.items(): setattr(self, k, v) def fopen(self, name): diff --git a/bin/scons-test.py b/bin/scons-test.py index 788fc6d..dd54dd1 100644 --- a/bin/scons-test.py +++ b/bin/scons-test.py @@ -14,6 +14,7 @@ # relevant information about the system, the Python version, etc., # so that problems on different platforms can be identified sooner. # +from __future__ import print_function import atexit import getopt @@ -224,7 +225,7 @@ if format == '--xml': print(" ") command = '"%s" runtest.py -q -o - --xml %s' % (sys.executable, runtest_args) - #print command + #print(command) os.system(command) print("") @@ -243,7 +244,7 @@ else: print_version_info("engine", SCons) command = '"%s" runtest.py %s' % (sys.executable, runtest_args) - #print command + #print(command) os.system(command) # Local Variables: diff --git a/bin/scons-unzip.py b/bin/scons-unzip.py index 75d3281..a64179f 100644 --- a/bin/scons-unzip.py +++ b/bin/scons-unzip.py @@ -7,6 +7,7 @@ # I'm using this to make it more convenient to manage working on multiple # changes on Windows, where I don't have access to my Aegis tools. # +from __future__ import print_function import getopt import os.path diff --git a/bin/scons_dev_master.py b/bin/scons_dev_master.py index 71034ad..a8862ea 100644 --- a/bin/scons_dev_master.py +++ b/bin/scons_dev_master.py @@ -3,6 +3,7 @@ # A script for turning a generic Ubuntu system into a master for # SCons development. +from __future__ import print_function import getopt import sys diff --git a/bin/sfsum b/bin/sfsum index 2dfa422..142793a 100644 --- a/bin/sfsum +++ b/bin/sfsum @@ -22,6 +22,7 @@ # # https://sourceforge.net/projects/sitedocs/ # +from __future__ import print_function import xml.sax import xml.sax.saxutils @@ -121,9 +122,9 @@ if __name__ == '__main__': # generalized once we figure out other things for this script to do. bugs = [x for x in Artifacts['Bugs'] if x.status == 'Open'] - print list(Artifacts.keys()) + print(list(Artifacts.keys())) - print "%d open bugs" % len(bugs) + print("%d open bugs" % len(bugs)) # Sort them into a separate list for each assignee. Assigned = {} @@ -141,7 +142,7 @@ if __name__ == '__main__': except KeyError: pass else: - print " %s" % a - b.sort(lambda x, y: cmp(x.artifact_id, y.artifact_id)) + print(" %s" % a) + b.sort(key=lambda x, y: (x.artifact_id, y.artifact_id)) for bug in b: - print " %-6s %s" % (bug.artifact_id, bug.summary) + print(" %-6s %s" % (bug.artifact_id, bug.summary)) diff --git a/bin/svn-bisect.py b/bin/svn-bisect.py index f262366..dbf8dd9 100755 --- a/bin/svn-bisect.py +++ b/bin/svn-bisect.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- Python -*- - +from __future__ import division, print_function import sys from math import log, ceil diff --git a/bin/update-release-info.py b/bin/update-release-info.py index f60c187..b6cf942 100644 --- a/bin/update-release-info.py +++ b/bin/update-release-info.py @@ -56,6 +56,7 @@ In 'post' mode, files are prepared for the next release cycle: # 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. +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -332,7 +333,7 @@ t.replace_assign('deprecated_python_version', str(deprecated_version)) # Update doc/user/main.{in,xml} -docyears = ', '.join(map(str, iter(list(range(2004, release_date[0] + 1))))) +docyears = ', '.join(map(str, range(2004, release_date[0] + 1))) t = UpdateFile(os.path.join('doc', 'user', 'main.in')) if DEBUG: t.file = '/tmp/main.in' ## TODO debug these diff --git a/bin/xmlagenda.py b/bin/xmlagenda.py index 40f5ca1..fcfe53e 100755 --- a/bin/xmlagenda.py +++ b/bin/xmlagenda.py @@ -18,6 +18,7 @@ # Grab the sort bar on the far left (just above the "1" for row one) # and move it down one row. (Row one becomes a floating header) # Voila! +from __future__ import print_function # The team members # FIXME: These names really should be external to this script diff --git a/doc/SConscript b/doc/SConscript index 8dcf697..c6b8f74 100644 --- a/doc/SConscript +++ b/doc/SConscript @@ -23,6 +23,7 @@ # 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. +from __future__ import print_function import os.path import re @@ -84,16 +85,16 @@ except: try: import lxml except: - print "doc: Neither libxml2 nor lxml Python bindings found!" - print " Please install one of the packages python-libxml2 or python-lxml." + print("doc: Neither libxml2 nor lxml Python bindings found!") + print(" Please install one of the packages python-libxml2 or python-lxml.") skip_doc = True if not fop and not xep: - print "doc: No PDF renderer found (fop|xep)!" + print("doc: No PDF renderer found (fop|xep)!") skip_doc = True if skip_doc: - print "doc: ...skipping building User Guide." + print("doc: ...skipping building User Guide.") else: # # Always create a version.xml file containing the version information @@ -109,18 +110,18 @@ else: # Ensure that all XML files are valid against our XSD, and # that all example names and example output suffixes are unique # - print "Validating files against SCons XSD..." + print("Validating files against SCons XSD...") if SConsDoc.validate_all_xml(['src'], xsdfile='xsd/scons.xsd'): - print "OK" + print("OK") else: - print "Validation failed! Please correct the errors above and try again." + print("Validation failed! Please correct the errors above and try again.") sys.exit(0) - print "Checking whether all example names are unique..." + print("Checking whether all example names are unique...") if SConsExamples.exampleNamesAreUnique(os.path.join('doc','user')): - print "OK" + print("OK") else: - print "Not all example names and suffixes are unique! Please correct the errors listed above and try again." + print("Not all example names and suffixes are unique! Please correct the errors listed above and try again.") sys.exit(0) # @@ -358,7 +359,7 @@ else: # epydoc_cli is found if not epydoc_cli and not epydoc: - print "doc: epydoc not found, skipping building API documentation." + print("doc: epydoc not found, skipping building API documentation.") else: # XXX Should be in common with reading the same thing in # the SConstruct file. @@ -380,7 +381,7 @@ else: tar_list.append(htmldir) if not epydoc_cli: - print "doc: command line epydoc is not found, skipping PDF/PS/Tex output" + print("doc: command line epydoc is not found, skipping PDF/PS/Tex output") else: # PDF and PostScript and TeX are built from the # same invocation. diff --git a/review.py b/review.py index 8d033ed..c01472e 100644 --- a/review.py +++ b/review.py @@ -13,6 +13,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import print_function """Tool for uploading diffs from a version control system to the codereview app. @@ -31,8 +32,16 @@ against by using the '--rev' option. # This code is derived from appcfg.py in the App Engine SDK (open source), # and from ASPN recipe #146306. -import configparser -import http.cookiejar +try: + from configparser import ConfigParser +except ImportError: # Python < 3 + from ConfigParser import ConfigParser +try: + from http.cookiejar import ( + CookieJar, MozillaCookieJar, LoadError as CookieLoadError) +except ImportError: # Python < 3 + from cookielib import ( + CookieJar, MozillaCookieJar, LoadError as CookieLoadError) import fnmatch import getpass import logging @@ -43,6 +52,24 @@ import re import socket import subprocess import sys +try: + from urllib.request import ( + Request, OpenerDirector, + ProxyHandler, UnknownHandler, HTTPHandler, HTTPSHandler, + HTTPDefaultErrorHandler, HTTPErrorProcessor, + HTTPCookieProcessor) + from urllib.error import HTTPError + from urllib.parse import ( + urlencode, urlparse, urlunparse, splituser as urlsplituser) +except ImportError: # Python < 3 + from urllib2 import ( + Request, OpenerDirector, + ProxyHandler, UnknownHandler, HTTPHandler, HTTPSHandler, + HTTPDefaultErrorHandler, HTTPErrorProcessor, HTTPError, + HTTPCookieProcessor, + urlparse) + from urllib import urlencode, splituser as urlsplituser + from urlparse import urlparse, urlunparse import urllib.request, urllib.parse, urllib.error import urllib.request, urllib.error, urllib.parse import urllib.parse @@ -155,11 +182,11 @@ def ErrorExit(msg): sys.exit(1) -class ClientLoginError(urllib.error.HTTPError): +class ClientLoginError(HTTPError): """Raised to indicate there was an error authenticating with ClientLogin.""" def __init__(self, url, code, msg, headers, args): - urllib.error.HTTPError.__init__(self, url, code, msg, headers, None) + HTTPError.__init__(self, url, code, msg, headers, None) self.args = args self.reason = args["Error"] self.info = args.get("Info", None) @@ -212,7 +239,7 @@ class AbstractRpcServer(object): def _CreateRequest(self, url, data=None): """Creates a new urllib request.""" logging.debug("Creating request for: '%s' with payload:\n%s", url, data) - req = urllib.request.Request(url, data=data) + req = Request(url, data=data) if self.host_override: req.add_header("Host", self.host_override) for key, value in self.extra_headers.items(): @@ -239,7 +266,7 @@ class AbstractRpcServer(object): account_type = "HOSTED" req = self._CreateRequest( url="https://www.google.com/accounts/ClientLogin", - data=urllib.parse.urlencode({ + data=urlencode({ "Email": email, "Passwd": password, "service": "ah", @@ -253,7 +280,7 @@ class AbstractRpcServer(object): response_dict = dict(x.split("=") for x in response_body.split("\n") if x) return response_dict["Auth"] - except urllib.error.HTTPError as e: + except HTTPError as e: if e.code == 403: body = e.read() response_dict = dict(x.split("=", 1) for x in body.split("\n") if x) @@ -275,15 +302,15 @@ class AbstractRpcServer(object): continue_location = "http://localhost/" args = {"continue": continue_location, "auth": auth_token} req = self._CreateRequest("%s/_ah/login?%s" % - (self.host, urllib.parse.urlencode(args))) + (self.host, urlencode(args))) try: response = self.opener.open(req) - except urllib.error.HTTPError as e: + except HTTPError as e: response = e if (response.code != 302 or response.info()["location"] != continue_location): - raise urllib.error.HTTPError(req.get_full_url(), response.code, response.msg, - response.headers, response.fp) + raise HTTPError(req.get_full_url(), response.code, response.msg, + response.headers, response.fp) self.authenticated = True def _Authenticate(self): @@ -306,23 +333,23 @@ class AbstractRpcServer(object): try: auth_token = self._GetAuthToken(credentials[0], credentials[1]) except ClientLoginError as e: - print('', file=sys.stderr) + print(file=sys.stderr) if e.reason == "BadAuthentication": if e.info == "InvalidSecondFactor": - print(( - "Use an application-specific password instead " - "of your regular account password.\n" - "See http://www.google.com/" - "support/accounts/bin/answer.py?answer=185833"), file=sys.stderr) + print("Use an application-specific password instead " + "of your regular account password.\n" + "See http://www.google.com/" + "support/accounts/bin/answer.py?answer=185833", + file=sys.stderr) else: print("Invalid username or password.", file=sys.stderr) elif e.reason == "CaptchaRequired": - print(( - "Please go to\n" - "https://www.google.com/accounts/DisplayUnlockCaptcha\n" - "and verify you are a human. Then try again.\n" - "If you are using a Google Apps account the URL is:\n" - "https://www.google.com/a/yourdomain.com/UnlockCaptcha"), file=sys.stderr) + print("Please go to\n" + "https://www.google.com/accounts/DisplayUnlockCaptcha\n" + "and verify you are a human. Then try again.\n" + "If you are using a Google Apps account the URL is:\n" + "https://www.google.com/a/yourdomain.com/UnlockCaptcha", + file=sys.stderr) elif e.reason == "NotVerified": print("Account not verified.", file=sys.stderr) elif e.reason == "TermsNotAgreed": @@ -333,14 +360,15 @@ class AbstractRpcServer(object): print("The user account has been disabled.", file=sys.stderr) break elif e.reason == "ServiceDisabled": - print(("The user's access to the service has been " - "disabled."), file=sys.stderr) + print("The user's access to the service has been disabled.", + file=sys.stderr) elif e.reason == "ServiceUnavailable": - print("The service is not available; try again later.", file=sys.stderr) + print("The service is not available; try again later.", + file=sys.stderr) else: # Unknown error. raise - print('', file=sys.stderr) + print(file=sys.stderr) continue self._GetAuthCookie(auth_token) return @@ -380,18 +408,18 @@ class AbstractRpcServer(object): args = dict(kwargs) url = "%s%s" % (self.host, request_path) if args: - url += "?" + urllib.parse.urlencode(args) + url += "?" + urlencode(args) req = self._CreateRequest(url=url, data=payload) req.add_header("Content-Type", content_type) if extra_headers: - for header, value in list(extra_headers.items()): + for header, value in extra_headers.items(): req.add_header(header, value) try: f = self.opener.open(req) response = f.read() f.close() return response - except urllib.error.HTTPError as e: + except HTTPError as e: if tries > 3: raise elif e.code == 401 or e.code == 302: @@ -402,7 +430,7 @@ class AbstractRpcServer(object): elif e.code == 301: # Handle permanent redirect manually. url = e.info()["location"] - url_loc = urllib.parse.urlparse(url) + url_loc = urlparse(url) self.host = '%s://%s' % (url_loc[0], url_loc[1]) else: raise @@ -426,23 +454,23 @@ class HttpRpcServer(AbstractRpcServer): Returns: A urllib2.OpenerDirector object. """ - opener = urllib.request.OpenerDirector() - opener.add_handler(urllib.request.ProxyHandler()) - opener.add_handler(urllib.request.UnknownHandler()) - opener.add_handler(urllib.request.HTTPHandler()) - opener.add_handler(urllib.request.HTTPDefaultErrorHandler()) - opener.add_handler(urllib.request.HTTPSHandler()) - opener.add_handler(urllib2.HTTPErrorProcessor()) + opener = OpenerDirector() + opener.add_handler(ProxyHandler()) + opener.add_handler(UnknownHandler()) + opener.add_handler(HTTPHandler()) + opener.add_handler(HTTPDefaultErrorHandler()) + opener.add_handler(HTTPSHandler()) + opener.add_handler(HTTPErrorProcessor()) if self.save_cookies: self.cookie_file = os.path.expanduser("~/.codereview_upload_cookies") - self.cookie_jar = http.cookiejar.MozillaCookieJar(self.cookie_file) + self.cookie_jar = MozillaCookieJar(self.cookie_file) if os.path.exists(self.cookie_file): try: self.cookie_jar.load() self.authenticated = True StatusUpdate("Loaded authentication cookies from %s" % self.cookie_file) - except (http.cookiejar.LoadError, IOError): + except (CookieLoadError, IOError): # Failed to load cookies - just ignore them. pass else: @@ -453,8 +481,8 @@ class HttpRpcServer(AbstractRpcServer): os.chmod(self.cookie_file, 0o600) else: # Don't save cookies across runs of update.py. - self.cookie_jar = http.cookiejar.CookieJar() - opener.add_handler(urllib.request.HTTPCookieProcessor(self.cookie_jar)) + self.cookie_jar = CookieJar() + opener.add_handler(HTTPCookieProcessor(self.cookie_jar)) return opener @@ -804,8 +832,8 @@ class VersionControlSystem(object): else: type = "current" if len(content) > MAX_UPLOAD_SIZE: - print(("Not uploading the %s file for %s because it's too large." % - (type, filename))) + print("Not uploading the %s file for %s because it's too large." % + (type, filename)) file_too_large = True content = "" checksum = md5(content).hexdigest() @@ -832,7 +860,7 @@ class VersionControlSystem(object): patches = dict() [patches.setdefault(v, k) for k, v in patch_list] - for filename in list(patches.keys()): + for filename in patches.keys(): base_content, new_content, is_binary, status = files[filename] file_id_str = patches.get(filename) if file_id_str.find("nobase") != -1: @@ -898,7 +926,7 @@ class SubversionVCS(VersionControlSystem): for line in info.splitlines(): if line.startswith("URL: "): url = line.split()[1] - scheme, netloc, path, params, query, fragment = urllib.parse.urlparse(url) + scheme, netloc, path, params, query, fragment = urlparse(url) guess = "" if netloc == "svn.python.org" and scheme == "svn+ssh": path = "projects" + path @@ -908,8 +936,7 @@ class SubversionVCS(VersionControlSystem): scheme = "http" guess = "Google Code " path = path + "/" - base = urllib.parse.urlunparse((scheme, netloc, path, params, - query, fragment)) + base = urlunparse((scheme, netloc, path, params, query, fragment)) logging.info("Guessed %sbase = %s", guess, base) return base if required: @@ -1412,8 +1439,8 @@ def UploadSeparatePatches(issue, rpc_server, patchset, data, options): rv = [] for patch in patches: if len(patch[1]) > MAX_UPLOAD_SIZE: - print(("Not uploading the patch for " + patch[0] + - " because the file is too large.")) + print("Not uploading the patch for " + patch[0] + + " because the file is too large.") continue form_fields = [("filename", patch[0])] if not options.download_base: @@ -1551,7 +1578,7 @@ def LoadSubversionAutoProperties(): subversion_config = os.path.expanduser("~/.subversion/config") if not os.path.exists(subversion_config): return {} - config = configparser.ConfigParser() + config = ConfigParser() config.read(subversion_config) if (config.has_section("miscellany") and config.has_option("miscellany", "enable-auto-props") and @@ -1606,7 +1633,7 @@ def GetSubversionPropertyChanges(filename): svn_auto_props_map = LoadSubversionAutoProperties() all_props = [] - for file_pattern, props in list(svn_auto_props_map.items()): + for file_pattern, props in svn_auto_props_map.items(): if fnmatch.fnmatch(filename, file_pattern): all_props.extend(props) if all_props: @@ -1703,12 +1730,12 @@ def RealMain(argv, data=None): options.account_type) form_fields = [("subject", message)] if base: - b = urllib.parse.urlparse(base) - username, netloc = urllib.parse.splituser(b.netloc) + b = urlparse(base) + username, netloc = urlsplituser(b.netloc) if username: logging.info("Removed username from base URL") - base = urllib.parse.urlunparse((b.scheme, netloc, b.path, b.params, - b.query, b.fragment)) + base = urlunparse((b.scheme, netloc, b.path, b.params, + b.query, b.fragment)) form_fields.append(("base", base)) if options.issue: form_fields.append(("issue", str(options.issue))) diff --git a/runtest.py b/runtest.py index 65d7851..0fad655 100755 --- a/runtest.py +++ b/runtest.py @@ -81,6 +81,7 @@ # library directory. If we ever resurrect that as the default, then # you can find the appropriate code in the 0.04 version of this script, # rather than reinventing that wheel.) +from __future__ import print_function import getopt import glob @@ -92,7 +93,10 @@ import time try: import threading - import queue # 2to3: rename to queue + try: + from queue import Queue + except ImportError: # Python < 3 + from Queue import Queue threading_ok = True except ImportError: print("Can't import threading or queue") @@ -865,7 +869,7 @@ class RunTest(threading.Thread): if jobs > 1 and threading_ok: print("Running tests using %d jobs"%jobs) # Start worker threads - queue = queue.Queue() + queue = Queue() io_lock = threading.Lock() for i in range(1, jobs): t = RunTest(queue, io_lock) diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index 66757a4..006e8f5 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -114,7 +114,6 @@ import SCons.Errors import SCons.Executor import SCons.Util import SCons.Subst -import collections # we use these a lot, so try to optimize them is_String = SCons.Util.is_String @@ -329,7 +328,7 @@ def _do_create_keywords(args, kw): cmdstrfunc = args[0] if cmdstrfunc is None or is_String(cmdstrfunc): kw['cmdstr'] = cmdstrfunc - elif isinstance(cmdstrfunc, collections.Callable): + elif callable(cmdstrfunc): kw['strfunction'] = cmdstrfunc else: raise SCons.Errors.UserError( @@ -360,7 +359,7 @@ def _do_create_action(act, kw): if is_List(act): return CommandAction(act, **kw) - if isinstance(act, collections.Callable): + if callable(act): try: gen = kw['generator'] del kw['generator'] @@ -494,7 +493,7 @@ class _ActionAction(ActionBase): self.targets = targets if batch_key: - if not isinstance(batch_key, collections.Callable): + if not callable(batch_key): # They have set batch_key, but not to their own # callable. The default behavior here will batch # *all* targets+sources using this action, separated @@ -514,7 +513,7 @@ class _ActionAction(ActionBase): # This code assumes s is a regular string, but should # work if it's unicode too. try: - sys.stdout.write(str(s + "\n")) + sys.stdout.write(s + u"\n") except UnicodeDecodeError: sys.stdout.write(s + "\n") @@ -555,7 +554,7 @@ class _ActionAction(ActionBase): source = executor.get_all_sources() t = ' and '.join(map(str, target)) l = '\n '.join(self.presub_lines(env)) - out = "Building %s with action:\n %s\n" % (t, l) + out = u"Building %s with action:\n %s\n" % (t, l) sys.stdout.write(out) cmd = None if show and self.strfunction: @@ -655,7 +654,7 @@ def _subproc(scons_env, cmd, error = 'ignore', **kw): # Ensure that the ENV values are all strings: new_env = {} - for key, value in list(ENV.items()): + for key, value in ENV.items(): if is_List(value): # If the value is a list, then we assume it is a path list, # because that's a pretty common list-like value to stick @@ -781,7 +780,7 @@ class CommandAction(_ActionAction): ENV = get_default_ENV(env) # Ensure that the ENV values are all strings: - for key, value in list(ENV.items()): + for key, value in ENV.items(): if not is_String(value): if is_List(value): # If the value is a list, then we assume it is a @@ -1040,7 +1039,7 @@ class FunctionAction(_ActionAction): else: if strfunc is None: return None - if isinstance(strfunc, collections.Callable): + if callable(strfunc): return strfunc(target, source, env) name = self.function_name() tstr = array(target) @@ -1216,7 +1215,7 @@ class ActionCaller(object): def subst_kw(self, target, source, env): kw = {} - for key in list(self.kw.keys()): + for key in 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 6edf373..754c6e7 100644 --- a/src/engine/SCons/ActionTests.py +++ b/src/engine/SCons/ActionTests.py @@ -133,7 +133,7 @@ class Environment(object): self.d['SPAWN'] = scons_env['SPAWN'] self.d['PSPAWN'] = scons_env['PSPAWN'] self.d['ESCAPE'] = scons_env['ESCAPE'] - for k, v in list(kw.items()): + for k, v in kw.items(): self.d[k] = v # Just use the underlying scons_subst*() utility methods. def subst(self, strSubst, raw=0, target=[], source=[], conv=None): @@ -158,12 +158,12 @@ class Environment(object): def Clone(self, **kw): res = Environment() res.d = SCons.Util.semi_deepcopy(self.d) - for k, v in list(kw.items()): + for k, v in kw.items(): res.d[k] = v return res def sig_dict(self): d = {} - for k,v in list(self.items()): d[k] = v + for k,v in self.items(): d[k] = v d['TARGETS'] = ['__t1__', '__t2__', '__t3__', '__t4__', '__t5__', '__t6__'] d['TARGET'] = d['TARGETS'][0] d['SOURCES'] = ['__s1__', '__s2__', '__s3__', '__s4__', '__s5__', '__s6__'] @@ -305,7 +305,7 @@ class ActionTestCase(unittest.TestCase): # a singleton list returns the contained action test_positional_args(cmd_action, ["string"]) - try: str + try: unicode except NameError: pass else: a2 = eval("SCons.Action.Action(u'string')") diff --git a/src/engine/SCons/Builder.py b/src/engine/SCons/Builder.py index 6abcbcf..0f7aff4 100644 --- a/src/engine/SCons/Builder.py +++ b/src/engine/SCons/Builder.py @@ -179,7 +179,7 @@ class CallableSelector(SCons.Util.Selector): finds if it can.""" def __call__(self, env, source): value = SCons.Util.Selector.__call__(self, env, source) - if isinstance(value, collections.Callable): + if callable(value): value = value(env, source) return value @@ -230,7 +230,7 @@ class OverrideWarner(collections.UserDict): def warn(self): if self.already_warned: return - for k in list(self.keys()): + for k in self.keys(): if k in misleading_keywords: alt = misleading_keywords[k] msg = "Did you mean to use `%s' instead of `%s'?" % (alt, k) @@ -336,7 +336,7 @@ class EmitterProxy(object): # in strings. Maybe we should change that? while SCons.Util.is_String(emitter) and emitter in env: emitter = env[emitter] - if isinstance(emitter, collections.Callable): + if callable(emitter): target, source = emitter(target, source, env) elif SCons.Util.is_List(emitter): for e in emitter: @@ -426,9 +426,12 @@ class BuilderBase(object): src_builder = [ src_builder ] self.src_builder = src_builder - def __bool__(self): + def __nonzero__(self): raise InternalError("Do not test for the Node.builder attribute directly; use Node.has_builder() instead") + def __bool__(self): + return self.__nonzero__() + def get_name(self, env): """Attempts to get the name of the Builder. @@ -638,18 +641,18 @@ class BuilderBase(object): def get_prefix(self, env, sources=[]): prefix = self.prefix - if isinstance(prefix, collections.Callable): + if callable(prefix): prefix = prefix(env, sources) return env.subst(prefix) def set_suffix(self, suffix): - if not isinstance(suffix, collections.Callable): + if not callable(suffix): suffix = self.adjust_suffix(suffix) self.suffix = suffix def get_suffix(self, env, sources=[]): suffix = self.suffix - if isinstance(suffix, collections.Callable): + if callable(suffix): suffix = suffix(env, sources) return env.subst(suffix) @@ -658,7 +661,7 @@ class BuilderBase(object): src_suffix = [] elif not SCons.Util.is_List(src_suffix): src_suffix = [ src_suffix ] - self.src_suffix = [isinstance(suf, collections.Callable) and suf or self.adjust_suffix(suf) for suf in src_suffix] + self.src_suffix = [callable(suf) and suf or self.adjust_suffix(suf) for suf in src_suffix] def get_src_suffix(self, env): """Get the first src_suffix in the list of src_suffixes.""" @@ -868,7 +871,7 @@ def is_a_Builder(obj): """ return (isinstance(obj, BuilderBase) or isinstance(obj, CompositeBuilder) - or isinstance(obj, collections.Callable)) + or callable(obj)) # Local Variables: # tab-width:4 diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py index da03a3c..41b640b 100644 --- a/src/engine/SCons/BuilderTests.py +++ b/src/engine/SCons/BuilderTests.py @@ -20,6 +20,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -77,7 +78,7 @@ class Environment(object): self.d['SHELL'] = scons_env['SHELL'] self.d['SPAWN'] = scons_env['SPAWN'] self.d['ESCAPE'] = scons_env['ESCAPE'] - for k, v in list(kw.items()): + for k, v in kw.items(): self.d[k] = v global env_arg2nodes_called env_arg2nodes_called = None @@ -138,7 +139,7 @@ class Environment(object): return list(self.d.items()) def sig_dict(self): d = {} - for k,v in list(self.items()): d[k] = v + for k,v in self.items(): d[k] = v d['TARGETS'] = ['__t1__', '__t2__', '__t3__', '__t4__', '__t5__', '__t6__'] d['TARGET'] = d['TARGETS'][0] d['SOURCES'] = ['__s1__', '__s2__', '__s3__', '__s4__', '__s5__', '__s6__'] @@ -305,11 +306,11 @@ class BuilderTestCase(unittest.TestCase): #be = target.get_build_env() #assert be['VAR'] == 'foo', be['VAR'] - try: str + try: unicode except NameError: uni = str else: - uni = str + uni = unicode target = builder(env, target = uni('n12 n13'), source = [uni('n14 n15')])[0] diff --git a/src/engine/SCons/Conftest.py b/src/engine/SCons/Conftest.py index 4e2a3e8..6212a47 100644 --- a/src/engine/SCons/Conftest.py +++ b/src/engine/SCons/Conftest.py @@ -728,7 +728,7 @@ def _Have(context, key, have, comment = None): line = "#define %s 1\n" % key_up elif have == 0: line = "/* #undef %s */\n" % key_up - elif isinstance(have, IntType): + elif isinstance(have, int): line = "#define %s %d\n" % (key_up, have) else: line = "#define %s %s\n" % (key_up, str(have)) diff --git a/src/engine/SCons/Debug.py b/src/engine/SCons/Debug.py index 363c8b7..1c0c638 100644 --- a/src/engine/SCons/Debug.py +++ b/src/engine/SCons/Debug.py @@ -73,7 +73,7 @@ def dumpLoggedInstances(classes, file=sys.stdout): obj = ref() if obj is not None: file.write(' %s:\n' % obj) - for key, value in list(obj.__dict__.items()): + for key, value in obj.__dict__.items(): file.write(' %20s : %s\n' % (key, value)) @@ -143,7 +143,7 @@ def caller_trace(back=0): # print a single caller and its callers, if any def _dump_one_caller(key, file, level=0): leader = ' '*level - for v,c in sorted([(-v,c) for c,v in list(caller_dicts[key].items())]): + for v,c in sorted([(-v,c) for c,v in caller_dicts[key].items()]): file.write("%s %6d %s:%d(%s)\n" % ((leader,-v) + func_shorten(c[-3:]))) if c in caller_dicts: _dump_one_caller(c, file, level+1) diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py index fe1f87b..491b9f2 100644 --- a/src/engine/SCons/Defaults.py +++ b/src/engine/SCons/Defaults.py @@ -31,7 +31,7 @@ from distutils.msvccompiler. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # - +from __future__ import division __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -50,7 +50,6 @@ import SCons.Environment import SCons.PathList import SCons.Subst import SCons.Tool -import collections # A placeholder for a default Environment (for fetching source files # from source code management systems and the like). This must be @@ -326,9 +325,9 @@ def _stripixes(prefix, itms, suffix, stripprefixes, stripsuffixes, env, c=None): if not itms: return itms - if not isinstance(c, collections.Callable): + if not callable(c): env_c = env['_concat'] - if env_c != _concat and isinstance(env_c, collections.Callable): + if env_c != _concat and callable(env_c): # There's a custom _concat() method in the construction # environment, and we've allowed people to set that in # the past (see test/custom-concat.py), so preserve the diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index 88b0553..b5bd620 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -58,7 +58,6 @@ import SCons.Subst import SCons.Tool import SCons.Util import SCons.Warnings -import collections class _Null(object): pass @@ -128,7 +127,7 @@ future_reserved_construction_var_names = [ def copy_non_reserved_keywords(dict): result = semi_deepcopy(dict) - for k in list(result.keys()): + for k in result.keys(): if k in reserved_construction_var_names: msg = "Ignoring attempt to set reserved variable `$%s'" SCons.Warnings.warn(SCons.Warnings.ReservedVariableWarning, msg % k) @@ -152,7 +151,7 @@ def _set_BUILDERS(env, key, value): except KeyError: bd = BuilderDict(kwbd, env) env._dict[key] = bd - for k, v in list(value.items()): + for k, v in value.items(): if not SCons.Builder.is_a_Builder(v): raise SCons.Errors.UserError('%s is not a Builder.' % repr(v)) bd.update(value) @@ -324,7 +323,7 @@ class BuilderDict(UserDict): delattr(self.env, item) def update(self, dict): - for i, v in list(dict.items()): + for i, v in dict.items(): self.__setitem__(i, v) @@ -518,7 +517,7 @@ class SubstitutionEnvironment(object): def subst_kw(self, kw, raw=0, target=None, source=None): nkw = {} - for k, v in list(kw.items()): + for k, v in kw.items(): k = self.subst(k, raw, target, source) if SCons.Util.is_String(v): v = self.subst(v, raw, target, source) @@ -592,7 +591,7 @@ class SubstitutionEnvironment(object): out,err = p.communicate() status = p.wait() if err: - sys.stderr.write(str(err)) + sys.stderr.write(u"" + err) if status: raise OSError("'%s' exited %d" % (command, status)) return out @@ -630,7 +629,7 @@ class SubstitutionEnvironment(object): if not o: return self overrides = {} merges = None - for key, value in list(o.items()): + for key, value in o.items(): if key == 'parse_flags': merges = value else: @@ -815,7 +814,7 @@ class SubstitutionEnvironment(object): if not unique: self.Append(**args) return self - for key, value in list(args.items()): + for key, value in args.items(): if not value: continue try: @@ -1005,7 +1004,7 @@ class Base(SubstitutionEnvironment): # Now restore the passed-in and customized variables # to the environment, since the values the user set explicitly # should override any values set by the tools. - for key, val in list(save.items()): + for key, val in save.items(): self._dict[key] = val # Finally, apply any flags to be merged in @@ -1263,7 +1262,7 @@ class Base(SubstitutionEnvironment): values move to end. """ kw = copy_non_reserved_keywords(kw) - for key, val in list(kw.items()): + for key, val in kw.items(): if SCons.Util.is_List(val): val = _delete_duplicates(val, delete_existing) if key not in self._dict or self._dict[key] in ('', None): @@ -1403,7 +1402,7 @@ class Base(SubstitutionEnvironment): # so the tools can use the new variables kw = copy_non_reserved_keywords(kw) new = {} - for key, value in list(kw.items()): + for key, value in kw.items(): new[key] = SCons.Subst.scons_subst_once(value, self, key) clone.Replace(**new) @@ -1470,7 +1469,7 @@ class Base(SubstitutionEnvironment): copy_function = self._copy_from_cache elif function == 'timestamp-match': function = self._changed_timestamp_match - elif not isinstance(function, collections.Callable): + elif not callable(function): raise UserError("Unknown Decider value %s" % repr(function)) # We don't use AddMethod because we don't want to turn the @@ -1603,7 +1602,7 @@ class Base(SubstitutionEnvironment): in an Environment. """ kw = copy_non_reserved_keywords(kw) - for key, val in list(kw.items()): + for key, val in kw.items(): # It would be easier on the eyes to write this using # "continue" statements whenever we finish processing an item, # but Python 1.5.2 apparently doesn't let you use "continue" @@ -1694,7 +1693,7 @@ class Base(SubstitutionEnvironment): values move to front. """ kw = copy_non_reserved_keywords(kw) - for key, val in list(kw.items()): + for key, val in kw.items(): if SCons.Util.is_List(val): val = _delete_duplicates(val, not delete_existing) if key not in self._dict or self._dict[key] in ('', None): @@ -1769,7 +1768,7 @@ class Base(SubstitutionEnvironment): return os.path.join(dir, new_prefix+name+new_suffix) def SetDefault(self, **kw): - for k in list(kw.keys()): + for k in kw.keys(): if k in self._dict: del kw[k] self.Replace(**kw) @@ -1831,7 +1830,7 @@ class Base(SubstitutionEnvironment): uniq = {} for executor in [n.get_executor() for n in nodes]: uniq[executor] = 1 - for executor in list(uniq.keys()): + for executor in uniq.keys(): executor.add_pre_action(action) return nodes @@ -1841,7 +1840,7 @@ class Base(SubstitutionEnvironment): uniq = {} for executor in [n.get_executor() for n in nodes]: uniq[executor] = 1 - for executor in list(uniq.keys()): + for executor in uniq.keys(): executor.add_post_action(action) return nodes diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index 3af879a..22552b3 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -20,6 +20,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -160,7 +161,7 @@ class TestEnvironmentFixture(object): default_keys = { 'CC' : 'cc', 'CCFLAGS' : '-DNDEBUG', 'ENV' : { 'TMP' : '/tmp' } } - for key, value in list(default_keys.items()): + for key, value in default_keys.items(): if key not in kw: kw[key] = value if 'BUILDERS' not in kw: @@ -263,16 +264,10 @@ class SubstitutionTestCase(unittest.TestCase): assert isinstance(nodes[0], X) assert nodes[0].name == "Util.py UtilTests.py" - try: str - except NameError: pass - else: - code = """if 1: - nodes = env.arg2nodes(u"Util.py UtilTests.py", Factory) - assert len(nodes) == 1, nodes - assert isinstance(nodes[0], X) - assert nodes[0].name == u"Util.py UtilTests.py" - \n""" - exec(code, globals(), locals()) + nodes = env.arg2nodes(u"Util.py UtilTests.py", Factory) + assert len(nodes) == 1, nodes + assert isinstance(nodes[0], X) + assert nodes[0].name == u"Util.py UtilTests.py" nodes = env.arg2nodes(["Util.py", "UtilTests.py"], Factory) assert len(nodes) == 2, nodes diff --git a/src/engine/SCons/Executor.py b/src/engine/SCons/Executor.py index 68419b8..6248cf1 100644 --- a/src/engine/SCons/Executor.py +++ b/src/engine/SCons/Executor.py @@ -428,8 +428,8 @@ class Executor(object): pass env = self.get_build_env() result = b"".join([action.get_contents(self.get_all_targets(), - self.get_all_sources(), - env) + self.get_all_sources(), + env) for action in self.get_action_list()]) self._memo['get_contents'] = result return result diff --git a/src/engine/SCons/Memoize.py b/src/engine/SCons/Memoize.py index 9fe6851..ac728c9 100644 --- a/src/engine/SCons/Memoize.py +++ b/src/engine/SCons/Memoize.py @@ -20,6 +20,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/src/engine/SCons/MemoizeTests.py b/src/engine/SCons/MemoizeTests.py index b6750e0..06b4235 100644 --- a/src/engine/SCons/MemoizeTests.py +++ b/src/engine/SCons/MemoizeTests.py @@ -20,6 +20,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from six import add_metaclass __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -29,8 +30,8 @@ import unittest import SCons.Memoize - -class FakeObject(object, metaclass=SCons.Memoize.Memoized_Metaclass): +@add_metaclass(SCons.Memoize.Memoized_Metaclass) +class FakeObject(object): memoizer_counters = [] diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 22dca1f..91c6893 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -31,6 +31,7 @@ that can be used by scripts or modules looking for the canonical default. # 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. +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -54,7 +55,6 @@ import SCons.Util import SCons.Warnings from SCons.Debug import Trace -import collections do_store_info = True print_duplicate = 0 @@ -1509,7 +1509,7 @@ class Dir(Base): This clears any cached information that is invalidated by changing the repository.""" - for node in list(self.entries.values()): + for node in self.entries.values(): if node != self.dir: if node != self and isinstance(node, Dir): node.__clearRepositoryCache(duplicate) @@ -2056,7 +2056,7 @@ class Dir(Base): # We use the .name attribute from the Node because the keys of # the dir.entries dictionary are normalized (that is, all upper # case) on case-insensitive systems like Windows. - node_names = [ v.name for k, v in list(dir.entries.items()) + node_names = [ v.name for k, v in dir.entries.items() if k not in ('.', '..') ] names.extend(node_names) if not strings: @@ -3197,10 +3197,10 @@ class FileFinder(object): except KeyError: pass - if verbose and not isinstance(verbose, collections.Callable): + if verbose and not callable(verbose): if not SCons.Util.is_String(verbose): verbose = "find_file" - _verbose = ' %s: ' % verbose + _verbose = u' %s: ' % verbose verbose = lambda s: sys.stdout.write(_verbose + s) filedir, filename = os.path.split(filename) diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index e8442e9..66803f9 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -20,7 +20,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # - +from __future__ import division, print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -1305,7 +1305,7 @@ class FSTestCase(_tempdirTestCase): assert f1.get_contents() == "Foo\x1aBar", f1.get_contents() # This tests to make sure we can decode UTF-8 text files. - test_string = "Foo\x1aBar" + test_string = u"Foo\x1aBar" test.write("utf8_file", test_string.encode('utf-8')) f1 = fs.File(test.workpath("utf8_file")) assert eval('f1.get_text_contents() == u"Foo\x1aBar"'), \ diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 8f48d86..7f5d7ff 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -1197,8 +1197,8 @@ class Node(object): new_bkids = new.bsources + new.bdepends + new.bimplicit new_bkidsigs = new.bsourcesigs + new.bdependsigs + new.bimplicitsigs - osig = dict(list(zip(old_bkids, old_bkidsigs))) - nsig = dict(list(zip(new_bkids, new_bkidsigs))) + osig = dict(zip(old_bkids, old_bkidsigs)) + nsig = dict(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/Platform/__init__.py b/src/engine/SCons/Platform/__init__.py index 6ef8b05..dba3606 100644 --- a/src/engine/SCons/Platform/__init__.py +++ b/src/engine/SCons/Platform/__init__.py @@ -41,6 +41,7 @@ their own platform definition. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/src/engine/SCons/Platform/posix.py b/src/engine/SCons/Platform/posix.py index d1f6c78..908be4d 100644 --- a/src/engine/SCons/Platform/posix.py +++ b/src/engine/SCons/Platform/posix.py @@ -92,7 +92,7 @@ def _get_env_command(sh, escape, cmd, args, env): s = ' '.join(args) if env: l = ['env', '-'] + \ - [escape(t[0])+'='+escape(t[1]) for t in list(env.items())] + \ + [escape(t[0])+'='+escape(t[1]) for t in env.items()] + \ [sh, '-c', escape(s)] s = ' '.join(l) return s diff --git a/src/engine/SCons/SConf.py b/src/engine/SCons/SConf.py index e14c5e0..62f2671 100644 --- a/src/engine/SCons/SConf.py +++ b/src/engine/SCons/SConf.py @@ -25,6 +25,7 @@ Autoconf-like configuration support. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -118,7 +119,7 @@ def CreateConfigHBuilder(env): _stringConfigH) sconfigHBld = SCons.Builder.Builder(action=action) env.Append( BUILDERS={'SConfigHBuilder':sconfigHBld} ) - for k in list(_ac_config_hs.keys()): + for k in _ac_config_hs.keys(): env.SConfigHBuilder(k, env.Value(_ac_config_hs[k])) class SConfWarning(SCons.Warnings.Warning): @@ -175,19 +176,13 @@ class Streamer(object): """ def __init__(self, orig): self.orig = orig - try: - import StringIO - self.s = StringIO.StringIO() - except: - self.s = io.StringIO() + self.s = io.StringIO() def write(self, str): - try: - if self.orig: - self.orig.write(str) - self.s.write(str) - except: - print ('oops') + if self.orig: + self.orig.write(str) + self.s.write(str) + def writelines(self, lines): for l in lines: self.write(l + '\n') @@ -658,7 +653,7 @@ class SConfBase(object): """Adds all the tests given in the tests dictionary to this SConf instance """ - for name in list(tests.keys()): + for name in tests.keys(): self.AddTest(name, tests[name]) def _createDir( self, node ): diff --git a/src/engine/SCons/SConfTests.py b/src/engine/SCons/SConfTests.py index ba524fd..e604886 100644 --- a/src/engine/SCons/SConfTests.py +++ b/src/engine/SCons/SConfTests.py @@ -60,7 +60,7 @@ class SConfTestCase(unittest.TestCase): # We try to reset scons' state (including all global variables) import SCons.SConsign SCons.SConsign.write() # simulate normal scons-finish - for n in list(sys.modules.keys()): + for n in sys.modules.keys(): if n.split('.')[0] == 'SCons' and n[:12] != 'SCons.compat': m = sys.modules[n] if isinstance(m, ModuleType): diff --git a/src/engine/SCons/SConsign.py b/src/engine/SCons/SConsign.py index 5ce61be..ab8e297 100644 --- a/src/engine/SCons/SConsign.py +++ b/src/engine/SCons/SConsign.py @@ -26,6 +26,7 @@ Writing and reading information to the .sconsign file or files. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -172,7 +173,7 @@ class Base(object): pass def merge(self): - for key, node in list(self.to_be_merged.items()): + for key, node in self.to_be_merged.items(): entry = node.get_stored_info() try: ninfo = entry.ninfo @@ -218,7 +219,7 @@ class DB(Base): except Exception as e: SCons.Warnings.warn(SCons.Warnings.CorruptSConsignWarning, "Ignoring corrupt sconsign entry : %s (%s)\n"%(self.dir.tpath, e)) - for key, entry in list(self.entries.items()): + for key, entry in self.entries.items(): entry.convert_from_sconsign(dir, key) if mode == "r": @@ -245,7 +246,7 @@ class DB(Base): # the Repository; we only write to our own .sconsign file, # not to .sconsign files in Repositories. path = normcase(self.dir.path) - for key, entry in list(self.entries.items()): + for key, entry in self.entries.items(): entry.convert_to_sconsign() db[path] = pickle.dumps(self.entries, 1) @@ -333,7 +334,7 @@ class DirFile(Dir): fname = self.sconsign except IOError: return - for key, entry in list(self.entries.items()): + for key, entry in self.entries.items(): entry.convert_to_sconsign() pickle.dump(self.entries, file, 1) file.close() diff --git a/src/engine/SCons/Scanner/Fortran.py b/src/engine/SCons/Scanner/Fortran.py index 5339ab2..1b55130 100644 --- a/src/engine/SCons/Scanner/Fortran.py +++ b/src/engine/SCons/Scanner/Fortran.py @@ -35,7 +35,6 @@ import SCons.Node.FS import SCons.Scanner import SCons.Util import SCons.Warnings -import collections class F90Scanner(SCons.Scanner.Classic): """ @@ -110,7 +109,7 @@ class F90Scanner(SCons.Scanner.Classic): # is actually found in a Repository or locally. nodes = [] source_dir = node.get_dir() - if isinstance(path, collections.Callable): + if callable(path): path = path() for dep in mods_and_includes: n, i = self.find_include(dep, source_dir, path) diff --git a/src/engine/SCons/Scanner/LaTeX.py b/src/engine/SCons/Scanner/LaTeX.py index 1e0fea1..2cb1ed5 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 list(dictionary.items()): + for k,n in dictionary.items(): self.dictionary[k] = ( SCons.Scanner.FindPathDirs(n), FindENVPathDirs(n) ) def __call__(self, env, dir=None, target=None, source=None, argument=None): di = {} - for k,(c,cENV) in list(self.dictionary.items()): + for k,(c,cENV) in self.dictionary.items(): di[k] = ( c(env, dir=None, target=None, source=None, argument=None) , cENV(env, dir=None, target=None, source=None, diff --git a/src/engine/SCons/Scanner/Prog.py b/src/engine/SCons/Scanner/Prog.py index 6e2da21..49e93a5 100644 --- a/src/engine/SCons/Scanner/Prog.py +++ b/src/engine/SCons/Scanner/Prog.py @@ -27,7 +27,6 @@ import SCons.Node import SCons.Node.FS import SCons.Scanner import SCons.Util -import collections # global, set by --debug=findlibs print_find_libs = None @@ -77,7 +76,7 @@ def scan(node, env, libpath = ()): result = [] - if isinstance(libpath, collections.Callable): + if callable(libpath): libpath = libpath() find_file = SCons.Node.FS.find_file diff --git a/src/engine/SCons/Scanner/ProgTests.py b/src/engine/SCons/Scanner/ProgTests.py index f564c91..250838d 100644 --- a/src/engine/SCons/Scanner/ProgTests.py +++ b/src/engine/SCons/Scanner/ProgTests.py @@ -230,7 +230,7 @@ def suite(): suite.addTest(ProgramScannerTestCase6()) suite.addTest(ProgramScannerTestCase7()) suite.addTest(ProgramScannerTestCase8()) - try: str + try: unicode except NameError: pass else: code = """if 1: diff --git a/src/engine/SCons/Scanner/ScannerTests.py b/src/engine/SCons/Scanner/ScannerTests.py index 5a4639d..ee26922 100644 --- a/src/engine/SCons/Scanner/ScannerTests.py +++ b/src/engine/SCons/Scanner/ScannerTests.py @@ -569,7 +569,7 @@ class ClassicCPPTestCase(unittest.TestCase): assert n == 'path/bbb', n assert i == 'bbb', i - n, i = s.find_include(('<', 'ccc'), 'foo', ('path',)) + n, i = s.find_include(('<', u'ccc'), 'foo', ('path',)) assert n == 'path/ccc', n assert i == 'ccc', i diff --git a/src/engine/SCons/Scanner/__init__.py b/src/engine/SCons/Scanner/__init__.py index b947961..2375bc4 100644 --- a/src/engine/SCons/Scanner/__init__.py +++ b/src/engine/SCons/Scanner/__init__.py @@ -33,7 +33,6 @@ import re import SCons.Node.FS import SCons.Util -import collections class _Null(object): @@ -179,7 +178,7 @@ class Base(object): self.node_class = node_class self.node_factory = node_factory self.scan_check = scan_check - if isinstance(recursive, collections.Callable): + if callable(recursive): self.recurse_nodes = recursive elif recursive: self.recurse_nodes = self._recurse_all_nodes @@ -370,7 +369,7 @@ class Classic(Current): # is actually found in a Repository or locally. nodes = [] source_dir = node.get_dir() - if isinstance(path, collections.Callable): + if callable(path): path = path() for include in includes: n, i = self.find_include(include, source_dir, path) diff --git a/src/engine/SCons/Script/Interactive.py b/src/engine/SCons/Script/Interactive.py index 87fe1cf..0b28f1a 100644 --- a/src/engine/SCons/Script/Interactive.py +++ b/src/engine/SCons/Script/Interactive.py @@ -19,6 +19,7 @@ # 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. +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -120,7 +121,7 @@ class SConsInteractiveCmd(cmd.Cmd): def __init__(self, **kw): cmd.Cmd.__init__(self) - for key, val in list(kw.items()): + for key, val in kw.items(): setattr(self, key, val) if sys.platform == 'win32': @@ -249,7 +250,7 @@ class SConsInteractiveCmd(cmd.Cmd): while n: n = walker.get_next() - for node in list(seen_nodes.keys()): + for node in 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 9a52937..584960b 100644 --- a/src/engine/SCons/Script/Main.py +++ b/src/engine/SCons/Script/Main.py @@ -10,6 +10,8 @@ some other module. If it's specific to the "scons" script invocation, it goes here. """ +from __future__ import print_function + unsupported_python_version = (2, 3, 0) deprecated_python_version = (2, 7, 0) @@ -68,7 +70,6 @@ import SCons.Util import SCons.Warnings import SCons.Script.Interactive -import collections def fetch_win32_parallel_msg(): # A subsidiary function that exists solely to isolate this import @@ -105,7 +106,7 @@ class Progressor(object): self.interval = interval self.overwrite = overwrite - if isinstance(obj, collections.Callable): + if callable(obj): self.func = obj elif SCons.Util.is_List(obj): self.func = self.spinner @@ -716,7 +717,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 list(m.__dict__.keys()): + for k in 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 559db97..a97fc94 100644 --- a/src/engine/SCons/Script/SConsOptions.py +++ b/src/engine/SCons/Script/SConsOptions.py @@ -611,7 +611,7 @@ def Parser(version): deprecated_debug_options=deprecated_debug_options): if value in debug_options: parser.values.debug.append(value) - elif value in list(deprecated_debug_options.keys()): + elif value in 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 05cb6a6..b2dc4c1 100644 --- a/src/engine/SCons/Script/SConscript.py +++ b/src/engine/SCons/Script/SConscript.py @@ -26,7 +26,7 @@ files. # 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. - +from __future__ import division, print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -529,7 +529,7 @@ class SConsEnvironment(SCons.Environment.Base): return x ls = list(map(subst_element, ls)) subst_kw = {} - for key, val in list(kw.items()): + for key, val in kw.items(): if SCons.Util.is_String(val): val = self.subst(val) elif SCons.Util.is_List(val): diff --git a/src/engine/SCons/Subst.py b/src/engine/SCons/Subst.py index cca9bbc..f1e80ac 100644 --- a/src/engine/SCons/Subst.py +++ b/src/engine/SCons/Subst.py @@ -472,7 +472,7 @@ def scons_subst(strSubst, env, mode=SUBST_RAW, target=None, source=None, gvars={ def func(l, conv=self.conv, substitute=self.substitute, lvars=lvars): return conv(substitute(l, lvars)) return list(map(func, s)) - elif isinstance(s, collections.Callable): + elif callable(s): try: s = s(target=lvars['TARGETS'], source=lvars['SOURCES'], @@ -681,7 +681,7 @@ def scons_subst_list(strSubst, env, mode=SUBST_RAW, target=None, source=None, gv for a in s: self.substitute(a, lvars, 1) self.next_word() - elif isinstance(s, collections.Callable): + elif callable(s): try: s = s(target=lvars['TARGETS'], source=lvars['SOURCES'], diff --git a/src/engine/SCons/SubstTests.py b/src/engine/SCons/SubstTests.py index da21020..7001899 100644 --- a/src/engine/SCons/SubstTests.py +++ b/src/engine/SCons/SubstTests.py @@ -20,6 +20,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/src/engine/SCons/Taskmaster.py b/src/engine/SCons/Taskmaster.py index 14ffe8c..86bff53 100644 --- a/src/engine/SCons/Taskmaster.py +++ b/src/engine/SCons/Taskmaster.py @@ -19,6 +19,7 @@ # 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. +from __future__ import print_function __doc__ = """ Generic Taskmaster module for the SCons build engine. @@ -164,7 +165,7 @@ class Task(object): """ global print_prepare T = self.tm.trace - if T: T.write(self.trace_message('Task.prepare()', self.node)) + if T: T.write(self.trace_message(u'Task.prepare()', self.node)) # Now that it's the appropriate time, give the TaskMaster a # chance to raise any exceptions it encountered while preparing @@ -224,7 +225,7 @@ class Task(object): prepare(), executed() or failed(). """ T = self.tm.trace - if T: T.write(self.trace_message('Task.execute()', self.node)) + if T: T.write(self.trace_message(u'Task.execute()', self.node)) try: cached_targets = [] @@ -383,7 +384,7 @@ class Task(object): This is the default behavior for building only what's necessary. """ T = self.tm.trace - if T: T.write(self.trace_message('Task.make_ready_current()', + if T: T.write(self.trace_message(u'Task.make_ready_current()', self.node)) self.out_of_date = [] @@ -428,7 +429,7 @@ class Task(object): that can be put back on the candidates list. """ T = self.tm.trace - if T: T.write(self.trace_message('Task.postprocess()', self.node)) + if T: T.write(self.trace_message(u'Task.postprocess()', self.node)) # We may have built multiple targets, some of which may have # common parents waiting for this build. Count up how many @@ -445,7 +446,7 @@ class Task(object): # A node can only be in the pending_children set if it has # some waiting_parents. if t.waiting_parents: - if T: T.write(self.trace_message('Task.postprocess()', + if T: T.write(self.trace_message(u'Task.postprocess()', t, 'removing')) pending_children.discard(t) @@ -462,9 +463,9 @@ class Task(object): if p.ref_count == 0: self.tm.candidates.append(p) - for p, subtract in list(parents.items()): + for p, subtract in parents.items(): p.ref_count = p.ref_count - subtract - if T: T.write(self.trace_message('Task.postprocess()', + if T: T.write(self.trace_message(u'Task.postprocess()', p, 'adjusted parent ref count')) if p.ref_count == 0: @@ -744,12 +745,12 @@ class Taskmaster(object): self.ready_exc = None T = self.trace - if T: T.write('\n' + self.trace_message('Looking for a node to evaluate')) + if T: T.write(u'\n' + self.trace_message('Looking for a node to evaluate')) while True: node = self.next_candidate() if node is None: - if T: T.write(self.trace_message('No candidate anymore.') + '\n') + if T: T.write(self.trace_message('No candidate anymore.') + u'\n') return None node = node.disambiguate() @@ -772,7 +773,7 @@ class Taskmaster(object): else: S = None - if T: T.write(self.trace_message(' Considering node %s and its children:' % self.trace_node(node))) + if T: T.write(self.trace_message(u' Considering node %s and its children:' % self.trace_node(node))) if state == NODE_NO_STATE: # Mark this node as being on the execution stack: @@ -780,7 +781,7 @@ class Taskmaster(object): elif state > NODE_PENDING: # Skip this node if it has already been evaluated: if S: S.already_handled = S.already_handled + 1 - if T: T.write(self.trace_message(' already handled (executed)')) + if T: T.write(self.trace_message(u' already handled (executed)')) continue executor = node.get_executor() @@ -811,7 +812,7 @@ class Taskmaster(object): for child in chain(executor.get_all_prerequisites(), children): childstate = child.get_state() - if T: T.write(self.trace_message(' ' + self.trace_node(child))) + if T: T.write(self.trace_message(u' ' + self.trace_node(child))) if childstate == NODE_NO_STATE: children_not_visited.append(child) @@ -870,7 +871,7 @@ class Taskmaster(object): # count so we can be put back on the list for # re-evaluation when they've all finished. node.ref_count = node.ref_count + child.add_to_waiting_parents(node) - if T: T.write(self.trace_message(' adjusted ref count: %s, child %s' % + if T: T.write(self.trace_message(u' adjusted ref count: %s, child %s' % (self.trace_node(node), repr(str(child))))) if T: @@ -896,7 +897,7 @@ class Taskmaster(object): # The default when we've gotten through all of the checks above: # this node is ready to be built. if S: S.build = S.build + 1 - if T: T.write(self.trace_message('Evaluating %s\n' % + if T: T.write(self.trace_message(u'Evaluating %s\n' % self.trace_node(node))) # For debugging only: diff --git a/src/engine/SCons/TaskmasterTests.py b/src/engine/SCons/TaskmasterTests.py index 0140278..278b690 100644 --- a/src/engine/SCons/TaskmasterTests.py +++ b/src/engine/SCons/TaskmasterTests.py @@ -20,7 +20,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # - +from __future__ import division __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/src/engine/SCons/Tool/FortranCommon.py b/src/engine/SCons/Tool/FortranCommon.py index c21128e..088c717 100644 --- a/src/engine/SCons/Tool/FortranCommon.py +++ b/src/engine/SCons/Tool/FortranCommon.py @@ -26,6 +26,7 @@ Stuff for processing Fortran, common to all fortran dialects. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -167,7 +168,7 @@ def add_fortran_to_env(env): except KeyError: FortranSuffixes = ['.f', '.for', '.ftn'] - #print "Adding %s to fortran suffixes" % FortranSuffixes + #print("Adding %s to fortran suffixes" % FortranSuffixes) try: FortranPPSuffixes = env['FORTRANPPFILESUFFIXES'] except KeyError: @@ -191,7 +192,7 @@ def add_f77_to_env(env): except KeyError: F77Suffixes = ['.f77'] - #print "Adding %s to f77 suffixes" % F77Suffixes + #print("Adding %s to f77 suffixes" % F77Suffixes) try: F77PPSuffixes = env['F77PPFILESUFFIXES'] except KeyError: diff --git a/src/engine/SCons/Tool/MSCommon/common.py b/src/engine/SCons/Tool/MSCommon/common.py index dcf69c8..e1b4820 100644 --- a/src/engine/SCons/Tool/MSCommon/common.py +++ b/src/engine/SCons/Tool/MSCommon/common.py @@ -20,6 +20,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -113,7 +114,7 @@ def normalize_env(env, keys, force=False): Note: the environment is copied.""" normenv = {} if env: - for k in list(env.keys()): + for k in env.keys(): normenv[k] = copy.deepcopy(env[k]).encode('mbcs') for k in keys: @@ -217,7 +218,7 @@ def parse_output(output, keep = ("INCLUDE", "LIB", "LIBPATH", "PATH")): dkeep[key].append(p) for line in output.splitlines(): - for k,v in list(rdk.items()): + for k,v in rdk.items(): m = v.match(line) if m: add_env(m, k) diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py index 35b95d5..1a221ac 100644 --- a/src/engine/SCons/Tool/MSCommon/vc.py +++ b/src/engine/SCons/Tool/MSCommon/vc.py @@ -468,7 +468,7 @@ def msvc_setup_env(env): SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning, warn_msg) return None - for k, v in list(d.items()): + for k, v in d.items(): debug('vc.py:msvc_setup_env() env:%s -> %s'%(k,v)) env.PrependENVPath(k, v, delete_existing=True) diff --git a/src/engine/SCons/Tool/MSCommon/vs.py b/src/engine/SCons/Tool/MSCommon/vs.py index 3219719..0a170fb 100644 --- a/src/engine/SCons/Tool/MSCommon/vs.py +++ b/src/engine/SCons/Tool/MSCommon/vs.py @@ -536,7 +536,7 @@ def msvs_setup_env(env): env['ENV'] = save_ENV vars = parse_output(output, vars) - for k, v in list(vars.items()): + for k, v in vars.items(): env.PrependENVPath(k, v, delete_existing=1) def query_versions(): diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index 1d5b504..517b987 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -34,6 +34,7 @@ tool definition. # 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. +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -631,7 +632,7 @@ class ToolInitializer(object): so we no longer copy and re-bind them when the construction environment gets cloned. """ - for method in list(self.methods.values()): + for method in self.methods.values(): env.RemoveMethod(method) def apply_tools(self, env): diff --git a/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/docbook.py b/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/docbook.py index ef03206..e7b8cfa 100644 --- a/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/docbook.py +++ b/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/docbook.py @@ -1,5 +1,6 @@ # docbook.py: extension module # $Id: docbook.py 8353 2009-03-17 16:57:50Z mzjn $ +from __future__ import print_function import sys import string diff --git a/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/xslt.py b/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/xslt.py index 8554dd1..77ca0de 100644 --- a/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/xslt.py +++ b/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/xslt.py @@ -1,5 +1,6 @@ #!/usr/bin/python -u # $Id: xslt.py 8353 2009-03-17 16:57:50Z mzjn $ +from __future__ import print_function import sys import libxml2 diff --git a/src/engine/SCons/Tool/install.py b/src/engine/SCons/Tool/install.py index 4236e81..0d75765 100644 --- a/src/engine/SCons/Tool/install.py +++ b/src/engine/SCons/Tool/install.py @@ -29,6 +29,7 @@ selection method. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/src/engine/SCons/Tool/intelc.py b/src/engine/SCons/Tool/intelc.py index 8b178a7..86c6e12 100644 --- a/src/engine/SCons/Tool/intelc.py +++ b/src/engine/SCons/Tool/intelc.py @@ -30,7 +30,7 @@ selection method. # 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. - +from __future__ import division, print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -438,14 +438,14 @@ def generate(env, version=None, abi=None, topdir=None, verbose=0): 'LIB' : libdir, 'PATH' : bindir, 'LD_LIBRARY_PATH' : libdir} - for p in list(paths.keys()): + for p in 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 list(paths.keys()): + for p in 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/link.py b/src/engine/SCons/Tool/link.py index 864a018..c7c6790 100644 --- a/src/engine/SCons/Tool/link.py +++ b/src/engine/SCons/Tool/link.py @@ -30,6 +30,7 @@ selection method. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/src/engine/SCons/Tool/mslink.py b/src/engine/SCons/Tool/mslink.py index b56d34a..f30c1d3 100644 --- a/src/engine/SCons/Tool/mslink.py +++ b/src/engine/SCons/Tool/mslink.py @@ -30,6 +30,7 @@ selection method. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -183,7 +184,7 @@ def prog_emitter(target, source, env): # MSVC 11 and above need the PCH object file to be added to the link line, # otherwise you get link error LNK2011. pchobj = SCons.Util.splitext(str(env['PCH']))[0] + '.obj' - # print "prog_emitter, version %s, appending pchobj %s"%(version_num, pchobj) + # print("prog_emitter, version %s, appending pchobj %s"%(version_num, pchobj)) if pchobj not in extrasources: extrasources.append(pchobj) diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py index 0879a28..370af9a 100644 --- a/src/engine/SCons/Tool/msvs.py +++ b/src/engine/SCons/Tool/msvs.py @@ -29,6 +29,7 @@ selection method. # 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. +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -357,7 +358,7 @@ class _DSPGenerator(object): AddConfig(self, variants[i], buildtarget[i], outdir[i], runfile[i], cmdargs) self.platforms = [] - for key in list(self.configs.keys()): + for key in self.configs.keys(): platform = self.configs[key].platform if not platform in self.platforms: self.platforms.append(platform) @@ -480,7 +481,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(list(categories.keys()), key=lambda a: a.lower()): + for kind in sorted(categories.keys(), key=lambda a: a.lower()): if not self.sources[kind]: continue # skip empty groups @@ -744,7 +745,7 @@ class _GenerateV7DSP(_DSPGenerator): self.file.write(pdata + '-->\n') def printSources(self, hierarchy, commonprefix): - sorteditems = sorted(list(hierarchy.items()), key=lambda a: a[0].lower()) + sorteditems = sorted(hierarchy.items(), key=lambda a: a[0].lower()) # First folders, then files for key, value in sorteditems: @@ -774,7 +775,7 @@ class _GenerateV7DSP(_DSPGenerator): self.file.write('\t\n') - cats = sorted([k for k in list(categories.keys()) if self.sources[k]], + cats = sorted([k for k in categories.keys() if self.sources[k]], key=lambda a: a.lower()) for kind in cats: if len(cats) > 1: @@ -1055,7 +1056,7 @@ class _GenerateV10DSP(_DSPGenerator): self.file.write(pdata + '-->\n') def printFilters(self, hierarchy, name): - sorteditems = sorted(list(hierarchy.items()), key = lambda a: a[0].lower()) + sorteditems = sorted(hierarchy.items(), key = lambda a: a[0].lower()) for key, value in sorteditems: if SCons.Util.is_Dict(value): @@ -1072,7 +1073,7 @@ class _GenerateV10DSP(_DSPGenerator): 'Resource Files': 'None', 'Other Files': 'None'} - sorteditems = sorted(list(hierarchy.items()), key = lambda a: a[0].lower()) + sorteditems = sorted(hierarchy.items(), key = lambda a: a[0].lower()) # First folders, then files for key, value in sorteditems: @@ -1098,7 +1099,7 @@ class _GenerateV10DSP(_DSPGenerator): '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 list(categories.keys()) if self.sources[k]], + cats = sorted([k for k in categories.keys() if self.sources[k]], key = lambda a: a.lower()) # print vcxproj.filters file first @@ -1254,7 +1255,7 @@ class _GenerateV7DSW(_DSWGenerator): AddConfig(self, variant) self.platforms = [] - for key in list(self.configs.keys()): + for key in 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 1466db6..1f5fb2b 100644 --- a/src/engine/SCons/Tool/msvsTests.py +++ b/src/engine/SCons/Tool/msvsTests.py @@ -20,6 +20,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/src/engine/SCons/Tool/packaging/__init__.py b/src/engine/SCons/Tool/packaging/__init__.py index c3de2aa..345ec87 100644 --- a/src/engine/SCons/Tool/packaging/__init__.py +++ b/src/engine/SCons/Tool/packaging/__init__.py @@ -72,7 +72,7 @@ def Tag(env, target, source, *more_tags, **kw_tags): target=env.Flatten(target) for t in target: - for (k,v) in list(kw_tags.items()): + for (k,v) in kw_tags.items(): # all file tags have to start with PACKAGING_, so we can later # differentiate between "normal" object attributes and the # packaging attributes. As the user should not be bothered with diff --git a/src/engine/SCons/Tool/packaging/ipk.py b/src/engine/SCons/Tool/packaging/ipk.py index ad27a62..6549445 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 list(opened_files.values()): + for f in 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 70fdc48..49c28ca 100644 --- a/src/engine/SCons/Tool/packaging/msi.py +++ b/src/engine/SCons/Tool/packaging/msi.py @@ -172,7 +172,7 @@ def generate_guids(root): # find all XMl nodes matching the key, retrieve their attribute, hash their # subtree, convert hash to string and add as a attribute to the xml node. - for (key,value) in list(needs_id.items()): + for (key,value) in needs_id.items(): node_list = root.getElementsByTagName(key) attribute = value for node in node_list: @@ -335,7 +335,7 @@ def build_wxsfile_file_section(root, files, NAME, VERSION, VENDOR, filename_set, } # fill in the default tags given above. - for k,v in [ (k, v) for (k,v) in list(h.items()) if not hasattr(file, k) ]: + for k,v in [ (k, v) for (k,v) in h.items() if not hasattr(file, k) ]: setattr( file, k, v ) File = factory.createElement( 'File' ) @@ -382,7 +382,7 @@ def build_wxsfile_features_section(root, files, NAME, VERSION, SUMMARY, id_set): Feature.attributes['Description'] = escape( SUMMARY ) Feature.attributes['Display'] = 'expand' - for (feature, files) in list(create_feature_dict(files).items()): + for (feature, files) in create_feature_dict(files).items(): SubFeature = factory.createElement('Feature') SubFeature.attributes['Level'] = '1' diff --git a/src/engine/SCons/Tool/packaging/rpm.py b/src/engine/SCons/Tool/packaging/rpm.py index 4958065..a9e0fa2 100644 --- a/src/engine/SCons/Tool/packaging/rpm.py +++ b/src/engine/SCons/Tool/packaging/rpm.py @@ -277,7 +277,7 @@ def build_specfile_filesection(spec, files): for file in files: # build the tagset tags = {} - for k in list(supported_tags.keys()): + for k in supported_tags.keys(): try: tags[k]=getattr(file, k) except AttributeError: @@ -340,7 +340,7 @@ class SimpleTagCompiler(object): for key, replacement in international: try: #int_values_for_key = [ (get_country_code(k),v) for k,v in values.items() if strip_country_code(k) == key ] - x = [t for t in list(values.items()) if strip_country_code(t[0]) == key] + x = [t for t in values.items() if strip_country_code(t[0]) == key] int_values_for_key = [(get_country_code(t[0]),t[1]) for t in x] for v in int_values_for_key: str = str + replacement % v diff --git a/src/engine/SCons/Tool/qt.py b/src/engine/SCons/Tool/qt.py index fdfdd26..723c39c 100644 --- a/src/engine/SCons/Tool/qt.py +++ b/src/engine/SCons/Tool/qt.py @@ -31,6 +31,7 @@ selection method. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/src/engine/SCons/Tool/rpmutils.py b/src/engine/SCons/Tool/rpmutils.py index e96c54c..a444508 100644 --- a/src/engine/SCons/Tool/rpmutils.py +++ b/src/engine/SCons/Tool/rpmutils.py @@ -34,6 +34,7 @@ exact syntax. # 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. +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/src/engine/SCons/Tool/tex.py b/src/engine/SCons/Tool/tex.py index febec35..dac98b7 100644 --- a/src/engine/SCons/Tool/tex.py +++ b/src/engine/SCons/Tool/tex.py @@ -31,6 +31,7 @@ selection method. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/src/engine/SCons/Tool/textfile.py b/src/engine/SCons/Tool/textfile.py index 4897113..693b62b 100644 --- a/src/engine/SCons/Tool/textfile.py +++ b/src/engine/SCons/Tool/textfile.py @@ -54,7 +54,6 @@ import re from SCons.Node import Node from SCons.Node.Python import Value from SCons.Util import is_String, is_Sequence, is_Dict -import collections def _do_subst(node, subs): """ @@ -97,7 +96,7 @@ def _action(target, source, env): raise SCons.Errors.UserError('SUBST_DICT must be dict or sequence') subs = [] for (k,v) in d: - if isinstance(v, collections.Callable): + if callable(v): v = v() if is_String(v): v = env.subst(v) diff --git a/src/engine/SCons/Tool/xgettext.py b/src/engine/SCons/Tool/xgettext.py index 489d4d7..f9375a2 100644 --- a/src/engine/SCons/Tool/xgettext.py +++ b/src/engine/SCons/Tool/xgettext.py @@ -23,6 +23,7 @@ Tool specific initialization of `xgettext` tool. # 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. +from six import u __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -55,7 +56,7 @@ class _CmdRunner(object): proc = SCons.Action._subproc(env, command, **kw) self.out, self.err = proc.communicate() self.status = proc.wait() - if self.err: sys.stderr.write(str(self.err)) + if self.err: sys.stderr.write(u(self.err)) return self.status def strfunction(self, target, source, env): diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 0c4daff..60e5c10 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -23,6 +23,7 @@ Various utility functions go here. # 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. +from six import PY2, PY3, u __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -32,14 +33,22 @@ import copy import re import types -from collections import UserDict, UserList, UserString -import collections +try: + from collections import UserDict, UserList, UserString +except ImportError: # Python < 3 + from UserDict import UserDict + from UserList import UserList + from UserString import UserString # Don't "from types import ..." these because we need to get at the # types module later to look for UnicodeType. +try: + InstanceType = types.InstanceType +except AttributeError: # Python 3 + InstanceType = None MethodType = types.MethodType FunctionType = types.FunctionType -try: str +try: unicode except NameError: UnicodeType = None else: UnicodeType = str @@ -111,9 +120,12 @@ class NodeList(UserList): >>> someList.strip() [ 'foo', 'bar' ] """ - def __bool__(self): + def __nonzero__(self): return len(self.data) != 0 + def __bool__(self): + return self.__nonzero__() + def __str__(self): return ' '.join(map(str, self.data)) @@ -153,7 +165,7 @@ class DisplayEngine(object): return if append_newline: text = text + '\n' try: - sys.stdout.write(str(text)) + sys.stdout.write(u(text)) except IOError: # Stdout might be connected to a pipe that has been closed # by now. The most likely reason for the pipe being closed @@ -239,7 +251,7 @@ def print_tree(root, child_func, prune=0, showtags=0, margin=[0], visited={}): ' N = no clean\n' + ' H = no cache\n' + '\n') - sys.stdout.write(str(legend)) + sys.stdout.write(u(legend)) tags = ['['] tags.append(' E'[IDX(root.exists())]) @@ -264,10 +276,10 @@ def print_tree(root, child_func, prune=0, showtags=0, margin=[0], visited={}): children = child_func(root) if prune and rname in visited and children: - sys.stdout.write(''.join(tags + margins + ['+-[', rname, ']']) + '\n') + sys.stdout.write(''.join(tags + margins + ['+-[', rname, ']']) + u'\n') return - sys.stdout.write(''.join(tags + margins + ['+-', rname]) + '\n') + sys.stdout.write(''.join(tags + margins + ['+-', rname]) + u'\n') visited[rname] = 1 @@ -303,11 +315,17 @@ SequenceTypes = (list, tuple, UserList) # Note that profiling data shows a speed-up when comparing # explicitely with str and unicode instead of simply comparing # with basestring. (at least on Python 2.5.1) -StringTypes = (str, str, UserString) +try: + StringTypes = (str, unicode, UserString) +except NameError: + StringTypes = (str, UserString) # Empirically, it is faster to check explicitely for str and # unicode than for basestring. -BaseStringTypes = (str, str) +try: + BaseStringTypes = (str, unicode) +except NameError: + BaseStringTypes = (str) def is_Dict(obj, isinstance=isinstance, DictTypes=DictTypes): return isinstance(obj, DictTypes) @@ -440,7 +458,7 @@ _semi_deepcopy_dispatch = d = {} def semi_deepcopy_dict(x, exclude = [] ): copy = {} - for key, val in list(x.items()): + for key, val in x.items(): # The regular Python copy.deepcopy() also deepcopies the key, # as follows: # @@ -465,7 +483,7 @@ def semi_deepcopy(x): if copier: return copier(x) else: - if hasattr(x, '__semi_deepcopy__') and isinstance(x.__semi_deepcopy__, collections.Callable): + if hasattr(x, '__semi_deepcopy__') and callable(x.__semi_deepcopy__): return x.__semi_deepcopy__() elif isinstance(x, UserDict): return x.__class__(semi_deepcopy_dict(x)) @@ -979,7 +997,7 @@ class OrderedDict(UserDict): if key not in self._keys: self._keys.append(key) def update(self, dict): - for (key, val) in list(dict.items()): + for (key, val) in dict.items(): self.__setitem__(key, val) def values(self): @@ -1001,7 +1019,7 @@ class Selector(OrderedDict): # Try to perform Environment substitution on the keys of # the dictionary before giving up. s_dict = {} - for (k,v) in list(self.items()): + for (k,v) in self.items(): if k is not None: s_k = env.subst(k) if s_k in s_dict: @@ -1346,8 +1364,9 @@ def make_path_relative(path): def AddMethod(obj, function, name=None): """ - Adds either a bound method to an instance or an unbound method to - a class. If name is ommited the name of the specified function + Adds either a bound method to an instance or the function itself + (or an unbound method in Python 2) to a class. + If name is ommited the name of the specified function is used by default. Example: a = A() @@ -1366,9 +1385,15 @@ def AddMethod(obj, function, name=None): if hasattr(obj, '__class__') and obj.__class__ is not type: # "obj" is an instance, so it gets a bound method. - setattr(obj, name, MethodType(function, obj, obj.__class__)) + if PY3: + method = MethodType(function, obj) + else: + method = MethodType(function, obj, obj.__class__) + setattr(obj, name, method) else: # "obj" is a class, so it gets an unbound method. + if PY2: + function = MethodType(function, None, obj) setattr(obj, name, function) def RenameFunction(function, name): @@ -1461,6 +1486,8 @@ class Null(object): return self def __repr__(self): return "Null(0x%08X)" % id(self) + def __nonzero__(self): + return False def __bool__(self): return False def __getattr__(self, name): diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py index a30404c..5666f36 100644 --- a/src/engine/SCons/UtilTests.py +++ b/src/engine/SCons/UtilTests.py @@ -20,6 +20,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from six import u __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -285,16 +286,16 @@ class UtilTestCase(unittest.TestCase): assert to_String(s2) == 'foo', s2 if HasUnicode: - s3=UserString(str('bar')) + s3=UserString(unicode('bar')) assert to_String(s3) == s3, s3 - assert to_String(s3) == str('bar'), s3 - assert isinstance(to_String(s3), str), \ + assert to_String(s3) == unicode('bar'), s3 + assert isinstance(to_String(s3), unicode), \ type(to_String(s3)) if HasUnicode: - s4 = str('baz') - assert to_String(s4) == str('baz'), to_String(s4) - assert isinstance(to_String(s4), str), \ + s4 = unicode('baz') + assert to_String(s4) == unicode('baz'), to_String(s4) + assert isinstance(to_String(s4), unicode), \ type(to_String(s4)) def test_WhereIs(self): @@ -681,7 +682,7 @@ bling fobj = io.StringIO(content) except TypeError: # Python 2.7 and beyond require unicode strings. - fobj = io.StringIO(str(content)) + fobj = io.StringIO(u(content)) lines = LogicalLines(fobj).readlines() assert lines == [ @@ -696,7 +697,7 @@ bling s1 = silent_intern("spam") # Python 3.x does not have a unicode() global function if sys.version[0] == '2': - s2 = silent_intern(str("unicode spam")) + s2 = silent_intern(unicode("unicode spam")) s3 = silent_intern(42) s4 = silent_intern("spam") assert id(s1) == id(s4) diff --git a/src/engine/SCons/Variables/EnumVariableTests.py b/src/engine/SCons/Variables/EnumVariableTests.py index 4feb712..f4b600d 100644 --- a/src/engine/SCons/Variables/EnumVariableTests.py +++ b/src/engine/SCons/Variables/EnumVariableTests.py @@ -122,7 +122,7 @@ class EnumVariableTestCase(unittest.TestCase): 'C' : ['C', 'three', 'three'], } - for k, l in list(table.items()): + for k, l in table.items(): x = o0.converter(k) assert x == l[0], "o0 got %s, expected %s" % (x, l[0]) x = o1.converter(k) @@ -186,7 +186,7 @@ class EnumVariableTestCase(unittest.TestCase): 'no_v' : [invalid, invalid, invalid], } - for v, l in list(table.items()): + for v, l in table.items(): l[0](o0, v) l[1](o1, v) l[2](o2, v) diff --git a/src/engine/SCons/Variables/__init__.py b/src/engine/SCons/Variables/__init__.py index 8d15b8d..1c8d834 100644 --- a/src/engine/SCons/Variables/__init__.py +++ b/src/engine/SCons/Variables/__init__.py @@ -180,7 +180,7 @@ class Variables(object): if args is None: args = self.args - for arg, value in list(args.items()): + for arg, value in args.items(): added = False for option in self.options: if arg in list(option.aliases) + [ option.key ]: diff --git a/src/engine/SCons/compat/_scons_subprocess.py b/src/engine/SCons/compat/_scons_subprocess.py index 72581f7..e4ac777 100644 --- a/src/engine/SCons/compat/_scons_subprocess.py +++ b/src/engine/SCons/compat/_scons_subprocess.py @@ -351,6 +351,8 @@ except that: """ +from __future__ import print_function +from six import integer_types import sys mswindows = (sys.platform == "win32") @@ -444,15 +446,15 @@ else: def is_int(obj): return isinstance(obj, int) def is_int_or_long(obj): - return isinstance(obj, int) + return isinstance(obj, integer_types) try: - str + types.StringTypes except AttributeError: try: - str = (str, str) + types.StringTypes = (str, unicode) except NameError: - str = (str,) + types.StringTypes = (str,) def is_string(obj): return isinstance(obj, str) @@ -785,7 +787,7 @@ class Popen(object): errread, errwrite): """Execute program (MS Windows version)""" - if not isinstance(args, str): + if not isinstance(args, types.StringTypes): args = list2cmdline(args) # Process startup details diff --git a/src/engine/SCons/cpp.py b/src/engine/SCons/cpp.py index 4cc771b..0ba10f5 100644 --- a/src/engine/SCons/cpp.py +++ b/src/engine/SCons/cpp.py @@ -31,7 +31,6 @@ import SCons.compat import os import re -import collections # # First "subsystem" of regular expressions that we set up: @@ -73,7 +72,7 @@ cpp_lines_dict = { # the corresponding compiled regular expression that fetches the arguments # we care about. Table = {} -for op_list, expr in list(cpp_lines_dict.items()): +for op_list, expr in cpp_lines_dict.items(): e = re.compile(expr) for op in op_list: Table[op] = e @@ -88,7 +87,7 @@ del op_list override = { 'if' : 'if(?!def)', } -l = [override.get(x, x) for x in list(Table.keys())] +l = [override.get(x, x) for x in Table.keys()] # Turn the list of expressions into one big honkin' regular expression @@ -131,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(list(CPP_to_Python_Ops_Dict.keys()), key=lambda a: len(a), reverse=True) +l = sorted(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. @@ -267,7 +266,7 @@ class PreProcessor(object): d = { 'scons_current_file' : self.scons_current_file } - for op in list(Table.keys()): + for op in Table.keys(): d[op] = getattr(self, 'do_' + op) self.default_table = d @@ -553,7 +552,7 @@ class PreProcessor(object): except KeyError: m = function_name.search(s) s = self.cpp_namespace[m.group(1)] - if isinstance(s, collections.Callable): + if callable(s): args = function_arg_separator.split(m.group(2)) s = s(*args) if not s: diff --git a/src/engine/SCons/cppTests.py b/src/engine/SCons/cppTests.py index 5566e53..2f2025b 100644 --- a/src/engine/SCons/cppTests.py +++ b/src/engine/SCons/cppTests.py @@ -27,7 +27,7 @@ import atexit import sys import unittest -from . import cpp +import cpp diff --git a/src/engine/SCons/dblite.py b/src/engine/SCons/dblite.py index 4b02239..dbbd65d 100644 --- a/src/engine/SCons/dblite.py +++ b/src/engine/SCons/dblite.py @@ -1,5 +1,6 @@ # dblite.py module contributed by Ralf W. Grosse-Kunstleve. # Extended for Unicode by Steven Knight. +from __future__ import print_function import SCons.compat @@ -16,14 +17,19 @@ ignore_corrupt_dbfiles = 0 def corruption_warning(filename): print("Warning: Discarding corrupt database:", filename) -def is_string(s): - return isinstance(s, str) +try: unicode +except NameError: + def is_string(s): + return isinstance(s, str) +else: + def is_string(s): + return type(s) in (str, unicode) def is_bytes(s): return isinstance (s, bytes) try: - str('a') + unicode('a') except NameError: - def str(s): return s + def unicode(s): return s dblite_suffix = '.dblite' if bytes is not str: @@ -177,23 +183,23 @@ def _exercise(): assert len(db) == 0 db["foo"] = "bar" assert db["foo"] == "bar" - db[str("ufoo")] = str("ubar") - assert db[str("ufoo")] == str("ubar") + db[unicode("ufoo")] = unicode("ubar") + assert db[unicode("ufoo")] == unicode("ubar") db.sync() db = open("tmp", "c") assert len(db) == 2, len(db) assert db["foo"] == "bar" db["bar"] = "foo" assert db["bar"] == "foo" - db[str("ubar")] = str("ufoo") - assert db[str("ubar")] == str("ufoo") + db[unicode("ubar")] = unicode("ufoo") + assert db[unicode("ubar")] == unicode("ufoo") db.sync() db = open("tmp", "r") assert len(db) == 4, len(db) assert db["foo"] == "bar" assert db["bar"] == "foo" - assert db[str("ufoo")] == str("ubar") - assert db[str("ubar")] == str("ufoo") + assert db[unicode("ufoo")] == unicode("ubar") + assert db[unicode("ubar")] == unicode("ufoo") try: db.sync() except IOError as e: diff --git a/src/script/scons-time.py b/src/script/scons-time.py index 4296192..9737dfe 100644 --- a/src/script/scons-time.py +++ b/src/script/scons-time.py @@ -29,8 +29,7 @@ # 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. - - +from __future__ import division, print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -42,7 +41,6 @@ import shutil import sys import tempfile import time -import collections try: sorted @@ -456,7 +454,7 @@ class SConsTimer(object): Each message is prepended with a standard prefix of our name plus the time. """ - if isinstance(msg, collections.Callable): + if callable(msg): msg = msg(*args) else: msg = msg % args @@ -475,7 +473,7 @@ class SConsTimer(object): The action is called if it's a callable Python function, and otherwise passed to os.system(). """ - if isinstance(action, collections.Callable): + if callable(action): action(*args) else: os.system(action % args) @@ -697,7 +695,7 @@ class SConsTimer(object): sys.stderr.write('%s Cannot use the "func" subcommand.\n' % self.name_spaces) sys.exit(1) statistics = pstats.Stats(file).stats - matches = [ e for e in list(statistics.items()) if e[0][2] == function ] + matches = [ e for e in statistics.items() if e[0][2] == function ] r = matches[0] return r[0][0], r[0][1], r[0][2], r[1][3] @@ -1467,7 +1465,7 @@ class SConsTimer(object): elif o in ('--title',): self.title = a elif o in ('--which',): - if not a in list(self.time_strings.keys()): + if not a in 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/script/sconsign.py b/src/script/sconsign.py index 323d1bf..e99a741 100644 --- a/src/script/sconsign.py +++ b/src/script/sconsign.py @@ -22,6 +22,9 @@ # 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. +from __future__ import print_function + +from six import PY2, PY3 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -171,6 +174,8 @@ sys.path = libs + sys.path import SCons.compat # so pickle will import cPickle instead +if PY2: + import whichdb import dbm import time import pickle @@ -189,7 +194,10 @@ def my_whichdb(filename): pass return _orig_whichdb(filename) -_orig_whichdb = dbm.whichdb +if PY3: + _orig_whichdb = dbm.whichdb +else: + _orig_whichdb = whichdb.whichdb dbm.whichdb = my_whichdb def my_import(mname): diff --git a/src/test_files.py b/src/test_files.py index d71329b..1eee11d 100644 --- a/src/test_files.py +++ b/src/test_files.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -77,7 +78,7 @@ check = { missing = [] no_result = [] -for directory, check_list in list(check.items()): +for directory, check_list in check.items(): if os.path.exists(directory): for c in check_list: f = os.path.join(directory, c) diff --git a/src/test_interrupts.py b/src/test_interrupts.py index 1e027a1..de3a0db 100644 --- a/src/test_interrupts.py +++ b/src/test_interrupts.py @@ -102,7 +102,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 list(try_except_lines.keys()): + for indent in 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/src/test_pychecker.py b/src/test_pychecker.py index 24aa966..54d78fb 100644 --- a/src/test_pychecker.py +++ b/src/test_pychecker.py @@ -20,6 +20,7 @@ # 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. +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/src/test_setup.py b/src/test_setup.py index 731fbe7..edf0de5 100644 --- a/src/test_setup.py +++ b/src/test_setup.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/src/test_strings.py b/src/test_strings.py index b57c714..297d59d 100644 --- a/src/test_strings.py +++ b/src/test_strings.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/AS/nasm.py b/test/AS/nasm.py index 551a5ab..be7db3e 100644 --- a/test/AS/nasm.py +++ b/test/AS/nasm.py @@ -69,7 +69,7 @@ else: # anyway...). nasm_format = 'elf' format_map = {} -for k, v in list(format_map.items()): +for k, v in format_map.items(): if sys.platform.find(k) != -1: nasm_format = v break diff --git a/test/Actions/unicode-signature.py b/test/Actions/unicode-signature.py index 0ba50c3..d91bfa8 100644 --- a/test/Actions/unicode-signature.py +++ b/test/Actions/unicode-signature.py @@ -35,12 +35,12 @@ import TestSCons test = TestSCons.TestSCons() -try: - str -except NameError: - import sys - msg = "Unicode not supported by Python version %s; skipping test\n" - test.skip_test(msg % sys.version[:3]) +## try: +## unicode +## except NameError: +## import sys +## 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') diff --git a/test/AddOption/help.py b/test/AddOption/help.py index a3fd7be..7b886cb 100644 --- a/test/AddOption/help.py +++ b/test/AddOption/help.py @@ -20,6 +20,7 @@ # 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. +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/Configure/ConfigureDryRunError.py b/test/Configure/ConfigureDryRunError.py index a8c6309..fa85042 100644 --- a/test/Configure/ConfigureDryRunError.py +++ b/test/Configure/ConfigureDryRunError.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/Configure/config-h.py b/test/Configure/config-h.py index 6c70c9c..ed95055 100644 --- a/test/Configure/config-h.py +++ b/test/Configure/config-h.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/Configure/implicit-cache.py b/test/Configure/implicit-cache.py index 059fd4c..1a9ff34 100644 --- a/test/Configure/implicit-cache.py +++ b/test/Configure/implicit-cache.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/Deprecated/SourceCode/BitKeeper/BitKeeper.py b/test/Deprecated/SourceCode/BitKeeper/BitKeeper.py index 9a36eac..2959736 100644 --- a/test/Deprecated/SourceCode/BitKeeper/BitKeeper.py +++ b/test/Deprecated/SourceCode/BitKeeper/BitKeeper.py @@ -20,6 +20,7 @@ # 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. +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/Deprecated/SourceCode/Subversion.py b/test/Deprecated/SourceCode/Subversion.py index ac3eb57..7d45a8c 100644 --- a/test/Deprecated/SourceCode/Subversion.py +++ b/test/Deprecated/SourceCode/Subversion.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/GetBuildFailures/parallel.py b/test/GetBuildFailures/parallel.py index 101c2e2..e746d53 100644 --- a/test/GetBuildFailures/parallel.py +++ b/test/GetBuildFailures/parallel.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function """ Verify that a failed build action with -j works as expected. diff --git a/test/Glob/glob-libpath.py b/test/Glob/glob-libpath.py index 6ee06e6..0878090 100644 --- a/test/Glob/glob-libpath.py +++ b/test/Glob/glob-libpath.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/Interactive/version.py b/test/Interactive/version.py index 295b9d3..34f8825 100644 --- a/test/Interactive/version.py +++ b/test/Interactive/version.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ diff --git a/test/Java/multi-step.py b/test/Java/multi-step.py index add4208..44ebd31 100644 --- a/test/Java/multi-step.py +++ b/test/Java/multi-step.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/MSVC/msvc.py b/test/MSVC/msvc.py index 6f5c8d6..a70ed67 100644 --- a/test/MSVC/msvc.py +++ b/test/MSVC/msvc.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/QT/QTFLAGS.py b/test/QT/QTFLAGS.py index b7172fc..008397a 100644 --- a/test/QT/QTFLAGS.py +++ b/test/QT/QTFLAGS.py @@ -147,7 +147,7 @@ test.must_exist(['work1', 'mmmmocFromH.cxx'], ['work1', 'mmmanother_ui_file.cxx']) def _flagTest(test,fileToContentsStart): - for f,c in list(fileToContentsStart.items()): + for f,c in fileToContentsStart.items(): if test.read(test.workpath('work1', f)).find(c) != 0: return 1 return 0 diff --git a/test/QT/copied-env.py b/test/QT/copied-env.py index 59a344d..3989143 100644 --- a/test/QT/copied-env.py +++ b/test/QT/copied-env.py @@ -20,6 +20,7 @@ # 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. +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/QT/warnings.py b/test/QT/warnings.py index 5e680f6..a1cf221 100644 --- a/test/QT/warnings.py +++ b/test/QT/warnings.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/Scanner/unicode.py b/test/Scanner/unicode.py index 7a72804..2737f7d 100644 --- a/test/Scanner/unicode.py +++ b/test/Scanner/unicode.py @@ -35,12 +35,12 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() -try: - str -except NameError: - import sys - msg = "Unicode not supported by Python version %s; skipping test\n" - test.skip_test(msg % sys.version[:3]) +## try: +## unicode +## except NameError: +## import sys +## msg = "Unicode not supported by Python version %s; skipping test\n" +## test.skip_test(msg % sys.version[:3]) import codecs @@ -102,28 +102,28 @@ include utf16be.k foo.k 1 line 4 """) -contents = str("""\ +contents = (u"""\ ascii.k 1 line 1 include ascii.inc ascii.k 1 line 3 """) test.write('ascii.k', contents.encode('ascii')) -contents = str("""\ +contents = (u"""\ utf8.k 1 line 1 include utf8.inc utf8.k 1 line 3 """) test.write('utf8.k', codecs.BOM_UTF8 + contents.encode('utf-8')) -contents = str("""\ +contents = (u"""\ utf16le.k 1 line 1 include utf16le.inc utf16le.k 1 line 3 """) test.write('utf16le.k', codecs.BOM_UTF16_LE + contents.encode('utf-16-le')) -contents = str("""\ +contents = (u"""\ utf16be.k 1 line 1 include utf16be.inc utf16be.k 1 line 3 diff --git a/test/TEX/TEX.py b/test/TEX/TEX.py index 863144d..b749690 100644 --- a/test/TEX/TEX.py +++ b/test/TEX/TEX.py @@ -20,6 +20,7 @@ # 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. +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/Value.py b/test/Value.py index 025c6de..7abe758 100644 --- a/test/Value.py +++ b/test/Value.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/Win32/bad-drive.py b/test/Win32/bad-drive.py index ff98b4e..4d0d6e9 100644 --- a/test/Win32/bad-drive.py +++ b/test/Win32/bad-drive.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function """ This test verifies (on Windows systems) that we fail gracefully and diff --git a/test/Win32/default-drive.py b/test/Win32/default-drive.py index 2bc14b1..31253e4 100644 --- a/test/Win32/default-drive.py +++ b/test/Win32/default-drive.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function """ This test verifies (on Windows systems) that specifying an diff --git a/test/gnutools.py b/test/gnutools.py index f79efe4..b0ebc1c 100644 --- a/test/gnutools.py +++ b/test/gnutools.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/import.py b/test/import.py index fb8a28c..d1e1ecf 100644 --- a/test/import.py +++ b/test/import.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/option--random.py b/test/option--random.py index 59592cb..357cf2e 100644 --- a/test/option--random.py +++ b/test/option--random.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/option-v.py b/test/option-v.py index 8985db0..43245da 100644 --- a/test/option-v.py +++ b/test/option-v.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/option/debug-count.py b/test/option/debug-count.py index 076d7fa..ce79086 100644 --- a/test/option/debug-count.py +++ b/test/option/debug-count.py @@ -20,6 +20,7 @@ # 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. +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/option/debug-time.py b/test/option/debug-time.py index 7448e1c..7dd17fe 100644 --- a/test/option/debug-time.py +++ b/test/option/debug-time.py @@ -20,7 +20,7 @@ # 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. - +from __future__ import division, print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/option/help-options.py b/test/option/help-options.py index 1b23cb3..e14eff2 100644 --- a/test/option/help-options.py +++ b/test/option/help-options.py @@ -20,6 +20,7 @@ # 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. +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/option/profile.py b/test/option/profile.py index 513da47..97f84db 100644 --- a/test/option/profile.py +++ b/test/option/profile.py @@ -21,6 +21,8 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +from six import u + __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import sys @@ -36,7 +38,7 @@ else: # when we drop support for Python 2.6. class StringIO(_StringIO): def write(self, s): - _StringIO.write(self, str(s)) + _StringIO.write(self, u(s)) import TestSCons diff --git a/test/site_scons/sysdirs.py b/test/site_scons/sysdirs.py index d05f6a4..87f448d 100644 --- a/test/site_scons/sysdirs.py +++ b/test/site_scons/sysdirs.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/update-release-info/update-release-info.py b/test/update-release-info/update-release-info.py index 0db65ba..d3125c7 100644 --- a/test/update-release-info/update-release-info.py +++ b/test/update-release-info/update-release-info.py @@ -201,7 +201,7 @@ RELEASE 2.0.0.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE """, mode = 'r') -years = ', '.join(map(str, list(range(2001, this_year + 1)))) +years = ', '.join(map(str, range(2001, this_year + 1))) test.must_match(SConstruct, """ month_year = 'MONTH YEAR' copyright_years = %s diff --git a/timings/ElectricCloud/TimeSCons-run.py b/timings/ElectricCloud/TimeSCons-run.py index fbe0028..130d916 100644 --- a/timings/ElectricCloud/TimeSCons-run.py +++ b/timings/ElectricCloud/TimeSCons-run.py @@ -20,6 +20,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function """ This configuration comes from the following blog article: diff --git a/www/gen_sched_table.py b/www/gen_sched_table.py index 9ac8acd..85b1b81 100755 --- a/www/gen_sched_table.py +++ b/www/gen_sched_table.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +from __future__ import print_function import sys import datetime -- cgit v0.12 From cbd2254037664fdfe6ba1bf6678896fbd51698a9 Mon Sep 17 00:00:00 2001 From: Stefan Zimmermann Date: Fri, 27 Dec 2013 09:39:26 +0000 Subject: QMTest: open() in text mode. Add ()s to prints on writing test scripts from str. --- QMTest/SConscript | 4 ++-- QMTest/TestCmd.py | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/QMTest/SConscript b/QMTest/SConscript index 33fe903..5469d29 100644 --- a/QMTest/SConscript +++ b/QMTest/SConscript @@ -44,12 +44,12 @@ files = [ def copy(target, source, env): t = str(target[0]) s = str(source[0]) - c = open(s, 'rb').read() + c = open(s, 'r').read() # Note: We construct the __ VERSION __ substitution string at # run-time so it doesn't get replaced when this file gets copied # into the tree for packaging. c = c.replace('__' + 'VERSION' + '__', env['VERSION']) - open(t, 'wb').write(c) + open(t, 'w').write(c) for file in files: # Guarantee that real copies of these files always exist in diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index 488d940..c075cd3 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -287,6 +287,8 @@ version. # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. from __future__ import division, print_function +from six import PY3 + __author__ = "Steven Knight " __revision__ = "TestCmd.py 1.3.D001 2010/06/03 12:58:27 knight" __version__ = "1.3" @@ -1705,7 +1707,7 @@ class TestCmd(object): do_chmod(os.path.join(dirpath, name)) do_chmod(top) - def write(self, file, content, mode = 'wb'): + def write(self, file, content, mode = 'w'): """Writes the specified content text (second argument) to the specified file name (first argument). The file name may be a list, in which case the elements are concatenated with the @@ -1714,6 +1716,8 @@ class TestCmd(object): exist. The I/O mode for the file may be specified; it must begin with a 'w'. The default is 'wb' (binary write). """ + if PY3: + content = re.sub('print (.+)', 'print(\1)', content) file = self.canonicalize(file) if mode[0] != 'w': raise ValueError("mode must begin with 'w'") -- cgit v0.12 From 724d115835ddfe49096b9ad695a3b75cb612745a Mon Sep 17 00:00:00 2001 From: Stefan Zimmermann Date: Fri, 27 Dec 2013 09:40:41 +0000 Subject: SConstruct: open() in text mode. Fixed octal literals. --- SConstruct | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/SConstruct b/SConstruct index 1a0aef0..09eb739 100644 --- a/SConstruct +++ b/SConstruct @@ -70,7 +70,7 @@ def whereis(file): st = os.stat(f_ext) except: continue - if stat.S_IMODE(st[stat.ST_MODE]) & 0111: + if stat.S_IMODE(st[stat.ST_MODE]) & 0o111: return f_ext return None @@ -372,7 +372,7 @@ def SCons_revision(target, source, env): """ t = str(target[0]) s = source[0].rstr() - contents = open(s, 'rb').read() + contents = open(s, 'r').read() # Note: We construct the __*__ substitution strings here # so that they don't get replaced when this file gets # copied into the tree for packaging. @@ -386,7 +386,7 @@ def SCons_revision(target, source, env): contents = contents.replace('__REVISION' + '__', env['REVISION']) contents = contents.replace('__VERSION' + '__', env['VERSION']) contents = contents.replace('__NULL' + '__', '') - open(t, 'wb').write(contents) + open(t, 'w').write(contents) os.chmod(t, os.stat(s)[0]) revaction = SCons_revision @@ -851,7 +851,7 @@ for p in [ scons ]: dist_distutils_targets = env.Install('$DISTDIR', distutils_targets) Local(dist_distutils_targets) - AddPostAction(dist_distutils_targets, Chmod(dist_distutils_targets, 0644)) + AddPostAction(dist_distutils_targets, Chmod(dist_distutils_targets, 0o644)) if not gzip: print("gzip not found in %s; skipping .tar.gz package for %s." % (os.environ['PATH'], pkg)) @@ -866,8 +866,8 @@ for p in [ scons ]: dist_tar_gz = env.Install('$DISTDIR', tar_gz) dist_platform_tar_gz = env.Install('$DISTDIR', platform_tar_gz) Local(dist_tar_gz, dist_platform_tar_gz) - AddPostAction(dist_tar_gz, Chmod(dist_tar_gz, 0644)) - AddPostAction(dist_platform_tar_gz, Chmod(dist_platform_tar_gz, 0644)) + AddPostAction(dist_tar_gz, Chmod(dist_tar_gz, 0o644)) + AddPostAction(dist_platform_tar_gz, Chmod(dist_platform_tar_gz, 0o644)) # # Unpack the tar.gz archive created by the distutils into @@ -941,8 +941,8 @@ for p in [ scons ]: dist_zip = env.Install('$DISTDIR', zip) dist_platform_zip = env.Install('$DISTDIR', platform_zip) Local(dist_zip, dist_platform_zip) - AddPostAction(dist_zip, Chmod(dist_zip, 0644)) - AddPostAction(dist_platform_zip, Chmod(dist_platform_zip, 0644)) + AddPostAction(dist_zip, Chmod(dist_zip, 0o644)) + AddPostAction(dist_platform_zip, Chmod(dist_platform_zip, 0o644)) # # Unpack the zip archive created by the distutils into @@ -1029,8 +1029,8 @@ for p in [ scons ]: dist_noarch_rpm = env.Install('$DISTDIR', noarch_rpm) dist_src_rpm = env.Install('$DISTDIR', src_rpm) Local(dist_noarch_rpm, dist_src_rpm) - AddPostAction(dist_noarch_rpm, Chmod(dist_noarch_rpm, 0644)) - AddPostAction(dist_src_rpm, Chmod(dist_src_rpm, 0644)) + AddPostAction(dist_noarch_rpm, Chmod(dist_noarch_rpm, 0o644)) + AddPostAction(dist_src_rpm, Chmod(dist_src_rpm, 0o644)) dfiles = [os.path.join(test_rpm_dir, 'usr', x) for x in dst_files] env.Command(dfiles, @@ -1097,8 +1097,8 @@ for p in [ scons ]: dist_local_tar_gz = os.path.join("$DISTDIR/%s.tar.gz" % s_l_v) dist_local_zip = os.path.join("$DISTDIR/%s.zip" % s_l_v) - AddPostAction(dist_local_tar_gz, Chmod(dist_local_tar_gz, 0644)) - AddPostAction(dist_local_zip, Chmod(dist_local_zip, 0644)) + AddPostAction(dist_local_tar_gz, Chmod(dist_local_tar_gz, 0o644)) + AddPostAction(dist_local_zip, Chmod(dist_local_zip, 0o644)) commands = [ Delete(build_dir_local), -- cgit v0.12 From b5d204ffae80f78083c34b0ba4c105791d57c084 Mon Sep 17 00:00:00 2001 From: Stefan Zimmermann Date: Fri, 27 Dec 2013 09:43:46 +0000 Subject: copy_func: return 0 instead of return shutil.* --- src/engine/SCons/Defaults.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py index 491b9f2..92f2344 100644 --- a/src/engine/SCons/Defaults.py +++ b/src/engine/SCons/Defaults.py @@ -183,11 +183,11 @@ def copy_func(dest, src): if SCons.Util.is_List(src) and os.path.isdir(dest): for file in src: shutil.copy2(file, dest) - return 0 elif os.path.isfile(src): - return shutil.copy2(src, dest) + shutil.copy2(src, dest) else: - return shutil.copytree(src, dest, 1) + shutil.copytree(src, dest, 1) + return 0 Copy = ActionFactory(copy_func, lambda dest, src: 'Copy("%s", "%s")' % (dest, src), -- cgit v0.12 From 808610957042c630d19c7f7b0fd9b87b81f9de2e Mon Sep 17 00:00:00 2001 From: Stefan Zimmermann Date: Fri, 27 Dec 2013 09:51:19 +0000 Subject: Environment.py: __cmp__ to __eq__. list(*.keys()) for item deletion loops. --- src/engine/SCons/Environment.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index b5bd620..7a369a9 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -127,7 +127,7 @@ future_reserved_construction_var_names = [ def copy_non_reserved_keywords(dict): result = semi_deepcopy(dict) - for k in result.keys(): + for k in list(result.keys()): if k in reserved_construction_var_names: msg = "Ignoring attempt to set reserved variable `$%s'" SCons.Warnings.warn(SCons.Warnings.ReservedVariableWarning, msg % k) @@ -398,8 +398,8 @@ class SubstitutionEnvironment(object): # gotten better than dict.has_key() in Python 2.5.) self._special_set_keys = list(self._special_set.keys()) - def __cmp__(self, other): - return cmp(self._dict, other._dict) + def __eq__(self, other): + return self._dict == other._dict def __delitem__(self, key): special = self._special_del.get(key) @@ -1768,7 +1768,7 @@ class Base(SubstitutionEnvironment): return os.path.join(dir, new_prefix+name+new_suffix) def SetDefault(self, **kw): - for k in kw.keys(): + for k in list(kw.keys()): if k in self._dict: del kw[k] self.Replace(**kw) -- cgit v0.12 From d1c2f4dbdbf5ca3f5c1f8bf6da45c09d82046683 Mon Sep 17 00:00:00 2001 From: Stefan Zimmermann Date: Fri, 27 Dec 2013 13:05:24 +0000 Subject: doc/SConscript: Fixed octal literal. --- doc/SConscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/SConscript b/doc/SConscript index c6b8f74..a1feba9 100644 --- a/doc/SConscript +++ b/doc/SConscript @@ -414,7 +414,7 @@ if tar_deps: tar_list = ' '.join([x.replace(build+'/', '') for x in tar_list]) t = env.Command(dist_doc_tar_gz, tar_deps, "tar cf${TAR_HFLAG} - -C %s %s | gzip > $TARGET" % (build, tar_list)) - AddPostAction(dist_doc_tar_gz, Chmod(dist_doc_tar_gz, 0644)) + AddPostAction(dist_doc_tar_gz, Chmod(dist_doc_tar_gz, 0o644)) Local(t) Alias('doc', t) else: -- cgit v0.12 From fd24c4ea622e271936c2df2a5efa484cd351bd9c Mon Sep 17 00:00:00 2001 From: Stefan Zimmermann Date: Fri, 27 Dec 2013 13:07:07 +0000 Subject: Use exec() with compile() to preserve script name. --- src/engine/SCons/Script/SConscript.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py index b2dc4c1..3ee9464 100644 --- a/src/engine/SCons/Script/SConscript.py +++ b/src/engine/SCons/Script/SConscript.py @@ -26,7 +26,6 @@ files. # 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. -from __future__ import division, print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -257,7 +256,8 @@ def _SConscript(fs, *files, **kw): pass try: try: - exec(_file_.read(), call_stack[-1].globals) + exec(compile(_file_.read(), _file_.name, 'exec'), + call_stack[-1].globals) except SConscriptReturn: pass finally: -- cgit v0.12 From 87b458d186fe0553b054b8eeb7d57c80e0a54f21 Mon Sep 17 00:00:00 2001 From: Stefan Zimmermann Date: Mon, 31 Mar 2014 15:21:40 +0000 Subject: More __cmp__ to __eq__ (and __lt__). Resolved some UnboundLocalErrors after except. --- bin/SConsDoc.py | 6 ++++-- bin/scons-proc.py | 11 ++++++++--- src/engine/SCons/Action.py | 4 ++-- src/engine/SCons/Builder.py | 11 +++++++---- src/engine/SCons/BuilderTests.py | 22 ++++++++++++++-------- src/engine/SCons/EnvironmentTests.py | 8 ++++---- src/engine/SCons/Memoize.py | 6 +++--- src/engine/SCons/Scanner/ScannerTests.py | 2 +- src/engine/SCons/Scanner/__init__.py | 6 +++--- src/engine/SCons/Util.py | 6 +++--- test/Scanner/generated.py | 4 ++-- 11 files changed, 51 insertions(+), 35 deletions(-) diff --git a/bin/SConsDoc.py b/bin/SConsDoc.py index 80f41a5..72c0306 100644 --- a/bin/SConsDoc.py +++ b/bin/SConsDoc.py @@ -668,8 +668,10 @@ class Item(object): if name[0] == '_': name = name[1:] return name.lower() - def __cmp__(self, other): - return cmp(self.sort_name, other.sort_name) + def __eq__(self, other): + return self.sort_name == other.sort_name + def __lt__(self, other): + return self.sort_name < other.sort_name class Builder(Item): pass diff --git a/bin/scons-proc.py b/bin/scons-proc.py index b93b25a..138cff7 100644 --- a/bin/scons-proc.py +++ b/bin/scons-proc.py @@ -231,10 +231,15 @@ class Proxy(object): """Retrieve the entire wrapped object""" return self.__subject - def __cmp__(self, other): + def __eq__(self, other): if issubclass(other.__class__, self.__subject.__class__): - return cmp(self.__subject, other) - return cmp(self.__dict__, other.__dict__) + return self.__subject == other + return self.__dict__ == other.__dict__ + + ## def __lt__(self, other): + ## if issubclass(other.__class__, self.__subject.__class__): + ## return self.__subject < other + ## return self.__dict__ < other.__dict__ class SConsThing(Proxy): def idfunc(self): diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index 006e8f5..49b9f35 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -420,8 +420,8 @@ class ActionBase(object): other objects (Builders, Executors, etc.) This provides the common methods for manipulating and combining those actions.""" - def __cmp__(self, other): - return cmp(self.__dict__, other) + def __eq__(self, other): + return self.__dict__ == other def no_batch_key(self, env, target, source): return None diff --git a/src/engine/SCons/Builder.py b/src/engine/SCons/Builder.py index 0f7aff4..4b41827 100644 --- a/src/engine/SCons/Builder.py +++ b/src/engine/SCons/Builder.py @@ -345,8 +345,11 @@ class EmitterProxy(object): return (target, source) - def __cmp__(self, other): - return cmp(self.var, other.var) + def __eq__(self, other): + return self.var == other.var + + def __lt__(self, other): + return self.var < other.var class BuilderBase(object): """Base class for Builders, objects that create output @@ -449,8 +452,8 @@ class BuilderBase(object): except AttributeError: return str(self.__class__) - def __cmp__(self, other): - return cmp(self.__dict__, other.__dict__) + def __eq__(self, other): + return self.__dict__ == other.__dict__ def splitext(self, path, env=None): if not env: diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py index 41b640b..eb56299 100644 --- a/src/engine/SCons/BuilderTests.py +++ b/src/engine/SCons/BuilderTests.py @@ -145,8 +145,8 @@ class Environment(object): d['SOURCES'] = ['__s1__', '__s2__', '__s3__', '__s4__', '__s5__', '__s6__'] d['SOURCE'] = d['SOURCES'][0] return d - def __cmp__(self, other): - return cmp(self.scanner, other.scanner) or cmp(self.d, other.d) + def __eq__(self, other): + return self.scanner == other.scanner or self.d == other.d class MyAction(object): def __init__(self, action): @@ -1500,9 +1500,10 @@ class CompositeBuilderTestCase(unittest.TestCase): builder(env, target='test3', source=['test2.bar', 'test1.foo'])[0] except SCons.Errors.UserError as e: flag = 1 + err = e assert flag, "UserError should be thrown when we call a builder with files of different suffixes." expect = "While building `['test3']' from `test1.foo': Cannot build multiple sources with different extensions: .bar, .foo" - assert str(e) == expect, e + assert str(err) == expect, err def test_source_ext_match(self): """Test the CompositeBuilder source_ext_match argument""" @@ -1584,45 +1585,50 @@ class CompositeBuilderTestCase(unittest.TestCase): builder(env, target='t5', source=['test5a.foo', 'test5b.inb'])[0] except SCons.Errors.UserError as e: flag = 1 + err = e assert flag, "UserError should be thrown when we call a builder with files of different suffixes." expect = "While building `['t5']' from `test5b.bar': Cannot build multiple sources with different extensions: .foo, .bar" - assert str(e) == expect, e + assert str(err) == expect, err flag = 0 try: builder(env, target='t6', source=['test6a.bar', 'test6b.ina'])[0] except SCons.Errors.UserError as e: flag = 1 + err = e assert flag, "UserError should be thrown when we call a builder with files of different suffixes." expect = "While building `['t6']' from `test6b.foo': Cannot build multiple sources with different extensions: .bar, .foo" - assert str(e) == expect, e + assert str(err) == expect, err flag = 0 try: builder(env, target='t4', source=['test4a.ina', 'test4b.inb'])[0] except SCons.Errors.UserError as e: flag = 1 + err = e assert flag, "UserError should be thrown when we call a builder with files of different suffixes." expect = "While building `['t4']' from `test4b.bar': Cannot build multiple sources with different extensions: .foo, .bar" - assert str(e) == expect, e + assert str(err) == expect, err flag = 0 try: builder(env, target='t7', source=[env.fs.File('test7')])[0] except SCons.Errors.UserError as e: flag = 1 + err = e assert flag, "UserError should be thrown when we call a builder with files of different suffixes." expect = "While building `['t7']': Cannot deduce file extension from source files: ['test7']" - assert str(e) == expect, e + assert str(err) == expect, err flag = 0 try: builder(env, target='t8', source=['test8.unknown'])[0] except SCons.Errors.UserError as e: flag = 1 + err = e assert flag, "UserError should be thrown when we call a builder target with an unknown suffix." expect = "While building `['t8']' from `['test8.unknown']': Don't know how to build from a source file with suffix `.unknown'. Expected a suffix in this list: ['.foo', '.bar']." - assert str(e) == expect, e + assert str(err) == expect, err if __name__ == "__main__": suite = unittest.TestSuite() diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index 22552b3..6933b6b 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -113,11 +113,11 @@ class Scanner(object): global scanned_it scanned_it[filename] = 1 - def __cmp__(self, other): + def __eq__(self, other): try: - return cmp(self.__dict__, other.__dict__) + return self.__dict__ == other.__dict__ except AttributeError: - return 1 + return False def get_skeys(self, env): return self.skeys @@ -1613,7 +1613,7 @@ def exists(env): self.name = name def __str__(self): return self.name - def __cmp__(self, other): + def __eq__(self, other): raise Exception("should not compare") ccc = C('ccc') diff --git a/src/engine/SCons/Memoize.py b/src/engine/SCons/Memoize.py index ac728c9..d2938c7 100644 --- a/src/engine/SCons/Memoize.py +++ b/src/engine/SCons/Memoize.py @@ -145,11 +145,11 @@ class Counter(object): def display(self): fmt = " %7d hits %7d misses %s()" print(fmt % (self.hit, self.miss, self.name)) - def __cmp__(self, other): + def __eq__(self, other): try: - return cmp(self.name, other.name) + return self.name == other.name except AttributeError: - return 0 + return True class CountValue(Counter): """ diff --git a/src/engine/SCons/Scanner/ScannerTests.py b/src/engine/SCons/Scanner/ScannerTests.py index ee26922..f29d545 100644 --- a/src/engine/SCons/Scanner/ScannerTests.py +++ b/src/engine/SCons/Scanner/ScannerTests.py @@ -234,7 +234,7 @@ class BaseTestCase(unittest.TestCase): def test___cmp__(self): """Test the Scanner.Base class __cmp__() method""" s = SCons.Scanner.Base(self.func, "Cmp") - assert cmp(s, None) + assert s != None def test_hash(self): """Test the Scanner.Base class __hash__() method""" diff --git a/src/engine/SCons/Scanner/__init__.py b/src/engine/SCons/Scanner/__init__.py index 2375bc4..5700fe9 100644 --- a/src/engine/SCons/Scanner/__init__.py +++ b/src/engine/SCons/Scanner/__init__.py @@ -221,12 +221,12 @@ class Base(object): nodes.append(l) return nodes - def __cmp__(self, other): + def __eq__(self, other): try: - return cmp(self.__dict__, other.__dict__) + return self.__dict__ == other.__dict__ except AttributeError: # other probably doesn't have a __dict__ - return cmp(self.__dict__, other) + return self.__dict__ == other def __hash__(self): return id(self) diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 60e5c10..7ea2789 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -537,10 +537,10 @@ class Proxy(object): """Retrieve the entire wrapped object""" return self._subject - def __cmp__(self, other): + def __eq__(self, other): if issubclass(other.__class__, self._subject.__class__): - return cmp(self._subject, other) - return cmp(self.__dict__, other.__dict__) + return self._subject == other + return self.__dict__ == other.__dict__ class Delegate(object): """A Python Descriptor class that delegates attribute fetches diff --git a/test/Scanner/generated.py b/test/Scanner/generated.py index 845111c..82206c2 100644 --- a/test/Scanner/generated.py +++ b/test/Scanner/generated.py @@ -317,8 +317,8 @@ def write_out(file, dict): class CScannerCounter(object): def __init__(self, original_CScanner, *args, **kw): self.original_CScanner = original_CScanner - def __cmp__(self, *args, **kw): - return self.original_CScanner.__cmp__(*args, **kw) + def __eq__(self, *args, **kw): + return self.original_CScanner.__eq__(*args, **kw) def __hash__(self, *args, **kw): return self.original_CScanner.__hash__(*args, **kw) def __str__(self, *args, **kw): -- cgit v0.12 From 6c1162f68d4682a045d35806a49dee50fba62808 Mon Sep 17 00:00:00 2001 From: Stefan Zimmermann Date: Fri, 27 Dec 2013 13:28:41 +0000 Subject: ActionTests: No string.join(). b prefix for assert Action.get_contents(). --- src/engine/SCons/ActionTests.py | 74 ++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py index 754c6e7..01b38f3 100644 --- a/src/engine/SCons/ActionTests.py +++ b/src/engine/SCons/ActionTests.py @@ -62,7 +62,7 @@ test = TestCmd.TestCmd(workdir = '') test.write('act.py', """\ import os, string, sys f = open(sys.argv[1], 'w') -f.write("act.py: '" + string.join(sys.argv[2:], "' '") + "'\\n") +f.write("act.py: '" + "' '".join(sys.argv[2:]) + "'\\n") try: if sys.argv[3]: f.write("act.py: '" + os.environ[sys.argv[3]] + "'\\n") @@ -1326,7 +1326,7 @@ class CommandActionTestCase(unittest.TestCase): c = a.get_contents(target=[], source=[], env=Environment(foo = 'FFF', bar = 'BBB', baz = CmdGen)) - assert c == "| | FFF BBB 1", c + assert c == b"| | FFF BBB 1", c # Make sure that CommandActions use an Environment's # subst_target_source() method for substitution. @@ -1337,7 +1337,7 @@ class CommandActionTestCase(unittest.TestCase): c = a.get_contents(target=DummyNode('ttt'), source = DummyNode('sss'), env=SpecialEnvironment(foo = 'GGG', bar = 'CCC', baz = 'ZZZ')) - assert c == 'subst_target_source: | $( $foo | $bar $) | $baz 1', c + assert c == b'subst_target_source: | $( $foo | $bar $) | $baz 1', c # We've discussed using the real target and source names in a # CommandAction's signature contents. This would have have the @@ -1354,35 +1354,35 @@ class CommandActionTestCase(unittest.TestCase): a = SCons.Action.CommandAction(["$TARGET"]) c = a.get_contents(target=t, source=s, env=env) - assert c == "t1", c + assert c == b"t1", c a = SCons.Action.CommandAction(["$TARGETS"]) c = a.get_contents(target=t, source=s, env=env) - assert c == "t1 t2 t3 t4 t5 t6", c + assert c == b"t1 t2 t3 t4 t5 t6", c a = SCons.Action.CommandAction(["${TARGETS[2]}"]) c = a.get_contents(target=t, source=s, env=env) - assert c == "t3", c + assert c == b"t3", c a = SCons.Action.CommandAction(["${TARGETS[3:5]}"]) c = a.get_contents(target=t, source=s, env=env) - assert c == "t4 t5", c + assert c == b"t4 t5", c a = SCons.Action.CommandAction(["$SOURCE"]) c = a.get_contents(target=t, source=s, env=env) - assert c == "s1", c + assert c == b"s1", c a = SCons.Action.CommandAction(["$SOURCES"]) c = a.get_contents(target=t, source=s, env=env) - assert c == "s1 s2 s3 s4 s5 s6", c + assert c == b"s1 s2 s3 s4 s5 s6", c a = SCons.Action.CommandAction(["${SOURCES[2]}"]) c = a.get_contents(target=t, source=s, env=env) - assert c == "s3", c + assert c == b"s3", c a = SCons.Action.CommandAction(["${SOURCES[3:5]}"]) c = a.get_contents(target=t, source=s, env=env) - assert c == "s4 s5", c + assert c == b"s4 s5", c class CommandGeneratorActionTestCase(unittest.TestCase): @@ -1499,7 +1499,7 @@ class CommandGeneratorActionTestCase(unittest.TestCase): ignore = 'foo', test=test) a = self.factory(f) c = a.get_contents(target=[], source=[], env=env) - assert c == "guux FFF BBB test", c + assert c == b"guux FFF BBB test", c def test_get_contents_of_function_action(self): """Test contents of a CommandGeneratorAction-generated FunctionAction @@ -1509,13 +1509,13 @@ class CommandGeneratorActionTestCase(unittest.TestCase): pass func_matches = [ - "0,0,0,0,(),(),(d\000\000S),(),()", - "0,0,0,0,(),(),(d\x00\x00S),(),()", + b"0,0,0,0,(),(),(d\000\000S),(),()", + b"0,0,0,0,(),(),(d\x00\x00S),(),()", ] meth_matches = [ - "1,1,0,0,(),(),(d\000\000S),(),()", - "1,1,0,0,(),(),(d\x00\x00S),(),()", + b"1,1,0,0,(),(),(d\000\000S),(),()", + b"1,1,0,0,(),(),(d\x00\x00S),(),()", ] def f_global(target, source, env, for_signature): @@ -1540,7 +1540,7 @@ class CommandGeneratorActionTestCase(unittest.TestCase): def f_local(target, source, env, for_signature): return SCons.Action.Action(LocalFunc, varlist=['XYZ']) - matches_foo = [x + "foo" for x in func_matches] + matches_foo = [x + b"foo" for x in func_matches] a = self.factory(f_global) c = a.get_contents(target=[], source=[], env=env) @@ -1668,13 +1668,13 @@ class FunctionActionTestCase(unittest.TestCase): pass func_matches = [ - "0,0,0,0,(),(),(d\000\000S),(),()", - "0,0,0,0,(),(),(d\x00\x00S),(),()", + b"0,0,0,0,(),(),(d\000\000S),(),()", + b"0,0,0,0,(),(),(d\x00\x00S),(),()", ] meth_matches = [ - "1,1,0,0,(),(),(d\000\000S),(),()", - "1,1,0,0,(),(),(d\x00\x00S),(),()", + b"1,1,0,0,(),(),(d\000\000S),(),()", + b"1,1,0,0,(),(),(d\x00\x00S),(),()", ] def factory(act, **kw): @@ -1688,7 +1688,7 @@ class FunctionActionTestCase(unittest.TestCase): c = a.get_contents(target=[], source=[], env=Environment()) assert c in func_matches, repr(c) - matches_foo = [x + "foo" for x in func_matches] + matches_foo = [x + b"foo" for x in func_matches] a = factory(GlobalFunc, varlist=['XYZ']) c = a.get_contents(target=[], source=[], env=Environment()) @@ -1706,10 +1706,10 @@ class FunctionActionTestCase(unittest.TestCase): class Foo(object): def get_contents(self, target, source, env): - return 'xyzzy' + return b'xyzzy' a = factory(Foo()) c = a.get_contents(target=[], source=[], env=Environment()) - assert c == 'xyzzy', repr(c) + assert c == b'xyzzy', repr(c) class LocalClass(object): def LocalMethod(self): @@ -1820,7 +1820,7 @@ class ListActionTestCase(unittest.TestCase): "z"]) c = a.get_contents(target=[], source=[], env=Environment(s = self)) assert self.foo==1, self.foo - assert c == "xyz", c + assert c == b"xyz", c class LazyActionTestCase(unittest.TestCase): def test___init__(self): @@ -1871,7 +1871,7 @@ class LazyActionTestCase(unittest.TestCase): a = SCons.Action.Action("${FOO}") env = Environment(FOO = [["This", "is", "a", "test"]]) c = a.get_contents(target=[], source=[], env=env) - assert c == "This is a test", c + assert c == b"This is a test", c def test_get_contents_of_function_action(self): """Test fetching the contents of a lazy-evaluation FunctionAction @@ -1881,13 +1881,13 @@ class LazyActionTestCase(unittest.TestCase): pass func_matches = [ - "0,0,0,0,(),(),(d\000\000S),(),()", - "0,0,0,0,(),(),(d\x00\x00S),(),()", + b"0,0,0,0,(),(),(d\000\000S),(),()", + b"0,0,0,0,(),(),(d\x00\x00S),(),()", ] meth_matches = [ - "1,1,0,0,(),(),(d\000\000S),(),()", - "1,1,0,0,(),(),(d\x00\x00S),(),()", + b"1,1,0,0,(),(),(d\000\000S),(),()", + b"1,1,0,0,(),(),(d\x00\x00S),(),()", ] def factory(act, **kw): @@ -1904,7 +1904,7 @@ class LazyActionTestCase(unittest.TestCase): c = a.get_contents(target=[], source=[], env=env) assert c in func_matches, repr(c) - matches_foo = [x + "foo" for x in func_matches] + matches_foo = [x + b"foo" for x in func_matches] env = Environment(FOO = factory(GlobalFunc, varlist=['XYZ'])) c = a.get_contents(target=[], source=[], env=env) @@ -1931,8 +1931,8 @@ class ActionCallerTestCase(unittest.TestCase): pass matches = [ - "d\000\000S", - "d\x00\x00S" + b"d\000\000S", + b"d\x00\x00S" ] af = SCons.Action.ActionFactory(GlobalFunc, strfunc) @@ -1946,8 +1946,8 @@ class ActionCallerTestCase(unittest.TestCase): assert c in matches, repr(c) matches = [ - 'd\000\000S', - "d\x00\x00S" + b'd\000\000S', + b"d\x00\x00S" ] class LocalActFunc(object): @@ -1965,8 +1965,8 @@ class ActionCallerTestCase(unittest.TestCase): assert c in matches, repr(c) matches = [ - "", - "", + b"", + b"", ] af = SCons.Action.ActionFactory(str, strfunc) -- cgit v0.12 From 2d2df48b33045bb15b543264114c6ef35773ef29 Mon Sep 17 00:00:00 2001 From: Stefan Zimmermann Date: Fri, 27 Dec 2013 13:30:45 +0000 Subject: Another list(*.keys()) for item deletion loop. --- src/engine/SCons/SConfTests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/SConfTests.py b/src/engine/SCons/SConfTests.py index e604886..ba524fd 100644 --- a/src/engine/SCons/SConfTests.py +++ b/src/engine/SCons/SConfTests.py @@ -60,7 +60,7 @@ class SConfTestCase(unittest.TestCase): # We try to reset scons' state (including all global variables) import SCons.SConsign SCons.SConsign.write() # simulate normal scons-finish - for n in sys.modules.keys(): + for n in list(sys.modules.keys()): if n.split('.')[0] == 'SCons' and n[:12] != 'SCons.compat': m = sys.modules[n] if isinstance(m, ModuleType): -- cgit v0.12 From 26003a0bd3168f8c2ee3d92a26d35ca977f8e25b Mon Sep 17 00:00:00 2001 From: Stefan Zimmermann Date: Wed, 8 Jan 2014 13:25:16 +0000 Subject: Some more six.PY2/PY3 usage. --- bin/install_scons.py | 6 ++++-- review.py | 14 ++++++++------ runtest.py | 6 ++++-- src/engine/SCons/Util.py | 11 ++++------- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/bin/install_scons.py b/bin/install_scons.py index 7a39e96..afd0789 100644 --- a/bin/install_scons.py +++ b/bin/install_scons.py @@ -19,14 +19,16 @@ # hierarchy. from __future__ import print_function +from six import PY3 + import getopt import os import shutil import sys import tarfile -try: +if PY3: from urllib.request import urlretrieve -except ImportError: # Python < 3 +else: from urllib import urlretrieve from Command import CommandRunner, Usage diff --git a/review.py b/review.py index c01472e..9f1ba82 100644 --- a/review.py +++ b/review.py @@ -15,6 +15,8 @@ # limitations under the License. from __future__ import print_function +from six import PY3 + """Tool for uploading diffs from a version control system to the codereview app. Usage summary: upload.py [options] [-- diff_options] [path...] @@ -32,14 +34,14 @@ against by using the '--rev' option. # This code is derived from appcfg.py in the App Engine SDK (open source), # and from ASPN recipe #146306. -try: +if PY3: from configparser import ConfigParser -except ImportError: # Python < 3 +else: from ConfigParser import ConfigParser -try: +if PY3: from http.cookiejar import ( CookieJar, MozillaCookieJar, LoadError as CookieLoadError) -except ImportError: # Python < 3 +else: from cookielib import ( CookieJar, MozillaCookieJar, LoadError as CookieLoadError) import fnmatch @@ -52,7 +54,7 @@ import re import socket import subprocess import sys -try: +if PY3: from urllib.request import ( Request, OpenerDirector, ProxyHandler, UnknownHandler, HTTPHandler, HTTPSHandler, @@ -61,7 +63,7 @@ try: from urllib.error import HTTPError from urllib.parse import ( urlencode, urlparse, urlunparse, splituser as urlsplituser) -except ImportError: # Python < 3 +else: from urllib2 import ( Request, OpenerDirector, ProxyHandler, UnknownHandler, HTTPHandler, HTTPSHandler, diff --git a/runtest.py b/runtest.py index 2470a61..6380292 100755 --- a/runtest.py +++ b/runtest.py @@ -85,6 +85,8 @@ # rather than reinventing that wheel.) from __future__ import print_function +from six import PY3 + import getopt import glob import os @@ -95,9 +97,9 @@ import time try: import threading - try: + if PY3: from queue import Queue - except ImportError: # Python < 3 + else: from Queue import Queue threading_ok = True except ImportError: diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 7ea2789..052b3fc 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -33,24 +33,21 @@ import copy import re import types -try: +if PY3: from collections import UserDict, UserList, UserString -except ImportError: # Python < 3 +else: from UserDict import UserDict from UserList import UserList from UserString import UserString # Don't "from types import ..." these because we need to get at the # types module later to look for UnicodeType. -try: - InstanceType = types.InstanceType -except AttributeError: # Python 3 - InstanceType = None +InstanceType = types.InstanceType if PY2 else None MethodType = types.MethodType FunctionType = types.FunctionType try: unicode except NameError: UnicodeType = None -else: UnicodeType = str +else: UnicodeType = unicode def dictify(keys, values, result={}): for k, v in zip(keys, values): -- cgit v0.12 From 8986df6b325e924f4143b03705129899fccc72ba Mon Sep 17 00:00:00 2001 From: Stefan Zimmermann Date: Wed, 8 Jan 2014 13:27:10 +0000 Subject: Fixed re.sub for PY3 print() in TestCmd.write(). --- QMTest/TestCmd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index c075cd3..2ac3da1 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -1717,7 +1717,7 @@ class TestCmd(object): begin with a 'w'. The default is 'wb' (binary write). """ if PY3: - content = re.sub('print (.+)', 'print(\1)', content) + content = re.sub(r'print (.+)', r'print(\1)', content) file = self.canonicalize(file) if mode[0] != 'w': raise ValueError("mode must begin with 'w'") -- cgit v0.12 From ea1890249923aab9cda388b2d22b566dbb7b8949 Mon Sep 17 00:00:00 2001 From: Rocco Matano Date: Fri, 7 Mar 2014 15:39:43 +0100 Subject: fix some minor 2to3 issues on windows --- src/engine/SCons/Platform/win32.py | 22 +++++++++++++--------- src/engine/SCons/Tool/386asm.py | 2 +- src/engine/SCons/Tool/MSCommon/common.py | 5 ++--- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/engine/SCons/Platform/win32.py b/src/engine/SCons/Platform/win32.py index 879817d..1e4fb2a 100644 --- a/src/engine/SCons/Platform/win32.py +++ b/src/engine/SCons/Platform/win32.py @@ -61,16 +61,21 @@ else: parallel_msg = None import builtins - - _builtin_file = builtins.file + builtin_file = getattr(builtins, 'file', None) is not None + + if builtin_file: + _builtin_file = builtins.file + + class _scons_file(_builtin_file): + def __init__(self, *args, **kw): + _builtin_file.__init__(self, *args, **kw) + win32api.SetHandleInformation(msvcrt.get_osfhandle(self.fileno()), + win32con.HANDLE_FLAG_INHERIT, 0) + + builtins.file = _scons_file + _builtin_open = builtins.open - class _scons_file(_builtin_file): - def __init__(self, *args, **kw): - _builtin_file.__init__(self, *args, **kw) - win32api.SetHandleInformation(msvcrt.get_osfhandle(self.fileno()), - win32con.HANDLE_FLAG_INHERIT, 0) - def _scons_open(*args, **kw): fp = _builtin_open(*args, **kw) win32api.SetHandleInformation(msvcrt.get_osfhandle(fp.fileno()), @@ -78,7 +83,6 @@ else: 0) return fp - builtins.file = _scons_file builtins.open = _scons_open try: diff --git a/src/engine/SCons/Tool/386asm.py b/src/engine/SCons/Tool/386asm.py index 8acc55f..51738eb 100644 --- a/src/engine/SCons/Tool/386asm.py +++ b/src/engine/SCons/Tool/386asm.py @@ -37,7 +37,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" from SCons.Tool.PharLapCommon import addPharLapPaths import SCons.Util -as_module = __import__('as', globals(), locals(), []) +as_module = __import__('as', globals(), locals(), [], 1) def generate(env): """Add Builders and construction variables for ar to an Environment.""" diff --git a/src/engine/SCons/Tool/MSCommon/common.py b/src/engine/SCons/Tool/MSCommon/common.py index e5c78e9..4a91310 100644 --- a/src/engine/SCons/Tool/MSCommon/common.py +++ b/src/engine/SCons/Tool/MSCommon/common.py @@ -115,11 +115,11 @@ def normalize_env(env, keys, force=False): normenv = {} if env: for k in env.keys(): - normenv[k] = copy.deepcopy(env[k]).encode('mbcs') + normenv[k] = copy.deepcopy(env[k]) for k in keys: if k in os.environ and (force or not k in normenv): - normenv[k] = os.environ[k].encode('mbcs') + normenv[k] = os.environ[k] # This shouldn't be necessary, since the default environment should include system32, # but keep this here to be safe, since it's needed to find reg.exe which the MSVC @@ -212,7 +212,6 @@ def parse_output(output, keep = ("INCLUDE", "LIB", "LIBPATH", "PATH")): for p in plist: # Do not add empty paths (when a var ends with ;) if p: - p = p.encode('mbcs') # XXX: For some reason, VC98 .bat file adds "" around the PATH # values, and it screws up the environment later, so we strip # it. -- cgit v0.12 From 18ecb44af82ac0b95c852ff05eaf4fe3af3fb724 Mon Sep 17 00:00:00 2001 From: Stefan Zimmermann Date: Mon, 31 Mar 2014 22:32:02 +0000 Subject: Additional ()s for print. --- src/script/scons.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/script/scons.py b/src/script/scons.py index d0bb812..25ae644 100644 --- a/src/script/scons.py +++ b/src/script/scons.py @@ -191,7 +191,7 @@ if __name__ == "__main__": except: print("Import failed. Unable to find SCons files in:") for path in libs: - print " %s" % path + print(" %s" % path) raise # this does all the work, and calls sys.exit -- cgit v0.12 From e7fbae42ed9a4db4be2152c2bccd05ce46226689 Mon Sep 17 00:00:00 2001 From: Stefan Zimmermann Date: Mon, 31 Mar 2014 22:37:42 +0000 Subject: SConstruct: More bytes/str fixes. --- SConstruct | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/SConstruct b/SConstruct index f1f1fa3..a18de57 100644 --- a/SConstruct +++ b/SConstruct @@ -418,7 +418,8 @@ def soelim(target, source, env): def soscan(node, env, path): c = node.get_text_contents() - return re.compile(r"^[\.']so\s+(\S+)", re.M).findall(c) + # Node contents are bytes ==> br"..." + return re.compile(br"^[\.']so\s+(\S+)", re.M).findall(c) soelimbuilder = Builder(action = Action(soelim), source_scanner = Scanner(soscan)) @@ -828,7 +829,7 @@ for p in [ scons ]: def write_src_files(target, source, **kw): global src_files src_files.sort() - f = open(str(target[0]), 'wb') + f = open(str(target[0]), 'w') for file in src_files: f.write(file + "\n") f.close() -- cgit v0.12 From 83cdce661b4a953f2b307f60577db53fb23a8b2d Mon Sep 17 00:00:00 2001 From: Stefan Zimmermann Date: Mon, 31 Mar 2014 22:38:22 +0000 Subject: engine.SCons: More bytes/str fixes. --- src/engine/SCons/Action.py | 2 +- src/engine/SCons/Node/FS.py | 2 +- src/engine/SCons/Tool/docbook/__init__.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index d7d9afd..cec241d 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -290,7 +290,7 @@ def _function_contents(func): xxx = [_object_contents(x.cell_contents) for x in closure] except AttributeError: xxx = [] - contents.append(b',(' + b','.join(xxx) + b')') + contents.append(b',(' + ','.join(xxx).encode('ascii') + b')') return b''.join(contents) diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index a537ca8..efca0c7 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -2420,7 +2420,7 @@ class File(Base): def get_contents(self): if not self.rexists(): - return '' + return b'' # Should always be bytes fname = self.rfile().abspath try: contents = open(fname, "rb").read() diff --git a/src/engine/SCons/Tool/docbook/__init__.py b/src/engine/SCons/Tool/docbook/__init__.py index aacc26d..627ff51 100644 --- a/src/engine/SCons/Tool/docbook/__init__.py +++ b/src/engine/SCons/Tool/docbook/__init__.py @@ -335,7 +335,7 @@ def __build_lxml(target, source, env): result = transform(doc) try: - of = open(str(target[0]), "w") + of = open(str(target[0]), "wb") of.write(of.write(etree.tostring(result, pretty_print=True))) of.close() except: -- cgit v0.12 From 7ae89fc5202506a060260f6052ec2f464c451107 Mon Sep 17 00:00:00 2001 From: Stefan Zimmermann Date: Mon, 31 Mar 2014 22:39:12 +0000 Subject: Tool.gs: Changed relative pdf import to absolute. --- src/engine/SCons/Tool/gs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/Tool/gs.py b/src/engine/SCons/Tool/gs.py index 443ace2..25359a8 100644 --- a/src/engine/SCons/Tool/gs.py +++ b/src/engine/SCons/Tool/gs.py @@ -62,7 +62,7 @@ def generate(env): if GhostscriptAction is None: GhostscriptAction = SCons.Action.Action('$GSCOM', '$GSCOMSTR') - from . import pdf + from SCons.Tool import pdf pdf.generate(env) bld = env['BUILDERS']['PDF'] -- cgit v0.12 From fad7c3eaf7f9cae12dbf03e03df7919d6fedea0e Mon Sep 17 00:00:00 2001 From: Stefan Zimmermann Date: Tue, 1 Apr 2014 07:19:29 +0000 Subject: Main: Use exec() with compile(). --- src/engine/SCons/Script/Main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py index 7906488..8725530 100644 --- a/src/engine/SCons/Script/Main.py +++ b/src/engine/SCons/Script/Main.py @@ -733,7 +733,7 @@ def _load_site_scons_dir(topdir, site_dir_name=None): site_m[k] = m.__dict__[k] # This is the magic. - exec(fp, site_m) + exec(compile(fp.read(), fp.name, 'exec'), site_m) except KeyboardInterrupt: raise except Exception as e: -- cgit v0.12 From a13f1049893f07d3a77474d77214a24eee3cb75b Mon Sep 17 00:00:00 2001 From: Stefan Zimmermann Date: Tue, 1 Apr 2014 07:28:31 +0000 Subject: test: site_scons/site_init: list() globals keys for looping to allow changes. --- test/site_scons/site_init.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/site_scons/site_init.py b/test/site_scons/site_init.py index 9f2e411..45201ac 100644 --- a/test/site_scons/site_init.py +++ b/test/site_scons/site_init.py @@ -51,7 +51,7 @@ import os.path import re special = [] -for x in globals().keys(): +for x in list(globals().keys()): if re.match("__[^_]+__", x): if x in ("__builtins__", "__package__",): # Ignore certain keywords, as they are known to be added by Python -- cgit v0.12 From 4631c0c43550e65bb4cb57a21b17c329966b2e03 Mon Sep 17 00:00:00 2001 From: Stefan Zimmermann Date: Tue, 1 Apr 2014 07:40:28 +0000 Subject: Main: No __future__.print_function (would affect exec()'d code). --- src/engine/SCons/Script/Main.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py index 8725530..0663c7a 100644 --- a/src/engine/SCons/Script/Main.py +++ b/src/engine/SCons/Script/Main.py @@ -10,7 +10,9 @@ some other module. If it's specific to the "scons" script invocation, it goes here. """ -from __future__ import print_function +# Would affect exec()'d site_init.py: +## from __future__ import print_function +from six import print_ unsupported_python_version = (2, 3, 0) deprecated_python_version = (2, 7, 0) @@ -339,7 +341,7 @@ class CleanTask(SCons.Taskmaster.AlwaysTask): except SCons.Errors.UserError as e: print(e) except (IOError, OSError) as e: - print("scons: Could not remove '%s':" % pathstr, e.strerror) + print_("scons: Could not remove '%s':" % pathstr, e.strerror) def show(self): target = self.targets[0] @@ -364,7 +366,7 @@ class CleanTask(SCons.Taskmaster.AlwaysTask): # the file not existing. In either case, print a # message and keep going to try to remove as many # targets aa possible. - print("scons: Could not remove '%s':" % str(t), e.strerror) + print_("scons: Could not remove '%s':" % str(t), e.strerror) else: if removed: display("Removed " + str(t)) @@ -798,7 +800,7 @@ def _load_all_site_scons_dirs(topdir, verbose=None): dirs=sysdirs + [topdir] for d in dirs: if verbose: # this is used by unit tests. - print("Loading site dir ", d) + print_("Loading site dir ", d) _load_site_scons_dir(d) def test_load_all_site_scons_dirs(d): -- cgit v0.12 From 8490ea812140862af7058f9617959061510c3701 Mon Sep 17 00:00:00 2001 From: Gary Oberbrunner Date: Sun, 6 Apr 2014 10:50:33 -0400 Subject: Added change log for python3 port --- src/CHANGES.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 5cea35f..f65dfd5 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -6,6 +6,9 @@ RELEASE 2.3.2.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE + From Neal Becker and Stefan Zimmermann: + - Python 3 port and compatibility + From Gary Oberbrunner: - get default RPM architecture more robustly when building RPMs -- cgit v0.12 From a6ea2d760464092ea91a0dd01ba6260288aa3587 Mon Sep 17 00:00:00 2001 From: Gary Oberbrunner Date: Sun, 20 Apr 2014 06:56:10 -0400 Subject: Added six module as SCons.compat.six, for python3 port. --- QMTest/TestCmd.py | 4 +- QMTest/TestCmdTests.py | 50 +-- bin/install_scons.py | 2 +- review.py | 8 +- runtest.py | 5 +- src/engine/SCons/MemoizeTests.py | 2 +- src/engine/SCons/Script/Main.py | 2 +- src/engine/SCons/Taskmaster.py | 10 +- src/engine/SCons/Tool/xgettext.py | 30 +- src/engine/SCons/Util.py | 32 +- src/engine/SCons/UtilTests.py | 6 +- src/engine/SCons/compat/_scons_subprocess.py | 2 +- src/engine/SCons/compat/six.py | 646 +++++++++++++++++++++++++++ src/engine/SCons/compat/sixTests.py | 34 ++ src/script/sconsign.py | 4 +- test/option/profile.py | 4 +- 16 files changed, 760 insertions(+), 81 deletions(-) create mode 100755 src/engine/SCons/compat/six.py create mode 100644 src/engine/SCons/compat/sixTests.py diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index 55c198f..e6b128b 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -287,7 +287,7 @@ version. # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. from __future__ import division, print_function -from six import PY3 +from SCons.compat.six import PY3 __author__ = "Steven Knight " __revision__ = "TestCmd.py 1.3.D001 2010/06/03 12:58:27 knight" @@ -685,7 +685,7 @@ if subprocess.mswindows: assert ol is None lpBuffer = ctypes.create_string_buffer(bufSize) bytesRead = DWORD() - bErr = ctypes.windll.kernel32.ReadFile( + bErr = ctypes.windll.kernel32.ReadFile( hFile, lpBuffer, bufSize, ctypes.byref(bytesRead), ol) if not bErr: raise ctypes.WinError() return (0, ctypes.string_at(lpBuffer, bytesRead.value)) diff --git a/QMTest/TestCmdTests.py b/QMTest/TestCmdTests.py index 6611590..a2e7022 100644 --- a/QMTest/TestCmdTests.py +++ b/QMTest/TestCmdTests.py @@ -19,7 +19,7 @@ AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. """ -from six import PY3 +from SCons.compat.six import PY3 __author__ = "Steven Knight " __revision__ = "TestCmdTests.py 1.3.D001 2010/06/03 12:58:27 knight" @@ -1870,24 +1870,24 @@ class run_verbose_TestCase(TestCmdTestCase): interpreter = 'python', workdir = '', verbose = 1) - + sys.stdout = StringIO() sys.stderr = StringIO() - + test.run(arguments = ['arg1 arg2']) o = sys.stdout.getvalue() assert o == '', o e = sys.stderr.getvalue() expect = 'python "%s" "arg1 arg2"\n' % t.script_path assert expect == e, (expect, e) - + testx = TestCmd.TestCmd(program = t.scriptx, workdir = '', verbose = 1) - + sys.stdout = StringIO() sys.stderr = StringIO() - + testx.run(arguments = ['arg1 arg2']) expect = '"%s" "arg1 arg2"\n' % t.scriptx_path o = sys.stdout.getvalue() @@ -1921,10 +1921,10 @@ class run_verbose_TestCase(TestCmdTestCase): interpreter = 'python', workdir = '', verbose = 2) - + sys.stdout = StringIO() sys.stderr = StringIO() - + test.run(arguments = ['arg1 arg2']) line_fmt = "script: %s: %s: ['arg1 arg2']\n" @@ -1938,14 +1938,14 @@ class run_verbose_TestCase(TestCmdTestCase): expect = 'python "%s" "arg1 arg2"\n' % t.script_path e = sys.stderr.getvalue() assert e == expect, (e, expect) - + testx = TestCmd.TestCmd(program = t.scriptx, workdir = '', verbose = 2) - + sys.stdout = StringIO() sys.stderr = StringIO() - + testx.run(arguments = ['arg1 arg2']) line_fmt = "scriptx.bat: %s: %s: ['arg1 arg2']\n" @@ -1966,10 +1966,10 @@ class run_verbose_TestCase(TestCmdTestCase): interpreter = 'python', workdir = '', verbose = 2) - + sys.stdout = StringIO() sys.stderr = StringIO() - + test.run(arguments = ['arg1 arg2']) line_fmt = "scriptout: %s: %s: ['arg1 arg2']\n" @@ -1986,10 +1986,10 @@ class run_verbose_TestCase(TestCmdTestCase): interpreter = 'python', workdir = '', verbose = 3) - + sys.stdout = StringIO() sys.stderr = StringIO() - + test.run(arguments = ['arg1 arg2']) line_fmt = "scriptout: %s: %s: ['arg1 arg2']\n" @@ -2010,10 +2010,10 @@ class run_verbose_TestCase(TestCmdTestCase): test = TestCmd.TestCmd(program = t.script, interpreter = 'python', workdir = '') - + sys.stdout = StringIO() sys.stderr = StringIO() - + test.run(arguments = ['arg1 arg2']) line_fmt = "script: %s: %s: ['arg1 arg2']\n" @@ -2027,13 +2027,13 @@ class run_verbose_TestCase(TestCmdTestCase): expect = 'python "%s" "arg1 arg2"\n' % t.script_path e = sys.stderr.getvalue() assert e == expect, (e, expect) - + testx = TestCmd.TestCmd(program = t.scriptx, workdir = '') - + sys.stdout = StringIO() sys.stderr = StringIO() - + testx.run(arguments = ['arg1 arg2']) line_fmt = "scriptx.bat: %s: %s: ['arg1 arg2']\n" @@ -2056,24 +2056,24 @@ class run_verbose_TestCase(TestCmdTestCase): interpreter = 'python', workdir = '', verbose = 1) - + sys.stdout = StringIO() sys.stderr = StringIO() - + test.run(arguments = ['arg1 arg2']) o = sys.stdout.getvalue() assert o == '', o e = sys.stderr.getvalue() expect = 'python "%s" "arg1 arg2"\n' % t.script_path assert expect == e, (expect, e) - + testx = TestCmd.TestCmd(program = t.scriptx, workdir = '', verbose = 1) - + sys.stdout = StringIO() sys.stderr = StringIO() - + testx.run(arguments = ['arg1 arg2']) expect = '"%s" "arg1 arg2"\n' % t.scriptx_path o = sys.stdout.getvalue() diff --git a/bin/install_scons.py b/bin/install_scons.py index afd0789..55e327d 100644 --- a/bin/install_scons.py +++ b/bin/install_scons.py @@ -19,7 +19,7 @@ # hierarchy. from __future__ import print_function -from six import PY3 +from SCons.compat.six import PY3 import getopt import os diff --git a/review.py b/review.py index 9f1ba82..a796b2f 100644 --- a/review.py +++ b/review.py @@ -15,7 +15,7 @@ # limitations under the License. from __future__ import print_function -from six import PY3 +from SCons.compat.six import PY3 """Tool for uploading diffs from a version control system to the codereview app. @@ -120,7 +120,7 @@ VCS_UNKNOWN = "Unknown" # whitelist for non-binary filetypes which do not start with "text/" # .mm (Objective-C) shows up as application/x-freemind on my Linux box. TEXT_MIMETYPES = ['application/javascript', 'application/x-javascript', - 'application/xml', 'application/x-freemind', + 'application/xml', 'application/x-freemind', 'application/x-sh'] VCS_ABBREVIATIONS = { @@ -1474,7 +1474,7 @@ def GuessVCSName(): """ def RunDetectCommand(vcs_type, command): """Helper to detect VCS by executing command. - + Returns: A pair (vcs, output) or None. Throws exception on error. """ @@ -1486,7 +1486,7 @@ def GuessVCSName(): (errcode, message) = xxx_todo_changeme.args if errcode != errno.ENOENT: # command not found code raise - + # Mercurial has a command to get the base directory of a repository # Try running it, but don't die if we don't have hg installed. # NOTE: we try Mercurial first as it can sit on top of an SVN working copy. diff --git a/runtest.py b/runtest.py index 7155556..485374a 100755 --- a/runtest.py +++ b/runtest.py @@ -81,7 +81,6 @@ # rather than reinventing that wheel.) from __future__ import print_function -from six import PY3 import getopt import glob @@ -93,9 +92,9 @@ import time try: import threading - if PY3: + try: # python3 from queue import Queue - else: + except ImportError as e: # python2 from Queue import Queue threading_ok = True except ImportError: diff --git a/src/engine/SCons/MemoizeTests.py b/src/engine/SCons/MemoizeTests.py index c1c69ae..8476349 100644 --- a/src/engine/SCons/MemoizeTests.py +++ b/src/engine/SCons/MemoizeTests.py @@ -20,7 +20,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -from six import add_metaclass +from SCons.compat.six import add_metaclass __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py index 0663c7a..1357e7f 100644 --- a/src/engine/SCons/Script/Main.py +++ b/src/engine/SCons/Script/Main.py @@ -12,7 +12,7 @@ it goes here. # Would affect exec()'d site_init.py: ## from __future__ import print_function -from six import print_ +from SCons.compat.six import print_ unsupported_python_version = (2, 3, 0) deprecated_python_version = (2, 7, 0) diff --git a/src/engine/SCons/Taskmaster.py b/src/engine/SCons/Taskmaster.py index 00147b2..4a06654 100644 --- a/src/engine/SCons/Taskmaster.py +++ b/src/engine/SCons/Taskmaster.py @@ -306,7 +306,7 @@ class Task(object): t.push_to_cache() t.built() t.visited() - if (not print_prepare and + if (not print_prepare and (not hasattr(self, 'options') or not self.options.debug_includes)): t.release_target_info() else: @@ -424,7 +424,7 @@ class Task(object): # parallel build...) t.visited() t.set_state(NODE_UP_TO_DATE) - if (not print_prepare and + if (not print_prepare and (not hasattr(self, 'options') or not self.options.debug_includes)): t.release_target_info() @@ -533,8 +533,8 @@ class Task(object): Task ready for execution. """ - import six - six.reraise(*self.exc_info()) + import SCons.compat.six + SCons.compat.six.reraise(*self.exc_info()) class AlwaysTask(Task): def needs_execute(self): @@ -940,7 +940,7 @@ class Taskmaster(object): executor = node.get_executor() if executor is None: return None - + tlist = executor.get_all_targets() task = self.tasker(self, tlist, node in self.original_top, node) diff --git a/src/engine/SCons/Tool/xgettext.py b/src/engine/SCons/Tool/xgettext.py index f9375a2..923fd17 100644 --- a/src/engine/SCons/Tool/xgettext.py +++ b/src/engine/SCons/Tool/xgettext.py @@ -1,10 +1,10 @@ -""" xgettext tool +""" xgettext tool Tool specific initialization of `xgettext` tool. """ # __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 @@ -12,10 +12,10 @@ Tool specific initialization of `xgettext` tool. # 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 @@ -23,7 +23,7 @@ Tool specific initialization of `xgettext` tool. # 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. -from six import u +from SCons.compat.six import u __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -40,12 +40,12 @@ class _CmdRunner(object): self.command = command self.commandstr = commandstr - def __call__(self, target, source, env): + def __call__(self, target, source, env): import SCons.Action import subprocess import os import sys - kw = { + kw = { 'stdin' : 'devnull', 'stdout' : subprocess.PIPE, 'stderr' : subprocess.PIPE, @@ -105,9 +105,9 @@ def _update_pot_file(target, source, env): os.chdir(save_os_cwd) # If the command was not successfull, return error code. if status: return status - + new_content = cmd.out - + if not new_content: # When xgettext finds no internationalized messages, no *.pot is created # (because we don't want to bother translators with empty POT files). @@ -145,7 +145,7 @@ def _update_pot_file(target, source, env): # Print message employing SCons.Action.Action for that. msg = "Not writting " + repr(str(target[0])) + " (" + explain + ")" env.Execute(SCons.Action.Action(nop, msg)) - return 0 + return 0 ############################################################################# ############################################################################# @@ -208,7 +208,7 @@ def _scan_xgettext_from_files(target, source, env, files = None, path = None): contents = re_emptyln.sub("", contents) contents = re_trailws.sub("", contents) depnames = contents.splitlines() - for depname in depnames: + for depname in depnames: depfile = SCons.Node.FS.find_file(depname, dirs) if not depfile: depfile = env.arg2nodes(depname, dirs[0].File) @@ -223,7 +223,7 @@ def _pot_update_emitter(target, source, env): import SCons.Util import SCons.Node.FS - if 'XGETTEXTFROM' in env: + if 'XGETTEXTFROM' in env: xfrom = env['XGETTEXTFROM'] else: return target, source @@ -231,13 +231,13 @@ def _pot_update_emitter(target, source, env): xfrom = [ xfrom ] xfrom = SCons.Util.flatten(xfrom) - + # Prepare list of 'POTFILE.in' files. files = [] for xf in xfrom: if not isinstance(xf, SCons.Node.FS.Base): if SCons.Util.is_String(xf): - # Interpolate variables in strings + # Interpolate variables in strings xf = env.subst(xf, source = source, target = target) xf = env.arg2nodes(xf) files.extend(xf) @@ -275,7 +275,7 @@ def generate(env,**kw): try: env['XGETTEXT'] = _detect_xgettext(env) except: - env['XGETTEXT'] = 'xgettext' + env['XGETTEXT'] = 'xgettext' # NOTE: sources="$SOURCES" would work as well. However, we use following # construction to convert absolute paths provided by scons onto paths # relative to current working dir. Note, that scons expands $SOURCE(S) to diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 052b3fc..3a368cb 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -23,7 +23,7 @@ Various utility functions go here. # 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. -from six import PY2, PY3, u +from SCons.compat.six import PY2, PY3, u __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -348,7 +348,7 @@ def is_Scalar(obj, isinstance=isinstance, StringTypes=StringTypes, SequenceTypes # assumes that the obj argument is a string must of the time. return isinstance(obj, StringTypes) or not isinstance(obj, SequenceTypes) -def do_flatten(sequence, result, isinstance=isinstance, +def do_flatten(sequence, result, isinstance=isinstance, StringTypes=StringTypes, SequenceTypes=SequenceTypes): for item in sequence: if isinstance(item, StringTypes) or not isinstance(item, SequenceTypes): @@ -356,7 +356,7 @@ def do_flatten(sequence, result, isinstance=isinstance, else: do_flatten(item, result) -def flatten(obj, isinstance=isinstance, StringTypes=StringTypes, +def flatten(obj, isinstance=isinstance, StringTypes=StringTypes, SequenceTypes=SequenceTypes, do_flatten=do_flatten): """Flatten a sequence to a non-nested list. @@ -374,7 +374,7 @@ def flatten(obj, isinstance=isinstance, StringTypes=StringTypes, do_flatten(item, result) return result -def flatten_sequence(sequence, isinstance=isinstance, StringTypes=StringTypes, +def flatten_sequence(sequence, isinstance=isinstance, StringTypes=StringTypes, SequenceTypes=SequenceTypes, do_flatten=do_flatten): """Flatten a sequence to a non-nested list. @@ -395,7 +395,7 @@ def flatten_sequence(sequence, isinstance=isinstance, StringTypes=StringTypes, # to_String_for_signature() will use a for_signature() method if the # specified object has one. # -def to_String(s, +def to_String(s, isinstance=isinstance, str=str, UserString=UserString, BaseStringTypes=BaseStringTypes): if isinstance(s,BaseStringTypes): @@ -408,11 +408,11 @@ def to_String(s, else: return str(s) -def to_String_for_subst(s, +def to_String_for_subst(s, isinstance=isinstance, str=str, to_String=to_String, BaseStringTypes=BaseStringTypes, SequenceTypes=SequenceTypes, UserString=UserString): - + # Note that the test cases are sorted by order of probability. if isinstance(s, BaseStringTypes): return s @@ -428,7 +428,7 @@ def to_String_for_subst(s, else: return str(s) -def to_String_for_signature(obj, to_String_for_subst=to_String_for_subst, +def to_String_for_signature(obj, to_String_for_subst=to_String_for_subst, AttributeError=AttributeError): try: f = obj.for_signature @@ -486,7 +486,7 @@ def semi_deepcopy(x): return x.__class__(semi_deepcopy_dict(x)) elif isinstance(x, UserList): return x.__class__(_semi_deepcopy_list(x)) - + return x @@ -632,7 +632,7 @@ else: builtins.WindowsError = WindowsError else: del e - + HKEY_CLASSES_ROOT = None HKEY_LOCAL_MACHINE = None HKEY_CURRENT_USER = None @@ -741,7 +741,7 @@ else: continue return None -def PrependPath(oldpath, newpath, sep = os.pathsep, +def PrependPath(oldpath, newpath, sep = os.pathsep, delete_existing=1, canonicalize=None): """This prepends newpath elements to the given oldpath. Will only add any particular path once (leaving the first one it encounters @@ -760,7 +760,7 @@ def PrependPath(oldpath, newpath, sep = os.pathsep, not move it to the beginning; it will stay where it is in the list. - If canonicalize is not None, it is applied to each element of + If canonicalize is not None, it is applied to each element of newpath before use. """ @@ -782,7 +782,7 @@ def PrependPath(oldpath, newpath, sep = os.pathsep, newpaths=list(map(canonicalize, newpaths)) if not delete_existing: - # First uniquify the old paths, making sure to + # First uniquify the old paths, making sure to # preserve the first instance (in Unix/Linux, # the first one wins), and remembering them in normpaths. # Then insert the new paths at the head of the list @@ -823,7 +823,7 @@ def PrependPath(oldpath, newpath, sep = os.pathsep, else: return sep.join(paths) -def AppendPath(oldpath, newpath, sep = os.pathsep, +def AppendPath(oldpath, newpath, sep = os.pathsep, delete_existing=1, canonicalize=None): """This appends new path elements to the given old path. Will only add any particular path once (leaving the last one it @@ -841,7 +841,7 @@ def AppendPath(oldpath, newpath, sep = os.pathsep, If delete_existing is 0, then adding a path that exists will not move it to the end; it will stay where it is in the list. - If canonicalize is not None, it is applied to each element of + If canonicalize is not None, it is applied to each element of newpath before use. """ @@ -1436,7 +1436,7 @@ else: m.update(to_bytes (str(blck))) f.close() return m.hexdigest() - + def MD5collect(signatures): """ Collects a list of signatures into an aggregate signature. diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py index 3167b9d..c52c910 100644 --- a/src/engine/SCons/UtilTests.py +++ b/src/engine/SCons/UtilTests.py @@ -20,7 +20,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -from six import u +from SCons.compat.six import u __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -697,7 +697,7 @@ bling def test_intern(self): s1 = silent_intern("spam") # Python 3.x does not have a unicode() global function - if sys.version[0] == '2': + if sys.version[0] == '2': s2 = silent_intern(unicode("unicode spam")) s3 = silent_intern(42) s4 = silent_intern("spam") @@ -710,7 +710,7 @@ class MD5TestCase(unittest.TestCase): """Test collecting a list of signatures into a new signature value """ s = list(map(MD5signature, ('111', '222', '333'))) - + assert '698d51a19d8a121ce581499d7b701668' == MD5collect(s[0:1]) assert '8980c988edc2c78cc43ccb718c06efd5' == MD5collect(s[0:2]) assert '53fd88c84ff8a285eb6e0a687e55b8c7' == MD5collect(s) diff --git a/src/engine/SCons/compat/_scons_subprocess.py b/src/engine/SCons/compat/_scons_subprocess.py index e4ac777..a58539d 100644 --- a/src/engine/SCons/compat/_scons_subprocess.py +++ b/src/engine/SCons/compat/_scons_subprocess.py @@ -352,7 +352,7 @@ except that: """ from __future__ import print_function -from six import integer_types +from SCons.compat.six import integer_types import sys mswindows = (sys.platform == "win32") diff --git a/src/engine/SCons/compat/six.py b/src/engine/SCons/compat/six.py new file mode 100755 index 0000000..019130f --- /dev/null +++ b/src/engine/SCons/compat/six.py @@ -0,0 +1,646 @@ +"""Utilities for writing code that runs on Python 2 and 3""" + +# Copyright (c) 2010-2014 Benjamin Peterson +# +# 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. + +import operator +import sys +import types + +__author__ = "Benjamin Peterson " +__version__ = "1.6.1" + + +# Useful for very coarse version differentiation. +PY2 = sys.version_info[0] == 2 +PY3 = sys.version_info[0] == 3 + +if PY3: + string_types = str, + integer_types = int, + class_types = type, + text_type = str + binary_type = bytes + + MAXSIZE = sys.maxsize +else: + string_types = basestring, + integer_types = (int, long) + class_types = (type, types.ClassType) + text_type = unicode + binary_type = str + + if sys.platform.startswith("java"): + # Jython always uses 32 bits. + MAXSIZE = int((1 << 31) - 1) + else: + # It's possible to have sizeof(long) != sizeof(Py_ssize_t). + class X(object): + def __len__(self): + return 1 << 31 + try: + len(X()) + except OverflowError: + # 32-bit + MAXSIZE = int((1 << 31) - 1) + else: + # 64-bit + MAXSIZE = int((1 << 63) - 1) + del X + + +def _add_doc(func, doc): + """Add documentation to a function.""" + func.__doc__ = doc + + +def _import_module(name): + """Import module, returning the module after the last dot.""" + __import__(name) + return sys.modules[name] + + +class _LazyDescr(object): + + def __init__(self, name): + self.name = name + + def __get__(self, obj, tp): + try: + result = self._resolve() + except ImportError: + # See the nice big comment in MovedModule.__getattr__. + raise AttributeError("%s could not be imported " % self.name) + setattr(obj, self.name, result) # Invokes __set__. + # This is a bit ugly, but it avoids running this again. + delattr(obj.__class__, self.name) + return result + + +class MovedModule(_LazyDescr): + + def __init__(self, name, old, new=None): + super(MovedModule, self).__init__(name) + if PY3: + if new is None: + new = name + self.mod = new + else: + self.mod = old + + def _resolve(self): + return _import_module(self.mod) + + def __getattr__(self, attr): + # It turns out many Python frameworks like to traverse sys.modules and + # try to load various attributes. This causes problems if this is a + # platform-specific module on the wrong platform, like _winreg on + # Unixes. Therefore, we silently pretend unimportable modules do not + # have any attributes. See issues #51, #53, #56, and #63 for the full + # tales of woe. + # + # First, if possible, avoid loading the module just to look at __file__, + # __name__, or __path__. + if (attr in ("__file__", "__name__", "__path__") and + self.mod not in sys.modules): + raise AttributeError(attr) + try: + _module = self._resolve() + except ImportError: + raise AttributeError(attr) + value = getattr(_module, attr) + setattr(self, attr, value) + return value + + +class _LazyModule(types.ModuleType): + + def __init__(self, name): + super(_LazyModule, self).__init__(name) + self.__doc__ = self.__class__.__doc__ + + def __dir__(self): + attrs = ["__doc__", "__name__"] + attrs += [attr.name for attr in self._moved_attributes] + return attrs + + # Subclasses should override this + _moved_attributes = [] + + +class MovedAttribute(_LazyDescr): + + def __init__(self, name, old_mod, new_mod, old_attr=None, new_attr=None): + super(MovedAttribute, self).__init__(name) + if PY3: + if new_mod is None: + new_mod = name + self.mod = new_mod + if new_attr is None: + if old_attr is None: + new_attr = name + else: + new_attr = old_attr + self.attr = new_attr + else: + self.mod = old_mod + if old_attr is None: + old_attr = name + self.attr = old_attr + + def _resolve(self): + module = _import_module(self.mod) + return getattr(module, self.attr) + + + +class _MovedItems(_LazyModule): + """Lazy loading of moved objects""" + + +_moved_attributes = [ + MovedAttribute("cStringIO", "cStringIO", "io", "StringIO"), + MovedAttribute("filter", "itertools", "builtins", "ifilter", "filter"), + MovedAttribute("filterfalse", "itertools", "itertools", "ifilterfalse", "filterfalse"), + MovedAttribute("input", "__builtin__", "builtins", "raw_input", "input"), + MovedAttribute("map", "itertools", "builtins", "imap", "map"), + MovedAttribute("range", "__builtin__", "builtins", "xrange", "range"), + MovedAttribute("reload_module", "__builtin__", "imp", "reload"), + MovedAttribute("reduce", "__builtin__", "functools"), + MovedAttribute("StringIO", "StringIO", "io"), + MovedAttribute("UserString", "UserString", "collections"), + MovedAttribute("xrange", "__builtin__", "builtins", "xrange", "range"), + MovedAttribute("zip", "itertools", "builtins", "izip", "zip"), + MovedAttribute("zip_longest", "itertools", "itertools", "izip_longest", "zip_longest"), + + MovedModule("builtins", "__builtin__"), + MovedModule("configparser", "ConfigParser"), + MovedModule("copyreg", "copy_reg"), + MovedModule("dbm_gnu", "gdbm", "dbm.gnu"), + MovedModule("http_cookiejar", "cookielib", "http.cookiejar"), + MovedModule("http_cookies", "Cookie", "http.cookies"), + MovedModule("html_entities", "htmlentitydefs", "html.entities"), + MovedModule("html_parser", "HTMLParser", "html.parser"), + MovedModule("http_client", "httplib", "http.client"), + MovedModule("email_mime_multipart", "email.MIMEMultipart", "email.mime.multipart"), + MovedModule("email_mime_text", "email.MIMEText", "email.mime.text"), + MovedModule("email_mime_base", "email.MIMEBase", "email.mime.base"), + MovedModule("BaseHTTPServer", "BaseHTTPServer", "http.server"), + MovedModule("CGIHTTPServer", "CGIHTTPServer", "http.server"), + MovedModule("SimpleHTTPServer", "SimpleHTTPServer", "http.server"), + MovedModule("cPickle", "cPickle", "pickle"), + MovedModule("queue", "Queue"), + MovedModule("reprlib", "repr"), + MovedModule("socketserver", "SocketServer"), + MovedModule("_thread", "thread", "_thread"), + MovedModule("tkinter", "Tkinter"), + MovedModule("tkinter_dialog", "Dialog", "tkinter.dialog"), + MovedModule("tkinter_filedialog", "FileDialog", "tkinter.filedialog"), + MovedModule("tkinter_scrolledtext", "ScrolledText", "tkinter.scrolledtext"), + MovedModule("tkinter_simpledialog", "SimpleDialog", "tkinter.simpledialog"), + MovedModule("tkinter_tix", "Tix", "tkinter.tix"), + MovedModule("tkinter_ttk", "ttk", "tkinter.ttk"), + MovedModule("tkinter_constants", "Tkconstants", "tkinter.constants"), + MovedModule("tkinter_dnd", "Tkdnd", "tkinter.dnd"), + MovedModule("tkinter_colorchooser", "tkColorChooser", + "tkinter.colorchooser"), + MovedModule("tkinter_commondialog", "tkCommonDialog", + "tkinter.commondialog"), + MovedModule("tkinter_tkfiledialog", "tkFileDialog", "tkinter.filedialog"), + MovedModule("tkinter_font", "tkFont", "tkinter.font"), + MovedModule("tkinter_messagebox", "tkMessageBox", "tkinter.messagebox"), + MovedModule("tkinter_tksimpledialog", "tkSimpleDialog", + "tkinter.simpledialog"), + MovedModule("urllib_parse", __name__ + ".moves.urllib_parse", "urllib.parse"), + MovedModule("urllib_error", __name__ + ".moves.urllib_error", "urllib.error"), + MovedModule("urllib", __name__ + ".moves.urllib", __name__ + ".moves.urllib"), + MovedModule("urllib_robotparser", "robotparser", "urllib.robotparser"), + MovedModule("xmlrpc_client", "xmlrpclib", "xmlrpc.client"), + MovedModule("xmlrpc_server", "xmlrpclib", "xmlrpc.server"), + MovedModule("winreg", "_winreg"), +] +for attr in _moved_attributes: + setattr(_MovedItems, attr.name, attr) + if isinstance(attr, MovedModule): + sys.modules[__name__ + ".moves." + attr.name] = attr +del attr + +_MovedItems._moved_attributes = _moved_attributes + +moves = sys.modules[__name__ + ".moves"] = _MovedItems(__name__ + ".moves") + + +class Module_six_moves_urllib_parse(_LazyModule): + """Lazy loading of moved objects in six.moves.urllib_parse""" + + +_urllib_parse_moved_attributes = [ + MovedAttribute("ParseResult", "urlparse", "urllib.parse"), + MovedAttribute("SplitResult", "urlparse", "urllib.parse"), + MovedAttribute("parse_qs", "urlparse", "urllib.parse"), + MovedAttribute("parse_qsl", "urlparse", "urllib.parse"), + MovedAttribute("urldefrag", "urlparse", "urllib.parse"), + MovedAttribute("urljoin", "urlparse", "urllib.parse"), + MovedAttribute("urlparse", "urlparse", "urllib.parse"), + MovedAttribute("urlsplit", "urlparse", "urllib.parse"), + MovedAttribute("urlunparse", "urlparse", "urllib.parse"), + MovedAttribute("urlunsplit", "urlparse", "urllib.parse"), + MovedAttribute("quote", "urllib", "urllib.parse"), + MovedAttribute("quote_plus", "urllib", "urllib.parse"), + MovedAttribute("unquote", "urllib", "urllib.parse"), + MovedAttribute("unquote_plus", "urllib", "urllib.parse"), + MovedAttribute("urlencode", "urllib", "urllib.parse"), + MovedAttribute("splitquery", "urllib", "urllib.parse"), +] +for attr in _urllib_parse_moved_attributes: + setattr(Module_six_moves_urllib_parse, attr.name, attr) +del attr + +Module_six_moves_urllib_parse._moved_attributes = _urllib_parse_moved_attributes + +sys.modules[__name__ + ".moves.urllib_parse"] = sys.modules[__name__ + ".moves.urllib.parse"] = Module_six_moves_urllib_parse(__name__ + ".moves.urllib_parse") + + +class Module_six_moves_urllib_error(_LazyModule): + """Lazy loading of moved objects in six.moves.urllib_error""" + + +_urllib_error_moved_attributes = [ + MovedAttribute("URLError", "urllib2", "urllib.error"), + MovedAttribute("HTTPError", "urllib2", "urllib.error"), + MovedAttribute("ContentTooShortError", "urllib", "urllib.error"), +] +for attr in _urllib_error_moved_attributes: + setattr(Module_six_moves_urllib_error, attr.name, attr) +del attr + +Module_six_moves_urllib_error._moved_attributes = _urllib_error_moved_attributes + +sys.modules[__name__ + ".moves.urllib_error"] = sys.modules[__name__ + ".moves.urllib.error"] = Module_six_moves_urllib_error(__name__ + ".moves.urllib.error") + + +class Module_six_moves_urllib_request(_LazyModule): + """Lazy loading of moved objects in six.moves.urllib_request""" + + +_urllib_request_moved_attributes = [ + MovedAttribute("urlopen", "urllib2", "urllib.request"), + MovedAttribute("install_opener", "urllib2", "urllib.request"), + MovedAttribute("build_opener", "urllib2", "urllib.request"), + MovedAttribute("pathname2url", "urllib", "urllib.request"), + MovedAttribute("url2pathname", "urllib", "urllib.request"), + MovedAttribute("getproxies", "urllib", "urllib.request"), + MovedAttribute("Request", "urllib2", "urllib.request"), + MovedAttribute("OpenerDirector", "urllib2", "urllib.request"), + MovedAttribute("HTTPDefaultErrorHandler", "urllib2", "urllib.request"), + MovedAttribute("HTTPRedirectHandler", "urllib2", "urllib.request"), + MovedAttribute("HTTPCookieProcessor", "urllib2", "urllib.request"), + MovedAttribute("ProxyHandler", "urllib2", "urllib.request"), + MovedAttribute("BaseHandler", "urllib2", "urllib.request"), + MovedAttribute("HTTPPasswordMgr", "urllib2", "urllib.request"), + MovedAttribute("HTTPPasswordMgrWithDefaultRealm", "urllib2", "urllib.request"), + MovedAttribute("AbstractBasicAuthHandler", "urllib2", "urllib.request"), + MovedAttribute("HTTPBasicAuthHandler", "urllib2", "urllib.request"), + MovedAttribute("ProxyBasicAuthHandler", "urllib2", "urllib.request"), + MovedAttribute("AbstractDigestAuthHandler", "urllib2", "urllib.request"), + MovedAttribute("HTTPDigestAuthHandler", "urllib2", "urllib.request"), + MovedAttribute("ProxyDigestAuthHandler", "urllib2", "urllib.request"), + MovedAttribute("HTTPHandler", "urllib2", "urllib.request"), + MovedAttribute("HTTPSHandler", "urllib2", "urllib.request"), + MovedAttribute("FileHandler", "urllib2", "urllib.request"), + MovedAttribute("FTPHandler", "urllib2", "urllib.request"), + MovedAttribute("CacheFTPHandler", "urllib2", "urllib.request"), + MovedAttribute("UnknownHandler", "urllib2", "urllib.request"), + MovedAttribute("HTTPErrorProcessor", "urllib2", "urllib.request"), + MovedAttribute("urlretrieve", "urllib", "urllib.request"), + MovedAttribute("urlcleanup", "urllib", "urllib.request"), + MovedAttribute("URLopener", "urllib", "urllib.request"), + MovedAttribute("FancyURLopener", "urllib", "urllib.request"), + MovedAttribute("proxy_bypass", "urllib", "urllib.request"), +] +for attr in _urllib_request_moved_attributes: + setattr(Module_six_moves_urllib_request, attr.name, attr) +del attr + +Module_six_moves_urllib_request._moved_attributes = _urllib_request_moved_attributes + +sys.modules[__name__ + ".moves.urllib_request"] = sys.modules[__name__ + ".moves.urllib.request"] = Module_six_moves_urllib_request(__name__ + ".moves.urllib.request") + + +class Module_six_moves_urllib_response(_LazyModule): + """Lazy loading of moved objects in six.moves.urllib_response""" + + +_urllib_response_moved_attributes = [ + MovedAttribute("addbase", "urllib", "urllib.response"), + MovedAttribute("addclosehook", "urllib", "urllib.response"), + MovedAttribute("addinfo", "urllib", "urllib.response"), + MovedAttribute("addinfourl", "urllib", "urllib.response"), +] +for attr in _urllib_response_moved_attributes: + setattr(Module_six_moves_urllib_response, attr.name, attr) +del attr + +Module_six_moves_urllib_response._moved_attributes = _urllib_response_moved_attributes + +sys.modules[__name__ + ".moves.urllib_response"] = sys.modules[__name__ + ".moves.urllib.response"] = Module_six_moves_urllib_response(__name__ + ".moves.urllib.response") + + +class Module_six_moves_urllib_robotparser(_LazyModule): + """Lazy loading of moved objects in six.moves.urllib_robotparser""" + + +_urllib_robotparser_moved_attributes = [ + MovedAttribute("RobotFileParser", "robotparser", "urllib.robotparser"), +] +for attr in _urllib_robotparser_moved_attributes: + setattr(Module_six_moves_urllib_robotparser, attr.name, attr) +del attr + +Module_six_moves_urllib_robotparser._moved_attributes = _urllib_robotparser_moved_attributes + +sys.modules[__name__ + ".moves.urllib_robotparser"] = sys.modules[__name__ + ".moves.urllib.robotparser"] = Module_six_moves_urllib_robotparser(__name__ + ".moves.urllib.robotparser") + + +class Module_six_moves_urllib(types.ModuleType): + """Create a six.moves.urllib namespace that resembles the Python 3 namespace""" + parse = sys.modules[__name__ + ".moves.urllib_parse"] + error = sys.modules[__name__ + ".moves.urllib_error"] + request = sys.modules[__name__ + ".moves.urllib_request"] + response = sys.modules[__name__ + ".moves.urllib_response"] + robotparser = sys.modules[__name__ + ".moves.urllib_robotparser"] + + def __dir__(self): + return ['parse', 'error', 'request', 'response', 'robotparser'] + + +sys.modules[__name__ + ".moves.urllib"] = Module_six_moves_urllib(__name__ + ".moves.urllib") + + +def add_move(move): + """Add an item to six.moves.""" + setattr(_MovedItems, move.name, move) + + +def remove_move(name): + """Remove item from six.moves.""" + try: + delattr(_MovedItems, name) + except AttributeError: + try: + del moves.__dict__[name] + except KeyError: + raise AttributeError("no such move, %r" % (name,)) + + +if PY3: + _meth_func = "__func__" + _meth_self = "__self__" + + _func_closure = "__closure__" + _func_code = "__code__" + _func_defaults = "__defaults__" + _func_globals = "__globals__" + + _iterkeys = "keys" + _itervalues = "values" + _iteritems = "items" + _iterlists = "lists" +else: + _meth_func = "im_func" + _meth_self = "im_self" + + _func_closure = "func_closure" + _func_code = "func_code" + _func_defaults = "func_defaults" + _func_globals = "func_globals" + + _iterkeys = "iterkeys" + _itervalues = "itervalues" + _iteritems = "iteritems" + _iterlists = "iterlists" + + +try: + advance_iterator = next +except NameError: + def advance_iterator(it): + return it.next() +next = advance_iterator + + +try: + callable = callable +except NameError: + def callable(obj): + return any("__call__" in klass.__dict__ for klass in type(obj).__mro__) + + +if PY3: + def get_unbound_function(unbound): + return unbound + + create_bound_method = types.MethodType + + Iterator = object +else: + def get_unbound_function(unbound): + return unbound.im_func + + def create_bound_method(func, obj): + return types.MethodType(func, obj, obj.__class__) + + class Iterator(object): + + def next(self): + return type(self).__next__(self) + + callable = callable +_add_doc(get_unbound_function, + """Get the function out of a possibly unbound function""") + + +get_method_function = operator.attrgetter(_meth_func) +get_method_self = operator.attrgetter(_meth_self) +get_function_closure = operator.attrgetter(_func_closure) +get_function_code = operator.attrgetter(_func_code) +get_function_defaults = operator.attrgetter(_func_defaults) +get_function_globals = operator.attrgetter(_func_globals) + + +def iterkeys(d, **kw): + """Return an iterator over the keys of a dictionary.""" + return iter(getattr(d, _iterkeys)(**kw)) + +def itervalues(d, **kw): + """Return an iterator over the values of a dictionary.""" + return iter(getattr(d, _itervalues)(**kw)) + +def iteritems(d, **kw): + """Return an iterator over the (key, value) pairs of a dictionary.""" + return iter(getattr(d, _iteritems)(**kw)) + +def iterlists(d, **kw): + """Return an iterator over the (key, [values]) pairs of a dictionary.""" + return iter(getattr(d, _iterlists)(**kw)) + + +if PY3: + def b(s): + return s.encode("latin-1") + def u(s): + return s + unichr = chr + if sys.version_info[1] <= 1: + def int2byte(i): + return bytes((i,)) + else: + # This is about 2x faster than the implementation above on 3.2+ + int2byte = operator.methodcaller("to_bytes", 1, "big") + byte2int = operator.itemgetter(0) + indexbytes = operator.getitem + iterbytes = iter + import io + StringIO = io.StringIO + BytesIO = io.BytesIO +else: + def b(s): + return s + # Workaround for standalone backslash + def u(s): + return unicode(s.replace(r'\\', r'\\\\'), "unicode_escape") + unichr = unichr + int2byte = chr + def byte2int(bs): + return ord(bs[0]) + def indexbytes(buf, i): + return ord(buf[i]) + def iterbytes(buf): + return (ord(byte) for byte in buf) + import StringIO + StringIO = BytesIO = StringIO.StringIO +_add_doc(b, """Byte literal""") +_add_doc(u, """Text literal""") + + +if PY3: + exec_ = getattr(moves.builtins, "exec") + + + def reraise(tp, value, tb=None): + if value.__traceback__ is not tb: + raise value.with_traceback(tb) + raise value + +else: + def exec_(_code_, _globs_=None, _locs_=None): + """Execute code in a namespace.""" + if _globs_ is None: + frame = sys._getframe(1) + _globs_ = frame.f_globals + if _locs_ is None: + _locs_ = frame.f_locals + del frame + elif _locs_ is None: + _locs_ = _globs_ + exec("""exec _code_ in _globs_, _locs_""") + + + exec_("""def reraise(tp, value, tb=None): + raise tp, value, tb +""") + + +print_ = getattr(moves.builtins, "print", None) +if print_ is None: + def print_(*args, **kwargs): + """The new-style print function for Python 2.4 and 2.5.""" + fp = kwargs.pop("file", sys.stdout) + if fp is None: + return + def write(data): + if not isinstance(data, basestring): + data = str(data) + # If the file has an encoding, encode unicode with it. + if (isinstance(fp, file) and + isinstance(data, unicode) and + fp.encoding is not None): + errors = getattr(fp, "errors", None) + if errors is None: + errors = "strict" + data = data.encode(fp.encoding, errors) + fp.write(data) + want_unicode = False + sep = kwargs.pop("sep", None) + if sep is not None: + if isinstance(sep, unicode): + want_unicode = True + elif not isinstance(sep, str): + raise TypeError("sep must be None or a string") + end = kwargs.pop("end", None) + if end is not None: + if isinstance(end, unicode): + want_unicode = True + elif not isinstance(end, str): + raise TypeError("end must be None or a string") + if kwargs: + raise TypeError("invalid keyword arguments to print()") + if not want_unicode: + for arg in args: + if isinstance(arg, unicode): + want_unicode = True + break + if want_unicode: + newline = unicode("\n") + space = unicode(" ") + else: + newline = "\n" + space = " " + if sep is None: + sep = space + if end is None: + end = newline + for i, arg in enumerate(args): + if i: + write(sep) + write(arg) + write(end) + +_add_doc(reraise, """Reraise an exception.""") + + +def with_metaclass(meta, *bases): + """Create a base class with a metaclass.""" + return meta("NewBase", bases, {}) + +def add_metaclass(metaclass): + """Class decorator for creating a class with a metaclass.""" + def wrapper(cls): + orig_vars = cls.__dict__.copy() + orig_vars.pop('__dict__', None) + orig_vars.pop('__weakref__', None) + slots = orig_vars.get('__slots__') + if slots is not None: + if isinstance(slots, str): + slots = [slots] + for slots_var in slots: + orig_vars.pop(slots_var) + return metaclass(cls.__name__, cls.__bases__, orig_vars) + return wrapper diff --git a/src/engine/SCons/compat/sixTests.py b/src/engine/SCons/compat/sixTests.py new file mode 100644 index 0000000..f8c1979 --- /dev/null +++ b/src/engine/SCons/compat/sixTests.py @@ -0,0 +1,34 @@ +# +# __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. +# + +import unittest + +class sixTestCase(unittest.TestCase): + + def test_import(self): + """Test that six imports correctly.""" + import sys + print sys.path + from SCons.compat.six import PY2, PY3 + self.assertTrue(PY2 or PY3) + diff --git a/src/script/sconsign.py b/src/script/sconsign.py index e99a741..9f75e3a 100644 --- a/src/script/sconsign.py +++ b/src/script/sconsign.py @@ -24,7 +24,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. from __future__ import print_function -from six import PY2, PY3 +from SCons.compat.six import PY2, PY3 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -85,7 +85,7 @@ try: except ImportError: pass else: - # when running from an egg add the egg's directory + # when running from an egg add the egg's directory try: d = pkg_resources.get_distribution('scons') except pkg_resources.DistributionNotFound: diff --git a/test/option/profile.py b/test/option/profile.py index 97f84db..f408136 100644 --- a/test/option/profile.py +++ b/test/option/profile.py @@ -21,7 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -from six import u +from SCons.compat.six import u __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -113,7 +113,7 @@ memory_lines = [l for l in lines if l.find(expect) != -1] test.fail_test(len(memory_lines) != 1) - + test.pass_test() -- cgit v0.12 From 98bb69c7c9e13ea57ae7e6e8db4740a4dd43ed16 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Wed, 25 Feb 2015 21:02:49 -0800 Subject: remove extra parens causing syntax error --- src/engine/SCons/Script/Main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py index 3ef88c7..556ddd3 100644 --- a/src/engine/SCons/Script/Main.py +++ b/src/engine/SCons/Script/Main.py @@ -373,7 +373,7 @@ class CleanTask(SCons.Taskmaster.AlwaysTask): # the file not existing. In either case, print a # message and keep going to try to remove as many # targets aa possible. - print(("scons: Could not remove '%s':" % str(t), e.strerror) + print("scons: Could not remove '%s':" % str(t), e.strerror) else: if removed: display("Removed " + str(t)) -- cgit v0.12 From f65ea0c5b50572926e11e03c91ebd45b760d073e Mon Sep 17 00:00:00 2001 From: Richard Viney Date: Fri, 18 Sep 2015 19:06:39 +1200 Subject: Fix PCHPDBFLAGS causing a deprecation warning on MSVC v8 and later when using PCHs and PDBs together --- src/engine/SCons/Tool/MSCommon/__init__.py | 3 ++- src/engine/SCons/Tool/msvc.py | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/engine/SCons/Tool/MSCommon/__init__.py b/src/engine/SCons/Tool/MSCommon/__init__.py index fe4a7c6..c87bf71 100644 --- a/src/engine/SCons/Tool/MSCommon/__init__.py +++ b/src/engine/SCons/Tool/MSCommon/__init__.py @@ -41,7 +41,8 @@ from SCons.Tool.MSCommon.sdk import mssdk_exists, \ from SCons.Tool.MSCommon.vc import msvc_exists, \ msvc_setup_env, \ - msvc_setup_env_once + msvc_setup_env_once, \ + msvc_version_to_maj_min from SCons.Tool.MSCommon.vs import get_default_version, \ get_vs_by_version, \ diff --git a/src/engine/SCons/Tool/msvc.py b/src/engine/SCons/Tool/msvc.py index 878ec6e..e6a9428 100644 --- a/src/engine/SCons/Tool/msvc.py +++ b/src/engine/SCons/Tool/msvc.py @@ -47,7 +47,7 @@ import SCons.Util import SCons.Warnings import SCons.Scanner.RC -from MSCommon import msvc_exists, msvc_setup_env_once +from MSCommon import msvc_exists, msvc_setup_env_once, msvc_version_to_maj_min CSuffixes = ['.c', '.C'] CXXSuffixes = ['.cc', '.cpp', '.cxx', '.c++', '.C++'] @@ -259,7 +259,12 @@ def generate(env): env['CFILESUFFIX'] = '.c' env['CXXFILESUFFIX'] = '.cc' - env['PCHPDBFLAGS'] = SCons.Util.CLVar(['${(PDB and "/Yd") or ""}']) + maj, min = msvc_version_to_maj_min(env['MSVC_VERSION']) + if maj < 8: + env['PCHPDBFLAGS'] = SCons.Util.CLVar(['${(PDB and "/Yd") or ""}']) + else: + env['PCHPDBFLAGS'] = '' + env['PCHCOM'] = '$CXX /Fo${TARGETS[1]} $CXXFLAGS $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS /c $SOURCES /Yc$PCHSTOP /Fp${TARGETS[0]} $CCPDBFLAGS $PCHPDBFLAGS' env['BUILDERS']['PCH'] = pch_builder -- cgit v0.12 From 34cf3bdb1743de9a5534bfd25998d0a01297f004 Mon Sep 17 00:00:00 2001 From: Russel Winder Date: Fri, 1 Jan 2016 13:52:31 +0000 Subject: Run futurize --stage1. --- bin/SConsExamples.py | 128 ++++---- bin/memlogs.py | 3 +- bin/memoicmp.py | 7 +- src/engine/SCons/Action.py | 3 +- src/engine/SCons/EnvironmentTests.py | 3 +- src/engine/SCons/Node/__init__.py | 38 +-- src/engine/SCons/Script/Main.py | 6 +- src/engine/SCons/Script/SConscript.py | 4 +- src/engine/SCons/Tool/cyglink.py | 37 ++- src/engine/SCons/Tool/f08.py | 4 +- src/engine/SCons/Tool/msvs.py | 136 ++++---- src/engine/SCons/Tool/swig.py | 5 +- src/engine/SCons/compat/six.py | 4 +- src/engine/SCons/compat/sixTests.py | 3 +- src/engine/SCons/cppTests.py | 4 +- src/script/scons.py | 2 + src/setup.py | 2 + src/test_interrupts.py | 2 + test/LINK/VersionedLib.py | 574 +++++++++++++++++----------------- test/option/debug-multiple.py | 16 +- test/site_scons/sysdirs.py | 6 +- 21 files changed, 509 insertions(+), 478 deletions(-) diff --git a/bin/SConsExamples.py b/bin/SConsExamples.py index e3a7502..dd9bfaf 100644 --- a/bin/SConsExamples.py +++ b/bin/SConsExamples.py @@ -1,7 +1,7 @@ # !/usr/bin/env python -# +# # Copyright (c) 2010 The SCons Foundation -# +# # 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 @@ -9,10 +9,10 @@ # 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 @@ -21,18 +21,18 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# +# +# # This script looks for some XML tags that describe SCons example # configurations and commands to execute in those configurations, and # uses TestCmd.py to execute the commands and insert the output from # those commands into the XML that we output. This way, we can run a # script and update all of our example documentation output without # a lot of laborious by-hand checking. -# +# # An "SCons example" looks like this, and essentially describes a set of # input files (program source files as well as SConscript files): -# +# # # # env = Environment() @@ -42,7 +42,7 @@ # int main() { printf("foo.c\n"); } # # -# +# # The contents within the tag will get written # into a temporary directory whenever example output needs to be # generated. By default, the contents are not inserted into text @@ -50,41 +50,43 @@ # in which case they will get inserted within a tag. # This makes it easy to define the example at the appropriate # point in the text where you intend to show the SConstruct file. -# +# # Note that you should usually give the a "name" # attribute so that you can refer to the example configuration later to # run SCons and generate output. -# +# # If you just want to show a file's contents without worry about running # SCons, there's a shorter tag: -# +# # # env = Environment() # env.Program('foo') # -# +# # This is essentially equivalent to , # but it's more straightforward. -# +# # SCons output is generated from the following sort of tag: -# +# # # scons -Q foo # scons -Q foo # -# +# # You tell it which example to use with the "example" attribute, and then # give it a list of tags to execute. You can also # supply an "os" tag, which specifies the type of operating system this # example is intended to show; if you omit this, default value is "posix". -# +# # The generated XML will show the command line (with the appropriate # command-line prompt for the operating system), execute the command in # a temporary directory with the example files, capture the standard # output from SCons, and insert it into the text as appropriate. # Error output gets passed through to your error output so you # can see if there are any problems executing the command. -# +# + +from __future__ import print_function import os import re @@ -94,9 +96,9 @@ import time import SConsDoc from SConsDoc import tf as stf -# +# # The available types for ExampleFile entries -# +# FT_FILE = 0 # a physical file (=) FT_FILEREF = 1 # a reference (=) @@ -106,7 +108,7 @@ class ExampleFile: self.name = '' self.content = '' self.chmod = '' - + def isFileRef(self): return self.type == FT_FILEREF @@ -130,19 +132,19 @@ class ExampleOutput: self.preserve = None self.suffix = '' self.commands = [] - + class ExampleInfo: def __init__(self): self.name = '' self.files = [] self.folders = [] self.outputs = [] - + def getFileContents(self, fname): for f in self.files: if fname == f.name and not f.isFileRef(): return f.content - + return '' def readExampleInfos(fpath, examples): @@ -150,10 +152,10 @@ def readExampleInfos(fpath, examples): global dictionary examples. """ - # Create doctree + # Create doctree t = SConsDoc.SConsDocTree() t.parseXmlFile(fpath) - + # Parse scons_examples for e in stf.findAll(t.root, "scons_example", SConsDoc.dbxid, t.xpath_context, t.nsmap): @@ -164,7 +166,7 @@ def readExampleInfos(fpath, examples): i = ExampleInfo() i.name = n examples[n] = i - + # Parse file and directory entries for f in stf.findAll(e, "file", SConsDoc.dbxid, t.xpath_context, t.nsmap): @@ -199,8 +201,8 @@ def readExampleInfos(fpath, examples): fi.chmod = stf.getAttribute(f, 'chmod') fi.content = stf.getText(f) examples[e].files.append(fi) - - + + # Parse scons_output for o in stf.findAll(t.root, "scons_output", SConsDoc.dbxid, t.xpath_context, t.nsmap): @@ -238,7 +240,7 @@ def readExampleInfos(fpath, examples): examples[n].outputs.append(eout) def readAllExampleInfos(dpath): - """ Scan for XML files in the given directory and + """ Scan for XML files in the given directory and collect together all relevant infos (files/folders, output commands) in a map, which gets returned. """ @@ -249,13 +251,13 @@ def readAllExampleInfos(dpath): fpath = os.path.join(path, f) if SConsDoc.isSConsXml(fpath): readExampleInfos(fpath, examples) - + return examples generated_examples = os.path.join('doc', 'generated', 'examples') def ensureExampleOutputsExist(dpath): - """ Scan for XML files in the given directory and + """ Scan for XML files in the given directory and ensure that for every example output we have a corresponding output file in the 'generated/examples' folder. @@ -263,7 +265,7 @@ def ensureExampleOutputsExist(dpath): # Ensure that the output folder exists if not os.path.isdir(generated_examples): os.mkdir(generated_examples) - + examples = readAllExampleInfos(dpath) for key, value in examples.items(): # Process all scons_output tags @@ -276,7 +278,7 @@ def ensureExampleOutputsExist(dpath): stf.setText(s, "NO OUTPUT YET! Run the script to generate/update all examples.") # Write file stf.writeTree(s, cpath) - + # Process all scons_example_file tags for r in value.files: if r.isFileRef(): @@ -292,14 +294,14 @@ def ensureExampleOutputsExist(dpath): perc = "%" def createAllExampleOutputs(dpath): - """ Scan for XML files in the given directory and + """ Scan for XML files in the given directory and creates all output files for every example in the 'generated/examples' folder. """ # Ensure that the output folder exists if not os.path.isdir(generated_examples): os.mkdir(generated_examples) - + examples = readAllExampleInfos(dpath) total = len(examples) idx = 0 @@ -307,7 +309,7 @@ def createAllExampleOutputs(dpath): # Process all scons_output tags print("%.2f%s (%d/%d) %s" % (float(idx + 1) * 100.0 / float(total), perc, idx + 1, total, key)) - + create_scons_output(value) # Process all scons_example_file tags for r in value.files: @@ -329,10 +331,10 @@ def collectSConsExampleNames(fpath): suffixes = {} failed_suffixes = False - # Create doctree + # Create doctree t = SConsDoc.SConsDocTree() t.parseXmlFile(fpath) - + # Parse it for e in stf.findAll(t.root, "scons_example", SConsDoc.dbxid, t.xpath_context, t.nsmap): @@ -346,7 +348,7 @@ def collectSConsExampleNames(fpath): else: print("Error: Example in file '%s' is missing a name!" % fpath) failed_suffixes = True - + for o in stf.findAll(t.root, "scons_output", SConsDoc.dbxid, t.xpath_context, t.nsmap): n = '' @@ -355,29 +357,29 @@ def collectSConsExampleNames(fpath): else: print("Error: scons_output in file '%s' is missing an example name!" % fpath) failed_suffixes = True - + if n not in suffixes: print("Error: scons_output in file '%s' is referencing non-existent example '%s'!" % (fpath, n)) failed_suffixes = True continue - + s = '' if stf.hasAttribute(o, 'suffix'): s = stf.getAttribute(o, 'suffix') else: print("Error: scons_output in file '%s' (example '%s') is missing a suffix!" % (fpath, n)) failed_suffixes = True - + if s not in suffixes[n]: suffixes[n].append(s) else: print("Error: scons_output in file '%s' (example '%s') is using a duplicate suffix '%s'!" % (fpath, n, s)) failed_suffixes = True - + return names, failed_suffixes def exampleNamesAreUnique(dpath): - """ Scan for XML files in the given directory and + """ Scan for XML files in the given directory and check whether the scons_example names are unique. """ unique = True @@ -394,19 +396,19 @@ def exampleNamesAreUnique(dpath): if i: print("Not unique in %s are: %s" % (fpath, ', '.join(i))) unique = False - + allnames |= names - + return unique # ############################################################### -# +# # In the second half of this module (starting here) # we define the variables and functions that are required # to actually run the examples, collect their output and # write it into the files in doc/generated/examples... # which then get included by our UserGuide. -# +# # ############################################################### sys.path.append(os.path.join(os.getcwd(), 'QMTest')) @@ -430,7 +432,7 @@ Prompt = { } # The magick SCons hackery that makes this work. -# +# # So that our examples can still use the default SConstruct file, we # actually feed the following into SCons via stdin and then have it # SConscript() the SConstruct file. This stdin wrapper creates a set @@ -438,7 +440,7 @@ Prompt = { # Surrogates print output like the real tools and behave like them # without actually having to be on the right platform or have the right # tool installed. -# +# # The upshot: The wrapper transparently changes the world out from # under the top-level SConstruct file in an example just so we can get # the command output. @@ -765,7 +767,7 @@ def ExecuteCommand(args, c, t, dict): def create_scons_output(e): # The real raison d'etre for this script, this is where we # actually execute SCons to fetch the output. - + # Loop over all outputs for the example for o in e.outputs: # Create new test directory @@ -774,19 +776,19 @@ def create_scons_output(e): t.preserve() t.subdir('ROOT', 'WORK') t.rootpath = t.workpath('ROOT').replace('\\', '\\\\') - + for d in e.folders: dir = t.workpath('WORK', d.name) if not os.path.exists(dir): os.makedirs(dir) - + for f in e.files: if f.isFileRef(): continue - # + # # Left-align file's contents, starting on the first # non-empty line - # + # data = f.content.split('\n') i = 0 # Skip empty lines @@ -813,26 +815,26 @@ def create_scons_output(e): if hasattr(f, 'chmod'): if len(f.chmod): os.chmod(path, int(f.chmod, 0)) - + # Regular expressions for making the doc output consistent, # regardless of reported addresses or Python version. - + # Massage addresses in object repr strings to a constant. address_re = re.compile(r' at 0x[0-9a-fA-F]*\>') - + # Massage file names in stack traces (sometimes reported as absolute # paths) to a consistent relative path. engine_re = re.compile(r' File ".*/src/engine/SCons/') - + # Python 2.5 changed the stack trace when the module is read # from standard input from read "... line 7, in ?" to # "... line 7, in ". file_re = re.compile(r'^( *File ".*", line \d+, in) \?$', re.M) - + # Python 2.6 made UserList a new-style class, which changes the # AttributeError message generated by our NodeList subclass. nodelist_re = re.compile(r'(AttributeError:) NodeList instance (has no attribute \S+)') - + # Root element for our subtree sroot = stf.newEtreeNode("screen", True) curchild = None @@ -881,7 +883,7 @@ def create_scons_output(e): curchild.tail = content else: sroot.text = content - + # Construct filename fpath = os.path.join(generated_examples, e.name + '_' + o.suffix + '.xml') diff --git a/bin/memlogs.py b/bin/memlogs.py index 6e68ce0..b450939 100644 --- a/bin/memlogs.py +++ b/bin/memlogs.py @@ -20,7 +20,8 @@ # 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. -from future import print_function + +from __future__ import print_function import getopt import sys diff --git a/bin/memoicmp.py b/bin/memoicmp.py index 1106ac3..7f0369e 100644 --- a/bin/memoicmp.py +++ b/bin/memoicmp.py @@ -2,7 +2,8 @@ # # A script to compare the --debug=memoizer output found in # two different files. -from future import print_function + +from __future__ import print_function import sys @@ -46,7 +47,7 @@ def memoize_cmp(filea, fileb): mab.sort() ma_o.sort() mb_o.sort() - + for k in mab: hits = cfmt%(ma[k][0], mb[k][0], mb[k][0]-ma[k][0]) miss = cfmt%(ma[k][1], mb[k][1], mb[k][1]-ma[k][1]) @@ -63,7 +64,7 @@ def memoize_cmp(filea, fileb): print('%-24s %-24s %s'%(hits, miss, k)) print('-'*(24+24+1+20)) - + if __name__ == "__main__": if len(sys.argv) != 3: diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index d11f30d..a4e75f3 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -101,7 +101,6 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import dis import os -# compat layer imports "cPickle" for us if it's available. import pickle import re import sys @@ -272,7 +271,7 @@ def _function_contents(func): contents.append(b',()') # The function contents depends on the closure captured cell values. - closure = func.func_closure or [] + closure = func.__closure__ or [] #xxx = [_object_contents(x.cell_contents) for x in closure] try: diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index 99d169a..4b57763 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -20,6 +20,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # + from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -1868,7 +1869,7 @@ def generate(env): # test for pull request #150 env = self.TestEnvironment() env._dict.pop('BUILDERS') - assert env.has_key('BUILDERS') is False + assert ('BUILDERS' in env) is False env2 = env.Clone() def test_Copy(self): diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 85e30c2..1a76b60 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -19,6 +19,8 @@ be able to depend on any other type of "thing." """ +from __future__ import print_function + # # __COPYRIGHT__ # @@ -151,7 +153,7 @@ def exists_file(node): # The source file does not exist. Make sure no old # copy remains in the variant directory. if print_duplicate: - print "dup: no src for %s, unlinking old variant copy"%self + print("dup: no src for %s, unlinking old variant copy"%self) if exists_base(node) or node.islink(): node.fs.unlink(node.get_internal_path()) # Return None explicitly because the Base.exists() call @@ -205,13 +207,13 @@ def get_contents_dir(node): contents.append('%s %s\n' % (n.get_csig(), n.name)) return ''.join(contents) -def get_contents_file(node): +def get_contents_file(node): if not node.rexists(): return '' fname = node.rfile().get_abspath() try: contents = open(fname, "rb").read() - except EnvironmentError, e: + except EnvironmentError as e: if not e.filename: e.filename = fname raise @@ -407,21 +409,21 @@ class NodeInfoBase(object): for name in getattr(obj,'__slots__',()): if hasattr(self, name): state[name] = getattr(self, name) - + state['_version_id'] = self.current_version_id try: del state['__weakref__'] except KeyError: pass return state - + def __setstate__(self, state): """ Restore the attributes from a pickled state. The version is discarded. """ # TODO check or discard version del state['_version_id'] - + for key, value in state.items(): if key not in ('__weakref__',): setattr(self, key, value) @@ -456,7 +458,7 @@ class BuildInfoBase(object): """ state = other.__getstate__() self.__setstate__(state) - + def __getstate__(self): """ Return all fields that shall be pickled. Walk the slots in the class @@ -536,7 +538,7 @@ class Node(object): class Attrs(object): __slots__ = ('shared', '__dict__') - + def __init__(self): if SCons.Debug.track_instances: logInstanceCreation(self, 'Node.Node') @@ -588,7 +590,7 @@ class Node(object): self._func_rexists = 1 self._func_get_contents = 0 self._func_target_from_source = 0 - + self.clear_memoized_values() # Let the interface in which the build engine is embedded @@ -776,16 +778,16 @@ class Node(object): def release_target_info(self): """Called just after this node has been marked up-to-date or was built completely. - + This is where we try to release as many target node infos as possible for clean builds and update runs, in order to minimize the overall memory consumption. - + By purging attributes that aren't needed any longer after a Node (=File) got built, we don't have to care that much how many KBytes a Node actually requires...as long as we free the memory shortly afterwards. - + @see: built() and File.release_target_info() """ pass @@ -934,7 +936,7 @@ class Node(object): node = nodes.pop(0) scanner = node._get_scanner(env, initial_scanner, root_node_scanner, kw) - + if not scanner: continue @@ -958,14 +960,14 @@ class Node(object): else: # handle explicit scanner case scanner = initial_scanner.select(self) - + if not scanner: # no scanner could be found for the given node's scanner key; # thus, make an attempt at using a default. scanner = root_node_scanner - + return scanner - + def get_env_scanner(self, env, kw={}): return env.get_scanner(self.scanner_key()) @@ -1422,14 +1424,14 @@ class Node(object): any difference, but we now rely on checking every dependency to make sure that any necessary Node information (for example, the content signature of an #included .h file) is updated. - + The allowcache option was added for supporting the early release of the executor/builder structures, right after a File target was built. When set to true, the return value of this changed method gets cached for File nodes. Like this, the executor isn't needed any longer for subsequent calls to changed(). - + @see: FS.File.changed(), FS.File.release_target_info() """ t = 0 diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py index 71d64fc..7cc7d47 100644 --- a/src/engine/SCons/Script/Main.py +++ b/src/engine/SCons/Script/Main.py @@ -10,6 +10,8 @@ some other module. If it's specific to the "scons" script invocation, it goes here. """ +from __future__ import print_function + unsupported_python_version = (2, 6, 0) deprecated_python_version = (2, 7, 0) @@ -354,13 +356,13 @@ class CleanTask(SCons.Taskmaster.AlwaysTask): for t in self._get_files_to_clean(): try: removed = t.remove() - except OSError, e: + except OSError as e: # An OSError may indicate something like a permissions # issue, an IOError would indicate something like # the file not existing. In either case, print a # message and keep going to try to remove as many # targets as possible. - print("scons: Could not remove '{}':".format(str(t)), e.strerror) + print(("scons: Could not remove '{}':".format(str(t)), e.strerror)) else: if removed: display("Removed " + str(t)) diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py index ab032be..6480ace 100644 --- a/src/engine/SCons/Script/SConscript.py +++ b/src/engine/SCons/Script/SConscript.py @@ -5,6 +5,8 @@ files. """ +from __future__ import print_function + # # __COPYRIGHT__ # @@ -68,7 +70,7 @@ def get_calling_namespaces(): """Return the locals and globals for the function that called into this module in the current call stack.""" try: 1//0 - except ZeroDivisionError: + except ZeroDivisionError: # Don't start iterating with the current stack-frame to # prevent creating reference cycles (f_back is safe). frame = sys.exc_info()[2].tb_frame.f_back diff --git a/src/engine/SCons/Tool/cyglink.py b/src/engine/SCons/Tool/cyglink.py index 2f54a17..f69b886 100644 --- a/src/engine/SCons/Tool/cyglink.py +++ b/src/engine/SCons/Tool/cyglink.py @@ -7,6 +7,9 @@ It will usually be imported through the generic SCons.Tool.Tool() selection method. """ + +from __future__ import absolute_import, print_function + import re import os @@ -15,8 +18,8 @@ import SCons.Util import SCons.Tool #MAYBE: from . import gnulink -import gnulink -import link +from . import gnulink +from . import link def _lib_generator(target, source, env, for_signature, **kw): try: cmd = kw['cmd'] @@ -59,7 +62,7 @@ def _lib_emitter(target, source, env, **kw): Verbose = False if Verbose: - print "_lib_emitter: target[0]=%r" % target[0].get_path() + print("_lib_emitter: target[0]=%r" % target[0].get_path()) try: vp = kw['varprefix'] except KeyError: vp = 'SHLIB' @@ -71,7 +74,7 @@ def _lib_emitter(target, source, env, **kw): no_import_lib = env.get('no_import_lib', 0) if Verbose: - print "_lib_emitter: dll=%r" % dll.get_path() + print("_lib_emitter: dll=%r" % dll.get_path()) if not dll or len(target) > 1: raise SCons.Errors.UserError("A shared library should have exactly one target with the suffix: %s" % env.subst("$%sSUFFIX" % vp)) @@ -82,14 +85,14 @@ def _lib_emitter(target, source, env, **kw): dll.name = pre + dll.name[len(pre)+3:] if Verbose: - print "_lib_emitter: dll.name=%r" % dll.name + print("_lib_emitter: dll.name=%r" % dll.name) orig_target = target target = [env.fs.File(dll)] target[0].attributes.shared = 1 if Verbose: - print "_lib_emitter: after target=[env.fs.File(dll)]: target[0]=%r" % target[0].get_path() + print("_lib_emitter: after target=[env.fs.File(dll)]: target[0]=%r" % target[0].get_path()) # Append an import lib target if not no_import_lib: @@ -98,11 +101,11 @@ def _lib_emitter(target, source, env, **kw): '%sPREFIX' % vp, '%sSUFFIX' % vp, 'IMPLIBPREFIX', 'IMPLIBSUFFIX') if Verbose: - print "_lib_emitter: target_strings=%r" % target_strings + print("_lib_emitter: target_strings=%r" % target_strings) implib_target = env.fs.File(target_strings) if Verbose: - print "_lib_emitter: implib_target=%r" % implib_target.get_path() + print("_lib_emitter: implib_target=%r" % implib_target.get_path()) implib_target.attributes.shared = 1 target.append(implib_target) @@ -110,7 +113,7 @@ def _lib_emitter(target, source, env, **kw): implib_libtype=libtype, generator_libtype=libtype+'ImpLib') if Verbose: - print "_lib_emitter: implib symlinks=%r" % SCons.Tool.StringizeLibSymlinks(symlinks) + print("_lib_emitter: implib symlinks=%r" % SCons.Tool.StringizeLibSymlinks(symlinks)) if symlinks: SCons.Tool.EmitLibSymlinks(env, symlinks, implib_target, clean_targets = target[0]) implib_target.attributes.shliblinks = symlinks @@ -128,13 +131,13 @@ def _versioned_lib_suffix(env, suffix, version): If suffix='.dll', and version='0.1.2', then it returns '-0-1-2.dll'""" Verbose = False if Verbose: - print "_versioned_lib_suffix: suffix= ", suffix - print "_versioned_lib_suffix: version= ", version + print("_versioned_lib_suffix: suffix= ", suffix) + print("_versioned_lib_suffix: version= ", version) cygversion = re.sub('\.', '-', version) if not suffix.startswith('-' + cygversion): suffix = '-' + cygversion + suffix if Verbose: - print "_versioned_lib_suffix: return suffix= ", suffix + print("_versioned_lib_suffix: return suffix= ", suffix) return suffix def _versioned_implib_name(env, libnode, version, prefix, suffix, **kw): @@ -150,8 +153,8 @@ def _versioned_implib_symlinks(env, libnode, version, prefix, suffix, **kw): Verbose = False if Verbose: - print "_versioned_implib_symlinks: libnode=%r" % libnode.get_path() - print "_versioned_implib_symlinks: version=%r" % version + print("_versioned_implib_symlinks: libnode=%r" % libnode.get_path()) + print("_versioned_implib_symlinks: version=%r" % version) try: libtype = kw['libtype'] except KeyError: libtype = 'ShLib' @@ -159,13 +162,13 @@ def _versioned_implib_symlinks(env, libnode, version, prefix, suffix, **kw): linkdir = os.path.dirname(libnode.get_path()) if Verbose: - print "_versioned_implib_symlinks: linkdir=%r" % linkdir + print("_versioned_implib_symlinks: linkdir=%r" % linkdir) name = SCons.Tool.ImpLibNameGenerator(env, libnode, implib_libtype=libtype, generator_libtype=libtype+'ImpLib') if Verbose: - print "_versioned_implib_symlinks: name=%r" % name + print("_versioned_implib_symlinks: name=%r" % name) major = version.split('.')[0] @@ -173,7 +176,7 @@ def _versioned_implib_symlinks(env, libnode, version, prefix, suffix, **kw): symlinks = [(link0, libnode)] if Verbose: - print "_versioned_implib_symlinks: return symlinks=%r" % SCons.Tool.StringizeLibSymlinks(symlinks) + print("_versioned_implib_symlinks: return symlinks=%r" % SCons.Tool.StringizeLibSymlinks(symlinks)) return symlinks diff --git a/src/engine/SCons/Tool/f08.py b/src/engine/SCons/Tool/f08.py index a45a61d..7fa5872 100644 --- a/src/engine/SCons/Tool/f08.py +++ b/src/engine/SCons/Tool/f08.py @@ -8,6 +8,8 @@ selection method. """ +from __future__ import absolute_import + # # __COPYRIGHT__ # @@ -36,7 +38,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.Defaults import SCons.Tool import SCons.Util -import fortran +from . import fortran from SCons.Tool.FortranCommon import add_all_to_env, add_f08_to_env compilers = ['f08'] diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py index efdc8a1..c3c8164 100644 --- a/src/engine/SCons/Tool/msvs.py +++ b/src/engine/SCons/Tool/msvs.py @@ -29,6 +29,7 @@ selection method. # 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. + from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -39,7 +40,6 @@ import base64 import hashlib import ntpath import os -# compat layer imports "cPickle" for us if it's available. import pickle import re import sys @@ -71,7 +71,7 @@ def xmlify(s): # Returns a tuple of nodes. def processIncludes(includes, env, target, source): return SCons.PathList.PathList(includes).subst_path(env, target, source) - + external_makefile_guid = '{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}' @@ -169,15 +169,15 @@ class _UserGenerator(object): Base class for .dsp.user file generator ''' # Default instance values. - # Ok ... a bit defensive, but it does not seem reasonable to crash the + # Ok ... a bit defensive, but it does not seem reasonable to crash the # build for a workspace user file. :-) usrhead = None - usrdebg = None + usrdebg = None usrconf = None - createfile = False + createfile = False def __init__(self, dspfile, source, env): # DebugSettings should be a list of debug dictionary sorted in the same order - # as the target list and variants + # as the target list and variants if 'variant' not in env: raise SCons.Errors.InternalError("You must specify a 'variant' argument (i.e. 'Debug' or " +\ "'Release') to create an MSVSProject.") @@ -185,7 +185,7 @@ class _UserGenerator(object): variants = [env['variant']] elif SCons.Util.is_List(env['variant']): variants = env['variant'] - + if 'DebugSettings' not in env or env['DebugSettings'] == None: dbg_settings = [] elif SCons.Util.is_Dict(env['DebugSettings']): @@ -201,12 +201,12 @@ class _UserGenerator(object): dbg_settings.append({}) else: dbg_settings = [] - + if len(dbg_settings) == 1: dbg_settings = dbg_settings * len(variants) - + self.createfile = self.usrhead and self.usrdebg and self.usrconf and \ - dbg_settings and bool([ds for ds in dbg_settings if ds]) + dbg_settings and bool([ds for ds in dbg_settings if ds]) if self.createfile: dbg_settings = dict(zip(variants, dbg_settings)) @@ -216,22 +216,22 @@ class _UserGenerator(object): for key in [k for k in self.usrdebg.keys() if k in src]: trg[key] = str(src[key]) self.configs[var].debug = trg - + def UserHeader(self): encoding = self.env.subst('$MSVSENCODING') versionstr = self.versionstr self.usrfile.write(self.usrhead % locals()) - + def UserProject(self): pass - + def Build(self): if not self.createfile: return try: filename = self.dspabs +'.user' self.usrfile = open(filename, 'w') - except IOError, detail: + except IOError as detail: raise SCons.Errors.InternalError('Unable to open "' + filename + '" for writing:' + str(detail)) else: self.UserHeader() @@ -291,7 +291,7 @@ class _GenerateV7User(_UserGenerator): self.usrconf = V9UserConfiguration self.usrdebg = V9DebugSettings _UserGenerator.__init__(self, dspfile, source, env) - + def UserProject(self): confkeys = sorted(self.configs.keys()) for kind in confkeys: @@ -299,8 +299,8 @@ class _GenerateV7User(_UserGenerator): platform = self.configs[kind].platform 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() + debug_settings = '\n'.join(['\t\t\t\t%s="%s"' % (key, xmlify(value)) + for key, value in debug.items() if value is not None]) self.usrfile.write(self.usrconf % locals()) self.usrfile.write('\t\n') @@ -346,7 +346,7 @@ V10DebugSettings = { class _GenerateV10User(_UserGenerator): """Generates a Project'user file for MSVS 2010""" - + def __init__(self, dspfile, source, env): self.versionstr = '4.0' self.usrhead = V10UserHeader @@ -361,8 +361,8 @@ class _GenerateV10User(_UserGenerator): platform = self.configs[kind].platform debug = self.configs[kind].debug if debug: - debug_settings = '\n'.join(['\t\t<%s>%s' % (key, xmlify(value), key) - for key, value in debug.items() + debug_settings = '\n'.join(['\t\t<%s>%s' % (key, xmlify(value), key) + for key, value in debug.items() if value is not None]) self.usrfile.write(self.usrconf % locals()) self.usrfile.write('') @@ -458,7 +458,7 @@ class _DSPGenerator(object): runfile.append(s) self.sconscript = env['MSVSSCONSCRIPT'] - + if 'cmdargs' not in env or env['cmdargs'] == None: cmdargs = [''] * len(variants) elif SCons.Util.is_String(env['cmdargs']): @@ -468,7 +468,7 @@ class _DSPGenerator(object): raise SCons.Errors.InternalError("Sizes of 'cmdargs' and 'variant' lists must be the same.") else: cmdargs = env['cmdargs'] - + self.env = env if 'name' in self.env: @@ -550,16 +550,16 @@ V6DSPHeader = """\ CFG=%(name)s - Win32 %(confkey)s !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run -!MESSAGE +!MESSAGE !MESSAGE NMAKE /f "%(name)s.mak". -!MESSAGE +!MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE +!MESSAGE !MESSAGE NMAKE /f "%(name)s.mak" CFG="%(name)s - Win32 %(confkey)s" -!MESSAGE +!MESSAGE !MESSAGE Possible choices for configuration are: -!MESSAGE +!MESSAGE """ class _GenerateV6DSP(_DSPGenerator): @@ -818,7 +818,7 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User): self.dspheader = V7DSPHeader self.dspconfiguration = V7DSPConfiguration self.file = None - + _GenerateV7User.__init__(self, dspfile, source, env) def PrintHeader(self): @@ -895,7 +895,7 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User): preprocdefs = xmlify(';'.join(processDefines(self.env.get('CPPDEFINES', [])))) includepath_Dirs = processIncludes(self.env.get('CPPPATH', []), self.env, None, None) includepath = xmlify(';'.join([str(x) for x in includepath_Dirs])) - + if not env_has_buildtarget: del self.env['MSVSBUILDTARGET'] @@ -1044,7 +1044,7 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User): self.PrintHeader() self.PrintProject() self.file.close() - + _GenerateV7User.Build(self) V10DSPHeader = """\ @@ -1101,7 +1101,7 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): self.dspheader = V10DSPHeader self.dspconfiguration = V10DSPProjectConfiguration self.dspglobals = V10DSPGlobals - + _GenerateV10User.__init__(self, dspfile, source, env) def PrintHeader(self): @@ -1132,27 +1132,27 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): '\t\t%s\n' % (scc_project_name, scc_local_path_legacy)) else: self.dspglobals = self.dspglobals.replace('%(scc_attrs)s', '') - + self.file.write(self.dspheader % locals()) - + self.file.write('\t\n') - + confkeys = sorted(self.configs.keys()) for kind in confkeys: variant = self.configs[kind].variant platform = self.configs[kind].platform self.file.write(self.dspconfiguration % locals()) - + self.file.write('\t\n') - + self.file.write(self.dspglobals % locals()) - + def PrintProject(self): name = self.name confkeys = sorted(self.configs.keys()) - + self.file.write('\t\n') - + toolset = '' if 'MSVC_VERSION' in self.env: version_num, suite = msvs_parse_version(self.env['MSVC_VERSION']) @@ -1165,16 +1165,16 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): self.file.write('\t\n') self.file.write('\t\n') self.file.write('\t\n') - + for kind in confkeys: variant = self.configs[kind].variant platform = self.configs[kind].platform self.file.write(V10DSPImportGroupCondition % locals()) - + self.file.write('\t\n') self.file.write('\t\n') self.file.write('\t<_ProjectFileVersion>10.0.30319.1\n') - + for kind in confkeys: variant = self.configs[kind].variant platform = self.configs[kind].platform @@ -1182,7 +1182,7 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): buildtarget = self.configs[kind].buildtarget runfile = self.configs[kind].runfile cmdargs = self.configs[kind].cmdargs - + env_has_buildtarget = 'MSVSBUILDTARGET' in self.env if not env_has_buildtarget: self.env['MSVSBUILDTARGET'] = buildtarget @@ -1207,29 +1207,29 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): del self.env['MSVSBUILDTARGET'] self.file.write(V10DSPCommandLine % locals()) - + self.file.write('\t\n') - + #filter settings in MSVS 2010 are stored in separate file self.filtersabs = self.dspabs + '.filters' try: self.filters_file = open(self.filtersabs, 'w') except IOError as detail: raise SCons.Errors.InternalError('Unable to open "' + self.filtersabs + '" for writing:' + str(detail)) - + self.filters_file.write('\n' '\n') - + self.PrintSourceFiles() - + self.filters_file.write('') self.filters_file.close() - + self.file.write('\t\n' '\t\n' '\t\n' '\n') - + if self.nokeep == 0: # now we pickle some data and add it to the file -- MSDEV will ignore it. pdata = pickle.dumps(self.configs,1) @@ -1241,7 +1241,7 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): def printFilters(self, hierarchy, name): sorteditems = sorted(hierarchy.items(), key = lambda a: a[0].lower()) - + for key, value in sorteditems: if SCons.Util.is_Dict(value): filter_name = name + '\\' + key @@ -1249,14 +1249,14 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): '\t\t\t%s\n' '\t\t\n' % (filter_name, _generateGUID(self.dspabs, filter_name))) self.printFilters(value, filter_name) - + def printSources(self, hierarchy, kind, commonprefix, filter_name): keywords = {'Source Files': 'ClCompile', 'Header Files': 'ClInclude', 'Local Headers': 'ClInclude', 'Resource Files': 'None', 'Other Files': 'None'} - + sorteditems = sorted(hierarchy.items(), key = lambda a: a[0].lower()) # First folders, then files @@ -1270,7 +1270,7 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): if commonprefix: file = os.path.join(commonprefix, value) file = os.path.normpath(file) - + self.file.write('\t\t<%s Include="%s" />\n' % (keywords[kind], file)) self.filters_file.write('\t\t<%s Include="%s">\n' '\t\t\t%s\n' @@ -1282,10 +1282,10 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): 'Local Headers': 'h;hpp;hxx;hm;inl', '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]], key = lambda a: a.lower()) - + # print vcxproj.filters file first self.filters_file.write('\t\n') for kind in cats: @@ -1293,7 +1293,7 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): '\t\t\t{7b42d31d-d53c-4868-8b92-ca2bc9fc052f}\n' '\t\t\t%s\n' '\t\t\n' % (kind, categories[kind])) - + # First remove any common prefix sources = self.sources[kind] commonprefix = None @@ -1306,17 +1306,17 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): # +1 because the filename starts after the separator sources = [s[len(cp)+1:] for s in sources] commonprefix = cp - + hierarchy = makeHierarchy(sources) self.printFilters(hierarchy, kind) - + self.filters_file.write('\t\n') - + # then print files and filters for kind in cats: self.file.write('\t\n') self.filters_file.write('\t\n') - + # First remove any common prefix sources = self.sources[kind] commonprefix = None @@ -1329,13 +1329,13 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): # +1 because the filename starts after the separator sources = [s[len(cp)+1:] for s in sources] commonprefix = cp - + hierarchy = makeHierarchy(sources) self.printSources(hierarchy, kind, commonprefix, kind) - + self.file.write('\t\n') self.filters_file.write('\t\n') - + # add the SConscript file outside of the groups self.file.write('\t\n' '\t\t\n' @@ -1354,7 +1354,7 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): self.PrintHeader() self.PrintProject() self.file.close() - + _GenerateV10User.Build(self) class _DSWGenerator(object): @@ -1462,7 +1462,7 @@ class _GenerateV7DSW(_DSWGenerator): 'SLN_RELATIVE_FOLDER_PATH': dsp_relative_folder_path, 'SLN_RELATIVE_FILE_PATH': dsp_relative_file_path} self.dspfiles_info.append(dspfile_info) - + self.dspfiles_info = [] GenerateProjectFilesInfo(self) @@ -1508,7 +1508,7 @@ class _GenerateV7DSW(_DSWGenerator): self.file.write('# Visual Studio 2008\n') elif self.version_num >= 8.0: self.file.write('# Visual Studio 2005\n') - + for dspinfo in self.dspfiles_info: name = dspinfo['NAME'] base, suffix = SCons.Util.splitext(name) @@ -1970,7 +1970,7 @@ def generate(env): else: env['MSVS']['PROJECTSUFFIX'] = '.vcxproj' env['MSVS']['SOLUTIONSUFFIX'] = '.sln' - + if (version_num >= 10.0): env['MSVSENCODING'] = 'utf-8' else: diff --git a/src/engine/SCons/Tool/swig.py b/src/engine/SCons/Tool/swig.py index 9d1965d..fa86174 100644 --- a/src/engine/SCons/Tool/swig.py +++ b/src/engine/SCons/Tool/swig.py @@ -7,6 +7,7 @@ It will usually be imported through the generic SCons.Tool.Tool() selection method. """ +from __future__ import print_function # # __COPYRIGHT__ @@ -144,10 +145,10 @@ def _get_swig_version(env, swig): out = pipe.stdout.read() match = re.search(r'SWIG Version\s+(\S+).*', out, re.MULTILINE) if match: - if verbose: print "Version is:%s"%match.group(1) + if verbose: print("Version is:%s"%match.group(1)) return match.group(1) else: - if verbose: print "Unable to detect version: [%s]"%out + if verbose: print("Unable to detect version: [%s]"%out) def generate(env): """Add Builders and construction variables for swig to an Environment.""" diff --git a/src/engine/SCons/compat/six.py b/src/engine/SCons/compat/six.py index 019130f..0e8850c 100755 --- a/src/engine/SCons/compat/six.py +++ b/src/engine/SCons/compat/six.py @@ -43,7 +43,7 @@ if PY3: else: string_types = basestring, integer_types = (int, long) - class_types = (type, types.ClassType) + class_types = (type, type) text_type = unicode binary_type = str @@ -462,7 +462,7 @@ if PY3: Iterator = object else: def get_unbound_function(unbound): - return unbound.im_func + return unbound.__func__ def create_bound_method(func, obj): return types.MethodType(func, obj, obj.__class__) diff --git a/src/engine/SCons/compat/sixTests.py b/src/engine/SCons/compat/sixTests.py index f8c1979..71df78d 100644 --- a/src/engine/SCons/compat/sixTests.py +++ b/src/engine/SCons/compat/sixTests.py @@ -1,3 +1,4 @@ +from __future__ import print_function # # __COPYRIGHT__ # @@ -28,7 +29,7 @@ class sixTestCase(unittest.TestCase): def test_import(self): """Test that six imports correctly.""" import sys - print sys.path + print(sys.path) from SCons.compat.six import PY2, PY3 self.assertTrue(PY2 or PY3) diff --git a/src/engine/SCons/cppTests.py b/src/engine/SCons/cppTests.py index 9f4b875..28a1f5e 100644 --- a/src/engine/SCons/cppTests.py +++ b/src/engine/SCons/cppTests.py @@ -21,6 +21,8 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import absolute_import + __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import atexit @@ -29,7 +31,7 @@ import unittest import TestUnit -import cpp +from . import cpp diff --git a/src/script/scons.py b/src/script/scons.py index b5476b9..0595717 100644 --- a/src/script/scons.py +++ b/src/script/scons.py @@ -23,6 +23,8 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +from __future__ import print_function + __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" __version__ = "__VERSION__" diff --git a/src/setup.py b/src/setup.py index c036fb0..9a02b25 100644 --- a/src/setup.py +++ b/src/setup.py @@ -32,6 +32,8 @@ NOTE: Installed SCons is not importable like usual Python packages. It is below is dedicated to make it happen on various platforms. """ +from __future__ import print_function + __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os diff --git a/src/test_interrupts.py b/src/test_interrupts.py index de3a0db..b81ef3f 100644 --- a/src/test_interrupts.py +++ b/src/test_interrupts.py @@ -21,6 +21,8 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +from __future__ import print_function + __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ diff --git a/test/LINK/VersionedLib.py b/test/LINK/VersionedLib.py index 3f4a912..468e3e5 100644 --- a/test/LINK/VersionedLib.py +++ b/test/LINK/VersionedLib.py @@ -1,286 +1,288 @@ -#!/usr/bin/env python -# -# __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__" - -import os -import sys -import TestSCons - -import SCons.Platform -import SCons.Defaults - -env = SCons.Defaults.DefaultEnvironment() -platform = SCons.Platform.platform_default() -tool_list = SCons.Platform.DefaultToolList(platform, env) - -if 'gnulink' in tool_list: - test_plan = [ - { - 'libversion' : '2', - 'files' : [ 'libtest.so', 'libtest.so.2', 'test.os' ], - 'instfiles' : [ 'libtest.so', 'libtest.so.2' ], - 'symlinks' : [ ('libtest.so', 'libtest.so.2') ], - }, - { - 'libversion' : '2.5', - 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5', 'test.os' ], - 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5' ], - 'symlinks' : [ ('libtest.so', 'libtest.so.2.5'), ('libtest.so.2', 'libtest.so.2.5') ], - }, - { - 'libversion' : '2.5.4', - 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4', 'test.os' ], - 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4' ], - 'symlinks' : [ ('libtest.so', 'libtest.so.2.5.4'), ('libtest.so.2', 'libtest.so.2.5.4') ], - }, - { - 'libversion' : '2.5.4.7.8', - 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4.7.8', 'test.os' ], - 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4.7.8' ], - 'symlinks' : [ ('libtest.so', 'libtest.so.2.5.4.7.8'), ('libtest.so.2', 'libtest.so.2.5.4.7.8') ], - }, - { - 'libversion' : 'aabf114f', - 'files' : [ 'libtest.so', 'libtest.so.aabf114f', 'test.os' ], - 'instfiles' : [ 'libtest.so', 'libtest.so.aabf114f' ], - 'symlinks' : [ ('libtest.so', 'libtest.so.aabf114f') ], - }, - { - 'libversion' : '2.dfffa11', - 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.dfffa11', 'test.os' ], - 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.dfffa11' ], - 'symlinks' : [ ('libtest.so', 'libtest.so.2.dfffa11'), ('libtest.so.2', 'libtest.so.2.dfffa11') ], - }, - ] -elif 'applelink' in tool_list: - # All (?) the files we expect will get created in the current directory - test_plan = [ - { - 'libversion' : '2.5.4', - 'files' : [ 'libtest.dylib', 'libtest.2.5.4.dylib', 'test.os' ], - 'instfiles' : [ 'libtest.dylib', 'libtest.2.5.4.dylib' ], - 'symlinks' : [], - }, - ] -elif 'cyglink' in tool_list: - test_plan = [ - { - 'libversion' : '2', - 'files' : [ 'cygtest-2.dll', 'libtest-2.dll.a', 'libtest.dll.a', 'test.os' ], - 'instfiles' : [ 'cygtest-2.dll', 'libtest-2.dll.a', 'libtest.dll.a' ], - 'symlinks' : [ ('libtest.dll.a', 'libtest-2.dll.a') ], - }, - { - 'libversion' : '2.5', - 'files' : [ 'cygtest-2-5.dll', 'libtest-2-5.dll.a', 'libtest.dll.a', 'test.os' ], - 'instfiles' : [ 'cygtest-2-5.dll', 'libtest-2-5.dll.a', 'libtest.dll.a' ], - 'symlinks' : [ ('libtest.dll.a', 'libtest-2-5.dll.a') ], - }, - { - 'libversion' : '2.5.4', - 'files' : [ 'cygtest-2-5-4.dll', 'libtest-2-5-4.dll.a', 'libtest.dll.a', 'test.os' ], - 'instfiles' : [ 'cygtest-2-5-4.dll', 'libtest-2-5-4.dll.a', 'libtest.dll.a' ], - 'symlinks' : [ ('libtest.dll.a', 'libtest-2-5-4.dll.a') ], - }, - { - 'libversion' : '2.5.4.7.8', - 'files' : [ 'cygtest-2-5-4-7-8.dll', 'libtest-2-5-4-7-8.dll.a', 'libtest.dll.a', 'test.os' ], - 'instfiles' : [ 'cygtest-2-5-4-7-8.dll', 'libtest-2-5-4-7-8.dll.a', 'libtest.dll.a' ], - 'symlinks' : [ ('libtest.dll.a', 'libtest-2-5-4-7-8.dll.a') ], - }, - { - 'libversion' : 'aabf114f', - 'files' : [ 'cygtest-aabf114f.dll', 'libtest-aabf114f.dll.a', 'libtest.dll.a', 'test.os' ], - 'instfiles' : [ 'cygtest-aabf114f.dll', 'libtest-aabf114f.dll.a', 'libtest.dll.a' ], - 'symlinks' : [ ('libtest.dll.a', 'libtest-aabf114f.dll.a') ], - }, - { - 'libversion' : '2.dfffa11', - 'files' : [ 'cygtest-2-dfffa11.dll', 'libtest-2-dfffa11.dll.a', 'libtest.dll.a', 'test.os' ], - 'instfiles' : [ 'cygtest-2-dfffa11.dll', 'libtest-2-dfffa11.dll.a', 'libtest.dll.a' ], - 'symlinks' : [ ('libtest.dll.a', 'libtest-2-dfffa11.dll.a') ], - }, - ] -elif 'mslink' in tool_list: - test_plan = [ - { - 'libversion' : '2.5.4', - 'files' : [ 'test.dll', 'test.lib', 'test.obj' ], - 'instfiles' : [ 'test.dll', 'test.lib' ], - 'symlinks' : [], - }, - ] -elif 'sunlink' in tool_list: - test_plan = [ - { - 'libversion' : '2', - 'files' : [ 'libtest.so', 'libtest.so.2', 'so_test.os' ], - 'instfiles' : [ 'libtest.so', 'libtest.so.2' ], - 'symlinks' : [ ('libtest.so', 'libtest.so.2') ], - }, - { - 'libversion' : '2.5', - 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5', 'so_test.os' ], - 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5' ], - 'symlinks' : [ ('libtest.so', 'libtest.so.2.5'), ('libtest.so.2', 'libtest.so.2.5') ], - }, - { - 'libversion' : '2.5.4', - 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4', 'so_test.os' ], - 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4' ], - 'symlinks' : [ ('libtest.so', 'libtest.so.2.5.4'), ('libtest.so.2', 'libtest.so.2.5.4') ], - }, - { - 'libversion' : '2.5.4.7.8', - 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4.7.8', 'so_test.os' ], - 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4.7.8' ], - 'symlinks' : [ ('libtest.so', 'libtest.so.2.5.4.7.8'), ('libtest.so.2', 'libtest.so.2.5.4.7.8') ], - }, - { - 'libversion' : 'aabf114f', - 'files' : [ 'libtest.so', 'libtest.so.aabf114f', 'so_test.os' ], - 'instfiles' : [ 'libtest.so', 'libtest.so.aabf114f' ], - 'symlinks' : [ ('libtest.so', 'libtest.so.aabf114f') ], - }, - { - 'libversion' : '2.dfffa11', - 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.dfffa11', 'so_test.os' ], - 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.dfffa11' ], - 'symlinks' : [ ('libtest.so', 'libtest.so.2.dfffa11'), ('libtest.so.2', 'libtest.so.2.dfffa11') ], - }, - ] -else: - test_plan = [ - { - 'libversion' : '2.5.4', - 'files' : [ 'libtest.so', 'test.os' ], - 'instfiles' : [ ], - }, - ] - -test_c_src = """\ -#if _WIN32 -__declspec(dllexport) -#endif -int testlib(int n) { return n+1 ; } -""" - -test_c_src2 = """\ -#if _WIN32 -__declspec(dllexport) -#endif -int testlib(int n) { return n+11 ; } -""" - -testapp_c_src = """\ -#if _WIN32 -__declspec(dllimport) -#endif -int testlib(int n); -#include -int main(int argc, char **argv) -{ -int itest ; - -itest = testlib(2) ; -printf("results: testlib(2) = %d\\n",itest) ; -return 0 ; -} -""" - -for t in test_plan: - - test = TestSCons.TestSCons() - - libversion = t['libversion'] - files = t['files'] - symlinks = t['symlinks'] - instfiles = t['instfiles'] - - test.write('SConstruct', """\ -import os -env = Environment() -objs = env.SharedObject('test.c') -mylib = env.SharedLibrary('test', objs, SHLIBVERSION = '%s') -env.Program('testapp1.c', LIBS = mylib, LIBPATH='.') -env.Program('testapp2.c', LIBS = ['test'], LIBPATH='.') -instnode = env.InstallVersionedLib("#/installtest",mylib) -env.Default(instnode) - -# Extra test to ensure that InstallVersionedLib can be called from the DefaultEnvironment -# Ensures orthogonality where InstallVersionedLib wasn't previously available: SCons gave NameError. -instnode = InstallVersionedLib("defaultenv-installtest",mylib) -Default(instnode) - -""" % libversion) - - test.write('test.c', test_c_src) - test.write('testapp1.c', testapp_c_src) - test.write('testapp2.c', testapp_c_src) - - test.run(arguments = ['--tree=all']) - - for f in files: - test.must_exist([ f]) - for f in instfiles: - test.must_exist(['installtest', f]) - test.must_exist(['defaultenv-installtest', f]) - - wrong_symlinks = [] - for (linkname,expected) in symlinks: - try: - endpoint = os.readlink(linkname) - except OSError, err: - print "%s (expected symlink %r -> %r)" % (err, linkname, expected) - wrong_symlinks.append(linkname) - else: - if endpoint != expected: - print "Wrong symlink: %r -> %r (expected symlink: %r -> %r)" % (linkname, endpoint, linkname, expected) - wrong_symlinks.append(linkname) - - if wrong_symlinks: - test.fail_test(wrong_symlinks) - - # modify test.c and make sure it can recompile when links already exist - test.write('test.c', test_c_src2) - - test.run() - - test.run(arguments = ['-c']) - - for f in files: - test.must_not_exist([ f]) - - for f in instfiles: - test.must_not_exist(['installtest', f]) - test.must_not_exist(['defaultenv-installtest', f]) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: +#!/usr/bin/env python +# +# __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. +# + +from __future__ import print_function + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import os +import sys +import TestSCons + +import SCons.Platform +import SCons.Defaults + +env = SCons.Defaults.DefaultEnvironment() +platform = SCons.Platform.platform_default() +tool_list = SCons.Platform.DefaultToolList(platform, env) + +if 'gnulink' in tool_list: + test_plan = [ + { + 'libversion' : '2', + 'files' : [ 'libtest.so', 'libtest.so.2', 'test.os' ], + 'instfiles' : [ 'libtest.so', 'libtest.so.2' ], + 'symlinks' : [ ('libtest.so', 'libtest.so.2') ], + }, + { + 'libversion' : '2.5', + 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5', 'test.os' ], + 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5' ], + 'symlinks' : [ ('libtest.so', 'libtest.so.2.5'), ('libtest.so.2', 'libtest.so.2.5') ], + }, + { + 'libversion' : '2.5.4', + 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4', 'test.os' ], + 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4' ], + 'symlinks' : [ ('libtest.so', 'libtest.so.2.5.4'), ('libtest.so.2', 'libtest.so.2.5.4') ], + }, + { + 'libversion' : '2.5.4.7.8', + 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4.7.8', 'test.os' ], + 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4.7.8' ], + 'symlinks' : [ ('libtest.so', 'libtest.so.2.5.4.7.8'), ('libtest.so.2', 'libtest.so.2.5.4.7.8') ], + }, + { + 'libversion' : 'aabf114f', + 'files' : [ 'libtest.so', 'libtest.so.aabf114f', 'test.os' ], + 'instfiles' : [ 'libtest.so', 'libtest.so.aabf114f' ], + 'symlinks' : [ ('libtest.so', 'libtest.so.aabf114f') ], + }, + { + 'libversion' : '2.dfffa11', + 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.dfffa11', 'test.os' ], + 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.dfffa11' ], + 'symlinks' : [ ('libtest.so', 'libtest.so.2.dfffa11'), ('libtest.so.2', 'libtest.so.2.dfffa11') ], + }, + ] +elif 'applelink' in tool_list: + # All (?) the files we expect will get created in the current directory + test_plan = [ + { + 'libversion' : '2.5.4', + 'files' : [ 'libtest.dylib', 'libtest.2.5.4.dylib', 'test.os' ], + 'instfiles' : [ 'libtest.dylib', 'libtest.2.5.4.dylib' ], + 'symlinks' : [], + }, + ] +elif 'cyglink' in tool_list: + test_plan = [ + { + 'libversion' : '2', + 'files' : [ 'cygtest-2.dll', 'libtest-2.dll.a', 'libtest.dll.a', 'test.os' ], + 'instfiles' : [ 'cygtest-2.dll', 'libtest-2.dll.a', 'libtest.dll.a' ], + 'symlinks' : [ ('libtest.dll.a', 'libtest-2.dll.a') ], + }, + { + 'libversion' : '2.5', + 'files' : [ 'cygtest-2-5.dll', 'libtest-2-5.dll.a', 'libtest.dll.a', 'test.os' ], + 'instfiles' : [ 'cygtest-2-5.dll', 'libtest-2-5.dll.a', 'libtest.dll.a' ], + 'symlinks' : [ ('libtest.dll.a', 'libtest-2-5.dll.a') ], + }, + { + 'libversion' : '2.5.4', + 'files' : [ 'cygtest-2-5-4.dll', 'libtest-2-5-4.dll.a', 'libtest.dll.a', 'test.os' ], + 'instfiles' : [ 'cygtest-2-5-4.dll', 'libtest-2-5-4.dll.a', 'libtest.dll.a' ], + 'symlinks' : [ ('libtest.dll.a', 'libtest-2-5-4.dll.a') ], + }, + { + 'libversion' : '2.5.4.7.8', + 'files' : [ 'cygtest-2-5-4-7-8.dll', 'libtest-2-5-4-7-8.dll.a', 'libtest.dll.a', 'test.os' ], + 'instfiles' : [ 'cygtest-2-5-4-7-8.dll', 'libtest-2-5-4-7-8.dll.a', 'libtest.dll.a' ], + 'symlinks' : [ ('libtest.dll.a', 'libtest-2-5-4-7-8.dll.a') ], + }, + { + 'libversion' : 'aabf114f', + 'files' : [ 'cygtest-aabf114f.dll', 'libtest-aabf114f.dll.a', 'libtest.dll.a', 'test.os' ], + 'instfiles' : [ 'cygtest-aabf114f.dll', 'libtest-aabf114f.dll.a', 'libtest.dll.a' ], + 'symlinks' : [ ('libtest.dll.a', 'libtest-aabf114f.dll.a') ], + }, + { + 'libversion' : '2.dfffa11', + 'files' : [ 'cygtest-2-dfffa11.dll', 'libtest-2-dfffa11.dll.a', 'libtest.dll.a', 'test.os' ], + 'instfiles' : [ 'cygtest-2-dfffa11.dll', 'libtest-2-dfffa11.dll.a', 'libtest.dll.a' ], + 'symlinks' : [ ('libtest.dll.a', 'libtest-2-dfffa11.dll.a') ], + }, + ] +elif 'mslink' in tool_list: + test_plan = [ + { + 'libversion' : '2.5.4', + 'files' : [ 'test.dll', 'test.lib', 'test.obj' ], + 'instfiles' : [ 'test.dll', 'test.lib' ], + 'symlinks' : [], + }, + ] +elif 'sunlink' in tool_list: + test_plan = [ + { + 'libversion' : '2', + 'files' : [ 'libtest.so', 'libtest.so.2', 'so_test.os' ], + 'instfiles' : [ 'libtest.so', 'libtest.so.2' ], + 'symlinks' : [ ('libtest.so', 'libtest.so.2') ], + }, + { + 'libversion' : '2.5', + 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5', 'so_test.os' ], + 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5' ], + 'symlinks' : [ ('libtest.so', 'libtest.so.2.5'), ('libtest.so.2', 'libtest.so.2.5') ], + }, + { + 'libversion' : '2.5.4', + 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4', 'so_test.os' ], + 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4' ], + 'symlinks' : [ ('libtest.so', 'libtest.so.2.5.4'), ('libtest.so.2', 'libtest.so.2.5.4') ], + }, + { + 'libversion' : '2.5.4.7.8', + 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4.7.8', 'so_test.os' ], + 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4.7.8' ], + 'symlinks' : [ ('libtest.so', 'libtest.so.2.5.4.7.8'), ('libtest.so.2', 'libtest.so.2.5.4.7.8') ], + }, + { + 'libversion' : 'aabf114f', + 'files' : [ 'libtest.so', 'libtest.so.aabf114f', 'so_test.os' ], + 'instfiles' : [ 'libtest.so', 'libtest.so.aabf114f' ], + 'symlinks' : [ ('libtest.so', 'libtest.so.aabf114f') ], + }, + { + 'libversion' : '2.dfffa11', + 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.dfffa11', 'so_test.os' ], + 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.dfffa11' ], + 'symlinks' : [ ('libtest.so', 'libtest.so.2.dfffa11'), ('libtest.so.2', 'libtest.so.2.dfffa11') ], + }, + ] +else: + test_plan = [ + { + 'libversion' : '2.5.4', + 'files' : [ 'libtest.so', 'test.os' ], + 'instfiles' : [ ], + }, + ] + +test_c_src = """\ +#if _WIN32 +__declspec(dllexport) +#endif +int testlib(int n) { return n+1 ; } +""" + +test_c_src2 = """\ +#if _WIN32 +__declspec(dllexport) +#endif +int testlib(int n) { return n+11 ; } +""" + +testapp_c_src = """\ +#if _WIN32 +__declspec(dllimport) +#endif +int testlib(int n); +#include +int main(int argc, char **argv) +{ +int itest ; + +itest = testlib(2) ; +printf("results: testlib(2) = %d\\n",itest) ; +return 0 ; +} +""" + +for t in test_plan: + + test = TestSCons.TestSCons() + + libversion = t['libversion'] + files = t['files'] + symlinks = t['symlinks'] + instfiles = t['instfiles'] + + test.write('SConstruct', """\ +import os +env = Environment() +objs = env.SharedObject('test.c') +mylib = env.SharedLibrary('test', objs, SHLIBVERSION = '%s') +env.Program('testapp1.c', LIBS = mylib, LIBPATH='.') +env.Program('testapp2.c', LIBS = ['test'], LIBPATH='.') +instnode = env.InstallVersionedLib("#/installtest",mylib) +env.Default(instnode) + +# Extra test to ensure that InstallVersionedLib can be called from the DefaultEnvironment +# Ensures orthogonality where InstallVersionedLib wasn't previously available: SCons gave NameError. +instnode = InstallVersionedLib("defaultenv-installtest",mylib) +Default(instnode) + +""" % libversion) + + test.write('test.c', test_c_src) + test.write('testapp1.c', testapp_c_src) + test.write('testapp2.c', testapp_c_src) + + test.run(arguments = ['--tree=all']) + + for f in files: + test.must_exist([ f]) + for f in instfiles: + test.must_exist(['installtest', f]) + test.must_exist(['defaultenv-installtest', f]) + + wrong_symlinks = [] + for (linkname,expected) in symlinks: + try: + endpoint = os.readlink(linkname) + except OSError as err: + print("%s (expected symlink %r -> %r)" % (err, linkname, expected)) + wrong_symlinks.append(linkname) + else: + if endpoint != expected: + print("Wrong symlink: %r -> %r (expected symlink: %r -> %r)" % (linkname, endpoint, linkname, expected)) + wrong_symlinks.append(linkname) + + if wrong_symlinks: + test.fail_test(wrong_symlinks) + + # modify test.c and make sure it can recompile when links already exist + test.write('test.c', test_c_src2) + + test.run() + + test.run(arguments = ['-c']) + + for f in files: + test.must_not_exist([ f]) + + for f in instfiles: + test.must_not_exist(['installtest', f]) + test.must_not_exist(['defaultenv-installtest', f]) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/option/debug-multiple.py b/test/option/debug-multiple.py index f5bbdf0..f121a2c 100644 --- a/test/option/debug-multiple.py +++ b/test/option/debug-multiple.py @@ -21,6 +21,8 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +from __future__ import print_function + __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ @@ -65,16 +67,16 @@ for args in ['--debug=prepare,count', '--debug=count,prepare']: missing = [o for o in objects if find_object_count(o, stdout) is None] if missing: - print "Missing the following object lines from '%s' output:" % args - print "\t", ' '.join(missing) - print "STDOUT ==========" - print stdout + print("Missing the following object lines from '%s' output:" % args) + print("\t", ' '.join(missing)) + print("STDOUT ==========") + print(stdout) test.fail_test(1) if 'Preparing target file.out...' not in stdout: - print "Missing 'Preparing' lines from '%s' output:" % args - print "STDOUT ==========" - print stdout + print("Missing 'Preparing' lines from '%s' output:" % args) + print("STDOUT ==========") + print(stdout) test.fail_test(1) test.pass_test() diff --git a/test/site_scons/sysdirs.py b/test/site_scons/sysdirs.py index 663700b..60b4f0b 100644 --- a/test/site_scons/sysdirs.py +++ b/test/site_scons/sysdirs.py @@ -22,6 +22,8 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function + __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons @@ -54,10 +56,10 @@ else: dir_to_check_for='.scons' if 'Loading site dir' not in test.stdout(): - print test.stdout() + print(test.stdout()) test.fail_test() if dir_to_check_for not in test.stdout(): - print test.stdout() + print(test.stdout()) test.fail_test() test.pass_test() -- cgit v0.12 From 85aa9baee353e5a7710cb34932ea7ed09a847e39 Mon Sep 17 00:00:00 2001 From: Russel Winder Date: Fri, 1 Jan 2016 14:00:42 +0000 Subject: Amend some missed print functions. --- QMTest/TestCommon.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/QMTest/TestCommon.py b/QMTest/TestCommon.py index 7387e18..f878636 100644 --- a/QMTest/TestCommon.py +++ b/QMTest/TestCommon.py @@ -92,6 +92,7 @@ The TestCommon module also provides the following variables # PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, # AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + from __future__ import print_function __author__ = "Steven Knight " @@ -307,10 +308,10 @@ class TestCommon(TestCmd): if find(output, input) is None: if title is None: title = 'output' - print 'Missing expected input from %s:' % title - print input - print self.banner(title + ' ') - print output + print('Missing expected input from {}:'.format(title)) + print(input) + print(self.banner(title + ' ')) + print(output) self.fail_test() def must_contain_all_lines(self, output, lines, title=None, find=None): -- cgit v0.12 From e9989979ac3411919935afe3a8c8c70ebbc4fd58 Mon Sep 17 00:00:00 2001 From: Russel Winder Date: Fri, 1 Jan 2016 15:01:27 +0000 Subject: Some more print statements to functions. --- SConstruct | 5 +++-- doc/SConscript | 3 ++- src/engine/SCons/SConsign.py | 10 +++++----- src/engine/SCons/compat/sixTests.py | 4 ++-- src/engine/SCons/dblite.py | 1 - src/script/sconsign.py | 3 ++- test/ARGLIST.py | 2 +- test/Actions/pre-post.py | 22 +++++++++++----------- test/AddMethod.py | 8 ++++---- test/AddOption/basic.py | 4 ++-- test/CC/CFLAGS.py | 10 +++++----- .../convenience-functions/image/SConstruct | 5 +++-- 12 files changed, 40 insertions(+), 37 deletions(-) diff --git a/SConstruct b/SConstruct index 8734c2e..1616fc2 100644 --- a/SConstruct +++ b/SConstruct @@ -2,6 +2,7 @@ # SConstruct file to build scons packages during development. # # See the README.rst file for an overview of how SCons is built and tested. + from __future__ import print_function copyright_years = '2001 - 2015' @@ -162,7 +163,7 @@ import distutils.command no_winpack_templates = not os.path.exists(os.path.join(os.path.split(distutils.command.__file__)[0],'wininst-9.0.exe')) skip_win_packages = ARGUMENTS.get('SKIP_WIN_PACKAGES',False) or no_winpack_templates if skip_win_packages: - print "Skipping the build of Windows packages..." + print("Skipping the build of Windows packages...") python_ver = sys.version[0:3] @@ -1049,7 +1050,7 @@ for p in [ scons ]: # The built deb is called just x.y.z, not x.y.z.final.0 so strip those off: deb_version = '.'.join(version.split('.')[0:3]) deb = os.path.join(build_dir, 'dist', "%s_%s_all.deb" % (pkg, deb_version)) - # print "Building deb into %s (version=%s)"%(deb, deb_version) + # print("Building deb into %s (version=%s)"%(deb, deb_version)) for d in p['debian_deps']: b = env.SCons_revision(os.path.join(build, d), d) env.Depends(deb, b) diff --git a/doc/SConscript b/doc/SConscript index 6dbf33d..7e6aaeb 100644 --- a/doc/SConscript +++ b/doc/SConscript @@ -23,6 +23,7 @@ # 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. + from __future__ import print_function import os.path @@ -52,7 +53,7 @@ fop = whereis('fop') xep = whereis('xep') if not fop and not xep: - print "doc: No PDF renderer found (fop|xep)!" + print("doc: No PDF renderer found (fop|xep)!") skip_doc = True # diff --git a/src/engine/SCons/SConsign.py b/src/engine/SCons/SConsign.py index 970c35c..cb089aa 100644 --- a/src/engine/SCons/SConsign.py +++ b/src/engine/SCons/SConsign.py @@ -26,6 +26,7 @@ Writing and reading information to the .sconsign file or files. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # + from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -33,7 +34,6 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.compat import os -# compat layer imports "cPickle" for us if it's available. import pickle import SCons.dblite @@ -125,16 +125,16 @@ class SConsignEntry(object): """ __slots__ = ("binfo", "ninfo", "__weakref__") current_version_id = 2 - + def __init__(self): # Create an object attribute from the class attribute so it ends up # in the pickled data in the .sconsign file. #_version_id = self.current_version_id pass - + def convert_to_sconsign(self): self.binfo.convert_to_sconsign() - + def convert_from_sconsign(self, dir, name): self.binfo.convert_from_sconsign(dir, name) @@ -156,7 +156,7 @@ class SConsignEntry(object): for key, value in state.items(): if key not in ('_version_id','__weakref__'): setattr(self, key, value) - + class Base(object): """ This is the controlling class for the signatures for the collection of diff --git a/src/engine/SCons/compat/sixTests.py b/src/engine/SCons/compat/sixTests.py index 71df78d..8be3572 100644 --- a/src/engine/SCons/compat/sixTests.py +++ b/src/engine/SCons/compat/sixTests.py @@ -1,4 +1,3 @@ -from __future__ import print_function # # __COPYRIGHT__ # @@ -22,6 +21,8 @@ from __future__ import print_function # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function + import unittest class sixTestCase(unittest.TestCase): @@ -32,4 +33,3 @@ class sixTestCase(unittest.TestCase): print(sys.path) from SCons.compat.six import PY2, PY3 self.assertTrue(PY2 or PY3) - diff --git a/src/engine/SCons/dblite.py b/src/engine/SCons/dblite.py index 3be6cb2..b12d320 100644 --- a/src/engine/SCons/dblite.py +++ b/src/engine/SCons/dblite.py @@ -5,7 +5,6 @@ from __future__ import print_function import SCons.compat import os -# compat layer imports "cPickle" for us if it's available. import pickle import shutil import time diff --git a/src/script/sconsign.py b/src/script/sconsign.py index 1a4caf7..daf088e 100644 --- a/src/script/sconsign.py +++ b/src/script/sconsign.py @@ -22,6 +22,7 @@ # 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. + from __future__ import print_function from SCons.compat.six import PY2, PY3 @@ -185,7 +186,7 @@ sys.path = libs + sys.path # END STANDARD SCons SCRIPT HEADER ############################################################################## -import SCons.compat # so pickle will import cPickle instead +import SCons.compat if PY2: import whichdb diff --git a/test/ARGLIST.py b/test/ARGLIST.py index 186ad06..e246ba3 100644 --- a/test/ARGLIST.py +++ b/test/ARGLIST.py @@ -31,7 +31,7 @@ test = TestSCons.TestSCons() test.write('SConstruct', """ i = 0 for key, value in ARGLIST: - print "%d: %s = %s" % (i, key, value) + print("%d: %s = %s" % (i, key, value)) i = i + 1 """) diff --git a/test/Actions/pre-post.py b/test/Actions/pre-post.py index e09ee02..179e914 100644 --- a/test/Actions/pre-post.py +++ b/test/Actions/pre-post.py @@ -118,14 +118,14 @@ def b(target, source, env): env1 = Environment(X='111') env2 = Environment(X='222') B = Builder(action = b, env = env1, multi=1) -print "B =", B -print "B.env =", B.env +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 +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', []) @@ -133,12 +133,12 @@ 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 +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) """) test.run(chdir='work2', arguments = '.') diff --git a/test/AddMethod.py b/test/AddMethod.py index af84cb3..6049ae2 100644 --- a/test/AddMethod.py +++ b/test/AddMethod.py @@ -40,10 +40,10 @@ def foo(self): AddMethod(Environment, foo) env = Environment(FOO = '111') -print env.foo() +print(env.foo()) env = Environment(FOO = '222') -print env.foo() +print(env.foo()) env.AddMethod(foo, 'bar') env['FOO'] = '333' @@ -51,8 +51,8 @@ env['FOO'] = '333' e = env.Clone() e['FOO'] = '444' -print env.bar() -print e.bar() +print(env.bar()) +print(e.bar()) """) expect = """\ diff --git a/test/AddOption/basic.py b/test/AddOption/basic.py index a1bb7b3..b1b8f2e 100644 --- a/test/AddOption/basic.py +++ b/test/AddOption/basic.py @@ -48,8 +48,8 @@ AddOption('--prefix', f = GetOption('force') if f: f = "True" -print f -print GetOption('prefix') +print(f) +print(GetOption('prefix')) """) test.run('-Q -q .', diff --git a/test/CC/CFLAGS.py b/test/CC/CFLAGS.py index 6ea87ad..590d6b5 100644 --- a/test/CC/CFLAGS.py +++ b/test/CC/CFLAGS.py @@ -32,10 +32,10 @@ test = TestSCons.TestSCons() # Make sure CFLAGS is not passed to CXX by just expanding CXXCOM test.write('SConstruct', """ env = Environment(CFLAGS='-xyz', CCFLAGS='-abc') -print env.subst('$CXXCOM') -print env.subst('$CXXCOMSTR') -print env.subst('$SHCXXCOM') -print env.subst('$SHCXXCOMSTR') +print(env.subst('$CXXCOM')) +print(env.subst('$CXXCOMSTR')) +print(env.subst('$SHCXXCOM')) +print(env.subst('$SHCXXCOMSTR')) """) test.run(arguments = '.') test.must_not_contain_any_line(test.stdout(), ["-xyz"]) @@ -46,7 +46,7 @@ _obj = TestSCons._obj # Test passing CFLAGS to C compiler by actually compiling programs if sys.platform == 'win32': import SCons.Tool.MSCommon as msc - + if not msc.msvc_exists(): fooflags = '-DFOO' barflags = '-DBAR' diff --git a/test/packaging/convenience-functions/image/SConstruct b/test/packaging/convenience-functions/image/SConstruct index 461961e..f35c3e3 100644 --- a/test/packaging/convenience-functions/image/SConstruct +++ b/test/packaging/convenience-functions/image/SConstruct @@ -1,3 +1,4 @@ +from __future__ import print_function env = Environment(tools=['default', 'packaging']) prog = env.Install( 'bin/', ["f1", "f2"] ) @@ -6,5 +7,5 @@ env.File( "f3" ) src_files = sorted(map(str, env.FindSourceFiles())) oth_files = sorted(map(str, env.FindInstalledFiles())) -print src_files -print oth_files +print(src_files) +print(oth_files) -- cgit v0.12 From 7b68ccb54e7b4d2200f8ac813eb6f8b2ae3654eb Mon Sep 17 00:00:00 2001 From: Russel Winder Date: Fri, 1 Jan 2016 15:23:41 +0000 Subject: Some more print statements to functions. --- test/Actions/actions.py | 10 +++--- test/AddOption/optional-arg.py | 2 +- test/CPPDEFINES/append.py | 52 ++++++++++++++++---------------- test/CPPDEFINES/basic.py | 6 ++-- test/CPPDEFINES/undefined.py | 4 +-- test/CacheDir/scanner-target.py | 2 +- test/CacheDir/source-scanner.py | 2 +- test/Climb/filename--D.py | 4 +-- test/Climb/filename--U.py | 4 +-- test/Climb/filename-u.py | 4 +-- test/Clone-compatibility.py | 4 +-- test/Configure/Streamer1.py | 2 +- test/Configure/cache-not-ok.py | 2 +- test/ConstructionEnvironment.py | 2 +- test/Deprecated/Options/BoolOption.py | 4 +-- test/Deprecated/Options/Options.py | 26 ++++++++-------- test/Deprecated/Options/PackageOption.py | 2 +- test/Deprecated/Options/PathOption.py | 16 +++++----- test/Deprecated/Options/chdir.py | 2 +- test/Deprecated/Options/help.py | 6 ++-- test/Deprecated/Options/import.py | 2 +- test/Dir/Dir.py | 12 ++++---- 22 files changed, 85 insertions(+), 85 deletions(-) diff --git a/test/Actions/actions.py b/test/Actions/actions.py index 03d67a0..785a0cb 100644 --- a/test/Actions/actions.py +++ b/test/Actions/actions.py @@ -70,7 +70,7 @@ import os def func(env, target, source): cmd = r'%(_python_)s build.py %%s 3 %%s' %% (' '.join(map(str, target)), ' '.join(map(str, source))) - print cmd + print(cmd) return os.system(cmd) B = Builder(action = func) env = Environment(BUILDERS = { 'B' : B }) @@ -91,7 +91,7 @@ class bld(object): self.cmd = r'%(_python_)s build.py %%s 4 %%s' def __call__(self, env, target, source): cmd = self.get_contents(env, target, source) - print cmd + print(cmd) return os.system(cmd) def get_contents(self, env, target, source): return self.cmd %% (' '.join(map(str, target)), @@ -114,9 +114,9 @@ def func(env, target, source): env = Environment(S = Action('foo'), F = Action(func), L = Action(['arg1', 'arg2'])) -print env.subst('$S') -print env.subst('$F') -print env.subst('$L') +print(env.subst('$S')) +print(env.subst('$F')) +print(env.subst('$L')) """) test.run(arguments = '-Q .', stdout = """\ diff --git a/test/AddOption/optional-arg.py b/test/AddOption/optional-arg.py index f976ad9..b88b796 100644 --- a/test/AddOption/optional-arg.py +++ b/test/AddOption/optional-arg.py @@ -43,7 +43,7 @@ AddOption('--install', type='string', metavar='DIR', help='installation directory') -print GetOption('install') +print(GetOption('install')) """) test.run('-Q -q', diff --git a/test/CPPDEFINES/append.py b/test/CPPDEFINES/append.py index 6e69d09..432ab64 100644 --- a/test/CPPDEFINES/append.py +++ b/test/CPPDEFINES/append.py @@ -40,17 +40,17 @@ test.write('SConstruct', """\ env_1738_2 = Environment(CPPDEFPREFIX='-D') env_1738_2['CPPDEFINES'] = ['FOO'] env_1738_2.Append(CPPDEFINES={'value' : '1'}) -print env_1738_2.subst('$_CPPDEFFLAGS') +print(env_1738_2.subst('$_CPPDEFFLAGS')) #env_1738_2.Object('test_1738_2', 'main.c') # http://scons.tigris.org/issues/show_bug.cgi?id=2300 env_2300_1 = Environment(CPPDEFINES = 'foo', CPPDEFPREFIX='-D') env_2300_1.Append(CPPDEFINES='bar') -print env_2300_1.subst('$_CPPDEFFLAGS') +print(env_2300_1.subst('$_CPPDEFFLAGS')) env_2300_2 = Environment(CPPDEFINES = ['foo'], CPPDEFPREFIX='-D') # note the list env_2300_2.Append(CPPDEFINES='bar') -print env_2300_2.subst('$_CPPDEFFLAGS') +print(env_2300_2.subst('$_CPPDEFFLAGS')) # http://scons.tigris.org/issues/show_bug.cgi?id=1152 # http://scons.tigris.org/issues/show_bug.cgi?id=2900 @@ -62,18 +62,18 @@ cases=[('string', 'FOO'), for (t1, c1) in cases: for (t2, c2) in cases: - print "==== Testing CPPDEFINES, appending a %s to a %s"%(t2, t1) - print " orig = %s, append = %s"%(c1, c2) + print("==== Testing CPPDEFINES, appending a %s to a %s"%(t2, t1)) + print(" orig = %s, append = %s"%(c1, c2)) env=Environment(CPPDEFINES = c1, CPPDEFPREFIX='-D') env.Append(CPPDEFINES = c2) final=env.subst('$_CPPDEFFLAGS',source="src", target="tgt") - print 'Append: \\n\\tresult=%s\\n\\tfinal=%s'%\\ - (env['CPPDEFINES'], final) + print('Append: \\n\\tresult=%s\\n\\tfinal=%s'%\\ + (env['CPPDEFINES'], final)) env=Environment(CPPDEFINES = c1, CPPDEFPREFIX='-D') env.AppendUnique(CPPDEFINES = c2) final=env.subst('$_CPPDEFFLAGS',source="src", target="tgt") - print 'AppendUnique:\\n\\tresult=%s\\n\\tfinal=%s'%\\ - (env['CPPDEFINES'], final) + print('AppendUnique:\\n\\tresult=%s\\n\\tfinal=%s'%\\ + (env['CPPDEFINES'], final)) """) @@ -83,7 +83,7 @@ expect_print_output="""\ -Dfoo -Dbar ==== Testing CPPDEFINES, appending a string to a string orig = FOO, append = FOO -Append: +Append: result=['FOO', 'FOO'] final=-DFOO -DFOO AppendUnique: @@ -91,7 +91,7 @@ AppendUnique: final=-DFOO ==== Testing CPPDEFINES, appending a list to a string orig = FOO, append = ['NAME1', 'NAME2'] -Append: +Append: result=['FOO', 'NAME1', 'NAME2'] final=-DFOO -DNAME1 -DNAME2 AppendUnique: @@ -99,7 +99,7 @@ AppendUnique: final=-DFOO -DNAME1 -DNAME2 ==== Testing CPPDEFINES, appending a list-of-2lists to a string orig = FOO, append = [('NAME1', 'VAL1'), ['NAME2', 'VAL2']] -Append: +Append: result=['FOO', ('NAME1', 'VAL1'), ['NAME2', 'VAL2']] final=-DFOO -DNAME1=VAL1 -DNAME2=VAL2 AppendUnique: @@ -107,7 +107,7 @@ AppendUnique: final=-DFOO -DNAME1=VAL1 -DNAME2=VAL2 ==== Testing CPPDEFINES, appending a dict to a string orig = FOO, append = {'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'} -Append: +Append: result=['FOO', {'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'}] final=-DFOO -DNAME2=VAL2 -DNAME3 -DNAME1=VAL1 AppendUnique: @@ -115,7 +115,7 @@ AppendUnique: final=-DFOO -DNAME2=VAL2 -DNAME3 -DNAME1=VAL1 ==== Testing CPPDEFINES, appending a string to a list orig = ['NAME1', 'NAME2'], append = FOO -Append: +Append: result=['NAME1', 'NAME2', 'FOO'] final=-DNAME1 -DNAME2 -DFOO AppendUnique: @@ -123,7 +123,7 @@ AppendUnique: final=-DNAME1 -DNAME2 -DFOO ==== Testing CPPDEFINES, appending a list to a list orig = ['NAME1', 'NAME2'], append = ['NAME1', 'NAME2'] -Append: +Append: result=['NAME1', 'NAME2', 'NAME1', 'NAME2'] final=-DNAME1 -DNAME2 -DNAME1 -DNAME2 AppendUnique: @@ -131,7 +131,7 @@ AppendUnique: final=-DNAME1 -DNAME2 ==== Testing CPPDEFINES, appending a list-of-2lists to a list orig = ['NAME1', 'NAME2'], append = [('NAME1', 'VAL1'), ['NAME2', 'VAL2']] -Append: +Append: result=['NAME1', 'NAME2', ('NAME1', 'VAL1'), ['NAME2', 'VAL2']] final=-DNAME1 -DNAME2 -DNAME1=VAL1 -DNAME2=VAL2 AppendUnique: @@ -139,7 +139,7 @@ AppendUnique: final=-DNAME1 -DNAME2 -DNAME1=VAL1 -DNAME2=VAL2 ==== Testing CPPDEFINES, appending a dict to a list orig = ['NAME1', 'NAME2'], append = {'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'} -Append: +Append: result=['NAME1', 'NAME2', {'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'}] final=-DNAME1 -DNAME2 -DNAME2=VAL2 -DNAME3 -DNAME1=VAL1 AppendUnique: @@ -147,7 +147,7 @@ AppendUnique: final=-DNAME1 -DNAME2 -DNAME2=VAL2 -DNAME3 -DNAME1=VAL1 ==== Testing CPPDEFINES, appending a string to a list-of-2lists orig = [('NAME1', 'VAL1'), ['NAME2', 'VAL2']], append = FOO -Append: +Append: result=[('NAME1', 'VAL1'), ['NAME2', 'VAL2'], 'FOO'] final=-DNAME1=VAL1 -DNAME2=VAL2 -DFOO AppendUnique: @@ -155,7 +155,7 @@ AppendUnique: final=-DNAME1=VAL1 -DNAME2=VAL2 -DFOO ==== Testing CPPDEFINES, appending a list to a list-of-2lists orig = [('NAME1', 'VAL1'), ['NAME2', 'VAL2']], append = ['NAME1', 'NAME2'] -Append: +Append: result=[('NAME1', 'VAL1'), ['NAME2', 'VAL2'], 'NAME1', 'NAME2'] final=-DNAME1=VAL1 -DNAME2=VAL2 -DNAME1 -DNAME2 AppendUnique: @@ -163,7 +163,7 @@ AppendUnique: final=-DNAME1=VAL1 -DNAME2=VAL2 -DNAME1 -DNAME2 ==== Testing CPPDEFINES, appending a list-of-2lists to a list-of-2lists orig = [('NAME1', 'VAL1'), ['NAME2', 'VAL2']], append = [('NAME1', 'VAL1'), ['NAME2', 'VAL2']] -Append: +Append: result=[('NAME1', 'VAL1'), ['NAME2', 'VAL2'], ('NAME1', 'VAL1'), ['NAME2', 'VAL2']] final=-DNAME1=VAL1 -DNAME2=VAL2 -DNAME1=VAL1 -DNAME2=VAL2 AppendUnique: @@ -171,7 +171,7 @@ AppendUnique: final=-DNAME1=VAL1 -DNAME2=VAL2 ==== Testing CPPDEFINES, appending a dict to a list-of-2lists orig = [('NAME1', 'VAL1'), ['NAME2', 'VAL2']], append = {'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'} -Append: +Append: result=[('NAME1', 'VAL1'), ['NAME2', 'VAL2'], {'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'}] final=-DNAME1=VAL1 -DNAME2=VAL2 -DNAME2=VAL2 -DNAME3 -DNAME1=VAL1 AppendUnique: @@ -179,7 +179,7 @@ AppendUnique: final=-DNAME2=VAL2 -DNAME3 -DNAME1=VAL1 ==== Testing CPPDEFINES, appending a string to a dict orig = {'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'}, append = FOO -Append: +Append: result={'FOO': None, 'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'} final=-DFOO -DNAME1=VAL1 -DNAME2=VAL2 -DNAME3 AppendUnique: @@ -187,7 +187,7 @@ AppendUnique: final=-DNAME2=VAL2 -DNAME3 -DNAME1=VAL1 -DFOO ==== Testing CPPDEFINES, appending a list to a dict orig = {'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'}, append = ['NAME1', 'NAME2'] -Append: +Append: result=[('NAME2', 'VAL2'), ('NAME3',), ('NAME1', 'VAL1'), 'NAME1', 'NAME2'] final=-DNAME2=VAL2 -DNAME3 -DNAME1=VAL1 -DNAME1 -DNAME2 AppendUnique: @@ -195,7 +195,7 @@ AppendUnique: final=-DNAME2=VAL2 -DNAME3 -DNAME1=VAL1 -DNAME1 -DNAME2 ==== Testing CPPDEFINES, appending a list-of-2lists to a dict orig = {'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'}, append = [('NAME1', 'VAL1'), ['NAME2', 'VAL2']] -Append: +Append: result=[('NAME2', 'VAL2'), ('NAME3',), ('NAME1', 'VAL1'), ('NAME1', 'VAL1'), ['NAME2', 'VAL2']] final=-DNAME2=VAL2 -DNAME3 -DNAME1=VAL1 -DNAME1=VAL1 -DNAME2=VAL2 AppendUnique: @@ -203,7 +203,7 @@ AppendUnique: final=-DNAME2=VAL2 -DNAME3 -DNAME1=VAL1 ==== Testing CPPDEFINES, appending a dict to a dict orig = {'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'}, append = {'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'} -Append: +Append: result={'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'} final=-DNAME1=VAL1 -DNAME2=VAL2 -DNAME3 AppendUnique: @@ -213,7 +213,7 @@ AppendUnique: build_output="scons: `.' is up to date.\n" -expect = test.wrap_stdout(build_str=build_output, +expect = test.wrap_stdout(build_str=build_output, read_str = expect_print_output) test.run(arguments = '.', stdout=expect) test.pass_test() diff --git a/test/CPPDEFINES/basic.py b/test/CPPDEFINES/basic.py index b54a421..57d7260 100644 --- a/test/CPPDEFINES/basic.py +++ b/test/CPPDEFINES/basic.py @@ -41,13 +41,13 @@ test_list = [ ] for i in test_list: env = Environment(CPPDEFPREFIX='-D', CPPDEFSUFFIX='', INTEGER=0) - print env.Clone(CPPDEFINES=i).subst('$_CPPDEFFLAGS') + print(env.Clone(CPPDEFINES=i).subst('$_CPPDEFFLAGS')) for i in test_list: env = Environment(CPPDEFPREFIX='|', CPPDEFSUFFIX='|', INTEGER=1) - print env.Clone(CPPDEFINES=i).subst('$_CPPDEFFLAGS') + print(env.Clone(CPPDEFINES=i).subst('$_CPPDEFFLAGS')) """) -expect = test.wrap_stdout(build_str="scons: `.' is up to date.\n", +expect = test.wrap_stdout(build_str="scons: `.' is up to date.\n", read_str = """\ -Dxyz -Dx -Dy -Dz diff --git a/test/CPPDEFINES/undefined.py b/test/CPPDEFINES/undefined.py index 47825b6..b26b05a 100644 --- a/test/CPPDEFINES/undefined.py +++ b/test/CPPDEFINES/undefined.py @@ -34,10 +34,10 @@ test = TestSCons.TestSCons() test.write('SConstruct', """\ env = Environment() -print env.subst('$_CPPDEFFLAGS') +print(env.subst('$_CPPDEFFLAGS')) """) -expect = test.wrap_stdout(build_str="scons: `.' is up to date.\n", +expect = test.wrap_stdout(build_str="scons: `.' is up to date.\n", read_str = "\n") test.run(arguments = '.', stdout=expect) diff --git a/test/CacheDir/scanner-target.py b/test/CacheDir/scanner-target.py index 645b597..c39042e 100644 --- a/test/CacheDir/scanner-target.py +++ b/test/CacheDir/scanner-target.py @@ -52,7 +52,7 @@ def docopy(target,source,env): f.close() def sillyScanner(node, env, dirs): - print 'This is never called (unless we build file.out)' + print('This is never called (unless we build file.out)') return [] SillyScanner = SCons.Scanner.Base(function = sillyScanner, skeys = ['.res']) diff --git a/test/CacheDir/source-scanner.py b/test/CacheDir/source-scanner.py index e7db5e9..2359872 100644 --- a/test/CacheDir/source-scanner.py +++ b/test/CacheDir/source-scanner.py @@ -54,7 +54,7 @@ def docopy(target,source,env): f.close() def sillyScanner(node, env, dirs): - print 'This is never called (unless we build file.out)' + print('This is never called (unless we build file.out)') return [] SillyScanner = SCons.Scanner.Base(function = sillyScanner, skeys = ['.res']) diff --git a/test/Climb/filename--D.py b/test/Climb/filename--D.py index 06d95e7..6fea9bc 100644 --- a/test/Climb/filename--D.py +++ b/test/Climb/filename--D.py @@ -36,12 +36,12 @@ test = TestSCons.TestSCons() test.subdir('subdir', 'other') test.write('main.scons', """\ -print "main.scons" +print("main.scons") SConscript('subdir/sub.scons') """) test.write(['subdir', 'sub.scons'], """\ -print "subdir/sub.scons" +print("subdir/sub.scons") """) diff --git a/test/Climb/filename--U.py b/test/Climb/filename--U.py index 7f2e60d..49ccc0a 100644 --- a/test/Climb/filename--U.py +++ b/test/Climb/filename--U.py @@ -36,12 +36,12 @@ test = TestSCons.TestSCons() test.subdir('subdir', 'other') test.write('main.scons', """\ -print "main.scons" +print("main.scons") SConscript('subdir/sub.scons') """) test.write(['subdir', 'sub.scons'], """\ -print "subdir/sub.scons" +print("subdir/sub.scons") """) read_str = """\ diff --git a/test/Climb/filename-u.py b/test/Climb/filename-u.py index 7bae153..4485c4b 100644 --- a/test/Climb/filename-u.py +++ b/test/Climb/filename-u.py @@ -36,12 +36,12 @@ test = TestSCons.TestSCons() test.subdir('subdir', 'other') test.write('main.scons', """\ -print "main.scons" +print("main.scons") SConscript('subdir/sub.scons') """) test.write(['subdir', 'sub.scons'], """\ -print "subdir/sub.scons" +print("subdir/sub.scons") """) read_str = """\ diff --git a/test/Clone-compatibility.py b/test/Clone-compatibility.py index 089b7a4..a2f6362 100644 --- a/test/Clone-compatibility.py +++ b/test/Clone-compatibility.py @@ -48,8 +48,8 @@ except AttributeError: env1 = Environment(X = 1) env2 = env1.Clone(X = 2) -print env1['X'] -print env2['X'] +print(env1['X']) +print(env2['X']) """) test.run(arguments = '-q -Q', stdout = "1\n2\n") diff --git a/test/Configure/Streamer1.py b/test/Configure/Streamer1.py index 8f35308..318a936 100644 --- a/test/Configure/Streamer1.py +++ b/test/Configure/Streamer1.py @@ -45,7 +45,7 @@ test.write('SConstruct', """ def hello(target, source, env): import traceback try: - print 'hello!\\n' # this breaks the script + print('hello!\\n') # this breaks the script with open(env.subst('$TARGET', target = target),'w') as f: f.write('yes') except: diff --git a/test/Configure/cache-not-ok.py b/test/Configure/cache-not-ok.py index ccbb7d5..7502f7a 100644 --- a/test/Configure/cache-not-ok.py +++ b/test/Configure/cache-not-ok.py @@ -53,7 +53,7 @@ r1 = conf.CheckCHeader( 'no_std_c_header.h' ) # leads to compile error r2 = conf.CheckLib( 'no_c_library_SAFFDG' ) # leads to link error env = conf.Finish() if not (not r1 and not r2): - print "FAIL: ", r1, r2 + print("FAIL: ", r1, r2) Exit(1) """) diff --git a/test/ConstructionEnvironment.py b/test/ConstructionEnvironment.py index bec46b9..e25f86a 100644 --- a/test/ConstructionEnvironment.py +++ b/test/ConstructionEnvironment.py @@ -38,7 +38,7 @@ import SCons.Defaults SCons.Defaults.ConstructionEnvironment.update({ 'XXX' : 777, }) -print DefaultEnvironment()['XXX'] +print(DefaultEnvironment()['XXX']) """) expect = test.wrap_stdout(read_str = "777\n", diff --git a/test/Deprecated/Options/BoolOption.py b/test/Deprecated/Options/BoolOption.py index 563939b..5d12fc6 100644 --- a/test/Deprecated/Options/BoolOption.py +++ b/test/Deprecated/Options/BoolOption.py @@ -55,8 +55,8 @@ opts.AddOptions( env = Environment(options=opts) Help(opts.GenerateHelpText(env)) -print env['warnings'] -print env['profile'] +print(env['warnings']) +print(env['profile']) Default(env.Alias('dummy', None)) """) diff --git a/test/Deprecated/Options/Options.py b/test/Deprecated/Options/Options.py index 61a12f3..e435b9e 100644 --- a/test/Deprecated/Options/Options.py +++ b/test/Deprecated/Options/Options.py @@ -30,8 +30,8 @@ test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) test.write('SConstruct', """ env = Environment() -print env['CC'] -print " ".join(env['CCFLAGS']) +print(env['CC']) +print(" ".join(env['CCFLAGS'])) Default(env.Alias('dummy', None)) """) test.run() @@ -99,12 +99,12 @@ env = Environment(options=opts, tools=['default', test_tool]) Help('Variables settable in custom.py or on the command line:\\n' + opts.GenerateHelpText(env)) -print env['RELEASE_BUILD'] -print env['DEBUG_BUILD'] -print env['CC'] -print " ".join(env['CCFLAGS']) -print env['VALIDATE'] -print env['valid_key'] +print(env['RELEASE_BUILD']) +print(env['DEBUG_BUILD']) +print(env['CC']) +print(" ".join(env['CCFLAGS'])) +print(env['VALIDATE']) +print(env['valid_key']) # unspecified options should not be set: assert 'UNSPECIFIED' not in env @@ -226,8 +226,8 @@ opts.Add('UNSPECIFIED', env = Environment(options = opts) -print env['RELEASE_BUILD'] -print env['DEBUG_BUILD'] +print(env['RELEASE_BUILD']) +print(env['DEBUG_BUILD']) opts.Save('options.saved', env) """) @@ -282,9 +282,9 @@ opts.Add('LISTOPTION_TEST', env = Environment(options = opts) -print env['RELEASE_BUILD'] -print env['DEBUG_BUILD'] -print env['LISTOPTION_TEST'] +print(env['RELEASE_BUILD']) +print(env['DEBUG_BUILD']) +print(env['LISTOPTION_TEST']) opts.Save('options.saved', env) """) diff --git a/test/Deprecated/Options/PackageOption.py b/test/Deprecated/Options/PackageOption.py index 424e5a7..ec8990c 100644 --- a/test/Deprecated/Options/PackageOption.py +++ b/test/Deprecated/Options/PackageOption.py @@ -59,7 +59,7 @@ opts.AddOptions( env = Environment(options=opts) Help(opts.GenerateHelpText(env)) -print env['x11'] +print(env['x11']) Default(env.Alias('dummy', None)) """) diff --git a/test/Deprecated/Options/PathOption.py b/test/Deprecated/Options/PathOption.py index 4701420..0e6949c 100644 --- a/test/Deprecated/Options/PathOption.py +++ b/test/Deprecated/Options/PathOption.py @@ -25,7 +25,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ -Test the PathOption canned option type, with tests for its +Test the PathOption canned option type, with tests for its various canned validators. """ @@ -65,9 +65,9 @@ opts.AddOptions( env = Environment(options=opts) Help(opts.GenerateHelpText(env)) -print env['qtdir'] -print env['qt_libraries'] -print env.subst('$qt_libraries') +print(env['qtdir']) +print(env['qt_libraries']) +print(env.subst('$qt_libraries')) Default(env.Alias('dummy', None)) """ % (workpath, os.path.join('$qtdir', 'lib') )) @@ -144,7 +144,7 @@ opts.AddOptions( env = Environment(options=opts) -print env['X'] +print(env['X']) Default(env.Alias('dummy', None)) """ % default_subdir) @@ -177,7 +177,7 @@ opts.AddOptions( env = Environment(options=opts) -print env['X'] +print(env['X']) Default(env.Alias('dummy', None)) """ % default_file) @@ -218,7 +218,7 @@ opts.AddOptions( env = Environment(options=opts) -print env['X'] +print(env['X']) Default(env.Alias('dummy', None)) """ % default_subdir) @@ -263,7 +263,7 @@ opts.AddOptions( env = Environment(options=opts) -print env['X'] +print(env['X']) Default(env.Alias('dummy', None)) """ % default_subdir) diff --git a/test/Deprecated/Options/chdir.py b/test/Deprecated/Options/chdir.py index a8fb6c6..977a351 100644 --- a/test/Deprecated/Options/chdir.py +++ b/test/Deprecated/Options/chdir.py @@ -46,7 +46,7 @@ SConscript_contents = """\ Import("opts") env = Environment() opts.Update(env) -print "VARIABLE =", repr(env['VARIABLE']) +print("VARIABLE =", repr(env['VARIABLE'])) """ test.write(['bin', 'opts.cfg'], """\ diff --git a/test/Deprecated/Options/help.py b/test/Deprecated/Options/help.py index 8c240e3..ad8a96b 100644 --- a/test/Deprecated/Options/help.py +++ b/test/Deprecated/Options/help.py @@ -49,7 +49,7 @@ libdirvar_re = re.escape(libdirvar) test.subdir(qtpath) test.subdir(libpath) - + test.write('SConstruct', """ from SCons.Options import BoolOption, EnumOption, ListOption, \ PackageOption, PathOption @@ -86,8 +86,8 @@ opts.AddOptions( env = Environment(options=opts) Help(opts.GenerateHelpText(env)) -print env['warnings'] -print env['profile'] +print(env['warnings']) +print(env['profile']) Default(env.Alias('dummy', None)) """ % locals()) diff --git a/test/Deprecated/Options/import.py b/test/Deprecated/Options/import.py index a4d56b2..b93e6a2 100644 --- a/test/Deprecated/Options/import.py +++ b/test/Deprecated/Options/import.py @@ -48,7 +48,7 @@ SConscript_contents = """\ Import("opts") env = Environment() opts.Update(env) -print "VARIABLE =", env.get('VARIABLE') +print("VARIABLE =", env.get('VARIABLE')) """ test.write(['bin', 'opts.cfg'], """\ diff --git a/test/Dir/Dir.py b/test/Dir/Dir.py index af0a10b..2e8204c 100644 --- a/test/Dir/Dir.py +++ b/test/Dir/Dir.py @@ -36,12 +36,12 @@ test = TestSCons.TestSCons() test.write('SConstruct', """ env = Environment(FOO = 'fff', BAR = 'bbb') -print Dir('ddd') -print Dir('$FOO') -print Dir('${BAR}_$BAR') -print env.Dir('eee') -print env.Dir('$FOO') -print env.Dir('${BAR}_$BAR') +print(Dir('ddd')) +print(Dir('$FOO')) +print(Dir('${BAR}_$BAR')) +print(env.Dir('eee')) +print(env.Dir('$FOO')) +print(env.Dir('${BAR}_$BAR')) """) test.run(stdout = test.wrap_stdout(read_str = """\ -- cgit v0.12 From 3f637329635c089bdca30bb4b0e23334d12866b3 Mon Sep 17 00:00:00 2001 From: Russel Winder Date: Fri, 1 Jan 2016 15:59:23 +0000 Subject: Some more statement to function transforms. --- test/CPPDEFINES/pkg-config.py | 12 +++---- test/Deprecated/Options/EnumOption.py | 6 ++-- test/Deprecated/Options/ListOption.py | 16 ++++----- test/Entry.py | 12 +++---- test/Environment.py | 4 +-- test/Errors/Exception.py | 2 +- test/ExecuteInvalidateCache.py | 4 +-- test/Exit.py | 12 +++---- test/File.py | 16 ++++----- test/FindFile.py | 8 ++--- test/Flatten.py | 8 ++--- test/GetBuildFailures/parallel.py | 6 ++-- test/GetBuildFailures/serial.py | 4 +-- test/GetOption/help.py | 4 +-- test/Libs/SharedLibraryIxes.py | 16 ++++----- test/Mkdir.py | 2 +- test/NodeOps.py | 4 +-- test/ParseConfig.py | 32 +++++++++--------- test/Platform.py | 16 ++++----- test/QT/QTFLAGS.py | 8 ++--- test/QT/manual.py | 6 ++-- test/tool_args.py | 8 ++--- test/toolpath/basic.py | 62 +++++++++++++++++------------------ 23 files changed, 134 insertions(+), 134 deletions(-) diff --git a/test/CPPDEFINES/pkg-config.py b/test/CPPDEFINES/pkg-config.py index 1b308d3..4e81dec 100644 --- a/test/CPPDEFINES/pkg-config.py +++ b/test/CPPDEFINES/pkg-config.py @@ -60,26 +60,26 @@ test.write('SConstruct', """\ # Passing test cases env_1 = Environment(CPPDEFINES=[('DEBUG','1'), 'TEST']) env_1.ParseConfig('PKG_CONFIG_PATH=. %(pkg_config_path)s --cflags bug') -print env_1.subst('$_CPPDEFFLAGS') +print(env_1.subst('$_CPPDEFFLAGS')) env_2 = Environment(CPPDEFINES=[('DEBUG','1'), 'TEST']) env_2.MergeFlags('-DSOMETHING -DVARIABLE=2') -print env_2.subst('$_CPPDEFFLAGS') +print(env_2.subst('$_CPPDEFFLAGS')) # Failing test cases env_3 = Environment(CPPDEFINES={'DEBUG':1, 'TEST':None}) env_3.ParseConfig('PKG_CONFIG_PATH=. %(pkg_config_path)s --cflags bug') -print env_3.subst('$_CPPDEFFLAGS') +print(env_3.subst('$_CPPDEFFLAGS')) env_4 = Environment(CPPDEFINES={'DEBUG':1, 'TEST':None}) env_4.MergeFlags('-DSOMETHING -DVARIABLE=2') -print env_4.subst('$_CPPDEFFLAGS') +print(env_4.subst('$_CPPDEFFLAGS')) # http://scons.tigris.org/issues/show_bug.cgi?id=1738 env_1738_1 = Environment(tools=['default']) env_1738_1.ParseConfig('PKG_CONFIG_PATH=. %(pkg_config_path)s --cflags --libs bug') env_1738_1.Append(CPPDEFINES={'value' : '1'}) -print env_1738_1.subst('$_CPPDEFFLAGS') +print(env_1738_1.subst('$_CPPDEFFLAGS')) """%locals() ) expect_print_output="""\ @@ -92,7 +92,7 @@ expect_print_output="""\ build_output="scons: `.' is up to date.\n" -expect = test.wrap_stdout(build_str=build_output, +expect = test.wrap_stdout(build_str=build_output, read_str = expect_print_output) test.run(arguments = '.', stdout=expect) test.pass_test() diff --git a/test/Deprecated/Options/EnumOption.py b/test/Deprecated/Options/EnumOption.py index 57ae7eb..2b3ed47 100644 --- a/test/Deprecated/Options/EnumOption.py +++ b/test/Deprecated/Options/EnumOption.py @@ -66,9 +66,9 @@ opts.AddOptions( env = Environment(options=opts) Help(opts.GenerateHelpText(env)) -print env['debug'] -print env['guilib'] -print env['some'] +print(env['debug']) +print(env['guilib'] +print(env['some']) Default(env.Alias('dummy', None)) """) diff --git a/test/Deprecated/Options/ListOption.py b/test/Deprecated/Options/ListOption.py index bb3775b..ad804f2 100644 --- a/test/Deprecated/Options/ListOption.py +++ b/test/Deprecated/Options/ListOption.py @@ -67,15 +67,15 @@ env = Environment(options=opts) opts.Save(optsfile, env) Help(opts.GenerateHelpText(env)) -print env['shared'] -if 'ical' in env['shared']: print '1' -else: print '0' +print(env['shared']) +if 'ical' in env['shared']: print('1') +else: print('0') for x in env['shared']: - print x, -print -print env.subst('$shared') + print(x, end='') +print() +print(env.subst('$shared')) # Test subst_path() because it's used in $CPPDEFINES expansions. -print env.subst_path('$shared') +print(env.subst_path('$shared')) Default(env.Alias('dummy', None)) """) @@ -169,7 +169,7 @@ opts.AddOptions( env = Environment(options=opts) Help(opts.GenerateHelpText(env)) -print env['gpib'] +print(env['gpib']) Default(env.Alias('dummy', None)) """) diff --git a/test/Entry.py b/test/Entry.py index 3767cc5..3d3255d 100644 --- a/test/Entry.py +++ b/test/Entry.py @@ -36,12 +36,12 @@ test = TestSCons.TestSCons() test.write('SConstruct', """ env = Environment(FOO = 'fff', BAR = 'bbb') -print Entry('ddd') -print Entry('$FOO') -print Entry('${BAR}_$BAR') -print env.Entry('eee') -print env.Entry('$FOO') -print env.Entry('${BAR}_$BAR') +print(Entry('ddd')) +print(Entry('$FOO')) +print(Entry('${BAR}_$BAR')) +print(env.Entry('eee')) +print(env.Entry('$FOO')) +print(env.Entry('${BAR}_$BAR')) """) test.run(stdout = test.wrap_stdout(read_str = """\ diff --git a/test/Environment.py b/test/Environment.py index 52b6488..6810979 100644 --- a/test/Environment.py +++ b/test/Environment.py @@ -42,8 +42,8 @@ assert Dir('.') == Dir('.').Dir('.') assert target == target.File('foo.out') e2 = env.Environment(XXX='$BAR', YYY='$BLAT') -print e2['XXX'] -print e2['YYY'] +print(e2['XXX']) +print(e2['YYY']) """ % locals()) test.write('build.py', """ diff --git a/test/Errors/Exception.py b/test/Errors/Exception.py index cc36035..30404fc 100644 --- a/test/Errors/Exception.py +++ b/test/Errors/Exception.py @@ -30,7 +30,7 @@ test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) test.write('SConstruct', """\ def foo(env, target, source): - print str(target[0]) + print(str(target[0])) open(str(target[0]), 'wt').write('foo') def exit(env, target, source): diff --git a/test/ExecuteInvalidateCache.py b/test/ExecuteInvalidateCache.py index a22c5ea..6d8063e 100644 --- a/test/ExecuteInvalidateCache.py +++ b/test/ExecuteInvalidateCache.py @@ -40,9 +40,9 @@ subfn = os.path.join('sub', 'foo') test.write('SConstruct', """\ def exists(node): if node.exists(): - print str(node), "exists" + print(str(node), "exists") else: - print str(node), "does not exist" + print(str(node), "does not exist") Execute(Delete('abc')) n1 = File('abc') diff --git a/test/Exit.py b/test/Exit.py index 877a0b6..394ee2f 100644 --- a/test/Exit.py +++ b/test/Exit.py @@ -40,7 +40,7 @@ subdir_foo_in = os.path.join('subdir', 'foo.in') subdir_foo_out = os.path.join('subdir', 'foo.out') test.write('SConstruct', """\ -print "SConstruct, Exit()" +print("SConstruct, Exit()") Exit() """) @@ -51,7 +51,7 @@ SConstruct, Exit() test.write('SConstruct', """\ env = Environment() -print "SConstruct, env.Exit()" +print("SConstruct, env.Exit()") env.Exit() """) @@ -61,7 +61,7 @@ SConstruct, env.Exit() """) test.write('SConstruct', """\ -print "SConstruct" +print("SConstruct") Exit(7) """) @@ -71,12 +71,12 @@ SConstruct """) test.write('SConstruct', """\ -print "SConstruct" +print("SConstruct") SConscript('subdir/SConscript') """) test.write(['subdir', 'SConscript'], """\ -print "subdir/SConscript" +print("subdir/SConscript") Exit() """) @@ -87,7 +87,7 @@ subdir/SConscript """) test.write(['subdir', 'SConscript'], """\ -print "subdir/SConscript" +print("subdir/SConscript") Exit(17) """) diff --git a/test/File.py b/test/File.py index d919884..ec148b2 100644 --- a/test/File.py +++ b/test/File.py @@ -38,16 +38,16 @@ test = TestSCons.TestSCons() test.write('SConstruct', """ env = Environment(FOO = 'fff', BAR = 'bbb') -print File('ddd') -print File('$FOO') -print File('${BAR}_$BAR') -print env.File('eee') -print env.File('$FOO') -print env.File('${BAR}_$BAR') +print(File('ddd')) +print(File('$FOO')) +print(File('${BAR}_$BAR')) +print(env.File('eee')) +print(env.File('$FOO')) +print(env.File('${BAR}_$BAR')) f1 = env.File('f1') -print f1 +print(f1) f2 = f1.File('f2') -print f2 +print(f2) """) expect = test.wrap_stdout(read_str = """\ diff --git a/test/FindFile.py b/test/FindFile.py index 5d198ac..e878172 100644 --- a/test/FindFile.py +++ b/test/FindFile.py @@ -40,13 +40,13 @@ test.write(['bar', 'baz', 'testfile2'], 'test 4\n') test.write('SConstruct', """ env = Environment(FILE = 'file', BAR = 'bar') file1 = FindFile('testfile1', [ 'foo', '.', 'bar', 'bar/baz' ]) -print open(str(file1), 'r').read() +print(open(str(file1), 'r').read()) file2 = env.FindFile('test${FILE}1', [ 'bar', 'foo', '.', 'bar/baz' ]) -print open(str(file2), 'r').read() +print(open(str(file2), 'r').read()) file3 = FindFile('testfile2', [ 'foo', '.', 'bar', 'bar/baz' ]) -print open(str(file3), 'r').read() +print(open(str(file3), 'r').read()) file4 = env.FindFile('testfile2', [ '$BAR/baz', 'foo', '.', 'bar' ]) -print open(str(file4), 'r').read() +print(open(str(file4), 'r').read()) """) expect = test.wrap_stdout(read_str = """test 1 diff --git a/test/Flatten.py b/test/Flatten.py index b41c4fe..fd9943d 100644 --- a/test/Flatten.py +++ b/test/Flatten.py @@ -44,15 +44,15 @@ def cat(env, source, target): env = Environment(BUILDERS={'Cat':Builder(action=cat)}) f1 = env.Cat('../file1.out', 'file1.in') f2 = env.Cat('../file2.out', ['file2a.in', 'file2b.in']) -print list(map(str, Flatten(['begin', f1, 'middle', f2, 'end']))) -print list(map(str, env.Flatten([f1, [['a', 'b'], 'c'], f2]))) +print(list(map(str, Flatten(['begin', f1, 'middle', f2, 'end'])))) +print(list(map(str, env.Flatten([f1, [['a', 'b'], 'c'], f2])))) SConscript('SConscript', "env") """) test.write(['work', 'SConscript'], """ Import("env") -print Flatten([1, [2, 3], 4]) -print env.Flatten([[[[1], 2], 3], 4]) +print(Flatten([1, [2, 3], 4])) +print(env.Flatten([[[[1], 2], 3], 4])) """) test.write('file1.in', "file1.in\n") diff --git a/test/GetBuildFailures/parallel.py b/test/GetBuildFailures/parallel.py index e746d53..ee0e831 100644 --- a/test/GetBuildFailures/parallel.py +++ b/test/GetBuildFailures/parallel.py @@ -81,7 +81,7 @@ Command('f6', 'f6.in', r'@%(_python_)s mypass.py f5 - $TARGET $SOURCE') def print_build_failures(): from SCons.Script import GetBuildFailures for bf in sorted(GetBuildFailures(), key=lambda t: t.filename): - print "%%s failed: %%s" %% (bf.node, bf.errstr) + print("%%s failed: %%s" %% (bf.node, bf.errstr)) import atexit atexit.register(print_build_failures) @@ -96,7 +96,7 @@ test.run(arguments = '-Q -j 4 .', status = 2, stderr = None) -f4_error = "scons: *** [f4] Error 1\n" +f4_error = "scons: *** [f4] Error 1\n" f5_error = "scons: *** [f5] Error 1\n" error_45 = f4_error + f5_error @@ -129,7 +129,7 @@ if test.stdout() not in [failed_45, failed_54]: test.must_match(test.workpath('f3'), 'f3.in\n') test.must_not_exist(test.workpath('f4')) test.must_not_exist(test.workpath('f5')) -test.must_match(test.workpath('f6'), 'f6.in\n') +test.must_match(test.workpath('f6'), 'f6.in\n') diff --git a/test/GetBuildFailures/serial.py b/test/GetBuildFailures/serial.py index 9c56bb1..fb59c7c 100644 --- a/test/GetBuildFailures/serial.py +++ b/test/GetBuildFailures/serial.py @@ -91,9 +91,9 @@ def print_build_failures(): from SCons.Script import GetBuildFailures for bf in sorted(GetBuildFailures(), key=lambda t: str(t.node)): assert( isinstance(bf, SCons.Errors.BuildError) ) - print "BF: %%s failed (%%s): %%s" %% (bf.node, bf.status, bf.errstr) + print("BF: %%s failed (%%s): %%s" %% (bf.node, bf.status, bf.errstr)) if bf.command: - print "BF: %%s" %% " ".join(Flatten(bf.command)) + print("BF: %%s" %% " ".join(Flatten(bf.command))) import atexit atexit.register(print_build_failures) diff --git a/test/GetOption/help.py b/test/GetOption/help.py index e2eeef7..4f15fe6 100644 --- a/test/GetOption/help.py +++ b/test/GetOption/help.py @@ -34,9 +34,9 @@ test = TestSCons.TestSCons() test.write('SConstruct', """\ if GetOption('help'): - print "GetOption('help') set" + print("GetOption('help') set") else: - print "no help for you" + print("no help for you") """) test.run(arguments = '-q -Q', stdout = "no help for you\n") diff --git a/test/Libs/SharedLibraryIxes.py b/test/Libs/SharedLibraryIxes.py index 6924769..93d67ea 100644 --- a/test/Libs/SharedLibraryIxes.py +++ b/test/Libs/SharedLibraryIxes.py @@ -102,7 +102,7 @@ def nameInLib(source, lib, libname): # When using non-standard prefixes and suffixes, one has to # provide the full name of the library since scons can not know # which of the non-standard extension to use. - # + # # Note that this is not necessarily SHLIBPREFIX and # SHLIBSUFFIX. These are the ixes of the target library, not the # ixes of the library that we are linking against. @@ -130,7 +130,7 @@ def buildAndlinkAgainst(builder, target, source, method, lib, libname, **kw): # for the linker command line... if (isMingw or isCygwin) and len(lib) > 1: lib = lib[1:] - + # Apply the naming method to be tested and call the specified Builder. (source, LIBS) = method(source, lib, libname) #build = builder(target=target, source=source, LIBS=LIBS, **kw) @@ -153,8 +153,8 @@ def buildAndlinkAgainst(builder, target, source, method, lib, libname, **kw): (list(map(str,lib)), list(map(str, build[0].children())), method.__name__, libname, shlibsuffix) return build -def prog(i, - goomethod, goolibprefix, goolibsuffix, +def prog(i, + goomethod, goolibprefix, goolibsuffix, foomethod, foolibprefix, foolibsuffix): '''Build a program @@ -166,7 +166,7 @@ def prog(i, foo_name = foolibprefix+'foo'+str(i)+foolibsuffix prog_name = progprefix+'prog'+str(i)+progsuffix - print 'Prog: %d, %s, %s, %s' % (i, goo_name, foo_name, prog_name) + print('Prog: %d, %s, %s, %s' % (i, goo_name, foo_name, prog_name)) # On Windows, we have to link against the .lib file. if isWindows: @@ -179,7 +179,7 @@ def prog(i, goo_lib = env.SharedLibrary( goo_name, goo_obj, SHLIBSUFFIX=goolibsuffix) foo_lib = buildAndlinkAgainst( - env.SharedLibrary, foo_name, foo_obj, + env.SharedLibrary, foo_name, foo_obj, goomethod, goo_lib, goo_libname, SHLIBSUFFIX=foolibsuffix) prog = buildAndlinkAgainst(env.Program, prog_name, prog_obj, foomethod, foo_lib, foo_libname) @@ -199,8 +199,8 @@ for foolibprefix in prefixes: for goolibsuffix in suffixes: for goomethod in libmethods: tests.append( - (i, - goomethod, goolibprefix, goolibsuffix, + (i, + goomethod, goolibprefix, goolibsuffix, foomethod, foolibprefix, foolibsuffix)) i = i + 1 diff --git a/test/Mkdir.py b/test/Mkdir.py index 4d309bb..8ace476 100644 --- a/test/Mkdir.py +++ b/test/Mkdir.py @@ -178,7 +178,7 @@ test.write(['work3', 'sub1', 'sub11', 'SConscript'], """\ #/sub1/sub11/SConscript------------------------- Import('env test1') test11 = test1 + '/test11' -print 'test11 = ' + test11 +print('test11 = ' + test11) env.Command(Dir(test11), '', Mkdir('$TARGET')) """) diff --git a/test/NodeOps.py b/test/NodeOps.py index 5062b72..1f856c3 100644 --- a/test/NodeOps.py +++ b/test/NodeOps.py @@ -43,7 +43,7 @@ _lib = TestSCons._lib _obj = TestSCons._obj dll_ = TestSCons.dll_ _dll = TestSCons._dll - + if os.name == 'posix': os.environ['LD_LIBRARY_PATH'] = '.' if sys.platform.find('irix') > -1: @@ -71,7 +71,7 @@ if %(_E)s: exists = [N.exists() for N in Nodes] real2 = [os.path.exists(str(N)) for N in Nodes] for N,D,R,E,F in zip(Nodes, derived, real1, exists, real2): - print '%%s: %%s %%s %%s %%s'%%(N,D,R,E,F) + print('%%s: %%s %%s %%s %%s'%%(N,D,R,E,F)) foo.SharedLibrary(target = 'foo', source = 'foo%(_obj)s') bar.SharedLibrary(target = 'bar', source = 'bar%(_obj)s') diff --git a/test/ParseConfig.py b/test/ParseConfig.py index 9bcc440..efb3a75 100644 --- a/test/ParseConfig.py +++ b/test/ParseConfig.py @@ -38,17 +38,17 @@ test_config3 = test.workpath('test-config3') # File node. # It used to be returned as the 'static_libs' output of ParseConfig. test.write(test_config1, """\ -print "-I/usr/include/fum -Ibar -X -arch i386" -print "-L/usr/fax -Lfoo -lxxx abc" +print("-I/usr/include/fum -Ibar -X -arch i386") +print("-L/usr/fax -Lfoo -lxxx abc") """) test.write(test_config2, """\ -print "-L foo -L lib_dir" +print("-L foo -L lib_dir") """) # This is like what wxWidgets does on OSX w/ Universal Binaries test.write(test_config3, """\ -print "-L foo -L lib_dir -isysroot /tmp -arch ppc -arch i386" +print("-L foo -L lib_dir -isysroot /tmp -arch ppc -arch i386") """) test.write('SConstruct1', """ @@ -56,10 +56,10 @@ env = Environment(CPPPATH = [], LIBPATH = [], LIBS = [], CCFLAGS = '-pipe -Wall') env.ParseConfig([r'%(_python_)s', r"%(test_config1)s", "--libs --cflags"]) env.ParseConfig([r'%(_python_)s', r"%(test_config2)s", "--libs --cflags"]) -print env['CPPPATH'] -print env['LIBPATH'] -print [str(x) for x in env['LIBS']] -print env['CCFLAGS'] +print(env['CPPPATH']) +print(env['LIBPATH']) +print([str(x) for x in env['LIBS']]) +print(env['CCFLAGS']) """ % locals()) test.write('SConstruct2', """ @@ -68,10 +68,10 @@ env = Environment(CPPPATH = [], LIBPATH = [], LIBS = [], PYTHON = r'%(_python_)s') env.ParseConfig(r"$PYTHON %(test_config1)s --libs --cflags") env.ParseConfig(r"$PYTHON %(test_config2)s --libs --cflags") -print env['CPPPATH'] -print env['LIBPATH'] -print [str(x) for x in env['LIBS']] -print env['CCFLAGS'] +print(env['CPPPATH']) +print(env['LIBPATH']) +print([str(x) for x in env['LIBS']]) +print(env['CCFLAGS']) """ % locals()) test.write('SConstruct3', """ @@ -79,10 +79,10 @@ env = Environment(CPPPATH = [], LIBPATH = [], LIBS = [], CCFLAGS = '-pipe -Wall', PYTHON = r'%(_python_)s') env.ParseConfig(r"$PYTHON %(test_config3)s --libs --cflags") -print env['CPPPATH'] -print env['LIBPATH'] -print [str(x) for x in env['LIBS']] -print env['CCFLAGS'] +print(env['CPPPATH']) +print(env['LIBPATH']) +print([str(x) for x in env['LIBS']]) +print(env['CCFLAGS']) """ % locals()) good_stdout = """\ diff --git a/test/Platform.py b/test/Platform.py index 23068c4..924dbc7 100644 --- a/test/Platform.py +++ b/test/Platform.py @@ -31,27 +31,27 @@ test = TestSCons.TestSCons() test.write('SConstruct', """ env = Environment() Platform('cygwin')(env) -print "'%s'" % env['PROGSUFFIX'] +print("'%s'" % env['PROGSUFFIX']) assert env['SHELL'] == 'sh' Platform('os2')(env) -print "'%s'" % env['PROGSUFFIX'] +print("'%s'" % env['PROGSUFFIX']) env.Platform('posix') -print "'%s'" % env['PROGSUFFIX'] +print("'%s'" % env['PROGSUFFIX']) Platform('win32')(env) -print "'%s'" % env['PROGSUFFIX'] +print("'%s'" % env['PROGSUFFIX']) SConscript('SConscript') """) test.write('SConscript', """ env = Environment() Platform('cygwin')(env) -print "'%s'" % env['LIBSUFFIX'] +print("'%s'" % env['LIBSUFFIX']) Platform('os2')(env) -print "'%s'" % env['LIBSUFFIX'] +print("'%s'" % env['LIBSUFFIX']) env.Platform('posix') -print "'%s'" % env['LIBSUFFIX'] +print("'%s'" % env['LIBSUFFIX']) Platform('win32')(env) -print "'%s'" % env['LIBSUFFIX'] +print("'%s'" % env['LIBSUFFIX']) """) expect = test.wrap_stdout(read_str = """'.exe' diff --git a/test/QT/QTFLAGS.py b/test/QT/QTFLAGS.py index 008397a..f6aa00f 100644 --- a/test/QT/QTFLAGS.py +++ b/test/QT/QTFLAGS.py @@ -136,7 +136,7 @@ int main() { """) test.run(chdir = 'work1', arguments = "mytest" + _exe) - + test.must_exist(['work1', 'mmmmocFromH.cxx'], ['work1', 'mocmocFromCpp.inl'], ['work1', 'an_ui_file.cxx'], @@ -168,15 +168,15 @@ env1 = Environment(tools=['qt'], cpppath = env1.subst('$CPPPATH') if os.path.normpath(cpppath) != os.path.join(r'%(QTDIR)s', 'h64'): - print cpppath + print(cpppath) Exit(1) libpath = env1.subst('$LIBPATH') if os.path.normpath(libpath) != os.path.join(r'%(QTDIR)s', 'lib64'): - print libpath + print(libpath) Exit(2) qt_moc = env1.subst('$QT_MOC') if os.path.normpath(qt_moc) != os.path.join(r'%(QTDIR)s', 'bin64', 'moc'): - print qt_moc + print(qt_moc) Exit(3) env2 = Environment(tools=['default', 'qt'], diff --git a/test/QT/manual.py b/test/QT/manual.py index d911fb3..1f140ae 100644 --- a/test/QT/manual.py +++ b/test/QT/manual.py @@ -58,7 +58,7 @@ env.Ignore( moc, moc ) sources.extend(env.Uic(['include/uic_fff.hpp', 'fff.cpp', 'fff.moc.cpp'], 'ui/fff.ui')[1:]) -print list(map(str,sources)) +print(list(map(str,sources))) env.Program(target='aaa', source=sources, CPPPATH=['$CPPPATH', './include'], @@ -68,7 +68,7 @@ env.Program(target='aaa', test.write('aaa.cpp', r""" #include "aaa.h" """) - + test.write(['include', 'aaa.h'], r""" #include "my_qobject.h" void aaa(void) Q_OBJECT; @@ -91,7 +91,7 @@ void ccc(void) test.write('ddd.cpp', r""" #include "ddd.h" """) - + test.write(['include', 'ddd.h'], r""" #include "my_qobject.h" void ddd(void) Q_OBJECT; diff --git a/test/tool_args.py b/test/tool_args.py index 692f6a5..b0f69ef 100644 --- a/test/tool_args.py +++ b/test/tool_args.py @@ -38,13 +38,13 @@ test = TestSCons.TestSCons() test.write('SConstruct', """ # Test passing kw args to Tool constructor env1 = Environment(tools=[Tool('FooTool', toolpath=['.'], kw1='kw1val')]) -print "env1['TOOL_FOO'] =", env1.get('TOOL_FOO') -print "env1['kw1'] =", env1.get('kw1') +print("env1['TOOL_FOO'] =", env1.get('TOOL_FOO')) +print("env1['kw1'] =", env1.get('kw1')) # Test apply_tools taking a list of (name, kwargs_dict) env2 = Environment(tools=[('FooTool', {'kw2':'kw2val'})], toolpath=['.']) -print "env2['TOOL_FOO'] =", env2.get('TOOL_FOO') -print "env2['kw2'] =", env2.get('kw2') +print("env2['TOOL_FOO'] =", env2.get('TOOL_FOO')) +print("env2['kw2'] =", env2.get('kw2')) """) diff --git a/test/toolpath/basic.py b/test/toolpath/basic.py index e1e6f3c..eedd06e 100644 --- a/test/toolpath/basic.py +++ b/test/toolpath/basic.py @@ -33,63 +33,63 @@ test = TestSCons.TestSCons() test.write('SConstruct', """ def foo(env): env['TOOL_FOO'] = 1 - + env1 = Environment(tools=[foo, 'bar'], toolpath=['tools']) -print "env1['TOOL_FOO'] =", env1.get('TOOL_FOO') -print "env1['TOOL_BAR'] =", env1.get('TOOL_BAR') +print("env1['TOOL_FOO'] =", env1.get('TOOL_FOO')) +print("env1['TOOL_BAR'] =", env1.get('TOOL_BAR')) # pick a built-in tool with pretty simple behavior env2 = Environment(tools=['SCCS']) -print "env2['SCCS'] =", env2.get('SCCS') -print "env2['TOOL_SCCS1'] =", env2.get('TOOL_SCCS1') -print "env2['TOOL_SCCS2'] =", env2.get('TOOL_SCCS2') +print("env2['SCCS'] =", env2.get('SCCS') +print("env2['TOOL_SCCS1'] =", env2.get('TOOL_SCCS1')) +print("env2['TOOL_SCCS2'] =", env2.get('TOOL_SCCS2')) env3 = Environment(tools=['SCCS'], toolpath=['.']) -print "env3['SCCS'] =", env3.get('SCCS') -print "env3['TOOL_SCCS1'] =", env3.get('TOOL_SCCS1') -print "env3['TOOL_SCCS2'] =", env3.get('TOOL_SCCS2') +print("env3['SCCS'] =", env3.get('SCCS') +print("env3['TOOL_SCCS1'] =", env3.get('TOOL_SCCS1')) +print("env3['TOOL_SCCS2'] =", env3.get('TOOL_SCCS2')) env4 = Environment(tools=['SCCS'], toolpath=['tools']) -print "env4['SCCS'] =", env4.get('SCCS') -print "env4['TOOL_SCCS1'] =", env4.get('TOOL_SCCS1') -print "env4['TOOL_SCCS2'] =", env4.get('TOOL_SCCS2') +print("env4['SCCS'] =", env4.get('SCCS')) +print("env4['TOOL_SCCS1'] =", env4.get('TOOL_SCCS1')) +print("env4['TOOL_SCCS2'] =", env4.get('TOOL_SCCS2')) env5 = Environment(tools=['SCCS'], toolpath=['tools', '.']) -print "env5['SCCS'] =", env5.get('SCCS') -print "env5['TOOL_SCCS1'] =", env5.get('TOOL_SCCS1') -print "env5['TOOL_SCCS2'] =", env5.get('TOOL_SCCS2') +print("env5['SCCS'] =", env5.get('SCCS')) +print("env5['TOOL_SCCS1'] =", env5.get('TOOL_SCCS1')) +print("env5['TOOL_SCCS2'] =", env5.get('TOOL_SCCS2')) env6 = Environment(tools=['SCCS'], toolpath=['.', 'tools']) -print "env6['SCCS'] =", env6.get('SCCS') -print "env6['TOOL_SCCS1'] =", env6.get('TOOL_SCCS1') -print "env6['TOOL_SCCS2'] =", env6.get('TOOL_SCCS2') +print("env6['SCCS'] =", env6.get('SCCS')) +print("env6['TOOL_SCCS1'] =", env6.get('TOOL_SCCS1')) +print("env6['TOOL_SCCS2'] =", env6.get('TOOL_SCCS2')) env7 = Environment(TOOLPATH="tools", tools=['SCCS'], toolpath=['$TOOLPATH']) -print "env7['SCCS'] =", env7.get('SCCS') -print "env7['TOOL_SCCS1'] =", env7.get('TOOL_SCCS1') -print "env7['TOOL_SCCS2'] =", env7.get('TOOL_SCCS2') +print("env7['SCCS'] =", env7.get('SCCS')) +print("env7['TOOL_SCCS1'] =", env7.get('TOOL_SCCS1')) +print("env7['TOOL_SCCS2'] =", env7.get('TOOL_SCCS2')) env8 = Environment(tools=[]) env8.Tool('SCCS', toolpath=['tools']) -print "env8['SCCS'] =", env8.get('SCCS') -print "env8['TOOL_SCCS1'] =", env8.get('TOOL_SCCS1') -print "env8['TOOL_SCCS2'] =", env8.get('TOOL_SCCS2') +print("env8['SCCS'] =", env8.get('SCCS')) +print("env8['TOOL_SCCS1'] =", env8.get('TOOL_SCCS1')) +print("env8['TOOL_SCCS2'] =", env8.get('TOOL_SCCS2')) env9 = Environment(tools=[]) Tool('SCCS', toolpath=['tools'])(env9) -print "env9['SCCS'] =", env9.get('SCCS') -print "env9['TOOL_SCCS1'] =", env9.get('TOOL_SCCS1') -print "env9['TOOL_SCCS2'] =", env9.get('TOOL_SCCS2') +print("env9['SCCS'] =", env9.get('SCCS')) +print("env9['TOOL_SCCS1'] =", env9.get('TOOL_SCCS1')) +print("env9['TOOL_SCCS2'] =", env9.get('TOOL_SCCS2')) env0 = Environment(TOOLPATH='tools', tools=[]) env0.Tool('SCCS', toolpath=['$TOOLPATH']) -print "env0['SCCS'] =", env0.get('SCCS') -print "env0['TOOL_SCCS1'] =", env0.get('TOOL_SCCS1') -print "env0['TOOL_SCCS2'] =", env0.get('TOOL_SCCS2') +print("env0['SCCS'] =", env0.get('SCCS')) +print("env0['TOOL_SCCS1'] =", env0.get('TOOL_SCCS1')) +print("env0['TOOL_SCCS2'] =", env0.get('TOOL_SCCS2')) base = Environment(tools=[], toolpath=['tools']) derived = base.Clone(tools=['bar']) -print "derived['TOOL_BAR'] =", derived.get('TOOL_BAR') +print("derived['TOOL_BAR'] =", derived.get('TOOL_BAR')) """) test.write('SCCS.py', r"""\ -- cgit v0.12 From 7a6018983cf716374f2c7bf3b48e3f386bcaadd9 Mon Sep 17 00:00:00 2001 From: Russel Winder Date: Fri, 1 Jan 2016 16:21:10 +0000 Subject: Some more statement to function transforms. --- QMTest/TestSCons.py | 12 ++++++------ test/Repository/Default.py | 2 +- test/Repository/Local.py | 4 ++-- test/Repository/VariantDir.py | 2 +- test/Repository/option-c.py | 2 +- test/Repository/option-n.py | 2 +- test/Repository/targets.py | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index d98b155..3857da5 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -929,7 +929,7 @@ if ARGUMENTS.get('variant_dir', 0): else: builddir = 'build' VariantDir(builddir, '.', duplicate=dup) - print builddir, dup + print(builddir, dup) sconscript = Dir(builddir).File('SConscript') else: sconscript = File('SConscript') @@ -1142,12 +1142,12 @@ except AttributeError: try: import distutils.sysconfig exec_prefix = distutils.sysconfig.EXEC_PREFIX - print distutils.sysconfig.get_python_inc() - print os.path.join(exec_prefix, 'libs') + print(distutils.sysconfig.get_python_inc()) + print(os.path.join(exec_prefix, 'libs')) except: - print os.path.join(sys.prefix, 'include', py_ver) - print os.path.join(sys.prefix, 'lib', py_ver, 'config') -print py_ver + print(os.path.join(sys.prefix, 'include', py_ver) + print(os.path.join(sys.prefix, 'lib', py_ver, 'config')) +print(py_ver) """) return [python] + self.stdout().strip().split('\n') diff --git a/test/Repository/Default.py b/test/Repository/Default.py index 127c29a..44aecfb 100644 --- a/test/Repository/Default.py +++ b/test/Repository/Default.py @@ -46,7 +46,7 @@ test.write(['repository', 'SConstruct'], r""" def copy(env, source, target): source = str(source[0]) target = str(target[0]) - print 'copy() < %s > %s' % (source, target) + print('copy() < %s > %s' % (source, target)) open(target, "wb").write(open(source, "rb").read()) Build = Builder(action=copy) diff --git a/test/Repository/Local.py b/test/Repository/Local.py index 1b63345..ea03281 100644 --- a/test/Repository/Local.py +++ b/test/Repository/Local.py @@ -48,7 +48,7 @@ test.write(['repository', 'SConstruct'], r""" def copy(env, source, target): source = str(source[0]) target = str(target[0]) - print 'copy() < %s > %s' % (source, target) + print('copy() < %s > %s' % (source, target)) open(target, "wb").write(open(source, "rb").read()) Build = Builder(action=copy) @@ -65,7 +65,7 @@ SConscript('build/SConscript') test.write(['repository', 'src', 'SConscript'], r""" def bbb_copy(env, source, target): target = str(target[0]) - print 'bbb_copy()' + print('bbb_copy()') open(target, "wb").write(open('build/bbb.1', "rb").read()) Import("env") diff --git a/test/Repository/VariantDir.py b/test/Repository/VariantDir.py index ec723c8..0258ff5 100644 --- a/test/Repository/VariantDir.py +++ b/test/Repository/VariantDir.py @@ -48,7 +48,7 @@ test.write(['repository', 'src', 'SConscript'], r""" def cat(env, source, target): target = str(target[0]) source = list(map(str, source)) - print 'cat(%s) > %s' % (source, target) + print('cat(%s) > %s' % (source, target)) f = open(target, "wb") for src in source: f.write(open(src, "rb").read()) diff --git a/test/Repository/option-c.py b/test/Repository/option-c.py index ea989c2..c06c7d8 100644 --- a/test/Repository/option-c.py +++ b/test/Repository/option-c.py @@ -65,7 +65,7 @@ test.write(['repository', 'SConstruct'], r""" def copy(env, source, target): source = str(source[0]) target = str(target[0]) - print 'copy() < %s > %s' % (source, target) + print('copy() < %s > %s' % (source, target)) open(target, "wb").write(open(source, "rb").read()) Build = Builder(action=copy) diff --git a/test/Repository/option-n.py b/test/Repository/option-n.py index 220baad..2a0ae5d 100644 --- a/test/Repository/option-n.py +++ b/test/Repository/option-n.py @@ -48,7 +48,7 @@ test.write(['repository', 'SConstruct'], r""" def copy(env, source, target): source = str(source[0]) target = str(target[0]) - print 'copy() < %s > %s' % (source, target) + print('copy() < %s > %s' % (source, target)) open(target, "wb").write(open(source, "rb").read()) Build = Builder(action=copy) diff --git a/test/Repository/targets.py b/test/Repository/targets.py index 62f4785..0fbc896 100644 --- a/test/Repository/targets.py +++ b/test/Repository/targets.py @@ -43,7 +43,7 @@ test.write(['repository', 'SConstruct'], """ def cat(env, source, target): target = str(target[0]) source = list(map(str, source)) - print 'cat(%s) > %s' % (source, target) + print('cat(%s) > %s' % (source, target)) f = open(target, "wb") for src in source: f.write(open(src, "rb").read()) -- cgit v0.12 From 543495e2fe3353396225b973e7fe64fb8e566f64 Mon Sep 17 00:00:00 2001 From: Russel Winder Date: Sun, 10 Jan 2016 15:21:22 +0000 Subject: Remove relative import. --- src/engine/SCons/cppTests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/cppTests.py b/src/engine/SCons/cppTests.py index 28a1f5e..40236e4 100644 --- a/src/engine/SCons/cppTests.py +++ b/src/engine/SCons/cppTests.py @@ -31,7 +31,7 @@ import unittest import TestUnit -from . import cpp +import cpp -- cgit v0.12 From 2bffdfc4addbc1565c2f21f35b73ab09ef4f3105 Mon Sep 17 00:00:00 2001 From: Russel Winder Date: Sun, 10 Jan 2016 15:29:55 +0000 Subject: Remove spurious space causing test fail. --- test/CPPDEFINES/append.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/CPPDEFINES/append.py b/test/CPPDEFINES/append.py index 432ab64..14ea7b3 100644 --- a/test/CPPDEFINES/append.py +++ b/test/CPPDEFINES/append.py @@ -67,7 +67,7 @@ for (t1, c1) in cases: env=Environment(CPPDEFINES = c1, CPPDEFPREFIX='-D') env.Append(CPPDEFINES = c2) final=env.subst('$_CPPDEFFLAGS',source="src", target="tgt") - print('Append: \\n\\tresult=%s\\n\\tfinal=%s'%\\ + print('Append:\\n\\tresult=%s\\n\\tfinal=%s'%\\ (env['CPPDEFINES'], final)) env=Environment(CPPDEFINES = c1, CPPDEFPREFIX='-D') env.AppendUnique(CPPDEFINES = c2) -- cgit v0.12 From 31c24bc7e328fb2e8d75893c675f63e37dc2e6dc Mon Sep 17 00:00:00 2001 From: Russel Winder Date: Sun, 10 Jan 2016 15:55:12 +0000 Subject: Refactor of test, but it still fails due to missing output from SCons. --- test/Clean/mkfifo.py | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/test/Clean/mkfifo.py b/test/Clean/mkfifo.py index 0ef7662..01e4d98 100644 --- a/test/Clean/mkfifo.py +++ b/test/Clean/mkfifo.py @@ -38,35 +38,40 @@ test = TestSCons.TestSCons() if not hasattr(os, 'mkfifo'): test.skip_test('No os.mkfifo() function; skipping test\n') +test_dir_name = 'testdir' +pipe_path = os.path.join(test_dir_name, 'namedpipe') + test.write('SConstruct', """\ -Execute(Mkdir("testdir")) -dir = Dir("testdir") -Clean(dir, 'testdir') -""") +Execute(Mkdir("{0}")) +dir = Dir("{0}") +Clean(dir, '{0}') +""".format(test_dir_name)) + +test.run(arguments='-Q -q', stdout='Mkdir("{0}")\n'.format(test_dir_name)) -test.run(arguments='-Q -q', stdout='Mkdir("testdir")\n') +os.mkfifo(pipe_path) -os.mkfifo('testdir/namedpipe') +test.must_exist(test.workpath(pipe_path)) expect1 = """\ -Mkdir("testdir") -Path '%s' exists but isn't a file or directory. -scons: Could not remove 'testdir': Directory not empty -""" % os.path.join('testdir', 'namedpipe') +Mkdir("{0}") +Path '{1}' exists but isn't a file or directory. +scons: Could not remove '{0}': Directory not empty +""".format(test_dir_name, pipe_path) expect2 = """\ -Mkdir("testdir") -Path '%s' exists but isn't a file or directory. -scons: Could not remove 'testdir': File exists -""" % os.path.join('testdir', 'namedpipe') +Mkdir("{0}") +Path '{1}' exists but isn't a file or directory. +scons: Could not remove '{0}': File exists +""".format(test_dir_name, pipe_path) test.run(arguments='-c -Q -q') +test.must_exist(test.workpath(pipe_path)) + if test.stdout() not in [expect1, expect2]: test.diff(expect1, test.stdout(), 'STDOUT ') test.fail_test() - -test.must_exist(test.workpath('testdir/namedpipe')) test.pass_test() -- cgit v0.12 From 82857f4e863cc754cd02e4aee8507d888afc377e Mon Sep 17 00:00:00 2001 From: Russel Winder Date: Sun, 10 Jan 2016 17:37:41 +0000 Subject: Amend the message. --- test/D/SharedObjects/Common/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/D/SharedObjects/Common/common.py b/test/D/SharedObjects/Common/common.py index e81cf5b..280c6f2 100644 --- a/test/D/SharedObjects/Common/common.py +++ b/test/D/SharedObjects/Common/common.py @@ -46,7 +46,7 @@ def testForTool(tool): test.skip_test("Required executable for tool '{0}' not found, skipping test.\n".format(tool)) if tool == 'gdc': - test.skip_test('gdc does not, as at version 4.9.1, support shared libraries.\n') + test.skip_test('gdc in GCC distribution does not, as at version 5.3.1, support shared libraries.\n') if tool == 'dmd' and Base()['DC'] == 'gdmd': test.skip_test('gdmd does not recognize the -shared option so cannot support linking of shared objects.\n') -- cgit v0.12 From 79d11adfb4ae11260ab644e8968843058e091ab4 Mon Sep 17 00:00:00 2001 From: Russel Winder Date: Sun, 10 Jan 2016 18:07:35 +0000 Subject: Output changed so changed expected results. --- src/engine/SCons/ActionTests.py | 42 ++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py index f56948f..3eee4b6 100644 --- a/src/engine/SCons/ActionTests.py +++ b/src/engine/SCons/ActionTests.py @@ -556,7 +556,7 @@ class _ActionActionTestCase(unittest.TestCase): assert isinstance(source, list), type(source) return 9 b = SCons.Action.Action([firstfunc, execfunc, lastfunc]) - + sio = io.StringIO() sys.stdout = sio result = a("out", "in", env) @@ -699,7 +699,7 @@ class _ActionActionTestCase(unittest.TestCase): env['PRINT_CMD_LINE_FUNC'] = my_print_cmd_line a("output", "input", env) assert result == ["execfunc(['output'], ['input'])"], result - + finally: sys.stdout = save_stdout @@ -942,7 +942,7 @@ class CommandActionTestCase(unittest.TestCase): act = SCons.Action.CommandAction('xyzzy $TARGETS $SOURCES', cmdstr='cmdstr\t$TARGETS\n$SOURCES ') - + s = act.strfunction([], [], env) assert s == 'cmdstr\t\n ', s s = act.strfunction([t1], [s1], env) @@ -1429,13 +1429,13 @@ class CommandGeneratorActionTestCase(unittest.TestCase): pass func_matches = [ - b"0,0,0,0,(),(),(d\000\000S),(),()", - b"0,0,0,0,(),(),(d\x00\x00S),(),()", + b"0, 0, 0, 0,(),(),(d\000\000S),(),()", + b"0, 0, 0, 0,(),(),(d\x00\x00S),(),()", ] - + meth_matches = [ - b"1,1,0,0,(),(),(d\000\000S),(),()", - b"1,1,0,0,(),(),(d\x00\x00S),(),()", + b"1, 1, 0, 0,(),(),(d\000\000S),(),()", + b"1, 1, 0, 0,(),(),(d\x00\x00S),(),()", ] def f_global(target, source, env, for_signature): @@ -1588,13 +1588,13 @@ class FunctionActionTestCase(unittest.TestCase): pass func_matches = [ - b"0,0,0,0,(),(),(d\000\000S),(),()", - b"0,0,0,0,(),(),(d\x00\x00S),(),()", + b"0, 0, 0, 0,(),(),(d\000\000S),(),()", + b"0, 0, 0, 0,(),(),(d\x00\x00S),(),()", ] - + meth_matches = [ - b"1,1,0,0,(),(),(d\000\000S),(),()", - b"1,1,0,0,(),(),(d\x00\x00S),(),()", + b"1, 1, 0, 0,(),(),(d\000\000S),(),()", + b"1, 1, 0, 0,(),(),(d\x00\x00S),(),()", ] def factory(act, **kw): @@ -1801,13 +1801,13 @@ class LazyActionTestCase(unittest.TestCase): pass func_matches = [ - b"0,0,0,0,(),(),(d\000\000S),(),()", - b"0,0,0,0,(),(),(d\x00\x00S),(),()", + b"0, 0, 0, 0,(),(),(d\000\000S),(),()", + b"0, 0, 0, 0,(),(),(d\x00\x00S),(),()", ] - + meth_matches = [ - b"1,1,0,0,(),(),(d\000\000S),(),()", - b"1,1,0,0,(),(),(d\x00\x00S),(),()", + b"1, 1, 0, 0,(),(),(d\000\000S),(),()", + b"1, 1, 0, 0,(),(),(d\x00\x00S),(),()", ] def factory(act, **kw): @@ -1999,16 +1999,16 @@ class ActionCompareTestCase(unittest.TestCase): especially two builders that can generate the same suffix, where one of the builders has a suffix dictionary with a None key.""" - + foo = SCons.Builder.Builder(action = '$FOO', suffix = '.foo') bar = SCons.Builder.Builder(action = {}, suffix={None:'.bar'}) bar.add_action('.cow', "$MOO") dog = SCons.Builder.Builder(suffix = '.bar') - + env = Environment( BUILDERS = {'FOO' : foo, 'BAR' : bar, 'DOG' : dog} ) - + assert foo.get_name(env) == 'FOO', foo.get_name(env) assert bar.get_name(env) == 'BAR', bar.get_name(env) assert dog.get_name(env) == 'DOG', dog.get_name(env) -- cgit v0.12 From 36d36e8dbf9e43c412f7a52a38dc1f9d9e8bb078 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Sun, 24 Jan 2016 16:36:12 +0000 Subject: Resolving a batch of failing tests for python 2.7. Note: please evaluate python 3.X compliance. --- src/engine/SCons/Script/Main.py | 6 ++---- test/Split.py | 16 ++++++++-------- test/TARGETS.py | 28 ++++++++++++++-------------- test/Variables/BoolVariable.py | 4 ++-- test/Variables/EnumVariable.py | 6 +++--- test/Variables/PackageVariable.py | 2 +- test/Variables/PathVariable.py | 14 +++++++------- test/Variables/Variables.py | 26 +++++++++++++------------- test/Variables/chdir.py | 2 +- test/Variables/help.py | 4 ++-- test/Variables/import.py | 2 +- test/WhereIs.py | 24 ++++++++++++------------ test/_CPPINCFLAGS.py | 6 +++--- test/custom-concat.py | 2 +- test/exitfns.py | 6 +++--- test/import.py | 7 +++---- test/no-arguments.py | 2 +- test/option--C.py | 6 +++--- test/option--I.py | 4 ++-- test/option-f.py | 8 ++++---- test/overrides.py | 6 +++--- test/preserve-source.py | 2 +- test/site_scons/basic.py | 4 ++-- test/site_scons/no-site-dir.py | 4 ++-- test/site_scons/override.py | 2 +- test/site_scons/site-dir.py | 4 ++-- test/site_scons/site_init.py | 8 ++++---- 27 files changed, 101 insertions(+), 104 deletions(-) diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py index 7cc7d47..997d701 100644 --- a/src/engine/SCons/Script/Main.py +++ b/src/engine/SCons/Script/Main.py @@ -10,8 +10,6 @@ some other module. If it's specific to the "scons" script invocation, it goes here. """ -from __future__ import print_function - unsupported_python_version = (2, 6, 0) deprecated_python_version = (2, 7, 0) @@ -330,7 +328,7 @@ class CleanTask(SCons.Taskmaster.AlwaysTask): except SCons.Errors.UserError as e: print(e) except (IOError, OSError) as e: - print_("scons: Could not remove '%s':" % pathstr, e.strerror) + print("scons: Could not remove '%s':" % pathstr, e.strerror) def _get_files_to_clean(self): result = [] @@ -794,7 +792,7 @@ def _load_all_site_scons_dirs(topdir, verbose=None): dirs=sysdirs + [topdir] for d in dirs: if verbose: # this is used by unit tests. - print_("Loading site dir ", d) + print("Loading site dir ", d) _load_site_scons_dir(d) def test_load_all_site_scons_dirs(d): diff --git a/test/Split.py b/test/Split.py index e98e299..c0533fa 100644 --- a/test/Split.py +++ b/test/Split.py @@ -30,19 +30,19 @@ test = TestSCons.TestSCons() test.write('SConstruct', """ env = Environment(BBB = 'bbb', CCC = 'ccc') -print Split('aaa') -print Split('aaa $BBB') -print env.Split('bbb $CCC') -print env.Split('$BBB ccc') -print Split(['ddd', 'eee']) +print(Split('aaa')) +print(Split('aaa $BBB')) +print(env.Split('bbb $CCC')) +print(env.Split('$BBB ccc')) +print(Split(['ddd', 'eee'])) SConscript('SConscript') """) test.write('SConscript', """ env = Environment(FFF='fff', JJJ='jjj') -print env.Split('${FFF}.f') -print Split('ggg hhh') -print env.Split(['iii', '$JJJ']) +print(env.Split('${FFF}.f')) +print(Split('ggg hhh')) +print(env.Split(['iii', '$JJJ'])) """) expect = """\ diff --git a/test/TARGETS.py b/test/TARGETS.py index 5b36c49..0ffc3b6 100644 --- a/test/TARGETS.py +++ b/test/TARGETS.py @@ -35,11 +35,11 @@ test = TestSCons.TestSCons() test.write('SConstruct', """ -print COMMAND_LINE_TARGETS -print list(map(str, BUILD_TARGETS)) +print(COMMAND_LINE_TARGETS) +print(list(map(str, BUILD_TARGETS))) Default('.') -print COMMAND_LINE_TARGETS -print list(map(str, BUILD_TARGETS)) +print(COMMAND_LINE_TARGETS) +print(list(map(str, BUILD_TARGETS))) """) test.write('aaa', 'aaa\n') @@ -68,17 +68,17 @@ test.run(arguments = 'bbb ccc=xyz -n aaa', stdout = expect) test.write('SConstruct', """ env = Environment() -print list(map(str, DEFAULT_TARGETS)) -print list(map(str, BUILD_TARGETS)) +print(list(map(str, DEFAULT_TARGETS))) +print(list(map(str, BUILD_TARGETS))) Default('aaa') -print list(map(str, DEFAULT_TARGETS)) -print list(map(str, BUILD_TARGETS)) +print(list(map(str, DEFAULT_TARGETS))) +print(list(map(str, BUILD_TARGETS))) env.Default('bbb') -print list(map(str, DEFAULT_TARGETS)) -print list(map(str, BUILD_TARGETS)) +print(list(map(str, DEFAULT_TARGETS))) +print(list(map(str, BUILD_TARGETS))) env.Default(None) -print list(map(str, DEFAULT_TARGETS)) -print list(map(str, BUILD_TARGETS)) +print(list(map(str, DEFAULT_TARGETS))) +print(list(map(str, BUILD_TARGETS))) env.Default('ccc') """) @@ -113,9 +113,9 @@ test.run(arguments = '.', stdout = expect) test.write('SConstruct', """\ -print list(map(str, BUILD_TARGETS)) +print(list(map(str, BUILD_TARGETS))) SConscript('SConscript') -print list(map(str, BUILD_TARGETS)) +print(list(map(str, BUILD_TARGETS))) """) test.write('SConscript', """\ diff --git a/test/Variables/BoolVariable.py b/test/Variables/BoolVariable.py index 365567e..d259984 100644 --- a/test/Variables/BoolVariable.py +++ b/test/Variables/BoolVariable.py @@ -57,8 +57,8 @@ opts.AddVariables( env = Environment(variables=opts) Help(opts.GenerateHelpText(env)) -print env['warnings'] -print env['profile'] +print(env['warnings']) +print(env['profile']) Default(env.Alias('dummy', None)) """) diff --git a/test/Variables/EnumVariable.py b/test/Variables/EnumVariable.py index c04b396..cf35b9b 100644 --- a/test/Variables/EnumVariable.py +++ b/test/Variables/EnumVariable.py @@ -66,9 +66,9 @@ opts.AddVariables( env = Environment(variables=opts) Help(opts.GenerateHelpText(env)) -print env['debug'] -print env['guilib'] -print env['some'] +print(env['debug']) +print(env['guilib']) +print(env['some']) Default(env.Alias('dummy', None)) """) diff --git a/test/Variables/PackageVariable.py b/test/Variables/PackageVariable.py index 322bc9b..b3fd10a 100644 --- a/test/Variables/PackageVariable.py +++ b/test/Variables/PackageVariable.py @@ -59,7 +59,7 @@ opts.AddVariables( env = Environment(variables=opts) Help(opts.GenerateHelpText(env)) -print env['x11'] +print(env['x11']) Default(env.Alias('dummy', None)) """) diff --git a/test/Variables/PathVariable.py b/test/Variables/PathVariable.py index bfe82ba..753aa11 100644 --- a/test/Variables/PathVariable.py +++ b/test/Variables/PathVariable.py @@ -64,9 +64,9 @@ opts.AddVariables( env = Environment(variables=opts) Help(opts.GenerateHelpText(env)) -print env['qtdir'] -print env['qt_libraries'] -print env.subst('$qt_libraries') +print(env['qtdir']) +print(env['qt_libraries']) +print(env.subst('$qt_libraries')) Default(env.Alias('dummy', None)) """ % (workpath, os.path.join('$qtdir', 'lib') )) @@ -132,7 +132,7 @@ opts.AddVariables( env = Environment(variables=opts) -print env['X'] +print(env['X']) Default(env.Alias('dummy', None)) """ % default_subdir) @@ -165,7 +165,7 @@ opts.AddVariables( env = Environment(variables=opts) -print env['X'] +print(env['X']) Default(env.Alias('dummy', None)) """ % default_file) @@ -211,7 +211,7 @@ opts.AddVariables( env = Environment(variables=opts) -print env['X'] +print(env['X']) Default(env.Alias('dummy', None)) """ % default_subdir) @@ -259,7 +259,7 @@ opts.AddVariables( env = Environment(variables=opts) -print env['X'] +print(env['X']) Default(env.Alias('dummy', None)) """ % default_subdir) diff --git a/test/Variables/Variables.py b/test/Variables/Variables.py index d0bf432..1c60635 100644 --- a/test/Variables/Variables.py +++ b/test/Variables/Variables.py @@ -30,8 +30,8 @@ test = TestSCons.TestSCons() test.write('SConstruct', """ env = Environment() -print env['CC'] -print " ".join(env['CCFLAGS']) +print(env['CC']) +print(" ".join(env['CCFLAGS'])) Default(env.Alias('dummy', None)) """) test.run() @@ -99,12 +99,12 @@ env = Environment(variables=opts, tools=['default', test_tool]) Help('Variables settable in custom.py or on the command line:\\n' + opts.GenerateHelpText(env)) -print env['RELEASE_BUILD'] -print env['DEBUG_BUILD'] -print env['CC'] -print " ".join(env['CCFLAGS']) -print env['VALIDATE'] -print env['valid_key'] +print(env['RELEASE_BUILD']) +print(env['DEBUG_BUILD']) +print(env['CC']) +print(" ".join(env['CCFLAGS'])) +print(env['VALIDATE']) +print(env['valid_key']) # unspecified variables should not be set: assert 'UNSPECIFIED' not in env @@ -220,8 +220,8 @@ opts.Add('UNSPECIFIED', env = Environment(variables = opts) -print env['RELEASE_BUILD'] -print env['DEBUG_BUILD'] +print(env['RELEASE_BUILD']) +print(env['DEBUG_BUILD']) opts.Save('variables.saved', env) """) @@ -276,9 +276,9 @@ opts.Add('LISTOPTION_TEST', env = Environment(variables = opts) -print env['RELEASE_BUILD'] -print env['DEBUG_BUILD'] -print env['LISTOPTION_TEST'] +print(env['RELEASE_BUILD']) +print(env['DEBUG_BUILD']) +print(env['LISTOPTION_TEST']) opts.Save('variables.saved', env) """) diff --git a/test/Variables/chdir.py b/test/Variables/chdir.py index 621e166..2d097d5 100644 --- a/test/Variables/chdir.py +++ b/test/Variables/chdir.py @@ -46,7 +46,7 @@ SConscript_contents = """\ Import("opts") env = Environment() opts.Update(env) -print "VARIABLE =", repr(env['VARIABLE']) +print("VARIABLE =", repr(env['VARIABLE'])) """ test.write(['bin', 'opts.cfg'], """\ diff --git a/test/Variables/help.py b/test/Variables/help.py index f04f962..bee6011 100644 --- a/test/Variables/help.py +++ b/test/Variables/help.py @@ -81,8 +81,8 @@ opts.AddVariables( env = Environment(variables=opts) Help(opts.GenerateHelpText(env)) -print env['warnings'] -print env['profile'] +print(env['warnings']) +print(env['profile']) Default(env.Alias('dummy', None)) """ % locals()) diff --git a/test/Variables/import.py b/test/Variables/import.py index 7cdd274..2da670a 100644 --- a/test/Variables/import.py +++ b/test/Variables/import.py @@ -48,7 +48,7 @@ SConscript_contents = """\ Import("opts") env = Environment() opts.Update(env) -print "VARIABLE =", env.get('VARIABLE') +print("VARIABLE =", env.get('VARIABLE')) """ test.write(['bin', 'opts.cfg'], """\ diff --git a/test/WhereIs.py b/test/WhereIs.py index 07c3f6c..c765848 100644 --- a/test/WhereIs.py +++ b/test/WhereIs.py @@ -67,14 +67,14 @@ pathdirs_1243 = [ test.workpath('sub1'), test.write('SConstruct', """ SConscript('%s') env = Environment() -print WhereIs('xxx.exe') -print WhereIs('xxx.exe', %s) -print env.WhereIs('xxx.exe', %s) -print WhereIs('xxx.exe', %s) -print WhereIs('xxx.exe', %s) -print WhereIs('xxx.exe', %s, reject=%s) +print(WhereIs('xxx.exe')) +print(WhereIs('xxx.exe', %s)) +print(env.WhereIs('xxx.exe', %s)) +print(WhereIs('xxx.exe', %s)) +print(WhereIs('xxx.exe', %s)) +print(WhereIs('xxx.exe', %s, reject=%s)) env.Replace( XXXNAME='xxx.exe' ) -print env.WhereIs( '$XXXNAME', %s ) +print(env.WhereIs( '$XXXNAME', %s )) """ % (subdir_SConscript, repr(os.pathsep.join(pathdirs_1234)), repr(os.pathsep.join(pathdirs_1243)), @@ -87,11 +87,11 @@ print env.WhereIs( '$XXXNAME', %s ) test.write(subdir_SConscript, """ env = Environment() -print WhereIs('xxx.exe') -print WhereIs('xxx.exe', %s) -print env.WhereIs('xxx.exe', %s) -print WhereIs('xxx.exe', %s) -print WhereIs('xxx.exe', %s) +print(WhereIs('xxx.exe')) +print(WhereIs('xxx.exe', %s)) +print(env.WhereIs('xxx.exe', %s)) +print(WhereIs('xxx.exe', %s)) +print(WhereIs('xxx.exe', %s)) """ % (repr(os.pathsep.join(pathdirs_1234)), repr(os.pathsep.join(pathdirs_1243)), repr(pathdirs_1234), diff --git a/test/_CPPINCFLAGS.py b/test/_CPPINCFLAGS.py index ccf5e79..c5096ba 100644 --- a/test/_CPPINCFLAGS.py +++ b/test/_CPPINCFLAGS.py @@ -39,9 +39,9 @@ env=Environment(CPPPATH=['tmp'], INCPREFIX='-I') d=Entry('foo.d') e=Entry('foo.e') f=File('foo.f') -print env.subst('$_CPPINCFLAGS', target=e, source=f) -print env.subst('$_CPPINCFLAGS', target=d, source=f) -print env.subst('$_CPPINCFLAGS', target=f, source=d) +print(env.subst('$_CPPINCFLAGS', target=e, source=f)) +print(env.subst('$_CPPINCFLAGS', target=d, source=f)) +print(env.subst('$_CPPINCFLAGS', target=f, source=d)) """) expect = """\ diff --git a/test/custom-concat.py b/test/custom-concat.py index 56c7f64..730e6cd 100644 --- a/test/custom-concat.py +++ b/test/custom-concat.py @@ -44,7 +44,7 @@ env1 = Environment(MYFLAGS=myflags, _concat = my_concat1, MYPREFIX='p', MYSUFFIX='s', STRIPPREFIX='xxx', STRIPSUFFIX='yyy', LIST=['a', 'xxxb', 'cyyy', 'd']) -print env1.subst('$MYFLAGS') +print(env1.subst('$MYFLAGS')) """) expect = test.wrap_stdout(read_str = "mypas1 mypbs1 mypcs1 mypds1\n", diff --git a/test/exitfns.py b/test/exitfns.py index f64969b..d1bda3a 100644 --- a/test/exitfns.py +++ b/test/exitfns.py @@ -32,11 +32,11 @@ sconstruct = """ from SCons.exitfuncs import * def x1(): - print "running x1" + print("running x1") def x2(n): - print "running x2(%s)" % repr(n) + print("running x2(%s)" % repr(n)) def x3(n, kwd=None): - print "running x3(%s, kwd=%s)" % (repr(n), repr(kwd)) + print("running x3(%s, kwd=%s)" % (repr(n), repr(kwd))) register(x3, "no kwd args") register(x1) diff --git a/test/import.py b/test/import.py index d1e1ecf..c23657a 100644 --- a/test/import.py +++ b/test/import.py @@ -21,7 +21,6 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -64,7 +63,7 @@ platforms = [ for platform in platforms: test.write('SConstruct', """ -print "Platform %(platform)s" +print("Platform %(platform)s") env = Environment(platform = '%(platform)s') import SCons.Platform.%(platform)s x = SCons.Platform.%(platform)s.generate @@ -151,7 +150,7 @@ error_output = { # An SConstruct for importing Tool names that have illegal characters # for Python variable names. indirect_import = """\ -print "Tool %(tool)s (indirect)" +print("Tool %(tool)s (indirect)") env = Environment(tools = ['%(tool)s']) SCons = __import__('SCons.Tool.%(tool)s', globals(), locals(), []) @@ -162,7 +161,7 @@ m.generate(env) # An SConstruct for importing Tool names "normally." direct_import = """\ -print "Tool %(tool)s (direct)" +print("Tool %(tool)s (direct)") env = Environment(tools = ['%(tool)s']) import SCons.Tool.%(tool)s diff --git a/test/no-arguments.py b/test/no-arguments.py index e447ff6..953d827 100644 --- a/test/no-arguments.py +++ b/test/no-arguments.py @@ -40,7 +40,7 @@ test.write('SConstruct', r""" def cat(env, source, target): target = str(target[0]) source = list(map(str, source)) - print 'cat(%s) > %s' % (source, target) + print('cat(%s) > %s' % (source, target)) f = open(target, "wb") for src in source: f.write(open(src, "rb").read()) diff --git a/test/option--C.py b/test/option--C.py index 27f4950..1df3c1a 100644 --- a/test/option--C.py +++ b/test/option--C.py @@ -51,18 +51,18 @@ test.subdir('sub', ['sub', 'dir']) test.write('SConstruct', """ import os -print "SConstruct", os.getcwd() +print("SConstruct", os.getcwd()) """) test.write(['sub', 'SConstruct'], """ import os -print GetBuildPath('..') +print(GetBuildPath('..')) """) test.write(['sub', 'dir', 'SConstruct'], """ import os env = Environment(FOO='foo', BAR='bar') -print env.GetBuildPath('../$FOO/$BAR') +print(env.GetBuildPath('../$FOO/$BAR')) """) test.run(arguments = '-C sub .', diff --git a/test/option--I.py b/test/option--I.py index d65349a..0ca262d 100644 --- a/test/option--I.py +++ b/test/option--I.py @@ -44,9 +44,9 @@ variable = "sub2/bar" test.write('SConstruct', """ import foo -print foo.variable +print(foo.variable) import bar -print bar.variable +print(bar.variable) """) test.run(arguments = '-I sub1 -I sub2 .', diff --git a/test/option-f.py b/test/option-f.py index 2a238d3..9fd1a57 100644 --- a/test/option-f.py +++ b/test/option-f.py @@ -36,17 +36,17 @@ subdir_BuildThis = os.path.join('subdir', 'Buildthis') test.write('SConscript', """ import os -print "SConscript " + os.getcwd() +print("SConscript " + os.getcwd()) """) test.write(subdir_BuildThis, """ import os -print "subdir/BuildThis", os.getcwd() +print("subdir/BuildThis", os.getcwd()) """) test.write('Build2', """ import os -print "Build2", os.getcwd() +print("Build2", os.getcwd()) """) wpath = test.workpath() @@ -85,7 +85,7 @@ test.run(arguments = '--sconstruct=%s .' % subdir_BuildThis, test.run(arguments = '-f - .', stdin = """ import os -print "STDIN " + os.getcwd() +print("STDIN " + os.getcwd()) """, stdout = test.wrap_stdout(read_str = 'STDIN %s\n' % wpath, build_str = "scons: `.' is up to date.\n")) diff --git a/test/overrides.py b/test/overrides.py index d706ab7..69d5207 100644 --- a/test/overrides.py +++ b/test/overrides.py @@ -35,9 +35,9 @@ _python_ = TestSCons._python_ test.write('SConstruct', """ env = Environment(CCFLAGS='-DFOO', LIBS=['a']) def build(target, source, env): - print "env['CC'] =", env['CC'] - print "env['CCFLAGS'] =", env['CCFLAGS'] - print "env['LIBS'] =", env['LIBS'] + print("env['CC'] =", env['CC']) + print("env['CCFLAGS'] =", env['CCFLAGS']) + print("env['LIBS'] =", env['LIBS']) builder = Builder(action=build, CC='buildcc', LIBS='buildlibs') env['BUILDERS']['Build'] = builder diff --git a/test/preserve-source.py b/test/preserve-source.py index 6e09073..b7eccd1 100644 --- a/test/preserve-source.py +++ b/test/preserve-source.py @@ -35,7 +35,7 @@ test.write('SConstruct', r""" def cat(env, source, target): target = str(target[0]) source = list(map(str, source)) - print 'cat(%s) > %s' % (source, target) + print('cat(%s) > %s' % (source, target)) f = open(target, "wb") for src in source: f.write(open(src, "rb").read()) diff --git a/test/site_scons/basic.py b/test/site_scons/basic.py index 1868723..b3ae9f2 100644 --- a/test/site_scons/basic.py +++ b/test/site_scons/basic.py @@ -40,7 +40,7 @@ test.subdir('site_scons', ['site_scons', 'site_tools']) test.write(['site_scons', 'site_init.py'], """ from SCons.Script import * -print "Hi there, I am in site_scons/site_init.py!" +print("Hi there, I am in site_scons/site_init.py!") """) test.write(['site_scons', 'site_tools', 'mytool.py'], """ @@ -54,7 +54,7 @@ def exists(env): test.write('SConstruct', """ e=Environment(tools=['default', 'mytool']) -print e.subst('My site tool is $MYTOOL') +print(e.subst('My site tool is $MYTOOL')) """) test.run(arguments = '-Q .', diff --git a/test/site_scons/no-site-dir.py b/test/site_scons/no-site-dir.py index d01d419..c31ec94 100644 --- a/test/site_scons/no-site-dir.py +++ b/test/site_scons/no-site-dir.py @@ -37,7 +37,7 @@ test.subdir('site_scons', ['site_scons', 'site_tools']) test.write(['site_scons', 'site_init.py'], """ from SCons.Script import * -print "Hi there, I am in site_scons/site_init.py!" +print("Hi there, I am in site_scons/site_init.py!") """) test.write(['site_scons', 'site_tools', 'mytool.py'], """ @@ -68,7 +68,7 @@ test.run(arguments = '-Q --no-site-dir .', test.write('SConstruct', """ e=Environment() -print e.subst('no site: M4 is $M4, M4_MINE is $M4_MINE') +print(e.subst('no site: M4 is $M4, M4_MINE is $M4_MINE')) """) test.run(arguments = '-Q --no-site-dir .') diff --git a/test/site_scons/override.py b/test/site_scons/override.py index e33bb88..d65c09e 100644 --- a/test/site_scons/override.py +++ b/test/site_scons/override.py @@ -49,7 +49,7 @@ def exists(env): test.write('SConstruct', """ e=Environment(tools=['m4']) -print e.subst('M4 is $M4, M4_MINE is $M4_MINE') +print(e.subst('M4 is $M4, M4_MINE is $M4_MINE')) """) test.run(arguments = '-Q .', stdout = """M4 is my_m4, M4_MINE is 1 diff --git a/test/site_scons/site-dir.py b/test/site_scons/site-dir.py index 8e82e94..d60e7d9 100644 --- a/test/site_scons/site-dir.py +++ b/test/site_scons/site-dir.py @@ -38,7 +38,7 @@ test.subdir('site_scons', ['site_scons', 'site_tools']) test.write(['site_scons', 'site_init.py'], """ from SCons.Script import * -print "Hi there, I am in site_scons/site_init.py!" +print("Hi there, I am in site_scons/site_init.py!") """) test.write(['site_scons', 'site_tools', 'mytool.py'], """ @@ -55,7 +55,7 @@ test.subdir('alt_site', ['alt_site', 'site_tools']) test.write(['alt_site', 'site_init.py'], """ from SCons.Script import * -print "Hi there, I am in alt_site/site_init.py!" +print("Hi there, I am in alt_site/site_init.py!") """) test.write('SConstruct', """ diff --git a/test/site_scons/site_init.py b/test/site_scons/site_init.py index 45201ac..27768a9 100644 --- a/test/site_scons/site_init.py +++ b/test/site_scons/site_init.py @@ -58,10 +58,10 @@ for x in list(globals().keys()): continue special.append(x) -print sorted(special) -print __doc__ -print os.path.realpath(__file__) -print __name__ +print(sorted(special)) +print(__doc__) +print(os.path.realpath(__file__)) +print(__name__) """) test.write('SConstruct', "\n") -- cgit v0.12 From 664c1a40e20c38842a7dc8097ba32638c8925dde Mon Sep 17 00:00:00 2001 From: Russel Winder Date: Mon, 25 Jan 2016 07:46:43 +0000 Subject: Add a Shippable build file. --- shippable.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 shippable.yml diff --git a/shippable.yml b/shippable.yml new file mode 100644 index 0000000..b7e363a --- /dev/null +++ b/shippable.yml @@ -0,0 +1,7 @@ +language: python + +python: + - "2.7" + - "3.4" + +script: python runtest.py -a -- cgit v0.12 From 531b6617dcb0bfae3335eead483459651b4a47a0 Mon Sep 17 00:00:00 2001 From: Russel Winder Date: Mon, 25 Jan 2016 08:16:47 +0000 Subject: Add a dummy file to trigger a Codeship build. --- dummy.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 dummy.txt diff --git a/dummy.txt b/dummy.txt new file mode 100644 index 0000000..e69de29 -- cgit v0.12 From 6a42327dfce9dba97ad9643b519e5c93907a45be Mon Sep 17 00:00:00 2001 From: Russel Winder Date: Mon, 25 Jan 2016 09:06:57 +0000 Subject: Remove dummy file. --- dummy.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 dummy.txt diff --git a/dummy.txt b/dummy.txt deleted file mode 100644 index e69de29..0000000 -- cgit v0.12 From 193c96046004369ba13fb9b4fc0e992513cc8f78 Mon Sep 17 00:00:00 2001 From: Russel Winder Date: Tue, 2 Feb 2016 17:56:18 +0000 Subject: Remove all the six stuff. --- QMTest/TestCmd.py | 4 - QMTest/TestCmdTests.py | 12 +- bin/install_scons.py | 8 +- src/engine/SCons/MemoizeTests.py | 1 - src/engine/SCons/Tool/xgettext.py | 6 +- src/engine/SCons/Util.py | 24 +- src/engine/SCons/UtilTests.py | 1 - src/engine/SCons/compat/six.py | 646 ------------------------------------ src/engine/SCons/compat/sixTests.py | 35 -- src/script/sconsign.py | 10 +- 10 files changed, 17 insertions(+), 730 deletions(-) delete mode 100755 src/engine/SCons/compat/six.py delete mode 100644 src/engine/SCons/compat/sixTests.py diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index d645731..f8c4e69 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -287,8 +287,6 @@ version. # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. from __future__ import division, print_function -from SCons.compat.six import PY3 - __author__ = "Steven Knight " __revision__ = "TestCmd.py 1.3.D001 2010/06/03 12:58:27 knight" __version__ = "1.3" @@ -1730,8 +1728,6 @@ class TestCmd(object): exist. The I/O mode for the file may be specified; it must begin with a 'w'. The default is 'wb' (binary write). """ - if PY3: - content = re.sub(r'print (.+)', r'print(\1)', content) file = self.canonicalize(file) if mode[0] != 'w': raise ValueError("mode must begin with 'w'") diff --git a/QMTest/TestCmdTests.py b/QMTest/TestCmdTests.py index a2e7022..cd62d9f 100644 --- a/QMTest/TestCmdTests.py +++ b/QMTest/TestCmdTests.py @@ -19,8 +19,6 @@ AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. """ -from SCons.compat.six import PY3 - __author__ = "Steven Knight " __revision__ = "TestCmdTests.py 1.3.D001 2010/06/03 12:58:27 knight" @@ -28,19 +26,13 @@ import os import shutil import signal import stat -if PY3: - from io import StringIO -else: - from StringIO import StringIO +from StringIO import StringIO import sys import tempfile import time import types import unittest -if PY3: - from collections import UserList -else: - from UserList import UserList +from UserList import UserList # Strip the current directory so we get the right TestCmd.py module. diff --git a/bin/install_scons.py b/bin/install_scons.py index 55e327d..ac79fd3 100644 --- a/bin/install_scons.py +++ b/bin/install_scons.py @@ -17,19 +17,15 @@ # This was written for a Linux system (specifically Ubuntu) but should # be reasonably generic to any POSIX-style system with a /usr/local # hierarchy. -from __future__ import print_function -from SCons.compat.six import PY3 +from __future__ import print_function import getopt import os import shutil import sys import tarfile -if PY3: - from urllib.request import urlretrieve -else: - from urllib import urlretrieve +from urllib import urlretrieve from Command import CommandRunner, Usage diff --git a/src/engine/SCons/MemoizeTests.py b/src/engine/SCons/MemoizeTests.py index ba866d2..3ce9a11 100644 --- a/src/engine/SCons/MemoizeTests.py +++ b/src/engine/SCons/MemoizeTests.py @@ -20,7 +20,6 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -from SCons.compat.six import add_metaclass __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/src/engine/SCons/Tool/xgettext.py b/src/engine/SCons/Tool/xgettext.py index ff45989..e9b49b7 100644 --- a/src/engine/SCons/Tool/xgettext.py +++ b/src/engine/SCons/Tool/xgettext.py @@ -23,7 +23,6 @@ Tool specific initialization of `xgettext` tool. # 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. -from SCons.compat.six import u __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -33,7 +32,7 @@ class _CmdRunner(object): variables. It also provides `strfunction()` method, which shall be used by scons Action objects to print command string. """ - def __init__( self, command, commandstr = None): + def __init__(self, command, commandstr = None): self.out = None self.err = None self.status = None @@ -56,7 +55,8 @@ class _CmdRunner(object): proc = SCons.Action._subproc(env, command, **kw) self.out, self.err = proc.communicate() self.status = proc.wait() - if self.err: sys.stderr.write(u(self.err)) + if self.err: + sys.stderr.write(unicode(self.err)) return self.status def strfunction(self, target, source, env): diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index a66f92a..5b11f83 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -23,7 +23,6 @@ Various utility functions go here. # 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. -from SCons.compat.six import PY2, PY3, u __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -33,16 +32,13 @@ import copy import re import types -if PY3: - from collections import UserDict, UserList, UserString -else: - from UserDict import UserDict - from UserList import UserList - from UserString import UserString +from UserDict import UserDict +from UserList import UserList +from UserString import UserString # Don't "from types import ..." these because we need to get at the # types module later to look for UnicodeType. -InstanceType = types.InstanceType if PY2 else None +InstanceType = types.InstanceType MethodType = types.MethodType FunctionType = types.FunctionType try: unicode @@ -162,7 +158,7 @@ class DisplayEngine(object): return if append_newline: text = text + '\n' try: - sys.stdout.write(u(text)) + sys.stdout.write(unicode(text)) except IOError: # Stdout might be connected to a pipe that has been closed # by now. The most likely reason for the pipe being closed @@ -256,7 +252,7 @@ def print_tree(root, child_func, prune=0, showtags=0, margin=[0], visited=None): ' N = no clean\n' + ' H = no cache\n' + '\n') - sys.stdout.write(u(legend)) + sys.stdout.write(unicode(legend)) tags = ['['] tags.append(' E'[IDX(root.exists())]) @@ -1413,15 +1409,11 @@ def AddMethod(obj, function, name=None): if hasattr(obj, '__class__') and obj.__class__ is not type: # "obj" is an instance, so it gets a bound method. - if PY3: - method = MethodType(function, obj) - else: - method = MethodType(function, obj, obj.__class__) + method = MethodType(function, obj, obj.__class__) setattr(obj, name, method) else: # "obj" is a class, so it gets an unbound method. - if PY2: - function = MethodType(function, None, obj) + function = MethodType(function, None, obj) setattr(obj, name, function) def RenameFunction(function, name): diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py index 1e56dc0..9ebb924 100644 --- a/src/engine/SCons/UtilTests.py +++ b/src/engine/SCons/UtilTests.py @@ -20,7 +20,6 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -from SCons.compat.six import u __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/src/engine/SCons/compat/six.py b/src/engine/SCons/compat/six.py deleted file mode 100755 index 0e8850c..0000000 --- a/src/engine/SCons/compat/six.py +++ /dev/null @@ -1,646 +0,0 @@ -"""Utilities for writing code that runs on Python 2 and 3""" - -# Copyright (c) 2010-2014 Benjamin Peterson -# -# 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. - -import operator -import sys -import types - -__author__ = "Benjamin Peterson " -__version__ = "1.6.1" - - -# Useful for very coarse version differentiation. -PY2 = sys.version_info[0] == 2 -PY3 = sys.version_info[0] == 3 - -if PY3: - string_types = str, - integer_types = int, - class_types = type, - text_type = str - binary_type = bytes - - MAXSIZE = sys.maxsize -else: - string_types = basestring, - integer_types = (int, long) - class_types = (type, type) - text_type = unicode - binary_type = str - - if sys.platform.startswith("java"): - # Jython always uses 32 bits. - MAXSIZE = int((1 << 31) - 1) - else: - # It's possible to have sizeof(long) != sizeof(Py_ssize_t). - class X(object): - def __len__(self): - return 1 << 31 - try: - len(X()) - except OverflowError: - # 32-bit - MAXSIZE = int((1 << 31) - 1) - else: - # 64-bit - MAXSIZE = int((1 << 63) - 1) - del X - - -def _add_doc(func, doc): - """Add documentation to a function.""" - func.__doc__ = doc - - -def _import_module(name): - """Import module, returning the module after the last dot.""" - __import__(name) - return sys.modules[name] - - -class _LazyDescr(object): - - def __init__(self, name): - self.name = name - - def __get__(self, obj, tp): - try: - result = self._resolve() - except ImportError: - # See the nice big comment in MovedModule.__getattr__. - raise AttributeError("%s could not be imported " % self.name) - setattr(obj, self.name, result) # Invokes __set__. - # This is a bit ugly, but it avoids running this again. - delattr(obj.__class__, self.name) - return result - - -class MovedModule(_LazyDescr): - - def __init__(self, name, old, new=None): - super(MovedModule, self).__init__(name) - if PY3: - if new is None: - new = name - self.mod = new - else: - self.mod = old - - def _resolve(self): - return _import_module(self.mod) - - def __getattr__(self, attr): - # It turns out many Python frameworks like to traverse sys.modules and - # try to load various attributes. This causes problems if this is a - # platform-specific module on the wrong platform, like _winreg on - # Unixes. Therefore, we silently pretend unimportable modules do not - # have any attributes. See issues #51, #53, #56, and #63 for the full - # tales of woe. - # - # First, if possible, avoid loading the module just to look at __file__, - # __name__, or __path__. - if (attr in ("__file__", "__name__", "__path__") and - self.mod not in sys.modules): - raise AttributeError(attr) - try: - _module = self._resolve() - except ImportError: - raise AttributeError(attr) - value = getattr(_module, attr) - setattr(self, attr, value) - return value - - -class _LazyModule(types.ModuleType): - - def __init__(self, name): - super(_LazyModule, self).__init__(name) - self.__doc__ = self.__class__.__doc__ - - def __dir__(self): - attrs = ["__doc__", "__name__"] - attrs += [attr.name for attr in self._moved_attributes] - return attrs - - # Subclasses should override this - _moved_attributes = [] - - -class MovedAttribute(_LazyDescr): - - def __init__(self, name, old_mod, new_mod, old_attr=None, new_attr=None): - super(MovedAttribute, self).__init__(name) - if PY3: - if new_mod is None: - new_mod = name - self.mod = new_mod - if new_attr is None: - if old_attr is None: - new_attr = name - else: - new_attr = old_attr - self.attr = new_attr - else: - self.mod = old_mod - if old_attr is None: - old_attr = name - self.attr = old_attr - - def _resolve(self): - module = _import_module(self.mod) - return getattr(module, self.attr) - - - -class _MovedItems(_LazyModule): - """Lazy loading of moved objects""" - - -_moved_attributes = [ - MovedAttribute("cStringIO", "cStringIO", "io", "StringIO"), - MovedAttribute("filter", "itertools", "builtins", "ifilter", "filter"), - MovedAttribute("filterfalse", "itertools", "itertools", "ifilterfalse", "filterfalse"), - MovedAttribute("input", "__builtin__", "builtins", "raw_input", "input"), - MovedAttribute("map", "itertools", "builtins", "imap", "map"), - MovedAttribute("range", "__builtin__", "builtins", "xrange", "range"), - MovedAttribute("reload_module", "__builtin__", "imp", "reload"), - MovedAttribute("reduce", "__builtin__", "functools"), - MovedAttribute("StringIO", "StringIO", "io"), - MovedAttribute("UserString", "UserString", "collections"), - MovedAttribute("xrange", "__builtin__", "builtins", "xrange", "range"), - MovedAttribute("zip", "itertools", "builtins", "izip", "zip"), - MovedAttribute("zip_longest", "itertools", "itertools", "izip_longest", "zip_longest"), - - MovedModule("builtins", "__builtin__"), - MovedModule("configparser", "ConfigParser"), - MovedModule("copyreg", "copy_reg"), - MovedModule("dbm_gnu", "gdbm", "dbm.gnu"), - MovedModule("http_cookiejar", "cookielib", "http.cookiejar"), - MovedModule("http_cookies", "Cookie", "http.cookies"), - MovedModule("html_entities", "htmlentitydefs", "html.entities"), - MovedModule("html_parser", "HTMLParser", "html.parser"), - MovedModule("http_client", "httplib", "http.client"), - MovedModule("email_mime_multipart", "email.MIMEMultipart", "email.mime.multipart"), - MovedModule("email_mime_text", "email.MIMEText", "email.mime.text"), - MovedModule("email_mime_base", "email.MIMEBase", "email.mime.base"), - MovedModule("BaseHTTPServer", "BaseHTTPServer", "http.server"), - MovedModule("CGIHTTPServer", "CGIHTTPServer", "http.server"), - MovedModule("SimpleHTTPServer", "SimpleHTTPServer", "http.server"), - MovedModule("cPickle", "cPickle", "pickle"), - MovedModule("queue", "Queue"), - MovedModule("reprlib", "repr"), - MovedModule("socketserver", "SocketServer"), - MovedModule("_thread", "thread", "_thread"), - MovedModule("tkinter", "Tkinter"), - MovedModule("tkinter_dialog", "Dialog", "tkinter.dialog"), - MovedModule("tkinter_filedialog", "FileDialog", "tkinter.filedialog"), - MovedModule("tkinter_scrolledtext", "ScrolledText", "tkinter.scrolledtext"), - MovedModule("tkinter_simpledialog", "SimpleDialog", "tkinter.simpledialog"), - MovedModule("tkinter_tix", "Tix", "tkinter.tix"), - MovedModule("tkinter_ttk", "ttk", "tkinter.ttk"), - MovedModule("tkinter_constants", "Tkconstants", "tkinter.constants"), - MovedModule("tkinter_dnd", "Tkdnd", "tkinter.dnd"), - MovedModule("tkinter_colorchooser", "tkColorChooser", - "tkinter.colorchooser"), - MovedModule("tkinter_commondialog", "tkCommonDialog", - "tkinter.commondialog"), - MovedModule("tkinter_tkfiledialog", "tkFileDialog", "tkinter.filedialog"), - MovedModule("tkinter_font", "tkFont", "tkinter.font"), - MovedModule("tkinter_messagebox", "tkMessageBox", "tkinter.messagebox"), - MovedModule("tkinter_tksimpledialog", "tkSimpleDialog", - "tkinter.simpledialog"), - MovedModule("urllib_parse", __name__ + ".moves.urllib_parse", "urllib.parse"), - MovedModule("urllib_error", __name__ + ".moves.urllib_error", "urllib.error"), - MovedModule("urllib", __name__ + ".moves.urllib", __name__ + ".moves.urllib"), - MovedModule("urllib_robotparser", "robotparser", "urllib.robotparser"), - MovedModule("xmlrpc_client", "xmlrpclib", "xmlrpc.client"), - MovedModule("xmlrpc_server", "xmlrpclib", "xmlrpc.server"), - MovedModule("winreg", "_winreg"), -] -for attr in _moved_attributes: - setattr(_MovedItems, attr.name, attr) - if isinstance(attr, MovedModule): - sys.modules[__name__ + ".moves." + attr.name] = attr -del attr - -_MovedItems._moved_attributes = _moved_attributes - -moves = sys.modules[__name__ + ".moves"] = _MovedItems(__name__ + ".moves") - - -class Module_six_moves_urllib_parse(_LazyModule): - """Lazy loading of moved objects in six.moves.urllib_parse""" - - -_urllib_parse_moved_attributes = [ - MovedAttribute("ParseResult", "urlparse", "urllib.parse"), - MovedAttribute("SplitResult", "urlparse", "urllib.parse"), - MovedAttribute("parse_qs", "urlparse", "urllib.parse"), - MovedAttribute("parse_qsl", "urlparse", "urllib.parse"), - MovedAttribute("urldefrag", "urlparse", "urllib.parse"), - MovedAttribute("urljoin", "urlparse", "urllib.parse"), - MovedAttribute("urlparse", "urlparse", "urllib.parse"), - MovedAttribute("urlsplit", "urlparse", "urllib.parse"), - MovedAttribute("urlunparse", "urlparse", "urllib.parse"), - MovedAttribute("urlunsplit", "urlparse", "urllib.parse"), - MovedAttribute("quote", "urllib", "urllib.parse"), - MovedAttribute("quote_plus", "urllib", "urllib.parse"), - MovedAttribute("unquote", "urllib", "urllib.parse"), - MovedAttribute("unquote_plus", "urllib", "urllib.parse"), - MovedAttribute("urlencode", "urllib", "urllib.parse"), - MovedAttribute("splitquery", "urllib", "urllib.parse"), -] -for attr in _urllib_parse_moved_attributes: - setattr(Module_six_moves_urllib_parse, attr.name, attr) -del attr - -Module_six_moves_urllib_parse._moved_attributes = _urllib_parse_moved_attributes - -sys.modules[__name__ + ".moves.urllib_parse"] = sys.modules[__name__ + ".moves.urllib.parse"] = Module_six_moves_urllib_parse(__name__ + ".moves.urllib_parse") - - -class Module_six_moves_urllib_error(_LazyModule): - """Lazy loading of moved objects in six.moves.urllib_error""" - - -_urllib_error_moved_attributes = [ - MovedAttribute("URLError", "urllib2", "urllib.error"), - MovedAttribute("HTTPError", "urllib2", "urllib.error"), - MovedAttribute("ContentTooShortError", "urllib", "urllib.error"), -] -for attr in _urllib_error_moved_attributes: - setattr(Module_six_moves_urllib_error, attr.name, attr) -del attr - -Module_six_moves_urllib_error._moved_attributes = _urllib_error_moved_attributes - -sys.modules[__name__ + ".moves.urllib_error"] = sys.modules[__name__ + ".moves.urllib.error"] = Module_six_moves_urllib_error(__name__ + ".moves.urllib.error") - - -class Module_six_moves_urllib_request(_LazyModule): - """Lazy loading of moved objects in six.moves.urllib_request""" - - -_urllib_request_moved_attributes = [ - MovedAttribute("urlopen", "urllib2", "urllib.request"), - MovedAttribute("install_opener", "urllib2", "urllib.request"), - MovedAttribute("build_opener", "urllib2", "urllib.request"), - MovedAttribute("pathname2url", "urllib", "urllib.request"), - MovedAttribute("url2pathname", "urllib", "urllib.request"), - MovedAttribute("getproxies", "urllib", "urllib.request"), - MovedAttribute("Request", "urllib2", "urllib.request"), - MovedAttribute("OpenerDirector", "urllib2", "urllib.request"), - MovedAttribute("HTTPDefaultErrorHandler", "urllib2", "urllib.request"), - MovedAttribute("HTTPRedirectHandler", "urllib2", "urllib.request"), - MovedAttribute("HTTPCookieProcessor", "urllib2", "urllib.request"), - MovedAttribute("ProxyHandler", "urllib2", "urllib.request"), - MovedAttribute("BaseHandler", "urllib2", "urllib.request"), - MovedAttribute("HTTPPasswordMgr", "urllib2", "urllib.request"), - MovedAttribute("HTTPPasswordMgrWithDefaultRealm", "urllib2", "urllib.request"), - MovedAttribute("AbstractBasicAuthHandler", "urllib2", "urllib.request"), - MovedAttribute("HTTPBasicAuthHandler", "urllib2", "urllib.request"), - MovedAttribute("ProxyBasicAuthHandler", "urllib2", "urllib.request"), - MovedAttribute("AbstractDigestAuthHandler", "urllib2", "urllib.request"), - MovedAttribute("HTTPDigestAuthHandler", "urllib2", "urllib.request"), - MovedAttribute("ProxyDigestAuthHandler", "urllib2", "urllib.request"), - MovedAttribute("HTTPHandler", "urllib2", "urllib.request"), - MovedAttribute("HTTPSHandler", "urllib2", "urllib.request"), - MovedAttribute("FileHandler", "urllib2", "urllib.request"), - MovedAttribute("FTPHandler", "urllib2", "urllib.request"), - MovedAttribute("CacheFTPHandler", "urllib2", "urllib.request"), - MovedAttribute("UnknownHandler", "urllib2", "urllib.request"), - MovedAttribute("HTTPErrorProcessor", "urllib2", "urllib.request"), - MovedAttribute("urlretrieve", "urllib", "urllib.request"), - MovedAttribute("urlcleanup", "urllib", "urllib.request"), - MovedAttribute("URLopener", "urllib", "urllib.request"), - MovedAttribute("FancyURLopener", "urllib", "urllib.request"), - MovedAttribute("proxy_bypass", "urllib", "urllib.request"), -] -for attr in _urllib_request_moved_attributes: - setattr(Module_six_moves_urllib_request, attr.name, attr) -del attr - -Module_six_moves_urllib_request._moved_attributes = _urllib_request_moved_attributes - -sys.modules[__name__ + ".moves.urllib_request"] = sys.modules[__name__ + ".moves.urllib.request"] = Module_six_moves_urllib_request(__name__ + ".moves.urllib.request") - - -class Module_six_moves_urllib_response(_LazyModule): - """Lazy loading of moved objects in six.moves.urllib_response""" - - -_urllib_response_moved_attributes = [ - MovedAttribute("addbase", "urllib", "urllib.response"), - MovedAttribute("addclosehook", "urllib", "urllib.response"), - MovedAttribute("addinfo", "urllib", "urllib.response"), - MovedAttribute("addinfourl", "urllib", "urllib.response"), -] -for attr in _urllib_response_moved_attributes: - setattr(Module_six_moves_urllib_response, attr.name, attr) -del attr - -Module_six_moves_urllib_response._moved_attributes = _urllib_response_moved_attributes - -sys.modules[__name__ + ".moves.urllib_response"] = sys.modules[__name__ + ".moves.urllib.response"] = Module_six_moves_urllib_response(__name__ + ".moves.urllib.response") - - -class Module_six_moves_urllib_robotparser(_LazyModule): - """Lazy loading of moved objects in six.moves.urllib_robotparser""" - - -_urllib_robotparser_moved_attributes = [ - MovedAttribute("RobotFileParser", "robotparser", "urllib.robotparser"), -] -for attr in _urllib_robotparser_moved_attributes: - setattr(Module_six_moves_urllib_robotparser, attr.name, attr) -del attr - -Module_six_moves_urllib_robotparser._moved_attributes = _urllib_robotparser_moved_attributes - -sys.modules[__name__ + ".moves.urllib_robotparser"] = sys.modules[__name__ + ".moves.urllib.robotparser"] = Module_six_moves_urllib_robotparser(__name__ + ".moves.urllib.robotparser") - - -class Module_six_moves_urllib(types.ModuleType): - """Create a six.moves.urllib namespace that resembles the Python 3 namespace""" - parse = sys.modules[__name__ + ".moves.urllib_parse"] - error = sys.modules[__name__ + ".moves.urllib_error"] - request = sys.modules[__name__ + ".moves.urllib_request"] - response = sys.modules[__name__ + ".moves.urllib_response"] - robotparser = sys.modules[__name__ + ".moves.urllib_robotparser"] - - def __dir__(self): - return ['parse', 'error', 'request', 'response', 'robotparser'] - - -sys.modules[__name__ + ".moves.urllib"] = Module_six_moves_urllib(__name__ + ".moves.urllib") - - -def add_move(move): - """Add an item to six.moves.""" - setattr(_MovedItems, move.name, move) - - -def remove_move(name): - """Remove item from six.moves.""" - try: - delattr(_MovedItems, name) - except AttributeError: - try: - del moves.__dict__[name] - except KeyError: - raise AttributeError("no such move, %r" % (name,)) - - -if PY3: - _meth_func = "__func__" - _meth_self = "__self__" - - _func_closure = "__closure__" - _func_code = "__code__" - _func_defaults = "__defaults__" - _func_globals = "__globals__" - - _iterkeys = "keys" - _itervalues = "values" - _iteritems = "items" - _iterlists = "lists" -else: - _meth_func = "im_func" - _meth_self = "im_self" - - _func_closure = "func_closure" - _func_code = "func_code" - _func_defaults = "func_defaults" - _func_globals = "func_globals" - - _iterkeys = "iterkeys" - _itervalues = "itervalues" - _iteritems = "iteritems" - _iterlists = "iterlists" - - -try: - advance_iterator = next -except NameError: - def advance_iterator(it): - return it.next() -next = advance_iterator - - -try: - callable = callable -except NameError: - def callable(obj): - return any("__call__" in klass.__dict__ for klass in type(obj).__mro__) - - -if PY3: - def get_unbound_function(unbound): - return unbound - - create_bound_method = types.MethodType - - Iterator = object -else: - def get_unbound_function(unbound): - return unbound.__func__ - - def create_bound_method(func, obj): - return types.MethodType(func, obj, obj.__class__) - - class Iterator(object): - - def next(self): - return type(self).__next__(self) - - callable = callable -_add_doc(get_unbound_function, - """Get the function out of a possibly unbound function""") - - -get_method_function = operator.attrgetter(_meth_func) -get_method_self = operator.attrgetter(_meth_self) -get_function_closure = operator.attrgetter(_func_closure) -get_function_code = operator.attrgetter(_func_code) -get_function_defaults = operator.attrgetter(_func_defaults) -get_function_globals = operator.attrgetter(_func_globals) - - -def iterkeys(d, **kw): - """Return an iterator over the keys of a dictionary.""" - return iter(getattr(d, _iterkeys)(**kw)) - -def itervalues(d, **kw): - """Return an iterator over the values of a dictionary.""" - return iter(getattr(d, _itervalues)(**kw)) - -def iteritems(d, **kw): - """Return an iterator over the (key, value) pairs of a dictionary.""" - return iter(getattr(d, _iteritems)(**kw)) - -def iterlists(d, **kw): - """Return an iterator over the (key, [values]) pairs of a dictionary.""" - return iter(getattr(d, _iterlists)(**kw)) - - -if PY3: - def b(s): - return s.encode("latin-1") - def u(s): - return s - unichr = chr - if sys.version_info[1] <= 1: - def int2byte(i): - return bytes((i,)) - else: - # This is about 2x faster than the implementation above on 3.2+ - int2byte = operator.methodcaller("to_bytes", 1, "big") - byte2int = operator.itemgetter(0) - indexbytes = operator.getitem - iterbytes = iter - import io - StringIO = io.StringIO - BytesIO = io.BytesIO -else: - def b(s): - return s - # Workaround for standalone backslash - def u(s): - return unicode(s.replace(r'\\', r'\\\\'), "unicode_escape") - unichr = unichr - int2byte = chr - def byte2int(bs): - return ord(bs[0]) - def indexbytes(buf, i): - return ord(buf[i]) - def iterbytes(buf): - return (ord(byte) for byte in buf) - import StringIO - StringIO = BytesIO = StringIO.StringIO -_add_doc(b, """Byte literal""") -_add_doc(u, """Text literal""") - - -if PY3: - exec_ = getattr(moves.builtins, "exec") - - - def reraise(tp, value, tb=None): - if value.__traceback__ is not tb: - raise value.with_traceback(tb) - raise value - -else: - def exec_(_code_, _globs_=None, _locs_=None): - """Execute code in a namespace.""" - if _globs_ is None: - frame = sys._getframe(1) - _globs_ = frame.f_globals - if _locs_ is None: - _locs_ = frame.f_locals - del frame - elif _locs_ is None: - _locs_ = _globs_ - exec("""exec _code_ in _globs_, _locs_""") - - - exec_("""def reraise(tp, value, tb=None): - raise tp, value, tb -""") - - -print_ = getattr(moves.builtins, "print", None) -if print_ is None: - def print_(*args, **kwargs): - """The new-style print function for Python 2.4 and 2.5.""" - fp = kwargs.pop("file", sys.stdout) - if fp is None: - return - def write(data): - if not isinstance(data, basestring): - data = str(data) - # If the file has an encoding, encode unicode with it. - if (isinstance(fp, file) and - isinstance(data, unicode) and - fp.encoding is not None): - errors = getattr(fp, "errors", None) - if errors is None: - errors = "strict" - data = data.encode(fp.encoding, errors) - fp.write(data) - want_unicode = False - sep = kwargs.pop("sep", None) - if sep is not None: - if isinstance(sep, unicode): - want_unicode = True - elif not isinstance(sep, str): - raise TypeError("sep must be None or a string") - end = kwargs.pop("end", None) - if end is not None: - if isinstance(end, unicode): - want_unicode = True - elif not isinstance(end, str): - raise TypeError("end must be None or a string") - if kwargs: - raise TypeError("invalid keyword arguments to print()") - if not want_unicode: - for arg in args: - if isinstance(arg, unicode): - want_unicode = True - break - if want_unicode: - newline = unicode("\n") - space = unicode(" ") - else: - newline = "\n" - space = " " - if sep is None: - sep = space - if end is None: - end = newline - for i, arg in enumerate(args): - if i: - write(sep) - write(arg) - write(end) - -_add_doc(reraise, """Reraise an exception.""") - - -def with_metaclass(meta, *bases): - """Create a base class with a metaclass.""" - return meta("NewBase", bases, {}) - -def add_metaclass(metaclass): - """Class decorator for creating a class with a metaclass.""" - def wrapper(cls): - orig_vars = cls.__dict__.copy() - orig_vars.pop('__dict__', None) - orig_vars.pop('__weakref__', None) - slots = orig_vars.get('__slots__') - if slots is not None: - if isinstance(slots, str): - slots = [slots] - for slots_var in slots: - orig_vars.pop(slots_var) - return metaclass(cls.__name__, cls.__bases__, orig_vars) - return wrapper diff --git a/src/engine/SCons/compat/sixTests.py b/src/engine/SCons/compat/sixTests.py deleted file mode 100644 index 8be3572..0000000 --- a/src/engine/SCons/compat/sixTests.py +++ /dev/null @@ -1,35 +0,0 @@ -# -# __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. -# - -from __future__ import print_function - -import unittest - -class sixTestCase(unittest.TestCase): - - def test_import(self): - """Test that six imports correctly.""" - import sys - print(sys.path) - from SCons.compat.six import PY2, PY3 - self.assertTrue(PY2 or PY3) diff --git a/src/script/sconsign.py b/src/script/sconsign.py index daf088e..6f49858 100644 --- a/src/script/sconsign.py +++ b/src/script/sconsign.py @@ -25,8 +25,6 @@ from __future__ import print_function -from SCons.compat.six import PY2, PY3 - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" __version__ = "__VERSION__" @@ -188,8 +186,7 @@ sys.path = libs + sys.path import SCons.compat -if PY2: - import whichdb +import whichdb import dbm import time import pickle @@ -208,10 +205,7 @@ def my_whichdb(filename): pass return _orig_whichdb(filename) -if PY3: - _orig_whichdb = dbm.whichdb -else: - _orig_whichdb = whichdb.whichdb +_orig_whichdb = whichdb.whichdb dbm.whichdb = my_whichdb def my_import(mname): -- cgit v0.12 From 3e0a831c7fcd60384266e14641a3a15f2cba1ced Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 9 Apr 2016 19:04:42 -0400 Subject: reset files to development mode --- ReleaseConfig | 2 +- src/Announce.txt | 2 +- src/CHANGES.txt | 7 +++++ src/RELEASE.txt | 82 +++++++++++++++++++++++++++----------------------------- 4 files changed, 48 insertions(+), 45 deletions(-) diff --git a/ReleaseConfig b/ReleaseConfig index a4bfce6..7a68f89 100644 --- a/ReleaseConfig +++ b/ReleaseConfig @@ -32,7 +32,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" # 'final', the patchlevel is set to the release date. This value is # mandatory and must be present in this file. #version_tuple = (2, 2, 0, 'final', 0) -version_tuple = (2, 5, 0) +version_tuple = (2, 6, 0, 'alpha', 0) # Python versions prior to unsupported_python_version cause a fatal error # when that version is used. Python versions prior to deprecate_python_version diff --git a/src/Announce.txt b/src/Announce.txt index b16fb3b..266988f 100644 --- a/src/Announce.txt +++ b/src/Announce.txt @@ -18,7 +18,7 @@ So that everyone using SCons can help each other learn how to use it more effectively, please go to http://scons.org/lists.php#users to sign up for the scons-users mailing list. -RELEASE 2.5.0 - Mon, 09 Apr 2016 11:27:42 -0700 +RELEASE VERSION/DATE TO BE FILLED IN LATER Please consult the RELEASE.txt file for a summary of changes since the last release and consult the CHANGES.txt file for complete a list of changes diff --git a/src/CHANGES.txt b/src/CHANGES.txt index b5a1fb6..b6973b7 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -4,6 +4,13 @@ Change Log +RELEASE VERSION/DATE TO BE FILLED IN LATER + + From John Doe: + + - Whatever John Doe did. + + RELEASE 2.5.0 - Mon, 09 Apr 2016 11:27:42 -0700 From Dirk Baechle: diff --git a/src/RELEASE.txt b/src/RELEASE.txt index 32d5a08..ac2b95a 100644 --- a/src/RELEASE.txt +++ b/src/RELEASE.txt @@ -1,76 +1,72 @@ - A new SCons checkpoint release, 2.5.0, is now available + A new SCons checkpoint release, 2.6.0.alpha.yyyymmdd, is now available on the SCons download page: http://www.scons.org/download.php XXX The primary purpose of this release ... XXX - Here is a summary of the changes since 2.4.1: + A SCons "checkpoint release" is intended to provide early access to + new features so they can be tested in the field before being released + for adoption by other software distributions. + + Note that a checkpoint release is developed using the same test-driven + development methodology as all SCons releases. Existing SCons + functionality should all work as it does in previous releases (except + for any changes identified in the release notes) and early adopters + should be able to use a checkpoint release safely for production work + with existing SConscript files. If not, it represents not only a bug + in SCons but also a hole in the regression test suite, and we want to + hear about it. + + New features may be more lightly tested than in past releases, + especially as concerns their interaction with all of the other + functionality in SCons. We are especially interested in hearing bug + reports about new functionality. + + We do not recommend that downstream distributions (Debian, Fedora, + etc.) package a checkpoint release, mainly to avoid confusing the + "public" release numbering with the long checkpoint release names. + + Here is a summary of the changes since 1.3.0: NEW FUNCTIONALITY - - We're enhancing implicit language scanning functionality to improve - correctness. SCons now honors scanner keys for implicit dependencies - and correctly changes scanner type (if necessary) when traversing - implicit dependency trees. - - This enhancement resolves missing dependencies - with built-in scanners including SWIG (#2264) and QT: - * http://scons.tigris.org/issues/show_bug.cgi?id=2264 - - - This enhancement broadens the horizon for handling heterogeneous - data flow environments (E.G. software builds): - - http://article.gmane.org/gmane.comp.programming.tools.scons.user/26596 - - - SCons may find new (and correct) dependencies in cross-langauge contexts. - - Update may cause rebuilds, especially in heterogeneous data environments. - - Update may find previously missed dependencies errors (E.G. cycles). - - Discovered in some QT test cases. - - SCons handles the SCANNERS variable differently. - - Previously, the Install builder would scan implicit dependencies for - a scanner found in SCANNERS (but not for built-in scanners), but now - the Install builder will not scan recursively regardless in order - to optimize Install behaviour and bring orthogonality to previous behaviour. - - - New external tool scons-configurecache which allows some configuration of - how files in the cache are controlled. + + - List new features (presumably why a checkpoint is being released) DEPRECATED FUNCTIONALITY - - None + - List anything that's been deprecated since the last release CHANGED/ENHANCED EXISTING FUNCTIONALITY - - SCons handles cache directories a bit differently/ - - Cache files are now stored in 256 subdirectories in the cache directory by - default (this stresses NFS less). Existing cache directories will remain as - current, but SCons will prompt you to run scons-configure-cache which will - allow you to migrate to the new layout, or confirm you want to use the - existing layout. + - List modifications to existing features, where the previous behavior + wouldn't actually be considered a bug FIXES - - This enhancement resolves missing dependencies with built-in scanners including - SWIG (#2264) and QT - See New Features above - * http://scons.tigris.org/issues/show_bug.cgi?id=2264 + - List fixes of outright bugs IMPROVEMENTS - - None + - List improvements that wouldn't be visible to the user in the + documentation: performance improvements (describe the circumstances + under which they would be observed), or major code cleanups PACKAGING - - None + - List changes in the way SCons is packaged and/or released DOCUMENTATION - - None + - List any significant changes to the documentation (not individual + typo fixes, even if they're mentioned in src/CHANGES.txt to give + the contributor credit) DEVELOPMENT - - None + - List visible changes in the way SCons is developed - Thanks to Dirk Baechle, William Blevins, William Deegan, Jakub Pola, Adarsh Sanjeev, Tom Tanner - for their contributions to this release. + Thanks to CURLY, LARRY, and MOE for their contributions to this release. Contributors are listed alphabetically by their last name. __COPYRIGHT__ -- cgit v0.12 From 7aadabd57fb93da426e599d01054ec26e99483c4 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 7 May 2016 20:15:18 -0700 Subject: Remove duplicate entry of "X_RPM_CONFLICTS" in dictionary. (It was there twice) --- src/engine/SCons/Tool/packaging/rpm.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/engine/SCons/Tool/packaging/rpm.py b/src/engine/SCons/Tool/packaging/rpm.py index 0750113..e5d2f0b 100644 --- a/src/engine/SCons/Tool/packaging/rpm.py +++ b/src/engine/SCons/Tool/packaging/rpm.py @@ -225,7 +225,6 @@ def build_specfile_header(spec): 'X_RPM_EXCLUDEARCH' : 'ExcludeArch: %s\n', 'X_RPM_EXCLUSIVEARCH' : 'ExclusiveArch: %s\n', 'X_RPM_PREFIX' : 'Prefix: %s\n', - 'X_RPM_CONFLICTS' : 'Conflicts: %s\n', # internal use 'X_RPM_BUILDROOT' : 'BuildRoot: %s\n', } -- cgit v0.12 From 89a20e7a132040e2429cb9124e6dcb535ec755b9 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 7 May 2016 20:17:59 -0700 Subject: Fix incorrect syntax m,group() instead of m.group().. --- src/engine/SCons/Tool/intelc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/Tool/intelc.py b/src/engine/SCons/Tool/intelc.py index c28532c..20df0f4 100644 --- a/src/engine/SCons/Tool/intelc.py +++ b/src/engine/SCons/Tool/intelc.py @@ -293,7 +293,7 @@ def get_all_compiler_versions(): # JPA: For the new version of Intel compiler 2016.1. m = re.search(r'([0-9]{0,4})(?:_sp\d*)?\.([0-9][0-9.]*)$', d) if m: - versions.append("%s.%s"%(m.group(1), m,group(2))) + versions.append("%s.%s"%(m.group(1), m.group(2))) def keyfunc(str): """Given a dot-separated version string, return a tuple of ints representing it.""" -- cgit v0.12 From c591da06c1a18873d09323d6700d1469120ad27d Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 8 May 2016 17:21:42 -0700 Subject: Guard checking for subprocess.mswindows by checking if on win32 platform --- QMTest/TestCmd.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index f8c4e69..8cb6fb9 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -658,7 +658,7 @@ except AttributeError: PIPE = subprocess.PIPE -if subprocess.mswindows: +if sys.platform == 'win32' and subprocess.mswindows: try: from win32file import ReadFile, WriteFile from win32pipe import PeekNamedPipe @@ -720,7 +720,7 @@ class Popen(subprocess.Popen): getattr(self, which).close() setattr(self, which, None) - if subprocess.mswindows: + if sys.platform == 'win32' and subprocess.mswindows: def send(self, input): if not self.stdin: return None -- cgit v0.12 From 36b38cccb12248c106575753a8f2807bfd88c2fa Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 8 May 2016 20:58:39 -0700 Subject: py2/3 compatibility changes. --- src/engine/SCons/Util.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 5b11f83..a5a92fa 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -32,13 +32,27 @@ import copy import re import types -from UserDict import UserDict -from UserList import UserList -from UserString import UserString +try: + from UserDict import UserDict +except ImportError as e: + from collections import UserDict + +try: + from UserList import UserList +except ImportError as e: + from collections import UserList + +try: + from UserString import UserString +except ImportError as e: + from collections import UserString # Don't "from types import ..." these because we need to get at the # types module later to look for UnicodeType. -InstanceType = types.InstanceType + +# Below not used? +# InstanceType = types.InstanceType + MethodType = types.MethodType FunctionType = types.FunctionType try: unicode -- cgit v0.12 From 70f4e3f26156b33f465fa12ec87b50c5b8f784e4 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 8 May 2016 21:23:37 -0700 Subject: Add from future import print_function to fix broken tests under python2.7 --- src/engine/SCons/Script/Main.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py index 997d701..c0b22a7 100644 --- a/src/engine/SCons/Script/Main.py +++ b/src/engine/SCons/Script/Main.py @@ -10,9 +10,13 @@ some other module. If it's specific to the "scons" script invocation, it goes here. """ +from __future__ import print_function + + unsupported_python_version = (2, 6, 0) deprecated_python_version = (2, 7, 0) + # __COPYRIGHT__ # # Permission is hereby granted, free of charge, to any person obtaining @@ -36,6 +40,7 @@ deprecated_python_version = (2, 7, 0) __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import SCons.compat import os @@ -360,7 +365,7 @@ class CleanTask(SCons.Taskmaster.AlwaysTask): # the file not existing. In either case, print a # message and keep going to try to remove as many # targets as possible. - print(("scons: Could not remove '{}':".format(str(t)), e.strerror)) + print("scons: Could not remove '{0}'".format(str(t)), e.strerror) else: if removed: display("Removed " + str(t)) -- cgit v0.12 From 1268203d907a4f653abd2f40299490fca9fc5874 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 9 May 2016 15:00:29 -0700 Subject: Fix missing right parent in print () function in generated SConstruct. --- test/Deprecated/Options/EnumOption.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/Deprecated/Options/EnumOption.py b/test/Deprecated/Options/EnumOption.py index 2b3ed47..02afef1 100644 --- a/test/Deprecated/Options/EnumOption.py +++ b/test/Deprecated/Options/EnumOption.py @@ -43,6 +43,7 @@ def check(expect): test.write(SConstruct_path, """\ + from SCons.Options.EnumOption import EnumOption EO = EnumOption @@ -67,7 +68,7 @@ env = Environment(options=opts) Help(opts.GenerateHelpText(env)) print(env['debug']) -print(env['guilib'] +print(env['guilib']) print(env['some']) Default(env.Alias('dummy', None)) -- cgit v0.12 From f4627c480788454ff3e8ab9f2c75966ed999d9cd Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 9 May 2016 15:26:03 -0700 Subject: Fixed usage of linknames which needed to be defined outside of the two methods which share it's value and wasn't. Curious this only fails in python2.7 when __future__ is imported.. --- src/engine/SCons/Tool/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index 9606ac1..26caf2f 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -244,6 +244,9 @@ def createStaticLibBuilder(env): return static_lib +# used by the following two methods +linknames = [] + def _call_linker_cb(env, callback, args, result = None): """Returns the result of env['LINKCALLBACKS'][callback](*args) if env['LINKCALLBACKS'] is a dictionary and env['LINKCALLBACKS'][callback] @@ -268,7 +271,7 @@ def _call_linker_cb(env, callback, args, result = None): if Verbose: print('_call_linker_cb: env["LINKCALLBACKS"][{:r}] found'.format(callback)) print('_call_linker_cb: env["LINKCALLBACKS"][{:r}]={:r}'.format(callback, cbfun)) - if(callable(cbfun)): + if (callable(cbfun)): if Verbose: print("VersionShLibLinkNames: linkname ",linkname, ", target ",libname) linknames.append(linkname) -- cgit v0.12 From b93369681ca5d4fc9a52fecd4d3afafc2dfa7742 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 9 May 2016 15:32:04 -0700 Subject: Fixed embedded SConscript/SConstruct's usage of print. Had no parens. --- test/SConscript/Return.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/test/SConscript/Return.py b/test/SConscript/Return.py index a810c7c..997de9d 100644 --- a/test/SConscript/Return.py +++ b/test/SConscript/Return.py @@ -39,50 +39,50 @@ x = SConscript('SConscript2') y, z = SConscript('SConscript3') a4, b4 = SConscript('SConscript4') foo, bar = SConscript('SConscript5') -print "x =", x -print "y =", y -print "z =", z -print "a4 =", a4 -print "b4 =", b4 -print "foo =", foo -print "bar =", bar +print ("x =", x) +print ("y =", y) +print ("z =", z) +print ("a4 =", a4) +print ("b4 =", b4) +print ("foo =", foo) +print ("bar =", bar) """) test.write('SConscript1', """\ -print "line 1" +print ("line 1") Return() -print "line 2" +print ("line 2") """) test.write('SConscript2', """\ -print "line 3" +print ("line 3") x = 7 Return('x') -print "line 4" +print ("line 4") """) test.write('SConscript3', """\ -print "line 5" +print ("line 5") y = 8 z = 9 Return('y z') -print "line 6" +print ("line 6") """) test.write('SConscript4', """\ a4 = 'aaa' b4 = 'bbb' -print "line 7" +print ("line 7") Return('a4', 'b4', stop=False) b4 = 'b-after' -print "line 8" +print ("line 8") """) test.write('SConscript5', """\ foo = 'foo' bar = 'bar' Return(["foo", "bar"]) -print "line 9" +print ("line 9") """) expect = """\ -- cgit v0.12 From 144d9dd9bd444d5cfab2b1094775d59ccc758882 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 9 May 2016 15:33:18 -0700 Subject: Fixed embedded SConscript/SConstruct's usage of print. Had no parens. --- test/SConscript/SConscript.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/SConscript/SConscript.py b/test/SConscript/SConscript.py index c8453a7..8bc9127 100644 --- a/test/SConscript/SConscript.py +++ b/test/SConscript/SConscript.py @@ -37,7 +37,7 @@ import foo assert foo.foo == 4 -print "SConstruct", os.getcwd() +print ("SConstruct", os.getcwd()) SConscript('SConscript') x1 = "SConstruct x1" @@ -89,7 +89,7 @@ test.write('SConscript', """\ assert "os" not in globals() import os -print "SConscript " + os.getcwd() +print ("SConscript " + os.getcwd()) """) test.write('SConscript1', """ -- cgit v0.12 From 9cc6b7b615b8b22a2a747fbb2d404d87b4091358 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 9 May 2016 15:36:18 -0700 Subject: Fixed embedded SConscript/SConstruct's usage of print. Had no parens. --- test/SConscript/env.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/SConscript/env.py b/test/SConscript/env.py index 42963ff..a16866c 100644 --- a/test/SConscript/env.py +++ b/test/SConscript/env.py @@ -36,7 +36,7 @@ test.subdir('sub1', 'sub2') test.write("SConstruct", """\ env = Environment(SUB1='sub1', SUB2='sub2') -print "SConstruct" +print("SConstruct") x = 'xxx' y = 'yyy' env.Export(["x", "y"]) @@ -49,15 +49,15 @@ env.SConscript(['s3', 's4']) test.write(['sub1', 'SConscript'], """\ env = Environment() env.Import("x") -print "sub1/SConscript" -print "x =", x +print("sub1/SConscript") +print("x =", x) """) test.write(['sub2', 'SConscript'], """\ env = Environment() env.Import("y") -print "sub2/SConscript" -print "y =", y +print("sub2/SConscript") +print("y =", y) """) test.write('s1', "\n") -- cgit v0.12 From 9e56ee19d57f6ecb32d6cb5cd36809fd02cd34c1 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 9 May 2016 15:37:11 -0700 Subject: Fix typo in comment. --- test/SConscript/SConscript.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/SConscript/SConscript.py b/test/SConscript/SConscript.py index 8bc9127..d1e09ce 100644 --- a/test/SConscript/SConscript.py +++ b/test/SConscript/SConscript.py @@ -85,7 +85,7 @@ SConscript('SConscript7') test.write('SConscript', """\ -# os should not be automajically imported: +# os should not be automatically imported: assert "os" not in globals() import os -- cgit v0.12 From d3c4aa79b66572dacc4be76fc7c54354c726ae3b Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 9 May 2016 15:38:08 -0700 Subject: Fixed print()'s --- test/SConscript/white-space.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/SConscript/white-space.py b/test/SConscript/white-space.py index 06acea8..cc8f00e 100644 --- a/test/SConscript/white-space.py +++ b/test/SConscript/white-space.py @@ -38,7 +38,7 @@ SConscript('white space/SConscript') """) test.write(['white space', 'SConscript'], """\ -print "`white space/SConscript'" +print("`white space/SConscript'") """) expect = test.wrap_stdout(read_str = "`white space/SConscript'\n", -- cgit v0.12 From da6d4138160e27aa34f80b6f48ba9e331a69aa77 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 9 May 2016 15:39:27 -0700 Subject: Fixed print()'s --- test/SConstruct.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/SConstruct.py b/test/SConstruct.py index 15e1c1b..9b2807f 100644 --- a/test/SConstruct.py +++ b/test/SConstruct.py @@ -41,7 +41,7 @@ wpath = test.workpath() test.write('sconstruct', """ import os -print "sconstruct", os.getcwd() +print("sconstruct", os.getcwd()) """) test.run(arguments = ".", @@ -51,7 +51,7 @@ test.run(arguments = ".", test.write('Sconstruct', """ import os -print "Sconstruct", os.getcwd() +print("Sconstruct", os.getcwd()) """) test.run(arguments = ".", @@ -60,7 +60,7 @@ test.run(arguments = ".", test.write('SConstruct', """ import os -print "SConstruct", os.getcwd() +print("SConstruct", os.getcwd()) """) test.run(arguments = ".", -- cgit v0.12 From 76aae9b8cb7bbd290fcd82fd6dbaf0c3f51c9bc4 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 9 May 2016 15:41:12 -0700 Subject: Fixed print()'s --- test/SWIG/SWIG.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/SWIG/SWIG.py b/test/SWIG/SWIG.py index d53fa49..38bdc97 100644 --- a/test/SWIG/SWIG.py +++ b/test/SWIG/SWIG.py @@ -48,14 +48,14 @@ for opt, arg in opts: if opt == '-c': pass elif opt == '-o': out = arg elif opt == '-v' and arg == 'ersion': - print "" - print "SWIG Version 0.1.2" - print "" - print "Compiled with g++ [x86_64-pc-linux-gnu]" - print "" - print "Configured options: +pcre" - print "" - print "Please see http://www.swig.org for reporting bugs and further information" + print("") + print("SWIG Version 0.1.2") + print("") + print("Compiled with g++ [x86_64-pc-linux-gnu]") + print("") + print("Configured options: +pcre") + print("") + print("Please see http://www.swig.org for reporting bugs and further information") sys.exit(0) infile = open(args[0], 'rb') outfile = open(out, 'wb') @@ -68,7 +68,7 @@ sys.exit(0) test.write('SConstruct', """ env = Environment(tools=['default', 'swig'], SWIG = [r'%(python)s', 'myswig.py']) -print env.subst("Using SWIG $SWIGVERSION") +print(env.subst("Using SWIG $SWIGVERSION")) env.Program(target = 'test1', source = 'test1.i') env.CFile(target = 'test2', source = 'test2.i') env.Clone(SWIGFLAGS = '-c++').Program(target = 'test3', source = 'test3.i') -- cgit v0.12 From 2efa4c01f3d8010adf98ab2ead5c5a4534544766 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 9 May 2016 15:42:14 -0700 Subject: Fixed print()'s --- test/Scanner/CrossLanguageNoExtension.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Scanner/CrossLanguageNoExtension.py b/test/Scanner/CrossLanguageNoExtension.py index 5bf205f..0016ca5 100644 --- a/test/Scanner/CrossLanguageNoExtension.py +++ b/test/Scanner/CrossLanguageNoExtension.py @@ -45,11 +45,11 @@ def scan(node, env, scanpaths, arg): return includes def kfile_scan(node, env, scanpaths, arg): - print 'kscan: ' + str(node) + print('kscan: ' + str(node)) return scan(node, env, scanpaths, arg) def k2file_scan(node, env, scanpaths, arg): - print 'k2scan: ' + str(node) + print('k2scan: ' + str(node)) return scan(node, env, scanpaths, arg) kscan = Scanner(name = 'kfile', -- cgit v0.12 From ac02a52b31e3e12271a9929e45fbecc10c4113c8 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 9 May 2016 15:43:40 -0700 Subject: Fixed print()'s --- test/Scanner/empty-implicit.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Scanner/empty-implicit.py b/test/Scanner/empty-implicit.py index 0323240..45fe952 100644 --- a/test/Scanner/empty-implicit.py +++ b/test/Scanner/empty-implicit.py @@ -37,7 +37,7 @@ test.write('SConstruct', r""" import os.path def scan(node, env, envkey, arg): - print 'XScanner: node =', os.path.split(str(node))[1] + print('XScanner: node =', os.path.split(str(node))[1]) return [] def exists_check(node, env): @@ -52,7 +52,7 @@ XScanner = Scanner(name = 'XScanner', def echo(env, target, source): t = os.path.split(str(target[0]))[1] s = os.path.split(str(source[0]))[1] - print 'create %s from %s' % (t, s) + print('create %s from %s' % (t, s)) open(t, 'wb').write(open(s, 'rb').read()) Echo = Builder(action = Action(echo, None), -- cgit v0.12 From dea50d86773e279f7b0f13e22285bb0a10eb5c48 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 9 May 2016 15:44:39 -0700 Subject: Fixed print()'s --- test/Scanner/scan-once.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Scanner/scan-once.py b/test/Scanner/scan-once.py index d68f918..eac1f49 100644 --- a/test/Scanner/scan-once.py +++ b/test/Scanner/scan-once.py @@ -36,7 +36,7 @@ test.write('SConstruct', r""" import os.path def scan(node, env, envkey, arg): - print 'XScanner: node =', os.path.split(str(node))[1] + print('XScanner: node =', os.path.split(str(node))[1]) return [] def exists_check(node, env): @@ -51,7 +51,7 @@ XScanner = Scanner(name = 'XScanner', def echo(env, target, source): t = os.path.split(str(target[0]))[1] s = os.path.split(str(source[0]))[1] - print 'create %s from %s' % (t, s) + print('create %s from %s' % (t, s)) Echo = Builder(action = Action(echo, None), src_suffix = '.x', -- cgit v0.12 From 8db3ac9ab52220be897c562c36599897e43af7ee Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 9 May 2016 15:46:20 -0700 Subject: Fixed print()'s --- test/Subst/AllowSubstExceptions.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/Subst/AllowSubstExceptions.py b/test/Subst/AllowSubstExceptions.py index 286f189..7f2a9aa 100644 --- a/test/Subst/AllowSubstExceptions.py +++ b/test/Subst/AllowSubstExceptions.py @@ -52,37 +52,37 @@ assert env.subst_list('${INDEX[999]}') == [[]] AllowSubstExceptions() try: env.subst('$NAME') -except SCons.Errors.UserError, e: print e +except SCons.Errors.UserError, e: print(e) else: raise Exception("did not catch expected SCons.Errors.UserError") try: env.subst('${NAME}') -except SCons.Errors.UserError, e: print e +except SCons.Errors.UserError, e: print(e) else: raise Exception("did not catch expected SCons.Errors.UserError") try: env.subst('${INDEX[999]}') -except SCons.Errors.UserError, e: print e +except SCons.Errors.UserError, e: print(e) else: raise Exception("did not catch expected SCons.Errors.UserError") try: env.subst_list('$NAME') -except SCons.Errors.UserError, e: print e +except SCons.Errors.UserError, e: print(e) else: raise Exception("did not catch expected SCons.Errors.UserError") try: env.subst_list('${NAME}') -except SCons.Errors.UserError, e: print e +except SCons.Errors.UserError, e: print(e) else: raise Exception("did not catch expected SCons.Errors.UserError") try: env.subst_list('${INDEX[999]}') -except SCons.Errors.UserError, e: print e +except SCons.Errors.UserError, e: print(e) else: raise Exception("did not catch expected SCons.Errors.UserError") try: env.subst('${1/0}') -except SCons.Errors.UserError, e: print e +except SCons.Errors.UserError, e: print(e) else: raise Exception("did not catch expected SCons.Errors.UserError") try: env.subst_list('${1/0}') -except SCons.Errors.UserError, e: print e +except SCons.Errors.UserError, e: print(e) else: raise Exception("did not catch expected SCons.Errors.UserError") AllowSubstExceptions(ZeroDivisionError) -- cgit v0.12 From b70ce9026da43a0d659fbc60588e2df471cbba77 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 9 May 2016 15:49:39 -0700 Subject: Fixed print()'s. Still some remaining issues. Check later. --- test/Variables/ListVariable.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/Variables/ListVariable.py b/test/Variables/ListVariable.py index e5be625..c6972c1 100644 --- a/test/Variables/ListVariable.py +++ b/test/Variables/ListVariable.py @@ -66,15 +66,15 @@ env = Environment(variables=opts) opts.Save(optsfile, env) Help(opts.GenerateHelpText(env)) -print env['shared'] -if 'ical' in env['shared']: print '1' -else: print '0' +print(env['shared']) +if 'ical' in env['shared']: print('1') +else: print('0') for x in env['shared']: - print x, -print -print env.subst('$shared') + print (x,) +print() +print(env.subst('$shared')) # Test subst_path() because it's used in $CPPDEFINES expansions. -print env.subst_path('$shared') +print(env.subst_path('$shared')) Default(env.Alias('dummy', None)) """) @@ -162,7 +162,7 @@ opts.AddVariables( env = Environment(variables=opts) Help(opts.GenerateHelpText(env)) -print env['gpib'] +print(env['gpib']) Default(env.Alias('dummy', None)) """) -- cgit v0.12 From ef93655b57fcd93cfda0e21439f5fc60df161238 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 9 May 2016 15:51:31 -0700 Subject: Fixed print()'s. Still some remaining issues. Check later. --- test/toolpath/basic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/toolpath/basic.py b/test/toolpath/basic.py index eedd06e..509d4cb 100644 --- a/test/toolpath/basic.py +++ b/test/toolpath/basic.py @@ -40,12 +40,12 @@ print("env1['TOOL_BAR'] =", env1.get('TOOL_BAR')) # pick a built-in tool with pretty simple behavior env2 = Environment(tools=['SCCS']) -print("env2['SCCS'] =", env2.get('SCCS') +print("env2['SCCS'] =", env2.get('SCCS')) print("env2['TOOL_SCCS1'] =", env2.get('TOOL_SCCS1')) print("env2['TOOL_SCCS2'] =", env2.get('TOOL_SCCS2')) env3 = Environment(tools=['SCCS'], toolpath=['.']) -print("env3['SCCS'] =", env3.get('SCCS') +print("env3['SCCS'] =", env3.get('SCCS')) print("env3['TOOL_SCCS1'] =", env3.get('TOOL_SCCS1')) print("env3['TOOL_SCCS2'] =", env3.get('TOOL_SCCS2')) -- cgit v0.12 From 67769cb3a7673604be8e1ddcc8af2f3be552d905 Mon Sep 17 00:00:00 2001 From: Pawel Tomulik Date: Wed, 11 May 2016 02:17:30 +0200 Subject: fixed issue with _xxxxxxVERSIONFLAGS --- src/engine/SCons/Defaults.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py index 6344975..37cbc99 100644 --- a/src/engine/SCons/Defaults.py +++ b/src/engine/SCons/Defaults.py @@ -540,10 +540,10 @@ class Variable_Method_Caller(object): frame = frame.f_back return None -# if env[version_var] id defined, returns env[flags_var], otherwise returns None +# if $version_var is not empty, returns env[flags_var], otherwise returns None def __libversionflags(env, version_var, flags_var): try: - if env[version_var]: + if env.subst('$'+version_var): return env[flags_var] except KeyError: pass -- cgit v0.12 From 170105963ce92f49eeb7441739b921198dec0505 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 12 May 2016 07:48:46 -0700 Subject: copy src/engine/SCons/Tool/__init__.py as the merge had issues at some point in the past the the versioned shared library logic got mangled. Then 2to3 that file. Seems to e working now --- src/engine/SCons/Tool/__init__.py | 175 ++++++++++---------------------------- 1 file changed, 43 insertions(+), 132 deletions(-) diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index 26caf2f..4cd242b 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -34,7 +34,6 @@ tool definition. # 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. -from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -53,6 +52,7 @@ import SCons.Scanner.D import SCons.Scanner.LaTeX import SCons.Scanner.Prog import SCons.Scanner.SWIG +import collections DefaultToolpath=[] @@ -122,7 +122,7 @@ class Tool(object): if file: file.close() except ImportError as e: - if not str(e).startswith ("No module"): + if str(e)!="No module named %s"%self.name: raise SCons.Errors.EnvironmentError(e) try: import zipimport @@ -152,7 +152,7 @@ class Tool(object): file.close() return module except ImportError as e: - if not str(e).startswith("No module"): + if str(e)!="No module named %s"%self.name: raise SCons.Errors.EnvironmentError(e) try: import zipimport @@ -244,9 +244,6 @@ def createStaticLibBuilder(env): return static_lib -# used by the following two methods -linknames = [] - def _call_linker_cb(env, callback, args, result = None): """Returns the result of env['LINKCALLBACKS'][callback](*args) if env['LINKCALLBACKS'] is a dictionary and env['LINKCALLBACKS'][callback] @@ -258,109 +255,22 @@ def _call_linker_cb(env, callback, args, result = None): Verbose = False if Verbose: - print('_call_linker_cb: args={:r}'.format(args)) - print('_call_linker_cb: callback={:r}'.format(callback)) - + print('_call_linker_cb: args=%r' % args) + print('_call_linker_cb: callback=%r' % callback) + try: cbfun = env['LINKCALLBACKS'][callback] except (KeyError, TypeError): if Verbose: - print('_call_linker_cb: env["LINKCALLBACKS"][{:r}] not found or can not be used'.format(callback)) + print('_call_linker_cb: env["LINKCALLBACKS"][%r] not found or can not be used' % callback) pass else: if Verbose: - print('_call_linker_cb: env["LINKCALLBACKS"][{:r}] found'.format(callback)) - print('_call_linker_cb: env["LINKCALLBACKS"][{:r}]={:r}'.format(callback, cbfun)) - if (callable(cbfun)): - if Verbose: - print("VersionShLibLinkNames: linkname ",linkname, ", target ",libname) - linknames.append(linkname) - # note: no Windows case here (win32 or cygwin); - # MSVC doesn't support this type of versioned shared libs. - # (could probably do something for MinGW though) - return linknames - -def VersionedSharedLibrary(target = None, source= None, env=None): - """Build a shared library. If the environment has SHLIBVERSION -defined make a versioned shared library and create the appropriate -symlinks for the platform we are on""" - Verbose = False - try: - version = env.subst('$SHLIBVERSION') - except KeyError: - version = None - - # libname includes the version number if one was given - libname = target[0].name - platform = env.subst('$PLATFORM') - shlib_suffix = env.subst('$SHLIBSUFFIX') - shlink_flags = SCons.Util.CLVar(env.subst('$SHLINKFLAGS')) - if Verbose: - print("VersionShLib: libname = ",libname) - print("VersionShLib: platform = ",platform) - print("VersionShLib: shlib_suffix = ",shlib_suffix) - print("VersionShLib: target = ",str(target[0])) - - if version: - # set the shared library link flags - if platform == 'posix': - shlink_flags += [ '-Wl,-Bsymbolic' ] - # OpenBSD doesn't usually use SONAME for libraries - if not sys.platform.startswith('openbsd'): - # continue setup of shlink flags for all other POSIX systems - suffix_re = re.escape(shlib_suffix + '.' + version) - (major, age, revision) = version.split(".") - # soname will have only the major version number in it - soname = re.sub(suffix_re, shlib_suffix, libname) + '.' + major - shlink_flags += [ '-Wl,-soname=%s' % soname ] - if Verbose: - print(" soname ",soname,", shlink_flags ",shlink_flags) - elif platform == 'cygwin': - shlink_flags += [ '-Wl,-Bsymbolic', - '-Wl,--out-implib,${TARGET.base}.a' ] - elif platform == 'darwin': - shlink_flags += [ '-current_version', '%s' % version, - '-compatibility_version', '%s' % version, - '-undefined', 'dynamic_lookup' ] - if Verbose: - print("VersionShLib: shlink_flags = ",shlink_flags) - envlink = env.Clone() - envlink['SHLINKFLAGS'] = shlink_flags - else: - envlink = env - - result = SCons.Defaults.ShLinkAction(target, source, envlink) - - if version: - # here we need the full pathname so the links end up in the right directory - libname = target[0].path - linknames = VersionShLibLinkNames(version, libname, env) - if Verbose: - print("VerShLib: linknames ",linknames) - # Here we just need the file name w/o path as the target of the link - lib_ver = target[0].name - # make symlink of adjacent names in linknames - for count in range(len(linknames)): - linkname = linknames[count] - if count > 0: - try: - os.remove(lastlinkname) - except: - pass - os.symlink(os.path.basename(linkname),lastlinkname) - if Verbose: - print("VerShLib: made sym link of %s -> %s" % (lastlinkname,linkname)) - lastlinkname = linkname - # finish chain of sym links with link to the actual library - if len(linknames)>0: - try: - os.remove(lastlinkname) - except: - pass - os.symlink(lib_ver,lastlinkname) + print('_call_linker_cb: env["LINKCALLBACKS"][%r] found' % callback) + print('_call_linker_cb: env["LINKCALLBACKS"][%r]=%r' % (callback, cbfun)) + if(isinstance(cbfun, collections.Callable)): if Verbose: - print("VerShLib: made sym link of %s -> %s" % (linkname, lib_ver)) - print('_call_linker_cb: env["LINKCALLBACKS"][{:r}] is callable'.format(callback)) + print('_call_linker_cb: env["LINKCALLBACKS"][%r] is callable' % callback) result = cbfun(env, *args) return result @@ -479,7 +389,7 @@ class _LibInfoGeneratorBase(object): def generate_versioned_lib_info(self, env, args, result = None, **kw): callback = self.get_versioned_lib_info_generator(**kw) - return _call_linker_cb(env, callback, args, result) + return _call_linker_cb(env, callback, args, result) class _LibPrefixGenerator(_LibInfoGeneratorBase): """Library prefix generator, used as target_prefix in SharedLibrary and @@ -498,17 +408,17 @@ class _LibPrefixGenerator(_LibInfoGeneratorBase): prefix = self.get_lib_prefix(env,**kw2) if Verbose: - print("_LibPrefixGenerator: input prefix={:r}".format(prefix)) + print("_LibPrefixGenerator: input prefix=%r" % prefix) version = self.get_lib_version(env, **kw2) if Verbose: - print("_LibPrefixGenerator: version={:r}".format(version)) + print("_LibPrefixGenerator: version=%r" % version) if version: prefix = self.generate_versioned_lib_info(env, [prefix, version], prefix, **kw2) if Verbose: - print("_LibPrefixGenerator: return prefix={:r}".format(prefix)) + print("_LibPrefixGenerator: return prefix=%r" % prefix) return prefix ShLibPrefixGenerator = _LibPrefixGenerator('ShLib') @@ -532,17 +442,17 @@ class _LibSuffixGenerator(_LibInfoGeneratorBase): suffix = self.get_lib_suffix(env, **kw2) if Verbose: - print("_LibSuffixGenerator: input suffix={:r}".format(suffix)) + print("_LibSuffixGenerator: input suffix=%r" % suffix) version = self.get_lib_version(env, **kw2) if Verbose: - print("_LibSuffixGenerator: version={:r}".format(version)) + print("_LibSuffixGenerator: version=%r" % version) if version: suffix = self.generate_versioned_lib_info(env, [suffix, version], suffix, **kw2) if Verbose: - print("_LibSuffixGenerator: return suffix={:r}".format(suffix)) + print("_LibSuffixGenerator: return suffix=%r" % suffix) return suffix ShLibSuffixGenerator = _LibSuffixGenerator('ShLib') @@ -565,15 +475,15 @@ class _LibSymlinkGenerator(_LibInfoGeneratorBase): kw2 = kw if Verbose: - print("_LibSymLinkGenerator: libnode={:r}".format(libnode.get_path())) + print("_LibSymLinkGenerator: libnode=%r" % libnode.get_path()) symlinks = None version = self.get_lib_version(env, **kw2) disable = self.get_lib_noversionsymlinks(env, **kw2) if Verbose: - print('_LibSymlinkGenerator: version={:r}'.format(version)) - print('_LibSymlinkGenerator: disable={:r}'.format(disable)) + print('_LibSymlinkGenerator: version=%r' % version) + print('_LibSymlinkGenerator: disable=%r' % disable) if version and not disable: prefix = self.get_lib_prefix(env,**kw2) @@ -581,7 +491,7 @@ class _LibSymlinkGenerator(_LibInfoGeneratorBase): symlinks = self.generate_versioned_lib_info(env, [libnode, version, prefix, suffix], **kw2) if Verbose: - print('_LibSymlinkGenerator: return symlinks={:r}'.format(StringizeLibSymlinks(symlinks))) + print('_LibSymlinkGenerator: return symlinks=%r' % StringizeLibSymlinks(symlinks)) return symlinks ShLibSymlinkGenerator = _LibSymlinkGenerator('ShLib') @@ -590,7 +500,7 @@ ImpLibSymlinkGenerator = _LibSymlinkGenerator('ImpLib') class _LibNameGenerator(_LibInfoGeneratorBase): """Generates "unmangled" library name from a library file node. - + Generally, it's thought to revert modifications done by prefix/suffix generators (_LibPrefixGenerator/_LibSuffixGenerator) used by a library builder. For example, on gnulink the suffix generator used by SharedLibrary @@ -600,7 +510,7 @@ class _LibNameGenerator(_LibInfoGeneratorBase): "$SHLIBSUFFIX" in the node's basename. So that, if $SHLIBSUFFIX is ".so", $SHLIBVERSION is "0.1.2" and the node path is "/foo/bar/libfoo.so.0.1.2", the _LibNameGenerator shall return "libfoo.so". Other link tools may - implement it's own way of library name unmangling. + implement it's own way of library name unmangling. """ def __init__(self, libtype): super(_LibNameGenerator, self).__init__(libtype, 'Name') @@ -616,11 +526,11 @@ class _LibNameGenerator(_LibInfoGeneratorBase): kw2 = kw if Verbose: - print("_LibNameGenerator: libnode={:r}".format(libnode.get_path())) + print("_LibNameGenerator: libnode=%r" % libnode.get_path()) version = self.get_lib_version(env, **kw2) if Verbose: - print('_LibNameGenerator: version={:r}'.format(version)) + print('_LibNameGenerator: version=%r' % version) name = None if version: @@ -632,7 +542,7 @@ class _LibNameGenerator(_LibInfoGeneratorBase): name = os.path.basename(libnode.get_path()) if Verbose: - print('_LibNameGenerator: return name={:r}'.format(name)) + print('_LibNameGenerator: return name=%r' % name) return name @@ -641,7 +551,7 @@ LdModNameGenerator = _LibNameGenerator('LdMod') ImpLibNameGenerator = _LibNameGenerator('ImpLib') class _LibSonameGenerator(_LibInfoGeneratorBase): - """Library soname generator. Returns library soname (e.g. libfoo.so.0) for + """Library soname generator. Returns library soname (e.g. libfoo.so.0) for a given node (e.g. /foo/bar/libfoo.so.0.1.2)""" def __init__(self, libtype): super(_LibSonameGenerator, self).__init__(libtype, 'Soname') @@ -657,13 +567,13 @@ class _LibSonameGenerator(_LibInfoGeneratorBase): kw2 = kw if Verbose: - print("_LibSonameGenerator: libnode={:r}".format(libnode.get_path())) + print("_LibSonameGenerator: libnode=%r" % libnode.get_path()) soname = _call_env_subst(env, '$SONAME', **kw2) if not soname: version = self.get_lib_version(env,**kw2) if Verbose: - print("_LibSonameGenerator: version={:r}".format(version)) + print("_LibSonameGenerator: version=%r" % version) if version: prefix = self.get_lib_prefix(env,**kw2) suffix = self.get_lib_suffix(env,**kw2) @@ -673,10 +583,10 @@ class _LibSonameGenerator(_LibInfoGeneratorBase): # fallback to library name (as returned by appropriate _LibNameGenerator) soname = _LibNameGenerator(self.get_libtype())(env, libnode) if Verbose: - print("_LibSonameGenerator: FALLBACK: soname={:r}".format(soname)) + print("_LibSonameGenerator: FALLBACK: soname=%r" % soname) if Verbose: - print("_LibSonameGenerator: return soname={:r}".format(soname)) + print("_LibSonameGenerator: return soname=%r" % soname) return soname @@ -704,39 +614,39 @@ def EmitLibSymlinks(env, symlinks, libnode, **kw): clean_targets = kw.get('clean_targets', []) if not SCons.Util.is_List(clean_targets): clean_targets = [ clean_targets ] - + for link, linktgt in symlinks: env.SideEffect(link, linktgt) if(Verbose): - print("EmitLibSymlinks: SideEffect({:r},{:r})".format(link.get_path(), linktgt.get_path())) - clean_list = filter(lambda x : x != linktgt, nodes) + print("EmitLibSymlinks: SideEffect(%r,%r)" % (link.get_path(), linktgt.get_path())) + clean_list = [x for x in nodes if x != linktgt] env.Clean(list(set([linktgt] + clean_targets)), clean_list) if(Verbose): - print("EmitLibSymlinks: Clean({:r},{:r})".format(linktgt.get_path(), map(lambda x : x.get_path(), clean_list))) + print("EmitLibSymlinks: Clean(%r,%r)" % (linktgt.get_path(), [x.get_path() for x in clean_list])) def CreateLibSymlinks(env, symlinks): """Physically creates symlinks. The symlinks argument must be a list in form [ (link, linktarget), ... ], where link and linktarget are SCons nodes. """ - + Verbose = False for link, linktgt in symlinks: linktgt = link.get_dir().rel_path(linktgt) link = link.get_path() if(Verbose): - print("CreateLibSymlinks: preparing to add symlink {:r} -> {:r}".format(link, linktgt)) + print("CreateLibSymlinks: preparing to add symlink %r -> %r" % (link, linktgt)) # Delete the (previously created) symlink if exists. Let only symlinks # to be deleted to prevent accidental deletion of source files... if env.fs.islink(link): env.fs.unlink(link) if(Verbose): - print("CreateLibSymlinks: removed old symlink {:r}".format(link)) + print("CreateLibSymlinks: removed old symlink %r" % link) # If a file or directory exists with the same name as link, an OSError # will be thrown, which should be enough, I think. env.fs.symlink(linktgt, link) if(Verbose): - print("CreateLibSymlinks: add symlink {:r} -> {:r}".format(link, linktgt)) + print("CreateLibSymlinks: add symlink %r -> %r" % (link, linktgt)) return 0 def LibSymlinksActionFunction(target, source, env): @@ -761,7 +671,7 @@ def LibSymlinksStrFun(target, source, env, *args): else: cmd += ": %s" % linkstr return cmd - + LibSymlinksAction = SCons.Action.Action(LibSymlinksActionFunction, LibSymlinksStrFun) @@ -1040,7 +950,7 @@ class ToolInitializer(object): so we no longer copy and re-bind them when the construction environment gets cloned. """ - for method in self.methods.values(): + for method in list(self.methods.values()): env.RemoveMethod(method) def apply_tools(self, env): @@ -1228,3 +1138,4 @@ def tool_list(platform, env): # indent-tabs-mode:nil # End: # vim: set expandtab tabstop=4 shiftwidth=4: + -- cgit v0.12 From 1d0d856ede1adca42d190ef4a9532df70961da8e Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 12 May 2016 15:08:55 -0400 Subject: fix whitespace in generated dsp file to match expected in test harness. Editor or 2to3 was chopping trailing space --- src/engine/SCons/Tool/msvs.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py index c3c8164..6df4928 100644 --- a/src/engine/SCons/Tool/msvs.py +++ b/src/engine/SCons/Tool/msvs.py @@ -550,16 +550,16 @@ V6DSPHeader = """\ CFG=%(name)s - Win32 %(confkey)s !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run -!MESSAGE +!MESSAGE !MESSAGE NMAKE /f "%(name)s.mak". -!MESSAGE +!MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE +!MESSAGE !MESSAGE NMAKE /f "%(name)s.mak" CFG="%(name)s - Win32 %(confkey)s" -!MESSAGE +!MESSAGE !MESSAGE Possible choices for configuration are: -!MESSAGE +!MESSAGE """ class _GenerateV6DSP(_DSPGenerator): -- cgit v0.12 From e24a73d1a94ac419d3acf6fe0af6d4ce6cfea3c1 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 12 May 2016 15:10:20 -0400 Subject: remove reference to six package.. unused --- test/option/profile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/test/option/profile.py b/test/option/profile.py index 93dad91..4d942cf 100644 --- a/test/option/profile.py +++ b/test/option/profile.py @@ -21,7 +21,6 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -from SCons.compat.six import u __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -- cgit v0.12 From 5dc3cdfd4df03ca7aa4d7db058e2c0b3926d4c10 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 12 May 2016 15:39:10 -0400 Subject: fix broken test. 2to3 print changes broke some formatting. Changed output to generate same in a different way --- test/Variables/ListVariable.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/test/Variables/ListVariable.py b/test/Variables/ListVariable.py index c6972c1..e463840 100644 --- a/test/Variables/ListVariable.py +++ b/test/Variables/ListVariable.py @@ -67,11 +67,14 @@ opts.Save(optsfile, env) Help(opts.GenerateHelpText(env)) print(env['shared']) -if 'ical' in env['shared']: print('1') -else: print('0') -for x in env['shared']: - print (x,) -print() + +if 'ical' in env['shared']: + print('1') +else: + print('0') + +print(" ".join(env['shared'])) + print(env.subst('$shared')) # Test subst_path() because it's used in $CPPDEFINES expansions. print(env.subst_path('$shared')) -- cgit v0.12 From fdd25f581023b3a4a98a4682ee20c64fb7567f90 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 12 May 2016 16:41:15 -0400 Subject: fix error where IOError and OSError exceptions were falling through to the wrong case in Errors.py/convert_to_BuildError().. EnvironmentError is now just an alias in Py3 and it looks like the future module is not properly handling the py3 alias'ing and breaking the py2 exception class hierarchy. --- src/engine/SCons/Errors.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/engine/SCons/Errors.py b/src/engine/SCons/Errors.py index 54e888c..3cc9c6d 100644 --- a/src/engine/SCons/Errors.py +++ b/src/engine/SCons/Errors.py @@ -144,6 +144,7 @@ def convert_to_BuildError(status, exc_info=None): if not exc_info and isinstance(status, Exception): exc_info = (status.__class__, status, None) + if isinstance(status, BuildError): buildError = status buildError.exitstatus = 2 # always exit with 2 on build errors @@ -161,14 +162,17 @@ def convert_to_BuildError(status, exc_info=None): status=2, exitstatus=2, exc_info=exc_info) - elif isinstance(status, EnvironmentError): + elif isinstance(status, (EnvironmentError, OSError, IOError)): # If an IOError/OSError happens, raise a BuildError. # Report the name of the file or directory that caused the # error, which might be different from the target being built # (for example, failure to create the directory in which the # target file will appear). - try: filename = status.filename - except AttributeError: filename = None + try: + filename = status.filename + except AttributeError: + filename = None + buildError = BuildError( errstr=status.strerror, status=status.errno, -- cgit v0.12 From 254e647fbe03e280af8f595fff9606d8ec003972 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 12 May 2016 18:21:29 -0400 Subject: fix print() conversion on test --- test/Deprecated/Options/ListOption.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/test/Deprecated/Options/ListOption.py b/test/Deprecated/Options/ListOption.py index ad804f2..42af511 100644 --- a/test/Deprecated/Options/ListOption.py +++ b/test/Deprecated/Options/ListOption.py @@ -68,11 +68,14 @@ opts.Save(optsfile, env) Help(opts.GenerateHelpText(env)) print(env['shared']) -if 'ical' in env['shared']: print('1') -else: print('0') -for x in env['shared']: - print(x, end='') -print() + +if 'ical' in env['shared']: + print('1') +else: + print('0') + +print(" ".join(env['shared'])) + print(env.subst('$shared')) # Test subst_path() because it's used in $CPPDEFINES expansions. print(env.subst_path('$shared')) -- cgit v0.12 From af735035cdaff0fa27fc396539cd51e9effe6e6c Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 12 May 2016 19:05:00 -0400 Subject: Seeems like EnvironmentError is not yielding the proper error output from SCons under __future__. py 3.5 EnvironmentError is an alias for OSError. Changing to OSError makes the test pass --- test/GetBuildFailures/serial.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/GetBuildFailures/serial.py b/test/GetBuildFailures/serial.py index fb59c7c..55a990f 100644 --- a/test/GetBuildFailures/serial.py +++ b/test/GetBuildFailures/serial.py @@ -82,8 +82,8 @@ Command('f08', 'f08.in', raiseExcAction(SCons.Errors.UserError("My User Error")) Command('f09', 'f09.in', returnExcAction(SCons.Errors.UserError("My User Error"))) Command('f10', 'f10.in', raiseExcAction(MyBuildError(errstr="My Build Error", status=7))) Command('f11', 'f11.in', returnExcAction(MyBuildError(errstr="My Build Error", status=7))) -Command('f12', 'f12.in', raiseExcAction(EnvironmentError(123, "My EnvironmentError", "f12"))) -Command('f13', 'f13.in', returnExcAction(EnvironmentError(123, "My EnvironmentError", "f13"))) +Command('f12', 'f12.in', raiseExcAction(OSError(123, "My EnvironmentError", "f12"))) +Command('f13', 'f13.in', returnExcAction(OSError(123, "My EnvironmentError", "f13"))) Command('f14', 'f14.in', raiseExcAction(SCons.Errors.InternalError("My InternalError"))) Command('f15', 'f15.in', returnExcAction(SCons.Errors.InternalError("My InternalError"))) -- cgit v0.12 From ba64112bdae96d643dbe398c0e4b9cd723348fb8 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 12 May 2016 21:39:57 -0400 Subject: fix print statement in embedded string which generates SConstruct --- test/GetBuildFailures/option-k.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/GetBuildFailures/option-k.py b/test/GetBuildFailures/option-k.py index b4e8d54..0ff22e6 100644 --- a/test/GetBuildFailures/option-k.py +++ b/test/GetBuildFailures/option-k.py @@ -65,7 +65,7 @@ Command('f6', 'f6.in', r'@%(_python_)s mypass.py f5 - $TARGET $SOURCE') def print_build_failures(): from SCons.Script import GetBuildFailures for bf in sorted(GetBuildFailures(), key=lambda a: a.filename): - print "%%s failed: %%s" %% (bf.node, bf.errstr) + print("%%s failed: %%s" %% (bf.node, bf.errstr)) import atexit atexit.register(print_build_failures) -- cgit v0.12 From 0a5aa629ffffda4aa6b960399ff19d59b6b76dd6 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 13 May 2016 14:51:22 -0400 Subject: Fixed print()'s. --- QMTest/TestSCons.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index 88d0e9c..a515684 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -1152,7 +1152,7 @@ try: print(distutils.sysconfig.get_python_inc()) print(os.path.join(exec_prefix, 'libs')) except: - print(os.path.join(sys.prefix, 'include', py_ver) + print(os.path.join(sys.prefix, 'include', py_ver)) print(os.path.join(sys.prefix, 'lib', py_ver, 'config')) print(py_ver) """) -- cgit v0.12 From b8ba51c52564ddf72a4f3dc229c35e081937aafa Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 13 May 2016 16:12:14 -0400 Subject: Restore deleted function _scons_file() in win32.py. This is causing most tests to fail in win32. See if this resolves. --- src/engine/SCons/Platform/win32.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/engine/SCons/Platform/win32.py b/src/engine/SCons/Platform/win32.py index 8ba8218..269007d 100644 --- a/src/engine/SCons/Platform/win32.py +++ b/src/engine/SCons/Platform/win32.py @@ -63,6 +63,13 @@ else: _builtin_file = file _builtin_open = open + class _scons_file(_builtin_file): + def __init__(self, *args, **kw): + _builtin_file.__init__(self, *args, **kw) + win32api.SetHandleInformation(msvcrt.get_osfhandle(self.fileno()), + win32con.HANDLE_FLAG_INHERIT, 0) + + def _scons_open(*args, **kw): fp = _builtin_open(*args, **kw) win32api.SetHandleInformation(msvcrt.get_osfhandle(fp.fileno()), -- cgit v0.12 From 9dc0f8feb825d50da88009c84fc274fb489d3a19 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 13 May 2016 16:30:20 -0700 Subject: fixes for print()'s for win32 --- QMTest/TestSConsMSVS.py | 4 ++-- src/engine/SCons/Action.py | 4 ++-- src/engine/SCons/Taskmaster.py | 6 +++++- test/MSVC/query_vcbat.py | 2 +- test/MSVS/vs-8.0-exec.py | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/QMTest/TestSConsMSVS.py b/QMTest/TestSConsMSVS.py index 7459af0..39dbb5e 100644 --- a/QMTest/TestSConsMSVS.py +++ b/QMTest/TestSConsMSVS.py @@ -1037,8 +1037,8 @@ class TestSConsMSVS(TestSCons): input = """\ import SCons import SCons.Tool.MSCommon -print "self.scons_version =", repr(SCons.__%s__) -print "self._msvs_versions =", str(SCons.Tool.MSCommon.query_versions()) +print("self.scons_version =", repr(SCons.__%s__)) +print("self._msvs_versions =", str(SCons.Tool.MSCommon.query_versions())) """ % 'version' self.run(arguments = '-n -q -Q -f -', stdin = input) diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index a4e75f3..7e1f8f1 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -233,8 +233,8 @@ def _code_contents(code): # The code contents depends on the number of local variables # but not their actual names. - contents.append("{}, {}".format(code.co_argcount, len(code.co_varnames))) - contents.append(", {}, {}".format(len(code.co_cellvars), len(code.co_freevars))) + contents.append(b"{}, {}".format(code.co_argcount, len(code.co_varnames))) + contents.append(b", {}, {}".format(len(code.co_cellvars), len(code.co_freevars))) # The code contents depends on any constants accessed by the # function. Note that we have to call _object_contents on each diff --git a/src/engine/SCons/Taskmaster.py b/src/engine/SCons/Taskmaster.py index 7260071..ddafeb9 100644 --- a/src/engine/SCons/Taskmaster.py +++ b/src/engine/SCons/Taskmaster.py @@ -539,7 +539,11 @@ class Task(object): except ValueError: exc_type, exc_value = exc exc_traceback = None - raise exc_type, exc_value, exc_traceback + # raise exc_type, exc_value, exc_traceback + raise exc_type(exc_value).with_traceback(exc_traceback) + + # raise e.__class__, e.__class__(e), sys.exc_info()[2] + class AlwaysTask(Task): def needs_execute(self): diff --git a/test/MSVC/query_vcbat.py b/test/MSVC/query_vcbat.py index 328345d..428fe56 100644 --- a/test/MSVC/query_vcbat.py +++ b/test/MSVC/query_vcbat.py @@ -49,7 +49,7 @@ DefaultEnvironment(tools = []) # print k, v #MergeMSVSBatFile(env, 9.0) #print env['ENV']['PATH'] -print query_versions() +print(query_versions()) """) test.run(stderr = None) diff --git a/test/MSVS/vs-8.0-exec.py b/test/MSVS/vs-8.0-exec.py index cff7ca2..96c4c29 100644 --- a/test/MSVS/vs-8.0-exec.py +++ b/test/MSVS/vs-8.0-exec.py @@ -55,7 +55,7 @@ if not msvs_version in test.msvs_versions(): test.run(arguments = '-n -q -Q -f -', stdin = """\ env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s') -print "os.environ.update(%%s)" %% repr(env['ENV']) +print("os.environ.update(%%s)" %% repr(env['ENV'])) """ % locals()) exec(test.stdout()) -- cgit v0.12 From 547a704c080c97304425fcde1eb2381d9f395352 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 13 May 2016 20:43:15 -0700 Subject: fix default open mode for test.write() to be wb.. it was changed to just w when six was the plan. it causes many tests to fail on win32 --- QMTest/TestCmd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index 8cb6fb9..198f586 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -1719,7 +1719,7 @@ class TestCmd(object): do_chmod(os.path.join(dirpath, name)) do_chmod(top) - def write(self, file, content, mode = 'w'): + def write(self, file, content, mode = 'wb'): """Writes the specified content text (second argument) to the specified file name (first argument). The file name may be a list, in which case the elements are concatenated with the -- cgit v0.12 From 37eb6eeaa3dc3d850b784b6f808b710836a6c244 Mon Sep 17 00:00:00 2001 From: Pawel Tomulik Date: Sat, 14 May 2016 20:59:00 +0200 Subject: regression tests for #319 --- src/engine/SCons/Script/__init__.py | 1 + test/LINK/LDMODULEVERSIONFLAGS.py | 71 +++++++++++++++++++++++++++++++++++++ test/LINK/SHLIBVERSIONFLAGS.py | 28 ++++++++++----- 3 files changed, 91 insertions(+), 9 deletions(-) create mode 100644 test/LINK/LDMODULEVERSIONFLAGS.py diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py index a0c61c5..be6e5ce 100644 --- a/src/engine/SCons/Script/__init__.py +++ b/src/engine/SCons/Script/__init__.py @@ -354,6 +354,7 @@ GlobalDefaultBuilders = [ 'Java', 'JavaH', 'Library', + 'LoadableModule', 'M4', 'MSVSProject', 'Object', diff --git a/test/LINK/LDMODULEVERSIONFLAGS.py b/test/LINK/LDMODULEVERSIONFLAGS.py new file mode 100644 index 0000000..5a9a847 --- /dev/null +++ b/test/LINK/LDMODULEVERSIONFLAGS.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python +# +# __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__" + +import os +import re + +import TestSCons +import SCons.Platform +import SCons.Defaults + +foo_c_src = "void foo() {}\n" + +env = SCons.Defaults.DefaultEnvironment() +platform = SCons.Platform.platform_default() +tool_list = SCons.Platform.DefaultToolList(platform, env) + + +test = TestSCons.TestSCons() +if 'gnulink' in tool_list: + versionflags = r".+ -Wl,-Bsymbolic -Wl,-soname=libfoo.so.1( .+)+" +elif 'sunlink' in tool_list: + versionflags = r".+ -h libfoo.so.1( .+)+" +else: + test.skip_test('No testable likers found, skipping the test\n') + + +# We expect stdout to not contain LDMODULEVERSIONFLAGS if there is no +# SHLIBVERSION nor LDMODULEVERSION provided +test.write('foo.c', foo_c_src) +test.write('SConstruct', "LoadableModule('foo','foo.c')\n") +test.run() +test.fail_test(test.match_re_dotall(test.stdout(), versionflags)) +test.run(arguments = ['-c']) + +for versionvar in ['SHLIBVERSION', 'LDMODULEVERSION']: + test = TestSCons.TestSCons() + test.write('foo.c', foo_c_src) + test.write('SConstruct', "LoadableModule('foo','foo.c',%s='1.2.3')\n" % versionvar) + test.run(stdout = versionflags, match = TestSCons.match_re_dotall) + test.run(arguments = ['-c']) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/LINK/SHLIBVERSIONFLAGS.py b/test/LINK/SHLIBVERSIONFLAGS.py index d8fd2e6..7f7975f 100644 --- a/test/LINK/SHLIBVERSIONFLAGS.py +++ b/test/LINK/SHLIBVERSIONFLAGS.py @@ -31,8 +31,6 @@ import TestSCons import SCons.Platform import SCons.Defaults -linkers = [ 'gnulink', 'cyglink', 'sunlink' ] - foo_c_src = "void foo() {}\n" env = SCons.Defaults.DefaultEnvironment() @@ -40,15 +38,27 @@ platform = SCons.Platform.platform_default() tool_list = SCons.Platform.DefaultToolList(platform, env) test = TestSCons.TestSCons() -test.write('foo.c', foo_c_src) -test.write('SConstruct', "SharedLibrary('foo','foo.c',SHLIBVERSION='1.2.3')\n") - if 'gnulink' in tool_list: - test.run(stdout = r".+ -Wl,-Bsymbolic -Wl,-soname=libfoo.so.1( .+)+", match = TestSCons.match_re_dotall) - test.run(arguments = ['-c']) + versionflags = r".+ -Wl,-Bsymbolic -Wl,-soname=libfoo.so.1( .+)+" elif 'sunlink' in tool_list: - test.run(stdout = r".+ -h libfoo.so.1( .+)+", match = TestSCons.match_re_dotall) - test.run(arguments = ['-c']) + versionflags = r".+ -h libfoo.so.1( .+)+" +else: + test.skip_test('No testable likers found, skipping the test\n') + + +# stdout must not contain SHLIBVERSIONFLAGS if there is no SHLIBVERSION provided +test.write('foo.c', foo_c_src) +test.write('SConstruct', "SharedLibrary('foo','foo.c')\n") +test.run() +test.fail_test(test.match_re_dotall(test.stdout(), versionflags)) +test.run(arguments = ['-c']) + +# stdout must contain SHLIBVERSIONFLAGS if there is SHLIBVERSION provided +test = TestSCons.TestSCons() +test.write('foo.c', foo_c_src) +test.write('SConstruct', "SharedLibrary('foo','foo.c',SHLIBVERSION='1.2.3')\n") +test.run(stdout = versionflags, match = TestSCons.match_re_dotall) +test.run(arguments = ['-c']) test.pass_test() -- cgit v0.12 From 96ba1793cf7346a6fdbee6bfd843cdbd3efebedf Mon Sep 17 00:00:00 2001 From: Bill Date: Sat, 14 May 2016 15:37:00 -0700 Subject: Fix re-raising exception so the syntax will work for both python3 and python2. --- src/engine/SCons/Taskmaster.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/engine/SCons/Taskmaster.py b/src/engine/SCons/Taskmaster.py index ddafeb9..0f4fd21 100644 --- a/src/engine/SCons/Taskmaster.py +++ b/src/engine/SCons/Taskmaster.py @@ -22,6 +22,8 @@ from __future__ import print_function +import sys + __doc__ = """ Generic Taskmaster module for the SCons build engine. @@ -539,8 +541,11 @@ class Task(object): except ValueError: exc_type, exc_value = exc exc_traceback = None - # raise exc_type, exc_value, exc_traceback - raise exc_type(exc_value).with_traceback(exc_traceback) + + if sys.version_info[0] == 2: + exec("raise exc_type, exc_value, exc_traceback") + else: # sys.version_info[0] == 3: + exec("raise exc_type(exc_value).with_traceback(exc_traceback)") # raise e.__class__, e.__class__(e), sys.exc_info()[2] -- cgit v0.12 From 9f4e808d1b38635151876a6ee513eae279b48c19 Mon Sep 17 00:00:00 2001 From: Bill Date: Sat, 14 May 2016 15:41:52 -0700 Subject: Fix print() --- test/MSVS/vs-10.0-exec.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/MSVS/vs-10.0-exec.py b/test/MSVS/vs-10.0-exec.py index 86b4042..1a4b59a 100644 --- a/test/MSVS/vs-10.0-exec.py +++ b/test/MSVS/vs-10.0-exec.py @@ -55,7 +55,7 @@ if not msvs_version in test.msvs_versions(): test.run(arguments = '-n -q -Q -f -', stdin = """\ env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s') -print "os.environ.update(%%s)" %% repr(env['ENV']) +print("os.environ.update(%%s)" %% repr(env['ENV'])) """ % locals()) exec(test.stdout()) -- cgit v0.12 From df76f938024f9d1ee96166bd9660886acd99f5de Mon Sep 17 00:00:00 2001 From: Bill Date: Sat, 14 May 2016 15:42:36 -0700 Subject: Fix print() --- test/Win32/bad-drive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Win32/bad-drive.py b/test/Win32/bad-drive.py index 4d0d6e9..67a287a 100644 --- a/test/Win32/bad-drive.py +++ b/test/Win32/bad-drive.py @@ -59,7 +59,7 @@ test.write('SConstruct', """ def cat(env, source, target): target = str(target[0]) source = list(map(str, source)) - print 'cat(%%s) > %%s' %% (source, target) + print('cat(%%s) > %%s' %% (source, target)) f = open(target, "wb") for src in source: f.write(open(src, "rb").read()) -- cgit v0.12 From be27b009e8b59ff8b6605459bf39fe8590a37cf0 Mon Sep 17 00:00:00 2001 From: Bill Date: Sat, 14 May 2016 15:43:31 -0700 Subject: Fix print() --- test/Win32/mingw.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Win32/mingw.py b/test/Win32/mingw.py index 6b23314..80067bc 100644 --- a/test/Win32/mingw.py +++ b/test/Win32/mingw.py @@ -47,7 +47,7 @@ from SCons.Tool.mingw import exists import sys env = Environment() if exists(env): - print 'mingw exists' + print('mingw exists') sys.exit(0) """) -- cgit v0.12 From 39d873ea2789008bb153026d730c3a6541331be4 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Sun, 15 May 2016 13:13:31 +0100 Subject: Fixed Fortran tests which were throughing missing include directory warning. Warning added in gcc5. --- test/Fortran/F77FLAGS.py | 5 ++++- test/Fortran/FORTRANFLAGS.py | 5 ++++- test/Fortran/SHF77FLAGS.py | 5 ++++- test/Fortran/SHFORTRANFLAGS.py | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/test/Fortran/F77FLAGS.py b/test/Fortran/F77FLAGS.py index b708f9e..342adac 100644 --- a/test/Fortran/F77FLAGS.py +++ b/test/Fortran/F77FLAGS.py @@ -77,6 +77,9 @@ g77 = test.detect_tool(fc) if g77: + directory = 'x' + test.subdir(directory) + test.write("wrapper.py", """import os import sys @@ -87,7 +90,7 @@ os.system(" ".join(sys.argv[1:])) test.write('SConstruct', """ foo = Environment(F77 = '%(fc)s', tools = ['default', 'f77'], F77FILESUFFIXES = [".f"]) f77 = foo.Dictionary('F77') -bar = foo.Clone(F77 = r'%(_python_)s wrapper.py ' + f77, F77FLAGS = '-Ix') +bar = foo.Clone(F77 = r'%(_python_)s wrapper.py ' + f77, F77FLAGS = '-I%(directory)s') foo.Program(target = 'foo', source = 'foo.f') bar.Program(target = 'bar', source = 'bar.f') """ % locals()) diff --git a/test/Fortran/FORTRANFLAGS.py b/test/Fortran/FORTRANFLAGS.py index 8c5e781..150000a 100644 --- a/test/Fortran/FORTRANFLAGS.py +++ b/test/Fortran/FORTRANFLAGS.py @@ -95,6 +95,9 @@ g77 = test.detect_tool(fc) if g77: + directory = 'x' + test.subdir(directory) + test.write("wrapper.py", """import os import sys @@ -105,7 +108,7 @@ os.system(" ".join(sys.argv[1:])) test.write('SConstruct', """ foo = Environment(FORTRAN = '%(fc)s') f77 = foo.Dictionary('FORTRAN') -bar = foo.Clone(FORTRAN = r'%(_python_)s wrapper.py ' + f77, FORTRANFLAGS = '-Ix') +bar = foo.Clone(FORTRAN = r'%(_python_)s wrapper.py ' + f77, FORTRANFLAGS = '-I%(directory)s') foo.Program(target = 'foo', source = 'foo.f') bar.Program(target = 'bar', source = 'bar.f') """ % locals()) diff --git a/test/Fortran/SHF77FLAGS.py b/test/Fortran/SHF77FLAGS.py index 644b827..79e46f3 100644 --- a/test/Fortran/SHF77FLAGS.py +++ b/test/Fortran/SHF77FLAGS.py @@ -75,6 +75,9 @@ g77 = test.detect_tool(fc) if g77: + directory = 'x' + test.subdir(directory) + test.write("wrapper.py", """import os import sys @@ -87,7 +90,7 @@ foo = Environment(SHF77 = '%(fc)s') shf77 = foo.Dictionary('SHF77') bar = foo.Clone(SHF77 = r'%(_python_)s wrapper.py ' + shf77, tools = ["default", 'f77'], F77FILESUFFIXES = [".f"]) -bar.Append(SHF77FLAGS = '-Ix') +bar.Append(SHF77FLAGS = '-I%(directory)s') foo.SharedLibrary(target = 'foo/foo', source = 'foo.f') bar.SharedLibrary(target = 'bar/bar', source = 'bar.f') """ % locals()) diff --git a/test/Fortran/SHFORTRANFLAGS.py b/test/Fortran/SHFORTRANFLAGS.py index 11116f4..8e6f019 100644 --- a/test/Fortran/SHFORTRANFLAGS.py +++ b/test/Fortran/SHFORTRANFLAGS.py @@ -91,6 +91,9 @@ fortran = test.detect_tool(fc) if fortran: + directory = 'x' + test.subdir(directory) + test.write("wrapper.py", """import os import sys @@ -102,7 +105,7 @@ os.system(" ".join(sys.argv[1:])) foo = Environment(SHFORTRAN = '%(fc)s') shfortran = foo.Dictionary('SHFORTRAN') bar = foo.Clone(SHFORTRAN = r'%(_python_)s wrapper.py ' + shfortran) -bar.Append(SHFORTRANFLAGS = '-Ix') +bar.Append(SHFORTRANFLAGS = '-I%(directory)s') foo.SharedLibrary(target = 'foo/foo', source = 'foo.f') bar.SharedLibrary(target = 'bar/bar', source = 'bar.f') """ % locals()) -- cgit v0.12 From 59543b3ca4070ba5b35c055780a244a29beadd8a Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 15 May 2016 07:55:12 -0700 Subject: fix incorrectly updated print formatting --- src/engine/SCons/Node/FS.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index a4dd5d9..d19afa9 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -3082,7 +3082,7 @@ class File(Base): try: self._createDir() except SCons.Errors.StopError as drive: - raise SCons.Errors.StopError("No drive `%s' for target `{}'.".format(drive, self)) + raise SCons.Errors.StopError("No drive `{}' for target `{}'.".format(drive, self)) # # -- cgit v0.12 From 6ea744952d40c63c98f8b04e1b9a8e7ce73992c3 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 15 May 2016 11:44:48 -0700 Subject: Update logic to pull files from mercurial --- bin/scons_dev_master.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/scons_dev_master.py b/bin/scons_dev_master.py index a8862ea..71842aa 100644 --- a/bin/scons_dev_master.py +++ b/bin/scons_dev_master.py @@ -11,7 +11,7 @@ import sys from Command import CommandRunner, Usage INITIAL_PACKAGES = [ - 'subversion', + 'mercurial', ] INSTALL_PACKAGES = [ @@ -123,7 +123,7 @@ Usage: scons_dev_master.py [-hnqy] [--password PASSWORD] [--username USER] buildbot Install packages for running BuildBot """ - scons_url = 'http://scons.tigris.org/svn/scons/trunk' + scons_url = 'https://bdbaddog@bitbucket.org/scons/scons' sudo = 'sudo' password = '""' username = 'guest' @@ -171,7 +171,7 @@ Usage: scons_dev_master.py [-hnqy] [--password PASSWORD] [--username USER] cmd.run('%(sudo)s apt-get %(yesflag)s upgrade') elif arg == 'checkout': cmd.run('%(sudo)s apt-get %(yesflag)s install %(initial_packages)s') - cmd.run('svn co --username guest --password "" %(scons_url)s') + cmd.run('hg clone" %(scons_url)s') elif arg == 'building': cmd.run('%(sudo)s apt-get %(yesflag)s install %(building_packages)s') elif arg == 'testing': -- cgit v0.12 From c5e30d23ebc878acb8e16e025b6f55aaab43f3a5 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 15 May 2016 12:27:51 -0700 Subject: change to handle py3 changes to byte/string for open().write() --- QMTest/TestCmd.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index 198f586..2fba0a0 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -1731,7 +1731,11 @@ class TestCmd(object): file = self.canonicalize(file) if mode[0] != 'w': raise ValueError("mode must begin with 'w'") - open(file, mode).write(content) + try: + open(file, mode).write(content) + except TypeError as e: + # python 3 default strings are not bytes, but unicode + open(file, mode).write(bytes(content,'utf-8')) # Local Variables: # tab-width:4 -- cgit v0.12 From d64346001c83adce8bdfd6f9e8df191762d11c44 Mon Sep 17 00:00:00 2001 From: Pawel Tomulik Date: Mon, 16 May 2016 00:11:59 +0200 Subject: add blurb to src/CHANGES.txt for #319 --- src/CHANGES.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index b6973b7..25f982a 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -11,6 +11,15 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Whatever John Doe did. + From Paweł Tomulik: + - Fixed the issue with LDMODULEVERSIONFLAGS reported by Tim Jennes + (https://pairlist4.pair.net/pipermail/scons-users/2016-May/004893.html). + An error was causing “-Wl,Bsymbolic” being added to linker's command-line + even when there was no specified value in LDMODULEVERSION and thus no + need for the flags to be specified. + - Added LoadableModule to the list of global functions (DefaultEnvironment + builders). + RELEASE 2.5.0 - Mon, 09 Apr 2016 11:27:42 -0700 From Dirk Baechle: -- cgit v0.12 From fd9c768bf1b749a15d56481a49f7d60dd22a7ef6 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 15 May 2016 15:16:34 -0700 Subject: revert some py3 changes which fail no py2 on windows and any platform/python without dbm module installed. Revisit py3 issues after we get py2 working again --- src/script/sconsign.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/script/sconsign.py b/src/script/sconsign.py index 6f49858..e046a2c 100644 --- a/src/script/sconsign.py +++ b/src/script/sconsign.py @@ -187,7 +187,9 @@ sys.path = libs + sys.path import SCons.compat import whichdb -import dbm + +# was added for py3, but breaks py2 on windows.. +#import dbm import time import pickle import imp @@ -205,8 +207,14 @@ def my_whichdb(filename): pass return _orig_whichdb(filename) + +# Should work on python2 _orig_whichdb = whichdb.whichdb -dbm.whichdb = my_whichdb +whichdb.whichdb = my_whichdb + +# was changed for python3 +#_orig_whichdb = whichdb.whichdb +#dbm.whichdb = my_whichdb def my_import(mname): if '.' in mname: @@ -523,7 +531,9 @@ if Do_Call: Do_Call(a) else: for a in args: - dbm_name = dbm.whichdb(a) + # changed for py3 compat, broke py2 on windows + # dbm_name = dbm.whichdb(a) + dbm_name = whichdb.whichdb(a) if dbm_name: Map_Module = {'SCons.dblite' : 'dblite'} if dbm_name != "SCons.dblite": -- cgit v0.12 From 013d87ae5921b0bb55232a38257433ca256ee197 Mon Sep 17 00:00:00 2001 From: ptomulik Date: Mon, 16 May 2016 11:01:17 +0200 Subject: correct typos in test/LINK/{SHLIB,LDMODULE}VERSIONFLAGS.py --- test/LINK/LDMODULEVERSIONFLAGS.py | 2 +- test/LINK/SHLIBVERSIONFLAGS.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/LINK/LDMODULEVERSIONFLAGS.py b/test/LINK/LDMODULEVERSIONFLAGS.py index 5a9a847..0683b72 100644 --- a/test/LINK/LDMODULEVERSIONFLAGS.py +++ b/test/LINK/LDMODULEVERSIONFLAGS.py @@ -44,7 +44,7 @@ if 'gnulink' in tool_list: elif 'sunlink' in tool_list: versionflags = r".+ -h libfoo.so.1( .+)+" else: - test.skip_test('No testable likers found, skipping the test\n') + test.skip_test('No testable linkers found, skipping the test\n') # We expect stdout to not contain LDMODULEVERSIONFLAGS if there is no diff --git a/test/LINK/SHLIBVERSIONFLAGS.py b/test/LINK/SHLIBVERSIONFLAGS.py index 7f7975f..aae8843 100644 --- a/test/LINK/SHLIBVERSIONFLAGS.py +++ b/test/LINK/SHLIBVERSIONFLAGS.py @@ -43,7 +43,7 @@ if 'gnulink' in tool_list: elif 'sunlink' in tool_list: versionflags = r".+ -h libfoo.so.1( .+)+" else: - test.skip_test('No testable likers found, skipping the test\n') + test.skip_test('No testable linkers found, skipping the test\n') # stdout must not contain SHLIBVERSIONFLAGS if there is no SHLIBVERSION provided -- cgit v0.12 From b763362d906af8e23409a1f5d3dc782b0ca3cc91 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Wed, 18 May 2016 19:09:05 -0700 Subject: Fix py2/3 StringIO import --- src/engine/SCons/Script/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py index 974841c..66120e4 100644 --- a/src/engine/SCons/Script/__init__.py +++ b/src/engine/SCons/Script/__init__.py @@ -41,7 +41,12 @@ start_time = time.time() import collections import os -import StringIO + +try: + from StringIO import StringIO +except ImportError: + from io import StringIO + import sys # Special chicken-and-egg handling of the "--debug=memoizer" flag: -- cgit v0.12 From 7d7012b21a1434ab03cead57e4b8926c8b5ef153 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Wed, 18 May 2016 19:58:51 -0700 Subject: fix for module loading to us importlib instead of imp (which no longer works in pyton3) --- src/engine/SCons/Tool/__init__.py | 68 +++++++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 20 deletions(-) diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index 4cd242b..87ebb98 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -38,11 +38,13 @@ tool definition. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import imp +import importlib import sys import re import os import shutil + import SCons.Builder import SCons.Errors import SCons.Node.FS @@ -114,30 +116,56 @@ class Tool(object): sys.path = self.toolpath + sys.path try: + # Try site_tools first + return importlib.import_module(self.name) + except ImportError as e: + # Then try modules in main distribution + return importlib.import_module('SCons.Tool.'+self.name) + except ImportError as e: + if str(e) != "No module named %s" % self.name: + raise SCons.Errors.EnvironmentError(e) try: - file, path, desc = imp.find_module(self.name, self.toolpath) - try: - return imp.load_module(self.name, file, path, desc) - finally: - if file: - file.close() - except ImportError as e: - if str(e)!="No module named %s"%self.name: - raise SCons.Errors.EnvironmentError(e) - try: - import zipimport - except ImportError: - pass - else: - for aPath in self.toolpath: - try: - importer = zipimport.zipimporter(aPath) - return importer.load_module(self.name) - except ImportError as e: - pass + import zipimport + except ImportError: + pass + else: + for aPath in self.toolpath: + try: + importer = zipimport.zipimporter(aPath) + return importer.load_module(self.name) + except ImportError as e: + pass + finally: sys.path = oldpythonpath + # old code + # try: + # try: + # file, path, desc = imp.find_module(self.name, self.toolpath) + # try: + # return imp.load_module(self.name, file, path, desc) + # + # finally: + # if file: + # file.close() + # except ImportError as e: + # if str(e)!="No module named %s"%self.name: + # raise SCons.Errors.EnvironmentError(e) + # try: + # import zipimport + # except ImportError: + # pass + # else: + # for aPath in self.toolpath: + # try: + # importer = zipimport.zipimporter(aPath) + # return importer.load_module(self.name) + # except ImportError as e: + # pass + # finally: + # sys.path = oldpythonpath + full_name = 'SCons.Tool.' + self.name try: return sys.modules[full_name] -- cgit v0.12 From 01ab580ffdd90459f729d44efa6a3f0cc733fbf5 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 19 May 2016 09:03:06 -0700 Subject: Fix unicode type code to handle py2/3 --- src/engine/SCons/Util.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index a5a92fa..0be6196 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -55,9 +55,13 @@ except ImportError as e: MethodType = types.MethodType FunctionType = types.FunctionType -try: unicode -except NameError: UnicodeType = None -else: UnicodeType = unicode + +try: + unicode +except NameError: + UnicodeType = str +else: + UnicodeType = unicode def dictify(keys, values, result={}): for k, v in zip(keys, values): @@ -172,7 +176,7 @@ class DisplayEngine(object): return if append_newline: text = text + '\n' try: - sys.stdout.write(unicode(text)) + sys.stdout.write(UnicodeType(text)) except IOError: # Stdout might be connected to a pipe that has been closed # by now. The most likely reason for the pipe being closed -- cgit v0.12 From 6cb5d61fa6244c37b2aeb0255e47b9b749d3f4d1 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 19 May 2016 09:10:34 -0700 Subject: minor improvement to Tool loading code for py2/3 compat --- src/engine/SCons/Tool/__init__.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index 87ebb98..1590053 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -120,21 +120,22 @@ class Tool(object): return importlib.import_module(self.name) except ImportError as e: # Then try modules in main distribution - return importlib.import_module('SCons.Tool.'+self.name) - except ImportError as e: - if str(e) != "No module named %s" % self.name: - raise SCons.Errors.EnvironmentError(e) try: - import zipimport - except ImportError: - pass - else: - for aPath in self.toolpath: - try: - importer = zipimport.zipimporter(aPath) - return importer.load_module(self.name) - except ImportError as e: - pass + return importlib.import_module('SCons.Tool.'+self.name) + except ImportError as e: + if str(e) != "No module named %s" % self.name: + raise SCons.Errors.EnvironmentError(e) + try: + import zipimport + except ImportError: + pass + else: + for aPath in self.toolpath: + try: + importer = zipimport.zipimporter(aPath) + return importer.load_module(self.name) + except ImportError as e: + pass finally: sys.path = oldpythonpath -- cgit v0.12 From 2b20141f5bc6fb7aedd9a24e4c8079e82d52d260 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 19 May 2016 10:53:46 -0700 Subject: Fixing StringIO usage. --- src/engine/SCons/Script/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py index 66120e4..291c108 100644 --- a/src/engine/SCons/Script/__init__.py +++ b/src/engine/SCons/Script/__init__.py @@ -269,7 +269,7 @@ def HelpFunction(text, append=False): global help_text if help_text is None: if append: - s = StringIO.StringIO() + s = StringIO() PrintHelp(s) help_text = s.getvalue() s.close() -- cgit v0.12 From 561eda349061019df9c8aa904de62896b12472c0 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 23 May 2016 10:00:43 -0700 Subject: use old tool loading code for py2, and new code (not quite working yet) for py3 --- src/engine/SCons/Tool/__init__.py | 101 ++++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 48 deletions(-) diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index 1590053..d75d7ca 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -115,57 +115,62 @@ class Tool(object): oldpythonpath = sys.path sys.path = self.toolpath + sys.path - try: - # Try site_tools first - return importlib.import_module(self.name) - except ImportError as e: - # Then try modules in main distribution + + if False and sys.version_info[0] < 3: + # Py 2 code try: - return importlib.import_module('SCons.Tool.'+self.name) + try: + file, path, desc = imp.find_module(self.name, self.toolpath) + try: + return imp.load_module(self.name, file, path, desc) + + finally: + if file: + file.close() + except ImportError as e: + if str(e)!="No module named %s"%self.name: + raise SCons.Errors.EnvironmentError(e) + try: + import zipimport + except ImportError: + pass + else: + for aPath in self.toolpath: + try: + importer = zipimport.zipimporter(aPath) + return importer.load_module(self.name) + except ImportError as e: + pass + finally: + sys.path = oldpythonpath + else: + # Py 3 code + try: + # Try site_tools first + return importlib.import_module(self.name) except ImportError as e: - if str(e) != "No module named %s" % self.name: - raise SCons.Errors.EnvironmentError(e) + # Then try modules in main distribution try: - import zipimport - except ImportError: - pass - else: - for aPath in self.toolpath: - try: - importer = zipimport.zipimporter(aPath) - return importer.load_module(self.name) - except ImportError as e: - pass - - finally: - sys.path = oldpythonpath - - # old code - # try: - # try: - # file, path, desc = imp.find_module(self.name, self.toolpath) - # try: - # return imp.load_module(self.name, file, path, desc) - # - # finally: - # if file: - # file.close() - # except ImportError as e: - # if str(e)!="No module named %s"%self.name: - # raise SCons.Errors.EnvironmentError(e) - # try: - # import zipimport - # except ImportError: - # pass - # else: - # for aPath in self.toolpath: - # try: - # importer = zipimport.zipimporter(aPath) - # return importer.load_module(self.name) - # except ImportError as e: - # pass - # finally: - # sys.path = oldpythonpath + return importlib.import_module('SCons.Tool.'+self.name) + except ImportError as e: + if str(e) != "No module named %s" % self.name: + raise SCons.Errors.EnvironmentError(e) + try: + import zipimport + except ImportError: + pass + else: + for aPath in self.toolpath: + try: + importer = zipimport.zipimporter(aPath) + return importer.load_module(self.name) + except ImportError as e: + pass + + finally: + sys.path = oldpythonpath + + full_name = 'SCons.Tool.' + self.name try: -- cgit v0.12 From b387e34357c968d0855c525c7e838657a957ff01 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 23 May 2016 10:35:46 -0700 Subject: Remove debug code to reenable python version specific tool module loading code. --- src/engine/SCons/Tool/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index d75d7ca..45d0aa1 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -116,7 +116,7 @@ class Tool(object): sys.path = self.toolpath + sys.path - if False and sys.version_info[0] < 3: + if sys.version_info[0] < 3: # Py 2 code try: try: -- cgit v0.12 -- cgit v0.12 From 29a46d09fdb0bc3e8d7b18dca6ac8495e96c5eb4 Mon Sep 17 00:00:00 2001 From: Alexey Klimkin Date: Thu, 26 May 2016 11:03:00 -0700 Subject: Optimize implicit dependency scan When calculating path, performance spent on two things: - Variable expansion, if CPPPATH contains any variables - CPPPATH flattening Use memoization to optimize PATH evaluation across all dependencies per node. --- src/engine/SCons/Node/__init__.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 1a76b60..d3cea53 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -926,9 +926,9 @@ class Node(object): scanner's recursive flag says that we should. """ nodes = [self] - seen = {} - seen[self] = 1 + seen = set(nodes) dependencies = [] + path_memo = {} root_node_scanner = self._get_scanner(env, initial_scanner, None, kw) @@ -936,30 +936,32 @@ class Node(object): node = nodes.pop(0) scanner = node._get_scanner(env, initial_scanner, root_node_scanner, kw) - if not scanner: continue - path = path_func(scanner) + try: + path = path_memo[scanner] + except KeyError: + path = path_func(scanner) + path_memo[scanner] = path included_deps = [x for x in node.get_found_includes(env, scanner, path) if x not in seen] if included_deps: dependencies.extend(included_deps) - for dep in included_deps: - seen[dep] = 1 + seen.update(included_deps) nodes.extend(scanner.recurse_nodes(included_deps)) return dependencies def _get_scanner(self, env, initial_scanner, root_node_scanner, kw): - if not initial_scanner: + if initial_scanner: + # handle explicit scanner case + scanner = initial_scanner.select(self) + else: # handle implicit scanner case scanner = self.get_env_scanner(env, kw) if scanner: scanner = scanner.select(self) - else: - # handle explicit scanner case - scanner = initial_scanner.select(self) if not scanner: # no scanner could be found for the given node's scanner key; -- cgit v0.12 From e4b799e8dc348159c5f2d70bdf49819c4d8270bc Mon Sep 17 00:00:00 2001 From: Daniel Holth Date: Sun, 5 Jun 2016 20:23:12 -0400 Subject: avoid using __slots__ on Node and Executor (but only on PyPy) --- src/engine/SCons/Executor.py | 6 ++--- src/engine/SCons/Node/__init__.py | 5 +++- src/engine/SCons/compat/__init__.py | 47 +++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 4 deletions(-) diff --git a/src/engine/SCons/Executor.py b/src/engine/SCons/Executor.py index 7107fde..dd5088d 100644 --- a/src/engine/SCons/Executor.py +++ b/src/engine/SCons/Executor.py @@ -35,7 +35,7 @@ import SCons.Debug from SCons.Debug import logInstanceCreation import SCons.Errors import SCons.Memoize - +from SCons.compat import with_metaclass, NoSlotsPyPy class Batch(object): """Remembers exact association between targets @@ -154,7 +154,7 @@ _execute_str_map = {0 : execute_null_str, 1 : execute_actions_str} -class Executor(object): +class Executor(object, with_metaclass(NoSlotsPyPy)): """A class for controlling instances of executing an action. This largely exists to hold a single association of an action, @@ -580,7 +580,7 @@ def get_NullEnvironment(): nullenv = NullEnvironment() return nullenv -class Null(object): +class Null(object, with_metaclass(NoSlotsPyPy)): """A null Executor, with a null build Environment, that does nothing when the rest of the methods call it. diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 1a76b60..e714172 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -57,6 +57,8 @@ import SCons.Util from SCons.Debug import Trace +from SCons.compat import with_metaclass, NoSlotsPyPy + print_duplicate = 0 def classname(obj): @@ -489,7 +491,8 @@ class BuildInfoBase(object): if key not in ('__weakref__',): setattr(self, key, value) -class Node(object): + +class Node(object, with_metaclass(NoSlotsPyPy)): """The base Node class, for entities that we know how to build, or use to build other Nodes. """ diff --git a/src/engine/SCons/compat/__init__.py b/src/engine/SCons/compat/__init__.py index 0ddbdd5..285c4ac 100644 --- a/src/engine/SCons/compat/__init__.py +++ b/src/engine/SCons/compat/__init__.py @@ -63,6 +63,8 @@ import os import sys import imp # Use the "imp" module to protect imports from fixers. +PYPY = hasattr(sys, 'pypy_translation_info') + def import_as(module, name): """ Imports the specified module (from our local directory) as the @@ -135,6 +137,51 @@ except AttributeError: del _UserString +def with_metaclass(meta, *bases): + """ + Function from jinja2/_compat.py. License: BSD. + + Use it like this:: + + class BaseForm(object): + pass + + class FormType(type): + pass + + class Form(with_metaclass(FormType, BaseForm)): + pass + + This requires a bit of explanation: the basic idea is to make a + dummy metaclass for one level of class instantiation that replaces + itself with the actual metaclass. Because of internal type checks + we also need to make sure that we downgrade the custom metaclass + for one level to something closer to type (that's why __call__ and + __init__ comes back from type etc.). + + This has the advantage over six.with_metaclass of not introducing + dummy classes into the final MRO. + """ + class metaclass(meta): + __call__ = type.__call__ + __init__ = type.__init__ + def __new__(cls, name, this_bases, d): + if this_bases is None: + return type.__new__(cls, name, (), d) + return meta(name, bases, d) + return metaclass('temporary_class', None, {}) + + +class NoSlotsPyPy(type): + """ + Workaround for PyPy not working well with __slots__ and __class__ assignment. + """ + def __new__(meta, name, bases, dct): + if PYPY and '__slots__' in dct: + dct['__slats__'] = dct.pop('__slots__') + return super(NoSlotsPyPy, meta).__new__(meta, name, bases, dct) + + # Local Variables: # tab-width:4 # indent-tabs-mode:nil -- cgit v0.12 From 3128ce66f69ee2be54080caea8d86f817885616b Mon Sep 17 00:00:00 2001 From: Daniel Holth Date: Sun, 5 Jun 2016 22:57:26 -0400 Subject: fix some tests for pypy The major category of broken test is that which depends on garbage collection to flush and close an open file. Also, the empty list is apparently not a singleton in pypy. --- QMTest/TestCmd.py | 11 ++++++----- src/engine/SCons/ActionTests.py | 30 ++++++++++++++++++------------ 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index 2fba0a0..b0a456b 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -1731,11 +1731,12 @@ class TestCmd(object): file = self.canonicalize(file) if mode[0] != 'w': raise ValueError("mode must begin with 'w'") - try: - open(file, mode).write(content) - except TypeError as e: - # python 3 default strings are not bytes, but unicode - open(file, mode).write(bytes(content,'utf-8')) + with open(file, mode) as f: + try: + f.write(content) + except TypeError as e: + # python 3 default strings are not bytes, but unicode + f.write(bytes(content,'utf-8')) # Local Variables: # tab-width:4 diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py index 3eee4b6..9007183 100644 --- a/src/engine/SCons/ActionTests.py +++ b/src/engine/SCons/ActionTests.py @@ -231,7 +231,7 @@ def test_positional_args(pos_callback, cmd, **kw): """ act = SCons.Action.Action(cmd, **kw) pos_callback(act) - assert act.varlist is (), act.varlist + assert act.varlist == (), act.varlist if not isinstance(act, SCons.Action._ActionAction): # only valid cmdstrfunc is None @@ -316,7 +316,7 @@ class ActionTestCase(unittest.TestCase): """ a1 = SCons.Action.Action(["x", "y", "z", [ "a", "b", "c"]]) assert isinstance(a1, SCons.Action.ListAction), a1 - assert a1.varlist is (), a1.varlist + assert a1.varlist == (), a1.varlist assert isinstance(a1.list[0], SCons.Action.CommandAction), a1.list[0] assert a1.list[0].cmd_list == "x", a1.list[0].cmd_list assert isinstance(a1.list[1], SCons.Action.CommandAction), a1.list[1] @@ -328,7 +328,7 @@ class ActionTestCase(unittest.TestCase): a2 = SCons.Action.Action("x\ny\nz") assert isinstance(a2, SCons.Action.ListAction), a2 - assert a2.varlist is (), a2.varlist + assert a2.varlist == (), a2.varlist assert isinstance(a2.list[0], SCons.Action.CommandAction), a2.list[0] assert a2.list[0].cmd_list == "x", a2.list[0].cmd_list assert isinstance(a2.list[1], SCons.Action.CommandAction), a2.list[1] @@ -341,7 +341,7 @@ class ActionTestCase(unittest.TestCase): a3 = SCons.Action.Action(["x", foo, "z"]) assert isinstance(a3, SCons.Action.ListAction), a3 - assert a3.varlist is (), a3.varlist + assert a3.varlist == (), a3.varlist assert isinstance(a3.list[0], SCons.Action.CommandAction), a3.list[0] assert a3.list[0].cmd_list == "x", a3.list[0].cmd_list assert isinstance(a3.list[1], SCons.Action.FunctionAction), a3.list[1] @@ -351,7 +351,7 @@ class ActionTestCase(unittest.TestCase): a4 = SCons.Action.Action(["x", "y"], strfunction=foo) assert isinstance(a4, SCons.Action.ListAction), a4 - assert a4.varlist is (), a4.varlist + assert a4.varlist == (), a4.varlist assert isinstance(a4.list[0], SCons.Action.CommandAction), a4.list[0] assert a4.list[0].cmd_list == "x", a4.list[0].cmd_list assert a4.list[0].strfunction == foo, a4.list[0].strfunction @@ -361,7 +361,7 @@ class ActionTestCase(unittest.TestCase): a5 = SCons.Action.Action("x\ny", strfunction=foo) assert isinstance(a5, SCons.Action.ListAction), a5 - assert a5.varlist is (), a5.varlist + assert a5.varlist == (), a5.varlist assert isinstance(a5.list[0], SCons.Action.CommandAction), a5.list[0] assert a5.list[0].cmd_list == "x", a5.list[0].cmd_list assert a5.list[0].strfunction == foo, a5.list[0].strfunction @@ -1533,7 +1533,8 @@ class FunctionActionTestCase(unittest.TestCase): global count count = count + 1 for t in target: - open(t, 'w').write("function1\n") + with open(t, 'w') as f: + f.write("function1\n") return 1 act = SCons.Action.FunctionAction(function1, {}) @@ -1548,7 +1549,8 @@ class FunctionActionTestCase(unittest.TestCase): class class1a(object): def __init__(self, target, source, env): - open(env['out'], 'w').write("class1a\n") + with open(env['out'], 'w') as f: + f.write("class1a\n") act = SCons.Action.FunctionAction(class1a, {}) r = act([], [], Environment(out = outfile)) @@ -1558,7 +1560,8 @@ class FunctionActionTestCase(unittest.TestCase): class class1b(object): def __call__(self, target, source, env): - open(env['out'], 'w').write("class1b\n") + with open(env['out'], 'w') as f: + f.write("class1b\n") return 2 act = SCons.Action.FunctionAction(class1b(), {}) @@ -1710,17 +1713,20 @@ class ListActionTestCase(unittest.TestCase): cmd2 = r'%s %s %s syzygy' % (_python_, act_py, outfile) def function2(target, source, env): - open(env['out'], 'a').write("function2\n") + with open(env['out'], 'a') as f: + f.write("function2\n") return 0 class class2a(object): def __call__(self, target, source, env): - open(env['out'], 'a').write("class2a\n") + with open(env['out'], 'a') as f: + f.write("class2a\n") return 0 class class2b(object): def __init__(self, target, source, env): - open(env['out'], 'a').write("class2b\n") + with open(env['out'], 'a') as f: + f.write("class2b\n") act = SCons.Action.ListAction([cmd2, function2, class2a(), class2b]) r = act([], [], Environment(out = outfile)) assert isinstance(r.status, class2b), r.status -- cgit v0.12 From 88958d1f4beae35315b26ec1b32b38eeb41946f8 Mon Sep 17 00:00:00 2001 From: Daniel Holth Date: Mon, 6 Jun 2016 20:05:23 -0400 Subject: just throw away __slots__ on pypy --- src/engine/SCons/compat/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/compat/__init__.py b/src/engine/SCons/compat/__init__.py index 285c4ac..6f20b73 100644 --- a/src/engine/SCons/compat/__init__.py +++ b/src/engine/SCons/compat/__init__.py @@ -178,7 +178,7 @@ class NoSlotsPyPy(type): """ def __new__(meta, name, bases, dct): if PYPY and '__slots__' in dct: - dct['__slats__'] = dct.pop('__slots__') + dct.pop('__slots__') return super(NoSlotsPyPy, meta).__new__(meta, name, bases, dct) -- cgit v0.12 From f8fbe351d2677bc2e4e3094e905c579825c1582a Mon Sep 17 00:00:00 2001 From: Daniel Holth Date: Wed, 15 Jun 2016 19:46:00 -0400 Subject: wrap several frequently-used open() calls in with statements --- src/engine/SCons/Node/FS.py | 4 ++-- src/engine/SCons/Node/__init__.py | 3 ++- src/engine/SCons/Scanner/C.py | 5 ++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index d19afa9..71511b5 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -1211,9 +1211,9 @@ class FS(LocalFS): def getcwd(self): if hasattr(self, "_cwd"): - return self._cwd + return self._cwd else: - return "" + return "" def chdir(self, dir, change_os_dir=0): """Change the current working directory for lookups. diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index e714172..51762a3 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -214,7 +214,8 @@ def get_contents_file(node): return '' fname = node.rfile().get_abspath() try: - contents = open(fname, "rb").read() + with open(fname, "rb") as fp: + contents = fp.read() except EnvironmentError as e: if not e.filename: e.filename = fname diff --git a/src/engine/SCons/Scanner/C.py b/src/engine/SCons/Scanner/C.py index 3b34b88..c2e50a6 100644 --- a/src/engine/SCons/Scanner/C.py +++ b/src/engine/SCons/Scanner/C.py @@ -58,12 +58,11 @@ class SConsCPPScanner(SCons.cpp.PreProcessor): return result def read_file(self, file): try: - fp = open(str(file.rfile())) + with open(str(file.rfile())) as fp: + return fp.read() except EnvironmentError as e: self.missing.append((file, self.current_file)) return '' - else: - return fp.read() def dictify_CPPDEFINES(env): cppdefines = env.get('CPPDEFINES', {}) -- cgit v0.12 From d31cff4a15d3adf3842826c3af8317a2ba050038 Mon Sep 17 00:00:00 2001 From: Daniel Holth Date: Thu, 16 Jun 2016 22:46:03 -0400 Subject: add __main__.py for 'python -m SCons' --- src/engine/SCons/__main__.py | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/engine/SCons/__main__.py diff --git a/src/engine/SCons/__main__.py b/src/engine/SCons/__main__.py new file mode 100644 index 0000000..5a3aadb --- /dev/null +++ b/src/engine/SCons/__main__.py @@ -0,0 +1,5 @@ +if __name__ == "__main__": + import SCons.Script + # this does all the work, and calls sys.exit + # with the proper exit status when done. + SCons.Script.main() -- cgit v0.12 From 16c3e45d786b939f78cf0169be160fd65c679150 Mon Sep 17 00:00:00 2001 From: Daniel Holth Date: Thu, 16 Jun 2016 22:49:38 -0400 Subject: no need for a __main__ guard in __main__.py --- src/engine/SCons/__main__.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/engine/SCons/__main__.py b/src/engine/SCons/__main__.py index 5a3aadb..0dfbb9d 100644 --- a/src/engine/SCons/__main__.py +++ b/src/engine/SCons/__main__.py @@ -1,5 +1,4 @@ -if __name__ == "__main__": - import SCons.Script - # this does all the work, and calls sys.exit - # with the proper exit status when done. - SCons.Script.main() +import SCons.Script +# this does all the work, and calls sys.exit +# with the proper exit status when done. +SCons.Script.main() -- cgit v0.12 From 707a453c9c9db84449c4d3bf214b9ec65f2807db Mon Sep 17 00:00:00 2001 From: Daniel Holth Date: Sun, 19 Jun 2016 22:48:06 -0400 Subject: update CHANGES.txt --- src/CHANGES.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index aab73b4..db52cf0 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -10,6 +10,11 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Whatever John Doe did. + From Daniel Holth: + - Add basic support for PyPy (by deleting __slots__ from Node with a + metaclass on PyPy); wrap most-used open() calls in 'with' statements to + avoid too many open files. + - Add __main__.py for `python -m SCons` in case it is on PYTHONPATH. From Paweł Tomulik: - Fixed the issue with LDMODULEVERSIONFLAGS reported by Tim Jennes -- cgit v0.12 From 1d93e3871ee6858e3bc362aa4e9822c29aadb1a3 Mon Sep 17 00:00:00 2001 From: Daniel Holth Date: Sun, 19 Jun 2016 22:50:06 -0400 Subject: 'with open' in own SConstruct --- SConstruct | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/SConstruct b/SConstruct index 5eded92..c5734af 100644 --- a/SConstruct +++ b/SConstruct @@ -356,7 +356,8 @@ try: if os.path.isfile(dest) or os.path.islink(dest): os.unlink(dest) if not os.path.isdir(dest): - open(dest, 'wb').write(zf.read(name)) + with open(dest, 'wb') as fp: + fp.write(zf.read(name)) except ImportError: if unzip and zip: @@ -371,7 +372,8 @@ def SCons_revision(target, source, env): """ t = str(target[0]) s = source[0].rstr() - contents = open(s, 'rb').read() + with open(s, 'rb') as fp: + contents = fp.read() # Note: We construct the __*__ substitution strings here # so that they don't get replaced when this file gets # copied into the tree for packaging. -- cgit v0.12 From ccf62abac7be516e2947f5badb6bc86021159772 Mon Sep 17 00:00:00 2001 From: Daniel Holth Date: Mon, 20 Jun 2016 19:40:16 -0400 Subject: centralize the preferred pickle protocol; use highest protocol. --- src/engine/SCons/SConsign.py | 6 ++++-- src/engine/SCons/Tool/msvs.py | 15 ++++++++------- src/engine/SCons/compat/__init__.py | 5 +++++ src/engine/SCons/dblite.py | 4 +++- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/engine/SCons/SConsign.py b/src/engine/SCons/SConsign.py index cb089aa..3a5e5c0 100644 --- a/src/engine/SCons/SConsign.py +++ b/src/engine/SCons/SConsign.py @@ -39,6 +39,8 @@ import pickle import SCons.dblite import SCons.Warnings +from SCons.compat import PICKLE_PROTOCOL + def corrupt_dblite_warning(filename): SCons.Warnings.warn(SCons.Warnings.CorruptSConsignWarning, "Ignoring corrupt .sconsign file: %s"%filename) @@ -272,7 +274,7 @@ class DB(Base): path = normcase(self.dir.get_internal_path()) for key, entry in self.entries.items(): entry.convert_to_sconsign() - db[path] = pickle.dumps(self.entries, 1) + db[path] = pickle.dumps(self.entries, PICKLE_PROTOCOL) if sync: try: @@ -360,7 +362,7 @@ class DirFile(Dir): return for key, entry in self.entries.items(): entry.convert_to_sconsign() - pickle.dump(self.entries, file, 1) + pickle.dump(self.entries, file, PICKLE_PROTOCOL) file.close() if fname != self.sconsign: try: diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py index 6df4928..02b9a34 100644 --- a/src/engine/SCons/Tool/msvs.py +++ b/src/engine/SCons/Tool/msvs.py @@ -54,6 +54,7 @@ import SCons.Warnings from .MSCommon import msvc_exists, msvc_setup_env_once from SCons.Defaults import processDefines +from SCons.compat import PICKLE_PROTOCOL ############################################################################## # Below here are the classes and functions for generation of @@ -641,10 +642,10 @@ class _GenerateV6DSP(_DSPGenerator): if self.nokeep == 0: # now we pickle some data and add it to the file -- MSDEV will ignore it. - pdata = pickle.dumps(self.configs,1) + pdata = pickle.dumps(self.configs,PICKLE_PROTOCOL) pdata = base64.encodestring(pdata) self.file.write(pdata + '\n') - pdata = pickle.dumps(self.sources,1) + pdata = pickle.dumps(self.sources,PICKLE_PROTOCOL) pdata = base64.encodestring(pdata) self.file.write(pdata + '\n') @@ -913,10 +914,10 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User): if self.nokeep == 0: # now we pickle some data and add it to the file -- MSDEV will ignore it. - pdata = pickle.dumps(self.configs,1) + pdata = pickle.dumps(self.configs,PICKLE_PROTOCOL) pdata = base64.encodestring(pdata) self.file.write('\n') @@ -1232,10 +1233,10 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): if self.nokeep == 0: # now we pickle some data and add it to the file -- MSDEV will ignore it. - pdata = pickle.dumps(self.configs,1) + pdata = pickle.dumps(self.configs,PICKLE_PROTOCOL) pdata = base64.encodestring(pdata) self.file.write('\n') @@ -1606,7 +1607,7 @@ class _GenerateV7DSW(_DSWGenerator): '\tEndGlobalSection\n') self.file.write('EndGlobal\n') if self.nokeep == 0: - pdata = pickle.dumps(self.configs,1) + pdata = pickle.dumps(self.configs,PICKLE_PROTOCOL) pdata = base64.encodestring(pdata) self.file.write(pdata + '\n') diff --git a/src/engine/SCons/compat/__init__.py b/src/engine/SCons/compat/__init__.py index 6f20b73..9a911f7 100644 --- a/src/engine/SCons/compat/__init__.py +++ b/src/engine/SCons/compat/__init__.py @@ -88,6 +88,11 @@ def rename_module(new, old): # In 3.x, 'pickle' automatically loads the fast version if available. rename_module('pickle', 'cPickle') +# Default pickle protocol. Higher protocols are more efficient/featureful +# but incompatible with older Python versions. On Python 2.7 this is 2. +# Negative numbers choose the highest available protocol. +PICKLE_PROTOCOL=-1 + # TODO: FIXME # In 3.x, 'profile' automatically loads the fast version if available. rename_module('profile', 'cProfile') diff --git a/src/engine/SCons/dblite.py b/src/engine/SCons/dblite.py index b12d320..c32f494 100644 --- a/src/engine/SCons/dblite.py +++ b/src/engine/SCons/dblite.py @@ -4,6 +4,8 @@ from __future__ import print_function import SCons.compat +from SCons.compat import PICKLE_PROTOCOL + import os import pickle import shutil @@ -119,7 +121,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, 1) + self._pickle_dump(self._dict, f, 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 -- cgit v0.12 From b10a8e66e04ed191b27c8d7d33040deabe255714 Mon Sep 17 00:00:00 2001 From: Daniel Holth Date: Tue, 21 Jun 2016 01:06:22 +0000 Subject: CHANGES.txt edited --- src/CHANGES.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index db52cf0..4cf2100 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -15,7 +15,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER metaclass on PyPy); wrap most-used open() calls in 'with' statements to avoid too many open files. - Add __main__.py for `python -m SCons` in case it is on PYTHONPATH. - +  - Always use highest available pickle protocol for efficiency. + From Paweł Tomulik: - Fixed the issue with LDMODULEVERSIONFLAGS reported by Tim Jennes (https://pairlist4.pair.net/pipermail/scons-users/2016-May/004893.html). -- cgit v0.12 From d8f891005dc3edc527e62fd06fa92feab94db61d Mon Sep 17 00:00:00 2001 From: Daniel Holth Date: Tue, 21 Jun 2016 12:24:43 +0000 Subject: use pickle.HIGHEST_PROTOCOL instead of -1 --- src/engine/SCons/compat/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/SCons/compat/__init__.py b/src/engine/SCons/compat/__init__.py index 9a911f7..c6c7214 100644 --- a/src/engine/SCons/compat/__init__.py +++ b/src/engine/SCons/compat/__init__.py @@ -91,7 +91,8 @@ rename_module('pickle', 'cPickle') # Default pickle protocol. Higher protocols are more efficient/featureful # but incompatible with older Python versions. On Python 2.7 this is 2. # Negative numbers choose the highest available protocol. -PICKLE_PROTOCOL=-1 +import pickle +PICKLE_PROTOCOL=pickle.HIGHEST_PROTOCOL # TODO: FIXME # In 3.x, 'profile' automatically loads the fast version if available. -- cgit v0.12 From 1fbc1b90d4ec3eac950865c4dd815f3cc71f70cf Mon Sep 17 00:00:00 2001 From: mlimber Date: Wed, 6 Jul 2016 18:55:07 +0000 Subject: Fix float conversion for Express editions where the version number is reported as "10.0Exp", which fails the float conversion with: Error : ValueError: invalid literal for float(): 10.0Exp. --- src/engine/SCons/Tool/msvs.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py index 6df4928..6e91909 100644 --- a/src/engine/SCons/Tool/msvs.py +++ b/src/engine/SCons/Tool/msvs.py @@ -1844,7 +1844,10 @@ def projectEmitter(target, source, env): targetlist = targetlist + t # Beginning with Visual Studio 2010 for each project file (.vcxproj) we have additional file (.vcxproj.filters) - if float(env['MSVS_VERSION']) >= 10.0: + version_num = 6.0 + if 'MSVS_VERSION' in env: + version_num, suite = msvs_parse_version(env['MSVS_VERSION']) + if version_num >= 10.0: targetlist.append(targetlist[0] + '.filters') return (targetlist, sourcelist) -- cgit v0.12 From 68626be4e6761d2b0835f402da3bb8ae54d80e07 Mon Sep 17 00:00:00 2001 From: mlimber Date: Wed, 6 Jul 2016 19:20:00 +0000 Subject: Updated for Visual Studio Express --- src/CHANGES.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index db52cf0..dc3904c 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -25,6 +25,10 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Added LoadableModule to the list of global functions (DefaultEnvironment builders). + From Matthew Limber: + - Fixed msvs.py for Visual Studio Express editions that would report + "Error : ValueError: invalid literal for float(): 10.0Exp". + RELEASE 2.5.0 - Mon, 09 Apr 2016 11:27:42 -0700 From Dirk Baechle: -- cgit v0.12 From 83e76a293df54101826975c78bbffbe5e8018304 Mon Sep 17 00:00:00 2001 From: mlimber Date: Wed, 6 Jul 2016 19:34:20 +0000 Subject: CHANGES.txt edited online with Bitbucket --- src/CHANGES.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index dc3904c..0bac28f 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -25,7 +25,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Added LoadableModule to the list of global functions (DefaultEnvironment builders). - From Matthew Limber: + From M. Limber: - Fixed msvs.py for Visual Studio Express editions that would report "Error : ValueError: invalid literal for float(): 10.0Exp". -- cgit v0.12 From 7f826db285f991f0c7b6332ba70642482fbe0381 Mon Sep 17 00:00:00 2001 From: Richard Viney Date: Sun, 10 Jul 2016 17:49:42 +1200 Subject: Added entry to src/CHANGES.txt --- src/CHANGES.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index db52cf0..b6a9507 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -25,6 +25,10 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Added LoadableModule to the list of global functions (DefaultEnvironment builders). + From Richard Viney: + - Fixed PCHPDBFLAGS causing a deprecation warning on MSVC v8 and later when + using PCHs and PDBs together. + RELEASE 2.5.0 - Mon, 09 Apr 2016 11:27:42 -0700 From Dirk Baechle: -- cgit v0.12 From 3d4767acc37e29665fd43ac79981495b17253421 Mon Sep 17 00:00:00 2001 From: Alexey Klimkin Date: Wed, 13 Jul 2016 14:42:15 -0700 Subject: Update CHANGES.txt --- src/CHANGES.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index aab73b4..38f29c0 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -20,6 +20,10 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Added LoadableModule to the list of global functions (DefaultEnvironment builders). + From Alexey Klimkin: + - Use memoization to optimize PATH evaluation across all dependencies per + node. (PR #345) + RELEASE 2.5.0 - Mon, 09 Apr 2016 11:27:42 -0700 From Dirk Baechle: -- cgit v0.12 From 5a7b42144f99ff62bd4f2b81b47a038c415d61cf Mon Sep 17 00:00:00 2001 From: William Blevins Date: Wed, 10 Aug 2016 01:10:09 +0100 Subject: Updated QMTest fortran lib setup for versions GCC 5/6 (and higher*). --- QMTest/TestSCons.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index a515684..2d4df3a 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -977,7 +977,9 @@ SConscript( sconscript ) m = re.search('(gcc\s+version|gcc-Version)\s+(\d\.\d)', stderr) if m: gcc_version = m.group(2) - if re.match('4.[^0]', gcc_version): + if re.match('[5-9].\d', gcc_version): + libs = ['gfortran'] + elif re.match('4.[^0]', gcc_version): libs = ['gfortranbegin'] elif gcc_version in ('3.1', '4.0'): libs = ['frtbegin'] + libs -- cgit v0.12 From 2f3daaaff1ad6d5252e1583fd65b2a5fd4a95ca7 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Wed, 10 Aug 2016 01:19:17 +0100 Subject: Updated CHANGES.txt. --- src/CHANGES.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index db52cf0..3d86359 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -25,6 +25,9 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Added LoadableModule to the list of global functions (DefaultEnvironment builders). + From William Blevins: + - Updated Fortran-related tests to pass under GCC 5/6. + RELEASE 2.5.0 - Mon, 09 Apr 2016 11:27:42 -0700 From Dirk Baechle: -- cgit v0.12 From 5f7882c1ff04fdd3ef3cc44654a2a69911cb73f0 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Wed, 10 Aug 2016 12:42:01 +0100 Subject: Removed deprecate fortran lib handling. --- QMTest/TestSCons.py | 28 ---------------------------- test/Fortran/FORTRAN.py | 1 - test/VariantDir/VariantDir.py | 7 +++---- 3 files changed, 3 insertions(+), 33 deletions(-) diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index 2d4df3a..98b2f00 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -958,34 +958,6 @@ SConscript( sconscript ) # to use cygwin compilers on cmd.exe -> uncomment following line #Configure_lib = 'm' - def gccFortranLibs(self): - """Test which gcc Fortran startup libraries are required. - This should probably move into SCons itself, but is kind of hacky. - """ - if sys.platform.find('irix') != -1: - return ['ftn'] - - libs = ['g2c'] - cmd = ['gcc','-v'] - - try: - p = Popen(cmd, stdout=PIPE, stderr=PIPE) - stdout, stderr = p.communicate() - except: - return libs - - m = re.search('(gcc\s+version|gcc-Version)\s+(\d\.\d)', stderr) - if m: - gcc_version = m.group(2) - if re.match('[5-9].\d', gcc_version): - libs = ['gfortran'] - elif re.match('4.[^0]', gcc_version): - libs = ['gfortranbegin'] - elif gcc_version in ('3.1', '4.0'): - libs = ['frtbegin'] + libs - - return libs - def skip_if_not_msvc(self, check_platform=True): """ Check whether we are on a Windows platform and skip the test if not. This check can be omitted by setting diff --git a/test/Fortran/FORTRAN.py b/test/Fortran/FORTRAN.py index 4a2529c..9a01fa6 100644 --- a/test/Fortran/FORTRAN.py +++ b/test/Fortran/FORTRAN.py @@ -87,7 +87,6 @@ test.must_match('test08' + _exe, "This is a .FPP file.\n") fc = 'f77' f77 = test.detect_tool(fc) -FTN_LIB = test.gccFortranLibs() if f77: diff --git a/test/VariantDir/VariantDir.py b/test/VariantDir/VariantDir.py index 0092692..1b620bb 100644 --- a/test/VariantDir/VariantDir.py +++ b/test/VariantDir/VariantDir.py @@ -28,7 +28,6 @@ import TestSCons _exe = TestSCons._exe test = TestSCons.TestSCons() -fortran_runtime = test.gccFortranLibs() fortran = test.detect('FORTRAN') @@ -118,9 +117,9 @@ except: if fortran and env.Detect(fortran): env.Command(target='b2.f', source='b2.in', action=buildIt) - env.Clone(LIBS = %s).Program(target='bar2', source='b2.f') - env.Clone(LIBS = %s).Program(target='bar1', source='b1.f') -""" % (fortran_runtime, fortran_runtime)) + env.Clone().Program(target='bar2', source='b2.f') + env.Clone().Program(target='bar1', source='b1.f') +""") test.write(['work1', 'src', 'f1.c'], r""" #include -- cgit v0.12 From d5d59de27b9d27649694e3fdca2737ca923550be Mon Sep 17 00:00:00 2001 From: William Blevins Date: Thu, 11 Aug 2016 18:02:10 +0100 Subject: Issue 1924: Updated D Language scanner support. Meets DLang specification 2.071.1 accessed 11 August 2016. URL: https://dlang.org/spec/module.html ImportDeclaration: import ImportList ; static import ImportList ; ImportList: Import ImportBindings Import , ImportList Import: ModuleFullyQualifiedName ModuleAliasIdentifier = ModuleFullyQualifiedName ImportBindings: Import : ImportBindList ImportBindList: ImportBind ImportBind , ImportBindList ImportBind: Identifier Identifier = Identifier ModuleAliasIdentifier: Identifier --- src/engine/SCons/Scanner/D.py | 16 +-- src/engine/SCons/Scanner/DTests.py | 271 +++++++++++++++++++++++++++++++++++++ 2 files changed, 279 insertions(+), 8 deletions(-) create mode 100644 src/engine/SCons/Scanner/DTests.py diff --git a/src/engine/SCons/Scanner/D.py b/src/engine/SCons/Scanner/D.py index 9402ed1..95496d5 100644 --- a/src/engine/SCons/Scanner/D.py +++ b/src/engine/SCons/Scanner/D.py @@ -32,8 +32,6 @@ Coded by Andy Friesen __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import re - import SCons.Scanner def DScanner(): @@ -43,13 +41,13 @@ def DScanner(): class D(SCons.Scanner.Classic): def __init__ (self): - SCons.Scanner.Classic.__init__ (self, + SCons.Scanner.Classic.__init__ ( + self, name = "DScanner", suffixes = '$DSUFFIXES', path_variable = 'DPATH', - regex = 'import\s+(?:[a-zA-Z0-9_.]+)\s*(?:,\s*(?:[a-zA-Z0-9_.]+)\s*)*;') - - self.cre2 = re.compile ('(?:import\s)?\s*([a-zA-Z0-9_.]+)\s*(?:,|;)', re.M) + regex = '(?:import\s+)([\w\s=,.]+)(?:\s*:[\s\w,=]+)?(?:;)' + ) def find_include(self, include, source_dir, path): # translate dots (package separators) to slashes @@ -62,8 +60,10 @@ class D(SCons.Scanner.Classic): def find_include_names(self, node): includes = [] - for i in self.cre.findall(node.get_text_contents()): - includes = includes + self.cre2.findall(i) + for iii in self.cre.findall(node.get_text_contents()): + for jjj in iii.split(','): + kkk = jjj.split('=')[-1] + includes.append(kkk.strip()) return includes # Local Variables: diff --git a/src/engine/SCons/Scanner/DTests.py b/src/engine/SCons/Scanner/DTests.py new file mode 100644 index 0000000..c644e95 --- /dev/null +++ b/src/engine/SCons/Scanner/DTests.py @@ -0,0 +1,271 @@ +# +# __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__" + +import unittest + +import TestCmd +import TestUnit + +import SCons.Scanner.D + +test = TestCmd.TestCmd(workdir = '') + +import collections +import os + +class DummyEnvironment(collections.UserDict): + def __init__(self, **kw): + collections.UserDict.__init__(self) + self.data.update(kw) + self.fs = SCons.Node.FS.FS(test.workpath('')) + + def Dictionary(self, *args): + return self.data + + def subst(self, strSubst, target=None, source=None, conv=None): + if strSubst[0] == '$': + return self.data[strSubst[1:]] + return strSubst + + def subst_list(self, strSubst, target=None, source=None, conv=None): + if strSubst[0] == '$': + return [self.data[strSubst[1:]]] + return [[strSubst]] + + def subst_path(self, path, target=None, source=None, conv=None): + if not isinstance(path, list): + path = [path] + return list(map(self.subst, path)) + + def get_calculator(self): + return None + + def get_factory(self, factory): + return factory or self.fs.File + + def Dir(self, filename): + return self.fs.Dir(filename) + + def File(self, filename): + return self.fs.File(filename) + +if os.path.normcase('foo') == os.path.normcase('FOO'): + my_normpath = os.path.normcase +else: + my_normpath = os.path.normpath + +def deps_match(self, deps, headers): + global my_normpath + scanned = list(map(my_normpath, list(map(str, deps)))) + expect = list(map(my_normpath, headers)) + self.failUnless(scanned == expect, "expect %s != scanned %s" % (expect, scanned)) + +""" +Examples from https://dlang.org/spec/module.html + +D Language: 2.071.1 +Accessed: 11 August 2016 +""" + +# Regular import +test.write('basic.d',""" +import A; + +void main() {} +""") + +# Static import +test.write('static.d',""" +static import A; + +void main() +{ + std.stdio.writeln("hello!"); // ok, writeln is fully qualified +} +""") + +# Public import +test.write('public.d',""" +public import A; + +void main() {} +""") + +# Renamed import +test.write('rename.d',""" +import B = A; + +void main() +{ + io.writeln("hello!"); // ok, calls std.stdio.writeln +} +""") + +# Selective import +test.write('selective.d',""" +import A : B, C = D; + +void main() +{ + writeln("hello!"); // ok, writeln bound into current namespace + foo("world"); // ok, calls std.stdio.write() +} +""") + +# Renamed and Selective import +test.write('renameAndSelective.d',""" +import B = A : C = D; + +void main() +{ +} +""") + +# Scoped import +test.write('scoped.d',""" +void main() +{ + import A; +} +""") + +# Combinatorial import +test.write('combinatorial.d',""" +import A, B, CCC = C, DDD = D : EEE = FFF; + +void main() +{ +} +""") + +# Subdirs import +test.write('subdirs.d',""" +import X.Y, X.Z, X.X.X; + +void main() {} +""") + +# Multiple import +test.write('multiple.d',""" +public import B; +static import C; + +import X = X.Y : Q, R, S, T = U; +void main() +{ + import A; +} +""") + +test.write('A.d',""" +module A; +void main() {} +""") + +test.write('B.d',""" +module B; +void main() {} +""") + +test.write('C.d',""" +module C; +void main() {} +""") + +test.write('D.d',""" +module D; +void main() {} +""") + +test.subdir('X', os.path.join('X','X')) + +test.write(os.path.join('X','Y.d'),""" +module Y; +void main() {} +""") + +test.write(os.path.join('X','Z.d'),""" +module Z; +void main() {} +""") + +test.write(os.path.join('X','X','X.d'),""" +module X; +void main() {} +""") + +class DScannerTestCase(unittest.TestCase): + def helper(self, filename, headers): + env = DummyEnvironment() + s = SCons.Scanner.D.DScanner() + path = s.path(env) + deps = s(env.File(filename), env, path) + deps_match(self, deps, headers) + + def test_BasicImport(self): + self.helper('basic.d', ['A.d']) + + def test_StaticImport(self): + self.helper('static.d', ['A.d']) + + def test_publicImport(self): + self.helper('public.d', ['A.d']) + + def test_RenameImport(self): + self.helper('rename.d', ['A.d']) + + def test_SelectiveImport(self): + self.helper('selective.d', ['A.d']) + + def test_RenameAndSelectiveImport(self): + self.helper('renameAndSelective.d', ['A.d']) + + def test_ScopedImport(self): + self.helper('scoped.d', ['A.d']) + + def test_CombinatorialImport(self): + self.helper('combinatorial.d', ['A.d', 'B.d', 'C.d', 'D.d']) + + def test_SubdirsImport(self): + self.helper('subdirs.d', [os.path.join('X','X','X.d'), os.path.join('X','Y.d'), os.path.join('X','Z.d')]) + + def test_MultipleImport(self): + self.helper('multiple.d', ['A.d', 'B.d', 'C.d', os.path.join('X','Y.d')]) + +if __name__ == "__main__": + suite = unittest.TestSuite() + tclasses = [ + DScannerTestCase, + ] + for tclass in tclasses: + names = unittest.getTestCaseNames(tclass, 'test_') + suite.addTests(list(map(tclass, names))) + TestUnit.run(suite) + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: -- cgit v0.12 From 4daf33934df9ae29e01037ab4646bcbae80a5e2d Mon Sep 17 00:00:00 2001 From: William Blevins Date: Thu, 11 Aug 2016 18:29:45 +0100 Subject: Updated CHANGES.txt --- src/CHANGES.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index db52cf0..28343a6 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -25,6 +25,10 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Added LoadableModule to the list of global functions (DefaultEnvironment builders). + From William Blevins: + - Updated D language scanner support to latest: 2.071.1. (PR #1924) + https://dlang.org/spec/module.html accessed 11 August 2016 + RELEASE 2.5.0 - Mon, 09 Apr 2016 11:27:42 -0700 From Dirk Baechle: -- cgit v0.12 From 65ff75bf1a44beaa4961af9ef6379c84aeb63a62 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Fri, 12 Aug 2016 16:05:28 +0100 Subject: Added multiline support test. --- src/engine/SCons/Scanner/DTests.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/engine/SCons/Scanner/DTests.py b/src/engine/SCons/Scanner/DTests.py index c644e95..805508d 100644 --- a/src/engine/SCons/Scanner/DTests.py +++ b/src/engine/SCons/Scanner/DTests.py @@ -179,6 +179,14 @@ void main() } """) +# Multiline import +test.write('multiline.d',""" +import +A; + +void main() {} +""") + test.write('A.d',""" module A; void main() {} @@ -254,6 +262,9 @@ class DScannerTestCase(unittest.TestCase): def test_MultipleImport(self): self.helper('multiple.d', ['A.d', 'B.d', 'C.d', os.path.join('X','Y.d')]) + def test_MultilineImport(self): + self.helper('multiline.d', ['A.d']) + if __name__ == "__main__": suite = unittest.TestSuite() tclasses = [ -- cgit v0.12 From 05f53e20938706a5bfbff65c82d4820374daa829 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Fri, 12 Aug 2016 16:10:40 +0100 Subject: Updated change notes to be explicit with regards to selective and renamed imports support. --- src/CHANGES.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 28343a6..09271f5 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -28,6 +28,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER From William Blevins: - Updated D language scanner support to latest: 2.071.1. (PR #1924) https://dlang.org/spec/module.html accessed 11 August 2016 + - Added support for selective imports. + - Added support for renamed imports. RELEASE 2.5.0 - Mon, 09 Apr 2016 11:27:42 -0700 -- cgit v0.12 From 70fd8bc246d6453d3da36cbd69f563a59b63c487 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Fri, 12 Aug 2016 16:25:46 +0100 Subject: Added change disclaimer of possible rebuild in Dlang projects after upgrade. --- src/CHANGES.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 09271f5..80ffc6b 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -28,8 +28,12 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER From William Blevins: - Updated D language scanner support to latest: 2.071.1. (PR #1924) https://dlang.org/spec/module.html accessed 11 August 2016 - - Added support for selective imports. - - Added support for renamed imports. + - Enhancements: + - Added support for selective imports. + - Added support for renamed imports. + - Notes: + - May find new (previously missed) Dlang dependencies. + - May cause rebuild after upgrade due to dependency changes. RELEASE 2.5.0 - Mon, 09 Apr 2016 11:27:42 -0700 -- cgit v0.12 From 944226d3beb4b158e4e55b577f46d99e63ca41f8 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Fri, 12 Aug 2016 16:35:48 +0100 Subject: Updated selective test to remove impurity from a selection rename. --- src/engine/SCons/Scanner/DTests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/Scanner/DTests.py b/src/engine/SCons/Scanner/DTests.py index 805508d..51e527a 100644 --- a/src/engine/SCons/Scanner/DTests.py +++ b/src/engine/SCons/Scanner/DTests.py @@ -125,7 +125,7 @@ void main() # Selective import test.write('selective.d',""" -import A : B, C = D; +import A : B, C; void main() { -- cgit v0.12 From 59d3af904b80f672a3719653e30cff72f1a7a44c Mon Sep 17 00:00:00 2001 From: William Blevins Date: Sat, 13 Aug 2016 20:48:31 +0100 Subject: Added additional support examples to the changes.txt. --- src/CHANGES.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 80ffc6b..648027b 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -29,8 +29,9 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Updated D language scanner support to latest: 2.071.1. (PR #1924) https://dlang.org/spec/module.html accessed 11 August 2016 - Enhancements: - - Added support for selective imports. - - Added support for renamed imports. + - Added support for selective imports: "import A : B, C;" -> A + - Added support for renamed imports. "import B = A;" -> A + - Supports valid combinations: "A, B, CCC = C, DDD = D : EEE = FFF;" -> A, B, C, D - Notes: - May find new (previously missed) Dlang dependencies. - May cause rebuild after upgrade due to dependency changes. -- cgit v0.12 From 52815bb68d058b12288a4f05fc3b7051d520a89c Mon Sep 17 00:00:00 2001 From: William Blevins Date: Sat, 13 Aug 2016 20:58:53 +0100 Subject: Updated example text for clarity. --- src/CHANGES.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 648027b..f032d93 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -31,7 +31,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Enhancements: - Added support for selective imports: "import A : B, C;" -> A - Added support for renamed imports. "import B = A;" -> A - - Supports valid combinations: "A, B, CCC = C, DDD = D : EEE = FFF;" -> A, B, C, D + - Supports valid combinations: "import A, B, CCC = C, DDD = D : EEE = FFF;" -> A, B, C, D - Notes: - May find new (previously missed) Dlang dependencies. - May cause rebuild after upgrade due to dependency changes. -- cgit v0.12 From c9a335d6bed101757540429c314e227c9d119486 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 18 Aug 2016 16:30:22 -0700 Subject: fix typo in Decider documentation. --- src/engine/SCons/Environment.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/SCons/Environment.xml b/src/engine/SCons/Environment.xml index b90f1d8..65d71ff 100644 --- a/src/engine/SCons/Environment.xml +++ b/src/engine/SCons/Environment.xml @@ -1100,7 +1100,7 @@ timestamp, such as can happen when restoring files from backup archives. Specifies that a target shall be considered out of date and rebuilt -if the dependency's content has changed sine the last time +if the dependency's content has changed since the last time the target was built, as determined be performing an MD5 checksum on the dependency's contents @@ -1117,7 +1117,7 @@ can be used as a synonym for Specifies that a target shall be considered out of date and rebuilt -if the dependency's content has changed sine the last time +if the dependency's content has changed since the last time the target was built, except that dependencies with a timestamp that matches the last time the target was rebuilt will be -- cgit v0.12 From 8df60cf25428207781fda6ad66c06325556a09a0 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Sun, 18 Sep 2016 00:19:52 -0400 Subject: Sorting RPM tarball sources to correct nondeterminism in ordering. --- src/engine/SCons/Tool/packaging/rpm.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/engine/SCons/Tool/packaging/rpm.py b/src/engine/SCons/Tool/packaging/rpm.py index a132555..99124ed 100644 --- a/src/engine/SCons/Tool/packaging/rpm.py +++ b/src/engine/SCons/Tool/packaging/rpm.py @@ -95,6 +95,8 @@ def collectintargz(target, source, env): # find the .spec file for rpm and add it since it is not necessarily found # by the FindSourceFiles function. sources.extend( [s for s in source if str(s).rfind('.spec')!=-1] ) + # sort to keep sources from changing order across builds + sources.sort() # as the source contains the url of the source package this rpm package # is built from, we extract the target name -- cgit v0.12 From 43448eba072c9638416004986a10836df4d70d90 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Sun, 18 Sep 2016 16:20:21 -0400 Subject: Updated CHANGES.TXT. --- src/CHANGES.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 69fb621..4ae9cb2 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -43,6 +43,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - May find new (previously missed) Dlang dependencies. - May cause rebuild after upgrade due to dependency changes. - Updated Fortran-related tests to pass under GCC 5/6. + - Fixed SCons.Tool.Packaging.rpm.package source nondeterminism across builds. RELEASE 2.5.0 - Mon, 09 Apr 2016 11:27:42 -0700 -- cgit v0.12 From 804fc90e41588c3cbb2eadb58c3120dbcdf0c7b1 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Mon, 19 Sep 2016 22:33:12 -0400 Subject: Caching a pickle protocol in the dblite class. Access to SCons.compat is not available. --- src/engine/SCons/dblite.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/engine/SCons/dblite.py b/src/engine/SCons/dblite.py index c32f494..9ece011 100644 --- a/src/engine/SCons/dblite.py +++ b/src/engine/SCons/dblite.py @@ -2,10 +2,6 @@ # 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 @@ -50,6 +46,7 @@ class dblite(object): _open = open _pickle_dump = staticmethod(pickle.dump) + _pickle_protocol = pickle.HIGHEST_PROTOCOL _os_chmod = os.chmod try: _os_chown = os.chown @@ -121,7 +118,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 -- cgit v0.12 From 2e74f8c28a15f64bad8429ebece227db285f07dc Mon Sep 17 00:00:00 2001 From: William Blevins Date: Mon, 19 Sep 2016 22:52:01 -0400 Subject: Work around src/engine/SCons/SConfTests.py failing without decentralizing pickle protocal variable. --- src/engine/SCons/dblite.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/engine/SCons/dblite.py b/src/engine/SCons/dblite.py index 9ece011..588a7ab 100644 --- a/src/engine/SCons/dblite.py +++ b/src/engine/SCons/dblite.py @@ -7,6 +7,8 @@ import pickle import shutil import time +from SCons.compat import PICKLE_PROTOCOL + keep_all_files = 00000 ignore_corrupt_dbfiles = 0 @@ -46,7 +48,7 @@ class dblite(object): _open = open _pickle_dump = staticmethod(pickle.dump) - _pickle_protocol = pickle.HIGHEST_PROTOCOL + _pickle_protocol = PICKLE_PROTOCOL _os_chmod = os.chmod try: _os_chown = os.chown -- cgit v0.12 From 226c34a47471c5c27bc9a0c262edd62d713acc81 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Tue, 20 Sep 2016 15:05:06 -0400 Subject: Futurize stage 2 2to3 fixes only. --- QMTest/TestSCons.py | 6 +- QMTest/scons_tdb.py | 2 +- bench/bench.py | 2 +- bin/SConsDoc.py | 2 +- bin/SConsExamples.py | 4 +- bin/caller-tree.py | 2 +- bin/memoicmp.py | 8 +- bin/objcounts.py | 4 +- bin/scons-diff.py | 2 +- bin/scons-proc.py | 2 +- src/engine/SCons/Action.py | 6 +- src/engine/SCons/ActionTests.py | 6 +- src/engine/SCons/Builder.py | 2 +- src/engine/SCons/BuilderTests.py | 4 +- src/engine/SCons/Debug.py | 4 +- src/engine/SCons/Defaults.py | 2 +- src/engine/SCons/Environment.py | 34 +-- src/engine/SCons/EnvironmentTests.py | 2 +- src/engine/SCons/Node/Alias.py | 2 +- src/engine/SCons/Node/FS.py | 8 +- src/engine/SCons/Node/Python.py | 2 +- src/engine/SCons/Node/__init__.py | 16 +- src/engine/SCons/SConf.py | 4 +- src/engine/SCons/SConsign.py | 10 +- src/engine/SCons/Scanner/LaTeX.py | 4 +- src/engine/SCons/Script/Interactive.py | 4 +- src/engine/SCons/Script/Main.py | 2 +- src/engine/SCons/Script/SConsOptions.py | 2 +- src/engine/SCons/Script/SConscript.py | 2 +- src/engine/SCons/Taskmaster.py | 2 +- src/engine/SCons/Tool/MSCommon/common.py | 4 +- src/engine/SCons/Tool/MSCommon/vc.py | 2 +- src/engine/SCons/Tool/MSCommon/vs.py | 2 +- src/engine/SCons/Tool/aixlink.py | 2 +- src/engine/SCons/Tool/docbook/__init__.py | 2 +- src/engine/SCons/Tool/gnulink.py | 2 +- src/engine/SCons/Tool/install.py | 2 +- src/engine/SCons/Tool/intelc.py | 4 +- src/engine/SCons/Tool/msvs.py | 26 +-- src/engine/SCons/Tool/msvsTests.py | 10 +- src/engine/SCons/Tool/packaging/__init__.py | 2 +- src/engine/SCons/Tool/packaging/ipk.py | 2 +- src/engine/SCons/Tool/packaging/msi.py | 6 +- src/engine/SCons/Tool/packaging/rpm.py | 4 +- src/engine/SCons/Tool/rpmutils.py | 2 +- src/engine/SCons/Util.py | 6 +- src/engine/SCons/Variables/EnumVariableTests.py | 4 +- src/engine/SCons/Variables/__init__.py | 2 +- src/engine/SCons/cpp.py | 8 +- src/script/scons-configure-cache.py | 276 ++++++++++++------------ src/script/scons-time.py | 4 +- src/test_files.py | 2 +- src/test_interrupts.py | 2 +- test/AS/nasm.py | 2 +- test/QT/QTFLAGS.py | 2 +- 55 files changed, 266 insertions(+), 266 deletions(-) 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\n') @@ -363,7 +363,7 @@ class _GenerateV10User(_UserGenerator): debug = self.configs[kind].debug if debug: debug_settings = '\n'.join(['\t\t<%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('') @@ -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\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 a132555..25b5875 100644 --- a/src/engine/SCons/Tool/packaging/rpm.py +++ b/src/engine/SCons/Tool/packaging/rpm.py @@ -270,7 +270,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: @@ -331,7 +331,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/Util.py b/src/engine/SCons/Util.py index 0be6196..4f4ac2d 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: 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/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' : '', - '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' : '', + '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/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/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 -- cgit v0.12 From 0e2a4161264e7bac8368b8132b368796c880e30e Mon Sep 17 00:00:00 2001 From: William Blevins Date: Tue, 20 Sep 2016 16:07:30 -0400 Subject: Fixing QMTest str and bytes issues. --- QMTest/TestCmd.py | 19 ++++++++++++++++++- QMTest/TestCommon.py | 2 +- src/engine/SCons/Tool/swig.py | 2 +- test/AR/AR.py | 4 ++-- test/AR/ARCOM.py | 2 +- test/AR/ARCOMSTR.py | 2 +- test/AR/ARFLAGS.py | 4 ++-- 7 files changed, 26 insertions(+), 9 deletions(-) diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index b0a456b..d7b8d94 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -328,12 +328,27 @@ __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 + else: + return bytes (s, 'utf-8') + +def to_str (s): + if bytes is str: + return s + elif not is_String(s): + return str (s, 'utf-8') + return s + try: eval('unicode') except NameError: @@ -513,6 +528,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/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/test/AR/AR.py b/test/AR/AR.py index 8fb8073..573f2d9 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('\\', '\\\\')) @@ -100,7 +100,7 @@ test.run(arguments = 'b' + _exe, stderr=TestSCons.noisy_ar, match=TestSCons.match_re_dotall) -test.fail_test(test.read('wrapper.out') != "wrapper.py\n") +test.fail_test(test.read('wrapper.out') != b"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..fad9c19 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('\\', '\\\\')) @@ -99,7 +99,7 @@ test.run(arguments = 'b' + _exe, stderr=TestSCons.noisy_ar, match=TestSCons.match_re_dotall) -test.fail_test(test.read('wrapper.out') != "wrapper.py\n") +test.fail_test(test.read('wrapper.out') != b"wrapper.py\n") test.pass_test() -- cgit v0.12 From 191d1f1a9937ecdf16e12ad5610586c3ba7c50fd Mon Sep 17 00:00:00 2001 From: William Blevins Date: Tue, 20 Sep 2016 22:11:33 -0400 Subject: Updates to test/AR and test/Actions. -Moved some string files to fixture. --- test/AR/AR.py | 4 +- test/AR/ARFLAGS.py | 4 +- test/Actions/actions.py | 10 +-- test/Actions/addpost-link-fixture/.exclude_tests | 1 + test/Actions/addpost-link-fixture/strip.py | 2 + test/Actions/addpost-link-fixture/test1.c | 5 ++ test/Actions/addpost-link-fixture/test_lib.c | 5 ++ test/Actions/addpost-link.py | 21 +---- test/Actions/append-fixture/foo.c | 7 ++ test/Actions/append.py | 21 ++--- test/Actions/pre-post-fixture/work1/bar.c | 7 ++ test/Actions/pre-post-fixture/work1/foo.c | 7 ++ test/Actions/pre-post-fixture/work2/SConstruct | 26 ++++++ test/Actions/pre-post-fixture/work3/SConstruct | 10 +++ test/Actions/pre-post-fixture/work4/.exclude_tests | 1 + test/Actions/pre-post-fixture/work4/file.in | 1 + test/Actions/pre-post.py | 98 ++-------------------- test/Actions/unicode-signature-fixture/SConstruct | 11 +++ test/Actions/unicode-signature.py | 14 +--- 19 files changed, 107 insertions(+), 148 deletions(-) create mode 100644 test/Actions/addpost-link-fixture/.exclude_tests create mode 100644 test/Actions/addpost-link-fixture/strip.py create mode 100644 test/Actions/addpost-link-fixture/test1.c create mode 100644 test/Actions/addpost-link-fixture/test_lib.c create mode 100644 test/Actions/append-fixture/foo.c create mode 100644 test/Actions/pre-post-fixture/work1/bar.c create mode 100644 test/Actions/pre-post-fixture/work1/foo.c create mode 100644 test/Actions/pre-post-fixture/work2/SConstruct create mode 100644 test/Actions/pre-post-fixture/work3/SConstruct create mode 100644 test/Actions/pre-post-fixture/work4/.exclude_tests create mode 100644 test/Actions/pre-post-fixture/work4/file.in create mode 100644 test/Actions/unicode-signature-fixture/SConstruct diff --git a/test/AR/AR.py b/test/AR/AR.py index 573f2d9..eb4c507 100644 --- a/test/AR/AR.py +++ b/test/AR/AR.py @@ -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') != b"wrapper.py\n") +test.must_match('wrapper.out', 'wrapper.py\n') test.pass_test() diff --git a/test/AR/ARFLAGS.py b/test/AR/ARFLAGS.py index fad9c19..0a9f36e 100644 --- a/test/AR/ARFLAGS.py +++ b/test/AR/ARFLAGS.py @@ -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') != b"wrapper.py\n") +test.must_match('wrapper.out', 'wrapper.py\n') test.pass_test() 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 + +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 - -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 + +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 - -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 + +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 + +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 - -int main(void) -{ - printf("foo.c\n"); - return 0; -} -""") - -test.write(['work1', 'bar.c'], r""" -#include - -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 = '.') -- cgit v0.12 From d81a3387f0c6ab528986d25bd57a27f549cd0c91 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Tue, 20 Sep 2016 22:34:39 -0400 Subject: Updating to_str and to_bytes between QMTest and SCons.Util. -Added check to skip decode if already string; otherwise, throws TypeError. --- QMTest/TestCmd.py | 9 +++------ src/engine/SCons/Util.py | 8 +++----- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index d7b8d94..bff0d6a 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -339,15 +339,12 @@ def is_List(e): 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 - elif not is_String(s): - return str (s, 'utf-8') - return s + return str (s, 'utf-8') try: eval('unicode') diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 4f4ac2d..6a7e4a1 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -1553,14 +1553,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 -- cgit v0.12 From 5f4aa5312e2d37a271233d864573772ae2b512fe Mon Sep 17 00:00:00 2001 From: William Blevins Date: Tue, 20 Sep 2016 23:07:51 -0400 Subject: Fixed test/ZIP tests. --- test/ZIP/ZIP.py | 16 ++++++++-------- test/ZIP/ZIPCOM-fixture/.exclude_tests | 1 + test/ZIP/ZIPCOM-fixture/myzip.py | 6 ++++++ test/ZIP/ZIPCOM-fixture/test1.in | 2 ++ test/ZIP/ZIPCOM.py | 18 +----------------- test/ZIP/ZIPCOMSTR-fixture/.exclude_tests | 1 + test/ZIP/ZIPCOMSTR-fixture/aaa.in | 2 ++ test/ZIP/ZIPCOMSTR-fixture/myzip.py | 7 +++++++ test/ZIP/ZIPCOMSTR.py | 16 +--------------- 9 files changed, 29 insertions(+), 40 deletions(-) create mode 100644 test/ZIP/ZIPCOM-fixture/.exclude_tests create mode 100644 test/ZIP/ZIPCOM-fixture/myzip.py create mode 100644 test/ZIP/ZIPCOM-fixture/test1.in create mode 100644 test/ZIP/ZIPCOMSTR-fixture/.exclude_tests create mode 100644 test/ZIP/ZIPCOMSTR-fixture/aaa.in create mode 100644 test/ZIP/ZIPCOMSTR-fixture/myzip.py 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: -- cgit v0.12 From f5035c6a61ad10f440a22c14ce22bbb1d6796f62 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Wed, 21 Sep 2016 12:57:57 -0400 Subject: More test fixes. --- test/ARGUMENTS.py | 4 ++-- test/AS/AS.py | 8 ++++---- test/AS/ASCOM.py | 18 +++++++++--------- test/AS/ASCOMSTR.py | 10 +++++----- test/AS/ASPPCOM.py | 10 +++++----- test/AS/ASPPCOMSTR.py | 6 +++--- test/AS/as-live.py | 2 +- test/AS/ml.py | 2 +- test/CC/CCCOM.py | 16 +--------------- test/CC/CCCOMSTR.py | 16 +--------------- test/CC/SHCC.py | 6 +++--- test/CC/SHCCCOM.py | 16 +--------------- test/CC/SHCCCOMSTR.py | 16 +--------------- test/CC/shared-fixture/.exclude_tests | 1 + test/CC/shared-fixture/mycc.py | 6 ++++++ test/CC/shared-fixture/test1.c | 2 ++ test/CFILESUFFIX.py | 2 +- test/SWIG/SWIGCOM.py | 2 +- test/SWIG/SWIGCOMSTR.py | 2 +- test/file-names.py | 6 +++--- 20 files changed, 52 insertions(+), 99 deletions(-) create mode 100644 test/CC/shared-fixture/.exclude_tests create mode 100644 test/CC/shared-fixture/mycc.py create mode 100644 test/CC/shared-fixture/test1.c 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/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/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/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/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() -- cgit v0.12 From 88eb753eb8e65721368beb2fc1247312e2a5ab4c Mon Sep 17 00:00:00 2001 From: William Blevins Date: Wed, 21 Sep 2016 19:54:23 -0400 Subject: Fixed difference in types MethodType argument list between 2/3 which allowed finishing CC folder. --- src/engine/SCons/Util.py | 16 ++++++--- test/CC/CC-fixture/bar.c | 10 ++++++ test/CC/CC-fixture/foo.c | 10 ++++++ test/CC/CC-fixture/test1.c | 3 ++ test/CC/CC-fixture/test2.C | 3 ++ test/CC/CC.py | 57 +++++--------------------------- test/CC/CCVERSION-fixture/.exclude_tests | 1 + test/CC/CCVERSION-fixture/versioned.py | 12 +++++++ test/CC/CCVERSION.py | 29 ++-------------- 9 files changed, 61 insertions(+), 80 deletions(-) create mode 100644 test/CC/CC-fixture/bar.c create mode 100644 test/CC/CC-fixture/foo.c create mode 100644 test/CC/CC-fixture/test1.c create mode 100644 test/CC/CC-fixture/test2.C create mode 100644 test/CC/CCVERSION-fixture/.exclude_tests create mode 100644 test/CC/CCVERSION-fixture/versioned.py diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 6a7e4a1..7653acd 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -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): """ 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 +#include + +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 +#include + +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 -#include - -int -main(int argc, char *argv[]) -{ - argv[argc++] = "--"; - printf("foo.c\n"); - exit (0); -} -""") - -test.write('bar.c', r""" -#include -#include - -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/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 -#include - -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) -- cgit v0.12 From bea6d372a175aff23d05b6a513c2df53aaa6fa87 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Wed, 21 Sep 2016 20:47:35 -0400 Subject: Fixed the YACC tests. --- test/YACC/YACC-fixture/.exclude_tests | 1 + test/YACC/YACC-fixture/aaa.y | 2 ++ test/YACC/YACC-fixture/bbb.yacc | 2 ++ test/YACC/YACC-fixture/ccc.yy | 2 ++ test/YACC/YACC-fixture/ddd.ym | 2 ++ test/YACC/YACC-fixture/myyacc.py | 13 +++++++++++++ test/YACC/YACC.py | 25 +------------------------ test/YACC/YACCCOM-fixture/.exclude_tests | 1 + test/YACC/YACCCOM-fixture/myyacc.py | 7 +++++++ test/YACC/YACCCOM.py | 16 ++-------------- test/YACC/YACCCOMSTR.py | 16 ++-------------- test/YACC/YACCFLAGS-fixture/.exclude_tests | 1 + test/YACC/YACCFLAGS-fixture/myyacc.py | 17 +++++++++++++++++ test/YACC/YACCFLAGS.py | 22 +--------------------- test/YACC/YACCHFILESUFFIX.py | 4 ++-- test/YACC/YACCHXXFILESUFFIX.py | 4 ++-- test/YACC/YACCVCGFILESUFFIX.py | 4 ++-- test/YACC/shared-fixture/.exclude_tests | 1 + test/YACC/shared-fixture/aaa.y | 2 ++ test/YACC/shared-fixture/bbb.yacc | 2 ++ 20 files changed, 65 insertions(+), 79 deletions(-) create mode 100644 test/YACC/YACC-fixture/.exclude_tests create mode 100644 test/YACC/YACC-fixture/aaa.y create mode 100644 test/YACC/YACC-fixture/bbb.yacc create mode 100644 test/YACC/YACC-fixture/ccc.yy create mode 100644 test/YACC/YACC-fixture/ddd.ym create mode 100644 test/YACC/YACC-fixture/myyacc.py create mode 100644 test/YACC/YACCCOM-fixture/.exclude_tests create mode 100644 test/YACC/YACCCOM-fixture/myyacc.py create mode 100644 test/YACC/YACCFLAGS-fixture/.exclude_tests create mode 100644 test/YACC/YACCFLAGS-fixture/myyacc.py create mode 100644 test/YACC/shared-fixture/.exclude_tests create mode 100644 test/YACC/shared-fixture/aaa.y create mode 100644 test/YACC/shared-fixture/bbb.yacc 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*/ -- cgit v0.12 From 0f0725d9215ca35e9b9995a9421ef83e35a338d8 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Thu, 22 Sep 2016 17:19:50 -0400 Subject: Yet another batch of test fixes. --- .hgignore | 1 + test/LEX/LEX.py | 2 +- test/LEX/LEXCOM.py | 2 +- test/LEX/LEXCOMSTR.py | 2 +- test/LEX/LEXFLAGS.py | 6 +++--- test/LEX/live.py | 2 +- test/LINK/LINK.py | 6 +++--- test/LINK/LINKCOM.py | 5 +---- test/LINK/LINKCOMSTR.py | 4 ++-- test/LINK/LINKFLAGS.py | 4 ++-- test/LINK/SHLINK.py | 6 +++--- test/LINK/SHLINKCOM.py | 4 ++-- test/LINK/SHLINKCOMSTR.py | 4 ++-- test/LINK/SHLINKFLAGS.py | 4 ++-- test/M4/M4.py | 10 +++++----- test/M4/M4COM.py | 2 +- test/M4/M4COMSTR.py | 2 +- test/YACC/live.py | 2 +- 18 files changed, 33 insertions(+), 35 deletions(-) diff --git a/.hgignore b/.hgignore index 3e16531..15c093f 100644 --- a/.hgignore +++ b/.hgignore @@ -11,6 +11,7 @@ syntax:glob *.orig *.DS_Store *\# +*.swp doc/user/scons-user doc/user/scons_db.xml diff --git a/test/LEX/LEX.py b/test/LEX/LEX.py index 975d4e9..1239c6b 100644 --- a/test/LEX/LEX.py +++ b/test/LEX/LEX.py @@ -41,7 +41,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/LEX/LEXCOM.py b/test/LEX/LEXCOM.py index 5fb82fe..6a32388 100644 --- a/test/LEX/LEXCOM.py +++ b/test/LEX/LEXCOM.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 != '/*lex*/\\n']: + for l in [l for l in infile.readlines() if l != b'/*lex*/\\n']: outfile.write(l) sys.exit(0) """) diff --git a/test/LEX/LEXCOMSTR.py b/test/LEX/LEXCOMSTR.py index 83b2f9c..07e693c 100644 --- a/test/LEX/LEXCOMSTR.py +++ b/test/LEX/LEXCOMSTR.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 != '/*lex*/\\n']: + for l in [l for l in infile.readlines() if l != b'/*lex*/\\n']: outfile.write(l) sys.exit(0) """) diff --git a/test/LEX/LEXFLAGS.py b/test/LEX/LEXFLAGS.py index 82ae586..54df161 100644 --- a/test/LEX/LEXFLAGS.py +++ b/test/LEX/LEXFLAGS.py @@ -48,9 +48,9 @@ for opt, arg in cmd_opts: else: opt_string = opt_string + ' ' + opt for a in args: contents = open(a, 'rb').read() - contents = contents.replace('LEXFLAGS', opt_string) - contents = contents.replace('I_ARGS', i_arguments) - sys.stdout.write(contents) + contents = contents.replace(b'LEXFLAGS', opt_string.encode()) + contents = contents.replace(b'I_ARGS', i_arguments.encode()) + sys.stdout.write(contents.decode()) sys.exit(0) """) diff --git a/test/LEX/live.py b/test/LEX/live.py index e4b4dfb..2abb8ce 100644 --- a/test/LEX/live.py +++ b/test/LEX/live.py @@ -44,7 +44,7 @@ if not lex: 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/LINK/LINK.py b/test/LINK/LINK.py index 25d9efb..54c75fa 100644 --- a/test/LINK/LINK.py +++ b/test/LINK/LINK.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(("wrapper.py\\n").encode()) os.system(" ".join(sys.argv[1:])) """ % test.workpath('wrapper.out').replace('\\', '\\\\')) @@ -75,11 +75,11 @@ main(int argc, char *argv[]) test.run(arguments = 'foo' + _exe) -test.fail_test(os.path.exists(test.workpath('wrapper.out'))) +test.must_not_exist(test.workpath('wrapper.out')) test.run(arguments = 'bar' + _exe) -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/LINK/LINKCOM.py b/test/LINK/LINKCOM.py index f09e8f8..996e727 100644 --- a/test/LINK/LINKCOM.py +++ b/test/LINK/LINKCOM.py @@ -31,18 +31,15 @@ Test the ability to configure the $LINKCOM construction variable. import TestSCons _python_ = TestSCons._python_ -_exe = TestSCons._exe test = TestSCons.TestSCons() - - test.write('mylink.py', r""" 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 != '/*link*/\n']: + for l in [l for l in infile.readlines() if l != b'/*link*/\n']: outfile.write(l) sys.exit(0) """) diff --git a/test/LINK/LINKCOMSTR.py b/test/LINK/LINKCOMSTR.py index 8fd8adc..8163016 100644 --- a/test/LINK/LINKCOMSTR.py +++ b/test/LINK/LINKCOMSTR.py @@ -32,7 +32,6 @@ the displayed linker string. import TestSCons _python_ = TestSCons._python_ -_exe = TestSCons._exe test = TestSCons.TestSCons() @@ -43,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 != '/*link*/\n']: + for l in [l for l in infile.readlines() if l != b'/*link*/\n']: outfile.write(l) sys.exit(0) """) @@ -80,6 +79,7 @@ env = Environment(CXXCOMSTR = 'Compiling $TARGET ...', LINKCOMSTR = 'Linking $TARGET ...') env.Program('test', 'test.cpp') """) + test.write('test.cpp', """ int main(int argc, char **argv) {} """) diff --git a/test/LINK/LINKFLAGS.py b/test/LINK/LINKFLAGS.py index 442baf7..f0c7518 100644 --- a/test/LINK/LINKFLAGS.py +++ b/test/LINK/LINKFLAGS.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(("wrapper.py\\n").encode()) args = [s for s in sys.argv[1:] if s != 'fake_link_flag'] os.system(" ".join(args)) """ % test.workpath('wrapper.out').replace('\\', '\\\\')) @@ -80,7 +80,7 @@ test.must_not_exist(test.workpath('wrapper.out')) test.run(arguments = 'bar' + _exe) -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/LINK/SHLINK.py b/test/LINK/SHLINK.py index bc1239b..7353996 100644 --- a/test/LINK/SHLINK.py +++ b/test/LINK/SHLINK.py @@ -37,7 +37,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('\\', '\\\\')) @@ -73,11 +73,11 @@ test() test.run(arguments = dll_ + 'foo' + _shlib) -test.fail_test(os.path.exists(test.workpath('wrapper.out'))) +test.must_not_exist(test.workpath('wrapper.out')) test.run(arguments = dll_ + 'bar' + _shlib) -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/LINK/SHLINKCOM.py b/test/LINK/SHLINKCOM.py index 8bdb9b5..1204ed1 100644 --- a/test/LINK/SHLINKCOM.py +++ b/test/LINK/SHLINKCOM.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 != '/*cc*/\n']: + for l in [l for l in infile.readlines() if l != b'/*cc*/\n']: outfile.write(l) sys.exit(0) @@ -51,7 +51,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 != '/*link*/\n']: + for l in [l for l in infile.readlines() if l != b'/*link*/\n']: outfile.write(l) sys.exit(0) """) diff --git a/test/LINK/SHLINKCOMSTR.py b/test/LINK/SHLINKCOMSTR.py index db40732..5663a1e 100644 --- a/test/LINK/SHLINKCOMSTR.py +++ b/test/LINK/SHLINKCOMSTR.py @@ -43,7 +43,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 != '/*cc*/\n']: + for l in [l for l in infile.readlines() if l != b'/*cc*/\n']: outfile.write(l) sys.exit(0) @@ -53,7 +53,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 != '/*link*/\n']: + for l in [l for l in infile.readlines() if l != b'/*link*/\n']: outfile.write(l) sys.exit(0) """) diff --git a/test/LINK/SHLINKFLAGS.py b/test/LINK/SHLINKFLAGS.py index 57766de..51b6e22 100644 --- a/test/LINK/SHLINKFLAGS.py +++ b/test/LINK/SHLINKFLAGS.py @@ -37,7 +37,7 @@ test = TestSCons.TestSCons() test.write("wrapper.py", """import os import sys -open('%s', 'wb').write("wrapper.py\\n") +open('%s', 'wb').write(("wrapper.py\\n").encode()) args = [s for s in sys.argv[1:] if s != 'fake_shlink_flag'] os.system(" ".join(args)) """ % test.workpath('wrapper.out').replace('\\', '\\\\')) @@ -78,7 +78,7 @@ test.must_not_exist(test.workpath('wrapper.out')) test.run(arguments = lib_ + 'bar' + _shlib) -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/M4/M4.py b/test/M4/M4.py index 6c2de9c..d2b8365 100644 --- a/test/M4/M4.py +++ b/test/M4/M4.py @@ -59,7 +59,7 @@ line 3 test.run() -test.fail_test(test.read(test.workpath('aaa.x'), 'r') != "line 1\nmym4.py\nline 3\n") +test.must_match(test.workpath('aaa.x'), "line 1\nmym4.py\nline 3\n") @@ -70,7 +70,7 @@ if m4: 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('\\', '\\\\')) @@ -96,11 +96,11 @@ bar.M4(target = 'bar', source = 'bar.m4') test.up_to_date(arguments = '.') - test.fail_test(test.read('wrapper.out') != "wrapper.py\n") + test.must_match('wrapper.out', "wrapper.py\n") - test.fail_test(test.read('foo.x', 'r') != "line 1\nfff\nline 3\n") + test.must_match('foo.x', "line 1\nfff\nline 3\n") - test.fail_test(test.read('bar', 'r') != "line 1\nbbb\nline 3\n") + test.must_match('bar', "line 1\nbbb\nline 3\n") test.pass_test() diff --git a/test/M4/M4COM.py b/test/M4/M4COM.py index ad15172..5a2f076 100644 --- a/test/M4/M4COM.py +++ b/test/M4/M4COM.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 != '/*m4*/\\n']: + for l in [l for l in infile.readlines() if l != b'/*m4*/\\n']: outfile.write(l) sys.exit(0) """) diff --git a/test/M4/M4COMSTR.py b/test/M4/M4COMSTR.py index 1b5bd35..da01e6c 100644 --- a/test/M4/M4COMSTR.py +++ b/test/M4/M4COMSTR.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 != '/*m4*/\\n']: + for l in [l for l in infile.readlines() if l != b'/*m4*/\\n']: outfile.write(l) sys.exit(0) """) diff --git a/test/YACC/live.py b/test/YACC/live.py index f6733da..e125daa 100644 --- a/test/YACC/live.py +++ b/test/YACC/live.py @@ -43,7 +43,7 @@ if not yacc: 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('\\', '\\\\')) -- cgit v0.12 From 4fe5ff748a5831be8279c3c9bc1c198fcacc9aca Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 22 Sep 2016 18:15:47 -0400 Subject: fix missing file from test fixture --- test/Actions/pre-post-fixture/work4/build.py | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 test/Actions/pre-post-fixture/work4/build.py diff --git a/test/Actions/pre-post-fixture/work4/build.py b/test/Actions/pre-post-fixture/work4/build.py new file mode 100644 index 0000000..db0572a --- /dev/null +++ b/test/Actions/pre-post-fixture/work4/build.py @@ -0,0 +1,5 @@ +import sys +outfp = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + outfp.write(open(f, 'rb').read()) +outfp.close() -- cgit v0.12 From 2c18000b934722c69e23a2d0ad181767d5266ac9 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Fri, 23 Sep 2016 00:43:00 -0400 Subject: Allowed for multiple fixture dirs and added default global directory. --- QMTest/TestCmd.py | 25 ++++++++++++++++--------- QMTest/TestSCons.py | 2 +- runtest.py | 8 +++++--- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index bff0d6a..109c83a 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -924,7 +924,7 @@ class TestCmd(object): self.condition = 'no_result' self.workdir_set(workdir) self.subdir(subdir) - self.script_srcdir = None + self.fixture_dirs = [] def __del__(self): self.cleanup() @@ -1248,8 +1248,13 @@ class TestCmd(object): assumed to be under the temporary working directory, it gets created automatically, if it does not already exist. """ - if srcdir and self.script_srcdir and not os.path.isabs(srcdir): - spath = os.path.join(self.script_srcdir, srcdir) + + if srcdir and self.fixture_dirs and not os.path.isabs(srcdir): + for dir in self.fixture_dirs: + spath = os.path.join(self.fixture_dirs, srcdir) + if os.path.isdir(spath): + continue + else: spath = srcdir if dstdir: @@ -1285,13 +1290,15 @@ class TestCmd(object): automatically, if it does not already exist. """ srcpath, srctail = os.path.split(srcfile) - if srcpath: - if self.script_srcdir and not os.path.isabs(srcpath): - spath = os.path.join(self.script_srcdir, srcfile) - else: - spath = srcfile + + if srcpath and (not self.fixture_dirs or os.path.isabs(srcpath)): + spath = srcfile else: - spath = os.path.join(self.script_srcdir, srcfile) + for dir in self.fixture_dirs: + spath = os.path.join(self.fixture_dirs, srcfile) + if os.path.isfile(spath): + continue + if not dstfile: if srctail: dpath = os.path.join(self.workdir, srctail) diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index 0d5dc90..f02ddd8 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -268,7 +268,7 @@ class TestSCons(TestCommon): SCons.Node.FS.default_fs = SCons.Node.FS.FS() try: - self.script_srcdir = os.environ['PYTHON_SCRIPT_DIR'] + self.fixture_dirs = os.environ['FIXTURE_DIRS'].split(':') except KeyError: pass diff --git a/runtest.py b/runtest.py index 0950bbe..dec8f9f 100755 --- a/runtest.py +++ b/runtest.py @@ -786,10 +786,12 @@ def run_test(t, io_lock, async=True): if not suppress_stdout and not suppress_stderr: sys.stdout.write(header) head, tail = os.path.split(t.abspath) + fixture_dirs = [] if head: - os.environ['PYTHON_SCRIPT_DIR'] = head - else: - os.environ['PYTHON_SCRIPT_DIR'] = '' + fixture_dirs.append(head) + fixture_dirs.append(os.path.join(os.path.split(os.path.abspath(__file__))[0], 'fixture')) + os.environ['PYTHON_SCRIPT_DIR'] = ':'.join(fixture_dirs) + test_start_time = time_func() if execute_tests: t.execute() -- cgit v0.12 From d2312ff7f05636c425526936d1957464221b26d0 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Fri, 23 Sep 2016 02:13:44 -0400 Subject: Initial python3 cut of test/Fortran. --- QMTest/TestCmd.py | 10 ++--- QMTest/TestSCons.py | 2 +- fixture/mylink.py | 31 ++++++++++++++ fixture/wrapper.py | 5 +++ runtest.py | 4 +- src/engine/SCons/Scanner/Fortran.py | 12 +++--- src/engine/SCons/Tool/FortranCommon.py | 2 +- test/Fortran/F03.py | 14 ++----- test/Fortran/common.py | 75 ---------------------------------- 9 files changed, 54 insertions(+), 101 deletions(-) create mode 100644 fixture/mylink.py create mode 100644 fixture/wrapper.py delete mode 100644 test/Fortran/common.py diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index 109c83a..370101b 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -1251,12 +1251,12 @@ class TestCmd(object): if srcdir and self.fixture_dirs and not os.path.isabs(srcdir): for dir in self.fixture_dirs: - spath = os.path.join(self.fixture_dirs, srcdir) + spath = os.path.join(dir, srcdir) if os.path.isdir(spath): - continue - + break else: spath = srcdir + if dstdir: dstdir = self.canonicalize(dstdir) else: @@ -1295,9 +1295,9 @@ class TestCmd(object): spath = srcfile else: for dir in self.fixture_dirs: - spath = os.path.join(self.fixture_dirs, srcfile) + spath = os.path.join(dir, srcfile) if os.path.isfile(spath): - continue + break if not dstfile: if srctail: diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index f02ddd8..a987c5a 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -268,7 +268,7 @@ class TestSCons(TestCommon): SCons.Node.FS.default_fs = SCons.Node.FS.FS() try: - self.fixture_dirs = os.environ['FIXTURE_DIRS'].split(':') + self.fixture_dirs = (os.environ['FIXTURE_DIRS']).split(':') except KeyError: pass diff --git a/fixture/mylink.py b/fixture/mylink.py new file mode 100644 index 0000000..7c03f00 --- /dev/null +++ b/fixture/mylink.py @@ -0,0 +1,31 @@ +import sys + +if sys.platform == 'win32': + args = sys.argv[1:] + while args: + a = args[0] + if a == '-o': + out = args[1] + args = args[2:] + continue + if not a[0] in '/-': + break + args = args[1:] + if a[:5].lower() == '/out:': out = a[5:] + infile = open(args[0], 'rb') + outfile = open(out, 'wb') + for l in infile.readlines(): + if l[:5] != b'#link': + outfile.write(l) + sys.exit(0) +else: + import getopt + opts, args = getopt.getopt(sys.argv[1:], 'o:') + for opt, arg in opts: + if opt == '-o': out = arg + infile = open(args[0], 'rb') + outfile = open(out, 'wb') + for l in infile.readlines(): + if l[:5] != b'#link': + outfile.write(l) + sys.exit(0) diff --git a/fixture/wrapper.py b/fixture/wrapper.py new file mode 100644 index 0000000..a797434 --- /dev/null +++ b/fixture/wrapper.py @@ -0,0 +1,5 @@ +import os +import sys +path = os.path.join(os.path.abspath(__file__), 'wrapper.out') +open(path, 'wb').write(b"wrapper.py\n") +os.system(" ".join(sys.argv[1:])) diff --git a/runtest.py b/runtest.py index dec8f9f..c856740 100755 --- a/runtest.py +++ b/runtest.py @@ -789,8 +789,8 @@ def run_test(t, io_lock, async=True): fixture_dirs = [] if head: fixture_dirs.append(head) - fixture_dirs.append(os.path.join(os.path.split(os.path.abspath(__file__))[0], 'fixture')) - os.environ['PYTHON_SCRIPT_DIR'] = ':'.join(fixture_dirs) + fixture_dirs.append(os.path.join(scriptpath, 'fixture')) + os.environ['FIXTURE_DIRS'] = ':'.join(fixture_dirs) test_start_time = time_func() if execute_tests: diff --git a/src/engine/SCons/Scanner/Fortran.py b/src/engine/SCons/Scanner/Fortran.py index 1b55130..9082015 100644 --- a/src/engine/SCons/Scanner/Fortran.py +++ b/src/engine/SCons/Scanner/Fortran.py @@ -82,11 +82,11 @@ class F90Scanner(SCons.Scanner.Classic): mods_and_includes = node.includes else: # retrieve all included filenames - includes = self.cre_incl.findall(node.get_text_contents()) + includes = self.cre_incl.findall(node.get_contents()) # retrieve all USE'd module names - modules = self.cre_use.findall(node.get_text_contents()) + modules = self.cre_use.findall(node.get_contents()) # retrieve all defined module names - defmodules = self.cre_def.findall(node.get_text_contents()) + defmodules = self.cre_def.findall(node.get_contents()) # Remove all USE'd module names that are defined in the same file # (case-insensitively) @@ -187,7 +187,7 @@ def FortranScan(path_variable="FORTRANPATH"): # (\w+) : match the module name that is being USE'd # # - use_regex = "(?i)(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)" + use_regex = b"(?i)(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)" # The INCLUDE statement regex matches the following: @@ -275,7 +275,7 @@ def FortranScan(path_variable="FORTRANPATH"): # set of semicolon-separated INCLUDE statements # (as allowed by the F2003 standard) - include_regex = """(?i)(?:^|['">]\s*;)\s*INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])""" + include_regex = b"(?i)(?:^|['\">]\s*;)\s*INCLUDE\s+(?:\w+_)?[<\"'](.+?)(?=[\"'>])" # The MODULE statement regex finds module definitions by matching # the following: @@ -299,7 +299,7 @@ def FortranScan(path_variable="FORTRANPATH"): # that make up the defined module name and # save it in a group - def_regex = """(?i)^\s*MODULE\s+(?!PROCEDURE)(\w+)""" + def_regex = b"(?i)^\s*MODULE\s+(?!PROCEDURE)(\w+)" scanner = F90Scanner("FortranScan", "$FORTRANSUFFIXES", diff --git a/src/engine/SCons/Tool/FortranCommon.py b/src/engine/SCons/Tool/FortranCommon.py index e450730..1503639 100644 --- a/src/engine/SCons/Tool/FortranCommon.py +++ b/src/engine/SCons/Tool/FortranCommon.py @@ -64,7 +64,7 @@ def _fortranEmitter(target, source, env): if not node.exists() and not node.is_derived(): print("Could not locate " + str(node.name)) return ([], []) - mod_regex = """(?i)^\s*MODULE\s+(?!PROCEDURE)(\w+)""" + mod_regex = b"(?i)^\s*MODULE\s+(?!PROCEDURE)(\w+)" cre = re.compile(mod_regex,re.M) # Retrieve all USE'd module names modules = cre.findall(node.get_text_contents()) diff --git a/test/Fortran/F03.py b/test/Fortran/F03.py index ea706a9..3c6bba4 100644 --- a/test/Fortran/F03.py +++ b/test/Fortran/F03.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt @@ -46,7 +44,7 @@ for opt, arg in opts: infile = open(args[0], 'rb') outfile = open(out, 'wb') for l in infile.readlines(): - if l[:length] != comment: + if l[:length] != comment.encode(): outfile.write(l) sys.exit(0) """) @@ -97,13 +95,7 @@ fc = 'f03' g03 = test.detect_tool(fc) if g03: - - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(F03 = '%(fc)s') diff --git a/test/Fortran/common.py b/test/Fortran/common.py deleted file mode 100644 index 6763ef4..0000000 --- a/test/Fortran/common.py +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env python -# -# __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__" - - -"""This module implements common code to all fortran tests.""" - -import sys - -def write_fake_link(t): - """Writes a mylink.py script to remove the link step for 'fake' (e.g. - non-compiled) tests.""" - if sys.platform == 'win32': - t.write('mylink.py', r""" -import sys -args = sys.argv[1:] -while args: - a = args[0] - if a == '-o': - out = args[1] - args = args[2:] - continue - if not a[0] in '/-': - break - args = args[1:] - if a[:5].lower() == '/out:': out = a[5:] -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:5] != '#link': - outfile.write(l) -sys.exit(0) - """) - else: - t.write('mylink.py', r""" -import getopt -import sys -opts, args = getopt.getopt(sys.argv[1:], 'o:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:5] != '#link': - outfile.write(l) -sys.exit(0) - """) - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: -- cgit v0.12 From 9e87609dfac0fd6a87d2cdc0a9e4e8b5c0a6a99a Mon Sep 17 00:00:00 2001 From: William Blevins Date: Sat, 24 Sep 2016 02:05:34 -0400 Subject: Updated remaining Fortran tests to use fixture over import. --- test/Fortran/F03COM.py | 4 +--- test/Fortran/F03FILESUFFIXES.py | 4 +--- test/Fortran/F03FILESUFFIXES2.py | 4 +--- test/Fortran/F03FLAGS.py | 4 +--- test/Fortran/F08.py | 4 +--- test/Fortran/F08COM.py | 4 +--- test/Fortran/F08FILESUFFIXES.py | 4 +--- test/Fortran/F08FILESUFFIXES2.py | 4 +--- test/Fortran/F08FLAGS.py | 4 +--- test/Fortran/F77.py | 4 +--- test/Fortran/F77COM.py | 4 +--- test/Fortran/F77FILESUFFIXES.py | 4 +--- test/Fortran/F77FILESUFFIXES2.py | 4 +--- test/Fortran/F77FLAGS.py | 4 +--- test/Fortran/F90.py | 4 +--- test/Fortran/F90COM.py | 4 +--- test/Fortran/F90FILESUFFIXES.py | 4 +--- test/Fortran/F90FILESUFFIXES2.py | 4 +--- test/Fortran/F90FLAGS.py | 4 ++-- test/Fortran/F95.py | 4 ++-- test/Fortran/F95COM.py | 4 ++-- test/Fortran/F95FILESUFFIXES.py | 4 ++-- test/Fortran/F95FILESUFFIXES2.py | 4 ++-- test/Fortran/F95FLAGS.py | 4 ++-- test/Fortran/FORTRAN.py | 4 ++-- test/Fortran/FORTRANCOM.py | 4 ++-- test/Fortran/FORTRANFILESUFFIXES.py | 4 ++-- test/Fortran/FORTRANFILESUFFIXES2.py | 4 ++-- test/Fortran/FORTRANFLAGS.py | 4 ++-- test/Fortran/FORTRANPPFILESUFFIXES.py | 4 ++-- 30 files changed, 42 insertions(+), 78 deletions(-) diff --git a/test/Fortran/F03COM.py b/test/Fortran/F03COM.py index b0d1f79..dc1523e 100644 --- a/test/Fortran/F03COM.py +++ b/test/Fortran/F03COM.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import sys diff --git a/test/Fortran/F03FILESUFFIXES.py b/test/Fortran/F03FILESUFFIXES.py index ffc2169..b1d2b93 100644 --- a/test/Fortran/F03FILESUFFIXES.py +++ b/test/Fortran/F03FILESUFFIXES.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F03FILESUFFIXES2.py b/test/Fortran/F03FILESUFFIXES2.py index 77a601f..44be880 100644 --- a/test/Fortran/F03FILESUFFIXES2.py +++ b/test/Fortran/F03FILESUFFIXES2.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F03FLAGS.py b/test/Fortran/F03FLAGS.py index 0c5bf93..b11b780 100644 --- a/test/Fortran/F03FLAGS.py +++ b/test/Fortran/F03FLAGS.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ test = TestSCons.TestSCons() _exe = TestSCons._exe -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F08.py b/test/Fortran/F08.py index 35df37c..b61b861 100644 --- a/test/Fortran/F08.py +++ b/test/Fortran/F08.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F08COM.py b/test/Fortran/F08COM.py index 783a163..363c2d0 100644 --- a/test/Fortran/F08COM.py +++ b/test/Fortran/F08COM.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import sys diff --git a/test/Fortran/F08FILESUFFIXES.py b/test/Fortran/F08FILESUFFIXES.py index 8463403..41059af 100644 --- a/test/Fortran/F08FILESUFFIXES.py +++ b/test/Fortran/F08FILESUFFIXES.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F08FILESUFFIXES2.py b/test/Fortran/F08FILESUFFIXES2.py index 39bba44..e53cee1 100644 --- a/test/Fortran/F08FILESUFFIXES2.py +++ b/test/Fortran/F08FILESUFFIXES2.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F08FLAGS.py b/test/Fortran/F08FLAGS.py index 866ea2c..34f3d75 100644 --- a/test/Fortran/F08FLAGS.py +++ b/test/Fortran/F08FLAGS.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ test = TestSCons.TestSCons() _exe = TestSCons._exe -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F77.py b/test/Fortran/F77.py index 0ebd7ee..300df85 100644 --- a/test/Fortran/F77.py +++ b/test/Fortran/F77.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F77COM.py b/test/Fortran/F77COM.py index 1efbe05..4e15eea 100644 --- a/test/Fortran/F77COM.py +++ b/test/Fortran/F77COM.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import sys diff --git a/test/Fortran/F77FILESUFFIXES.py b/test/Fortran/F77FILESUFFIXES.py index 2070ff2..1715ce9 100644 --- a/test/Fortran/F77FILESUFFIXES.py +++ b/test/Fortran/F77FILESUFFIXES.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F77FILESUFFIXES2.py b/test/Fortran/F77FILESUFFIXES2.py index 52e4d68..1938af1 100644 --- a/test/Fortran/F77FILESUFFIXES2.py +++ b/test/Fortran/F77FILESUFFIXES2.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F77FLAGS.py b/test/Fortran/F77FLAGS.py index 342adac..8e972ec 100644 --- a/test/Fortran/F77FLAGS.py +++ b/test/Fortran/F77FLAGS.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ test = TestSCons.TestSCons() _exe = TestSCons._exe -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myg77.py', r""" import getopt diff --git a/test/Fortran/F90.py b/test/Fortran/F90.py index d7c73c6..bbceaac 100644 --- a/test/Fortran/F90.py +++ b/test/Fortran/F90.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F90COM.py b/test/Fortran/F90COM.py index 8981bb3..e3be2a1 100644 --- a/test/Fortran/F90COM.py +++ b/test/Fortran/F90COM.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import sys diff --git a/test/Fortran/F90FILESUFFIXES.py b/test/Fortran/F90FILESUFFIXES.py index ae61a84..47da08e 100644 --- a/test/Fortran/F90FILESUFFIXES.py +++ b/test/Fortran/F90FILESUFFIXES.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F90FILESUFFIXES2.py b/test/Fortran/F90FILESUFFIXES2.py index ab62ca7..7039530 100644 --- a/test/Fortran/F90FILESUFFIXES2.py +++ b/test/Fortran/F90FILESUFFIXES2.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F90FLAGS.py b/test/Fortran/F90FLAGS.py index f0b3003..8eaa938 100644 --- a/test/Fortran/F90FLAGS.py +++ b/test/Fortran/F90FLAGS.py @@ -27,14 +27,14 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link + _python_ = TestSCons._python_ test = TestSCons.TestSCons() _exe = TestSCons._exe -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F95.py b/test/Fortran/F95.py index e7745b1..56c6edd 100644 --- a/test/Fortran/F95.py +++ b/test/Fortran/F95.py @@ -26,14 +26,14 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link + _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F95COM.py b/test/Fortran/F95COM.py index 6ef6eb0..4761635 100644 --- a/test/Fortran/F95COM.py +++ b/test/Fortran/F95COM.py @@ -26,14 +26,14 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link + _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import sys diff --git a/test/Fortran/F95FILESUFFIXES.py b/test/Fortran/F95FILESUFFIXES.py index 119629d..8643a24 100644 --- a/test/Fortran/F95FILESUFFIXES.py +++ b/test/Fortran/F95FILESUFFIXES.py @@ -26,14 +26,14 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link + _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F95FILESUFFIXES2.py b/test/Fortran/F95FILESUFFIXES2.py index d89839b..d267a24 100644 --- a/test/Fortran/F95FILESUFFIXES2.py +++ b/test/Fortran/F95FILESUFFIXES2.py @@ -26,14 +26,14 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link + _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F95FLAGS.py b/test/Fortran/F95FLAGS.py index 8c3ce09..525b8cc 100644 --- a/test/Fortran/F95FLAGS.py +++ b/test/Fortran/F95FLAGS.py @@ -26,14 +26,14 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link + _python_ = TestSCons._python_ test = TestSCons.TestSCons() _exe = TestSCons._exe -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/FORTRAN.py b/test/Fortran/FORTRAN.py index 9a01fa6..c03698f 100644 --- a/test/Fortran/FORTRAN.py +++ b/test/Fortran/FORTRAN.py @@ -26,14 +26,14 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link + _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myg77.py', r""" import getopt diff --git a/test/Fortran/FORTRANCOM.py b/test/Fortran/FORTRANCOM.py index 6948b96..bf84d26 100644 --- a/test/Fortran/FORTRANCOM.py +++ b/test/Fortran/FORTRANCOM.py @@ -26,14 +26,14 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link + _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import sys diff --git a/test/Fortran/FORTRANFILESUFFIXES.py b/test/Fortran/FORTRANFILESUFFIXES.py index 92e30ea..e4b6192 100644 --- a/test/Fortran/FORTRANFILESUFFIXES.py +++ b/test/Fortran/FORTRANFILESUFFIXES.py @@ -26,14 +26,14 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link + _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/FORTRANFILESUFFIXES2.py b/test/Fortran/FORTRANFILESUFFIXES2.py index 8ba0962..79231ac 100644 --- a/test/Fortran/FORTRANFILESUFFIXES2.py +++ b/test/Fortran/FORTRANFILESUFFIXES2.py @@ -26,14 +26,14 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link + _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/FORTRANFLAGS.py b/test/Fortran/FORTRANFLAGS.py index 150000a..7dbc049 100644 --- a/test/Fortran/FORTRANFLAGS.py +++ b/test/Fortran/FORTRANFLAGS.py @@ -26,14 +26,14 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link + _python_ = TestSCons._python_ test = TestSCons.TestSCons() _exe = TestSCons._exe -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/FORTRANPPFILESUFFIXES.py b/test/Fortran/FORTRANPPFILESUFFIXES.py index e0c6974..2791b91 100644 --- a/test/Fortran/FORTRANPPFILESUFFIXES.py +++ b/test/Fortran/FORTRANPPFILESUFFIXES.py @@ -30,14 +30,14 @@ import string import sys import TestSCons -from common import write_fake_link + _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt -- cgit v0.12 From c4c2ba91c671527828fbc6ffb79421d5e487a398 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Sat, 24 Sep 2016 04:29:36 -0400 Subject: Updating tests to use fixture wrapper.py. --- fixture/wrapper.py | 5 +++-- test/AR/AR.py | 7 +------ test/AR/ARFLAGS.py | 7 +------ test/AS/ml.py | 7 +------ test/AS/nasm.py | 7 +------ test/CC/CC.py | 8 +------- test/CC/SHCC.py | 7 +------ test/CXX/CXX.py | 8 +------- test/CXX/SHCXX.py | 7 +------ test/Fortran/F03FLAGS.py | 7 +------ test/Fortran/F08.py | 7 +------ test/Fortran/F08FLAGS.py | 7 +------ test/Fortran/F77.py | 7 +------ test/Fortran/F77FLAGS.py | 7 +------ test/Fortran/F90.py | 7 +------ test/Fortran/F90FLAGS.py | 7 +------ test/Fortran/F95.py | 7 +------ test/Fortran/F95FLAGS.py | 7 +------ test/Fortran/FORTRAN.py | 7 +------ test/Fortran/FORTRANFLAGS.py | 7 +------ test/Fortran/SHF03.py | 7 +------ test/Fortran/SHF08.py | 7 +------ test/Fortran/SHF77.py | 7 +------ test/Fortran/SHF77FLAGS.py | 7 +------ test/Fortran/SHF90.py | 7 +------ test/Fortran/SHF90FLAGS.py | 7 +------ test/Fortran/SHF95.py | 7 +------ test/Fortran/SHF95FLAGS.py | 7 +------ test/Fortran/SHFORTRAN.py | 7 +------ test/Fortran/SHFORTRANFLAGS.py | 7 +------ test/Ghostscript/GSFLAGS.py | 7 +------ test/Java/JAR.py | 7 +------ test/Java/JAVAH.py | 7 +------ test/Java/RMIC.py | 7 +------ test/LEX/live.py | 6 +----- test/LINK/LINK.py | 7 +------ test/LINK/SHLINK.py | 7 +------ test/M4/M4.py | 7 +------ test/RANLIB/RANLIB.py | 7 +------ test/RANLIB/RANLIBFLAGS.py | 7 +------ test/SWIG/live.py | 7 +------ test/TAR/TAR.py | 6 +----- test/TAR/TARFLAGS.py | 6 +----- test/TEX/LATEX.py | 6 +----- test/TEX/LATEXFLAGS.py | 6 +----- test/TEX/PDFLATEX.py | 6 +----- test/TEX/PDFLATEXFLAGS.py | 6 +----- test/TEX/PDFTEX.py | 6 +----- test/TEX/PDFTEXFLAGS.py | 6 +----- test/TEX/TEX.py | 6 +----- test/TEX/TEXFLAGS.py | 6 +----- test/YACC/live.py | 7 +------ 52 files changed, 54 insertions(+), 299 deletions(-) diff --git a/fixture/wrapper.py b/fixture/wrapper.py index a797434..f02ea03 100644 --- a/fixture/wrapper.py +++ b/fixture/wrapper.py @@ -1,5 +1,6 @@ import os import sys -path = os.path.join(os.path.abspath(__file__), 'wrapper.out') -open(path, 'wb').write(b"wrapper.py\n") +if '--version' not in sys.argv and '-dumpversion' not in sys.argv: + path = os.path.join(os.path.dirname(os.path.relpath(__file__)), 'wrapper.out') + open(path, 'wb').write(b"wrapper.py\n") os.system(" ".join(sys.argv[1:])) diff --git a/test/AR/AR.py b/test/AR/AR.py index eb4c507..11687d9 100644 --- a/test/AR/AR.py +++ b/test/AR/AR.py @@ -33,12 +33,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() -test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write(b"wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(LIBS = ['foo'], LIBPATH = ['.']) diff --git a/test/AR/ARFLAGS.py b/test/AR/ARFLAGS.py index 0a9f36e..2d90752 100644 --- a/test/AR/ARFLAGS.py +++ b/test/AR/ARFLAGS.py @@ -33,12 +33,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() -test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write(b"wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(LIBS = ['foo'], LIBPATH = ['.']) diff --git a/test/AS/ml.py b/test/AS/ml.py index c377172..0506f5f 100644 --- a/test/AS/ml.py +++ b/test/AS/ml.py @@ -45,12 +45,7 @@ ml = test.where_is('ml') if not ml: test.skip_test("ml not found; skipping test\n") -test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write(b"wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ import os diff --git a/test/AS/nasm.py b/test/AS/nasm.py index 551a5ab..b436a75 100644 --- a/test/AS/nasm.py +++ b/test/AS/nasm.py @@ -74,12 +74,7 @@ for k, v in list(format_map.items()): nasm_format = v break -test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ eee = Environment(tools = ['gcc', 'gnulink', 'nasm'], diff --git a/test/CC/CC.py b/test/CC/CC.py index 7478cbe..f6c2954 100644 --- a/test/CC/CC.py +++ b/test/CC/CC.py @@ -139,13 +139,7 @@ env.Program(target = 'test2', source = 'test2.C') test.run(arguments = '.', stderr = None) 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(b"wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment() diff --git a/test/CC/SHCC.py b/test/CC/SHCC.py index 5f121fc..beda8e4 100644 --- a/test/CC/SHCC.py +++ b/test/CC/SHCC.py @@ -32,12 +32,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() -test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write(b"wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment() diff --git a/test/CXX/CXX.py b/test/CXX/CXX.py index 79dbde4..c9dbf1c 100644 --- a/test/CXX/CXX.py +++ b/test/CXX/CXX.py @@ -183,13 +183,7 @@ env.Program(target = 'test6', source = 'test6.C') -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") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment() diff --git a/test/CXX/SHCXX.py b/test/CXX/SHCXX.py index 9a78881..d6a314e 100644 --- a/test/CXX/SHCXX.py +++ b/test/CXX/SHCXX.py @@ -32,12 +32,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() -test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment() diff --git a/test/Fortran/F03FLAGS.py b/test/Fortran/F03FLAGS.py index b11b780..4e99db8 100644 --- a/test/Fortran/F03FLAGS.py +++ b/test/Fortran/F03FLAGS.py @@ -103,12 +103,7 @@ g03 = test.detect_tool(fc) if g03: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(F03 = '%(fc)s') diff --git a/test/Fortran/F08.py b/test/Fortran/F08.py index b61b861..a28389e 100644 --- a/test/Fortran/F08.py +++ b/test/Fortran/F08.py @@ -96,12 +96,7 @@ g08 = test.detect_tool(fc) if g08: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(F08 = '%(fc)s') diff --git a/test/Fortran/F08FLAGS.py b/test/Fortran/F08FLAGS.py index 34f3d75..c693c82 100644 --- a/test/Fortran/F08FLAGS.py +++ b/test/Fortran/F08FLAGS.py @@ -103,12 +103,7 @@ g08 = test.detect_tool(fc) if g08: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(F08 = '%(fc)s') diff --git a/test/Fortran/F77.py b/test/Fortran/F77.py index 300df85..8fdd391 100644 --- a/test/Fortran/F77.py +++ b/test/Fortran/F77.py @@ -94,12 +94,7 @@ f77 = test.detect_tool(fc) if f77: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(F77 = '%(fc)s', tools = ['default', 'f77'], F77FILESUFFIXES = ['.f']) diff --git a/test/Fortran/F77FLAGS.py b/test/Fortran/F77FLAGS.py index 8e972ec..9b4c56c 100644 --- a/test/Fortran/F77FLAGS.py +++ b/test/Fortran/F77FLAGS.py @@ -78,12 +78,7 @@ if g77: directory = 'x' test.subdir(directory) - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(F77 = '%(fc)s', tools = ['default', 'f77'], F77FILESUFFIXES = [".f"]) diff --git a/test/Fortran/F90.py b/test/Fortran/F90.py index bbceaac..633b174 100644 --- a/test/Fortran/F90.py +++ b/test/Fortran/F90.py @@ -96,12 +96,7 @@ g90 = test.detect_tool(fc) if g90: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(F90 = '%(fc)s') diff --git a/test/Fortran/F90FLAGS.py b/test/Fortran/F90FLAGS.py index 8eaa938..cf2b3b3 100644 --- a/test/Fortran/F90FLAGS.py +++ b/test/Fortran/F90FLAGS.py @@ -105,12 +105,7 @@ g90 = test.detect_tool(fc) if g90: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(F90 = '%(fc)s') diff --git a/test/Fortran/F95.py b/test/Fortran/F95.py index 56c6edd..0912f71 100644 --- a/test/Fortran/F95.py +++ b/test/Fortran/F95.py @@ -98,12 +98,7 @@ g95 = test.detect_tool(fc) if g95: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(F95 = '%(fc)s') diff --git a/test/Fortran/F95FLAGS.py b/test/Fortran/F95FLAGS.py index 525b8cc..cc5a5e3 100644 --- a/test/Fortran/F95FLAGS.py +++ b/test/Fortran/F95FLAGS.py @@ -111,12 +111,7 @@ if g95: # Exists only such that -Ix finds the directory... """) - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(F95 = '%(fc)s') diff --git a/test/Fortran/FORTRAN.py b/test/Fortran/FORTRAN.py index c03698f..577421e 100644 --- a/test/Fortran/FORTRAN.py +++ b/test/Fortran/FORTRAN.py @@ -90,12 +90,7 @@ f77 = test.detect_tool(fc) if f77: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(FORTRAN = '%(fc)s') diff --git a/test/Fortran/FORTRANFLAGS.py b/test/Fortran/FORTRANFLAGS.py index 7dbc049..7b9f7d7 100644 --- a/test/Fortran/FORTRANFLAGS.py +++ b/test/Fortran/FORTRANFLAGS.py @@ -98,12 +98,7 @@ if g77: directory = 'x' test.subdir(directory) - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(FORTRAN = '%(fc)s') diff --git a/test/Fortran/SHF03.py b/test/Fortran/SHF03.py index 6502f49..d514f64 100644 --- a/test/Fortran/SHF03.py +++ b/test/Fortran/SHF03.py @@ -95,12 +95,7 @@ g03 = test.detect_tool(fc) if g03: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(SHF03 = '%(fc)s') diff --git a/test/Fortran/SHF08.py b/test/Fortran/SHF08.py index 85f2bcd..0aed858 100644 --- a/test/Fortran/SHF08.py +++ b/test/Fortran/SHF08.py @@ -95,12 +95,7 @@ g08 = test.detect_tool(fc) if g08: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(SHF08 = '%(fc)s') diff --git a/test/Fortran/SHF77.py b/test/Fortran/SHF77.py index ff2a0ca..3c2565b 100644 --- a/test/Fortran/SHF77.py +++ b/test/Fortran/SHF77.py @@ -94,12 +94,7 @@ f77 = test.detect_tool(fc) if f77: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(SHF77 = '%(fc)s') diff --git a/test/Fortran/SHF77FLAGS.py b/test/Fortran/SHF77FLAGS.py index 79e46f3..1b9628c 100644 --- a/test/Fortran/SHF77FLAGS.py +++ b/test/Fortran/SHF77FLAGS.py @@ -78,12 +78,7 @@ if g77: directory = 'x' test.subdir(directory) - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(SHF77 = '%(fc)s') diff --git a/test/Fortran/SHF90.py b/test/Fortran/SHF90.py index 486b57b..46bf4ae 100644 --- a/test/Fortran/SHF90.py +++ b/test/Fortran/SHF90.py @@ -96,12 +96,7 @@ g90 = test.detect_tool(fc) if g90: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(SHF90 = '%(fc)s') diff --git a/test/Fortran/SHF90FLAGS.py b/test/Fortran/SHF90FLAGS.py index d5066c6..0f9e2ba3 100644 --- a/test/Fortran/SHF90FLAGS.py +++ b/test/Fortran/SHF90FLAGS.py @@ -101,12 +101,7 @@ g90 = test.detect_tool(fc) if g90: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(SHF90 = '%(fc)s') diff --git a/test/Fortran/SHF95.py b/test/Fortran/SHF95.py index 0b64923..6329c9e 100644 --- a/test/Fortran/SHF95.py +++ b/test/Fortran/SHF95.py @@ -95,12 +95,7 @@ g95 = test.detect_tool(fc) if g95: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(SHF95 = '%(fc)s') diff --git a/test/Fortran/SHF95FLAGS.py b/test/Fortran/SHF95FLAGS.py index 8e75878..e573eb4 100644 --- a/test/Fortran/SHF95FLAGS.py +++ b/test/Fortran/SHF95FLAGS.py @@ -110,12 +110,7 @@ if g95: # Exists only such that -Ix finds the directory... """) - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(SHF95 = '%(fc)s') diff --git a/test/Fortran/SHFORTRAN.py b/test/Fortran/SHFORTRAN.py index d9ae55d..fdcba7f 100644 --- a/test/Fortran/SHFORTRAN.py +++ b/test/Fortran/SHFORTRAN.py @@ -89,12 +89,7 @@ fortran = test.detect_tool(fc) if fortran: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(SHFORTRAN = '%(fc)s') diff --git a/test/Fortran/SHFORTRANFLAGS.py b/test/Fortran/SHFORTRANFLAGS.py index 8e6f019..7067c6f 100644 --- a/test/Fortran/SHFORTRANFLAGS.py +++ b/test/Fortran/SHFORTRANFLAGS.py @@ -94,12 +94,7 @@ if fortran: directory = 'x' test.subdir(directory) - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(SHFORTRAN = '%(fc)s') diff --git a/test/Ghostscript/GSFLAGS.py b/test/Ghostscript/GSFLAGS.py index 16ad6c1..c8e0668 100644 --- a/test/Ghostscript/GSFLAGS.py +++ b/test/Ghostscript/GSFLAGS.py @@ -82,12 +82,7 @@ gs = test.where_is(gs_executable) if gs: - test.write("wrapper.py", """import os -import sys -cmd = " ".join(sys.argv[1:]) -open('%s', 'ab').write("%%s\\n" %% cmd) -os.system(cmd) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """\ import os diff --git a/test/Java/JAR.py b/test/Java/JAR.py index 81664dc..98dfa38 100644 --- a/test/Java/JAR.py +++ b/test/Java/JAR.py @@ -124,12 +124,7 @@ where_jar = test.java_where_jar() -test.write("wrapper.py", """\ -import os -import sys -open('%s', 'ab').write("wrapper.py %%s\\n" %% " ".join(sys.argv[1:])) -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(tools = ['javac', 'jar'], diff --git a/test/Java/JAVAH.py b/test/Java/JAVAH.py index 81582d7..f647b03 100644 --- a/test/Java/JAVAH.py +++ b/test/Java/JAVAH.py @@ -105,12 +105,7 @@ if java_version: if test.javac_is_gcj: test.skip_test('Test not valid for gcj (gnu java); skipping test(s).\n') -test.write("wrapper.py", """\ -import os -import sys -open('%s', 'ab').write("wrapper.py %%s\\n" %% " ".join(sys.argv[1:])) -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(tools = ['javac', 'javah', 'install'], diff --git a/test/Java/RMIC.py b/test/Java/RMIC.py index 876ed80..5f5decd 100644 --- a/test/Java/RMIC.py +++ b/test/Java/RMIC.py @@ -111,12 +111,7 @@ if java_version.count('.') == 1: # Note, how we allow simple version strings like "5" and # "6" to successfully pass this test. if curver < (1, 8): - test.write("wrapper.py", """\ -import os -import sys -open('%s', 'ab').write("wrapper.py %%s\\n" %% " ".join(sys.argv[1:])) -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(tools = ['javac', 'rmic'], diff --git a/test/LEX/live.py b/test/LEX/live.py index 2abb8ce..3d697d5 100644 --- a/test/LEX/live.py +++ b/test/LEX/live.py @@ -42,11 +42,7 @@ if not lex: -test.write("wrapper.py", """import os -import sys -open('%s', 'wb').write(b"wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment() diff --git a/test/LINK/LINK.py b/test/LINK/LINK.py index 54c75fa..533163c 100644 --- a/test/LINK/LINK.py +++ b/test/LINK/LINK.py @@ -33,12 +33,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() -test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write(("wrapper.py\\n").encode()) -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment() diff --git a/test/LINK/SHLINK.py b/test/LINK/SHLINK.py index 7353996..9b546c7 100644 --- a/test/LINK/SHLINK.py +++ b/test/LINK/SHLINK.py @@ -34,12 +34,7 @@ _shlib = TestSCons._dll test = TestSCons.TestSCons() -test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write(b"wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment() diff --git a/test/M4/M4.py b/test/M4/M4.py index d2b8365..4306558 100644 --- a/test/M4/M4.py +++ b/test/M4/M4.py @@ -67,12 +67,7 @@ m4 = test.where_is('m4') if m4: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write(b"wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(tools=['default', 'm4'], diff --git a/test/RANLIB/RANLIB.py b/test/RANLIB/RANLIB.py index fbfe36c..8d64b36 100644 --- a/test/RANLIB/RANLIB.py +++ b/test/RANLIB/RANLIB.py @@ -39,12 +39,7 @@ ranlib = test.detect('RANLIB', 'ranlib') if not ranlib: test.skip_test("Could not find 'ranlib', skipping test.\n") -test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(LIBS = ['foo'], LIBPATH = ['.']) diff --git a/test/RANLIB/RANLIBFLAGS.py b/test/RANLIB/RANLIBFLAGS.py index 86e5283..0de0cdc 100644 --- a/test/RANLIB/RANLIBFLAGS.py +++ b/test/RANLIB/RANLIBFLAGS.py @@ -38,12 +38,7 @@ ranlib = test.detect('RANLIB', 'ranlib') if not ranlib: test.skip_test("Could not find 'ranlib', skipping test.\n") -test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(LIBS = ['foo'], LIBPATH = ['.']) diff --git a/test/SWIG/live.py b/test/SWIG/live.py index 7d79bae..5e95dc7 100644 --- a/test/SWIG/live.py +++ b/test/SWIG/live.py @@ -61,12 +61,7 @@ if sys.platform == 'win32' and sys.maxsize <= 2**32: else: swig_arch_var="" -test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """\ foo = Environment(SWIGFLAGS='-python', diff --git a/test/TAR/TAR.py b/test/TAR/TAR.py index 93c5cea..8aa2747 100644 --- a/test/TAR/TAR.py +++ b/test/TAR/TAR.py @@ -88,11 +88,7 @@ tar = test.detect('TAR', 'tar') if tar: - test.write("wrapper.py", """import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment() diff --git a/test/TAR/TARFLAGS.py b/test/TAR/TARFLAGS.py index 96d61fe..034539c 100644 --- a/test/TAR/TARFLAGS.py +++ b/test/TAR/TARFLAGS.py @@ -94,11 +94,7 @@ tar = test.detect('TAR', 'tar') if tar: - test.write("wrapper.py", """import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment() diff --git a/test/TEX/LATEX.py b/test/TEX/LATEX.py index 03d3a00..c6f58e6 100644 --- a/test/TEX/LATEX.py +++ b/test/TEX/LATEX.py @@ -96,11 +96,7 @@ latex = test.where_is('latex') if latex: - test.write("wrapper.py", """import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ import os diff --git a/test/TEX/LATEXFLAGS.py b/test/TEX/LATEXFLAGS.py index f693970..46e0479 100644 --- a/test/TEX/LATEXFLAGS.py +++ b/test/TEX/LATEXFLAGS.py @@ -80,11 +80,7 @@ latex = test.where_is('latex') if latex: - test.write("wrapper.py", """import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ import os diff --git a/test/TEX/PDFLATEX.py b/test/TEX/PDFLATEX.py index dbae623..dece385 100644 --- a/test/TEX/PDFLATEX.py +++ b/test/TEX/PDFLATEX.py @@ -96,11 +96,7 @@ pdflatex = test.where_is('pdflatex') if pdflatex: - test.write("wrapper.py", """import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ import os diff --git a/test/TEX/PDFLATEXFLAGS.py b/test/TEX/PDFLATEXFLAGS.py index deee9ed..ffed20b 100644 --- a/test/TEX/PDFLATEXFLAGS.py +++ b/test/TEX/PDFLATEXFLAGS.py @@ -80,11 +80,7 @@ pdflatex = test.where_is('pdflatex') if pdflatex: - test.write("wrapper.py", """import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ import os diff --git a/test/TEX/PDFTEX.py b/test/TEX/PDFTEX.py index 321a58a..5a958d5 100644 --- a/test/TEX/PDFTEX.py +++ b/test/TEX/PDFTEX.py @@ -83,11 +83,7 @@ pdftex = test.where_is('pdftex') if pdftex: - test.write("wrapper.py", """import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ import os diff --git a/test/TEX/PDFTEXFLAGS.py b/test/TEX/PDFTEXFLAGS.py index ce27e82..06dc780 100644 --- a/test/TEX/PDFTEXFLAGS.py +++ b/test/TEX/PDFTEXFLAGS.py @@ -73,11 +73,7 @@ pdftex = test.where_is('pdftex') if pdftex: - test.write("wrapper.py", """import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ import os diff --git a/test/TEX/TEX.py b/test/TEX/TEX.py index e1d634f..3e48419 100644 --- a/test/TEX/TEX.py +++ b/test/TEX/TEX.py @@ -86,11 +86,7 @@ tex = test.where_is('tex') if tex: - test.write("wrapper.py", """import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ import os diff --git a/test/TEX/TEXFLAGS.py b/test/TEX/TEXFLAGS.py index 7ae86ff..e21aaa9 100644 --- a/test/TEX/TEXFLAGS.py +++ b/test/TEX/TEXFLAGS.py @@ -73,11 +73,7 @@ tex = test.where_is('tex') if tex: - test.write("wrapper.py", """import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ import os diff --git a/test/YACC/live.py b/test/YACC/live.py index e125daa..253a387 100644 --- a/test/YACC/live.py +++ b/test/YACC/live.py @@ -40,12 +40,7 @@ yacc = test.where_is('yacc') or test.where_is('bison') if not yacc: test.skip_test('No yacc or bison found; skipping test.\n') -test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write(b"wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(YACCFLAGS='-d') -- cgit v0.12 From db1903ca5df83294d9f38f521058b75a7f647c1c Mon Sep 17 00:00:00 2001 From: William Blevins Date: Sat, 24 Sep 2016 06:03:34 -0400 Subject: Ensuring that FS.get_text_contents returns actual text. --- src/engine/SCons/Node/FS.py | 8 ++++++-- src/engine/SCons/Tool/FortranCommon.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 9b7e105..0de3989 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -696,7 +696,7 @@ class Base(SCons.Node.Node): return self._memo['_save_str'] except KeyError: pass - result = sys.intern(self._get_str()) + result = SCons.Util.silent_intern(self._get_str()) self._memo['_save_str'] = result return result @@ -2670,7 +2670,11 @@ class File(Base): return contents[len(codecs.BOM_UTF16_LE):].decode('utf-16-le') if contents.startswith(codecs.BOM_UTF16_BE): return contents[len(codecs.BOM_UTF16_BE):].decode('utf-16-be') - return contents + try: + return contents.decode() + except UnicodeDecodeError: + return contents + def get_content_hash(self): """ diff --git a/src/engine/SCons/Tool/FortranCommon.py b/src/engine/SCons/Tool/FortranCommon.py index 1503639..e450730 100644 --- a/src/engine/SCons/Tool/FortranCommon.py +++ b/src/engine/SCons/Tool/FortranCommon.py @@ -64,7 +64,7 @@ def _fortranEmitter(target, source, env): if not node.exists() and not node.is_derived(): print("Could not locate " + str(node.name)) return ([], []) - mod_regex = b"(?i)^\s*MODULE\s+(?!PROCEDURE)(\w+)" + mod_regex = """(?i)^\s*MODULE\s+(?!PROCEDURE)(\w+)""" cre = re.compile(mod_regex,re.M) # Retrieve all USE'd module names modules = cre.findall(node.get_text_contents()) -- cgit v0.12 From 203e9a690d471e53c88e6fe577188593c98bd9ef Mon Sep 17 00:00:00 2001 From: William Blevins Date: Sat, 24 Sep 2016 06:13:49 -0400 Subject: Revert src/engine/SCons/Scanner/Fortran.py changes. --- src/engine/SCons/Scanner/Fortran.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/engine/SCons/Scanner/Fortran.py b/src/engine/SCons/Scanner/Fortran.py index 9082015..1b55130 100644 --- a/src/engine/SCons/Scanner/Fortran.py +++ b/src/engine/SCons/Scanner/Fortran.py @@ -82,11 +82,11 @@ class F90Scanner(SCons.Scanner.Classic): mods_and_includes = node.includes else: # retrieve all included filenames - includes = self.cre_incl.findall(node.get_contents()) + includes = self.cre_incl.findall(node.get_text_contents()) # retrieve all USE'd module names - modules = self.cre_use.findall(node.get_contents()) + modules = self.cre_use.findall(node.get_text_contents()) # retrieve all defined module names - defmodules = self.cre_def.findall(node.get_contents()) + defmodules = self.cre_def.findall(node.get_text_contents()) # Remove all USE'd module names that are defined in the same file # (case-insensitively) @@ -187,7 +187,7 @@ def FortranScan(path_variable="FORTRANPATH"): # (\w+) : match the module name that is being USE'd # # - use_regex = b"(?i)(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)" + use_regex = "(?i)(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)" # The INCLUDE statement regex matches the following: @@ -275,7 +275,7 @@ def FortranScan(path_variable="FORTRANPATH"): # set of semicolon-separated INCLUDE statements # (as allowed by the F2003 standard) - include_regex = b"(?i)(?:^|['\">]\s*;)\s*INCLUDE\s+(?:\w+_)?[<\"'](.+?)(?=[\"'>])" + include_regex = """(?i)(?:^|['">]\s*;)\s*INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])""" # The MODULE statement regex finds module definitions by matching # the following: @@ -299,7 +299,7 @@ def FortranScan(path_variable="FORTRANPATH"): # that make up the defined module name and # save it in a group - def_regex = b"(?i)^\s*MODULE\s+(?!PROCEDURE)(\w+)" + def_regex = """(?i)^\s*MODULE\s+(?!PROCEDURE)(\w+)""" scanner = F90Scanner("FortranScan", "$FORTRANSUFFIXES", -- cgit v0.12 From 6dd3fd8b838d18d65edd6e7adabf3a363437f8a9 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Sat, 24 Sep 2016 18:36:07 -0400 Subject: Moved fixture directory under #test. --- fixture/mylink.py | 31 ------------------------------- fixture/wrapper.py | 6 ------ runtest.py | 2 +- test/fixture/mylink.py | 31 +++++++++++++++++++++++++++++++ test/fixture/sconstest.skip | 0 test/fixture/wrapper.py | 6 ++++++ 6 files changed, 38 insertions(+), 38 deletions(-) delete mode 100644 fixture/mylink.py delete mode 100644 fixture/wrapper.py create mode 100644 test/fixture/mylink.py create mode 100644 test/fixture/sconstest.skip create mode 100644 test/fixture/wrapper.py diff --git a/fixture/mylink.py b/fixture/mylink.py deleted file mode 100644 index 7c03f00..0000000 --- a/fixture/mylink.py +++ /dev/null @@ -1,31 +0,0 @@ -import sys - -if sys.platform == 'win32': - args = sys.argv[1:] - while args: - a = args[0] - if a == '-o': - out = args[1] - args = args[2:] - continue - if not a[0] in '/-': - break - args = args[1:] - if a[:5].lower() == '/out:': out = a[5:] - infile = open(args[0], 'rb') - outfile = open(out, 'wb') - for l in infile.readlines(): - if l[:5] != b'#link': - outfile.write(l) - sys.exit(0) -else: - import getopt - opts, args = getopt.getopt(sys.argv[1:], 'o:') - for opt, arg in opts: - if opt == '-o': out = arg - infile = open(args[0], 'rb') - outfile = open(out, 'wb') - for l in infile.readlines(): - if l[:5] != b'#link': - outfile.write(l) - sys.exit(0) diff --git a/fixture/wrapper.py b/fixture/wrapper.py deleted file mode 100644 index f02ea03..0000000 --- a/fixture/wrapper.py +++ /dev/null @@ -1,6 +0,0 @@ -import os -import sys -if '--version' not in sys.argv and '-dumpversion' not in sys.argv: - path = os.path.join(os.path.dirname(os.path.relpath(__file__)), 'wrapper.out') - open(path, 'wb').write(b"wrapper.py\n") -os.system(" ".join(sys.argv[1:])) diff --git a/runtest.py b/runtest.py index c856740..d636b73 100755 --- a/runtest.py +++ b/runtest.py @@ -789,7 +789,7 @@ def run_test(t, io_lock, async=True): fixture_dirs = [] if head: fixture_dirs.append(head) - fixture_dirs.append(os.path.join(scriptpath, 'fixture')) + fixture_dirs.append(os.path.join(scriptpath, 'test', 'fixture')) os.environ['FIXTURE_DIRS'] = ':'.join(fixture_dirs) test_start_time = time_func() diff --git a/test/fixture/mylink.py b/test/fixture/mylink.py new file mode 100644 index 0000000..7c03f00 --- /dev/null +++ b/test/fixture/mylink.py @@ -0,0 +1,31 @@ +import sys + +if sys.platform == 'win32': + args = sys.argv[1:] + while args: + a = args[0] + if a == '-o': + out = args[1] + args = args[2:] + continue + if not a[0] in '/-': + break + args = args[1:] + if a[:5].lower() == '/out:': out = a[5:] + infile = open(args[0], 'rb') + outfile = open(out, 'wb') + for l in infile.readlines(): + if l[:5] != b'#link': + outfile.write(l) + sys.exit(0) +else: + import getopt + opts, args = getopt.getopt(sys.argv[1:], 'o:') + for opt, arg in opts: + if opt == '-o': out = arg + infile = open(args[0], 'rb') + outfile = open(out, 'wb') + for l in infile.readlines(): + if l[:5] != b'#link': + outfile.write(l) + sys.exit(0) diff --git a/test/fixture/sconstest.skip b/test/fixture/sconstest.skip new file mode 100644 index 0000000..e69de29 diff --git a/test/fixture/wrapper.py b/test/fixture/wrapper.py new file mode 100644 index 0000000..f02ea03 --- /dev/null +++ b/test/fixture/wrapper.py @@ -0,0 +1,6 @@ +import os +import sys +if '--version' not in sys.argv and '-dumpversion' not in sys.argv: + path = os.path.join(os.path.dirname(os.path.relpath(__file__)), 'wrapper.out') + open(path, 'wb').write(b"wrapper.py\n") +os.system(" ".join(sys.argv[1:])) -- cgit v0.12 From f3a1b325d4baf5f4bc554a596b676e2029046b7c Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 30 Sep 2016 15:02:36 -0400 Subject: fix some formatting --- QMTest/TestSCons.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index a515684..69e1bbb 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -47,17 +47,18 @@ SConsVersion = '__VERSION__' if SConsVersion == '__' + 'VERSION' + '__': SConsVersion = default_version -__all__.extend([ 'TestSCons', - 'machine', - 'python', - '_exe', - '_obj', - '_shobj', - 'shobj_', - 'lib_', - '_lib', - 'dll_', - '_dll' +__all__.extend([ + 'TestSCons', + 'machine', + 'python', + '_exe', + '_obj', + '_shobj', + 'shobj_', + 'lib_', + '_lib', + 'dll_', + '_dll' ]) machine_map = { -- cgit v0.12 From cff6d51e2d64ab0a716c1321ea5afb1c99a12b52 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 30 Sep 2016 16:54:12 -0400 Subject: PEP8 fixes. --- src/engine/SCons/compat/__init__.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/engine/SCons/compat/__init__.py b/src/engine/SCons/compat/__init__.py index c6c7214..477b67c 100644 --- a/src/engine/SCons/compat/__init__.py +++ b/src/engine/SCons/compat/__init__.py @@ -61,10 +61,11 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os import sys -import imp # Use the "imp" module to protect imports from fixers. +import imp # Use the "imp" module to protect imports from fixers. PYPY = hasattr(sys, 'pypy_translation_info') + def import_as(module, name): """ Imports the specified module (from our local directory) as the @@ -73,6 +74,7 @@ def import_as(module, name): dir = os.path.split(__file__)[0] return imp.load_module(name, *imp.find_module(module, [dir])) + def rename_module(new, old): """ Attempts to import the old module and load it under the new name. @@ -84,6 +86,7 @@ def rename_module(new, old): except ImportError: return False + # TODO: FIXME # In 3.x, 'pickle' automatically loads the fast version if available. rename_module('pickle', 'cPickle') @@ -92,7 +95,8 @@ rename_module('pickle', 'cPickle') # but incompatible with older Python versions. On Python 2.7 this is 2. # Negative numbers choose the highest available protocol. import pickle -PICKLE_PROTOCOL=pickle.HIGHEST_PROTOCOL + +PICKLE_PROTOCOL = pickle.HIGHEST_PROTOCOL # TODO: FIXME # In 3.x, 'profile' automatically loads the fast version if available. @@ -106,7 +110,6 @@ rename_module('queue', 'Queue') # Before Python 3.0, the 'winreg' module was named '_winreg' rename_module('winreg', '_winreg') - # Python 3 moved builtin intern() to sys package # To make porting easier, make intern always live # in sys package (for python 2.7.x) @@ -117,28 +120,28 @@ except AttributeError: # intern into the sys package sys.intern = intern - # Preparing for 3.x. UserDict, UserList, UserString are in # collections for 3.x, but standalone in 2.7.x import collections + try: collections.UserDict except AttributeError: - exec('from UserDict import UserDict as _UserDict') + exec ('from UserDict import UserDict as _UserDict') collections.UserDict = _UserDict del _UserDict try: collections.UserList except AttributeError: - exec('from UserList import UserList as _UserList') + exec ('from UserList import UserList as _UserList') collections.UserList = _UserList del _UserList try: collections.UserString except AttributeError: - exec('from UserString import UserString as _UserString') + exec ('from UserString import UserString as _UserString') collections.UserString = _UserString del _UserString @@ -168,13 +171,16 @@ def with_metaclass(meta, *bases): This has the advantage over six.with_metaclass of not introducing dummy classes into the final MRO. """ + class metaclass(meta): __call__ = type.__call__ __init__ = type.__init__ + def __new__(cls, name, this_bases, d): if this_bases is None: return type.__new__(cls, name, (), d) return meta(name, bases, d) + return metaclass('temporary_class', None, {}) @@ -182,12 +188,12 @@ class NoSlotsPyPy(type): """ Workaround for PyPy not working well with __slots__ and __class__ assignment. """ + def __new__(meta, name, bases, dct): if PYPY and '__slots__' in dct: dct.pop('__slots__') return super(NoSlotsPyPy, meta).__new__(meta, name, bases, dct) - # Local Variables: # tab-width:4 # indent-tabs-mode:nil -- cgit v0.12 From 398b8988f37034f4f6e9639ede26581af7a5a2b3 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Sun, 2 Oct 2016 01:30:02 -0400 Subject: Fixes for str/bytes in Scanners: resolves ~150 tests. --- src/engine/SCons/Scanner/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/SCons/Scanner/__init__.py b/src/engine/SCons/Scanner/__init__.py index 5700fe9..28be642 100644 --- a/src/engine/SCons/Scanner/__init__.py +++ b/src/engine/SCons/Scanner/__init__.py @@ -324,7 +324,7 @@ class Classic(Current): def __init__(self, name, suffixes, path_variable, regex, *args, **kw): - self.cre = re.compile(SCons.Util.to_bytes(regex), re.M) + self.cre = re.compile(regex, re.M) def _scan(node, env, path=(), self=self): node = node.rfile() @@ -405,7 +405,7 @@ class ClassicCPP(Classic): return n, i def sort_key(self, include): - return SCons.Node.FS._my_normcase(b' '.join(include)) + return SCons.Node.FS._my_normcase(' '.join(include)) # Local Variables: # tab-width:4 -- cgit v0.12 From 40cb13a34b33464fa2acd3a1b12e792ca059e67d Mon Sep 17 00:00:00 2001 From: William Blevins Date: Sun, 2 Oct 2016 01:41:50 -0400 Subject: Fixed src/engine/SCons/ExecutorTests.py under Python3 --- src/engine/SCons/ExecutorTests.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/engine/SCons/ExecutorTests.py b/src/engine/SCons/ExecutorTests.py index 99c6226..dbfb7d1 100644 --- a/src/engine/SCons/ExecutorTests.py +++ b/src/engine/SCons/ExecutorTests.py @@ -53,7 +53,11 @@ class MyAction(object): def genstring(self, target, source, env): return ' '.join(['GENSTRING'] + list(map(str, self.actions)) + target + source) def get_contents(self, target, source, env): - return ' '.join(self.actions + target + source) + return b' '.join( + [SCons.Util.to_bytes(aa) for aa in self.actions] + + [SCons.Util.to_bytes(tt) for tt in target] + + [SCons.Util.to_bytes(ss) for ss in source] + ) def get_implicit_deps(self, target, source, env): return [] @@ -381,14 +385,14 @@ class ExecutorTestCase(unittest.TestCase): x = SCons.Executor.Executor(MyAction(), env, [], ['t'], ['s']) c = x.get_contents() - assert c == 'action1 action2 t s', c + assert c == b'action1 action2 t s', c x = SCons.Executor.Executor(MyAction(actions=['grow']), env, [], ['t'], ['s']) x.add_pre_action(MyAction(['pre'])) x.add_post_action(MyAction(['post'])) c = x.get_contents() - assert c == 'pre t sgrow t spost t s', c + assert c == b'pre t sgrow t spost t s', c def test_get_timestamp(self): """Test fetching the "timestamp" """ -- cgit v0.12 From 5587089a661a520a32c353ea886939cd63a0636a Mon Sep 17 00:00:00 2001 From: William Blevins Date: Mon, 3 Oct 2016 02:08:04 -0400 Subject: Moved common my.py functions to global fixture and resolve byte/str. --- test/AR/ARCOM.py | 26 ++++----------- test/AR/ARCOMSTR.py | 26 ++++----------- test/AS/ASCOM.py | 31 ++++++------------ test/AS/ASCOMSTR.py | 23 ++++---------- test/AS/ASPPCOM.py | 23 ++++---------- test/AS/ASPPCOMSTR.py | 19 +++-------- test/CC/CCCOM.py | 9 +++--- test/CC/CCCOMSTR.py | 9 +++--- test/CC/SHCCCOM.py | 8 ++--- test/CC/SHCCCOMSTR.py | 7 ++-- test/CC/shared-fixture/.exclude_tests | 1 - test/CC/shared-fixture/mycc.py | 6 ---- test/CC/shared-fixture/test1.c | 2 -- test/CXX/CXXCOM.py | 16 ++-------- test/CXX/CXXCOMSTR.py | 14 ++------ test/CXX/SHCXXCOM.py | 15 ++------- test/CXX/SHCXXCOMSTR.py | 16 ++-------- test/DVIPDF/DVIPDFCOM.py | 16 ++-------- test/DVIPDF/DVIPDFCOMSTR.py | 16 ++-------- test/DVIPS/PSCOM.py | 16 ++-------- test/DVIPS/PSCOMSTR.py | 16 ++-------- test/Fortran/F03COM.py | 48 +++++++++++----------------- test/Fortran/F03COMSTR.py | 20 +++--------- test/Fortran/F08COM.py | 40 +++++++++-------------- test/Fortran/F08COMSTR.py | 20 +++--------- test/Fortran/F77COM.py | 40 +++++++++-------------- test/Fortran/F77COMSTR.py | 20 +++--------- test/Fortran/F90COM.py | 48 +++++++++++----------------- test/Fortran/F90COMSTR.py | 20 +++--------- test/Fortran/F95COM.py | 52 ++++++++++++------------------ test/Fortran/F95COMSTR.py | 20 +++--------- test/Fortran/FORTRANCOM.py | 34 +++++++------------- test/Fortran/FORTRANCOMSTR.py | 32 +++++++------------ test/Fortran/SHF77COM.py | 43 +++++++++---------------- test/Fortran/SHF77COMSTR.py | 36 ++++++++------------- test/Fortran/SHF90COM.py | 53 ++++++++++++------------------- test/Fortran/SHF90COMSTR.py | 21 +++--------- test/Fortran/SHF95COM.py | 53 ++++++++++++------------------- test/Fortran/SHF95COMSTR.py | 20 +++--------- test/Fortran/SHFORTRANCOM.py | 35 +++++++------------- test/Fortran/SHFORTRANCOMSTR.py | 32 +++++++------------ test/Ghostscript/GSCOM.py | 16 ++-------- test/Ghostscript/GSCOMSTR.py | 16 ++-------- test/IDL/MIDLCOMSTR.py | 16 ++-------- test/Java/JARCOM.py | 15 ++------- test/Java/JARCOMSTR.py | 16 ++-------- test/Java/JAVACCOM.py | 16 ++-------- test/Java/JAVACCOMSTR.py | 16 ++-------- test/Java/JAVAHCOM.py | 16 ++-------- test/Java/JAVAHCOMSTR.py | 18 ++--------- test/Java/RMICCOM.py | 18 ++--------- test/Java/RMICCOMSTR.py | 18 ++--------- test/LEX/LEXCOM.py | 16 ++-------- test/LEX/LEXCOMSTR.py | 16 ++-------- test/LINK/LINKCOM.py | 14 ++------ test/LINK/LINKCOMSTR.py | 14 ++------ test/LINK/SHLINKCOM.py | 29 ++--------------- test/LINK/SHLINKCOMSTR.py | 30 +++-------------- test/MSVC/PCHCOM.py | 16 ++-------- test/MSVC/PCHCOMSTR.py | 16 ++-------- test/MSVC/RCCOM.py | 16 ++-------- test/MSVC/RCCOMSTR.py | 16 ++-------- test/MinGW/RCCOM.py | 14 ++------ test/MinGW/RCCOMSTR.py | 14 ++------ test/RANLIB/RANLIBCOM.py | 28 +++------------- test/RANLIB/RANLIBCOMSTR.py | 28 +++------------- test/SWIG/SWIGCOM.py | 16 ++-------- test/SWIG/SWIGCOMSTR.py | 16 ++-------- test/TAR/TARCOM.py | 15 ++------- test/TAR/TARCOMSTR.py | 16 ++-------- test/TEX/LATEXCOM.py | 16 ++-------- test/TEX/LATEXCOMSTR.py | 16 ++-------- test/TEX/PDFLATEXCOM.py | 16 ++-------- test/TEX/PDFLATEXCOMSTR.py | 16 ++-------- test/TEX/PDFTEXCOM.py | 16 ++-------- test/TEX/PDFTEXCOMSTR.py | 16 ++-------- test/TEX/TEXCOM.py | 16 ++-------- test/TEX/TEXCOMSTR.py | 16 ++-------- test/YACC/YACCCOM-fixture/.exclude_tests | 1 - test/YACC/YACCCOM-fixture/myyacc.py | 7 ---- test/YACC/YACCCOM.py | 10 +++--- test/YACC/YACCCOMSTR.py | 10 +++--- test/YACC/shared-fixture/.exclude_tests | 1 - test/YACC/shared-fixture/aaa.y | 2 -- test/YACC/shared-fixture/bbb.yacc | 2 -- test/ZIP/ZIPCOM-fixture/.exclude_tests | 1 - test/ZIP/ZIPCOM-fixture/myzip.py | 6 ---- test/ZIP/ZIPCOM-fixture/test1.in | 2 -- test/ZIP/ZIPCOM.py | 6 ++-- test/ZIP/ZIPCOMSTR-fixture/.exclude_tests | 1 - test/ZIP/ZIPCOMSTR-fixture/aaa.in | 2 -- test/ZIP/ZIPCOMSTR-fixture/myzip.py | 7 ---- test/ZIP/ZIPCOMSTR.py | 6 ++-- test/fixture/mycompile.py | 8 +++++ test/fixture/myrewrite.py | 7 ++++ 95 files changed, 421 insertions(+), 1299 deletions(-) delete mode 100644 test/CC/shared-fixture/.exclude_tests delete mode 100644 test/CC/shared-fixture/mycc.py delete mode 100644 test/CC/shared-fixture/test1.c delete mode 100644 test/YACC/YACCCOM-fixture/.exclude_tests delete mode 100644 test/YACC/YACCCOM-fixture/myyacc.py delete mode 100644 test/YACC/shared-fixture/.exclude_tests delete mode 100644 test/YACC/shared-fixture/aaa.y delete mode 100644 test/YACC/shared-fixture/bbb.yacc delete mode 100644 test/ZIP/ZIPCOM-fixture/.exclude_tests delete mode 100644 test/ZIP/ZIPCOM-fixture/myzip.py delete mode 100644 test/ZIP/ZIPCOM-fixture/test1.in delete mode 100644 test/ZIP/ZIPCOMSTR-fixture/.exclude_tests delete mode 100644 test/ZIP/ZIPCOMSTR-fixture/aaa.in delete mode 100644 test/ZIP/ZIPCOMSTR-fixture/myzip.py create mode 100644 test/fixture/mycompile.py create mode 100644 test/fixture/myrewrite.py diff --git a/test/AR/ARCOM.py b/test/AR/ARCOM.py index bf2830e..f9d0038 100644 --- a/test/AR/ARCOM.py +++ b/test/AR/ARCOM.py @@ -34,39 +34,25 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('myar.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 != b'/*ar*/\\n']: - outfile.write(l) -sys.exit(0) -""") - -test.write('myranlib.py', """ -""") +test.file_fixture('mycompile.py') +test.file_fixture('myrewrite.py') test.write('SConstruct', """ env = Environment(tools=['default', 'ar'], - ARCOM = r'%(_python_)s myar.py $TARGET $SOURCES', - RANLIBCOM = r'%(_python_)s myranlib.py $TARGET', + ARCOM = r'%(_python_)s mycompile.py ar $TARGET $SOURCES', + RANLIBCOM = r'%(_python_)s myrewrite.py ranlib $TARGET', LIBPREFIX = '', LIBSUFFIX = '.lib') env.Library(target = 'output', source = ['file.1', 'file.2']) """ % locals()) -test.write('file.1', "file.1\n/*ar*/\n") -test.write('file.2', "file.2\n/*ar*/\n") +test.write('file.1', "file.1\n/*ar*/\n/*ranlib*/\n") +test.write('file.2', "file.2\n/*ar*/\n/*ranlib*/\n") test.run(arguments = '.') test.must_match('output.lib', "file.1\nfile.2\n") - - test.pass_test() # Local Variables: diff --git a/test/AR/ARCOMSTR.py b/test/AR/ARCOMSTR.py index 1b1a9fb..3235f12 100644 --- a/test/AR/ARCOMSTR.py +++ b/test/AR/ARCOMSTR.py @@ -35,33 +35,21 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('myar.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 != b'/*ar*/\\n']: - outfile.write(l) -sys.exit(0) -""") - -test.write('myranlib.py', """ -""") +test.file_fixture('mycompile.py') +test.file_fixture('myrewrite.py') test.write('SConstruct', """ env = Environment(tools=['default', 'ar'], - ARCOM = r'%(_python_)s myar.py $TARGET $SOURCES', + ARCOM = r'%(_python_)s mycompile.py ar $TARGET $SOURCES', ARCOMSTR = 'Archiving $TARGET from $SOURCES', - RANLIBCOM = r'%(_python_)s myranlib.py $TARGET', + RANLIBCOM = r'%(_python_)s myrewrite.py ranlib $TARGET', LIBPREFIX = '', LIBSUFFIX = '.lib') env.Library(target = 'output', source = ['file.1', 'file.2']) """ % locals()) -test.write('file.1', "file.1\n/*ar*/\n") -test.write('file.2', "file.2\n/*ar*/\n") +test.write('file.1', "file.1\n/*ar*/\n/*ranlib*/\n") +test.write('file.2', "file.2\n/*ar*/\n/*ranlib*/\n") test.run() @@ -69,8 +57,6 @@ expect = 'Archiving output.lib from file.1 file.2' test.must_contain_all_lines(test.stdout(), [expect]) test.must_match('output.lib', "file.1\nfile.2\n") - - test.pass_test() # Local Variables: diff --git a/test/AS/ASCOM.py b/test/AS/ASCOM.py index 8f91404..ab77586 100644 --- a/test/AS/ASCOM.py +++ b/test/AS/ASCOM.py @@ -36,16 +36,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -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 != b"#as\n"]: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') if os.path.normcase('.s') == os.path.normcase('.S'): alt_s_suffix = '.S' @@ -55,7 +46,7 @@ else: alt_asm_suffix = '.asm' test.write('SConstruct', """ -env = Environment(ASCOM = r'%(_python_)s myas.py $TARGET $SOURCE', +env = Environment(ASCOM = r'%(_python_)s mycompile.py as $TARGET $SOURCE', OBJSUFFIX = '.obj', SHOBJPREFIX = '', SHOBJSUFFIX = '.shobj') @@ -69,14 +60,14 @@ env.SharedObject(target = 'test7', source = 'test7.asm') env.SharedObject(target = 'test8', source = 'test8%(alt_asm_suffix)s') """ % locals()) -test.write('test1.s', "test1.s\n#as\n") -test.write('test2'+alt_s_suffix, "test2.S\n#as\n") -test.write('test3.asm', "test3.asm\n#as\n") -test.write('test4'+alt_asm_suffix, "test4.ASM\n#as\n") -test.write('test5.s', "test5.s\n#as\n") -test.write('test6'+alt_s_suffix, "test6.S\n#as\n") -test.write('test7.asm', "test7.asm\n#as\n") -test.write('test8'+alt_asm_suffix, "test8.ASM\n#as\n") +test.write('test1.s', "test1.s\n/*as*/\n") +test.write('test2'+alt_s_suffix, "test2.S\n/*as*/\n") +test.write('test3.asm', "test3.asm\n/*as*/\n") +test.write('test4'+alt_asm_suffix, "test4.ASM\n/*as*/\n") +test.write('test5.s', "test5.s\n/*as*/\n") +test.write('test6'+alt_s_suffix, "test6.S\n/*as*/\n") +test.write('test7.asm', "test7.asm\n/*as*/\n") +test.write('test8'+alt_asm_suffix, "test8.ASM\n/*as*/\n") test.run(arguments = '.') @@ -89,8 +80,6 @@ test.must_match('test6.shobj', "test6.S\n") test.must_match('test7.shobj', "test7.asm\n") test.must_match('test8.shobj', "test8.ASM\n") - - test.pass_test() # Local Variables: diff --git a/test/AS/ASCOMSTR.py b/test/AS/ASCOMSTR.py index 39b963f..2aab94c 100644 --- a/test/AS/ASCOMSTR.py +++ b/test/AS/ASCOMSTR.py @@ -37,16 +37,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -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 != b"#as\n"]: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') if os.path.normcase('.s') == os.path.normcase('.S'): alt_s_suffix = '.S' @@ -56,7 +47,7 @@ else: alt_asm_suffix = '.asm' test.write('SConstruct', """ -env = Environment(ASCOM = r'%(_python_)s myas.py $TARGET $SOURCE', +env = Environment(ASCOM = r'%(_python_)s mycompile.py as $TARGET $SOURCE', ASCOMSTR = 'Assembling $TARGET from $SOURCE', OBJSUFFIX = '.obj') env.Object(target = 'test1', source = 'test1.s') @@ -65,10 +56,10 @@ env.Object(target = 'test3', source = 'test3.asm') env.Object(target = 'test4', source = 'test4%(alt_asm_suffix)s') """ % locals()) -test.write('test1.s', "test1.s\n#as\n") -test.write('test2'+alt_s_suffix, "test2.S\n#as\n") -test.write('test3.asm', "test3.asm\n#as\n") -test.write('test4'+alt_asm_suffix, "test4.ASM\n#as\n") +test.write('test1.s', "test1.s\n/*as*/\n") +test.write('test2'+alt_s_suffix, "test2.S\n/*as*/\n") +test.write('test3.asm', "test3.asm\n/*as*/\n") +test.write('test4'+alt_asm_suffix, "test4.ASM\n/*as*/\n") test.run(stdout = test.wrap_stdout("""\ Assembling test1.obj from test1.s @@ -82,8 +73,6 @@ 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.pass_test() # Local Variables: diff --git a/test/AS/ASPPCOM.py b/test/AS/ASPPCOM.py index 62f859a..ce938bb 100644 --- a/test/AS/ASPPCOM.py +++ b/test/AS/ASPPCOM.py @@ -34,19 +34,10 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -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 != b"#as\n"]: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ -env = Environment(ASPPCOM = r'%(_python_)s myas.py $TARGET $SOURCE', +env = Environment(ASPPCOM = r'%(_python_)s mycompile.py as $TARGET $SOURCE', OBJSUFFIX = '.obj', SHOBJPREFIX = '', SHOBJSUFFIX = '.shobj') @@ -56,10 +47,10 @@ env.SharedObject(target = 'test3', source = 'test3.spp') env.SharedObject(target = 'test4', source = 'test4.SPP') """ % locals()) -test.write('test1.spp', "test1.spp\n#as\n") -test.write('test2.SPP', "test2.SPP\n#as\n") -test.write('test3.spp', "test3.spp\n#as\n") -test.write('test4.SPP', "test4.SPP\n#as\n") +test.write('test1.spp', "test1.spp\n/*as*/\n") +test.write('test2.SPP', "test2.SPP\n/*as*/\n") +test.write('test3.spp', "test3.spp\n/*as*/\n") +test.write('test4.SPP', "test4.SPP\n/*as*/\n") test.run(arguments = '.') @@ -68,8 +59,6 @@ test.must_match('test2.obj', "test2.SPP\n") test.must_match('test3.shobj', "test3.spp\n") test.must_match('test4.shobj', "test4.SPP\n") - - test.pass_test() # Local Variables: diff --git a/test/AS/ASPPCOMSTR.py b/test/AS/ASPPCOMSTR.py index 0497470..0ee18f5 100644 --- a/test/AS/ASPPCOMSTR.py +++ b/test/AS/ASPPCOMSTR.py @@ -35,27 +35,18 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -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 != b"#as\n"]: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ -env = Environment(ASPPCOM = r'%(_python_)s myas.py $TARGET $SOURCE', +env = Environment(ASPPCOM = r'%(_python_)s mycompile.py as $TARGET $SOURCE', ASPPCOMSTR = 'Assembling $TARGET from $SOURCE', OBJSUFFIX = '.obj') env.Object(target = 'test1', source = 'test1.spp') env.Object(target = 'test2', source = 'test2.SPP') """ % locals()) -test.write('test1.spp', "test1.spp\n#as\n") -test.write('test2.SPP', "test2.SPP\n#as\n") +test.write('test1.spp', "test1.spp\n/*as*/\n") +test.write('test2.SPP', "test2.SPP\n/*as*/\n") test.run(stdout = test.wrap_stdout("""\ Assembling test1.obj from test1.spp @@ -65,8 +56,6 @@ Assembling test2.obj from test2.SPP test.must_match('test1.obj', "test1.spp\n") test.must_match('test2.obj', "test2.SPP\n") - - test.pass_test() # Local Variables: diff --git a/test/CC/CCCOM.py b/test/CC/CCCOM.py index f930ecd..291dad8 100644 --- a/test/CC/CCCOM.py +++ b/test/CC/CCCOM.py @@ -33,11 +33,10 @@ import os import TestSCons _python_ = TestSCons._python_ -_exe = TestSCons._exe test = TestSCons.TestSCons() -test.dir_fixture('shared-fixture') +test.file_fixture('mycompile.py') if os.path.normcase('.c') == os.path.normcase('.C'): alt_c_suffix = '.C' @@ -45,12 +44,14 @@ else: alt_c_suffix = '.c' test.write('SConstruct', """ -env = Environment(CCCOM = r'%(_python_)s mycc.py $TARGET $SOURCE', +env = Environment(CCCOM = r'%(_python_)s mycompile.py cc $TARGET $SOURCE', OBJSUFFIX='.obj') env.Object(target = 'test1', source = 'test1.c') env.Object(target = 'test2', source = 'test2%(alt_c_suffix)s') """ % locals()) +test.write('test1.c', 'test1.c\n/*cc*/\n') + test.write('test2'+alt_c_suffix, """\ test2.C /*cc*/ @@ -61,8 +62,6 @@ test.run() test.must_match('test1.obj', "test1.c\n") test.must_match('test2.obj', "test2.C\n") - - test.pass_test() # Local Variables: diff --git a/test/CC/CCCOMSTR.py b/test/CC/CCCOMSTR.py index 0be9971..9977243 100644 --- a/test/CC/CCCOMSTR.py +++ b/test/CC/CCCOMSTR.py @@ -34,11 +34,10 @@ import os import TestSCons _python_ = TestSCons._python_ -_exe = TestSCons._exe test = TestSCons.TestSCons() -test.dir_fixture('shared-fixture') +test.file_fixture('mycompile.py') if os.path.normcase('.c') == os.path.normcase('.C'): alt_c_suffix = '.C' @@ -46,13 +45,15 @@ else: alt_c_suffix = '.c' test.write('SConstruct', """ -env = Environment(CCCOM = r'%(_python_)s mycc.py $TARGET $SOURCE', +env = Environment(CCCOM = r'%(_python_)s mycompile.py cc $TARGET $SOURCE', CCCOMSTR = 'Building $TARGET from $SOURCE', OBJSUFFIX='.obj') env.Object(target = 'test1', source = 'test1.c') env.Object(target = 'test2', source = 'test2%(alt_c_suffix)s') """ % locals()) +test.write('test1.c', 'test1.c\n/*cc*/\n') + test.write('test2'+alt_c_suffix, """\ test2.C /*cc*/ @@ -66,8 +67,6 @@ Building test2.obj from test2%(alt_c_suffix)s test.must_match('test1.obj', "test1.c\n") test.must_match('test2.obj', "test2.C\n") - - test.pass_test() # Local Variables: diff --git a/test/CC/SHCCCOM.py b/test/CC/SHCCCOM.py index 689b6e7..5326c01 100644 --- a/test/CC/SHCCCOM.py +++ b/test/CC/SHCCCOM.py @@ -36,7 +36,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() -test.dir_fixture('shared-fixture') +test.file_fixture('mycompile.py') if os.path.normcase('.c') == os.path.normcase('.C'): alt_c_suffix = '.C' @@ -44,13 +44,15 @@ else: alt_c_suffix = '.c' test.write('SConstruct', """ -env = Environment(SHCCCOM = r'%(_python_)s mycc.py $TARGET $SOURCE', +env = Environment(SHCCCOM = r'%(_python_)s mycompile.py cc $TARGET $SOURCE', SHOBJPREFIX='', SHOBJSUFFIX='.obj') env.SharedObject(target = 'test1', source = 'test1.c') env.SharedObject(target = 'test2', source = 'test2%(alt_c_suffix)s') """ % locals()) +test.write('test1.c', 'test1.c\n/*cc*/\n') + test.write('test2'+alt_c_suffix, """\ test2.C /*cc*/ @@ -61,8 +63,6 @@ test.run() test.must_match('test1.obj', "test1.c\n") test.must_match('test2.obj', "test2.C\n") - - test.pass_test() # Local Variables: diff --git a/test/CC/SHCCCOMSTR.py b/test/CC/SHCCCOMSTR.py index 0983a67..75f3aad 100644 --- a/test/CC/SHCCCOMSTR.py +++ b/test/CC/SHCCCOMSTR.py @@ -34,11 +34,10 @@ import os import TestSCons _python_ = TestSCons._python_ -_exe = TestSCons._exe test = TestSCons.TestSCons() -test.dir_fixture('shared-fixture') +test.file_fixture('mycompile.py') if os.path.normcase('.c') == os.path.normcase('.C'): alt_c_suffix = '.C' @@ -46,7 +45,7 @@ else: alt_c_suffix = '.c' test.write('SConstruct', """ -env = Environment(SHCCCOM = r'%(_python_)s mycc.py $TARGET $SOURCE', +env = Environment(SHCCCOM = r'%(_python_)s mycompile.py cc $TARGET $SOURCE', SHCCCOMSTR = 'Building $TARGET from $SOURCE', SHOBJPREFIX='', SHOBJSUFFIX='.obj') @@ -54,6 +53,8 @@ env.SharedObject(target = 'test1', source = 'test1.c') env.SharedObject(target = 'test2', source = 'test2%(alt_c_suffix)s') """ % locals()) +test.write('test1.c', 'test1.c\n/*cc*/\n') + 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 deleted file mode 100644 index 3f2bc0f..0000000 --- a/test/CC/shared-fixture/.exclude_tests +++ /dev/null @@ -1 +0,0 @@ -mycc.py diff --git a/test/CC/shared-fixture/mycc.py b/test/CC/shared-fixture/mycc.py deleted file mode 100644 index b96c31c..0000000 --- a/test/CC/shared-fixture/mycc.py +++ /dev/null @@ -1,6 +0,0 @@ -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 deleted file mode 100644 index 9c281d7..0000000 --- a/test/CC/shared-fixture/test1.c +++ /dev/null @@ -1,2 +0,0 @@ -test1.c -/*cc*/ diff --git a/test/CXX/CXXCOM.py b/test/CXX/CXXCOM.py index a3da81a..307ab13 100644 --- a/test/CXX/CXXCOM.py +++ b/test/CXX/CXXCOM.py @@ -31,25 +31,15 @@ Test the ability to configure the $CXXCOM construction variable. import TestSCons _python_ = TestSCons._python_ -_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[:7] != '/*c++*/']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') alt_cpp_suffix=test.get_alt_cpp_suffix() test.write('SConstruct', """ -env = Environment(CXXCOM = r'%(_python_)s mycc.py $TARGET $SOURCE', +env = Environment(CXXCOM = r'%(_python_)s mycompile.py c++ $TARGET $SOURCE', OBJSUFFIX='.obj') env.Object(target = 'test1', source = 'test1.cpp') env.Object(target = 'test2', source = 'test2.cc') @@ -75,8 +65,6 @@ test.must_match('test4.obj', "test4.c++\n") test.must_match('test5.obj', "test5.C++\n") test.must_match('test6.obj', "test6.C\n") - - test.pass_test() # Local Variables: diff --git a/test/CXX/CXXCOMSTR.py b/test/CXX/CXXCOMSTR.py index 9d54e91..f7494ca 100644 --- a/test/CXX/CXXCOMSTR.py +++ b/test/CXX/CXXCOMSTR.py @@ -32,25 +32,15 @@ the C++ compilation output. import TestSCons _python_ = TestSCons._python_ -_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 != '/*c++*/\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') alt_cpp_suffix=test.get_alt_cpp_suffix() test.write('SConstruct', """ -env = Environment(CXXCOM = r'%(_python_)s mycc.py $TARGET $SOURCE', +env = Environment(CXXCOM = r'%(_python_)s mycompile.py c++ $TARGET $SOURCE', CXXCOMSTR = 'Building $TARGET from $SOURCE', OBJSUFFIX='.obj') env.Object(target = 'test1', source = 'test1.cpp') diff --git a/test/CXX/SHCXXCOM.py b/test/CXX/SHCXXCOM.py index 7f151ed..72e247a 100644 --- a/test/CXX/SHCXXCOM.py +++ b/test/CXX/SHCXXCOM.py @@ -31,25 +31,15 @@ Test the ability to configure the $SHCXXCOM construction variable. import TestSCons _python_ = TestSCons._python_ -_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[:7] != '/*c++*/']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') alt_cpp_suffix=test.get_alt_cpp_suffix() test.write('SConstruct', """ -env = Environment(SHCXXCOM = r'%(_python_)s mycc.py $TARGET $SOURCE', +env = Environment(SHCXXCOM = r'%(_python_)s mycompile.py c++ $TARGET $SOURCE', SHOBJPREFIX='', SHOBJSUFFIX='.obj') env.SharedObject(target = 'test1', source = 'test1.cpp') @@ -76,7 +66,6 @@ test.must_match('test4.obj', "test4.c++\n") test.must_match('test5.obj', "test5.C++\n") test.must_match('test6.obj', "test6.C\n") - test.pass_test() # Local Variables: diff --git a/test/CXX/SHCXXCOMSTR.py b/test/CXX/SHCXXCOMSTR.py index 716c9ad..77075e4 100644 --- a/test/CXX/SHCXXCOMSTR.py +++ b/test/CXX/SHCXXCOMSTR.py @@ -32,25 +32,15 @@ the shared object C++ compilation output. import TestSCons _python_ = TestSCons._python_ -_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 != '/*c++*/\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') alt_cpp_suffix=test.get_alt_cpp_suffix() test.write('SConstruct', """ -env = Environment(SHCXXCOM = r'%(_python_)s mycc.py $TARGET $SOURCE', +env = Environment(SHCXXCOM = r'%(_python_)s mycompile.py c++ $TARGET $SOURCE', SHCXXCOMSTR = 'Building shared object $TARGET from $SOURCE', SHOBJPREFIX='', SHOBJSUFFIX='.obj') env.SharedObject(target = 'test1', source = 'test1.cpp') @@ -84,8 +74,6 @@ test.must_match('test4.obj', "test4.c++\n") test.must_match('test5.obj', "test5.C++\n") test.must_match('test6.obj', "test6.C\n") - - test.pass_test() # Local Variables: diff --git a/test/DVIPDF/DVIPDFCOM.py b/test/DVIPDF/DVIPDFCOM.py index 362279e..ddc42b6 100644 --- a/test/DVIPDF/DVIPDFCOM.py +++ b/test/DVIPDF/DVIPDFCOM.py @@ -34,21 +34,11 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('mypdf.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 != '/*pdf*/\\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(tools=['default', 'dvipdf'], - DVIPDFCOM = r'%(_python_)s mypdf.py $TARGET $SOURCES') + DVIPDFCOM = r'%(_python_)s mycompile.py pdf $TARGET $SOURCES') env.PDF(target = 'aaa', source = 'aaa.dvi') """ % locals()) @@ -58,8 +48,6 @@ test.run() test.must_match('aaa.pdf', "aaa.dvi\n") - - test.pass_test() # Local Variables: diff --git a/test/DVIPDF/DVIPDFCOMSTR.py b/test/DVIPDF/DVIPDFCOMSTR.py index 0063e84..7cf221c 100644 --- a/test/DVIPDF/DVIPDFCOMSTR.py +++ b/test/DVIPDF/DVIPDFCOMSTR.py @@ -35,21 +35,11 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('mypdf.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 != '/*pdf*/\\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(tools=['default', 'dvipdf'], - DVIPDFCOM = r'%(_python_)s mypdf.py $TARGET $SOURCES', + DVIPDFCOM = r'%(_python_)s mycompile.py pdf $TARGET $SOURCES', DVIPDFCOMSTR = 'DVIPDFing $TARGET from $SOURCE') env.PDF(target = 'aaa', source = 'aaa.dvi') """ % locals()) @@ -62,8 +52,6 @@ DVIPDFing aaa.pdf from aaa.dvi test.must_match('aaa.pdf', "aaa.dvi\n") - - test.pass_test() # Local Variables: diff --git a/test/DVIPS/PSCOM.py b/test/DVIPS/PSCOM.py index fe4832b..1b90736 100644 --- a/test/DVIPS/PSCOM.py +++ b/test/DVIPS/PSCOM.py @@ -34,21 +34,11 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('myps.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 != '/*ps*/\\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(tools=['default', 'dvips'], - PSCOM = r'%(_python_)s myps.py $TARGET $SOURCES') + PSCOM = r'%(_python_)s mycompile.py ps $TARGET $SOURCES') env.PostScript(target = 'aaa', source = 'aaa.dvi') """ % locals()) @@ -58,8 +48,6 @@ test.run() test.must_match('aaa.ps', "aaa.dvi\n") - - test.pass_test() # Local Variables: diff --git a/test/DVIPS/PSCOMSTR.py b/test/DVIPS/PSCOMSTR.py index 7c57ded..0d754d2 100644 --- a/test/DVIPS/PSCOMSTR.py +++ b/test/DVIPS/PSCOMSTR.py @@ -35,21 +35,11 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('myps.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 != '/*ps*/\\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(tools=['default', 'dvips'], - PSCOM = r'%(_python_)s myps.py $TARGET $SOURCES', + PSCOM = r'%(_python_)s mycompile.py ps $TARGET $SOURCES', PSCOMSTR = 'PostScripting $TARGET from $SOURCE') env.PostScript(target = 'aaa', source = 'aaa.dvi') """ % locals()) @@ -62,8 +52,6 @@ PostScripting aaa.ps from aaa.dvi test.must_match('aaa.ps', "aaa.dvi\n") - - test.pass_test() # Local Variables: diff --git a/test/Fortran/F03COM.py b/test/Fortran/F03COM.py index dc1523e..4a42d22 100644 --- a/test/Fortran/F03COM.py +++ b/test/Fortran/F03COM.py @@ -31,26 +31,16 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() +test.file_fixture('mycompile.py') test.file_fixture('mylink.py') -test.write('myfortran.py', r""" -import sys -comment = '#' + sys.argv[1] -outfile = open(sys.argv[2], 'wb') -infile = open(sys.argv[3], 'rb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', LINKFLAGS = [], - F03COM = r'%(_python_)s myfortran.py f03 $TARGET $SOURCES', - F03PPCOM = r'%(_python_)s myfortran.py f03pp $TARGET $SOURCES', - FORTRANCOM = r'%(_python_)s myfortran.py fortran $TARGET $SOURCES', - FORTRANPPCOM = r'%(_python_)s myfortran.py fortranpp $TARGET $SOURCES') + F03COM = r'%(_python_)s mycompile.py f03 $TARGET $SOURCES', + F03PPCOM = r'%(_python_)s mycompile.py f03pp $TARGET $SOURCES', + FORTRANCOM = r'%(_python_)s mycompile.py fortran $TARGET $SOURCES', + FORTRANPPCOM = r'%(_python_)s mycompile.py fortranpp $TARGET $SOURCES') env.Program(target = 'test01', source = 'test01.f') env.Program(target = 'test02', source = 'test02.F') env.Program(target = 'test03', source = 'test03.for') @@ -63,25 +53,25 @@ env.Program(target = 'test13', source = 'test13.f03') env.Program(target = 'test14', source = 'test14.F03') env2 = Environment(LINK = r'%(_python_)s mylink.py', LINKFLAGS = [], - F03COM = r'%(_python_)s myfortran.py f03 $TARGET $SOURCES', - F03PPCOM = r'%(_python_)s myfortran.py f03pp $TARGET $SOURCES') + F03COM = r'%(_python_)s mycompile.py f03 $TARGET $SOURCES', + F03PPCOM = r'%(_python_)s mycompile.py f03pp $TARGET $SOURCES') env2.Program(target = 'test21', source = 'test21.f03') env2.Program(target = 'test22', source = 'test22.F03') """ % locals()) -test.write('test01.f', "This is a .f file.\n#link\n#fortran\n") -test.write('test02.F', "This is a .F file.\n#link\n#fortranpp\n") -test.write('test03.for', "This is a .for file.\n#link\n#fortran\n") -test.write('test04.FOR', "This is a .FOR file.\n#link\n#fortranpp\n") -test.write('test05.ftn', "This is a .ftn file.\n#link\n#fortran\n") -test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortranpp\n") -test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortranpp\n") -test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortranpp\n") -test.write('test13.f03', "This is a .f03 file.\n#link\n#f03\n") -test.write('test14.F03', "This is a .F03 file.\n#link\n#f03pp\n") +test.write('test01.f', "This is a .f file.\n#link\n/*fortran*/\n") +test.write('test02.F', "This is a .F file.\n#link\n/*fortranpp*/\n") +test.write('test03.for', "This is a .for file.\n#link\n/*fortran*/\n") +test.write('test04.FOR', "This is a .FOR file.\n#link\n/*fortranpp*/\n") +test.write('test05.ftn', "This is a .ftn file.\n#link\n/*fortran*/\n") +test.write('test06.FTN', "This is a .FTN file.\n#link\n/*fortranpp*/\n") +test.write('test07.fpp', "This is a .fpp file.\n#link\n/*fortranpp*/\n") +test.write('test08.FPP', "This is a .FPP file.\n#link\n/*fortranpp*/\n") +test.write('test13.f03', "This is a .f03 file.\n#link\n/*f03*/\n") +test.write('test14.F03', "This is a .F03 file.\n#link\n/*f03pp*/\n") -test.write('test21.f03', "This is a .f03 file.\n#link\n#f03\n") -test.write('test22.F03', "This is a .F03 file.\n#link\n#f03pp\n") +test.write('test21.f03', "This is a .f03 file.\n#link\n/*f03*/\n") +test.write('test22.F03', "This is a .F03 file.\n#link\n/*f03pp*/\n") test.run(arguments = '.', stderr = None) diff --git a/test/Fortran/F03COMSTR.py b/test/Fortran/F03COMSTR.py index 327c1cd..a3f4e38 100644 --- a/test/Fortran/F03COMSTR.py +++ b/test/Fortran/F03COMSTR.py @@ -30,17 +30,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('myfc.py', r""" -import sys -fline = '#'+sys.argv[1]+'\n' -outfile = open(sys.argv[2], 'wb') -infile = open(sys.argv[3], 'rb') -for l in [l for l in infile.readlines() if l != fline]: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') if not TestSCons.case_sensitive_suffixes('.f','.F'): f03pp = 'f03' @@ -49,17 +39,17 @@ else: test.write('SConstruct', """ -env = Environment(F03COM = r'%(_python_)s myfc.py f03 $TARGET $SOURCES', +env = Environment(F03COM = r'%(_python_)s mycompile.py f03 $TARGET $SOURCES', F03COMSTR = 'Building f03 $TARGET from $SOURCES', - F03PPCOM = r'%(_python_)s myfc.py f03pp $TARGET $SOURCES', + F03PPCOM = r'%(_python_)s mycompile.py f03pp $TARGET $SOURCES', F03PPCOMSTR = 'Building f03pp $TARGET from $SOURCES', OBJSUFFIX='.obj') env.Object(source = 'test01.f03') env.Object(source = 'test02.F03') """ % locals()) -test.write('test01.f03', "A .f03 file.\n#f03\n") -test.write('test02.F03', "A .F03 file.\n#%s\n" % f03pp) +test.write('test01.f03', "A .f03 file.\n/*f03*/\n") +test.write('test02.F03', "A .F03 file.\n/*%s*/\n" % f03pp) test.run(stdout = test.wrap_stdout("""\ Building f03 test01.obj from test01.f03 diff --git a/test/Fortran/F08COM.py b/test/Fortran/F08COM.py index 363c2d0..ba7d64e 100644 --- a/test/Fortran/F08COM.py +++ b/test/Fortran/F08COM.py @@ -31,26 +31,16 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() +test.file_fixture('mycompile.py') test.file_fixture('mylink.py') -test.write('myfortran.py', r""" -import sys -comment = '#' + sys.argv[1] -outfile = open(sys.argv[2], 'wb') -infile = open(sys.argv[3], 'rb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', LINKFLAGS = [], - F08COM = r'%(_python_)s myfortran.py f08 $TARGET $SOURCES', - F08PPCOM = r'%(_python_)s myfortran.py f08pp $TARGET $SOURCES', - FORTRANCOM = r'%(_python_)s myfortran.py fortran $TARGET $SOURCES', - FORTRANPPCOM = r'%(_python_)s myfortran.py fortranpp $TARGET $SOURCES') + F08COM = r'%(_python_)s mycompile.py f08 $TARGET $SOURCES', + F08PPCOM = r'%(_python_)s mycompile.py f08pp $TARGET $SOURCES', + FORTRANCOM = r'%(_python_)s mycompile.py fortran $TARGET $SOURCES', + FORTRANPPCOM = r'%(_python_)s mycompile.py fortranpp $TARGET $SOURCES') env.Program(target = 'test01', source = 'test01.f') env.Program(target = 'test02', source = 'test02.F') env.Program(target = 'test03', source = 'test03.for') @@ -63,16 +53,16 @@ env.Program(target = 'test09', source = 'test09.f08') env.Program(target = 'test10', source = 'test10.F08') """ % locals()) -test.write('test01.f', "This is a .f file.\n#link\n#fortran\n") -test.write('test02.F', "This is a .F file.\n#link\n#fortranpp\n") -test.write('test03.for', "This is a .for file.\n#link\n#fortran\n") -test.write('test04.FOR', "This is a .FOR file.\n#link\n#fortranpp\n") -test.write('test05.ftn', "This is a .ftn file.\n#link\n#fortran\n") -test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortranpp\n") -test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortranpp\n") -test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortranpp\n") -test.write('test09.f08', "This is a .f08 file.\n#link\n#f08\n") -test.write('test10.F08', "This is a .F08 file.\n#link\n#f08pp\n") +test.write('test01.f', "This is a .f file.\n#link\n/*fortran*/\n") +test.write('test02.F', "This is a .F file.\n#link\n/*fortranpp*/\n") +test.write('test03.for', "This is a .for file.\n#link\n/*fortran*/\n") +test.write('test04.FOR', "This is a .FOR file.\n#link\n/*fortranpp*/\n") +test.write('test05.ftn', "This is a .ftn file.\n#link\n/*fortran*/\n") +test.write('test06.FTN', "This is a .FTN file.\n#link\n/*fortranpp*/\n") +test.write('test07.fpp', "This is a .fpp file.\n#link\n/*fortranpp*/\n") +test.write('test08.FPP', "This is a .FPP file.\n#link\n/*fortranpp*/\n") +test.write('test09.f08', "This is a .f08 file.\n#link\n/*f08*/\n") +test.write('test10.F08', "This is a .F08 file.\n#link\n/*f08pp*/\n") test.run(arguments = '.', stderr = None) diff --git a/test/Fortran/F08COMSTR.py b/test/Fortran/F08COMSTR.py index 65bf32c..ba0b506 100644 --- a/test/Fortran/F08COMSTR.py +++ b/test/Fortran/F08COMSTR.py @@ -30,17 +30,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('myfc.py', r""" -import sys -fline = '#'+sys.argv[1]+'\n' -outfile = open(sys.argv[2], 'wb') -infile = open(sys.argv[3], 'rb') -for l in [l for l in infile.readlines() if l != fline]: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') if not TestSCons.case_sensitive_suffixes('.f','.F'): f08pp = 'f08' @@ -49,17 +39,17 @@ else: test.write('SConstruct', """ -env = Environment(F08COM = r'%(_python_)s myfc.py f08 $TARGET $SOURCES', +env = Environment(F08COM = r'%(_python_)s mycompile.py f08 $TARGET $SOURCES', F08COMSTR = 'Building f08 $TARGET from $SOURCES', - F08PPCOM = r'%(_python_)s myfc.py f08pp $TARGET $SOURCES', + F08PPCOM = r'%(_python_)s mycompile.py f08pp $TARGET $SOURCES', F08PPCOMSTR = 'Building f08pp $TARGET from $SOURCES', OBJSUFFIX='.obj') env.Object(source = 'test01.f08') env.Object(source = 'test02.F08') """ % locals()) -test.write('test01.f08', "A .f08 file.\n#f08\n") -test.write('test02.F08', "A .F08 file.\n#%s\n" % f08pp) +test.write('test01.f08', "A .f08 file.\n/*f08*/\n") +test.write('test02.F08', "A .F08 file.\n/*%s*/\n" % f08pp) test.run(stdout = test.wrap_stdout("""\ Building f08 test01.obj from test01.f08 diff --git a/test/Fortran/F77COM.py b/test/Fortran/F77COM.py index 4e15eea..e7a3cca 100644 --- a/test/Fortran/F77COM.py +++ b/test/Fortran/F77COM.py @@ -31,26 +31,16 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() +test.file_fixture('mycompile.py') test.file_fixture('mylink.py') -test.write('myfortran.py', r""" -import sys -comment = '#' + sys.argv[1] -outfile = open(sys.argv[2], 'wb') -infile = open(sys.argv[3], 'rb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', LINKFLAGS = [], - F77COM = r'%(_python_)s myfortran.py f77 $TARGET $SOURCES', - F77PPCOM = r'%(_python_)s myfortran.py f77pp $TARGET $SOURCES', - FORTRANCOM = r'%(_python_)s myfortran.py fortran $TARGET $SOURCES', - FORTRANPPCOM = r'%(_python_)s myfortran.py fortranpp $TARGET $SOURCES') + F77COM = r'%(_python_)s mycompile.py f77 $TARGET $SOURCES', + F77PPCOM = r'%(_python_)s mycompile.py f77pp $TARGET $SOURCES', + FORTRANCOM = r'%(_python_)s mycompile.py fortran $TARGET $SOURCES', + FORTRANPPCOM = r'%(_python_)s mycompile.py fortranpp $TARGET $SOURCES') env.Program(target = 'test01', source = 'test01.f') env.Program(target = 'test02', source = 'test02.F') env.Program(target = 'test03', source = 'test03.for') @@ -63,16 +53,16 @@ env.Program(target = 'test09', source = 'test09.f77') env.Program(target = 'test10', source = 'test10.F77') """ % locals()) -test.write('test01.f', "This is a .f file.\n#link\n#fortran\n") -test.write('test02.F', "This is a .F file.\n#link\n#fortranpp\n") -test.write('test03.for', "This is a .for file.\n#link\n#fortran\n") -test.write('test04.FOR', "This is a .FOR file.\n#link\n#fortranpp\n") -test.write('test05.ftn', "This is a .ftn file.\n#link\n#fortran\n") -test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortranpp\n") -test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortranpp\n") -test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortranpp\n") -test.write('test09.f77', "This is a .f77 file.\n#link\n#f77\n") -test.write('test10.F77', "This is a .F77 file.\n#link\n#f77pp\n") +test.write('test01.f', "This is a .f file.\n#link\n/*fortran*/\n") +test.write('test02.F', "This is a .F file.\n#link\n/*fortranpp*/\n") +test.write('test03.for', "This is a .for file.\n#link\n/*fortran*/\n") +test.write('test04.FOR', "This is a .FOR file.\n#link\n/*fortranpp*/\n") +test.write('test05.ftn', "This is a .ftn file.\n#link\n/*fortran*/\n") +test.write('test06.FTN', "This is a .FTN file.\n#link\n/*fortranpp*/\n") +test.write('test07.fpp', "This is a .fpp file.\n#link\n/*fortranpp*/\n") +test.write('test08.FPP', "This is a .FPP file.\n#link\n/*fortranpp*/\n") +test.write('test09.f77', "This is a .f77 file.\n#link\n/*f77*/\n") +test.write('test10.F77', "This is a .F77 file.\n#link\n/*f77pp*/\n") test.run(arguments = '.', stderr = None) diff --git a/test/Fortran/F77COMSTR.py b/test/Fortran/F77COMSTR.py index 6c89833..2bedf73 100644 --- a/test/Fortran/F77COMSTR.py +++ b/test/Fortran/F77COMSTR.py @@ -30,17 +30,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('myfc.py', r""" -import sys -fline = '#'+sys.argv[1]+'\n' -outfile = open(sys.argv[2], 'wb') -infile = open(sys.argv[3], 'rb') -for l in [l for l in infile.readlines() if l != fline]: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') if not TestSCons.case_sensitive_suffixes('.f','.F'): f77pp = 'f77' @@ -49,17 +39,17 @@ else: test.write('SConstruct', """ -env = Environment(F77COM = r'%(_python_)s myfc.py f77 $TARGET $SOURCES', +env = Environment(F77COM = r'%(_python_)s mycompile.py f77 $TARGET $SOURCES', F77COMSTR = 'Building f77 $TARGET from $SOURCES', - F77PPCOM = r'%(_python_)s myfc.py f77pp $TARGET $SOURCES', + F77PPCOM = r'%(_python_)s mycompile.py f77pp $TARGET $SOURCES', F77PPCOMSTR = 'Building f77pp $TARGET from $SOURCES', OBJSUFFIX='.obj') env.Object(source = 'test09.f77') env.Object(source = 'test10.F77') """ % locals()) -test.write('test09.f77', "A .f77 file.\n#f77\n") -test.write('test10.F77', "A .F77 file.\n#%s\n" % f77pp) +test.write('test09.f77', "A .f77 file.\n/*f77*/\n") +test.write('test10.F77', "A .F77 file.\n/*%s*/\n" % f77pp) test.run(stdout = test.wrap_stdout("""\ Building f77 test09.obj from test09.f77 diff --git a/test/Fortran/F90COM.py b/test/Fortran/F90COM.py index e3be2a1..a4f37c2 100644 --- a/test/Fortran/F90COM.py +++ b/test/Fortran/F90COM.py @@ -31,26 +31,16 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() +test.file_fixture('mycompile.py') test.file_fixture('mylink.py') -test.write('myfortran.py', r""" -import sys -comment = '#' + sys.argv[1] -outfile = open(sys.argv[2], 'wb') -infile = open(sys.argv[3], 'rb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', LINKFLAGS = [], - F90COM = r'%(_python_)s myfortran.py f90 $TARGET $SOURCES', - F90PPCOM = r'%(_python_)s myfortran.py f90pp $TARGET $SOURCES', - FORTRANCOM = r'%(_python_)s myfortran.py fortran $TARGET $SOURCES', - FORTRANPPCOM = r'%(_python_)s myfortran.py fortranpp $TARGET $SOURCES') + F90COM = r'%(_python_)s mycompile.py f90 $TARGET $SOURCES', + F90PPCOM = r'%(_python_)s mycompile.py f90pp $TARGET $SOURCES', + FORTRANCOM = r'%(_python_)s mycompile.py fortran $TARGET $SOURCES', + FORTRANPPCOM = r'%(_python_)s mycompile.py fortranpp $TARGET $SOURCES') env.Program(target = 'test01', source = 'test01.f') env.Program(target = 'test02', source = 'test02.F') env.Program(target = 'test03', source = 'test03.for') @@ -63,25 +53,25 @@ env.Program(target = 'test11', source = 'test11.f90') env.Program(target = 'test12', source = 'test12.F90') env2 = Environment(LINK = r'%(_python_)s mylink.py', LINKFLAGS = [], - F90COM = r'%(_python_)s myfortran.py f90 $TARGET $SOURCES', - F90PPCOM = r'%(_python_)s myfortran.py f90pp $TARGET $SOURCES') + F90COM = r'%(_python_)s mycompile.py f90 $TARGET $SOURCES', + F90PPCOM = r'%(_python_)s mycompile.py f90pp $TARGET $SOURCES') env2.Program(target = 'test21', source = 'test21.f90') env2.Program(target = 'test22', source = 'test22.F90') """ % locals()) -test.write('test01.f', "This is a .f file.\n#link\n#fortran\n") -test.write('test02.F', "This is a .F file.\n#link\n#fortranpp\n") -test.write('test03.for', "This is a .for file.\n#link\n#fortran\n") -test.write('test04.FOR', "This is a .FOR file.\n#link\n#fortranpp\n") -test.write('test05.ftn', "This is a .ftn file.\n#link\n#fortran\n") -test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortranpp\n") -test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortranpp\n") -test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortranpp\n") -test.write('test11.f90', "This is a .f90 file.\n#link\n#f90\n") -test.write('test12.F90', "This is a .F90 file.\n#link\n#f90pp\n") +test.write('test01.f', "This is a .f file.\n#link\n/*fortran*/\n") +test.write('test02.F', "This is a .F file.\n#link\n/*fortranpp*/\n") +test.write('test03.for', "This is a .for file.\n#link\n/*fortran*/\n") +test.write('test04.FOR', "This is a .FOR file.\n#link\n/*fortranpp*/\n") +test.write('test05.ftn', "This is a .ftn file.\n#link\n/*fortran*/\n") +test.write('test06.FTN', "This is a .FTN file.\n#link\n/*fortranpp*/\n") +test.write('test07.fpp', "This is a .fpp file.\n#link\n/*fortranpp*/\n") +test.write('test08.FPP', "This is a .FPP file.\n#link\n/*fortranpp*/\n") +test.write('test11.f90', "This is a .f90 file.\n#link\n/*f90*/\n") +test.write('test12.F90', "This is a .F90 file.\n#link\n/*f90pp*/\n") -test.write('test21.f90', "This is a .f90 file.\n#link\n#f90\n") -test.write('test22.F90', "This is a .F90 file.\n#link\n#f90pp\n") +test.write('test21.f90', "This is a .f90 file.\n#link\n/*f90*/\n") +test.write('test22.F90', "This is a .F90 file.\n#link\n/*f90pp*/\n") test.run(arguments = '.', stderr = None) diff --git a/test/Fortran/F90COMSTR.py b/test/Fortran/F90COMSTR.py index 117a5a9..4a0ab75 100644 --- a/test/Fortran/F90COMSTR.py +++ b/test/Fortran/F90COMSTR.py @@ -30,17 +30,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('myfc.py', r""" -import sys -fline = '#'+sys.argv[1]+'\n' -outfile = open(sys.argv[2], 'wb') -infile = open(sys.argv[3], 'rb') -for l in [l for l in infile.readlines() if l != fline]: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') if not TestSCons.case_sensitive_suffixes('.f','.F'): f90pp = 'f90' @@ -48,17 +38,17 @@ else: f90pp = 'f90pp' test.write('SConstruct', """ -env = Environment(F90COM = r'%(_python_)s myfc.py f90 $TARGET $SOURCES', +env = Environment(F90COM = r'%(_python_)s mycompile.py f90 $TARGET $SOURCES', F90COMSTR = 'Building f90 $TARGET from $SOURCES', - F90PPCOM = r'%(_python_)s myfc.py f90pp $TARGET $SOURCES', + F90PPCOM = r'%(_python_)s mycompile.py f90pp $TARGET $SOURCES', F90PPCOMSTR = 'Building f90pp $TARGET from $SOURCES', OBJSUFFIX='.obj') env.Object(source = 'test01.f90') env.Object(source = 'test02.F90') """ % locals()) -test.write('test01.f90', "A .f90 file.\n#f90\n") -test.write('test02.F90', "A .F90 file.\n#%s\n" % f90pp) +test.write('test01.f90', "A .f90 file.\n/*f90*/\n") +test.write('test02.F90', "A .F90 file.\n/*%s*/\n" % f90pp) test.run(stdout = test.wrap_stdout("""\ Building f90 test01.obj from test01.f90 diff --git a/test/Fortran/F95COM.py b/test/Fortran/F95COM.py index 4761635..32ae594 100644 --- a/test/Fortran/F95COM.py +++ b/test/Fortran/F95COM.py @@ -26,33 +26,21 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons - - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() +test.file_fixture('mycompile.py') test.file_fixture('mylink.py') -test.write('myfortran.py', r""" -import sys -comment = '#' + sys.argv[1] -outfile = open(sys.argv[2], 'wb') -infile = open(sys.argv[3], 'rb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', LINKFLAGS = [], - F95COM = r'%(_python_)s myfortran.py f95 $TARGET $SOURCES', - F95PPCOM = r'%(_python_)s myfortran.py f95pp $TARGET $SOURCES', - FORTRANCOM = r'%(_python_)s myfortran.py fortran $TARGET $SOURCES', - FORTRANPPCOM = r'%(_python_)s myfortran.py fortranpp $TARGET $SOURCES') + F95COM = r'%(_python_)s mycompile.py f95 $TARGET $SOURCES', + F95PPCOM = r'%(_python_)s mycompile.py f95pp $TARGET $SOURCES', + FORTRANCOM = r'%(_python_)s mycompile.py fortran $TARGET $SOURCES', + FORTRANPPCOM = r'%(_python_)s mycompile.py fortranpp $TARGET $SOURCES') env.Program(target = 'test01', source = 'test01.f') env.Program(target = 'test02', source = 'test02.F') env.Program(target = 'test03', source = 'test03.for') @@ -65,25 +53,25 @@ env.Program(target = 'test13', source = 'test13.f95') env.Program(target = 'test14', source = 'test14.F95') env2 = Environment(LINK = r'%(_python_)s mylink.py', LINKFLAGS = [], - F95COM = r'%(_python_)s myfortran.py f95 $TARGET $SOURCES', - F95PPCOM = r'%(_python_)s myfortran.py f95pp $TARGET $SOURCES') + F95COM = r'%(_python_)s mycompile.py f95 $TARGET $SOURCES', + F95PPCOM = r'%(_python_)s mycompile.py f95pp $TARGET $SOURCES') env2.Program(target = 'test21', source = 'test21.f95') env2.Program(target = 'test22', source = 'test22.F95') """ % locals()) -test.write('test01.f', "This is a .f file.\n#link\n#fortran\n") -test.write('test02.F', "This is a .F file.\n#link\n#fortranpp\n") -test.write('test03.for', "This is a .for file.\n#link\n#fortran\n") -test.write('test04.FOR', "This is a .FOR file.\n#link\n#fortranpp\n") -test.write('test05.ftn', "This is a .ftn file.\n#link\n#fortran\n") -test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortranpp\n") -test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortranpp\n") -test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortranpp\n") -test.write('test13.f95', "This is a .f95 file.\n#link\n#f95\n") -test.write('test14.F95', "This is a .F95 file.\n#link\n#f95pp\n") - -test.write('test21.f95', "This is a .f95 file.\n#link\n#f95\n") -test.write('test22.F95', "This is a .F95 file.\n#link\n#f95pp\n") +test.write('test01.f', "This is a .f file.\n#link\n/*fortran*/\n") +test.write('test02.F', "This is a .F file.\n#link\n/*fortranpp*/\n") +test.write('test03.for', "This is a .for file.\n#link\n/*fortran*/\n") +test.write('test04.FOR', "This is a .FOR file.\n#link\n/*fortranpp*/\n") +test.write('test05.ftn', "This is a .ftn file.\n#link\n/*fortran*/\n") +test.write('test06.FTN', "This is a .FTN file.\n#link\n/*fortranpp*/\n") +test.write('test07.fpp', "This is a .fpp file.\n#link\n/*fortranpp*/\n") +test.write('test08.FPP', "This is a .FPP file.\n#link\n/*fortranpp*/\n") +test.write('test13.f95', "This is a .f95 file.\n#link\n/*f95*/\n") +test.write('test14.F95', "This is a .F95 file.\n#link\n/*f95pp*/\n") + +test.write('test21.f95', "This is a .f95 file.\n#link\n/*f95*/\n") +test.write('test22.F95', "This is a .F95 file.\n#link\n/*f95pp*/\n") test.run(arguments = '.', stderr = None) diff --git a/test/Fortran/F95COMSTR.py b/test/Fortran/F95COMSTR.py index 5d162f9..e3bc3ac 100644 --- a/test/Fortran/F95COMSTR.py +++ b/test/Fortran/F95COMSTR.py @@ -30,17 +30,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('myfc.py', r""" -import sys -fline = '#'+sys.argv[1]+'\n' -outfile = open(sys.argv[2], 'wb') -infile = open(sys.argv[3], 'rb') -for l in [l for l in infile.readlines() if l != fline]: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') if not TestSCons.case_sensitive_suffixes('.f','.F'): f95pp = 'f95' @@ -49,17 +39,17 @@ else: test.write('SConstruct', """ -env = Environment(F95COM = r'%(_python_)s myfc.py f95 $TARGET $SOURCES', +env = Environment(F95COM = r'%(_python_)s mycompile.py f95 $TARGET $SOURCES', F95COMSTR = 'Building f95 $TARGET from $SOURCES', - F95PPCOM = r'%(_python_)s myfc.py f95pp $TARGET $SOURCES', + F95PPCOM = r'%(_python_)s mycompile.py f95pp $TARGET $SOURCES', F95PPCOMSTR = 'Building f95pp $TARGET from $SOURCES', OBJSUFFIX='.obj') env.Object(source = 'test01.f95') env.Object(source = 'test02.F95') """ % locals()) -test.write('test01.f95', "A .f95 file.\n#f95\n") -test.write('test02.F95', "A .F95 file.\n#%s\n" % f95pp) +test.write('test01.f95', "A .f95 file.\n/*f95*/\n") +test.write('test02.F95', "A .F95 file.\n/*%s*/\n" % f95pp) test.run(stdout = test.wrap_stdout("""\ Building f95 test01.obj from test01.f95 diff --git a/test/Fortran/FORTRANCOM.py b/test/Fortran/FORTRANCOM.py index bf84d26..a07d427 100644 --- a/test/Fortran/FORTRANCOM.py +++ b/test/Fortran/FORTRANCOM.py @@ -26,31 +26,19 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons - - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() +test.file_fixture('mycompile.py') test.file_fixture('mylink.py') -test.write('myfortran.py', r""" -import sys -comment = '#' + sys.argv[1] -outfile = open(sys.argv[2], 'wb') -infile = open(sys.argv[3], 'rb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', LINKFLAGS = [], - FORTRANCOM = r'%(_python_)s myfortran.py fortran $TARGET $SOURCES', - FORTRANPPCOM = r'%(_python_)s myfortran.py fortranpp $TARGET $SOURCES') + FORTRANCOM = r'%(_python_)s mycompile.py fortran $TARGET $SOURCES', + FORTRANPPCOM = r'%(_python_)s mycompile.py fortranpp $TARGET $SOURCES') env.Program(target = 'test01', source = 'test01.f') env.Program(target = 'test02', source = 'test02.F') env.Program(target = 'test03', source = 'test03.for') @@ -61,14 +49,14 @@ env.Program(target = 'test07', source = 'test07.fpp') env.Program(target = 'test08', source = 'test08.FPP') """ % locals()) -test.write('test01.f', "This is a .f file.\n#link\n#fortran\n") -test.write('test02.F', "This is a .F file.\n#link\n#fortranpp\n") -test.write('test03.for', "This is a .for file.\n#link\n#fortran\n") -test.write('test04.FOR', "This is a .FOR file.\n#link\n#fortranpp\n") -test.write('test05.ftn', "This is a .ftn file.\n#link\n#fortran\n") -test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortranpp\n") -test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortranpp\n") -test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortranpp\n") +test.write('test01.f', "This is a .f file.\n#link\n/*fortran*/\n") +test.write('test02.F', "This is a .F file.\n#link\n/*fortranpp*/\n") +test.write('test03.for', "This is a .for file.\n#link\n/*fortran*/\n") +test.write('test04.FOR', "This is a .FOR file.\n#link\n/*fortranpp*/\n") +test.write('test05.ftn', "This is a .ftn file.\n#link\n/*fortran*/\n") +test.write('test06.FTN', "This is a .FTN file.\n#link\n/*fortranpp*/\n") +test.write('test07.fpp', "This is a .fpp file.\n#link\n/*fortranpp*/\n") +test.write('test08.FPP', "This is a .FPP file.\n#link\n/*fortranpp*/\n") test.run(arguments = '.', stderr = None) diff --git a/test/Fortran/FORTRANCOMSTR.py b/test/Fortran/FORTRANCOMSTR.py index 5efa820..10f7d3f 100644 --- a/test/Fortran/FORTRANCOMSTR.py +++ b/test/Fortran/FORTRANCOMSTR.py @@ -30,17 +30,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('myfc.py', r""" -import sys -fline = '#'+sys.argv[1]+'\n' -outfile = open(sys.argv[2], 'wb') -infile = open(sys.argv[3], 'rb') -for l in [l for l in infile.readlines() if l != fline]: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') if not TestSCons.case_sensitive_suffixes('.f','.F'): fortranpp = 'fortran' @@ -49,9 +39,9 @@ else: test.write('SConstruct', """ -env = Environment(FORTRANCOM = r'%(_python_)s myfc.py fortran $TARGET $SOURCES', +env = Environment(FORTRANCOM = r'%(_python_)s mycompile.py fortran $TARGET $SOURCES', FORTRANCOMSTR = 'Building fortran $TARGET from $SOURCES', - FORTRANPPCOM = r'%(_python_)s myfc.py fortranpp $TARGET $SOURCES', + FORTRANPPCOM = r'%(_python_)s mycompile.py fortranpp $TARGET $SOURCES', FORTRANPPCOMSTR = 'Building fortranpp $TARGET from $SOURCES', OBJSUFFIX='.obj') env.Object(source = 'test01.f') @@ -64,14 +54,14 @@ env.Object(source = 'test07.fpp') env.Object(source = 'test08.FPP') """ % locals()) -test.write('test01.f', "A .f file.\n#fortran\n") -test.write('test02.F', "A .F file.\n#%s\n" % fortranpp) -test.write('test03.for', "A .for file.\n#fortran\n") -test.write('test04.FOR', "A .FOR file.\n#%s\n" % fortranpp) -test.write('test05.ftn', "A .ftn file.\n#fortran\n") -test.write('test06.FTN', "A .FTN file.\n#%s\n" % fortranpp) -test.write('test07.fpp', "A .fpp file.\n#fortranpp\n") -test.write('test08.FPP', "A .FPP file.\n#fortranpp\n") +test.write('test01.f', "A .f file.\n/*fortran*/\n") +test.write('test02.F', "A .F file.\n/*%s*/\n" % fortranpp) +test.write('test03.for', "A .for file.\n/*fortran*/\n") +test.write('test04.FOR', "A .FOR file.\n/*%s*/\n" % fortranpp) +test.write('test05.ftn', "A .ftn file.\n/*fortran*/\n") +test.write('test06.FTN', "A .FTN file.\n/*%s*/\n" % fortranpp) +test.write('test07.fpp', "A .fpp file.\n/*fortranpp*/\n") +test.write('test08.FPP', "A .FPP file.\n/*fortranpp*/\n") test.run(stdout = test.wrap_stdout("""\ Building fortran test01.obj from test01.f diff --git a/test/Fortran/SHF77COM.py b/test/Fortran/SHF77COM.py index c99207f..9289fa3 100644 --- a/test/Fortran/SHF77COM.py +++ b/test/Fortran/SHF77COM.py @@ -32,26 +32,13 @@ obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() - - -test.write('myfortran.py', r""" -import sys -comment = '#' + sys.argv[1] -outfile = open(sys.argv[2], 'wb') -infile = open(sys.argv[3], 'rb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture('mycompile.py') test.write('SConstruct', """ -env = Environment(SHF77COM = r'%(_python_)s myfortran.py f77 $TARGET $SOURCES', - SHF77PPCOM = r'%(_python_)s myfortran.py f77pp $TARGET $SOURCES', - SHFORTRANCOM = r'%(_python_)s myfortran.py fortran $TARGET $SOURCES', - SHFORTRANPPCOM = r'%(_python_)s myfortran.py fortranpp $TARGET $SOURCES') +env = Environment(SHF77COM = r'%(_python_)s mycompile.py f77 $TARGET $SOURCES', + SHF77PPCOM = r'%(_python_)s mycompile.py f77pp $TARGET $SOURCES', + SHFORTRANCOM = r'%(_python_)s mycompile.py fortran $TARGET $SOURCES', + SHFORTRANPPCOM = r'%(_python_)s mycompile.py fortranpp $TARGET $SOURCES') env.SharedObject(target = 'test01', source = 'test01.f') env.SharedObject(target = 'test02', source = 'test02.F') env.SharedObject(target = 'test03', source = 'test03.for') @@ -64,16 +51,16 @@ env.SharedObject(target = 'test09', source = 'test09.f77') env.SharedObject(target = 'test10', source = 'test10.F77') """ % locals()) -test.write('test01.f', "This is a .f file.\n#fortran\n") -test.write('test02.F', "This is a .F file.\n#fortranpp\n") -test.write('test03.for', "This is a .for file.\n#fortran\n") -test.write('test04.FOR', "This is a .FOR file.\n#fortranpp\n") -test.write('test05.ftn', "This is a .ftn file.\n#fortran\n") -test.write('test06.FTN', "This is a .FTN file.\n#fortranpp\n") -test.write('test07.fpp', "This is a .fpp file.\n#fortranpp\n") -test.write('test08.FPP', "This is a .FPP file.\n#fortranpp\n") -test.write('test09.f77', "This is a .f77 file.\n#f77\n") -test.write('test10.F77', "This is a .F77 file.\n#f77pp\n") +test.write('test01.f', "This is a .f file.\n/*fortran*/\n") +test.write('test02.F', "This is a .F file.\n/*fortranpp*/\n") +test.write('test03.for', "This is a .for file.\n/*fortran*/\n") +test.write('test04.FOR', "This is a .FOR file.\n/*fortranpp*/\n") +test.write('test05.ftn', "This is a .ftn file.\n/*fortran*/\n") +test.write('test06.FTN', "This is a .FTN file.\n/*fortranpp*/\n") +test.write('test07.fpp', "This is a .fpp file.\n/*fortranpp*/\n") +test.write('test08.FPP', "This is a .FPP file.\n/*fortranpp*/\n") +test.write('test09.f77', "This is a .f77 file.\n/*f77*/\n") +test.write('test10.F77', "This is a .F77 file.\n/*f77pp*/\n") test.run(arguments = '.', stderr = None) diff --git a/test/Fortran/SHF77COMSTR.py b/test/Fortran/SHF77COMSTR.py index 7a43a4a..37d2edf 100644 --- a/test/Fortran/SHF77COMSTR.py +++ b/test/Fortran/SHF77COMSTR.py @@ -30,17 +30,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('myfc.py', r""" -import sys -fline = '#'+sys.argv[1]+'\n' -outfile = open(sys.argv[2], 'wb') -infile = open(sys.argv[3], 'rb') -for l in [l for l in infile.readlines() if l != fline]: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') if not TestSCons.case_sensitive_suffixes('.f','.F'): f77pp = 'f77' @@ -49,25 +39,25 @@ else: test.write('SConstruct', """ -env = Environment(SHF77COM = r'%(_python_)s myfc.py f77 $TARGET $SOURCES', +env = Environment(SHF77COM = r'%(_python_)s mycompile.py f77 $TARGET $SOURCES', SHF77COMSTR = 'Building f77 $TARGET from $SOURCES', - SHF77PPCOM = r'%(_python_)s myfc.py f77pp $TARGET $SOURCES', + SHF77PPCOM = r'%(_python_)s mycompile.py f77pp $TARGET $SOURCES', SHF77PPCOMSTR = 'Building f77pp $TARGET from $SOURCES', SHOBJPREFIX='', SHOBJSUFFIX='.shobj') env.SharedObject(source = 'test09.f77') env.SharedObject(source = 'test10.F77') """ % locals()) -test.write('test01.f', "A .f file.\n#f77\n") -test.write('test02.F', "A .F file.\n#%s\n" % f77pp) -test.write('test03.for', "A .for file.\n#f77\n") -test.write('test04.FOR', "A .FOR file.\n#%s\n" % f77pp) -test.write('test05.ftn', "A .ftn file.\n#f77\n") -test.write('test06.FTN', "A .FTN file.\n#%s\n" % f77pp) -test.write('test07.fpp', "A .fpp file.\n#f77pp\n") -test.write('test08.FPP', "A .FPP file.\n#f77pp\n") -test.write('test09.f77', "A .f77 file.\n#f77\n") -test.write('test10.F77', "A .F77 file.\n#%s\n" % f77pp) +test.write('test01.f', "A .f file.\n/*f77*/\n") +test.write('test02.F', "A .F file.\n/*%s*/\n" % f77pp) +test.write('test03.for', "A .for file.\n/*f77*/\n") +test.write('test04.FOR', "A .FOR file.\n/*%s*/\n" % f77pp) +test.write('test05.ftn', "A .ftn file.\n/*f77*/\n") +test.write('test06.FTN', "A .FTN file.\n/*%s*/\n" % f77pp) +test.write('test07.fpp', "A .fpp file.\n/*f77pp*/\n") +test.write('test08.FPP', "A .FPP file.\n/*f77pp*/\n") +test.write('test09.f77', "A .f77 file.\n/*f77*/\n") +test.write('test10.F77', "A .F77 file.\n/*%s*/\n" % f77pp) test.run(stdout = test.wrap_stdout("""\ Building f77 test09.shobj from test09.f77 diff --git a/test/Fortran/SHF90COM.py b/test/Fortran/SHF90COM.py index 415cb9b..9eef8b6 100644 --- a/test/Fortran/SHF90COM.py +++ b/test/Fortran/SHF90COM.py @@ -32,26 +32,13 @@ obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() - - -test.write('myfortran.py', r""" -import sys -comment = '#' + sys.argv[1] -outfile = open(sys.argv[2], 'wb') -infile = open(sys.argv[3], 'rb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture('mycompile.py') test.write('SConstruct', """ -env = Environment(SHF90COM = r'%(_python_)s myfortran.py f90 $TARGET $SOURCES', - SHF90PPCOM = r'%(_python_)s myfortran.py f90pp $TARGET $SOURCES', - SHFORTRANCOM = r'%(_python_)s myfortran.py fortran $TARGET $SOURCES', - SHFORTRANPPCOM = r'%(_python_)s myfortran.py fortranpp $TARGET $SOURCES') +env = Environment(SHF90COM = r'%(_python_)s mycompile.py f90 $TARGET $SOURCES', + SHF90PPCOM = r'%(_python_)s mycompile.py f90pp $TARGET $SOURCES', + SHFORTRANCOM = r'%(_python_)s mycompile.py fortran $TARGET $SOURCES', + SHFORTRANPPCOM = r'%(_python_)s mycompile.py fortranpp $TARGET $SOURCES') env.SharedObject(target = 'test01', source = 'test01.f') env.SharedObject(target = 'test02', source = 'test02.F') env.SharedObject(target = 'test03', source = 'test03.for') @@ -62,25 +49,25 @@ env.SharedObject(target = 'test07', source = 'test07.fpp') env.SharedObject(target = 'test08', source = 'test08.FPP') env.SharedObject(target = 'test11', source = 'test11.f90') env.SharedObject(target = 'test12', source = 'test12.F90') -env2 = Environment(SHF90COM = r'%(_python_)s myfortran.py f90 $TARGET $SOURCES', - SHF90PPCOM = r'%(_python_)s myfortran.py f90pp $TARGET $SOURCES') +env2 = Environment(SHF90COM = r'%(_python_)s mycompile.py f90 $TARGET $SOURCES', + SHF90PPCOM = r'%(_python_)s mycompile.py f90pp $TARGET $SOURCES') env2.SharedObject(target = 'test21', source = 'test21.f90') env2.SharedObject(target = 'test22', source = 'test22.F90') """ % locals()) -test.write('test01.f', "This is a .f file.\n#fortran\n") -test.write('test02.F', "This is a .F file.\n#fortranpp\n") -test.write('test03.for', "This is a .for file.\n#fortran\n") -test.write('test04.FOR', "This is a .FOR file.\n#fortranpp\n") -test.write('test05.ftn', "This is a .ftn file.\n#fortran\n") -test.write('test06.FTN', "This is a .FTN file.\n#fortranpp\n") -test.write('test07.fpp', "This is a .fpp file.\n#fortranpp\n") -test.write('test08.FPP', "This is a .FPP file.\n#fortranpp\n") -test.write('test11.f90', "This is a .f90 file.\n#f90\n") -test.write('test12.F90', "This is a .F90 file.\n#f90pp\n") - -test.write('test21.f90', "This is a .f90 file.\n#f90\n") -test.write('test22.F90', "This is a .F90 file.\n#f90pp\n") +test.write('test01.f', "This is a .f file.\n/*fortran*/\n") +test.write('test02.F', "This is a .F file.\n/*fortranpp*/\n") +test.write('test03.for', "This is a .for file.\n/*fortran*/\n") +test.write('test04.FOR', "This is a .FOR file.\n/*fortranpp*/\n") +test.write('test05.ftn', "This is a .ftn file.\n/*fortran*/\n") +test.write('test06.FTN', "This is a .FTN file.\n/*fortranpp*/\n") +test.write('test07.fpp', "This is a .fpp file.\n/*fortranpp*/\n") +test.write('test08.FPP', "This is a .FPP file.\n/*fortranpp*/\n") +test.write('test11.f90', "This is a .f90 file.\n/*f90*/\n") +test.write('test12.F90', "This is a .F90 file.\n/*f90pp*/\n") + +test.write('test21.f90', "This is a .f90 file.\n/*f90*/\n") +test.write('test22.F90', "This is a .F90 file.\n/*f90pp*/\n") test.run(arguments = '.', stderr = None) diff --git a/test/Fortran/SHF90COMSTR.py b/test/Fortran/SHF90COMSTR.py index a3353fa..4ea8ca6 100644 --- a/test/Fortran/SHF90COMSTR.py +++ b/test/Fortran/SHF90COMSTR.py @@ -30,36 +30,25 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('myfc.py', r""" -import sys -fline = '#'+sys.argv[1]+'\n' -outfile = open(sys.argv[2], 'wb') -infile = open(sys.argv[3], 'rb') -for l in [l for l in infile.readlines() if l != fline]: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') if not TestSCons.case_sensitive_suffixes('.f','.F'): f90pp = 'f90' else: f90pp = 'f90pp' - test.write('SConstruct', """ -env = Environment(SHF90COM = r'%(_python_)s myfc.py f90 $TARGET $SOURCES', +env = Environment(SHF90COM = r'%(_python_)s mycompile.py f90 $TARGET $SOURCES', SHF90COMSTR = 'Building f90 $TARGET from $SOURCES', - SHF90PPCOM = r'%(_python_)s myfc.py f90pp $TARGET $SOURCES', + SHF90PPCOM = r'%(_python_)s mycompile.py f90pp $TARGET $SOURCES', SHF90PPCOMSTR = 'Building f90pp $TARGET from $SOURCES', SHOBJPREFIX='', SHOBJSUFFIX='.shobj') env.SharedObject(source = 'test01.f90') env.SharedObject(source = 'test02.F90') """ % locals()) -test.write('test01.f90', "A .f90 file.\n#f90\n") -test.write('test02.F90', "A .F90 file.\n#%s\n" % f90pp) +test.write('test01.f90', "A .f90 file.\n/*f90*/\n") +test.write('test02.F90', "A .F90 file.\n/*%s*/\n" % f90pp) test.run(stdout = test.wrap_stdout("""\ Building f90 test01.shobj from test01.f90 diff --git a/test/Fortran/SHF95COM.py b/test/Fortran/SHF95COM.py index 0984b20..e31cf45 100644 --- a/test/Fortran/SHF95COM.py +++ b/test/Fortran/SHF95COM.py @@ -32,26 +32,13 @@ obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() - - -test.write('myfortran.py', r""" -import sys -comment = '#' + sys.argv[1] -outfile = open(sys.argv[2], 'wb') -infile = open(sys.argv[3], 'rb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture('mycompile.py') test.write('SConstruct', """ -env = Environment(SHF95COM = r'%(_python_)s myfortran.py f95 $TARGET $SOURCES', - SHF95PPCOM = r'%(_python_)s myfortran.py f95pp $TARGET $SOURCES', - SHFORTRANCOM = r'%(_python_)s myfortran.py fortran $TARGET $SOURCES', - SHFORTRANPPCOM = r'%(_python_)s myfortran.py fortranpp $TARGET $SOURCES') +env = Environment(SHF95COM = r'%(_python_)s mycompile.py f95 $TARGET $SOURCES', + SHF95PPCOM = r'%(_python_)s mycompile.py f95pp $TARGET $SOURCES', + SHFORTRANCOM = r'%(_python_)s mycompile.py fortran $TARGET $SOURCES', + SHFORTRANPPCOM = r'%(_python_)s mycompile.py fortranpp $TARGET $SOURCES') env.SharedObject(target = 'test01', source = 'test01.f') env.SharedObject(target = 'test02', source = 'test02.F') env.SharedObject(target = 'test03', source = 'test03.for') @@ -62,25 +49,25 @@ env.SharedObject(target = 'test07', source = 'test07.fpp') env.SharedObject(target = 'test08', source = 'test08.FPP') env.SharedObject(target = 'test13', source = 'test13.f95') env.SharedObject(target = 'test14', source = 'test14.F95') -env2 = Environment(SHF95COM = r'%(_python_)s myfortran.py f95 $TARGET $SOURCES', - SHF95PPCOM = r'%(_python_)s myfortran.py f95pp $TARGET $SOURCES') +env2 = Environment(SHF95COM = r'%(_python_)s mycompile.py f95 $TARGET $SOURCES', + SHF95PPCOM = r'%(_python_)s mycompile.py f95pp $TARGET $SOURCES') env2.SharedObject(target = 'test21', source = 'test21.f95') env2.SharedObject(target = 'test22', source = 'test22.F95') """ % locals()) -test.write('test01.f', "This is a .f file.\n#fortran\n") -test.write('test02.F', "This is a .F file.\n#fortranpp\n") -test.write('test03.for', "This is a .for file.\n#fortran\n") -test.write('test04.FOR', "This is a .FOR file.\n#fortranpp\n") -test.write('test05.ftn', "This is a .ftn file.\n#fortran\n") -test.write('test06.FTN', "This is a .FTN file.\n#fortranpp\n") -test.write('test07.fpp', "This is a .fpp file.\n#fortranpp\n") -test.write('test08.FPP', "This is a .FPP file.\n#fortranpp\n") -test.write('test13.f95', "This is a .f95 file.\n#f95\n") -test.write('test14.F95', "This is a .F95 file.\n#f95pp\n") - -test.write('test21.f95', "This is a .f95 file.\n#f95\n") -test.write('test22.F95', "This is a .F95 file.\n#f95pp\n") +test.write('test01.f', "This is a .f file.\n/*fortran*/\n") +test.write('test02.F', "This is a .F file.\n/*fortranpp*/\n") +test.write('test03.for', "This is a .for file.\n/*fortran*/\n") +test.write('test04.FOR', "This is a .FOR file.\n/*fortranpp*/\n") +test.write('test05.ftn', "This is a .ftn file.\n/*fortran*/\n") +test.write('test06.FTN', "This is a .FTN file.\n/*fortranpp*/\n") +test.write('test07.fpp', "This is a .fpp file.\n/*fortranpp*/\n") +test.write('test08.FPP', "This is a .FPP file.\n/*fortranpp*/\n") +test.write('test13.f95', "This is a .f95 file.\n/*f95*/\n") +test.write('test14.F95', "This is a .F95 file.\n/*f95pp*/\n") + +test.write('test21.f95', "This is a .f95 file.\n/*f95*/\n") +test.write('test22.F95', "This is a .F95 file.\n/*f95pp*/\n") test.run(arguments = '.', stderr = None) diff --git a/test/Fortran/SHF95COMSTR.py b/test/Fortran/SHF95COMSTR.py index 5aec6b0..2c1282f 100644 --- a/test/Fortran/SHF95COMSTR.py +++ b/test/Fortran/SHF95COMSTR.py @@ -30,17 +30,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('myfc.py', r""" -import sys -fline = '#'+sys.argv[1]+'\n' -outfile = open(sys.argv[2], 'wb') -infile = open(sys.argv[3], 'rb') -for l in [l for l in infile.readlines() if l != fline]: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') if not TestSCons.case_sensitive_suffixes('.f','.F'): f95pp = 'f95' @@ -49,17 +39,17 @@ else: test.write('SConstruct', """ -env = Environment(SHF95COM = r'%(_python_)s myfc.py f95 $TARGET $SOURCES', +env = Environment(SHF95COM = r'%(_python_)s mycompile.py f95 $TARGET $SOURCES', SHF95COMSTR = 'Building f95 $TARGET from $SOURCES', - SHF95PPCOM = r'%(_python_)s myfc.py f95pp $TARGET $SOURCES', + SHF95PPCOM = r'%(_python_)s mycompile.py f95pp $TARGET $SOURCES', SHF95PPCOMSTR = 'Building f95pp $TARGET from $SOURCES', SHOBJPREFIX='', SHOBJSUFFIX='.shobj') env.SharedObject(source = 'test01.f95') env.SharedObject(source = 'test02.F95') """ % locals()) -test.write('test01.f95', "A .f95 file.\n#f95\n") -test.write('test02.F95', "A .F95 file.\n#%s\n" % f95pp) +test.write('test01.f95', "A .f95 file.\n/*f95*/\n") +test.write('test02.F95', "A .F95 file.\n/*%s*/\n" % f95pp) test.run(stdout = test.wrap_stdout("""\ Building f95 test01.shobj from test01.f95 diff --git a/test/Fortran/SHFORTRANCOM.py b/test/Fortran/SHFORTRANCOM.py index f89358d..56958b2 100644 --- a/test/Fortran/SHFORTRANCOM.py +++ b/test/Fortran/SHFORTRANCOM.py @@ -32,24 +32,11 @@ obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() - - -test.write('myfortran.py', r""" -import sys -comment = '#' + sys.argv[1] -outfile = open(sys.argv[2], 'wb') -infile = open(sys.argv[3], 'rb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture('mycompile.py') test.write('SConstruct', """ -env = Environment(SHFORTRANCOM = r'%(_python_)s myfortran.py fortran $TARGET $SOURCES', - SHFORTRANPPCOM = r'%(_python_)s myfortran.py fortranpp $TARGET $SOURCES') +env = Environment(SHFORTRANCOM = r'%(_python_)s mycompile.py fortran $TARGET $SOURCES', + SHFORTRANPPCOM = r'%(_python_)s mycompile.py fortranpp $TARGET $SOURCES') env.SharedObject(target = 'test01', source = 'test01.f') env.SharedObject(target = 'test02', source = 'test02.F') env.SharedObject(target = 'test03', source = 'test03.for') @@ -60,14 +47,14 @@ env.SharedObject(target = 'test07', source = 'test07.fpp') env.SharedObject(target = 'test08', source = 'test08.FPP') """ % locals()) -test.write('test01.f', "This is a .f file.\n#fortran\n") -test.write('test02.F', "This is a .F file.\n#fortranpp\n") -test.write('test03.for', "This is a .for file.\n#fortran\n") -test.write('test04.FOR', "This is a .FOR file.\n#fortranpp\n") -test.write('test05.ftn', "This is a .ftn file.\n#fortran\n") -test.write('test06.FTN', "This is a .FTN file.\n#fortranpp\n") -test.write('test07.fpp', "This is a .fpp file.\n#fortranpp\n") -test.write('test08.FPP', "This is a .FPP file.\n#fortranpp\n") +test.write('test01.f', "This is a .f file.\n/*fortran*/\n") +test.write('test02.F', "This is a .F file.\n/*fortranpp*/\n") +test.write('test03.for', "This is a .for file.\n/*fortran*/\n") +test.write('test04.FOR', "This is a .FOR file.\n/*fortranpp*/\n") +test.write('test05.ftn', "This is a .ftn file.\n/*fortran*/\n") +test.write('test06.FTN', "This is a .FTN file.\n/*fortranpp*/\n") +test.write('test07.fpp', "This is a .fpp file.\n/*fortranpp*/\n") +test.write('test08.FPP', "This is a .FPP file.\n/*fortranpp*/\n") test.run(arguments = '.', stderr = None) diff --git a/test/Fortran/SHFORTRANCOMSTR.py b/test/Fortran/SHFORTRANCOMSTR.py index 3b801db..c58920e 100644 --- a/test/Fortran/SHFORTRANCOMSTR.py +++ b/test/Fortran/SHFORTRANCOMSTR.py @@ -30,17 +30,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('myfc.py', r""" -import sys -fline = '#'+sys.argv[1]+'\n' -outfile = open(sys.argv[2], 'wb') -infile = open(sys.argv[3], 'rb') -for l in [l for l in infile.readlines() if l != fline]: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') if not TestSCons.case_sensitive_suffixes('.f','.F'): fortranpp = 'fortran' @@ -49,9 +39,9 @@ else: test.write('SConstruct', """ -env = Environment(SHFORTRANCOM = r'%(_python_)s myfc.py fortran $TARGET $SOURCES', +env = Environment(SHFORTRANCOM = r'%(_python_)s mycompile.py fortran $TARGET $SOURCES', SHFORTRANCOMSTR = 'Building fortran $TARGET from $SOURCES', - SHFORTRANPPCOM = r'%(_python_)s myfc.py fortranpp $TARGET $SOURCES', + SHFORTRANPPCOM = r'%(_python_)s mycompile.py fortranpp $TARGET $SOURCES', SHFORTRANPPCOMSTR = 'Building fortranpp $TARGET from $SOURCES', SHOBJPREFIX='', SHOBJSUFFIX='.shobj') env.SharedObject(source = 'test01.f') @@ -64,14 +54,14 @@ env.SharedObject(source = 'test07.fpp') env.SharedObject(source = 'test08.FPP') """ % locals()) -test.write('test01.f', "A .f file.\n#fortran\n") -test.write('test02.F', "A .F file.\n#%s\n" % fortranpp) -test.write('test03.for', "A .for file.\n#fortran\n") -test.write('test04.FOR', "A .FOR file.\n#%s\n" % fortranpp) -test.write('test05.ftn', "A .ftn file.\n#fortran\n") -test.write('test06.FTN', "A .FTN file.\n#%s\n" % fortranpp) -test.write('test07.fpp', "A .fpp file.\n#fortranpp\n") -test.write('test08.FPP', "A .FPP file.\n#fortranpp\n") +test.write('test01.f', "A .f file.\n/*fortran*/\n") +test.write('test02.F', "A .F file.\n/*%s*/\n" % fortranpp) +test.write('test03.for', "A .for file.\n/*fortran*/\n") +test.write('test04.FOR', "A .FOR file.\n/*%s*/\n" % fortranpp) +test.write('test05.ftn', "A .ftn file.\n/*fortran*/\n") +test.write('test06.FTN', "A .FTN file.\n/*%s*/\n" % fortranpp) +test.write('test07.fpp', "A .fpp file.\n/*fortranpp*/\n") +test.write('test08.FPP', "A .FPP file.\n/*fortranpp*/\n") test.run(stdout = test.wrap_stdout("""\ Building fortran test01.shobj from test01.f diff --git a/test/Ghostscript/GSCOM.py b/test/Ghostscript/GSCOM.py index c86f8b6..fd14ad8 100644 --- a/test/Ghostscript/GSCOM.py +++ b/test/Ghostscript/GSCOM.py @@ -34,21 +34,11 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('mygs.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 != '/*gs*/\\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(tools=['default', 'gs'], - GSCOM = r'%(_python_)s mygs.py $TARGET $SOURCES') + GSCOM = r'%(_python_)s mycompile.py gs $TARGET $SOURCES') env.PDF(target = 'aaa', source = 'aaa.ps') """ % locals()) @@ -58,8 +48,6 @@ test.run(arguments = '.') test.must_match('aaa.pdf', "aaa.ps\n") - - test.pass_test() # Local Variables: diff --git a/test/Ghostscript/GSCOMSTR.py b/test/Ghostscript/GSCOMSTR.py index b39cf4f..fd82bff 100644 --- a/test/Ghostscript/GSCOMSTR.py +++ b/test/Ghostscript/GSCOMSTR.py @@ -35,21 +35,11 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('mygs.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 != '/*gs*/\\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(tools=['default', 'gs'], - GSCOM = r'%(_python_)s mygs.py $TARGET $SOURCES', + GSCOM = r'%(_python_)s mycompile.py gs $TARGET $SOURCES', GSCOMSTR = 'GSing $TARGET from $SOURCE') env.PDF(target = 'aaa', source = 'aaa.ps') """ % locals()) @@ -62,8 +52,6 @@ GSing aaa.pdf from aaa.ps test.must_match('aaa.pdf', "aaa.ps\n") - - test.pass_test() # Local Variables: diff --git a/test/IDL/MIDLCOMSTR.py b/test/IDL/MIDLCOMSTR.py index 56f8c40..9e01aa0 100644 --- a/test/IDL/MIDLCOMSTR.py +++ b/test/IDL/MIDLCOMSTR.py @@ -35,21 +35,11 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('mymidl.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 != '/*midl*/\\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(tools=['default', 'midl'], - MIDLCOM = r'%(_python_)s mymidl.py $TARGET $SOURCES', + MIDLCOM = r'%(_python_)s mycompile.py midl $TARGET $SOURCES', MIDLCOMSTR = 'MIDLing $TARGET from $SOURCE') env.TypeLibrary(target = 'aaa', source = 'aaa.idl') """ % locals()) @@ -62,8 +52,6 @@ MIDLing aaa.tlb from aaa.idl test.must_match('aaa.tlb', "aaa.idl\n") - - test.pass_test() # Local Variables: diff --git a/test/Java/JARCOM.py b/test/Java/JARCOM.py index 9d93ba5..9146445 100644 --- a/test/Java/JARCOM.py +++ b/test/Java/JARCOM.py @@ -35,20 +35,11 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - -test.write('myjar.py', r""" -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 != '/*jar*/\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(TOOLS = ['default', 'jar'], - JARCOM = r'%(_python_)s myjar.py $TARGET $SOURCES') + JARCOM = r'%(_python_)s mycompile.py jar $TARGET $SOURCES') env.Jar(target = 'test1', source = ['file1.in', 'file2.in', 'file3.in']) """ % locals()) @@ -60,8 +51,6 @@ test.run() test.must_match('test1.jar', "file1.in\nfile2.in\nfile3.in\n") - - test.pass_test() # Local Variables: diff --git a/test/Java/JARCOMSTR.py b/test/Java/JARCOMSTR.py index 069587f..4bdc45b 100644 --- a/test/Java/JARCOMSTR.py +++ b/test/Java/JARCOMSTR.py @@ -35,21 +35,11 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('myjar.py', r""" -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 != '/*jar*/\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(TOOLS = ['default', 'jar'], - JARCOM = r'%(_python_)s myjar.py $TARGET $SOURCES', + JARCOM = r'%(_python_)s mycompile.py jar $TARGET $SOURCES', JARCOMSTR = "Jar'ing up $TARGET from $SOURCES") env.Jar(target = 'test1', source = ['file1.in', 'file2.in', 'file3.in']) """ % locals()) @@ -64,8 +54,6 @@ Jar'ing up test1.jar from file1.in file2.in file3.in test.must_match('test1.jar', "file1.in\nfile2.in\nfile3.in\n") - - test.pass_test() # Local Variables: diff --git a/test/Java/JAVACCOM.py b/test/Java/JAVACCOM.py index 064feed..0de173d 100644 --- a/test/Java/JAVACCOM.py +++ b/test/Java/JAVACCOM.py @@ -36,21 +36,11 @@ test = TestSCons.TestSCons() test.subdir('src') - - -test.write('myjavac.py', r""" -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 != '/*javac*/\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(TOOLS = ['default', 'javac'], - JAVACCOM = r'%(_python_)s myjavac.py $TARGET $SOURCES') + JAVACCOM = r'%(_python_)s mycompile.py javac $TARGET $SOURCES') env.Java(target = 'classes', source = 'src') """ % locals()) @@ -63,8 +53,6 @@ test.run() test.must_match(['classes', 'file1.class'], "file1.java\nfile2.java\nfile3.java\n") - - test.pass_test() # Local Variables: diff --git a/test/Java/JAVACCOMSTR.py b/test/Java/JAVACCOMSTR.py index 6440283..8540e13 100644 --- a/test/Java/JAVACCOMSTR.py +++ b/test/Java/JAVACCOMSTR.py @@ -39,21 +39,11 @@ test = TestSCons.TestSCons() test.subdir('src') - - -test.write('myjavac.py', r""" -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 != '/*javac*/\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(TOOLS = ['default', 'javac'], - JAVACCOM = r'%(_python_)s myjavac.py $TARGET $SOURCES', + JAVACCOM = r'%(_python_)s mycompile.py javac $TARGET $SOURCES', JAVACCOMSTR = "Compiling class(es) $TARGET from $SOURCES") env.Java(target = 'classes', source = 'src') """ % locals()) @@ -74,8 +64,6 @@ Compiling class(es) %(classes_file1_class)s from %(src_file1_java)s %(src_file2_ test.must_match(['classes', 'file1.class'], "file1.java\nfile2.java\nfile3.java\n") - - test.pass_test() # Local Variables: diff --git a/test/Java/JAVAHCOM.py b/test/Java/JAVAHCOM.py index 9db897a..801707e 100644 --- a/test/Java/JAVAHCOM.py +++ b/test/Java/JAVAHCOM.py @@ -34,21 +34,11 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('myjavah.py', r""" -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 != '/*javah*/\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(TOOLS = ['default', 'javah'], - JAVAHCOM = r'%(_python_)s myjavah.py $TARGET $SOURCES') + JAVAHCOM = r'%(_python_)s mycompile.py javah $TARGET $SOURCES') env.JavaH(target = 'out', source = 'file1.class') env.JavaH(target = 'out', source = 'file2.class') env.JavaH(target = 'out', source = 'file3.class') @@ -64,8 +54,6 @@ test.must_match(['out', 'file1.h'], "file1.class\n") test.must_match(['out', 'file2.h'], "file2.class\n") test.must_match(['out', 'file3.h'], "file3.class\n") - - test.pass_test() # Local Variables: diff --git a/test/Java/JAVAHCOMSTR.py b/test/Java/JAVAHCOMSTR.py index f8120d6..c205890 100644 --- a/test/Java/JAVAHCOMSTR.py +++ b/test/Java/JAVAHCOMSTR.py @@ -39,27 +39,15 @@ test = TestSCons.TestSCons() test.subdir('src') - - out_file1_h = os.path.join('out', 'file1.h') out_file2_h = os.path.join('out', 'file2.h') out_file3_h = os.path.join('out', 'file3.h') - - -test.write('myjavah.py', r""" -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 != '/*javah*/\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(TOOLS = ['default', 'javah'], - JAVAHCOM = r'%(_python_)s myjavah.py $TARGET $SOURCES', + JAVAHCOM = r'%(_python_)s mycompile.py javah $TARGET $SOURCES', JAVAHCOMSTR = 'Building javah $TARGET from $SOURCES') env.JavaH(target = 'out', source = 'file1.class') env.JavaH(target = 'out', source = 'file2.class') @@ -80,8 +68,6 @@ test.must_match(['out', 'file1.h'], "file1.class\n") test.must_match(['out', 'file2.h'], "file2.class\n") test.must_match(['out', 'file3.h'], "file3.class\n") - - test.pass_test() # Local Variables: diff --git a/test/Java/RMICCOM.py b/test/Java/RMICCOM.py index ba7f965..9f6595d 100644 --- a/test/Java/RMICCOM.py +++ b/test/Java/RMICCOM.py @@ -38,27 +38,15 @@ test = TestSCons.TestSCons() test.subdir('src') - - out_file1 = os.path.join('out', 'file1', 'class_Stub.class') out_file2 = os.path.join('out', 'file2', 'class_Stub.class') out_file3 = os.path.join('out', 'file3', 'class_Stub.class') - - -test.write('myrmic.py', r""" -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 != '/*rmic*/\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(TOOLS = ['default', 'rmic'], - RMICCOM = r'%(_python_)s myrmic.py $TARGET $SOURCES') + RMICCOM = r'%(_python_)s mycompile.py rmic $TARGET $SOURCES') env.RMIC(target = 'out', source = 'file1.class') env.RMIC(target = 'out', source = 'file2.class') env.RMIC(target = 'out', source = 'file3.class') @@ -74,8 +62,6 @@ test.must_match(out_file1, "file1.class\n") test.must_match(out_file2, "file2.class\n") test.must_match(out_file3, "file3.class\n") - - test.pass_test() # Local Variables: diff --git a/test/Java/RMICCOMSTR.py b/test/Java/RMICCOMSTR.py index 8fe535a..d4d1904 100644 --- a/test/Java/RMICCOMSTR.py +++ b/test/Java/RMICCOMSTR.py @@ -39,27 +39,15 @@ test = TestSCons.TestSCons() test.subdir('src') - - out_file1 = os.path.join('out', 'file1', 'class_Stub.class') out_file2 = os.path.join('out', 'file2', 'class_Stub.class') out_file3 = os.path.join('out', 'file3', 'class_Stub.class') - - -test.write('myrmic.py', r""" -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 != '/*rmic*/\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(TOOLS = ['default', 'rmic'], - RMICCOM = r'%(_python_)s myrmic.py $TARGET $SOURCES', + RMICCOM = r'%(_python_)s mycompile.py rmic $TARGET $SOURCES', RMICCOMSTR = 'Building rmic $TARGET from $SOURCES') env.RMIC(target = 'out', source = 'file1.class') env.RMIC(target = 'out', source = 'file2.class') @@ -80,8 +68,6 @@ test.must_match(out_file1, "file1.class\n") test.must_match(out_file2, "file2.class\n") test.must_match(out_file3, "file3.class\n") - - test.pass_test() # Local Variables: diff --git a/test/LEX/LEXCOM.py b/test/LEX/LEXCOM.py index 6a32388..75f21b7 100644 --- a/test/LEX/LEXCOM.py +++ b/test/LEX/LEXCOM.py @@ -34,21 +34,11 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('mylex.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 != b'/*lex*/\\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(tools=['default', 'lex'], - LEXCOM = r'%(_python_)s mylex.py $TARGET $SOURCES') + LEXCOM = r'%(_python_)s mycompile.py lex $TARGET $SOURCES') env.CFile(target = 'aaa', source = 'aaa.l') env.CFile(target = 'bbb', source = 'bbb.lex') """ % locals()) @@ -61,8 +51,6 @@ test.run(arguments = '.') test.must_match('aaa.c', "aaa.l\n") test.must_match('bbb.c', "bbb.lex\n") - - test.pass_test() # Local Variables: diff --git a/test/LEX/LEXCOMSTR.py b/test/LEX/LEXCOMSTR.py index 07e693c..2130d60 100644 --- a/test/LEX/LEXCOMSTR.py +++ b/test/LEX/LEXCOMSTR.py @@ -35,21 +35,11 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('mylex.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 != b'/*lex*/\\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(tools=['default', 'lex'], - LEXCOM = r'%(_python_)s mylex.py $TARGET $SOURCES', + LEXCOM = r'%(_python_)s mycompile.py lex $TARGET $SOURCES', LEXCOMSTR = 'Lexing $TARGET from $SOURCE') env.CFile(target = 'aaa', source = 'aaa.l') env.CFile(target = 'bbb', source = 'bbb.lex') @@ -66,8 +56,6 @@ Lexing bbb.c from bbb.lex test.must_match('aaa.c', "aaa.l\n") test.must_match('bbb.c', "bbb.lex\n") - - test.pass_test() # Local Variables: diff --git a/test/LINK/LINKCOM.py b/test/LINK/LINKCOM.py index 996e727..da12b10 100644 --- a/test/LINK/LINKCOM.py +++ b/test/LINK/LINKCOM.py @@ -34,18 +34,10 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() -test.write('mylink.py', r""" -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'/*link*/\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ -env = Environment(LINKCOM = r'%(_python_)s mylink.py $TARGET $SOURCES', +env = Environment(LINKCOM = r'%(_python_)s mycompile.py link $TARGET $SOURCES', OBJSUFFIX = '.obj', PROGSUFFIX = '.exe') env.Program(target = 'test1', source = ['test1.obj', 'test2.obj']) @@ -65,8 +57,6 @@ test.run() test.must_match('test1.exe', "test1.obj\ntest2.obj\n") - - test.pass_test() # Local Variables: diff --git a/test/LINK/LINKCOMSTR.py b/test/LINK/LINKCOMSTR.py index 8163016..df070fb 100644 --- a/test/LINK/LINKCOMSTR.py +++ b/test/LINK/LINKCOMSTR.py @@ -35,20 +35,10 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('mylink.py', r""" -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'/*link*/\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ -env = Environment(LINKCOM = r'%(_python_)s mylink.py $TARGET $SOURCES', +env = Environment(LINKCOM = r'%(_python_)s mycompile.py link $TARGET $SOURCES', LINKCOMSTR = 'Linking $TARGET from $SOURCES', OBJSUFFIX = '.obj', PROGSUFFIX = '.exe') diff --git a/test/LINK/SHLINKCOM.py b/test/LINK/SHLINKCOM.py index 1204ed1..9907db5 100644 --- a/test/LINK/SHLINKCOM.py +++ b/test/LINK/SHLINKCOM.py @@ -34,31 +34,11 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('mycc.py', r""" -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'/*cc*/\n']: - outfile.write(l) -sys.exit(0) - -""") -test.write('mylink.py', r""" -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'/*link*/\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ -env = Environment(SHCCCOM = r'%(_python_)s mycc.py $TARGET $SOURCES', - SHLINKCOM = r'%(_python_)s mylink.py $TARGET $SOURCES', +env = Environment(SHCCCOM = r'%(_python_)s mycompile.py cc $TARGET $SOURCES', + SHLINKCOM = r'%(_python_)s mycompile.py link $TARGET $SOURCES', SHOBJSUFFIX = '.obj', SHLIBPREFIX = '', SHLIBSUFFIX = '.dll') @@ -83,9 +63,6 @@ test.run() test.must_match('test3.dll', "test1.c\ntest2.c\n") - - - test.pass_test() # Local Variables: diff --git a/test/LINK/SHLINKCOMSTR.py b/test/LINK/SHLINKCOMSTR.py index 5663a1e..4dd5c7c 100644 --- a/test/LINK/SHLINKCOMSTR.py +++ b/test/LINK/SHLINKCOMSTR.py @@ -36,31 +36,11 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('mycc.py', r""" -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'/*cc*/\n']: - outfile.write(l) -sys.exit(0) - -""") -test.write('mylink.py', r""" -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'/*link*/\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ -env = Environment(SHCCCOM = r'%(_python_)s mycc.py $TARGET $SOURCES', - SHLINKCOM = r'%(_python_)s mylink.py $TARGET $SOURCES', +env = Environment(SHCCCOM = r'%(_python_)s mycompile.py cc $TARGET $SOURCES', + SHLINKCOM = r'%(_python_)s mycompile.py link $TARGET $SOURCES', SHLINKCOMSTR = 'Linking shared $TARGET from $SOURCES', SHOBJPREFIX = '', SHOBJSUFFIX = '.obj', @@ -84,8 +64,8 @@ test2.c """) test.run(stdout = test.wrap_stdout("""\ -%(_python_)s mycc.py test1.obj test1.c -%(_python_)s mycc.py test2.obj test2.c +%(_python_)s mycompile.py cc test1.obj test1.c +%(_python_)s mycompile.py cc test2.obj test2.c Linking shared test3.dll from test1.obj test2.obj """ % locals())) diff --git a/test/MSVC/PCHCOM.py b/test/MSVC/PCHCOM.py index ff27e10..fefab92 100644 --- a/test/MSVC/PCHCOM.py +++ b/test/MSVC/PCHCOM.py @@ -34,21 +34,11 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('mypch.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 != '/*pch*/\\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(tools=['default', 'msvc'], - PCHCOM = r'%(_python_)s mypch.py $TARGET $SOURCES') + PCHCOM = r'%(_python_)s mycompile.py pch $TARGET $SOURCES') env.PCH(target = 'aaa', source = 'aaa.h') """ % locals()) @@ -58,8 +48,6 @@ test.run(arguments = ".") test.must_match('aaa.pch', "aaa.h\n") - - test.pass_test() # Local Variables: diff --git a/test/MSVC/PCHCOMSTR.py b/test/MSVC/PCHCOMSTR.py index 51f56fb..beea488 100644 --- a/test/MSVC/PCHCOMSTR.py +++ b/test/MSVC/PCHCOMSTR.py @@ -35,21 +35,11 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('mypch.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 != '/*pch*/\\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(tools=['default', 'msvc'], - PCHCOM = r'%(_python_)s mypch.py $TARGET $SOURCES', + PCHCOM = r'%(_python_)s mycompile.py pch $TARGET $SOURCES', PCHCOMSTR = 'PCHing $TARGET from $SOURCE') env.PCH(target = 'aaa', source = 'aaa.h') """ % locals()) @@ -62,8 +52,6 @@ PCHing aaa.pch from aaa.h test.must_match('aaa.pch', "aaa.h\n") - - test.pass_test() # Local Variables: diff --git a/test/MSVC/RCCOM.py b/test/MSVC/RCCOM.py index 05382b8..04f8fff 100644 --- a/test/MSVC/RCCOM.py +++ b/test/MSVC/RCCOM.py @@ -35,21 +35,11 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('myrc.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 != '/*rc*/\\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(tools=['default', 'msvc'], - RCCOM = r'%(_python_)s myrc.py $TARGET $SOURCES') + RCCOM = r'%(_python_)s mycompile.py rc $TARGET $SOURCES') env.RES(target = 'aaa', source = 'aaa.rc') """ % locals()) @@ -59,8 +49,6 @@ test.run(arguments = ".") test.must_match('aaa.res', "aaa.rc\n") - - test.pass_test() # Local Variables: diff --git a/test/MSVC/RCCOMSTR.py b/test/MSVC/RCCOMSTR.py index 8425d73..2630651 100644 --- a/test/MSVC/RCCOMSTR.py +++ b/test/MSVC/RCCOMSTR.py @@ -35,21 +35,11 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('myrc.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 != '/*rc*/\\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(tools=['default', 'msvc'], - RCCOM = r'%(_python_)s myrc.py $TARGET $SOURCES', + RCCOM = r'%(_python_)s mycompile.py rc $TARGET $SOURCES', RCCOMSTR = 'RCing $TARGET from $SOURCE') env.RES(target = 'aaa', source = 'aaa.rc') """ % locals()) @@ -62,8 +52,6 @@ RCing aaa.res from aaa.rc test.must_match('aaa.res', "aaa.rc\n") - - test.pass_test() # Local Variables: diff --git a/test/MinGW/RCCOM.py b/test/MinGW/RCCOM.py index dadfea5..a4d9147 100644 --- a/test/MinGW/RCCOM.py +++ b/test/MinGW/RCCOM.py @@ -39,19 +39,11 @@ test = TestSCons.TestSCons() if sys.platform in ('irix6',): test.skip_test("Skipping mingw test on non-Windows %s platform."%sys.platform) -test.write('myrc.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 != '/*rc*/\\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(tools=['default', 'mingw'], - RCCOM = r'%(_python_)s myrc.py $TARGET $SOURCES') + RCCOM = r'%(_python_)s mycompile.py rc $TARGET $SOURCES') env.RES(target = 'aaa', source = 'aaa.rc') """ % locals()) @@ -61,8 +53,6 @@ test.run(arguments = ".") test.must_match('aaa.o', "aaa.rc\n") - - test.pass_test() # Local Variables: diff --git a/test/MinGW/RCCOMSTR.py b/test/MinGW/RCCOMSTR.py index 501a57d..0ed84c2 100644 --- a/test/MinGW/RCCOMSTR.py +++ b/test/MinGW/RCCOMSTR.py @@ -39,19 +39,11 @@ test = TestSCons.TestSCons() if sys.platform in ('irix6',): test.skip_test("Skipping mingw test on non-Windows %s platform."%sys.platform) -test.write('myrc.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 != '/*rc*/\\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(tools=['default', 'mingw'], - RCCOM = r'%(_python_)s myrc.py $TARGET $SOURCES', + RCCOM = r'%(_python_)s mycompile.py rc $TARGET $SOURCES', RCCOMSTR = 'RCing $TARGET from $SOURCE') env.RES(target = 'aaa', source = 'aaa.rc') """ % locals()) @@ -64,8 +56,6 @@ RCing aaa.o from aaa.rc test.must_match('aaa.o', "aaa.rc\n") - - test.pass_test() # Local Variables: diff --git a/test/RANLIB/RANLIBCOM.py b/test/RANLIB/RANLIBCOM.py index 486a91f..6a3ea0f 100644 --- a/test/RANLIB/RANLIBCOM.py +++ b/test/RANLIB/RANLIBCOM.py @@ -39,31 +39,13 @@ ranlib = test.detect('RANLIB', 'ranlib') if not ranlib: test.skip_test("Could not find 'ranlib', skipping test.\n") - - -test.write('myar.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 != '/*ar*/\\n']: - outfile.write(l) -sys.exit(0) -""") - -test.write('myranlib.py', """ -import sys -lines = open(sys.argv[1], 'rb').readlines() -outfile = open(sys.argv[1], 'wb') -for l in [l for l in lines if l != '/*ranlib*/\\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') +test.file_fixture('myrewrite.py') test.write('SConstruct', """ env = Environment(tools=['default', 'ar'], - ARCOM = r'%(_python_)s myar.py $TARGET $SOURCES', - RANLIBCOM = r'%(_python_)s myranlib.py $TARGET', + ARCOM = r'%(_python_)s mycompile.py ar $TARGET $SOURCES', + RANLIBCOM = r'%(_python_)s myrewrite.py ranlib $TARGET', LIBPREFIX = '', LIBSUFFIX = '.lib') env.Library(target = 'output', source = ['file.1', 'file.2']) @@ -76,8 +58,6 @@ test.run(arguments = '.') test.must_match('output.lib', "file.1\nfile.2\n") - - test.pass_test() # Local Variables: diff --git a/test/RANLIB/RANLIBCOMSTR.py b/test/RANLIB/RANLIBCOMSTR.py index 6e76cbf..2b8fc83 100644 --- a/test/RANLIB/RANLIBCOMSTR.py +++ b/test/RANLIB/RANLIBCOMSTR.py @@ -42,29 +42,13 @@ if not ranlib: -test.write('myar.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 != '/*ar*/\\n']: - outfile.write(l) -sys.exit(0) -""") - -test.write('myranlib.py', """ -import sys -lines = open(sys.argv[1], 'rb').readlines() -outfile = open(sys.argv[1], 'wb') -for l in [l for l in lines if l != '/*ranlib*/\\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') +test.file_fixture('myrewrite.py') test.write('SConstruct', """ env = Environment(tools=['default', 'ar'], - ARCOM = r'%(_python_)s myar.py $TARGET $SOURCES', - RANLIBCOM = r'%(_python_)s myranlib.py $TARGET', + ARCOM = r'%(_python_)s mycompile.py ar $TARGET $SOURCES', + RANLIBCOM = r'%(_python_)s myrewrite.py ranlib $TARGET', RANLIBCOMSTR = 'Indexing $TARGET', LIBPREFIX = '', LIBSUFFIX = '.lib') @@ -75,7 +59,7 @@ test.write('file.1', "file.1\n/*ar*/\n/*ranlib*/\n") test.write('file.2', "file.2\n/*ar*/\n/*ranlib*/\n") expect = test.wrap_stdout("""\ -%(_python_)s myar.py output.lib file.1 file.2 +%(_python_)s mycompile.py ar output.lib file.1 file.2 Indexing output.lib """ % locals()) @@ -83,8 +67,6 @@ test.run(stdout = expect) test.must_match('output.lib', "file.1\nfile.2\n") - - test.pass_test() # Local Variables: diff --git a/test/SWIG/SWIGCOM.py b/test/SWIG/SWIGCOM.py index ee3ff64..b2d8da2 100644 --- a/test/SWIG/SWIGCOM.py +++ b/test/SWIG/SWIGCOM.py @@ -34,21 +34,11 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('myswig.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 != b'/*swig*/\\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(tools=['default', 'swig'], - SWIGCOM = r'%(_python_)s myswig.py $TARGET $SOURCES') + SWIGCOM = r'%(_python_)s mycompile.py swig $TARGET $SOURCES') env.CFile(target = 'aaa', source = 'aaa.i') env.CXXFile(target = 'bbb', source = 'bbb.i', SWIGFLAGS='-c++') """ % locals()) @@ -61,8 +51,6 @@ test.run(arguments = '.') test.must_match('aaa_wrap.c', "aaa.i\n") test.must_match('bbb_wrap.cc', "bbb.i\n") - - test.pass_test() # Local Variables: diff --git a/test/SWIG/SWIGCOMSTR.py b/test/SWIG/SWIGCOMSTR.py index 24db13e..c2c3df3 100644 --- a/test/SWIG/SWIGCOMSTR.py +++ b/test/SWIG/SWIGCOMSTR.py @@ -35,21 +35,11 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('myswig.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 != b'/*swig*/\\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(tools=['default', 'swig'], - SWIGCOM = r'%(_python_)s myswig.py $TARGET $SOURCES', + SWIGCOM = r'%(_python_)s mycompile.py swig $TARGET $SOURCES', SWIGCOMSTR = 'Swigging $TARGET from $SOURCE') env.CFile(target = 'aaa', source = 'aaa.i') env.CXXFile(target = 'bbb', source = 'bbb.i', SWIGFLAGS='-c++') @@ -66,8 +56,6 @@ Swigging bbb_wrap.cc from bbb.i test.must_match('aaa_wrap.c', "aaa.i\n") test.must_match('bbb_wrap.cc', "bbb.i\n") - - test.pass_test() # Local Variables: diff --git a/test/TAR/TARCOM.py b/test/TAR/TARCOM.py index d1b3662..aaf7b60 100644 --- a/test/TAR/TARCOM.py +++ b/test/TAR/TARCOM.py @@ -34,20 +34,11 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('mytar.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 != '/*tar*/\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(TOOLS = ['tar'], - TARCOM = r'%(_python_)s mytar.py $TARGET $SOURCE') + TARCOM = r'%(_python_)s mycompile.py tar $TARGET $SOURCE') env.Tar('test1.tar', 'test1.in') """ % locals()) @@ -60,8 +51,6 @@ test.run() test.must_match('test1.tar', "test1.in\n") - - test.pass_test() # Local Variables: diff --git a/test/TAR/TARCOMSTR.py b/test/TAR/TARCOMSTR.py index 339f0ca..817dc59 100644 --- a/test/TAR/TARCOMSTR.py +++ b/test/TAR/TARCOMSTR.py @@ -35,21 +35,11 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('mytar.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 != '/*tar*/\\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(tools=['tar'], - TARCOM = r'%(_python_)s mytar.py $TARGET $SOURCES', + TARCOM = r'%(_python_)s mycompile.py tar $TARGET $SOURCES', TARCOMSTR = 'Taring $TARGET from $SOURCE') env.Tar('aaa.tar', 'aaa.in') """ % locals()) @@ -62,8 +52,6 @@ Taring aaa.tar from aaa.in test.must_match('aaa.tar', "aaa.in\n") - - test.pass_test() # Local Variables: diff --git a/test/TEX/LATEXCOM.py b/test/TEX/LATEXCOM.py index 2c63864..878d4cf 100644 --- a/test/TEX/LATEXCOM.py +++ b/test/TEX/LATEXCOM.py @@ -31,24 +31,14 @@ Test the ability to configure the $LATEXCOM construction variable. import TestSCons _python_ = TestSCons._python_ -_exe = TestSCons._exe test = TestSCons.TestSCons() - - -test.write('mylatex.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 != '/*latex*/\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(TOOLS = ['latex'], - LATEXCOM = r'%(_python_)s mylatex.py $TARGET $SOURCE') + LATEXCOM = r'%(_python_)s mycompile.py latex $TARGET $SOURCE') env.DVI('test1', 'test1.latex') """ % locals()) @@ -61,8 +51,6 @@ test.run() test.must_match('test1.dvi', "test1.latex\n") - - test.pass_test() # Local Variables: diff --git a/test/TEX/LATEXCOMSTR.py b/test/TEX/LATEXCOMSTR.py index 4e1b93c..f8a377d 100644 --- a/test/TEX/LATEXCOMSTR.py +++ b/test/TEX/LATEXCOMSTR.py @@ -32,24 +32,14 @@ the C compilation output. import TestSCons _python_ = TestSCons._python_ -_exe = TestSCons._exe test = TestSCons.TestSCons() - - -test.write('mylatex.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 != '/*latex*/\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(TOOLS = ['latex'], - LATEXCOM = r'%(_python_)s mylatex.py $TARGET $SOURCE', + LATEXCOM = r'%(_python_)s mycompile.py latex $TARGET $SOURCE', LATEXCOMSTR = 'Building $TARGET from $SOURCE') env.DVI('test1', 'test1.latex') """ % locals()) @@ -65,8 +55,6 @@ Building test1.dvi from test1.latex test.must_match('test1.dvi', "test1.latex\n") - - test.pass_test() # Local Variables: diff --git a/test/TEX/PDFLATEXCOM.py b/test/TEX/PDFLATEXCOM.py index 09283f3..c2b54ce 100644 --- a/test/TEX/PDFLATEXCOM.py +++ b/test/TEX/PDFLATEXCOM.py @@ -31,24 +31,14 @@ Test the ability to configure the $PDFLATEXCOM construction variable. import TestSCons _python_ = TestSCons._python_ -_exe = TestSCons._exe test = TestSCons.TestSCons() - - -test.write('mypdflatex.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 != '/*latex*/\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(TOOLS = ['pdflatex'], - PDFLATEXCOM = r'%(_python_)s mypdflatex.py $TARGET $SOURCE') + PDFLATEXCOM = r'%(_python_)s mycompile.py latex $TARGET $SOURCE') env.PDF('test1', 'test1.latex') """ % locals()) @@ -61,8 +51,6 @@ test.run() test.must_match('test1.pdf', "test1.latex\n") - - test.pass_test() # Local Variables: diff --git a/test/TEX/PDFLATEXCOMSTR.py b/test/TEX/PDFLATEXCOMSTR.py index c751e8e..1d911bd 100644 --- a/test/TEX/PDFLATEXCOMSTR.py +++ b/test/TEX/PDFLATEXCOMSTR.py @@ -33,24 +33,14 @@ the C compilation output. import TestSCons _python_ = TestSCons._python_ -_exe = TestSCons._exe test = TestSCons.TestSCons() - - -test.write('mypdflatex.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 != '/*latex*/\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(TOOLS = ['pdflatex'], - PDFLATEXCOM = r'%(_python_)s mypdflatex.py $TARGET $SOURCE', + PDFLATEXCOM = r'%(_python_)s mycompile.py latex $TARGET $SOURCE', PDFLATEXCOMSTR = 'Building $TARGET from $SOURCE') env.PDF('test1', 'test1.latex') """ % locals()) @@ -66,8 +56,6 @@ Building test1.pdf from test1.latex test.must_match('test1.pdf', "test1.latex\n") - - test.pass_test() # Local Variables: diff --git a/test/TEX/PDFTEXCOM.py b/test/TEX/PDFTEXCOM.py index 8c31da3..6e915a4 100644 --- a/test/TEX/PDFTEXCOM.py +++ b/test/TEX/PDFTEXCOM.py @@ -31,24 +31,14 @@ Test the ability to configure the $PDFTEXCOM construction variable. import TestSCons _python_ = TestSCons._python_ -_exe = TestSCons._exe test = TestSCons.TestSCons() - - -test.write('mypdftex.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 != '/*tex*/\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(TOOLS = ['pdftex'], - PDFTEXCOM = r'%(_python_)s mypdftex.py $TARGET $SOURCE') + PDFTEXCOM = r'%(_python_)s mycompile.py tex $TARGET $SOURCE') env.PDF('test1') """ % locals()) @@ -61,8 +51,6 @@ test.run() test.must_match('test1.pdf', "test1.tex\n") - - test.pass_test() # Local Variables: diff --git a/test/TEX/PDFTEXCOMSTR.py b/test/TEX/PDFTEXCOMSTR.py index 13abe7a..7ee5b41 100644 --- a/test/TEX/PDFTEXCOMSTR.py +++ b/test/TEX/PDFTEXCOMSTR.py @@ -33,24 +33,14 @@ the C compilation output. import TestSCons _python_ = TestSCons._python_ -_exe = TestSCons._exe test = TestSCons.TestSCons() - - -test.write('mypdftex.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 != '/*tex*/\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(TOOLS = ['pdftex'], - PDFTEXCOM = r'%(_python_)s mypdftex.py $TARGET $SOURCE', + PDFTEXCOM = r'%(_python_)s mycompile.py tex $TARGET $SOURCE', PDFTEXCOMSTR = 'Building $TARGET from $SOURCE') env.PDF('test1') """ % locals()) @@ -66,8 +56,6 @@ Building test1.pdf from test1.tex test.must_match('test1.pdf', "test1.tex\n") - - test.pass_test() # Local Variables: diff --git a/test/TEX/TEXCOM.py b/test/TEX/TEXCOM.py index 1cadd63..9d820bc 100644 --- a/test/TEX/TEXCOM.py +++ b/test/TEX/TEXCOM.py @@ -31,24 +31,14 @@ Test the ability to configure the $TEXCOM construction variable. import TestSCons _python_ = TestSCons._python_ -_exe = TestSCons._exe test = TestSCons.TestSCons() - - -test.write('mytex.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 != '/*tex*/\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(TOOLS = ['tex'], - TEXCOM = r'%(_python_)s mytex.py $TARGET $SOURCE') + TEXCOM = r'%(_python_)s mycompile.py tex $TARGET $SOURCE') env.DVI('test1') """ % locals()) @@ -61,8 +51,6 @@ test.run() test.must_match('test1.dvi', "test1.tex\n") - - test.pass_test() # Local Variables: diff --git a/test/TEX/TEXCOMSTR.py b/test/TEX/TEXCOMSTR.py index f1ead7f..0facc6f 100644 --- a/test/TEX/TEXCOMSTR.py +++ b/test/TEX/TEXCOMSTR.py @@ -32,24 +32,14 @@ the C compilation output. import TestSCons _python_ = TestSCons._python_ -_exe = TestSCons._exe test = TestSCons.TestSCons() - - -test.write('mytex.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 != '/*tex*/\n']: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(TOOLS = ['tex'], - TEXCOM = r'%(_python_)s mytex.py $TARGET $SOURCE', + TEXCOM = r'%(_python_)s mycompile.py tex $TARGET $SOURCE', TEXCOMSTR = 'Building $TARGET from $SOURCE') env.DVI('test1') """ % locals()) @@ -65,8 +55,6 @@ Building test1.dvi from test1.tex test.must_match('test1.dvi', "test1.tex\n") - - test.pass_test() # Local Variables: diff --git a/test/YACC/YACCCOM-fixture/.exclude_tests b/test/YACC/YACCCOM-fixture/.exclude_tests deleted file mode 100644 index f12c4d0..0000000 --- a/test/YACC/YACCCOM-fixture/.exclude_tests +++ /dev/null @@ -1 +0,0 @@ -myyacc.py diff --git a/test/YACC/YACCCOM-fixture/myyacc.py b/test/YACC/YACCCOM-fixture/myyacc.py deleted file mode 100644 index 1502800..0000000 --- a/test/YACC/YACCCOM-fixture/myyacc.py +++ /dev/null @@ -1,7 +0,0 @@ -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 70ffa72..e9fb47f 100644 --- a/test/YACC/YACCCOM.py +++ b/test/YACC/YACCCOM.py @@ -34,23 +34,23 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() -test.dir_fixture('shared-fixture') -test.dir_fixture('YACCCOM-fixture') +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(tools=['default', 'yacc'], - YACCCOM = r'%(_python_)s myyacc.py $TARGET $SOURCES') + YACCCOM = r'%(_python_)s mycompile.py yacc $TARGET $SOURCES') 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") test.must_match('bbb.c', "bbb.yacc\n") - - test.pass_test() # Local Variables: diff --git a/test/YACC/YACCCOMSTR.py b/test/YACC/YACCCOMSTR.py index 344b715..bded560 100644 --- a/test/YACC/YACCCOMSTR.py +++ b/test/YACC/YACCCOMSTR.py @@ -35,17 +35,19 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() -test.dir_fixture('shared-fixture') -test.dir_fixture('YACCCOM-fixture') +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(tools=['default', 'yacc'], - YACCCOM = r'%(_python_)s myyacc.py $TARGET $SOURCES', + YACCCOM = r'%(_python_)s mycompile.py yacc $TARGET $SOURCES', YACCCOMSTR = 'Yaccing $TARGET from $SOURCE') 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 @@ -54,8 +56,6 @@ Yaccing bbb.c from bbb.yacc test.must_match('aaa.c', "aaa.y\n") test.must_match('bbb.c', "bbb.yacc\n") - - test.pass_test() # Local Variables: diff --git a/test/YACC/shared-fixture/.exclude_tests b/test/YACC/shared-fixture/.exclude_tests deleted file mode 100644 index f12c4d0..0000000 --- a/test/YACC/shared-fixture/.exclude_tests +++ /dev/null @@ -1 +0,0 @@ -myyacc.py diff --git a/test/YACC/shared-fixture/aaa.y b/test/YACC/shared-fixture/aaa.y deleted file mode 100644 index f7f4cc7..0000000 --- a/test/YACC/shared-fixture/aaa.y +++ /dev/null @@ -1,2 +0,0 @@ -aaa.y -/*yacc*/ diff --git a/test/YACC/shared-fixture/bbb.yacc b/test/YACC/shared-fixture/bbb.yacc deleted file mode 100644 index b3c856f..0000000 --- a/test/YACC/shared-fixture/bbb.yacc +++ /dev/null @@ -1,2 +0,0 @@ -bbb.yacc -/*yacc*/ diff --git a/test/ZIP/ZIPCOM-fixture/.exclude_tests b/test/ZIP/ZIPCOM-fixture/.exclude_tests deleted file mode 100644 index dae6f60..0000000 --- a/test/ZIP/ZIPCOM-fixture/.exclude_tests +++ /dev/null @@ -1 +0,0 @@ -myzip.py diff --git a/test/ZIP/ZIPCOM-fixture/myzip.py b/test/ZIP/ZIPCOM-fixture/myzip.py deleted file mode 100644 index adbc6ac..0000000 --- a/test/ZIP/ZIPCOM-fixture/myzip.py +++ /dev/null @@ -1,6 +0,0 @@ -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 deleted file mode 100644 index 0546626..0000000 --- a/test/ZIP/ZIPCOM-fixture/test1.in +++ /dev/null @@ -1,2 +0,0 @@ -test1.in -/*zip*/ diff --git a/test/ZIP/ZIPCOM.py b/test/ZIP/ZIPCOM.py index 4d84ccf..c6c1412 100644 --- a/test/ZIP/ZIPCOM.py +++ b/test/ZIP/ZIPCOM.py @@ -34,14 +34,16 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() -test.dir_fixture('ZIPCOM-fixture') +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(TOOLS = ['zip'], - ZIPCOM = r'%(_python_)s myzip.py $TARGET $SOURCE') + ZIPCOM = r'%(_python_)s mycompile.py zip $TARGET $SOURCE') env.Zip('test1.zip', 'test1.in') """ % locals()) +test.write('test1.in', 'test1.in\n/*zip*/\n') + test.run() test.must_match('test1.zip', "test1.in\n") diff --git a/test/ZIP/ZIPCOMSTR-fixture/.exclude_tests b/test/ZIP/ZIPCOMSTR-fixture/.exclude_tests deleted file mode 100644 index dae6f60..0000000 --- a/test/ZIP/ZIPCOMSTR-fixture/.exclude_tests +++ /dev/null @@ -1 +0,0 @@ -myzip.py diff --git a/test/ZIP/ZIPCOMSTR-fixture/aaa.in b/test/ZIP/ZIPCOMSTR-fixture/aaa.in deleted file mode 100644 index 8474a29..0000000 --- a/test/ZIP/ZIPCOMSTR-fixture/aaa.in +++ /dev/null @@ -1,2 +0,0 @@ -aaa.in -/*zip*/ diff --git a/test/ZIP/ZIPCOMSTR-fixture/myzip.py b/test/ZIP/ZIPCOMSTR-fixture/myzip.py deleted file mode 100644 index f0fcc51..0000000 --- a/test/ZIP/ZIPCOMSTR-fixture/myzip.py +++ /dev/null @@ -1,7 +0,0 @@ -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 a26ed49..af9ba57 100644 --- a/test/ZIP/ZIPCOMSTR.py +++ b/test/ZIP/ZIPCOMSTR.py @@ -35,15 +35,17 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() -test.dir_fixture('ZIPCOMSTR-fixture') +test.file_fixture('mycompile.py') test.write('SConstruct', """ env = Environment(tools=['zip'], - ZIPCOM = r'%(_python_)s myzip.py $TARGET $SOURCES', + ZIPCOM = r'%(_python_)s mycompile.py zip $TARGET $SOURCES', ZIPCOMSTR = 'Zipping $TARGET from $SOURCE') 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 """)) diff --git a/test/fixture/mycompile.py b/test/fixture/mycompile.py new file mode 100644 index 0000000..555c2c8 --- /dev/null +++ b/test/fixture/mycompile.py @@ -0,0 +1,8 @@ +import sys +line = ('/*' + sys.argv[1] + '*/\n').encode() +outfile = open(sys.argv[2], 'wb') +for f in sys.argv[3:]: + infile = open(f, 'rb') + for l in [l for l in infile.readlines() if l != line]: + outfile.write(l) +sys.exit(0) diff --git a/test/fixture/myrewrite.py b/test/fixture/myrewrite.py new file mode 100644 index 0000000..40bf830 --- /dev/null +++ b/test/fixture/myrewrite.py @@ -0,0 +1,7 @@ +import sys +line = ('/*' + sys.argv[1] + '*/\n').encode() +lines = open(sys.argv[2], 'rb').readlines() +outfile = open(sys.argv[2], 'wb') +for l in [l for l in lines if l != line]: + outfile.write(l) +sys.exit(0) -- cgit v0.12 From 30135c2aa0b8a5e58ca8d3177a36b8c3678de3d5 Mon Sep 17 00:00:00 2001 From: mbyt Date: Wed, 19 Oct 2016 19:50:35 +0200 Subject: python3 compatibility. Exceptions might have more arguments. Especially the UnicodeDecodeError takes 5 arguments. Without this change, are TypeError: function takes exactly 5 arguments is raised at this position. --- src/engine/SCons/Taskmaster.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/Taskmaster.py b/src/engine/SCons/Taskmaster.py index 461a556..a620ba1 100644 --- a/src/engine/SCons/Taskmaster.py +++ b/src/engine/SCons/Taskmaster.py @@ -545,7 +545,7 @@ class Task(object): if sys.version_info[0] == 2: exec("raise exc_type, exc_value, exc_traceback") else: # sys.version_info[0] == 3: - exec("raise exc_type(exc_value).with_traceback(exc_traceback)") + exec("raise exc_type(*exc_value.args).with_traceback(exc_traceback)") # raise e.__class__, e.__class__(e), sys.exc_info()[2] -- cgit v0.12 From b8661de3379a931485fd73d6f2242edc93cc032d Mon Sep 17 00:00:00 2001 From: mbyt Date: Wed, 19 Oct 2016 20:14:18 +0200 Subject: the file builtin does not exist in python3 --- src/engine/SCons/Platform/win32.py | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/engine/SCons/Platform/win32.py b/src/engine/SCons/Platform/win32.py index 269007d..cb82df3 100644 --- a/src/engine/SCons/Platform/win32.py +++ b/src/engine/SCons/Platform/win32.py @@ -60,16 +60,8 @@ except AttributeError: else: parallel_msg = None - _builtin_file = file _builtin_open = open - class _scons_file(_builtin_file): - def __init__(self, *args, **kw): - _builtin_file.__init__(self, *args, **kw) - win32api.SetHandleInformation(msvcrt.get_osfhandle(self.fileno()), - win32con.HANDLE_FLAG_INHERIT, 0) - - def _scons_open(*args, **kw): fp = _builtin_open(*args, **kw) win32api.SetHandleInformation(msvcrt.get_osfhandle(fp.fileno()), @@ -77,9 +69,29 @@ else: 0) return fp - file = _scons_file open = _scons_open + if sys.version_info.major == 2: + _builtin_file = file + class _scons_file(_builtin_file): + def __init__(self, *args, **kw): + _builtin_file.__init__(self, *args, **kw) + win32api.SetHandleInformation(msvcrt.get_osfhandle(self.fileno()), + win32con.HANDLE_FLAG_INHERIT, 0) + file = _scons_file + else: + import io + for io_class in ['BufferedReader', 'BufferedWriter', 'BufferedRWPair', + 'BufferedRandom', 'TextIOWrapper']: + _builtin_file = getattr(io, io_class) + class _scons_file(_builtin_file): + def __init__(self, *args, **kw): + _builtin_file.__init__(self, *args, **kw) + win32api.SetHandleInformation(msvcrt.get_osfhandle(self.fileno()), + win32con.HANDLE_FLAG_INHERIT, 0) + setattr(io, io_class, _builtin_file) + + try: import threading spawn_lock = threading.Lock() -- cgit v0.12 From 3031330216256cbff09b5631fdf68fa75d2439f2 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 24 Oct 2016 23:08:59 -0400 Subject: Fix some minor formatting issues flagged by pycharms --- src/engine/SCons/Platform/__init__.py | 1 + src/engine/SCons/Platform/win32.py | 23 ++++++++++++++++------- src/engine/SCons/Tool/__init__.py | 10 +++++----- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/engine/SCons/Platform/__init__.py b/src/engine/SCons/Platform/__init__.py index 7f4639f..ebdbb4c 100644 --- a/src/engine/SCons/Platform/__init__.py +++ b/src/engine/SCons/Platform/__init__.py @@ -56,6 +56,7 @@ import SCons.Errors import SCons.Subst import SCons.Tool + def platform_default(): """Return the platform string for our execution environment. diff --git a/src/engine/SCons/Platform/win32.py b/src/engine/SCons/Platform/win32.py index 269007d..cdbb824 100644 --- a/src/engine/SCons/Platform/win32.py +++ b/src/engine/SCons/Platform/win32.py @@ -117,6 +117,7 @@ except ImportError: # you had better have cmd or command.com in your PATH when you run # scons. + def piped_spawn(sh, escape, cmd, args, env, stdout, stderr): # There is no direct way to do that in python. What we do # here should work for most cases: @@ -137,8 +138,7 @@ def piped_spawn(sh, escape, cmd, args, env, stdout, stderr): stderrRedirected = 0 for arg in args: # are there more possibilities to redirect stdout ? - if (arg.find( ">", 0, 1 ) != -1 or - arg.find( "1>", 0, 2 ) != -1): + if arg.find( ">", 0, 1 ) != -1 or arg.find( "1>", 0, 2 ) != -1: stdoutRedirected = 1 # are there more possibilities to redirect stderr ? if arg.find( "2>", 0, 2 ) != -1: @@ -179,6 +179,7 @@ def piped_spawn(sh, escape, cmd, args, env, stdout, stderr): pass return ret + def exec_spawn(l, env): try: result = spawnve(os.P_WAIT, l[0], l, env) @@ -198,6 +199,7 @@ def exec_spawn(l, env): sys.stderr.write("scons: unknown OSError exception code %d - '%s': %s\n" % (e[0], command, e[1])) return result + def spawn(sh, escape, cmd, args, env): if not sh: sys.stderr.write("scons: Could not find command interpreter, is it in your PATH?\n") @@ -217,6 +219,7 @@ def escape(x): # Get the windows system directory name _system_root = None + def get_system_root(): global _system_root if _system_root is not None: @@ -244,8 +247,14 @@ def get_system_root(): _system_root = val return val -# Get the location of the program files directory + def get_program_files_dir(): + """ + Get the location of the program files directory + Returns + ------- + + """ # Now see if we can look in the registry... val = '' if SCons.Util.can_read_reg: @@ -266,10 +275,9 @@ def get_program_files_dir(): return val - -# Determine which windows CPU were running on. class ArchDefinition(object): """ + Determine which windows CPU were running on. A class for defining architecture-specific settings and logic. """ def __init__(self, arch, synonyms=[]): @@ -299,6 +307,7 @@ for a in SupportedArchitectureList: for s in a.synonyms: SupportedArchitectureMap[s] = a + def get_architecture(arch=None): """Returns the definition for the specified architecture string. @@ -312,6 +321,7 @@ def get_architecture(arch=None): arch = os.environ.get('PROCESSOR_ARCHITECTURE') return SupportedArchitectureMap.get(arch, ArchDefinition('', [''])) + def generate(env): # Attempt to find cmd.exe (for WinNT/2k/XP) or # command.com for Win9x @@ -357,7 +367,6 @@ def generate(env): if not cmd_interp: cmd_interp = env.Detect('command') - if 'ENV' not in env: env['ENV'] = {} @@ -369,7 +378,7 @@ def generate(env): # for SystemDrive because it's related. # # Weigh the impact carefully before adding other variables to this list. - import_env = [ 'SystemDrive', 'SystemRoot', 'TEMP', 'TMP' ] + import_env = ['SystemDrive', 'SystemRoot', 'TEMP', 'TMP' ] for var in import_env: v = os.environ.get(var) if v: diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index 45d0aa1..cc5a508 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -925,9 +925,9 @@ class ToolInitializerMethod(object): def get_builder(self, env): """ - Returns the appropriate real Builder for this method name - after having the associated ToolInitializer object apply - the appropriate Tool module. + Returns the appropriate real Builder for this method name + after having the associated ToolInitializer object apply + the appropriate Tool module. """ builder = getattr(env, self.__name__) @@ -989,8 +989,8 @@ class ToolInitializer(object): def apply_tools(self, env): """ - Searches the list of associated Tool modules for one that - exists, and applies that to the construction environment. + Searches the list of associated Tool modules for one that + exists, and applies that to the construction environment. """ for t in self.tools: tool = SCons.Tool.Tool(t) -- cgit v0.12 From 9d637bc1d28420698f4a9345b7579d09cc8c311f Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 3 Nov 2016 16:25:46 -0400 Subject: manually merge packaging updates from 2.5.1 --- SConstruct | 8 +++++--- src/script/MANIFEST.in | 1 + src/setup.py | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/SConstruct b/SConstruct index c5734af..0cdf780 100644 --- a/SConstruct +++ b/SConstruct @@ -8,7 +8,7 @@ from __future__ import print_function copyright_years = '2001 - 2016' # This gets inserted into the man pages to reflect the month of release. -month_year = 'April 2016' +month_year = 'November 2016' # # __COPYRIGHT__ @@ -45,7 +45,7 @@ import tempfile import bootstrap project = 'scons' -default_version = '2.5.0' +default_version = '2.5.1' copyright = "Copyright (c) %s The SCons Foundation" % copyright_years platform = distutils.util.get_platform() @@ -646,6 +646,7 @@ scons_script = { 'scons' : 'scons.py', 'sconsign' : 'sconsign.py', 'scons-time' : 'scons-time.py', + 'scons-configure-cache' : 'scons-configure-cache.py', }, 'buildermap' : {}, @@ -654,6 +655,7 @@ scons_script = { 'scons-' + version, 'sconsign-' + version, 'scons-time-' + version, + 'scons-configure-cache-' + version, ], 'explicit_deps' : { @@ -710,7 +712,7 @@ scons = { }, } -scripts = ['scons', 'sconsign', 'scons-time'] +scripts = ['scons', 'sconsign', 'scons-time', 'scons-configure-cache'] src_deps = [] src_files = [] diff --git a/src/script/MANIFEST.in b/src/script/MANIFEST.in index f324ed4..d10cc82 100644 --- a/src/script/MANIFEST.in +++ b/src/script/MANIFEST.in @@ -1,3 +1,4 @@ scons sconsign scons-time +scons-configure-cache diff --git a/src/setup.py b/src/setup.py index 9a02b25..41fc35a 100644 --- a/src/setup.py +++ b/src/setup.py @@ -388,6 +388,7 @@ scripts = [ 'script/scons', 'script/sconsign', 'script/scons-time', + 'script/scons-configure-cache', # We include scons.bat in the list of scripts, even on UNIX systems, # because we provide an option to allow it be installed explicitly, -- cgit v0.12 From 57dadfa86386231767d10c886e2ab42997107ba0 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 3 Nov 2016 16:26:45 -0400 Subject: return file to devel mode --- ReleaseConfig | 2 +- src/CHANGES.txt | 7 +++++++ src/RELEASE.txt | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ReleaseConfig b/ReleaseConfig index 7a68f89..517b5db 100644 --- a/ReleaseConfig +++ b/ReleaseConfig @@ -32,7 +32,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" # 'final', the patchlevel is set to the release date. This value is # mandatory and must be present in this file. #version_tuple = (2, 2, 0, 'final', 0) -version_tuple = (2, 6, 0, 'alpha', 0) +version_tuple = (2, 7, 0, 'alpha', 0) # Python versions prior to unsupported_python_version cause a fatal error # when that version is used. Python versions prior to deprecate_python_version diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 4ae9cb2..385f49c 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -6,6 +6,13 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER + From John Doe: + + - Whatever John Doe did. + + +RELEASE VERSION/DATE TO BE FILLED IN LATER + From Daniel Holth: - Add basic support for PyPy (by deleting __slots__ from Node with a metaclass on PyPy); wrap most-used open() calls in 'with' statements to diff --git a/src/RELEASE.txt b/src/RELEASE.txt index ac2b95a..d71619d 100644 --- a/src/RELEASE.txt +++ b/src/RELEASE.txt @@ -1,4 +1,4 @@ - A new SCons checkpoint release, 2.6.0.alpha.yyyymmdd, is now available + A new SCons checkpoint release, 2.7.0.alpha.yyyymmdd, is now available on the SCons download page: http://www.scons.org/download.php -- cgit v0.12 From 9b969faf4a291d0620822f846d2e45a32367bead Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 5 Nov 2016 13:16:06 -0400 Subject: add 2.5.1 change info --- src/CHANGES.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 385f49c..a6f0f66 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -52,6 +52,14 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Updated Fortran-related tests to pass under GCC 5/6. - Fixed SCons.Tool.Packaging.rpm.package source nondeterminism across builds. +RELEASE 2.5.1 - Mon, 03 Nov 2016 13:37:42 -0400 + + From William Deegan: + - Add scons-configure-cache.py to packaging. It was omitted + + From Alexey Klimkin: + - Use memoization to optimize PATH evaluation across all dependencies per + node. (PR #345) RELEASE 2.5.0 - Mon, 09 Apr 2016 11:27:42 -0700 -- cgit v0.12 From b527c93ebbb5b3e83b2f0882cf62d6072d8b4cb5 Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Fri, 11 Nov 2016 01:19:20 -0500 Subject: The percent signs are causing syntax error on windows, switched to more compatible code --- test/MSVS/vs-10.0Exp-exec.py | 3 ++- test/MSVS/vs-11.0-exec.py | 3 ++- test/MSVS/vs-11.0Exp-exec.py | 3 ++- test/MSVS/vs-14.0-exec.py | 3 ++- test/MSVS/vs-14.0Exp-exec.py | 3 ++- test/MSVS/vs-6.0-exec.py | 3 ++- test/MSVS/vs-7.0-exec.py | 3 ++- test/MSVS/vs-7.1-exec.py | 3 ++- test/MSVS/vs-8.0Exp-exec.py | 3 ++- test/MSVS/vs-9.0-exec.py | 3 ++- test/MSVS/vs-9.0Exp-exec.py | 3 ++- 11 files changed, 22 insertions(+), 11 deletions(-) diff --git a/test/MSVS/vs-10.0Exp-exec.py b/test/MSVS/vs-10.0Exp-exec.py index 39c96ac..a63f6c4 100644 --- a/test/MSVS/vs-10.0Exp-exec.py +++ b/test/MSVS/vs-10.0Exp-exec.py @@ -55,7 +55,8 @@ if not msvs_version in test.msvs_versions(): test.run(arguments = '-n -q -Q -f -', stdin = """\ env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s') -print "os.environ.update(%%s)" %% repr(env['ENV']) +sconsEnv = repr(env['ENV']) +print("os.environ.update(" + sconsEnv + ")") """ % locals()) exec(test.stdout()) diff --git a/test/MSVS/vs-11.0-exec.py b/test/MSVS/vs-11.0-exec.py index 7acf9d5..21645f5 100644 --- a/test/MSVS/vs-11.0-exec.py +++ b/test/MSVS/vs-11.0-exec.py @@ -55,7 +55,8 @@ if not msvs_version in test.msvs_versions(): test.run(arguments = '-n -q -Q -f -', stdin = """\ env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s') -print "os.environ.update(%%s)" %% repr(env['ENV']) +sconsEnv = repr(env['ENV']) +print("os.environ.update(" + sconsEnv + ")") """ % locals()) exec(test.stdout()) diff --git a/test/MSVS/vs-11.0Exp-exec.py b/test/MSVS/vs-11.0Exp-exec.py index 7cfc85d..be48971 100644 --- a/test/MSVS/vs-11.0Exp-exec.py +++ b/test/MSVS/vs-11.0Exp-exec.py @@ -55,7 +55,8 @@ if not msvs_version in test.msvs_versions(): test.run(arguments = '-n -q -Q -f -', stdin = """\ env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s') -print "os.environ.update(%%s)" %% repr(env['ENV']) +sconsEnv = repr(env['ENV']) +print("os.environ.update(" + sconsEnv + ")") """ % locals()) exec(test.stdout()) diff --git a/test/MSVS/vs-14.0-exec.py b/test/MSVS/vs-14.0-exec.py index b96bdab..911c4ac 100644 --- a/test/MSVS/vs-14.0-exec.py +++ b/test/MSVS/vs-14.0-exec.py @@ -55,7 +55,8 @@ if not msvs_version in test.msvs_versions(): test.run(arguments = '-n -q -Q -f -', stdin = """\ env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s') -print "os.environ.update(%%s)" %% repr(env['ENV']) +sconsEnv = repr(env['ENV']) +print("os.environ.update(" + sconsEnv + ")") """ % locals()) exec(test.stdout()) diff --git a/test/MSVS/vs-14.0Exp-exec.py b/test/MSVS/vs-14.0Exp-exec.py index 44ebece..cb4aaf3 100644 --- a/test/MSVS/vs-14.0Exp-exec.py +++ b/test/MSVS/vs-14.0Exp-exec.py @@ -55,7 +55,8 @@ if not msvs_version in test.msvs_versions(): test.run(arguments = '-n -q -Q -f -', stdin = """\ env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s') -print "os.environ.update(%%s)" %% repr(env['ENV']) +sconsEnv = repr(env['ENV']) +print("os.environ.update(" + sconsEnv + ")") """ % locals()) exec(test.stdout()) diff --git a/test/MSVS/vs-6.0-exec.py b/test/MSVS/vs-6.0-exec.py index fe08a77..d017790 100644 --- a/test/MSVS/vs-6.0-exec.py +++ b/test/MSVS/vs-6.0-exec.py @@ -54,7 +54,8 @@ if not msvs_version in test.msvs_versions(): test.run(arguments = '-n -q -Q -f -', stdin = """\ env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s') -print "os.environ.update(%%s)" %% repr(env['ENV']) +sconsEnv = repr(env['ENV']) +print("os.environ.update(" + sconsEnv + ")") """ % locals()) exec(test.stdout()) diff --git a/test/MSVS/vs-7.0-exec.py b/test/MSVS/vs-7.0-exec.py index cc141f3..e62ee77 100644 --- a/test/MSVS/vs-7.0-exec.py +++ b/test/MSVS/vs-7.0-exec.py @@ -54,7 +54,8 @@ if not msvs_version in test.msvs_versions(): test.run(arguments = '-n -q -Q -f -', stdin = """\ env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s') -print "os.environ.update(%%s)" %% repr(env['ENV']) +sconsEnv = repr(env['ENV']) +print("os.environ.update(" + sconsEnv + ")") """ % locals()) exec(test.stdout()) diff --git a/test/MSVS/vs-7.1-exec.py b/test/MSVS/vs-7.1-exec.py index f44af80..42f6ae8 100644 --- a/test/MSVS/vs-7.1-exec.py +++ b/test/MSVS/vs-7.1-exec.py @@ -54,7 +54,8 @@ if not msvs_version in test.msvs_versions(): test.run(arguments = '-n -q -Q -f -', stdin = """\ env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s') -print "os.environ.update(%%s)" %% repr(env['ENV']) +sconsEnv = repr(env['ENV']) +print("os.environ.update(" + sconsEnv + ")") """ % locals()) exec(test.stdout()) diff --git a/test/MSVS/vs-8.0Exp-exec.py b/test/MSVS/vs-8.0Exp-exec.py index 5132d6d..66196f1 100644 --- a/test/MSVS/vs-8.0Exp-exec.py +++ b/test/MSVS/vs-8.0Exp-exec.py @@ -55,7 +55,8 @@ if not msvs_version in test.msvs_versions(): test.run(arguments = '-n -q -Q -f -', stdin = """\ env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s') -print "os.environ.update(%%s)" %% repr(env['ENV']) +sconsEnv = repr(env['ENV']) +print("os.environ.update(" + sconsEnv + ")") """ % locals()) exec(test.stdout()) diff --git a/test/MSVS/vs-9.0-exec.py b/test/MSVS/vs-9.0-exec.py index ebd08c0..7b544aa 100644 --- a/test/MSVS/vs-9.0-exec.py +++ b/test/MSVS/vs-9.0-exec.py @@ -55,7 +55,8 @@ if not msvs_version in test.msvs_versions(): test.run(arguments = '-n -q -Q -f -', stdin = """\ env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s') -print "os.environ.update(%%s)" %% repr(env['ENV']) +sconsEnv = repr(env['ENV']) +print("os.environ.update(" + sconsEnv + ")") """ % locals()) exec(test.stdout()) diff --git a/test/MSVS/vs-9.0Exp-exec.py b/test/MSVS/vs-9.0Exp-exec.py index c4a562a..caa763e 100644 --- a/test/MSVS/vs-9.0Exp-exec.py +++ b/test/MSVS/vs-9.0Exp-exec.py @@ -55,7 +55,8 @@ if not msvs_version in test.msvs_versions(): test.run(arguments = '-n -q -Q -f -', stdin = """\ env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s') -print "os.environ.update(%%s)" %% repr(env['ENV']) +sconsEnv = repr(env['ENV']) +print("os.environ.update(" + sconsEnv + ")") """ % locals()) exec(test.stdout()) -- cgit v0.12 From 7b6b5aabd09fc6100d56544f2c5b99b57e0c41e7 Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Fri, 11 Nov 2016 01:24:48 -0500 Subject: Wrote tests to make sure the xml is valid for visual studio project files generated by scons This can occur when the user puts invalid characters that don't get converted to xml ampersands escapes --- QMTest/TestSConsMSVS.py | 14 ++++++++++++++ test/MSVS/vs-14.0-exec.py | 6 +++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/QMTest/TestSConsMSVS.py b/QMTest/TestSConsMSVS.py index 39dbb5e..fcca470 100644 --- a/QMTest/TestSConsMSVS.py +++ b/QMTest/TestSConsMSVS.py @@ -20,6 +20,8 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os import sys import platform +import traceback +from xml.etree import ElementTree from TestSCons import * from TestSCons import __all__ @@ -1156,6 +1158,18 @@ print("self._msvs_versions =", str(SCons.Tool.MSCommon.query_versions())) return host + def validate_msvs_file(self, file): + try: + x = ElementTree.parse(file) + except: + print("--------------------------------------------------------------") + print("--------------------------------------------------------------") + print(traceback.format_exc()) + print("Failed to validate xml in MSVS file: ") + print(file) + print("--------------------------------------------------------------") + print("--------------------------------------------------------------") + self.fail_test() # Local Variables: # tab-width:4 # indent-tabs-mode:nil diff --git a/test/MSVS/vs-14.0-exec.py b/test/MSVS/vs-14.0-exec.py index 911c4ac..f2a826c 100644 --- a/test/MSVS/vs-14.0-exec.py +++ b/test/MSVS/vs-14.0-exec.py @@ -71,8 +71,8 @@ env=Environment(MSVS_VERSION = '%(msvs_version)s') env.MSVSProject(target = 'foo.vcxproj', srcs = ['foo.c'], buildtarget = 'foo.exe', - variant = 'Release') - + variant = 'Release', + DebugSettings = {'LocalDebuggerCommandArguments':'echo "" > output.txt'}) env.Program('foo.c') """ % locals()) @@ -98,7 +98,7 @@ test.run(chdir='sub dir', arguments=['foo.sln', '/build', 'Release']) test.run(program=test.workpath('sub dir', 'foo'), stdout="foo.c\n") - +test.validate_msvs_file(test.workpath('sub dir', 'foo.vcxproj.user')) test.pass_test() -- cgit v0.12 From ee1e65643f7d01fade819726280518b2fb72c08e Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Fri, 11 Nov 2016 01:26:55 -0500 Subject: fix for invalid xml getting generated to SCons generated visual studio projects made test for this in commit ebf8e9ebf3ac --- src/engine/SCons/Tool/msvs.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py index 50f6b27..939668e 100644 --- a/src/engine/SCons/Tool/msvs.py +++ b/src/engine/SCons/Tool/msvs.py @@ -65,6 +65,8 @@ def xmlify(s): s = s.replace("&", "&") # do this first s = s.replace("'", "'") s = s.replace('"', """) + s = s.replace('<', "<") + s = s.replace('>', ">") s = s.replace('\n', ' ') return s -- cgit v0.12 From cd856daadb0700fff703171f48b74dce60dc4279 Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Fri, 11 Nov 2016 01:33:13 -0500 Subject: add changes to CHANGES.txt --- src/CHANGES.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index a6f0f66..8d7aa28 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -13,6 +13,10 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER RELEASE VERSION/DATE TO BE FILLED IN LATER + From Daniel Moody: + - Fixed msvs.py for Visual Studio generated projects which were + creating invalid xml for greater than and less than symbols. + From Daniel Holth: - Add basic support for PyPy (by deleting __slots__ from Node with a metaclass on PyPy); wrap most-used open() calls in 'with' statements to -- cgit v0.12 From 06f27e5d358ec5fd7045b98be25aef04031c587e Mon Sep 17 00:00:00 2001 From: Rick Lupton Date: Wed, 23 Nov 2016 21:53:03 +0000 Subject: Find dependencies using LaTeX "import" package commands The import package adds new commands for including files, similar to \input and \include, but with better handling of subdirectories. These changes extend the LaTeX Scanner to look for these commands. --- src/engine/SCons/Scanner/LaTeX.py | 98 +++++++++++------ src/engine/SCons/Scanner/LaTeXTests.py | 15 ++- test/TEX/recursive_scanner_dependencies_import.py | 122 ++++++++++++++++++++++ test/TEX/recursive_scanner_dependencies_input.py | 112 ++++++++++++++++++++ 4 files changed, 316 insertions(+), 31 deletions(-) create mode 100644 test/TEX/recursive_scanner_dependencies_import.py create mode 100644 test/TEX/recursive_scanner_dependencies_input.py diff --git a/src/engine/SCons/Scanner/LaTeX.py b/src/engine/SCons/Scanner/LaTeX.py index 2cb1ed5..0c54bf3 100644 --- a/src/engine/SCons/Scanner/LaTeX.py +++ b/src/engine/SCons/Scanner/LaTeX.py @@ -166,6 +166,9 @@ class LaTeX(SCons.Scanner.Base): 'usepackage': 'TEXINPUTS', 'lstinputlisting': 'TEXINPUTS'} env_variables = SCons.Util.unique(list(keyword_paths.values())) + two_arg_commands = ['import', 'subimport', + 'includefrom', 'subincludefrom', + 'inputfrom', 'subinputfrom'] def __init__(self, name, suffixes, graphics_extensions, *args, **kw): @@ -175,8 +178,29 @@ class LaTeX(SCons.Scanner.Base): # line followed by one or more newline characters (i.e. blank # lines), interfering with a match on the next line. # add option for whitespace before the '[options]' or the '{filename}' - regex = r'^[^%\n]*\\(include|includegraphics(?:\s*\[[^\]]+\])?|lstinputlisting(?:\[[^\]]+\])?|input|bibliography|addbibresource|addglobalbib|addsectionbib|usepackage)\s*{([^}]*)}' - self.cre = re.compile(regex, re.M) + regex = r''' + ^[^%\n]* + \\( + include + | includegraphics(?:\s*\[[^\]]+\])? + | lstinputlisting(?:\[[^\]]+\])? + | input + | import + | subimport + | includefrom + | subincludefrom + | inputfrom + | subinputfrom + | bibliography + | addbibresource + | addglobalbib + | addsectionbib + | usepackage + ) + \s*{([^}]*)} # first arg + (?: \s*{([^}]*)} )? # maybe another arg + ''' + self.cre = re.compile(regex, re.M | re.X) self.comment_re = re.compile(r'^((?:(?:\\%)|[^%\n])*)(.*)$', re.M) self.graphics_extensions = graphics_extensions @@ -236,23 +260,26 @@ class LaTeX(SCons.Scanner.Base): SCons.Scanner.Base.__init__(self, *args, **kw) - def _latex_names(self, include): - filename = include[1] - if include[0] == 'input': + def _latex_names(self, include_type, filename): + if include_type == 'input': base, ext = os.path.splitext( filename ) if ext == "": return [filename + '.tex'] - if (include[0] == 'include'): - return [filename + '.tex'] - if include[0] == 'bibliography': + if include_type in ('include', 'import', 'subimport', + 'includefrom', 'subincludefrom', + 'inputfrom', 'subinputfrom'): + base, ext = os.path.splitext( filename ) + if ext == "": + return [filename + '.tex'] + if include_type == 'bibliography': base, ext = os.path.splitext( filename ) if ext == "": return [filename + '.bib'] - if include[0] == 'usepackage': + if include_type == 'usepackage': base, ext = os.path.splitext( filename ) if ext == "": return [filename + '.sty'] - if include[0] == 'includegraphics': + if include_type == 'includegraphics': base, ext = os.path.splitext( filename ) if ext == "": #return [filename+e for e in self.graphics_extensions + TexGraphics] @@ -267,21 +294,26 @@ class LaTeX(SCons.Scanner.Base): return SCons.Node.FS._my_normcase(str(include)) def find_include(self, include, source_dir, path): + inc_type, inc_subdir, inc_filename = include try: - sub_path = path[include[0]] + sub_paths = path[inc_type] except (IndexError, KeyError): - sub_path = () - try_names = self._latex_names(include) + sub_paths = ((), ()) + try_names = self._latex_names(inc_type, inc_filename) + + # There are three search paths to try: + # 1. current directory "source_dir" + # 2. env[var] + # 3. env['ENV'][var] + search_paths = [(source_dir,)] + list(sub_paths) + for n in try_names: - # see if we find it using the path in env[var] - i = SCons.Node.FS.find_file(n, (source_dir,) + sub_path[0]) - if i: - return i, include - # see if we find it using the path in env['ENV'][var] - i = SCons.Node.FS.find_file(n, (source_dir,) + sub_path[1]) - if i: - return i, include - return i, include + for search_path in search_paths: + paths = tuple([d.Dir(inc_subdir) for d in search_path]) + i = SCons.Node.FS.find_file(n, paths) + if i: + return i, include + return None, include def canonical_text(self, text): """Standardize an input TeX-file contents. @@ -300,7 +332,7 @@ class LaTeX(SCons.Scanner.Base): line_continues_a_comment = len(comment) > 0 return '\n'.join(out).rstrip()+'\n' - def scan(self, node): + def scan(self, node, subdir='.'): # Modify the default scan function to allow for the regular # expression to return a comma separated list of file names # as can be the case with the bibliography keyword. @@ -326,9 +358,14 @@ class LaTeX(SCons.Scanner.Base): split_includes = [] for include in includes: inc_type = noopt_cre.sub('', include[0]) - inc_list = include[1].split(',') + inc_subdir = subdir + if inc_type in self.two_arg_commands: + inc_subdir = os.path.join(subdir, include[1]) + inc_list = include[2].split(',') + else: + inc_list = include[1].split(',') for j in range(len(inc_list)): - split_includes.append( (inc_type, inc_list[j]) ) + split_includes.append( (inc_type, inc_subdir, inc_list[j]) ) # includes = split_includes node.includes = includes @@ -359,11 +396,12 @@ class LaTeX(SCons.Scanner.Base): while queue: include = queue.pop() + inc_type, inc_subdir, inc_filename = include try: - if seen[include[1]] == 1: + if seen[inc_filename] == 1: continue except KeyError: - seen[include[1]] = 1 + seen[inc_filename] = 1 # # Handle multiple filenames in include[1] @@ -372,14 +410,14 @@ class LaTeX(SCons.Scanner.Base): if n is None: # Do not bother with 'usepackage' warnings, as they most # likely refer to system-level files - if include[0] != 'usepackage': + if inc_type != 'usepackage': SCons.Warnings.warn(SCons.Warnings.DependencyWarning, "No dependency generated for file: %s (included from: %s) -- file not found" % (i, node)) else: sortkey = self.sort_key(n) nodes.append((sortkey, n)) - # recurse down - queue.extend( self.scan(n) ) + # recurse down + queue.extend( self.scan(n, inc_subdir) ) return [pair[1] for pair in sorted(nodes)] diff --git a/src/engine/SCons/Scanner/LaTeXTests.py b/src/engine/SCons/Scanner/LaTeXTests.py index 49553cf..213e89e 100644 --- a/src/engine/SCons/Scanner/LaTeXTests.py +++ b/src/engine/SCons/Scanner/LaTeXTests.py @@ -44,6 +44,12 @@ test.write('test1.latex',""" include{incNO} %\include{incNO} xyzzy \include{inc6} +\subimport{subdir}{inc3} +\import{subdir}{inc3a} +\includefrom{subdir}{inc3b} +\subincludefrom{subdir}{inc3c} +\inputfrom{subdir}{inc3d} +\subinputfrom{subdir}{inc3e} """) test.write('test2.latex',""" @@ -61,6 +67,10 @@ test.subdir('subdir') test.write('inc1.tex',"\n") test.write('inc2.tex',"\n") test.write(['subdir', 'inc3.tex'], "\n") +for suffix in 'abcde': + test.write(['subdir', 'inc3%s.tex' % suffix], "\n") +test.write(['subdir', 'inc3b.tex'], "\n") +test.write(['subdir', 'inc3c.tex'], "\n") test.write(['subdir', 'inc4.eps'], "\n") test.write('inc5.xyz', "\n") test.write('inc6.tex', "\n") @@ -122,7 +132,10 @@ class LaTeXScannerTestCase1(unittest.TestCase): s = SCons.Scanner.LaTeX.LaTeXScanner() path = s.path(env) deps = s(env.File('test1.latex'), env, path) - headers = ['inc1.tex', 'inc2.tex', 'inc6.tex'] + headers = ['inc1.tex', 'inc2.tex', 'inc6.tex', + 'subdir/inc3.tex', 'subdir/inc3a.tex', + 'subdir/inc3b.tex', 'subdir/inc3c.tex', + 'subdir/inc3d.tex', 'subdir/inc3e.tex'] deps_match(self, deps, headers) class LaTeXScannerTestCase2(unittest.TestCase): diff --git a/test/TEX/recursive_scanner_dependencies_import.py b/test/TEX/recursive_scanner_dependencies_import.py new file mode 100644 index 0000000..d9d2625 --- /dev/null +++ b/test/TEX/recursive_scanner_dependencies_import.py @@ -0,0 +1,122 @@ +#!/usr/bin/env python +# +# __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__" + +"""Verify that we re-run LaTeX after changing a nested \import. This +checks that recursive implicit dependencies are found correctly. + +This is a separate test from the +recursive_scanner_dependencies_input.py test because \input and +\include are handled specially by the PDF builder, whereas \import +dependencies are found only by the scanner. + +""" + +import TestSCons + +test = TestSCons.TestSCons() + +pdflatex = test.where_is('pdflatex') + +if not pdflatex: + test.skip_test("Could not find pdflatex; skipping test(s).\n") + +test.subdir('subdir') +test.subdir('subdir/subdir2') + +test.write(['SConstruct'], """\ +env = Environment(tools=['pdftex', 'tex']) +env.PDF('master.tex') +""") + +test.write(['master.tex'], r""" +\documentclass{article} +\usepackage{import} +\begin{document} +\subinputfrom{subdir/}{sub1} +\end{document} +""") + +test.write(['subdir', 'sub1.tex'], r""" +\subinputfrom{subdir2/}{sub2} +""") + +test.write(['subdir', 'subdir2', 'sub2.tex'], r""" +Sub-document 2 content +""") + +test.run() + +pdf_output_1 = test.read('master.pdf') + +# Change sub2.tex, see if master.pdf is changed +test.write(['subdir', 'subdir2', 'sub2.tex'], r""" +Sub-document 2 content -- updated +""") + +test.run() + +pdf_output_2 = test.read('master.pdf') + +# If the PDF file is the same as it was previously, then it didn't +# pick up the change in sub2.tex, so fail. +test.fail_test(pdf_output_1 == pdf_output_2) + +# Double-check: clean everything and rebuild from scratch, which +# should force the PDF file to be the 1982 version. + +test.run(arguments='-c') +test.run() + +pdf_output_3 = test.read('master.pdf') + +# If the PDF file is now different than the second run, modulo the +# creation timestamp and the ID and some other PDF garp, then something +# else odd has happened, so fail. + +pdf_output_2 = test.normalize_pdf(pdf_output_2) +pdf_output_3 = test.normalize_pdf(pdf_output_3) + +if pdf_output_2 != pdf_output_3: + import sys + test.write('master.normalized.2.pdf', pdf_output_2) + test.write('master.normalized.3.pdf', pdf_output_3) + sys.stdout.write("***** 2 and 3 are different!\n") + sys.stdout.write(test.diff_substr(pdf_output_2, pdf_output_3, 80, 80) + + '\n') + sys.stdout.write("Output from run 2:\n") + sys.stdout.write(test.stdout(-2) + '\n') + sys.stdout.write("Output from run 3:\n") + sys.stdout.write(test.stdout() + '\n') + sys.stdout.flush() + test.fail_test() + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/recursive_scanner_dependencies_input.py b/test/TEX/recursive_scanner_dependencies_input.py new file mode 100644 index 0000000..257051e --- /dev/null +++ b/test/TEX/recursive_scanner_dependencies_input.py @@ -0,0 +1,112 @@ +#!/usr/bin/env python +# +# __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__" + +"""Verify that we re-run LaTeX after changing a nested \input. This +checks that recursive implicit dependencies are found correctly. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +pdflatex = test.where_is('pdflatex') + +if not pdflatex: + test.skip_test("Could not find pdflatex; skipping test(s).\n") + +test.write(['SConstruct'], """\ +env = Environment(tools=['pdftex', 'tex']) +env.PDF('master.tex') +""") + +test.write(['master.tex'], r""" +\documentclass{article} +\begin{document} +\input{sub1} +\end{document} +""") + +test.write(['sub1.tex'], r""" +\input{sub2} +""") + +test.write(['sub2.tex'], r""" +Sub-document 2 content +""") + +test.run() + +pdf_output_1 = test.read('master.pdf') + +# Change sub2.tex, see if master.pdf is changed +test.write(['sub2.tex'], r""" +Sub-document 2 content -- updated +""") + +test.run() + +pdf_output_2 = test.read('master.pdf') + +# If the PDF file is the same as it was previously, then it didn't +# pick up the change in sub2.tex, so fail. +test.fail_test(pdf_output_1 == pdf_output_2) + +# Double-check: clean everything and rebuild from scratch, which +# should force the PDF file to be the 1982 version. + +test.run(arguments='-c') +test.run() + +pdf_output_3 = test.read('master.pdf') + +# If the PDF file is now different than the second run, modulo the +# creation timestamp and the ID and some other PDF garp, then something +# else odd has happened, so fail. + +pdf_output_2 = test.normalize_pdf(pdf_output_2) +pdf_output_3 = test.normalize_pdf(pdf_output_3) + +if pdf_output_2 != pdf_output_3: + import sys + test.write('master.normalized.2.pdf', pdf_output_2) + test.write('master.normalized.3.pdf', pdf_output_3) + sys.stdout.write("***** 2 and 3 are different!\n") + sys.stdout.write(test.diff_substr(pdf_output_2, pdf_output_3, 80, 80) + + '\n') + sys.stdout.write("Output from run 2:\n") + sys.stdout.write(test.stdout(-2) + '\n') + sys.stdout.write("Output from run 3:\n") + sys.stdout.write(test.stdout() + '\n') + sys.stdout.flush() + test.fail_test() + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: -- cgit v0.12 From 047c281b55c40a1707689769aff91532434619d7 Mon Sep 17 00:00:00 2001 From: Rick Lupton Date: Thu, 24 Nov 2016 09:02:56 +0000 Subject: Update CHANGES.txt --- src/CHANGES.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 282e80b..df9d5f9 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -40,6 +40,9 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - May find new (previously missed) Dlang dependencies. - May cause rebuild after upgrade due to dependency changes. + From Rick Lupton: + - Update LaTeX scanner to understand \import and related commands + RELEASE 2.5.0 - Mon, 09 Apr 2016 11:27:42 -0700 From Dirk Baechle: -- cgit v0.12 From 1fa9345f8757e26fb12758b7a618cde3776b25c6 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 25 Nov 2016 15:54:10 -0800 Subject: reorder entries to be correct --- src/CHANGES.txt | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 83f979a..0027404 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -13,6 +13,19 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER RELEASE VERSION/DATE TO BE FILLED IN LATER + From William Blevins: + - Updated D language scanner support to latest: 2.071.1. (PR #1924) + https://dlang.org/spec/module.html accessed 11 August 2016 + - Enhancements: + - Added support for selective imports: "import A : B, C;" -> A + - Added support for renamed imports. "import B = A;" -> A + - Supports valid combinations: "import A, B, CCC = C, DDD = D : EEE = FFF;" -> A, B, C, D + - Notes: + - May find new (previously missed) Dlang dependencies. + - May cause rebuild after upgrade due to dependency changes. + - Updated Fortran-related tests to pass under GCC 5/6. + - Fixed SCons.Tool.Packaging.rpm.package source nondeterminism across builds. + From Daniel Moody: - Fixed msvs.py for Visual Studio generated projects which were creating invalid xml for greater than and less than symbols. @@ -42,19 +55,9 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Added LoadableModule to the list of global functions (DefaultEnvironment builders). + From Rick Lupton: + - Update LaTeX scanner to understand \import and related commands - From William Blevins: - - Updated D language scanner support to latest: 2.071.1. (PR #1924) - https://dlang.org/spec/module.html accessed 11 August 2016 - - Enhancements: - - Added support for selective imports: "import A : B, C;" -> A - - Added support for renamed imports. "import B = A;" -> A - - Supports valid combinations: "import A, B, CCC = C, DDD = D : EEE = FFF;" -> A, B, C, D - - Notes: - - May find new (previously missed) Dlang dependencies. - - May cause rebuild after upgrade due to dependency changes. - - Updated Fortran-related tests to pass under GCC 5/6. - - Fixed SCons.Tool.Packaging.rpm.package source nondeterminism across builds. RELEASE 2.5.1 - Mon, 03 Nov 2016 13:37:42 -0400 @@ -65,9 +68,6 @@ RELEASE 2.5.1 - Mon, 03 Nov 2016 13:37:42 -0400 - Use memoization to optimize PATH evaluation across all dependencies per node. (PR #345) - From Rick Lupton: - - Update LaTeX scanner to understand \import and related commands - RELEASE 2.5.0 - Mon, 09 Apr 2016 11:27:42 -0700 From Dirk Baechle: -- cgit v0.12 From d938777da7f4b9e908075dabb1554bef9882d60f Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 27 Nov 2016 14:26:58 -0800 Subject: fix PCHPDBFLAGS changes to not crash if version of MSVC is unknown, and default to old value --- src/engine/SCons/Tool/MSCommon/vc.py | 11 ++++++----- src/engine/SCons/Tool/msvc.py | 13 +++++++++---- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py index baa4025..588fe98 100644 --- a/src/engine/SCons/Tool/MSCommon/vc.py +++ b/src/engine/SCons/Tool/MSCommon/vc.py @@ -185,16 +185,17 @@ _VCVER_TO_PRODUCT_DIR = { } def msvc_version_to_maj_min(msvc_version): - msvc_version_numeric = ''.join([x for x in msvc_version if x in string_digits + '.']) + + msvc_version_numeric = ''.join([x for x in msvc_version if x in string_digits + '.']) - t = msvc_version_numeric.split(".") - if not len(t) == 2: + t = msvc_version_numeric.split(".") + if not len(t) == 2: raise ValueError("Unrecognized version %s (%s)" % (msvc_version,msvc_version_numeric)) - try: + try: maj = int(t[0]) min = int(t[1]) return maj, min - except ValueError as e: + except ValueError as e: raise ValueError("Unrecognized version %s (%s)" % (msvc_version,msvc_version_numeric)) def is_host_target_supported(host_target, msvc_version): diff --git a/src/engine/SCons/Tool/msvc.py b/src/engine/SCons/Tool/msvc.py index 4a6feca..20b5d28 100644 --- a/src/engine/SCons/Tool/msvc.py +++ b/src/engine/SCons/Tool/msvc.py @@ -259,11 +259,16 @@ def generate(env): env['CFILESUFFIX'] = '.c' env['CXXFILESUFFIX'] = '.cc' - maj, min = msvc_version_to_maj_min(env['MSVC_VERSION']) - if maj < 8: - env['PCHPDBFLAGS'] = SCons.Util.CLVar(['${(PDB and "/Yd") or ""}']) + if env.get('MSVC_VERSION',False): + maj, min = msvc_version_to_maj_min(env['MSVC_VERSION']) + if maj < 8: + env['PCHPDBFLAGS'] = SCons.Util.CLVar(['${(PDB and "/Yd") or ""}']) + else: + env['PCHPDBFLAGS'] = '' else: - env['PCHPDBFLAGS'] = '' + # Default if we can't determine which version of MSVC we're using + env['PCHPDBFLAGS'] = SCons.Util.CLVar(['${(PDB and "/Yd") or ""}']) + env['PCHCOM'] = '$CXX /Fo${TARGETS[1]} $CXXFLAGS $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS /c $SOURCES /Yc$PCHSTOP /Fp${TARGETS[0]} $CCPDBFLAGS $PCHPDBFLAGS' env['BUILDERS']['PCH'] = pch_builder -- cgit v0.12 From b000c4588d0c5f01d2ff6e1a60785373b22ea044 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 27 Nov 2016 16:05:11 -0800 Subject: tests for msvc version specific PCHPDBFLAGS changes --- src/engine/SCons/Tool/msvc.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/engine/SCons/Tool/msvc.py b/src/engine/SCons/Tool/msvc.py index 20b5d28..e1b0536 100644 --- a/src/engine/SCons/Tool/msvc.py +++ b/src/engine/SCons/Tool/msvc.py @@ -60,6 +60,21 @@ def validate_vars(env): if not SCons.Util.is_String(env['PCHSTOP']): raise SCons.Errors.UserError("The PCHSTOP construction variable must be a string: %r"%env['PCHSTOP']) +def msvc_set_PCHPDBFLAGS(env): + """ + Set appropriate PCHPDBFLAGS for the MSVC version being used. + """ + if env.get('MSVC_VERSION',False): + maj, min = msvc_version_to_maj_min(env['MSVC_VERSION']) + if maj < 8: + env['PCHPDBFLAGS'] = SCons.Util.CLVar(['${(PDB and "/Yd") or ""}']) + else: + env['PCHPDBFLAGS'] = '' + else: + # Default if we can't determine which version of MSVC we're using + env['PCHPDBFLAGS'] = SCons.Util.CLVar(['${(PDB and "/Yd") or ""}']) + + def pch_emitter(target, source, env): """Adds the object file target.""" @@ -259,15 +274,7 @@ def generate(env): env['CFILESUFFIX'] = '.c' env['CXXFILESUFFIX'] = '.cc' - if env.get('MSVC_VERSION',False): - maj, min = msvc_version_to_maj_min(env['MSVC_VERSION']) - if maj < 8: - env['PCHPDBFLAGS'] = SCons.Util.CLVar(['${(PDB and "/Yd") or ""}']) - else: - env['PCHPDBFLAGS'] = '' - else: - # Default if we can't determine which version of MSVC we're using - env['PCHPDBFLAGS'] = SCons.Util.CLVar(['${(PDB and "/Yd") or ""}']) + msvc_set_PCHPDBFLAGS(env) env['PCHCOM'] = '$CXX /Fo${TARGETS[1]} $CXXFLAGS $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS /c $SOURCES /Yc$PCHSTOP /Fp${TARGETS[0]} $CCPDBFLAGS $PCHPDBFLAGS' -- cgit v0.12 From 51abbd22089b2274161ee95d48d00525d7905b01 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Sun, 27 Nov 2016 21:27:10 -0500 Subject: Python3 test fixes for Fortran/Side-effect. --- runtest.py | 2 +- test/Fortran/F03.py | 18 ++---------------- test/Fortran/F03FILESUFFIXES.py | 17 ++--------------- test/Fortran/F03FILESUFFIXES2.py | 17 ++--------------- test/Fortran/F03FLAGS.py | 26 ++++---------------------- test/Fortran/F08.py | 18 ++---------------- test/Fortran/F08FILESUFFIXES.py | 17 ++--------------- test/Fortran/F08FILESUFFIXES2.py | 17 ++--------------- test/Fortran/F08FLAGS.py | 26 ++++---------------------- test/Fortran/F77.py | 17 ++--------------- test/Fortran/F77FILESUFFIXES.py | 17 ++--------------- test/Fortran/F77FILESUFFIXES2.py | 17 ++--------------- test/Fortran/F77FLAGS.py | 23 +++-------------------- test/Fortran/F90.py | 18 ++---------------- test/Fortran/F90FILESUFFIXES.py | 17 ++--------------- test/Fortran/F90FILESUFFIXES2.py | 17 ++--------------- test/Fortran/F90FLAGS.py | 27 ++++----------------------- test/Fortran/F95.py | 20 ++------------------ test/Fortran/F95FILESUFFIXES.py | 19 ++----------------- test/Fortran/F95FILESUFFIXES2.py | 19 ++----------------- test/Fortran/F95FLAGS.py | 28 ++++------------------------ test/Fortran/FORTRAN.py | 20 +++----------------- test/Fortran/FORTRANFILESUFFIXES.py | 19 ++----------------- test/Fortran/FORTRANFILESUFFIXES2.py | 19 ++----------------- test/Fortran/FORTRANFLAGS.py | 25 +++---------------------- test/Fortran/FORTRANMODDIR.py | 2 +- test/Fortran/FORTRANPPFILESUFFIXES.py | 7 ++++--- test/Fortran/FORTRANSUFFIXES.py | 2 +- test/Fortran/SHF03.py | 20 ++------------------ test/Fortran/SHF08.py | 20 ++------------------ test/Fortran/SHF77.py | 20 ++------------------ test/Fortran/SHF77FLAGS.py | 25 +++---------------------- test/Fortran/SHF90.py | 20 ++------------------ test/Fortran/SHF90FLAGS.py | 28 ++++------------------------ test/Fortran/SHF95.py | 20 ++------------------ test/Fortran/SHF95FLAGS.py | 28 ++++------------------------ test/Fortran/SHFORTRAN.py | 21 +++------------------ test/Fortran/SHFORTRANFLAGS.py | 25 +++---------------------- test/Fortran/USE-MODULE.py | 2 +- test/Fortran/fixture/myfortran.py | 14 ++++++++++++++ test/Fortran/fixture/myfortran_flags.py | 16 ++++++++++++++++ test/Fortran/fixture/sconstest.skip | 0 test/Fortran/module-subdir.py | 10 +++++----- test/SideEffect/basic.py | 2 +- test/SideEffect/parallel.py | 4 ++-- test/SideEffect/variant_dir.py | 2 +- 46 files changed, 133 insertions(+), 635 deletions(-) create mode 100644 test/Fortran/fixture/myfortran.py create mode 100644 test/Fortran/fixture/myfortran_flags.py create mode 100644 test/Fortran/fixture/sconstest.skip diff --git a/runtest.py b/runtest.py index d636b73..cfdc0c9 100755 --- a/runtest.py +++ b/runtest.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # __COPYRIGHT__ # diff --git a/test/Fortran/F03.py b/test/Fortran/F03.py index 3c6bba4..61688c3 100644 --- a/test/Fortran/F03.py +++ b/test/Fortran/F03.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,22 +33,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -length = len(comment) -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:length] != comment.encode(): - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', diff --git a/test/Fortran/F03FILESUFFIXES.py b/test/Fortran/F03FILESUFFIXES.py index b1d2b93..9f1a031 100644 --- a/test/Fortran/F03FILESUFFIXES.py +++ b/test/Fortran/F03FILESUFFIXES.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,21 +33,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) # Test default file suffix: .f90/.F90 for F90 test.write('SConstruct', """ diff --git a/test/Fortran/F03FILESUFFIXES2.py b/test/Fortran/F03FILESUFFIXES2.py index 44be880..d84b089 100644 --- a/test/Fortran/F03FILESUFFIXES2.py +++ b/test/Fortran/F03FILESUFFIXES2.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,21 +33,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) # Test non-default file suffix: .f/.F for F03 test.write('SConstruct', """ diff --git a/test/Fortran/F03FLAGS.py b/test/Fortran/F03FLAGS.py index 4e99db8..a031005 100644 --- a/test/Fortran/F03FLAGS.py +++ b/test/Fortran/F03FLAGS.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,33 +33,14 @@ test = TestSCons.TestSCons() _exe = TestSCons._exe test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:xy') -optstring = '' -for opt, arg in opts: - if opt == '-o': out = arg - else: optstring = optstring + ' ' + opt -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -outfile.write(optstring + "\n") -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture(os.path.join('fixture', 'myfortran_flags.py')) test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', LINKFLAGS = [], - F03 = r'%(_python_)s myfortran.py g03', + F03 = r'%(_python_)s myfortran_flags.py g03', F03FLAGS = '-x', - FORTRAN = r'%(_python_)s myfortran.py fortran', + FORTRAN = r'%(_python_)s myfortran_flags.py fortran', FORTRANFLAGS = '-y') env.Program(target = 'test01', source = 'test01.f') env.Program(target = 'test02', source = 'test02.F') diff --git a/test/Fortran/F08.py b/test/Fortran/F08.py index a28389e..3b08f6e 100644 --- a/test/Fortran/F08.py +++ b/test/Fortran/F08.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,22 +33,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -length = len(comment) -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:length] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', diff --git a/test/Fortran/F08FILESUFFIXES.py b/test/Fortran/F08FILESUFFIXES.py index 41059af..5b078b1 100644 --- a/test/Fortran/F08FILESUFFIXES.py +++ b/test/Fortran/F08FILESUFFIXES.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,21 +33,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) # Test default file suffix: .f90/.F90 for F90 test.write('SConstruct', """ diff --git a/test/Fortran/F08FILESUFFIXES2.py b/test/Fortran/F08FILESUFFIXES2.py index e53cee1..955d64a 100644 --- a/test/Fortran/F08FILESUFFIXES2.py +++ b/test/Fortran/F08FILESUFFIXES2.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,21 +33,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) # Test non-default file suffix: .f/.F for F08 test.write('SConstruct', """ diff --git a/test/Fortran/F08FLAGS.py b/test/Fortran/F08FLAGS.py index c693c82..f91765b 100644 --- a/test/Fortran/F08FLAGS.py +++ b/test/Fortran/F08FLAGS.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,33 +33,14 @@ test = TestSCons.TestSCons() _exe = TestSCons._exe test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:xy') -optstring = '' -for opt, arg in opts: - if opt == '-o': out = arg - else: optstring = optstring + ' ' + opt -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -outfile.write(optstring + "\n") -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture(os.path.join('fixture', 'myfortran_flags.py')) test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', LINKFLAGS = [], - F08 = r'%(_python_)s myfortran.py g08', + F08 = r'%(_python_)s myfortran_flags.py g08', F08FLAGS = '-x', - FORTRAN = r'%(_python_)s myfortran.py fortran', + FORTRAN = r'%(_python_)s myfortran_flags.py fortran', FORTRANFLAGS = '-y') env.Program(target = 'test01', source = 'test01.f') env.Program(target = 'test02', source = 'test02.F') diff --git a/test/Fortran/F77.py b/test/Fortran/F77.py index 8fdd391..cea0485 100644 --- a/test/Fortran/F77.py +++ b/test/Fortran/F77.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,21 +33,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', diff --git a/test/Fortran/F77FILESUFFIXES.py b/test/Fortran/F77FILESUFFIXES.py index 1715ce9..26cf30c 100644 --- a/test/Fortran/F77FILESUFFIXES.py +++ b/test/Fortran/F77FILESUFFIXES.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,21 +33,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) # Test default file suffix: .f77/.F77 for F77 test.write('SConstruct', """ diff --git a/test/Fortran/F77FILESUFFIXES2.py b/test/Fortran/F77FILESUFFIXES2.py index 1938af1..7a000fe 100644 --- a/test/Fortran/F77FILESUFFIXES2.py +++ b/test/Fortran/F77FILESUFFIXES2.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,21 +33,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) # Test non-default file suffix: .f/.F for F77 test.write('SConstruct', """ diff --git a/test/Fortran/F77FLAGS.py b/test/Fortran/F77FLAGS.py index 9b4c56c..d4e6e8a 100644 --- a/test/Fortran/F77FLAGS.py +++ b/test/Fortran/F77FLAGS.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,30 +33,12 @@ test = TestSCons.TestSCons() _exe = TestSCons._exe test.file_fixture('mylink.py') - -test.write('myg77.py', r""" -import getopt -import sys -opts, args = getopt.getopt(sys.argv[1:], 'co:x') -optstring = '' -for opt, arg in opts: - if opt == '-o': out = arg - else: optstring = optstring + ' ' + opt -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -outfile.write(optstring + "\n") -for l in infile.readlines(): - if l[:4] != '#g77': - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture(os.path.join('fixture', 'myfortran_flags.py')) test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', LINKFLAGS = [], - F77 = r'%(_python_)s myg77.py', + F77 = r'%(_python_)s myfortran_flags.py g77', F77FLAGS = '-x') env.Program(target = 'test09', source = 'test09.f77') env.Program(target = 'test10', source = 'test10.F77') diff --git a/test/Fortran/F90.py b/test/Fortran/F90.py index 633b174..817a735 100644 --- a/test/Fortran/F90.py +++ b/test/Fortran/F90.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,22 +33,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -length = len(comment) -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:length] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', diff --git a/test/Fortran/F90FILESUFFIXES.py b/test/Fortran/F90FILESUFFIXES.py index 47da08e..a747570 100644 --- a/test/Fortran/F90FILESUFFIXES.py +++ b/test/Fortran/F90FILESUFFIXES.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,21 +33,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) # Test default file suffix: .f90/.F90 for F90 test.write('SConstruct', """ diff --git a/test/Fortran/F90FILESUFFIXES2.py b/test/Fortran/F90FILESUFFIXES2.py index 7039530..111c42b 100644 --- a/test/Fortran/F90FILESUFFIXES2.py +++ b/test/Fortran/F90FILESUFFIXES2.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,21 +33,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) # Test non-default file suffix: .f/.F for F90 test.write('SConstruct', """ diff --git a/test/Fortran/F90FLAGS.py b/test/Fortran/F90FLAGS.py index cf2b3b3..607ef60 100644 --- a/test/Fortran/F90FLAGS.py +++ b/test/Fortran/F90FLAGS.py @@ -25,42 +25,23 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons - - _python_ = TestSCons._python_ test = TestSCons.TestSCons() _exe = TestSCons._exe test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:xy') -optstring = '' -for opt, arg in opts: - if opt == '-o': out = arg - else: optstring = optstring + ' ' + opt -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -outfile.write(optstring + "\n") -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - +test.file_fixture(os.path.join('fixture', 'myfortran_flags.py')) test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', LINKFLAGS = [], - F90 = r'%(_python_)s myfortran.py g90', + F90 = r'%(_python_)s myfortran_flags.py g90', F90FLAGS = '-x', - FORTRAN = r'%(_python_)s myfortran.py fortran', + FORTRAN = r'%(_python_)s myfortran_flags.py fortran', FORTRANFLAGS = '-y') env.Program(target = 'test01', source = 'test01.f') env.Program(target = 'test02', source = 'test02.F') diff --git a/test/Fortran/F95.py b/test/Fortran/F95.py index 0912f71..07d1dc3 100644 --- a/test/Fortran/F95.py +++ b/test/Fortran/F95.py @@ -24,32 +24,16 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons - - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -length = len(comment) -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:length] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', diff --git a/test/Fortran/F95FILESUFFIXES.py b/test/Fortran/F95FILESUFFIXES.py index 8643a24..ac563cc 100644 --- a/test/Fortran/F95FILESUFFIXES.py +++ b/test/Fortran/F95FILESUFFIXES.py @@ -24,31 +24,16 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons - - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) # Test default file suffix: .f90/.F90 for F90 test.write('SConstruct', """ diff --git a/test/Fortran/F95FILESUFFIXES2.py b/test/Fortran/F95FILESUFFIXES2.py index d267a24..c6691e8 100644 --- a/test/Fortran/F95FILESUFFIXES2.py +++ b/test/Fortran/F95FILESUFFIXES2.py @@ -24,31 +24,16 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons - - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) # Test non-default file suffix: .f/.F for F95 test.write('SConstruct', """ diff --git a/test/Fortran/F95FLAGS.py b/test/Fortran/F95FLAGS.py index cc5a5e3..dd542f1 100644 --- a/test/Fortran/F95FLAGS.py +++ b/test/Fortran/F95FLAGS.py @@ -24,43 +24,23 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons - - _python_ = TestSCons._python_ test = TestSCons.TestSCons() _exe = TestSCons._exe test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:xy') -optstring = '' -for opt, arg in opts: - if opt == '-o': out = arg - else: optstring = optstring + ' ' + opt -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -outfile.write(optstring + "\n") -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture(os.path.join('fixture', 'myfortran_flags.py')) test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', LINKFLAGS = [], - F95 = r'%(_python_)s myfortran.py g95', + F95 = r'%(_python_)s myfortran_flags.py g95', F95FLAGS = '-x', - FORTRAN = r'%(_python_)s myfortran.py fortran', + FORTRAN = r'%(_python_)s myfortran_flags.py fortran', FORTRANFLAGS = '-y') env.Program(target = 'test01', source = 'test01.f') env.Program(target = 'test02', source = 'test02.F') diff --git a/test/Fortran/FORTRAN.py b/test/Fortran/FORTRAN.py index 577421e..379dfe9 100644 --- a/test/Fortran/FORTRAN.py +++ b/test/Fortran/FORTRAN.py @@ -24,35 +24,21 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons - - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myg77.py', r""" -import getopt -import sys -opts, args = getopt.getopt(sys.argv[1:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:4] != '#g77': - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', LINKFLAGS = [], - FORTRAN = r'%(_python_)s myg77.py') + FORTRAN = r'%(_python_)s myfortran.py g77') env.Program(target = 'test01', source = 'test01.f') env.Program(target = 'test02', source = 'test02.F') env.Program(target = 'test03', source = 'test03.for') diff --git a/test/Fortran/FORTRANFILESUFFIXES.py b/test/Fortran/FORTRANFILESUFFIXES.py index e4b6192..5294836 100644 --- a/test/Fortran/FORTRANFILESUFFIXES.py +++ b/test/Fortran/FORTRANFILESUFFIXES.py @@ -24,31 +24,16 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons - - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) # Test default file suffix: .f/.F for FORTRAN test.write('SConstruct', """ diff --git a/test/Fortran/FORTRANFILESUFFIXES2.py b/test/Fortran/FORTRANFILESUFFIXES2.py index 79231ac..141fc31 100644 --- a/test/Fortran/FORTRANFILESUFFIXES2.py +++ b/test/Fortran/FORTRANFILESUFFIXES2.py @@ -24,31 +24,16 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons - - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) # Test non default file suffix: .f, .f90 and .f95 for FORTRAN test.write('SConstruct', """ diff --git a/test/Fortran/FORTRANFLAGS.py b/test/Fortran/FORTRANFLAGS.py index 7b9f7d7..6ef2d72 100644 --- a/test/Fortran/FORTRANFLAGS.py +++ b/test/Fortran/FORTRANFLAGS.py @@ -24,40 +24,21 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons - - _python_ = TestSCons._python_ test = TestSCons.TestSCons() _exe = TestSCons._exe test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -opts, args = getopt.getopt(sys.argv[1:], 'co:x') -optstring = '' -for opt, arg in opts: - if opt == '-o': out = arg - else: optstring = optstring + ' ' + opt -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -outfile.write(optstring + "\n") -for l in infile.readlines(): - if l[:8] != '#fortran': - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture(os.path.join('fixture', 'myfortran_flags.py')) test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', LINKFLAGS = [], - FORTRAN = r'%(_python_)s myfortran.py', + FORTRAN = r'%(_python_)s myfortran_flags.py fortran', FORTRANFLAGS = '-x') env.Program(target = 'test01', source = 'test01.f') env.Program(target = 'test02', source = 'test02.F') diff --git a/test/Fortran/FORTRANMODDIR.py b/test/Fortran/FORTRANMODDIR.py index 3c14632..723efaf 100644 --- a/test/Fortran/FORTRANMODDIR.py +++ b/test/Fortran/FORTRANMODDIR.py @@ -42,7 +42,7 @@ contents = open(sys.argv[2]).read() modules = re.findall(mod_regex, contents) modules = [os.path.join(sys.argv[1], m.lower()+'.mod') for m in modules] for t in sys.argv[3:] + modules: - open(t, 'wb').write('myfortran.py wrote %s\n' % os.path.split(t)[1]) + open(t, 'wb').write(('myfortran.py wrote %s\n' % os.path.split(t)[1]).encode()) sys.exit(0) """) diff --git a/test/Fortran/FORTRANPPFILESUFFIXES.py b/test/Fortran/FORTRANPPFILESUFFIXES.py index 2791b91..6b3b3d8 100644 --- a/test/Fortran/FORTRANPPFILESUFFIXES.py +++ b/test/Fortran/FORTRANPPFILESUFFIXES.py @@ -43,7 +43,8 @@ test.write('myfortran.py', r""" import getopt import sys -comment = '#' + sys.argv[1] +comment = ('#' + sys.argv[1]).encode() +length = len(comment) args = sys.argv[2:] # First parse defines, since getopt won't have it defines = [] @@ -58,9 +59,9 @@ for opt, arg in opts: infile = open(args[0], 'rb') outfile = open(out, 'wb') for d in defines: - outfile.write("#define %s\n" % (d,)) + outfile.write(("#define %s\n" % (d,)).encode()) for l in infile.readlines(): - if l[:len(comment)] != comment: + if l[:length] != comment: outfile.write(l) sys.exit(0) """) diff --git a/test/Fortran/FORTRANSUFFIXES.py b/test/Fortran/FORTRANSUFFIXES.py index 9673e6f..c1b3455 100644 --- a/test/Fortran/FORTRANSUFFIXES.py +++ b/test/Fortran/FORTRANSUFFIXES.py @@ -38,7 +38,7 @@ test.write('myfc.py', r""" import sys def do_file(outf, inf): for line in open(inf, 'rb').readlines(): - if line[:15] == " INCLUDE '": + if line[:15] == b" INCLUDE '": do_file(outf, line[15:-2]) else: outf.write(line) diff --git a/test/Fortran/SHF03.py b/test/Fortran/SHF03.py index d514f64..5327c4c 100644 --- a/test/Fortran/SHF03.py +++ b/test/Fortran/SHF03.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,24 +33,7 @@ obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() - - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'cf:o:K:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture(os.path.join('fixture', 'myfortran.py')) test.write('SConstruct', """ env = Environment(SHF03 = r'%(_python_)s myfortran.py g03', diff --git a/test/Fortran/SHF08.py b/test/Fortran/SHF08.py index 0aed858..10f9314 100644 --- a/test/Fortran/SHF08.py +++ b/test/Fortran/SHF08.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,24 +33,7 @@ obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() - - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'cf:o:K:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture(os.path.join('fixture', 'myfortran.py')) test.write('SConstruct', """ env = Environment(SHF08 = r'%(_python_)s myfortran.py g08', diff --git a/test/Fortran/SHF77.py b/test/Fortran/SHF77.py index 3c2565b..ba3ac2e 100644 --- a/test/Fortran/SHF77.py +++ b/test/Fortran/SHF77.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,24 +33,7 @@ obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() - - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'cf:o:K:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture(os.path.join('fixture', 'myfortran.py')) test.write('SConstruct', """ env = Environment(SHF77 = r'%(_python_)s myfortran.py g77', diff --git a/test/Fortran/SHF77FLAGS.py b/test/Fortran/SHF77FLAGS.py index 1b9628c..e3f78a8 100644 --- a/test/Fortran/SHF77FLAGS.py +++ b/test/Fortran/SHF77FLAGS.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,30 +33,10 @@ _obj = TestSCons._shobj obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() - - - -test.write('myg77.py', r""" -import getopt -import sys -opts, args = getopt.getopt(sys.argv[1:], 'cf:K:o:x') -optstring = '' -for opt, arg in opts: - if opt == '-o': out = arg - elif opt not in ('-f', '-K'): optstring = optstring + ' ' + opt -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -outfile.write(optstring + "\n") -for l in infile.readlines(): - if l[:4] != '#g77': - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture(os.path.join('fixture', 'myfortran_flags.py')) test.write('SConstruct', """ -env = Environment(SHF77 = r'%(_python_)s myg77.py') +env = Environment(SHF77 = r'%(_python_)s myfortran_flags.py g77') env.Append(SHF77FLAGS = '-x') env.SharedObject(target = 'test09', source = 'test09.f77') env.SharedObject(target = 'test10', source = 'test10.F77') diff --git a/test/Fortran/SHF90.py b/test/Fortran/SHF90.py index 46bf4ae..c56772e 100644 --- a/test/Fortran/SHF90.py +++ b/test/Fortran/SHF90.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,24 +33,7 @@ obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() - - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'cf:o:K:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture(os.path.join('fixture', 'myfortran.py')) test.write('SConstruct', """ env = Environment(SHF90 = r'%(_python_)s myfortran.py g90', diff --git a/test/Fortran/SHF90FLAGS.py b/test/Fortran/SHF90FLAGS.py index 0f9e2ba3..6f7ee00 100644 --- a/test/Fortran/SHF90FLAGS.py +++ b/test/Fortran/SHF90FLAGS.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,32 +33,11 @@ _obj = TestSCons._shobj obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() - - - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'cf:K:o:xy') -optstring = '' -for opt, arg in opts: - if opt == '-o': out = arg - elif opt not in ('-f', '-K'): optstring = optstring + ' ' + opt -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -outfile.write(optstring + "\n") -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture(os.path.join('fixture', 'myfortran_flags.py')) test.write('SConstruct', """ -env = Environment(SHF90 = r'%(_python_)s myfortran.py g90', - SHFORTRAN = r'%(_python_)s myfortran.py fortran') +env = Environment(SHF90 = r'%(_python_)s myfortran_flags.py g90', + SHFORTRAN = r'%(_python_)s myfortran_flags.py fortran') env.Append(SHF90FLAGS = '-x', SHFORTRANFLAGS = '-y') env.SharedObject(target = 'test01', source = 'test01.f') diff --git a/test/Fortran/SHF95.py b/test/Fortran/SHF95.py index 6329c9e..ff0604b 100644 --- a/test/Fortran/SHF95.py +++ b/test/Fortran/SHF95.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,24 +33,7 @@ obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() - - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'cf:o:K:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture(os.path.join('fixture', 'myfortran.py')) test.write('SConstruct', """ env = Environment(SHF95 = r'%(_python_)s myfortran.py g95', diff --git a/test/Fortran/SHF95FLAGS.py b/test/Fortran/SHF95FLAGS.py index e573eb4..45c37bc 100644 --- a/test/Fortran/SHF95FLAGS.py +++ b/test/Fortran/SHF95FLAGS.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,32 +33,11 @@ _obj = TestSCons._shobj obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() - - - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'cf:K:o:xy') -optstring = '' -for opt, arg in opts: - if opt == '-o': out = arg - elif opt not in ('-f', '-K'): optstring = optstring + ' ' + opt -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -outfile.write(optstring + "\n") -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture(os.path.join('fixture', 'myfortran_flags.py')) test.write('SConstruct', """ -env = Environment(SHF95 = r'%(_python_)s myfortran.py g95', - SHFORTRAN = r'%(_python_)s myfortran.py fortran') +env = Environment(SHF95 = r'%(_python_)s myfortran_flags.py g95', + SHFORTRAN = r'%(_python_)s myfortran_flags.py fortran') env.Append(SHF95FLAGS = '-x', SHFORTRANFLAGS = '-y') env.SharedObject(target = 'test01', source = 'test01.f') diff --git a/test/Fortran/SHFORTRAN.py b/test/Fortran/SHFORTRAN.py index fdcba7f..2155736 100644 --- a/test/Fortran/SHFORTRAN.py +++ b/test/Fortran/SHFORTRAN.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,26 +33,10 @@ obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() - - -test.write('myfortran.py', r""" -import getopt -import sys -opts, args = getopt.getopt(sys.argv[1:], 'cf:o:K:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:8] != '#fortran': - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture(os.path.join('fixture', 'myfortran.py')) test.write('SConstruct', """ -env = Environment(SHFORTRAN = r'%(_python_)s myfortran.py') +env = Environment(SHFORTRAN = r'%(_python_)s myfortran.py fortran') env.SharedObject(target = 'test01', source = 'test01.f') env.SharedObject(target = 'test02', source = 'test02.F') env.SharedObject(target = 'test03', source = 'test03.for') diff --git a/test/Fortran/SHFORTRANFLAGS.py b/test/Fortran/SHFORTRANFLAGS.py index 7067c6f..70c353b 100644 --- a/test/Fortran/SHFORTRANFLAGS.py +++ b/test/Fortran/SHFORTRANFLAGS.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -31,30 +32,10 @@ _obj = TestSCons._shobj obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() - - - -test.write('myfortran.py', r""" -import getopt -import sys -opts, args = getopt.getopt(sys.argv[1:], 'cf:K:o:x') -optstring = '' -for opt, arg in opts: - if opt == '-o': out = arg - elif opt not in ('-f', '-K'): optstring = optstring + ' ' + opt -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -outfile.write(optstring + "\n") -for l in infile.readlines(): - if l[:8] != '#fortran': - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture(os.path.join('fixture', 'myfortran_flags.py')) test.write('SConstruct', """ -env = Environment(SHFORTRAN = r'%(_python_)s myfortran.py') +env = Environment(SHFORTRAN = r'%(_python_)s myfortran_flags.py fortran') env.Append(SHFORTRANFLAGS = '-x') env.SharedObject(target = 'test01', source = 'test01.f') env.SharedObject(target = 'test02', source = 'test02.F') diff --git a/test/Fortran/USE-MODULE.py b/test/Fortran/USE-MODULE.py index 8f537dd..0d78e7a 100644 --- a/test/Fortran/USE-MODULE.py +++ b/test/Fortran/USE-MODULE.py @@ -42,7 +42,7 @@ contents = open(sys.argv[1]).read() modules = re.findall(mod_regex, contents) modules = [m.lower()+'.mod' for m in modules] for t in sys.argv[2:] + modules: - open(t, 'wb').write('myfortran.py wrote %s\n' % os.path.split(t)[1]) + open(t, 'wb').write(('myfortran.py wrote %s\n' % os.path.split(t)[1]).encode()) sys.exit(0) """) diff --git a/test/Fortran/fixture/myfortran.py b/test/Fortran/fixture/myfortran.py new file mode 100644 index 0000000..08d1489 --- /dev/null +++ b/test/Fortran/fixture/myfortran.py @@ -0,0 +1,14 @@ +import getopt +import sys +print(sys.argv) +comment = ('#' + sys.argv[1]).encode() +length = len(comment) +opts, args = getopt.getopt(sys.argv[2:], 'cf:o:K:') +for opt, arg in opts: + if opt == '-o': out = arg +infile = open(args[0], 'rb') +outfile = open(out, 'wb') +for l in infile.readlines(): + if l[:length] != comment: + outfile.write(l) +sys.exit(0) diff --git a/test/Fortran/fixture/myfortran_flags.py b/test/Fortran/fixture/myfortran_flags.py new file mode 100644 index 0000000..b972e35 --- /dev/null +++ b/test/Fortran/fixture/myfortran_flags.py @@ -0,0 +1,16 @@ +import getopt +import sys +comment = ('#' + sys.argv[1]).encode() +opts, args = getopt.getopt(sys.argv[2:], 'cf:o:xy') +optstring = '' +length = len(comment) +for opt, arg in opts: + if opt == '-o': out = arg + elif opt not in ('-f', '-K'): optstring = optstring + ' ' + opt +infile = open(args[0], 'rb') +outfile = open(out, 'wb') +outfile.write((optstring + "\n").encode()) +for l in infile.readlines(): + if l[:length] != comment: + outfile.write(l) +sys.exit(0) diff --git a/test/Fortran/fixture/sconstest.skip b/test/Fortran/fixture/sconstest.skip new file mode 100644 index 0000000..e69de29 diff --git a/test/Fortran/module-subdir.py b/test/Fortran/module-subdir.py index def1e5c..6570e0f 100644 --- a/test/Fortran/module-subdir.py +++ b/test/Fortran/module-subdir.py @@ -45,7 +45,7 @@ test.write('myfortran.py', r""" import getopt import os import sys -comment = '#' + sys.argv[1] +comment = ('#' + sys.argv[1]).encode() length = len(comment) opts, args = getopt.getopt(sys.argv[2:], 'cM:o:') for opt, arg in opts: @@ -55,9 +55,9 @@ import os infile = open(args[0], 'rb') outfile = open(out, 'wb') for l in infile.readlines(): - if l[:7] == 'module ': - module = modsubdir + os.sep + l[7:-1] + '.mod' - open(module, 'wb').write('myfortran.py wrote %s\n' % module) + if l[:7] == b'module ': + module = modsubdir + os.sep + l[7:-1].decode() + '.mod' + open(module, 'wb').write(('myfortran.py wrote %s\n' % module).encode()) if l[:length] != comment: outfile.write(l) sys.exit(0) @@ -103,7 +103,7 @@ end module """) -test.run(arguments = '.') +test.run(arguments = '. --tree=all') somemodule = os.path.join('subdir', 'build', 'somemodule.mod') diff --git a/test/SideEffect/basic.py b/test/SideEffect/basic.py index 0ded6b6..af6c264 100644 --- a/test/SideEffect/basic.py +++ b/test/SideEffect/basic.py @@ -43,7 +43,7 @@ def build(env, source, target): copy(str(source[0]), str(target[0])) if target[0].side_effects: side_effect = open(str(target[0].side_effects[0]), "ab") - side_effect.write('%%s -> %%s\\n'%%(str(source[0]), str(target[0]))) + side_effect.write(('%%s -> %%s\\n'%%(str(source[0]), str(target[0]))).encode()) Build = Builder(action=build) env = Environment(BUILDERS={'Build':Build}, SUBDIR='subdir') diff --git a/test/SideEffect/parallel.py b/test/SideEffect/parallel.py index ff883c4..f750903 100644 --- a/test/SideEffect/parallel.py +++ b/test/SideEffect/parallel.py @@ -45,14 +45,14 @@ logfile = 'log.txt' try: os.mkdir(lockdir) -except OSError, e: +except OSError as e: msg = 'could not create lock directory: %s\\n' % e sys.stderr.write(msg) sys.exit(1) src, target = sys.argv[1:] -open(logfile, 'ab').write('%s -> %s\\n' % (src, target)) +open(logfile, 'ab').write(('%s -> %s\\n' % (src, target)).encode()) # Give the other threads a chance to start. time.sleep(1) diff --git a/test/SideEffect/variant_dir.py b/test/SideEffect/variant_dir.py index cc7b8e9..711e426 100644 --- a/test/SideEffect/variant_dir.py +++ b/test/SideEffect/variant_dir.py @@ -44,7 +44,7 @@ def build(env, source, target): copy(str(source[0]), str(target[0])) if target[0].side_effects: side_effect = open(str(target[0].side_effects[0]), "ab") - side_effect.write('%s -> %s\\n'%(str(source[0]), str(target[0]))) + side_effect.write(('%s -> %s\\n'%(str(source[0]), str(target[0]))).encode()) Build = Builder(action=build) env = Environment(BUILDERS={'Build':Build}) -- cgit v0.12 From 98b77fecd17937c0b10d809906c4c0760ca077e5 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Sun, 27 Nov 2016 22:05:26 -0500 Subject: Reverted Python3 change to runtest.py. --- runtest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtest.py b/runtest.py index cfdc0c9..d636b73 100755 --- a/runtest.py +++ b/runtest.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python # # __COPYRIGHT__ # -- cgit v0.12 From 2a13b4ee309325261f69cbcb7bb69a78ef27a08a Mon Sep 17 00:00:00 2001 From: William Blevins Date: Sun, 27 Nov 2016 22:11:10 -0500 Subject: Revert of minor debug change for python3 update. --- test/Fortran/module-subdir.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Fortran/module-subdir.py b/test/Fortran/module-subdir.py index 6570e0f..6224d44 100644 --- a/test/Fortran/module-subdir.py +++ b/test/Fortran/module-subdir.py @@ -103,7 +103,7 @@ end module """) -test.run(arguments = '. --tree=all') +test.run(arguments = '.') somemodule = os.path.join('subdir', 'build', 'somemodule.mod') -- cgit v0.12 From 1c19e9f962b8cab0f9086615bb6409f8a326c0b8 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 28 Nov 2016 07:33:57 -0800 Subject: Add better error messaging when missing (or surplus) shared library targets with file extension --- src/engine/SCons/Tool/mingw.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/SCons/Tool/mingw.py b/src/engine/SCons/Tool/mingw.py index 948ebe5..778db3c 100644 --- a/src/engine/SCons/Tool/mingw.py +++ b/src/engine/SCons/Tool/mingw.py @@ -86,7 +86,8 @@ def shlib_emitter(target, source, env): no_import_lib = env.get('no_import_lib', 0) if not dll: - raise SCons.Errors.UserError("A shared library should have exactly one target with the suffix: %s" % env.subst("$SHLIBSUFFIX")) + raise SCons.Errors.UserError("A shared library should have exactly one target with the suffix: %s Target(s) are:%s" % \ + (env.subst("$SHLIBSUFFIX"), ",".join([str(t) for t in target]))) if not no_import_lib and \ not env.FindIxes(target, 'LIBPREFIX', 'LIBSUFFIX'): -- cgit v0.12 From 694e80ea463c655d2e011afd4fe35109c119d6e7 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 28 Nov 2016 08:53:37 -0800 Subject: Fix tests failing on win32 AR and Fortran and M4 --- src/engine/SCons/Tool/__init__.py | 2 +- src/engine/SCons/Tool/ar.py | 4 ++-- test/AR/ARCOM.py | 2 ++ test/AR/ARCOMSTR.py | 1 + test/Fortran/F03COM.py | 18 +++++++++++++----- test/Fortran/F08COM.py | 16 +++++++++++----- test/Fortran/F77COM.py | 17 ++++++++++++----- test/Fortran/F90COM.py | 20 ++++++++++++++------ test/Fortran/F95COM.py | 18 ++++++++++++------ test/Fortran/FORTRANCOM.py | 15 +++++++++++---- test/Fortran/SHF77COM.py | 16 +++++++++++----- test/Fortran/SHF90COM.py | 19 +++++++++++++------ test/Fortran/SHF95COM.py | 18 ++++++++++++------ test/Fortran/SHFORTRANCOM.py | 14 ++++++++++---- test/M4/M4.py | 8 +++++++- 15 files changed, 132 insertions(+), 56 deletions(-) diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index 45d0aa1..15c8109 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -263,7 +263,7 @@ def createStaticLibBuilder(env): static_lib = env['BUILDERS']['StaticLibrary'] except KeyError: action_list = [ SCons.Action.Action("$ARCOM", "$ARCOMSTR") ] - if env.Detect('ranlib'): + if env.get('RANLIB',False) or env.Detect('ranlib'): ranlib_action = SCons.Action.Action("$RANLIBCOM", "$RANLIBCOMSTR") action_list.append(ranlib_action) diff --git a/src/engine/SCons/Tool/ar.py b/src/engine/SCons/Tool/ar.py index 0c3ac09..2cd15c8 100644 --- a/src/engine/SCons/Tool/ar.py +++ b/src/engine/SCons/Tool/ar.py @@ -48,8 +48,8 @@ def generate(env): env['LIBPREFIX'] = 'lib' env['LIBSUFFIX'] = '.a' - if env.Detect('ranlib'): - env['RANLIB'] = 'ranlib' + if env.get('RANLIB',env.Detect('ranlib')) : + env['RANLIB'] = env.get('RANLIB','ranlib') env['RANLIBFLAGS'] = SCons.Util.CLVar('') env['RANLIBCOM'] = '$RANLIB $RANLIBFLAGS $TARGET' diff --git a/test/AR/ARCOM.py b/test/AR/ARCOM.py index f9d0038..9ae5b9f 100644 --- a/test/AR/ARCOM.py +++ b/test/AR/ARCOM.py @@ -40,6 +40,7 @@ test.file_fixture('myrewrite.py') test.write('SConstruct', """ env = Environment(tools=['default', 'ar'], ARCOM = r'%(_python_)s mycompile.py ar $TARGET $SOURCES', + RANLIB = True, RANLIBCOM = r'%(_python_)s myrewrite.py ranlib $TARGET', LIBPREFIX = '', LIBSUFFIX = '.lib') @@ -49,6 +50,7 @@ env.Library(target = 'output', source = ['file.1', 'file.2']) test.write('file.1', "file.1\n/*ar*/\n/*ranlib*/\n") test.write('file.2', "file.2\n/*ar*/\n/*ranlib*/\n") + test.run(arguments = '.') test.must_match('output.lib', "file.1\nfile.2\n") diff --git a/test/AR/ARCOMSTR.py b/test/AR/ARCOMSTR.py index 3235f12..a3a9c8e 100644 --- a/test/AR/ARCOMSTR.py +++ b/test/AR/ARCOMSTR.py @@ -42,6 +42,7 @@ test.write('SConstruct', """ env = Environment(tools=['default', 'ar'], ARCOM = r'%(_python_)s mycompile.py ar $TARGET $SOURCES', ARCOMSTR = 'Archiving $TARGET from $SOURCES', + RANLIB = True, RANLIBCOM = r'%(_python_)s myrewrite.py ranlib $TARGET', LIBPREFIX = '', LIBSUFFIX = '.lib') diff --git a/test/Fortran/F03COM.py b/test/Fortran/F03COM.py index 4a42d22..aaa790c 100644 --- a/test/Fortran/F03COM.py +++ b/test/Fortran/F03COM.py @@ -25,6 +25,9 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys + +is_windows = (sys.platform == 'win32') _python_ = TestSCons._python_ _exe = TestSCons._exe @@ -76,18 +79,23 @@ test.write('test22.F03', "This is a .F03 file.\n#link\n/*f03pp*/\n") test.run(arguments = '.', stderr = None) test.must_match('test01' + _exe, "This is a .f file.\n") -test.must_match('test02' + _exe, "This is a .F file.\n") test.must_match('test03' + _exe, "This is a .for file.\n") -test.must_match('test04' + _exe, "This is a .FOR file.\n") test.must_match('test05' + _exe, "This is a .ftn file.\n") -test.must_match('test06' + _exe, "This is a .FTN file.\n") test.must_match('test07' + _exe, "This is a .fpp file.\n") test.must_match('test08' + _exe, "This is a .FPP file.\n") test.must_match('test13' + _exe, "This is a .f03 file.\n") -test.must_match('test14' + _exe, "This is a .F03 file.\n") test.must_match('test21' + _exe, "This is a .f03 file.\n") -test.must_match('test22' + _exe, "This is a .F03 file.\n") + +if not is_windows: + # Skip checking files we expect to differ in behavior + # based on file extension case + test.must_match('test02' + _exe, "This is a .F file.\n") + test.must_match('test04' + _exe, "This is a .FOR file.\n") + test.must_match('test06' + _exe, "This is a .FTN file.\n") + test.must_match('test14' + _exe, "This is a .F03 file.\n") + test.must_match('test22' + _exe, "This is a .F03 file.\n") + test.pass_test() diff --git a/test/Fortran/F08COM.py b/test/Fortran/F08COM.py index ba7d64e..f159a53 100644 --- a/test/Fortran/F08COM.py +++ b/test/Fortran/F08COM.py @@ -25,6 +25,9 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys + +is_windows = ( sys.platform =='win32') _python_ = TestSCons._python_ _exe = TestSCons._exe @@ -67,15 +70,18 @@ test.write('test10.F08', "This is a .F08 file.\n#link\n/*f08pp*/\n") test.run(arguments = '.', stderr = None) test.must_match('test01' + _exe, "This is a .f file.\n") -test.must_match('test02' + _exe, "This is a .F file.\n") test.must_match('test03' + _exe, "This is a .for file.\n") -test.must_match('test04' + _exe, "This is a .FOR file.\n") test.must_match('test05' + _exe, "This is a .ftn file.\n") -test.must_match('test06' + _exe, "This is a .FTN file.\n") test.must_match('test07' + _exe, "This is a .fpp file.\n") -test.must_match('test08' + _exe, "This is a .FPP file.\n") test.must_match('test09' + _exe, "This is a .f08 file.\n") -test.must_match('test10' + _exe, "This is a .F08 file.\n") +if not is_windows: + # Skip checking files we expect to differ in behavior + # based on file extension case + test.must_match('test02' + _exe, "This is a .F file.\n") + test.must_match('test04' + _exe, "This is a .FOR file.\n") + test.must_match('test06' + _exe, "This is a .FTN file.\n") + test.must_match('test08' + _exe, "This is a .FPP file.\n") + test.must_match('test10' + _exe, "This is a .F08 file.\n") test.pass_test() diff --git a/test/Fortran/F77COM.py b/test/Fortran/F77COM.py index e7a3cca..6550d92 100644 --- a/test/Fortran/F77COM.py +++ b/test/Fortran/F77COM.py @@ -25,6 +25,9 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys + +is_windows = ( sys.platform =='win32') _python_ = TestSCons._python_ _exe = TestSCons._exe @@ -67,15 +70,19 @@ test.write('test10.F77', "This is a .F77 file.\n#link\n/*f77pp*/\n") test.run(arguments = '.', stderr = None) test.must_match('test01' + _exe, "This is a .f file.\n") -test.must_match('test02' + _exe, "This is a .F file.\n") test.must_match('test03' + _exe, "This is a .for file.\n") -test.must_match('test04' + _exe, "This is a .FOR file.\n") test.must_match('test05' + _exe, "This is a .ftn file.\n") -test.must_match('test06' + _exe, "This is a .FTN file.\n") test.must_match('test07' + _exe, "This is a .fpp file.\n") -test.must_match('test08' + _exe, "This is a .FPP file.\n") test.must_match('test09' + _exe, "This is a .f77 file.\n") -test.must_match('test10' + _exe, "This is a .F77 file.\n") + +if not is_windows: + # Skip checking files we expect to differ in behavior + # based on file extension case + test.must_match('test02' + _exe, "This is a .F file.\n") + test.must_match('test04' + _exe, "This is a .FOR file.\n") + test.must_match('test06' + _exe, "This is a .FTN file.\n") + test.must_match('test08' + _exe, "This is a .FPP file.\n") + test.must_match('test10' + _exe, "This is a .F77 file.\n") test.pass_test() diff --git a/test/Fortran/F90COM.py b/test/Fortran/F90COM.py index a4f37c2..180e6b7 100644 --- a/test/Fortran/F90COM.py +++ b/test/Fortran/F90COM.py @@ -25,6 +25,9 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys + +is_windows = ( sys.platform =='win32') _python_ = TestSCons._python_ _exe = TestSCons._exe @@ -76,18 +79,23 @@ test.write('test22.F90', "This is a .F90 file.\n#link\n/*f90pp*/\n") test.run(arguments = '.', stderr = None) test.must_match('test01' + _exe, "This is a .f file.\n") -test.must_match('test02' + _exe, "This is a .F file.\n") test.must_match('test03' + _exe, "This is a .for file.\n") -test.must_match('test04' + _exe, "This is a .FOR file.\n") test.must_match('test05' + _exe, "This is a .ftn file.\n") -test.must_match('test06' + _exe, "This is a .FTN file.\n") test.must_match('test07' + _exe, "This is a .fpp file.\n") -test.must_match('test08' + _exe, "This is a .FPP file.\n") test.must_match('test11' + _exe, "This is a .f90 file.\n") -test.must_match('test12' + _exe, "This is a .F90 file.\n") test.must_match('test21' + _exe, "This is a .f90 file.\n") -test.must_match('test22' + _exe, "This is a .F90 file.\n") + +if not is_windows: + # Skip checking files we expect to differ in behavior + # based on file extension case + test.must_match('test02' + _exe, "This is a .F file.\n") + test.must_match('test04' + _exe, "This is a .FOR file.\n") + test.must_match('test06' + _exe, "This is a .FTN file.\n") + test.must_match('test08' + _exe, "This is a .FPP file.\n") + test.must_match('test12' + _exe, "This is a .F90 file.\n") + test.must_match('test22' + _exe, "This is a .F90 file.\n") + test.pass_test() diff --git a/test/Fortran/F95COM.py b/test/Fortran/F95COM.py index 32ae594..2d48770 100644 --- a/test/Fortran/F95COM.py +++ b/test/Fortran/F95COM.py @@ -25,6 +25,9 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys + +is_windows = ( sys.platform =='win32') _python_ = TestSCons._python_ _exe = TestSCons._exe @@ -76,18 +79,21 @@ test.write('test22.F95', "This is a .F95 file.\n#link\n/*f95pp*/\n") test.run(arguments = '.', stderr = None) test.must_match('test01' + _exe, "This is a .f file.\n") -test.must_match('test02' + _exe, "This is a .F file.\n") test.must_match('test03' + _exe, "This is a .for file.\n") -test.must_match('test04' + _exe, "This is a .FOR file.\n") test.must_match('test05' + _exe, "This is a .ftn file.\n") -test.must_match('test06' + _exe, "This is a .FTN file.\n") test.must_match('test07' + _exe, "This is a .fpp file.\n") -test.must_match('test08' + _exe, "This is a .FPP file.\n") test.must_match('test13' + _exe, "This is a .f95 file.\n") -test.must_match('test14' + _exe, "This is a .F95 file.\n") test.must_match('test21' + _exe, "This is a .f95 file.\n") -test.must_match('test22' + _exe, "This is a .F95 file.\n") +if not is_windows: + # Skip checking files we expect to differ in behavior + # based on file extension case + test.must_match('test02' + _exe, "This is a .F file.\n") + test.must_match('test04' + _exe, "This is a .FOR file.\n") + test.must_match('test06' + _exe, "This is a .FTN file.\n") + test.must_match('test08' + _exe, "This is a .FPP file.\n") + test.must_match('test14' + _exe, "This is a .F95 file.\n") + test.must_match('test22' + _exe, "This is a .F95 file.\n") test.pass_test() diff --git a/test/Fortran/FORTRANCOM.py b/test/Fortran/FORTRANCOM.py index a07d427..d3d7e7f 100644 --- a/test/Fortran/FORTRANCOM.py +++ b/test/Fortran/FORTRANCOM.py @@ -25,6 +25,10 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys + +is_windows = ( sys.platform =='win32') + _python_ = TestSCons._python_ _exe = TestSCons._exe @@ -61,13 +65,16 @@ test.write('test08.FPP', "This is a .FPP file.\n#link\n/*fortranpp*/\n") test.run(arguments = '.', stderr = None) test.must_match('test01' + _exe, "This is a .f file.\n") -test.must_match('test02' + _exe, "This is a .F file.\n") test.must_match('test03' + _exe, "This is a .for file.\n") -test.must_match('test04' + _exe, "This is a .FOR file.\n") test.must_match('test05' + _exe, "This is a .ftn file.\n") -test.must_match('test06' + _exe, "This is a .FTN file.\n") test.must_match('test07' + _exe, "This is a .fpp file.\n") -test.must_match('test08' + _exe, "This is a .FPP file.\n") +if not is_windows: + # Skip checking files we expect to differ in behavior + # based on file extension case + test.must_match('test02' + _exe, "This is a .F file.\n") + test.must_match('test04' + _exe, "This is a .FOR file.\n") + test.must_match('test06' + _exe, "This is a .FTN file.\n") + test.must_match('test08' + _exe, "This is a .FPP file.\n") test.pass_test() diff --git a/test/Fortran/SHF77COM.py b/test/Fortran/SHF77COM.py index 9289fa3..bd3d1e2 100644 --- a/test/Fortran/SHF77COM.py +++ b/test/Fortran/SHF77COM.py @@ -25,6 +25,9 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys + +is_windows = ( sys.platform =='win32') _python_ = TestSCons._python_ _obj = TestSCons._shobj @@ -65,15 +68,18 @@ test.write('test10.F77', "This is a .F77 file.\n/*f77pp*/\n") test.run(arguments = '.', stderr = None) test.must_match(obj_ + 'test01' + _obj, "This is a .f file.\n") -test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") test.must_match(obj_ + 'test03' + _obj, "This is a .for file.\n") -test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") test.must_match(obj_ + 'test05' + _obj, "This is a .ftn file.\n") -test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") test.must_match(obj_ + 'test07' + _obj, "This is a .fpp file.\n") -test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") test.must_match(obj_ + 'test09' + _obj, "This is a .f77 file.\n") -test.must_match(obj_ + 'test10' + _obj, "This is a .F77 file.\n") +if not is_windows: + # Skip checking files we expect to differ in behavior + # based on file extension case + test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") + test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") + test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") + test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") + test.must_match(obj_ + 'test10' + _obj, "This is a .F77 file.\n") test.pass_test() diff --git a/test/Fortran/SHF90COM.py b/test/Fortran/SHF90COM.py index 9eef8b6..f66c347 100644 --- a/test/Fortran/SHF90COM.py +++ b/test/Fortran/SHF90COM.py @@ -25,6 +25,10 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys + +is_windows = ( sys.platform =='win32') + _python_ = TestSCons._python_ _obj = TestSCons._shobj @@ -72,18 +76,21 @@ test.write('test22.F90', "This is a .F90 file.\n/*f90pp*/\n") test.run(arguments = '.', stderr = None) test.must_match(obj_ + 'test01' + _obj, "This is a .f file.\n") -test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") test.must_match(obj_ + 'test03' + _obj, "This is a .for file.\n") -test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") test.must_match(obj_ + 'test05' + _obj, "This is a .ftn file.\n") -test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") test.must_match(obj_ + 'test07' + _obj, "This is a .fpp file.\n") -test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") test.must_match(obj_ + 'test11' + _obj, "This is a .f90 file.\n") -test.must_match(obj_ + 'test12' + _obj, "This is a .F90 file.\n") test.must_match(obj_ + 'test21' + _obj, "This is a .f90 file.\n") -test.must_match(obj_ + 'test22' + _obj, "This is a .F90 file.\n") +if not is_windows: + # Skip checking files we expect to differ in behavior + # based on file extension case + test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") + test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") + test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") + test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") + test.must_match(obj_ + 'test12' + _obj, "This is a .F90 file.\n") + test.must_match(obj_ + 'test22' + _obj, "This is a .F90 file.\n") test.pass_test() diff --git a/test/Fortran/SHF95COM.py b/test/Fortran/SHF95COM.py index e31cf45..85de45e 100644 --- a/test/Fortran/SHF95COM.py +++ b/test/Fortran/SHF95COM.py @@ -25,6 +25,9 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys + +is_windows = ( sys.platform =='win32') _python_ = TestSCons._python_ _obj = TestSCons._shobj @@ -72,18 +75,21 @@ test.write('test22.F95', "This is a .F95 file.\n/*f95pp*/\n") test.run(arguments = '.', stderr = None) test.must_match(obj_ + 'test01' + _obj, "This is a .f file.\n") -test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") test.must_match(obj_ + 'test03' + _obj, "This is a .for file.\n") -test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") test.must_match(obj_ + 'test05' + _obj, "This is a .ftn file.\n") -test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") test.must_match(obj_ + 'test07' + _obj, "This is a .fpp file.\n") -test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") test.must_match(obj_ + 'test13' + _obj, "This is a .f95 file.\n") -test.must_match(obj_ + 'test14' + _obj, "This is a .F95 file.\n") test.must_match(obj_ + 'test21' + _obj, "This is a .f95 file.\n") -test.must_match(obj_ + 'test22' + _obj, "This is a .F95 file.\n") +if not is_windows: + # Skip checking files we expect to differ in behavior + # based on file extension case + test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") + test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") + test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") + test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") + test.must_match(obj_ + 'test14' + _obj, "This is a .F95 file.\n") + test.must_match(obj_ + 'test22' + _obj, "This is a .F95 file.\n") test.pass_test() diff --git a/test/Fortran/SHFORTRANCOM.py b/test/Fortran/SHFORTRANCOM.py index 56958b2..5c42864 100644 --- a/test/Fortran/SHFORTRANCOM.py +++ b/test/Fortran/SHFORTRANCOM.py @@ -25,6 +25,9 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys + +is_windows = ( sys.platform =='win32') _python_ = TestSCons._python_ _obj = TestSCons._shobj @@ -59,13 +62,16 @@ test.write('test08.FPP', "This is a .FPP file.\n/*fortranpp*/\n") test.run(arguments = '.', stderr = None) test.must_match(obj_ + 'test01' + _obj, "This is a .f file.\n") -test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") test.must_match(obj_ + 'test03' + _obj, "This is a .for file.\n") -test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") test.must_match(obj_ + 'test05' + _obj, "This is a .ftn file.\n") -test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") test.must_match(obj_ + 'test07' + _obj, "This is a .fpp file.\n") -test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") +if not is_windows: + # Skip checking files we expect to differ in behavior + # based on file extension case + test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") + test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") + test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") + test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") test.pass_test() diff --git a/test/M4/M4.py b/test/M4/M4.py index 4306558..76010e6 100644 --- a/test/M4/M4.py +++ b/test/M4/M4.py @@ -59,7 +59,13 @@ line 3 test.run() -test.must_match(test.workpath('aaa.x'), "line 1\nmym4.py\nline 3\n") +import sys + +if sys.platform == 'win32': + # Handle carriage returns. + test.must_match(test.workpath('aaa.x'), "line 1\r\nmym4.py\r\nline 3\r\n") +else: + test.must_match(test.workpath('aaa.x'), "line 1\nmym4.py\nline 3\n") -- cgit v0.12 From a3aa375f59535bfbe0aecdaabdeb40bc419125e1 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 28 Nov 2016 10:35:43 -0800 Subject: fix test to work after updates to ar.py tool --- test/RANLIB/RANLIBFLAGS.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/RANLIB/RANLIBFLAGS.py b/test/RANLIB/RANLIBFLAGS.py index 0de0cdc..e13bac8 100644 --- a/test/RANLIB/RANLIBFLAGS.py +++ b/test/RANLIB/RANLIBFLAGS.py @@ -42,8 +42,8 @@ test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(LIBS = ['foo'], LIBPATH = ['.']) -bar = Environment(LIBS = ['bar'], LIBPATH = ['.'], RANLIB = '', - RANLIBFLAGS = foo.subst(r'%(_python_)s wrapper.py $RANLIB $RANLIBFLAGS')) +bar = Environment(LIBS = ['bar'], LIBPATH = ['.'], RANLIB = r'%(_python_)s wrapper.py', + RANLIBFLAGS = foo.subst(r'$RANLIB $RANLIBFLAGS')) foo.Library(target = 'foo', source = 'foo.c') bar.Library(target = 'bar', source = 'bar.c') -- cgit v0.12 From 055dc8f39e8b0d175a7acdd5977bb35b152ad170 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Mon, 28 Nov 2016 20:25:38 -0500 Subject: Fixing merge conflict resolution: removed old test files. --- test/CC/shared-fixture/.exclude_tests | 1 - test/CC/shared-fixture/mycc.py | 6 ------ test/CC/shared-fixture/test1.c | 2 -- test/YACC/YACCCOM-fixture/.exclude_tests | 1 - test/YACC/YACCCOM-fixture/myyacc.py | 7 ------- test/YACC/shared-fixture/.exclude_tests | 1 - test/YACC/shared-fixture/aaa.y | 2 -- test/YACC/shared-fixture/bbb.yacc | 2 -- test/ZIP/ZIPCOM-fixture/.exclude_tests | 1 - test/ZIP/ZIPCOM-fixture/myzip.py | 6 ------ test/ZIP/ZIPCOM-fixture/test1.in | 2 -- test/ZIP/ZIPCOMSTR-fixture/.exclude_tests | 1 - test/ZIP/ZIPCOMSTR-fixture/aaa.in | 2 -- test/ZIP/ZIPCOMSTR-fixture/myzip.py | 7 ------- 14 files changed, 41 deletions(-) delete mode 100644 test/CC/shared-fixture/.exclude_tests delete mode 100644 test/CC/shared-fixture/mycc.py delete mode 100644 test/CC/shared-fixture/test1.c delete mode 100644 test/YACC/YACCCOM-fixture/.exclude_tests delete mode 100644 test/YACC/YACCCOM-fixture/myyacc.py delete mode 100644 test/YACC/shared-fixture/.exclude_tests delete mode 100644 test/YACC/shared-fixture/aaa.y delete mode 100644 test/YACC/shared-fixture/bbb.yacc delete mode 100644 test/ZIP/ZIPCOM-fixture/.exclude_tests delete mode 100644 test/ZIP/ZIPCOM-fixture/myzip.py delete mode 100644 test/ZIP/ZIPCOM-fixture/test1.in delete mode 100644 test/ZIP/ZIPCOMSTR-fixture/.exclude_tests delete mode 100644 test/ZIP/ZIPCOMSTR-fixture/aaa.in delete mode 100644 test/ZIP/ZIPCOMSTR-fixture/myzip.py diff --git a/test/CC/shared-fixture/.exclude_tests b/test/CC/shared-fixture/.exclude_tests deleted file mode 100644 index 3f2bc0f..0000000 --- a/test/CC/shared-fixture/.exclude_tests +++ /dev/null @@ -1 +0,0 @@ -mycc.py diff --git a/test/CC/shared-fixture/mycc.py b/test/CC/shared-fixture/mycc.py deleted file mode 100644 index b96c31c..0000000 --- a/test/CC/shared-fixture/mycc.py +++ /dev/null @@ -1,6 +0,0 @@ -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 deleted file mode 100644 index 9c281d7..0000000 --- a/test/CC/shared-fixture/test1.c +++ /dev/null @@ -1,2 +0,0 @@ -test1.c -/*cc*/ diff --git a/test/YACC/YACCCOM-fixture/.exclude_tests b/test/YACC/YACCCOM-fixture/.exclude_tests deleted file mode 100644 index f12c4d0..0000000 --- a/test/YACC/YACCCOM-fixture/.exclude_tests +++ /dev/null @@ -1 +0,0 @@ -myyacc.py diff --git a/test/YACC/YACCCOM-fixture/myyacc.py b/test/YACC/YACCCOM-fixture/myyacc.py deleted file mode 100644 index 1502800..0000000 --- a/test/YACC/YACCCOM-fixture/myyacc.py +++ /dev/null @@ -1,7 +0,0 @@ -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/shared-fixture/.exclude_tests b/test/YACC/shared-fixture/.exclude_tests deleted file mode 100644 index f12c4d0..0000000 --- a/test/YACC/shared-fixture/.exclude_tests +++ /dev/null @@ -1 +0,0 @@ -myyacc.py diff --git a/test/YACC/shared-fixture/aaa.y b/test/YACC/shared-fixture/aaa.y deleted file mode 100644 index f7f4cc7..0000000 --- a/test/YACC/shared-fixture/aaa.y +++ /dev/null @@ -1,2 +0,0 @@ -aaa.y -/*yacc*/ diff --git a/test/YACC/shared-fixture/bbb.yacc b/test/YACC/shared-fixture/bbb.yacc deleted file mode 100644 index b3c856f..0000000 --- a/test/YACC/shared-fixture/bbb.yacc +++ /dev/null @@ -1,2 +0,0 @@ -bbb.yacc -/*yacc*/ diff --git a/test/ZIP/ZIPCOM-fixture/.exclude_tests b/test/ZIP/ZIPCOM-fixture/.exclude_tests deleted file mode 100644 index dae6f60..0000000 --- a/test/ZIP/ZIPCOM-fixture/.exclude_tests +++ /dev/null @@ -1 +0,0 @@ -myzip.py diff --git a/test/ZIP/ZIPCOM-fixture/myzip.py b/test/ZIP/ZIPCOM-fixture/myzip.py deleted file mode 100644 index adbc6ac..0000000 --- a/test/ZIP/ZIPCOM-fixture/myzip.py +++ /dev/null @@ -1,6 +0,0 @@ -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 deleted file mode 100644 index 0546626..0000000 --- a/test/ZIP/ZIPCOM-fixture/test1.in +++ /dev/null @@ -1,2 +0,0 @@ -test1.in -/*zip*/ diff --git a/test/ZIP/ZIPCOMSTR-fixture/.exclude_tests b/test/ZIP/ZIPCOMSTR-fixture/.exclude_tests deleted file mode 100644 index dae6f60..0000000 --- a/test/ZIP/ZIPCOMSTR-fixture/.exclude_tests +++ /dev/null @@ -1 +0,0 @@ -myzip.py diff --git a/test/ZIP/ZIPCOMSTR-fixture/aaa.in b/test/ZIP/ZIPCOMSTR-fixture/aaa.in deleted file mode 100644 index 8474a29..0000000 --- a/test/ZIP/ZIPCOMSTR-fixture/aaa.in +++ /dev/null @@ -1,2 +0,0 @@ -aaa.in -/*zip*/ diff --git a/test/ZIP/ZIPCOMSTR-fixture/myzip.py b/test/ZIP/ZIPCOMSTR-fixture/myzip.py deleted file mode 100644 index f0fcc51..0000000 --- a/test/ZIP/ZIPCOMSTR-fixture/myzip.py +++ /dev/null @@ -1,7 +0,0 @@ -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) -- cgit v0.12 From 810413128c22359f06c7bd0f7de4840fe5657c31 Mon Sep 17 00:00:00 2001 From: Rick Lupton Date: Tue, 29 Nov 2016 08:02:08 +0000 Subject: Skip import.sty test when Latex package missing --- test/TEX/recursive_scanner_dependencies_import.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/TEX/recursive_scanner_dependencies_import.py b/test/TEX/recursive_scanner_dependencies_import.py index d9d2625..b31dfbe 100644 --- a/test/TEX/recursive_scanner_dependencies_import.py +++ b/test/TEX/recursive_scanner_dependencies_import.py @@ -34,6 +34,7 @@ dependencies are found only by the scanner. """ +import os import TestSCons test = TestSCons.TestSCons() @@ -43,6 +44,10 @@ pdflatex = test.where_is('pdflatex') if not pdflatex: test.skip_test("Could not find pdflatex; skipping test(s).\n") +latex_import = os.system('kpsewhich import.sty') +if latex_import != 0: + test.skip_test("import.sty not installed; skipping test(s).\n") + test.subdir('subdir') test.subdir('subdir/subdir2') -- cgit v0.12 From a559337466acf9fd91bf266fab72946ebbb64632 Mon Sep 17 00:00:00 2001 From: mbyt Date: Tue, 29 Nov 2016 20:07:10 +0100 Subject: fixing typo, it must be _scons_file --- src/engine/SCons/Platform/win32.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/Platform/win32.py b/src/engine/SCons/Platform/win32.py index cb82df3..98094b3 100644 --- a/src/engine/SCons/Platform/win32.py +++ b/src/engine/SCons/Platform/win32.py @@ -89,7 +89,7 @@ else: _builtin_file.__init__(self, *args, **kw) win32api.SetHandleInformation(msvcrt.get_osfhandle(self.fileno()), win32con.HANDLE_FLAG_INHERIT, 0) - setattr(io, io_class, _builtin_file) + setattr(io, io_class, _scons_file) try: -- cgit v0.12 From ef27873089f3b3e7520925eb347ab274c90bb17e Mon Sep 17 00:00:00 2001 From: William Deegan Date: Wed, 21 Dec 2016 12:28:01 -0800 Subject: fixes get function/object signatures working on python 3 (and 2.7) --- src/engine/SCons/Action.py | 36 +++++++++++++++++++++++------------- src/engine/SCons/ActionTests.py | 10 ++++++---- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index de9bf5c..b8fbe85 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -204,17 +204,17 @@ def _object_contents(obj): # Test if obj is a function object. return _function_contents(obj) - except AttributeError: - # Should be a pickable Python object. + except AttributeError as ae: + # Should be a pickle-able Python object. try: return pickle.dumps(obj) - except (pickle.PicklingError, TypeError): + except (pickle.PicklingError, TypeError, AttributeError): # This is weird, but it seems that nested classes # are unpickable. The Python docs say it should # always be a PicklingError, but some Python # versions seem to return TypeError. Just do # the best we can. - return str(obj) + return repr(obj) def _code_contents(code): @@ -233,8 +233,11 @@ def _code_contents(code): # The code contents depends on the number of local variables # but not their actual names. - contents.append(b"{}, {}".format(code.co_argcount, len(code.co_varnames))) - contents.append(b", {}, {}".format(len(code.co_cellvars), len(code.co_freevars))) + contents.append(bytes("{}, {}".format(code.co_argcount, len(code.co_varnames)),'utf-8')) + # part1 = str(code.co_argcount) + ", " + str(len(code.co_varnames)) + + contents.append(bytes(", {}, {}".format(len(code.co_cellvars), len(code.co_freevars)),'utf-8')) + # part2 = ", " + str(len(code.co_cellvars)) + ", " + str(len(code.co_freevars)) # The code contents depends on any constants accessed by the # function. Note that we have to call _object_contents on each @@ -244,14 +247,19 @@ def _code_contents(code): # Note that we also always ignore the first entry of co_consts # which contains the function doc string. We assume that the # function does not access its doc string. - contents.append(b',(' + b','.join(map(_object_contents,code.co_consts[1:])) + b')') + z= [str(_object_contents(cc)) for cc in code.co_consts[1:]] + # import pdb; pdb.set_trace() + # print("BLAH:%s"%code.co_consts) + # contents.append(bytes(',(' + ','.join(map(_object_contents,code.co_consts[1:])) + ')','utf-8')) + contents.append(bytes(',(' + ','.join(z) + ')','utf-8')) # The code contents depends on the variable names used to # accessed global variable, as changing the variable name changes # the variable actually accessed and therefore changes the # function result. - contents.append(b',(' + b','.join(map(_object_contents,code.co_names)) + b')') - + z= [str(_object_contents(cc)) for cc in code.co_names] + # contents.append(bytes(',(' + ','.join(map(_object_contents,code.co_names)) + ')','utf-8')) + contents.append(bytes(',(' + ','.join(z) + ')','utf-8')) # The code contents depends on its actual code!!! contents.append(b',(' + remove_set_lineno_codes(code.co_code) + b')') @@ -266,7 +274,9 @@ def _function_contents(func): # The function contents depends on the value of defaults arguments if func.__defaults__: - contents.append(b',(' + b','.join(map(_object_contents,func.__defaults__)) + b')') + z = [str(_object_contents(cc)) for cc in func.__defaults__] + + contents.append(bytes(',(' + ','.join(z) + ')','utf-8')) else: contents.append(b',()') @@ -1171,15 +1181,15 @@ class ActionCaller(object): actfunc = self.parent.actfunc try: # "self.actfunc" is a function. - contents = str(actfunc.__code__.co_code) + contents = bytes(actfunc.__code__.co_code) except AttributeError: # "self.actfunc" is a callable object. try: - contents = str(actfunc.__call__.__func__.__code__.co_code) + contents = actfunc.__call__.__func__.__code__.co_code except AttributeError: # No __call__() method, so it might be a builtin # or something like that. Do the best we can. - contents = str(actfunc) + contents = repr(actfunc) contents = remove_set_lineno_codes(contents) return contents diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py index b790ccc..b88958c 100644 --- a/src/engine/SCons/ActionTests.py +++ b/src/engine/SCons/ActionTests.py @@ -1858,13 +1858,13 @@ class ActionCallerTestCase(unittest.TestCase): matches = [ b"d\000\000S", - b"d\x00\x00S" + b"d\\x00\\x00S" ] af = SCons.Action.ActionFactory(GlobalFunc, strfunc) ac = SCons.Action.ActionCaller(af, [], {}) c = ac.get_contents([], [], Environment()) - assert c in matches, repr(c) + assert c in matches, "C [%s] not in matches [%s]"%(repr(c),matches) af = SCons.Action.ActionFactory(LocalFunc, strfunc) ac = SCons.Action.ActionCaller(af, [], {}) @@ -1883,7 +1883,7 @@ class ActionCallerTestCase(unittest.TestCase): af = SCons.Action.ActionFactory(GlobalActFunc(), strfunc) ac = SCons.Action.ActionCaller(af, [], {}) c = ac.get_contents([], [], Environment()) - assert c in matches, repr(c) + assert c in matches, "C [%s] not in matches [%s]"%(repr(c),matches) af = SCons.Action.ActionFactory(LocalActFunc(), strfunc) ac = SCons.Action.ActionCaller(af, [], {}) @@ -1899,7 +1899,9 @@ class ActionCallerTestCase(unittest.TestCase): ac = SCons.Action.ActionCaller(af, [], {}) c = ac.get_contents([], [], Environment()) assert c == "" or \ - c == "", repr(c) + c == "" or \ + c == "", repr(c) + # ^^ class str for python3 def test___call__(self): """Test calling an ActionCaller""" -- cgit v0.12 From 87c26bc0627fb528862f2a2dc4173074935f4290 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 22 Dec 2016 14:50:55 -0800 Subject: Added some details comments to _code_contents() which is used to generate action signatures. --- src/engine/SCons/Action.py | 52 +++++++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index b8fbe85..e0c8450 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -227,16 +227,37 @@ def _code_contents(code): number indications in the compiled byte code. Boo! So we remove the line number byte codes to prevent recompilations from moving a Python function. + + See: + * https://docs.python.org/2/library/inspect.html + * http://python-reference.readthedocs.io/en/latest/docs/code/index.html + For info on what each co_ variable provides + + The signature is as follows (should be byte/chars): + co_argcount, len(co_varnames), len(co_cellvars), len(co_freevars), + ( comma separated signature for each object in co_consts ), + ( comma separated signature for each object in co_names ), + ( The bytecode with line number bytecodes removed from co_code ) + + co_argcount - Returns the number of positional arguments (including arguments with default values). + co_varnames - Returns a tuple containing the names of the local variables (starting with the argument names). + co_cellvars - Returns a tuple containing the names of local variables that are referenced by nested functions. + co_freevars - Returns a tuple containing the names of free variables. (?) + co_consts - Returns a tuple containing the literals used by the bytecode. + co_names - Returns a tuple containing the names used by the bytecode. + co_code - Returns a string representing the sequence of bytecode instructions. + """ - contents = [] + # contents = [] # The code contents depends on the number of local variables # but not their actual names. - contents.append(bytes("{}, {}".format(code.co_argcount, len(code.co_varnames)),'utf-8')) + contents = bytearray("{}, {}".format(code.co_argcount, len(code.co_varnames)),'utf-8') + # part1 = str(code.co_argcount) + ", " + str(len(code.co_varnames)) - contents.append(bytes(", {}, {}".format(len(code.co_cellvars), len(code.co_freevars)),'utf-8')) + contents.append(bytearray(", {}, {}".format(len(code.co_cellvars), len(code.co_freevars)),'utf-8')) # part2 = ", " + str(len(code.co_cellvars)) + ", " + str(len(code.co_freevars)) # The code contents depends on any constants accessed by the @@ -248,23 +269,21 @@ def _code_contents(code): # which contains the function doc string. We assume that the # function does not access its doc string. z= [str(_object_contents(cc)) for cc in code.co_consts[1:]] - # import pdb; pdb.set_trace() - # print("BLAH:%s"%code.co_consts) - # contents.append(bytes(',(' + ','.join(map(_object_contents,code.co_consts[1:])) + ')','utf-8')) - contents.append(bytes(',(' + ','.join(z) + ')','utf-8')) + # contents.append(bytearray(',(' + ','.join(map(_object_contents,code.co_consts[1:])) + ')','utf-8')) + contents.append(bytearray(',(' + ','.join(z) + ')','utf-8')) # The code contents depends on the variable names used to # accessed global variable, as changing the variable name changes # the variable actually accessed and therefore changes the # function result. z= [str(_object_contents(cc)) for cc in code.co_names] - # contents.append(bytes(',(' + ','.join(map(_object_contents,code.co_names)) + ')','utf-8')) - contents.append(bytes(',(' + ','.join(z) + ')','utf-8')) + # contents.append(bytearray(',(' + ','.join(map(_object_contents,code.co_names)) + ')','utf-8')) + contents.append(bytearray(',(' + ','.join(z) + ')','utf-8')) # The code contents depends on its actual code!!! - contents.append(b',(' + remove_set_lineno_codes(code.co_code) + b')') + contents.append(bytearray(',(','utf-8') + remove_set_lineno_codes(code.co_code) + bytearray(')','utf-8')) - return b''.join(contents) + return bytearray('').join(contents) def _function_contents(func): @@ -276,7 +295,7 @@ def _function_contents(func): if func.__defaults__: z = [str(_object_contents(cc)) for cc in func.__defaults__] - contents.append(bytes(',(' + ','.join(z) + ')','utf-8')) + contents.append(bytearray(',(','utf-8') + b','.join(z) + bytearray(')','utf-8')) else: contents.append(b',()') @@ -290,7 +309,7 @@ def _function_contents(func): xxx = [] contents.append(b',(' + ','.join(xxx).encode('ascii') + b')') - return b''.join(contents) + return bytearray('','utf-8').join(contents) def _actionAppend(act1, act2): @@ -415,6 +434,7 @@ def Action(act, *args, **kw): return _do_create_list_action(act, kw) return _do_create_action(act, kw) + class ActionBase(object): """Base class for all types of action objects that can be held by other objects (Builders, Executors, etc.) This provides the @@ -442,6 +462,7 @@ class ActionBase(object): for v in vl: # do the subst this way to ignore $(...$) parts: result.append(SCons.Util.to_bytes(env.subst_target_source('${'+v+'}', SCons.Subst.SUBST_SIG, target, source))) + return b''.join(result) def __add__(self, other): @@ -472,6 +493,7 @@ class ActionBase(object): """ return self.targets + class _ActionAction(ActionBase): """Base class for actions that create output objects.""" def __init__(self, cmdstr=_null, strfunction=_null, varlist=(), @@ -1163,6 +1185,7 @@ class ListAction(ActionBase): result[var] = True return list(result.keys()) + class ActionCaller(object): """A class for delaying calling an Action function with specific (positional and keyword) arguments until the Action is actually @@ -1181,7 +1204,7 @@ class ActionCaller(object): actfunc = self.parent.actfunc try: # "self.actfunc" is a function. - contents = bytes(actfunc.__code__.co_code) + contents = bytearray(actfunc.__code__.co_code,'utf-8') except AttributeError: # "self.actfunc" is a callable object. try: @@ -1233,6 +1256,7 @@ class ActionCaller(object): def __str__(self): return self.parent.strfunc(*self.args, **self.kw) + class ActionFactory(object): """A factory class that will wrap up an arbitrary function as an SCons-executable Action object. -- cgit v0.12 From 3ba8ac0c4c2b9c92e2b15a6623ad2181931b0e2f Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 22 Dec 2016 15:23:50 -0800 Subject: Added some details comments to _function_contents() which is used to generate action signatures. --- src/engine/SCons/Action.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index e0c8450..08e36c5 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -287,15 +287,24 @@ def _code_contents(code): def _function_contents(func): - """Return the signature contents of a function.""" + """Return the signature contents of a function. + + The signature is as follows (should be byte/chars): + ,( comma separated _object_contents for function argument defaults) + ,( comma separated _object_contents for any closure contents ) + + func.__code__ - Code object for function + func.__defaults__ - Tuple of function argument default values + func.__closure__ - + """ contents = [_code_contents(func.__code__)] # The function contents depends on the value of defaults arguments if func.__defaults__: - z = [str(_object_contents(cc)) for cc in func.__defaults__] + function_defaults_contents = [str(_object_contents(cc)) for cc in func.__defaults__] - contents.append(bytearray(',(','utf-8') + b','.join(z) + bytearray(')','utf-8')) + contents.append(bytearray(',(','utf-8') + b','.join(function_defaults_contents) + bytearray(')','utf-8')) else: contents.append(b',()') @@ -304,10 +313,10 @@ def _function_contents(func): #xxx = [_object_contents(x.cell_contents) for x in closure] try: - xxx = [_object_contents(x.cell_contents) for x in closure] + closure_contents = [_object_contents(x.cell_contents) for x in closure] except AttributeError: - xxx = [] - contents.append(b',(' + ','.join(xxx).encode('ascii') + b')') + closure_contents = [] + contents.append(b',(' + ','.join(closure_contents).encode('ascii') + b')') return bytearray('','utf-8').join(contents) -- cgit v0.12 From edfd89550e6aa41696408a0280014ac8cc73e8b3 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 22 Dec 2016 16:38:11 -0800 Subject: Added some details comments to _function_contents() which is used to generate action signatures. --- src/engine/SCons/Action.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index 08e36c5..8fa672b 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -293,9 +293,10 @@ def _function_contents(func): ,( comma separated _object_contents for function argument defaults) ,( comma separated _object_contents for any closure contents ) - func.__code__ - Code object for function - func.__defaults__ - Tuple of function argument default values - func.__closure__ - + func.__code__ - The code object representing the compiled function body. + func.__defaults__ - A tuple containing default argument values for those arguments + that have defaults, or None if no arguments have a default value + func.__closure__ - None or a tuple of cells that contain bindings for the function's free variables. """ contents = [_code_contents(func.__code__)] -- cgit v0.12 From fd9f5268efe071386ce1245670a1be6a0246225c Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 22 Dec 2016 16:59:24 -0800 Subject: Added some details comments to _function_contents() which is used to generate action signatures. Remove remove_set_lineno_codes(), it's been non-function due to SET_LINENO being gone since python 2.3. --- src/engine/SCons/Action.py | 29 +++++------------------------ src/engine/SCons/ActionTests.py | 1 + 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index 8fa672b..4e17f19 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -132,28 +132,6 @@ def rfile(n): def default_exitstatfunc(s): return s -try: - SET_LINENO = dis.SET_LINENO - HAVE_ARGUMENT = dis.HAVE_ARGUMENT -except AttributeError: - remove_set_lineno_codes = lambda x: x -else: - def remove_set_lineno_codes(code): - result = [] - n = len(code) - i = 0 - while i < n: - c = code[i] - op = ord(c) - if op >= HAVE_ARGUMENT: - if op != SET_LINENO: - result.append(code[i:i+3]) - i = i+3 - else: - result.append(c) - i = i+1 - return ''.join(result) - strip_quotes = re.compile('^[\'"](.*)[\'"]$') @@ -281,7 +259,7 @@ def _code_contents(code): contents.append(bytearray(',(' + ','.join(z) + ')','utf-8')) # The code contents depends on its actual code!!! - contents.append(bytearray(',(','utf-8') + remove_set_lineno_codes(code.co_code) + bytearray(')','utf-8')) + contents.append(bytearray(',(','utf-8') + code.co_code + bytearray(')','utf-8')) return bytearray('').join(contents) @@ -290,9 +268,12 @@ def _function_contents(func): """Return the signature contents of a function. The signature is as follows (should be byte/chars): + < _code_contents (see above) from func.__code__ > ,( comma separated _object_contents for function argument defaults) ,( comma separated _object_contents for any closure contents ) + + See also: https://docs.python.org/3/reference/datamodel.html func.__code__ - The code object representing the compiled function body. func.__defaults__ - A tuple containing default argument values for those arguments that have defaults, or None if no arguments have a default value @@ -1223,7 +1204,7 @@ class ActionCaller(object): # No __call__() method, so it might be a builtin # or something like that. Do the best we can. contents = repr(actfunc) - contents = remove_set_lineno_codes(contents) + return contents def subst(self, s, target, source, env): diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py index b88958c..711b1b6 100644 --- a/src/engine/SCons/ActionTests.py +++ b/src/engine/SCons/ActionTests.py @@ -1840,6 +1840,7 @@ class LazyActionTestCase(unittest.TestCase): c = a.get_contents(target=[], source=[], env=env) assert c in matches_foo, repr(c) + class ActionCallerTestCase(unittest.TestCase): def test___init__(self): """Test creation of an ActionCaller""" -- cgit v0.12 From 7e55f7120bf5b54d12a8f1ab01ad36da3b930bc5 Mon Sep 17 00:00:00 2001 From: Jason Kenny Date: Fri, 23 Dec 2016 13:02:02 -0600 Subject: Make c++ proxy files to the cxx forms Change the old c++ files to be cxx to help make it easier and safer to import correctly --- src/engine/SCons/Tool/aixc++.py | 36 +--------- src/engine/SCons/Tool/aixcxx.py | 75 +++++++++++++++++++++ src/engine/SCons/Tool/c++.py | 60 +---------------- src/engine/SCons/Tool/cxx.py | 100 ++++++++++++++++++++++++++++ src/engine/SCons/Tool/g++.py | 38 +---------- src/engine/SCons/Tool/gxx.py | 79 ++++++++++++++++++++++ src/engine/SCons/Tool/hpc++.py | 43 +----------- src/engine/SCons/Tool/hpcxx.py | 84 ++++++++++++++++++++++++ src/engine/SCons/Tool/sgic++.py | 19 +----- src/engine/SCons/Tool/sgicxx.py | 58 ++++++++++++++++ src/engine/SCons/Tool/sunc++.py | 101 +--------------------------- src/engine/SCons/Tool/suncxx.py | 142 ++++++++++++++++++++++++++++++++++++++++ 12 files changed, 550 insertions(+), 285 deletions(-) create mode 100644 src/engine/SCons/Tool/aixcxx.py create mode 100644 src/engine/SCons/Tool/cxx.py create mode 100644 src/engine/SCons/Tool/gxx.py create mode 100644 src/engine/SCons/Tool/hpcxx.py create mode 100644 src/engine/SCons/Tool/sgicxx.py create mode 100644 src/engine/SCons/Tool/suncxx.py diff --git a/src/engine/SCons/Tool/aixc++.py b/src/engine/SCons/Tool/aixc++.py index f03f763..c3efaea 100644 --- a/src/engine/SCons/Tool/aixc++.py +++ b/src/engine/SCons/Tool/aixc++.py @@ -33,40 +33,8 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import os.path - -import SCons.Platform.aix - -cplusplus = __import__('c++', globals(), locals(), []) - -packages = ['vacpp.cmp.core', 'vacpp.cmp.batch', 'vacpp.cmp.C', 'ibmcxx.cmp'] - -def get_xlc(env): - xlc = env.get('CXX', 'xlC') - return SCons.Platform.aix.get_xlc(env, xlc, packages) - -def generate(env): - """Add Builders and construction variables for xlC / Visual Age - suite to an Environment.""" - path, _cxx, version = get_xlc(env) - if path and _cxx: - _cxx = os.path.join(path, _cxx) - - if 'CXX' not in env: - env['CXX'] = _cxx - - cplusplus.generate(env) - - if version: - env['CXXVERSION'] = version - -def exists(env): - path, _cxx, version = get_xlc(env) - if path and _cxx: - xlc = os.path.join(path, _cxx) - if os.path.exists(xlc): - return xlc - return None +#forward proxy to the preffered cxx version +from SCons.Tool.aixcxx import * # Local Variables: # tab-width:4 diff --git a/src/engine/SCons/Tool/aixcxx.py b/src/engine/SCons/Tool/aixcxx.py new file mode 100644 index 0000000..f03f763 --- /dev/null +++ b/src/engine/SCons/Tool/aixcxx.py @@ -0,0 +1,75 @@ +"""SCons.Tool.aixc++ + +Tool-specific initialization for IBM xlC / Visual Age C++ compiler. + +There normally shouldn't be any need to import this module directly. +It will usually be imported through the generic SCons.Tool.Tool() +selection method. + +""" + +# +# __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__" + +import os.path + +import SCons.Platform.aix + +cplusplus = __import__('c++', globals(), locals(), []) + +packages = ['vacpp.cmp.core', 'vacpp.cmp.batch', 'vacpp.cmp.C', 'ibmcxx.cmp'] + +def get_xlc(env): + xlc = env.get('CXX', 'xlC') + return SCons.Platform.aix.get_xlc(env, xlc, packages) + +def generate(env): + """Add Builders and construction variables for xlC / Visual Age + suite to an Environment.""" + path, _cxx, version = get_xlc(env) + if path and _cxx: + _cxx = os.path.join(path, _cxx) + + if 'CXX' not in env: + env['CXX'] = _cxx + + cplusplus.generate(env) + + if version: + env['CXXVERSION'] = version + +def exists(env): + path, _cxx, version = get_xlc(env) + if path and _cxx: + xlc = os.path.join(path, _cxx) + if os.path.exists(xlc): + return xlc + return None + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/src/engine/SCons/Tool/c++.py b/src/engine/SCons/Tool/c++.py index 430851c..6b772fa 100644 --- a/src/engine/SCons/Tool/c++.py +++ b/src/engine/SCons/Tool/c++.py @@ -32,66 +32,10 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import os.path -import SCons.Tool -import SCons.Defaults -import SCons.Util +#forward proxy to the preffered cxx version +from SCons.Tool.cxx import * -compilers = ['CC', 'c++'] - -CXXSuffixes = ['.cpp', '.cc', '.cxx', '.c++', '.C++', '.mm'] -if SCons.Util.case_sensitive_suffixes('.c', '.C'): - CXXSuffixes.append('.C') - -def iscplusplus(source): - if not source: - # Source might be None for unusual cases like SConf. - return 0 - for s in source: - if s.sources: - ext = os.path.splitext(str(s.sources[0]))[1] - if ext in CXXSuffixes: - return 1 - return 0 - -def generate(env): - """ - Add Builders and construction variables for Visual Age C++ compilers - to an Environment. - """ - import SCons.Tool - import SCons.Tool.cc - static_obj, shared_obj = SCons.Tool.createObjBuilders(env) - - for suffix in CXXSuffixes: - static_obj.add_action(suffix, SCons.Defaults.CXXAction) - shared_obj.add_action(suffix, SCons.Defaults.ShCXXAction) - static_obj.add_emitter(suffix, SCons.Defaults.StaticObjectEmitter) - shared_obj.add_emitter(suffix, SCons.Defaults.SharedObjectEmitter) - - SCons.Tool.cc.add_common_cc_variables(env) - - if 'CXX' not in env: - env['CXX'] = env.Detect(compilers) or compilers[0] - env['CXXFLAGS'] = SCons.Util.CLVar('') - env['CXXCOM'] = '$CXX -o $TARGET -c $CXXFLAGS $CCFLAGS $_CCCOMCOM $SOURCES' - env['SHCXX'] = '$CXX' - env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS') - env['SHCXXCOM'] = '$SHCXX -o $TARGET -c $SHCXXFLAGS $SHCCFLAGS $_CCCOMCOM $SOURCES' - - env['CPPDEFPREFIX'] = '-D' - env['CPPDEFSUFFIX'] = '' - env['INCPREFIX'] = '-I' - env['INCSUFFIX'] = '' - env['SHOBJSUFFIX'] = '.os' - env['OBJSUFFIX'] = '.o' - env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 0 - - env['CXXFILESUFFIX'] = '.cc' - -def exists(env): - return env.Detect(env.get('CXX', compilers)) # Local Variables: # tab-width:4 diff --git a/src/engine/SCons/Tool/cxx.py b/src/engine/SCons/Tool/cxx.py new file mode 100644 index 0000000..430851c --- /dev/null +++ b/src/engine/SCons/Tool/cxx.py @@ -0,0 +1,100 @@ +"""SCons.Tool.c++ + +Tool-specific initialization for generic Posix C++ compilers. + +There normally shouldn't be any need to import this module directly. +It will usually be imported through the generic SCons.Tool.Tool() +selection method. +""" + +# +# __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__" + +import os.path + +import SCons.Tool +import SCons.Defaults +import SCons.Util + +compilers = ['CC', 'c++'] + +CXXSuffixes = ['.cpp', '.cc', '.cxx', '.c++', '.C++', '.mm'] +if SCons.Util.case_sensitive_suffixes('.c', '.C'): + CXXSuffixes.append('.C') + +def iscplusplus(source): + if not source: + # Source might be None for unusual cases like SConf. + return 0 + for s in source: + if s.sources: + ext = os.path.splitext(str(s.sources[0]))[1] + if ext in CXXSuffixes: + return 1 + return 0 + +def generate(env): + """ + Add Builders and construction variables for Visual Age C++ compilers + to an Environment. + """ + import SCons.Tool + import SCons.Tool.cc + static_obj, shared_obj = SCons.Tool.createObjBuilders(env) + + for suffix in CXXSuffixes: + static_obj.add_action(suffix, SCons.Defaults.CXXAction) + shared_obj.add_action(suffix, SCons.Defaults.ShCXXAction) + static_obj.add_emitter(suffix, SCons.Defaults.StaticObjectEmitter) + shared_obj.add_emitter(suffix, SCons.Defaults.SharedObjectEmitter) + + SCons.Tool.cc.add_common_cc_variables(env) + + if 'CXX' not in env: + env['CXX'] = env.Detect(compilers) or compilers[0] + env['CXXFLAGS'] = SCons.Util.CLVar('') + env['CXXCOM'] = '$CXX -o $TARGET -c $CXXFLAGS $CCFLAGS $_CCCOMCOM $SOURCES' + env['SHCXX'] = '$CXX' + env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS') + env['SHCXXCOM'] = '$SHCXX -o $TARGET -c $SHCXXFLAGS $SHCCFLAGS $_CCCOMCOM $SOURCES' + + env['CPPDEFPREFIX'] = '-D' + env['CPPDEFSUFFIX'] = '' + env['INCPREFIX'] = '-I' + env['INCSUFFIX'] = '' + env['SHOBJSUFFIX'] = '.os' + env['OBJSUFFIX'] = '.o' + env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 0 + + env['CXXFILESUFFIX'] = '.cc' + +def exists(env): + return env.Detect(env.get('CXX', compilers)) + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/src/engine/SCons/Tool/g++.py b/src/engine/SCons/Tool/g++.py index c5eb579..88d88ca 100644 --- a/src/engine/SCons/Tool/g++.py +++ b/src/engine/SCons/Tool/g++.py @@ -33,44 +33,10 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import os.path -import re -import subprocess -import SCons.Tool -import SCons.Util +#forward proxy to the preffered cxx version +from SCons.Tool.gxx import * -from . import gcc -cplusplus = __import__(__package__+'.c++', globals(), locals(), ['*']) - -compilers = ['g++'] - -def generate(env): - """Add Builders and construction variables for g++ to an Environment.""" - static_obj, shared_obj = SCons.Tool.createObjBuilders(env) - - if 'CXX' not in env: - env['CXX'] = env.Detect(compilers) or compilers[0] - - cplusplus.generate(env) - - # platform specific settings - if env['PLATFORM'] == 'aix': - env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -mminimal-toc') - env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1 - env['SHOBJSUFFIX'] = '$OBJSUFFIX' - elif env['PLATFORM'] == 'hpux': - env['SHOBJSUFFIX'] = '.pic.o' - elif env['PLATFORM'] == 'sunos': - env['SHOBJSUFFIX'] = '.pic.o' - # determine compiler version - version = gcc.detect_version(env, env['CXX']) - if version: - env['CXXVERSION'] = version - -def exists(env): - # is executable, and is a GNU compiler (or accepts '--version' at least) - return gcc.detect_version(env, env.Detect(env.get('CXX', compilers))) # Local Variables: # tab-width:4 diff --git a/src/engine/SCons/Tool/gxx.py b/src/engine/SCons/Tool/gxx.py new file mode 100644 index 0000000..c5eb579 --- /dev/null +++ b/src/engine/SCons/Tool/gxx.py @@ -0,0 +1,79 @@ +"""SCons.Tool.g++ + +Tool-specific initialization for g++. + +There normally shouldn't be any need to import this module directly. +It will usually be imported through the generic SCons.Tool.Tool() +selection method. + +""" + +# +# __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__" + +import os.path +import re +import subprocess + +import SCons.Tool +import SCons.Util + +from . import gcc +cplusplus = __import__(__package__+'.c++', globals(), locals(), ['*']) + +compilers = ['g++'] + +def generate(env): + """Add Builders and construction variables for g++ to an Environment.""" + static_obj, shared_obj = SCons.Tool.createObjBuilders(env) + + if 'CXX' not in env: + env['CXX'] = env.Detect(compilers) or compilers[0] + + cplusplus.generate(env) + + # platform specific settings + if env['PLATFORM'] == 'aix': + env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -mminimal-toc') + env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1 + env['SHOBJSUFFIX'] = '$OBJSUFFIX' + elif env['PLATFORM'] == 'hpux': + env['SHOBJSUFFIX'] = '.pic.o' + elif env['PLATFORM'] == 'sunos': + env['SHOBJSUFFIX'] = '.pic.o' + # determine compiler version + version = gcc.detect_version(env, env['CXX']) + if version: + env['CXXVERSION'] = version + +def exists(env): + # is executable, and is a GNU compiler (or accepts '--version' at least) + return gcc.detect_version(env, env.Detect(env.get('CXX', compilers))) + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/src/engine/SCons/Tool/hpc++.py b/src/engine/SCons/Tool/hpc++.py index 2b8ed3f..9631277 100644 --- a/src/engine/SCons/Tool/hpc++.py +++ b/src/engine/SCons/Tool/hpc++.py @@ -33,49 +33,10 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import os.path -import SCons.Util +#forward proxy to the preffered cxx version +from SCons.Tool.hpcxx import * -cplusplus = __import__('c++', globals(), locals(), []) - -acc = None - -# search for the acc compiler and linker front end - -try: - dirs = os.listdir('/opt') -except (IOError, OSError): - # Not being able to read the directory because it doesn't exist - # (IOError) or isn't readable (OSError) is okay. - dirs = [] - -for dir in dirs: - cc = '/opt/' + dir + '/bin/aCC' - if os.path.exists(cc): - acc = cc - break - - -def generate(env): - """Add Builders and construction variables for g++ to an Environment.""" - cplusplus.generate(env) - - if acc: - env['CXX'] = acc or 'aCC' - env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS +Z') - # determine version of aCC - line = os.popen(acc + ' -V 2>&1').readline().rstrip() - if line.find('aCC: HP ANSI C++') == 0: - env['CXXVERSION'] = line.split()[-1] - - if env['PLATFORM'] == 'cygwin': - env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS') - else: - env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS +Z') - -def exists(env): - return acc # Local Variables: # tab-width:4 diff --git a/src/engine/SCons/Tool/hpcxx.py b/src/engine/SCons/Tool/hpcxx.py new file mode 100644 index 0000000..2b8ed3f --- /dev/null +++ b/src/engine/SCons/Tool/hpcxx.py @@ -0,0 +1,84 @@ +"""SCons.Tool.hpc++ + +Tool-specific initialization for c++ on HP/UX. + +There normally shouldn't be any need to import this module directly. +It will usually be imported through the generic SCons.Tool.Tool() +selection method. + +""" + +# +# __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__" + +import os.path + +import SCons.Util + +cplusplus = __import__('c++', globals(), locals(), []) + +acc = None + +# search for the acc compiler and linker front end + +try: + dirs = os.listdir('/opt') +except (IOError, OSError): + # Not being able to read the directory because it doesn't exist + # (IOError) or isn't readable (OSError) is okay. + dirs = [] + +for dir in dirs: + cc = '/opt/' + dir + '/bin/aCC' + if os.path.exists(cc): + acc = cc + break + + +def generate(env): + """Add Builders and construction variables for g++ to an Environment.""" + cplusplus.generate(env) + + if acc: + env['CXX'] = acc or 'aCC' + env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS +Z') + # determine version of aCC + line = os.popen(acc + ' -V 2>&1').readline().rstrip() + if line.find('aCC: HP ANSI C++') == 0: + env['CXXVERSION'] = line.split()[-1] + + if env['PLATFORM'] == 'cygwin': + env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS') + else: + env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS +Z') + +def exists(env): + return acc + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/src/engine/SCons/Tool/sgic++.py b/src/engine/SCons/Tool/sgic++.py index 35547ac..63c66e2 100644 --- a/src/engine/SCons/Tool/sgic++.py +++ b/src/engine/SCons/Tool/sgic++.py @@ -33,23 +33,8 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import SCons.Util - -cplusplus = __import__('c++', globals(), locals(), []) - -def generate(env): - """Add Builders and construction variables for SGI MIPS C++ to an Environment.""" - - cplusplus.generate(env) - - env['CXX'] = 'CC' - env['CXXFLAGS'] = SCons.Util.CLVar('-LANG:std') - env['SHCXX'] = '$CXX' - env['SHOBJSUFFIX'] = '.o' - env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1 - -def exists(env): - return env.Detect('CC') +#forward proxy to the preffered cxx version +from SCons.Tool.sgicxx import * # Local Variables: # tab-width:4 diff --git a/src/engine/SCons/Tool/sgicxx.py b/src/engine/SCons/Tool/sgicxx.py new file mode 100644 index 0000000..35547ac --- /dev/null +++ b/src/engine/SCons/Tool/sgicxx.py @@ -0,0 +1,58 @@ +"""SCons.Tool.sgic++ + +Tool-specific initialization for MIPSpro C++ on SGI. + +There normally shouldn't be any need to import this module directly. +It will usually be imported through the generic SCons.Tool.Tool() +selection method. + +""" + +# +# __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__" + +import SCons.Util + +cplusplus = __import__('c++', globals(), locals(), []) + +def generate(env): + """Add Builders and construction variables for SGI MIPS C++ to an Environment.""" + + cplusplus.generate(env) + + env['CXX'] = 'CC' + env['CXXFLAGS'] = SCons.Util.CLVar('-LANG:std') + env['SHCXX'] = '$CXX' + env['SHOBJSUFFIX'] = '.o' + env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1 + +def exists(env): + return env.Detect('CC') + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/src/engine/SCons/Tool/sunc++.py b/src/engine/SCons/Tool/sunc++.py index 49f90ea..3304f80 100644 --- a/src/engine/SCons/Tool/sunc++.py +++ b/src/engine/SCons/Tool/sunc++.py @@ -33,107 +33,10 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import SCons -import os -import re -import subprocess +#forward proxy to the preffered cxx version +from SCons.Tool.suncxx import * -cplusplus = __import__('c++', globals(), locals(), []) - -package_info = {} - -def get_package_info(package_name, pkginfo, pkgchk): - try: - return package_info[package_name] - except KeyError: - version = None - pathname = None - try: - sadm_contents = open('/var/sadm/install/contents', 'r').read() - except EnvironmentError: - pass - else: - sadm_re = re.compile('^(\S*/bin/CC)(=\S*)? %s$' % package_name, re.M) - sadm_match = sadm_re.search(sadm_contents) - if sadm_match: - pathname = os.path.dirname(sadm_match.group(1)) - - try: - p = subprocess.Popen([pkginfo, '-l', package_name], - stdout=subprocess.PIPE, - stderr=open('/dev/null', 'w')) - except EnvironmentError: - pass - else: - pkginfo_contents = p.communicate()[0] - version_re = re.compile('^ *VERSION:\s*(.*)$', re.M) - version_match = version_re.search(pkginfo_contents) - if version_match: - version = version_match.group(1) - - if pathname is None: - try: - p = subprocess.Popen([pkgchk, '-l', package_name], - stdout=subprocess.PIPE, - stderr=open('/dev/null', 'w')) - except EnvironmentError: - pass - else: - pkgchk_contents = p.communicate()[0] - pathname_re = re.compile(r'^Pathname:\s*(.*/bin/CC)$', re.M) - pathname_match = pathname_re.search(pkgchk_contents) - if pathname_match: - pathname = os.path.dirname(pathname_match.group(1)) - - package_info[package_name] = (pathname, version) - return package_info[package_name] - -# use the package installer tool lslpp to figure out where cppc and what -# version of it is installed -def get_cppc(env): - cxx = env.subst('$CXX') - if cxx: - cppcPath = os.path.dirname(cxx) - else: - cppcPath = None - - cppcVersion = None - - pkginfo = env.subst('$PKGINFO') - pkgchk = env.subst('$PKGCHK') - - for package in ['SPROcpl']: - path, version = get_package_info(package, pkginfo, pkgchk) - if path and version: - cppcPath, cppcVersion = path, version - break - - return (cppcPath, 'CC', 'CC', cppcVersion) - -def generate(env): - """Add Builders and construction variables for SunPRO C++.""" - path, cxx, shcxx, version = get_cppc(env) - if path: - cxx = os.path.join(path, cxx) - shcxx = os.path.join(path, shcxx) - - cplusplus.generate(env) - - env['CXX'] = cxx - env['SHCXX'] = shcxx - env['CXXVERSION'] = version - env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -KPIC') - env['SHOBJPREFIX'] = 'so_' - env['SHOBJSUFFIX'] = '.o' - -def exists(env): - path, cxx, shcxx, version = get_cppc(env) - if path and cxx: - cppc = os.path.join(path, cxx) - if os.path.exists(cppc): - return cppc - return None # Local Variables: # tab-width:4 diff --git a/src/engine/SCons/Tool/suncxx.py b/src/engine/SCons/Tool/suncxx.py new file mode 100644 index 0000000..49f90ea --- /dev/null +++ b/src/engine/SCons/Tool/suncxx.py @@ -0,0 +1,142 @@ +"""SCons.Tool.sunc++ + +Tool-specific initialization for C++ on SunOS / Solaris. + +There normally shouldn't be any need to import this module directly. +It will usually be imported through the generic SCons.Tool.Tool() +selection method. + +""" + +# +# __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__" + +import SCons + +import os +import re +import subprocess + +cplusplus = __import__('c++', globals(), locals(), []) + +package_info = {} + +def get_package_info(package_name, pkginfo, pkgchk): + try: + return package_info[package_name] + except KeyError: + version = None + pathname = None + try: + sadm_contents = open('/var/sadm/install/contents', 'r').read() + except EnvironmentError: + pass + else: + sadm_re = re.compile('^(\S*/bin/CC)(=\S*)? %s$' % package_name, re.M) + sadm_match = sadm_re.search(sadm_contents) + if sadm_match: + pathname = os.path.dirname(sadm_match.group(1)) + + try: + p = subprocess.Popen([pkginfo, '-l', package_name], + stdout=subprocess.PIPE, + stderr=open('/dev/null', 'w')) + except EnvironmentError: + pass + else: + pkginfo_contents = p.communicate()[0] + version_re = re.compile('^ *VERSION:\s*(.*)$', re.M) + version_match = version_re.search(pkginfo_contents) + if version_match: + version = version_match.group(1) + + if pathname is None: + try: + p = subprocess.Popen([pkgchk, '-l', package_name], + stdout=subprocess.PIPE, + stderr=open('/dev/null', 'w')) + except EnvironmentError: + pass + else: + pkgchk_contents = p.communicate()[0] + pathname_re = re.compile(r'^Pathname:\s*(.*/bin/CC)$', re.M) + pathname_match = pathname_re.search(pkgchk_contents) + if pathname_match: + pathname = os.path.dirname(pathname_match.group(1)) + + package_info[package_name] = (pathname, version) + return package_info[package_name] + +# use the package installer tool lslpp to figure out where cppc and what +# version of it is installed +def get_cppc(env): + cxx = env.subst('$CXX') + if cxx: + cppcPath = os.path.dirname(cxx) + else: + cppcPath = None + + cppcVersion = None + + pkginfo = env.subst('$PKGINFO') + pkgchk = env.subst('$PKGCHK') + + for package in ['SPROcpl']: + path, version = get_package_info(package, pkginfo, pkgchk) + if path and version: + cppcPath, cppcVersion = path, version + break + + return (cppcPath, 'CC', 'CC', cppcVersion) + +def generate(env): + """Add Builders and construction variables for SunPRO C++.""" + path, cxx, shcxx, version = get_cppc(env) + if path: + cxx = os.path.join(path, cxx) + shcxx = os.path.join(path, shcxx) + + cplusplus.generate(env) + + env['CXX'] = cxx + env['SHCXX'] = shcxx + env['CXXVERSION'] = version + env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -KPIC') + env['SHOBJPREFIX'] = 'so_' + env['SHOBJSUFFIX'] = '.o' + +def exists(env): + path, cxx, shcxx, version = get_cppc(env) + if path and cxx: + cppc = os.path.join(path, cxx) + if os.path.exists(cppc): + return cppc + return None + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: -- cgit v0.12 From 6d68e11eda90826cfee2a48539e9367664a36ae7 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 14 Jan 2017 18:04:19 -0800 Subject: changes to force SCons to respect RANLIB when initializing ar tools --- src/engine/SCons/Tool/__init__.py | 2 +- src/engine/SCons/Tool/ar.py | 4 ++-- test/AR/ARCOM.py | 2 ++ test/AR/ARCOMSTR.py | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index cc5a508..0e5f364 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -263,7 +263,7 @@ def createStaticLibBuilder(env): static_lib = env['BUILDERS']['StaticLibrary'] except KeyError: action_list = [ SCons.Action.Action("$ARCOM", "$ARCOMSTR") ] - if env.Detect('ranlib'): + if env.get('RANLIB',False) or env.Detect('ranlib'): ranlib_action = SCons.Action.Action("$RANLIBCOM", "$RANLIBCOMSTR") action_list.append(ranlib_action) diff --git a/src/engine/SCons/Tool/ar.py b/src/engine/SCons/Tool/ar.py index 0c3ac09..e9b5922 100644 --- a/src/engine/SCons/Tool/ar.py +++ b/src/engine/SCons/Tool/ar.py @@ -48,8 +48,8 @@ def generate(env): env['LIBPREFIX'] = 'lib' env['LIBSUFFIX'] = '.a' - if env.Detect('ranlib'): - env['RANLIB'] = 'ranlib' + if env.get('RANLIB',False) or env.Detect('ranlib'): + env['RANLIB'] = env.get('RANLIB','ranlib') env['RANLIBFLAGS'] = SCons.Util.CLVar('') env['RANLIBCOM'] = '$RANLIB $RANLIBFLAGS $TARGET' diff --git a/test/AR/ARCOM.py b/test/AR/ARCOM.py index f9d0038..9ae5b9f 100644 --- a/test/AR/ARCOM.py +++ b/test/AR/ARCOM.py @@ -40,6 +40,7 @@ test.file_fixture('myrewrite.py') test.write('SConstruct', """ env = Environment(tools=['default', 'ar'], ARCOM = r'%(_python_)s mycompile.py ar $TARGET $SOURCES', + RANLIB = True, RANLIBCOM = r'%(_python_)s myrewrite.py ranlib $TARGET', LIBPREFIX = '', LIBSUFFIX = '.lib') @@ -49,6 +50,7 @@ env.Library(target = 'output', source = ['file.1', 'file.2']) test.write('file.1', "file.1\n/*ar*/\n/*ranlib*/\n") test.write('file.2', "file.2\n/*ar*/\n/*ranlib*/\n") + test.run(arguments = '.') test.must_match('output.lib', "file.1\nfile.2\n") diff --git a/test/AR/ARCOMSTR.py b/test/AR/ARCOMSTR.py index 3235f12..a3a9c8e 100644 --- a/test/AR/ARCOMSTR.py +++ b/test/AR/ARCOMSTR.py @@ -42,6 +42,7 @@ test.write('SConstruct', """ env = Environment(tools=['default', 'ar'], ARCOM = r'%(_python_)s mycompile.py ar $TARGET $SOURCES', ARCOMSTR = 'Archiving $TARGET from $SOURCES', + RANLIB = True, RANLIBCOM = r'%(_python_)s myrewrite.py ranlib $TARGET', LIBPREFIX = '', LIBSUFFIX = '.lib') -- cgit v0.12 From 9035ce35b05670e644b63821a926232f405688ee Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 14 Jan 2017 18:04:31 -0800 Subject: fixes for fortran tests an py3 --- test/Fortran/F03COM.py | 18 +++++++++++++----- test/Fortran/F08COM.py | 16 +++++++++++----- test/Fortran/F77COM.py | 17 ++++++++++++----- test/Fortran/F90COM.py | 20 ++++++++++++++------ test/Fortran/F95COM.py | 18 ++++++++++++------ test/Fortran/FORTRANCOM.py | 15 +++++++++++---- test/Fortran/SHF77COM.py | 16 +++++++++++----- test/Fortran/SHF90COM.py | 19 +++++++++++++------ test/Fortran/SHF95COM.py | 18 ++++++++++++------ test/Fortran/SHFORTRANCOM.py | 14 ++++++++++---- test/M4/M4.py | 8 +++++++- 11 files changed, 126 insertions(+), 53 deletions(-) diff --git a/test/Fortran/F03COM.py b/test/Fortran/F03COM.py index 4a42d22..aaa790c 100644 --- a/test/Fortran/F03COM.py +++ b/test/Fortran/F03COM.py @@ -25,6 +25,9 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys + +is_windows = (sys.platform == 'win32') _python_ = TestSCons._python_ _exe = TestSCons._exe @@ -76,18 +79,23 @@ test.write('test22.F03', "This is a .F03 file.\n#link\n/*f03pp*/\n") test.run(arguments = '.', stderr = None) test.must_match('test01' + _exe, "This is a .f file.\n") -test.must_match('test02' + _exe, "This is a .F file.\n") test.must_match('test03' + _exe, "This is a .for file.\n") -test.must_match('test04' + _exe, "This is a .FOR file.\n") test.must_match('test05' + _exe, "This is a .ftn file.\n") -test.must_match('test06' + _exe, "This is a .FTN file.\n") test.must_match('test07' + _exe, "This is a .fpp file.\n") test.must_match('test08' + _exe, "This is a .FPP file.\n") test.must_match('test13' + _exe, "This is a .f03 file.\n") -test.must_match('test14' + _exe, "This is a .F03 file.\n") test.must_match('test21' + _exe, "This is a .f03 file.\n") -test.must_match('test22' + _exe, "This is a .F03 file.\n") + +if not is_windows: + # Skip checking files we expect to differ in behavior + # based on file extension case + test.must_match('test02' + _exe, "This is a .F file.\n") + test.must_match('test04' + _exe, "This is a .FOR file.\n") + test.must_match('test06' + _exe, "This is a .FTN file.\n") + test.must_match('test14' + _exe, "This is a .F03 file.\n") + test.must_match('test22' + _exe, "This is a .F03 file.\n") + test.pass_test() diff --git a/test/Fortran/F08COM.py b/test/Fortran/F08COM.py index ba7d64e..f159a53 100644 --- a/test/Fortran/F08COM.py +++ b/test/Fortran/F08COM.py @@ -25,6 +25,9 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys + +is_windows = ( sys.platform =='win32') _python_ = TestSCons._python_ _exe = TestSCons._exe @@ -67,15 +70,18 @@ test.write('test10.F08', "This is a .F08 file.\n#link\n/*f08pp*/\n") test.run(arguments = '.', stderr = None) test.must_match('test01' + _exe, "This is a .f file.\n") -test.must_match('test02' + _exe, "This is a .F file.\n") test.must_match('test03' + _exe, "This is a .for file.\n") -test.must_match('test04' + _exe, "This is a .FOR file.\n") test.must_match('test05' + _exe, "This is a .ftn file.\n") -test.must_match('test06' + _exe, "This is a .FTN file.\n") test.must_match('test07' + _exe, "This is a .fpp file.\n") -test.must_match('test08' + _exe, "This is a .FPP file.\n") test.must_match('test09' + _exe, "This is a .f08 file.\n") -test.must_match('test10' + _exe, "This is a .F08 file.\n") +if not is_windows: + # Skip checking files we expect to differ in behavior + # based on file extension case + test.must_match('test02' + _exe, "This is a .F file.\n") + test.must_match('test04' + _exe, "This is a .FOR file.\n") + test.must_match('test06' + _exe, "This is a .FTN file.\n") + test.must_match('test08' + _exe, "This is a .FPP file.\n") + test.must_match('test10' + _exe, "This is a .F08 file.\n") test.pass_test() diff --git a/test/Fortran/F77COM.py b/test/Fortran/F77COM.py index e7a3cca..6550d92 100644 --- a/test/Fortran/F77COM.py +++ b/test/Fortran/F77COM.py @@ -25,6 +25,9 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys + +is_windows = ( sys.platform =='win32') _python_ = TestSCons._python_ _exe = TestSCons._exe @@ -67,15 +70,19 @@ test.write('test10.F77', "This is a .F77 file.\n#link\n/*f77pp*/\n") test.run(arguments = '.', stderr = None) test.must_match('test01' + _exe, "This is a .f file.\n") -test.must_match('test02' + _exe, "This is a .F file.\n") test.must_match('test03' + _exe, "This is a .for file.\n") -test.must_match('test04' + _exe, "This is a .FOR file.\n") test.must_match('test05' + _exe, "This is a .ftn file.\n") -test.must_match('test06' + _exe, "This is a .FTN file.\n") test.must_match('test07' + _exe, "This is a .fpp file.\n") -test.must_match('test08' + _exe, "This is a .FPP file.\n") test.must_match('test09' + _exe, "This is a .f77 file.\n") -test.must_match('test10' + _exe, "This is a .F77 file.\n") + +if not is_windows: + # Skip checking files we expect to differ in behavior + # based on file extension case + test.must_match('test02' + _exe, "This is a .F file.\n") + test.must_match('test04' + _exe, "This is a .FOR file.\n") + test.must_match('test06' + _exe, "This is a .FTN file.\n") + test.must_match('test08' + _exe, "This is a .FPP file.\n") + test.must_match('test10' + _exe, "This is a .F77 file.\n") test.pass_test() diff --git a/test/Fortran/F90COM.py b/test/Fortran/F90COM.py index a4f37c2..180e6b7 100644 --- a/test/Fortran/F90COM.py +++ b/test/Fortran/F90COM.py @@ -25,6 +25,9 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys + +is_windows = ( sys.platform =='win32') _python_ = TestSCons._python_ _exe = TestSCons._exe @@ -76,18 +79,23 @@ test.write('test22.F90', "This is a .F90 file.\n#link\n/*f90pp*/\n") test.run(arguments = '.', stderr = None) test.must_match('test01' + _exe, "This is a .f file.\n") -test.must_match('test02' + _exe, "This is a .F file.\n") test.must_match('test03' + _exe, "This is a .for file.\n") -test.must_match('test04' + _exe, "This is a .FOR file.\n") test.must_match('test05' + _exe, "This is a .ftn file.\n") -test.must_match('test06' + _exe, "This is a .FTN file.\n") test.must_match('test07' + _exe, "This is a .fpp file.\n") -test.must_match('test08' + _exe, "This is a .FPP file.\n") test.must_match('test11' + _exe, "This is a .f90 file.\n") -test.must_match('test12' + _exe, "This is a .F90 file.\n") test.must_match('test21' + _exe, "This is a .f90 file.\n") -test.must_match('test22' + _exe, "This is a .F90 file.\n") + +if not is_windows: + # Skip checking files we expect to differ in behavior + # based on file extension case + test.must_match('test02' + _exe, "This is a .F file.\n") + test.must_match('test04' + _exe, "This is a .FOR file.\n") + test.must_match('test06' + _exe, "This is a .FTN file.\n") + test.must_match('test08' + _exe, "This is a .FPP file.\n") + test.must_match('test12' + _exe, "This is a .F90 file.\n") + test.must_match('test22' + _exe, "This is a .F90 file.\n") + test.pass_test() diff --git a/test/Fortran/F95COM.py b/test/Fortran/F95COM.py index 32ae594..2d48770 100644 --- a/test/Fortran/F95COM.py +++ b/test/Fortran/F95COM.py @@ -25,6 +25,9 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys + +is_windows = ( sys.platform =='win32') _python_ = TestSCons._python_ _exe = TestSCons._exe @@ -76,18 +79,21 @@ test.write('test22.F95', "This is a .F95 file.\n#link\n/*f95pp*/\n") test.run(arguments = '.', stderr = None) test.must_match('test01' + _exe, "This is a .f file.\n") -test.must_match('test02' + _exe, "This is a .F file.\n") test.must_match('test03' + _exe, "This is a .for file.\n") -test.must_match('test04' + _exe, "This is a .FOR file.\n") test.must_match('test05' + _exe, "This is a .ftn file.\n") -test.must_match('test06' + _exe, "This is a .FTN file.\n") test.must_match('test07' + _exe, "This is a .fpp file.\n") -test.must_match('test08' + _exe, "This is a .FPP file.\n") test.must_match('test13' + _exe, "This is a .f95 file.\n") -test.must_match('test14' + _exe, "This is a .F95 file.\n") test.must_match('test21' + _exe, "This is a .f95 file.\n") -test.must_match('test22' + _exe, "This is a .F95 file.\n") +if not is_windows: + # Skip checking files we expect to differ in behavior + # based on file extension case + test.must_match('test02' + _exe, "This is a .F file.\n") + test.must_match('test04' + _exe, "This is a .FOR file.\n") + test.must_match('test06' + _exe, "This is a .FTN file.\n") + test.must_match('test08' + _exe, "This is a .FPP file.\n") + test.must_match('test14' + _exe, "This is a .F95 file.\n") + test.must_match('test22' + _exe, "This is a .F95 file.\n") test.pass_test() diff --git a/test/Fortran/FORTRANCOM.py b/test/Fortran/FORTRANCOM.py index a07d427..d3d7e7f 100644 --- a/test/Fortran/FORTRANCOM.py +++ b/test/Fortran/FORTRANCOM.py @@ -25,6 +25,10 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys + +is_windows = ( sys.platform =='win32') + _python_ = TestSCons._python_ _exe = TestSCons._exe @@ -61,13 +65,16 @@ test.write('test08.FPP', "This is a .FPP file.\n#link\n/*fortranpp*/\n") test.run(arguments = '.', stderr = None) test.must_match('test01' + _exe, "This is a .f file.\n") -test.must_match('test02' + _exe, "This is a .F file.\n") test.must_match('test03' + _exe, "This is a .for file.\n") -test.must_match('test04' + _exe, "This is a .FOR file.\n") test.must_match('test05' + _exe, "This is a .ftn file.\n") -test.must_match('test06' + _exe, "This is a .FTN file.\n") test.must_match('test07' + _exe, "This is a .fpp file.\n") -test.must_match('test08' + _exe, "This is a .FPP file.\n") +if not is_windows: + # Skip checking files we expect to differ in behavior + # based on file extension case + test.must_match('test02' + _exe, "This is a .F file.\n") + test.must_match('test04' + _exe, "This is a .FOR file.\n") + test.must_match('test06' + _exe, "This is a .FTN file.\n") + test.must_match('test08' + _exe, "This is a .FPP file.\n") test.pass_test() diff --git a/test/Fortran/SHF77COM.py b/test/Fortran/SHF77COM.py index 9289fa3..bd3d1e2 100644 --- a/test/Fortran/SHF77COM.py +++ b/test/Fortran/SHF77COM.py @@ -25,6 +25,9 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys + +is_windows = ( sys.platform =='win32') _python_ = TestSCons._python_ _obj = TestSCons._shobj @@ -65,15 +68,18 @@ test.write('test10.F77', "This is a .F77 file.\n/*f77pp*/\n") test.run(arguments = '.', stderr = None) test.must_match(obj_ + 'test01' + _obj, "This is a .f file.\n") -test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") test.must_match(obj_ + 'test03' + _obj, "This is a .for file.\n") -test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") test.must_match(obj_ + 'test05' + _obj, "This is a .ftn file.\n") -test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") test.must_match(obj_ + 'test07' + _obj, "This is a .fpp file.\n") -test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") test.must_match(obj_ + 'test09' + _obj, "This is a .f77 file.\n") -test.must_match(obj_ + 'test10' + _obj, "This is a .F77 file.\n") +if not is_windows: + # Skip checking files we expect to differ in behavior + # based on file extension case + test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") + test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") + test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") + test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") + test.must_match(obj_ + 'test10' + _obj, "This is a .F77 file.\n") test.pass_test() diff --git a/test/Fortran/SHF90COM.py b/test/Fortran/SHF90COM.py index 9eef8b6..f66c347 100644 --- a/test/Fortran/SHF90COM.py +++ b/test/Fortran/SHF90COM.py @@ -25,6 +25,10 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys + +is_windows = ( sys.platform =='win32') + _python_ = TestSCons._python_ _obj = TestSCons._shobj @@ -72,18 +76,21 @@ test.write('test22.F90', "This is a .F90 file.\n/*f90pp*/\n") test.run(arguments = '.', stderr = None) test.must_match(obj_ + 'test01' + _obj, "This is a .f file.\n") -test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") test.must_match(obj_ + 'test03' + _obj, "This is a .for file.\n") -test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") test.must_match(obj_ + 'test05' + _obj, "This is a .ftn file.\n") -test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") test.must_match(obj_ + 'test07' + _obj, "This is a .fpp file.\n") -test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") test.must_match(obj_ + 'test11' + _obj, "This is a .f90 file.\n") -test.must_match(obj_ + 'test12' + _obj, "This is a .F90 file.\n") test.must_match(obj_ + 'test21' + _obj, "This is a .f90 file.\n") -test.must_match(obj_ + 'test22' + _obj, "This is a .F90 file.\n") +if not is_windows: + # Skip checking files we expect to differ in behavior + # based on file extension case + test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") + test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") + test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") + test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") + test.must_match(obj_ + 'test12' + _obj, "This is a .F90 file.\n") + test.must_match(obj_ + 'test22' + _obj, "This is a .F90 file.\n") test.pass_test() diff --git a/test/Fortran/SHF95COM.py b/test/Fortran/SHF95COM.py index e31cf45..85de45e 100644 --- a/test/Fortran/SHF95COM.py +++ b/test/Fortran/SHF95COM.py @@ -25,6 +25,9 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys + +is_windows = ( sys.platform =='win32') _python_ = TestSCons._python_ _obj = TestSCons._shobj @@ -72,18 +75,21 @@ test.write('test22.F95', "This is a .F95 file.\n/*f95pp*/\n") test.run(arguments = '.', stderr = None) test.must_match(obj_ + 'test01' + _obj, "This is a .f file.\n") -test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") test.must_match(obj_ + 'test03' + _obj, "This is a .for file.\n") -test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") test.must_match(obj_ + 'test05' + _obj, "This is a .ftn file.\n") -test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") test.must_match(obj_ + 'test07' + _obj, "This is a .fpp file.\n") -test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") test.must_match(obj_ + 'test13' + _obj, "This is a .f95 file.\n") -test.must_match(obj_ + 'test14' + _obj, "This is a .F95 file.\n") test.must_match(obj_ + 'test21' + _obj, "This is a .f95 file.\n") -test.must_match(obj_ + 'test22' + _obj, "This is a .F95 file.\n") +if not is_windows: + # Skip checking files we expect to differ in behavior + # based on file extension case + test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") + test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") + test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") + test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") + test.must_match(obj_ + 'test14' + _obj, "This is a .F95 file.\n") + test.must_match(obj_ + 'test22' + _obj, "This is a .F95 file.\n") test.pass_test() diff --git a/test/Fortran/SHFORTRANCOM.py b/test/Fortran/SHFORTRANCOM.py index 56958b2..5c42864 100644 --- a/test/Fortran/SHFORTRANCOM.py +++ b/test/Fortran/SHFORTRANCOM.py @@ -25,6 +25,9 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys + +is_windows = ( sys.platform =='win32') _python_ = TestSCons._python_ _obj = TestSCons._shobj @@ -59,13 +62,16 @@ test.write('test08.FPP', "This is a .FPP file.\n/*fortranpp*/\n") test.run(arguments = '.', stderr = None) test.must_match(obj_ + 'test01' + _obj, "This is a .f file.\n") -test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") test.must_match(obj_ + 'test03' + _obj, "This is a .for file.\n") -test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") test.must_match(obj_ + 'test05' + _obj, "This is a .ftn file.\n") -test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") test.must_match(obj_ + 'test07' + _obj, "This is a .fpp file.\n") -test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") +if not is_windows: + # Skip checking files we expect to differ in behavior + # based on file extension case + test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") + test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") + test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") + test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") test.pass_test() diff --git a/test/M4/M4.py b/test/M4/M4.py index 4306558..76010e6 100644 --- a/test/M4/M4.py +++ b/test/M4/M4.py @@ -59,7 +59,13 @@ line 3 test.run() -test.must_match(test.workpath('aaa.x'), "line 1\nmym4.py\nline 3\n") +import sys + +if sys.platform == 'win32': + # Handle carriage returns. + test.must_match(test.workpath('aaa.x'), "line 1\r\nmym4.py\r\nline 3\r\n") +else: + test.must_match(test.workpath('aaa.x'), "line 1\nmym4.py\nline 3\n") -- cgit v0.12 From 13873a35cc5bbfba162414d6a63c790632192729 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 14 Mar 2017 12:38:58 -0400 Subject: try mode='w' to see if this makes source file for msvc the proper format --- test/srcchange.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/srcchange.py b/test/srcchange.py index bbad4e7..8021827 100644 --- a/test/srcchange.py +++ b/test/srcchange.py @@ -82,31 +82,31 @@ main(int argc, char *argv[]) printf("Revision $REV$\\n"); exit (0); } -""") +""", mode='w') test.write('revnum.in', '3.2\n') -prog = 'main' + TestSCons._exe +program_name = 'main' + TestSCons._exe -light_build=test.wrap_stdout("""\ +light_build = test.wrap_stdout("""\ %(_python_)s getrevision > revision.in """ % locals()) test.run(arguments='.') -test.must_exist(prog) -test.run(program=test.workpath(prog), stdout='Revision $REV: 3.2$\n') +test.must_exist(program_name) +test.run(program_name=test.workpath(program_name), stdout='Revision $REV: 3.2$\n') test.run(arguments='.', stdout=light_build) -test.must_exist(prog) +test.must_exist(program_name) test.run(arguments='.', stdout=light_build) -test.must_exist(prog) +test.must_exist(program_name) test.write('revnum.in', '3.3\n') test.run(arguments='.') -test.must_exist(prog) -test.run(program=test.workpath(prog), stdout='Revision $REV: 3.3$\n') +test.must_exist(program_name) +test.run(program_name=test.workpath(program_name), stdout='Revision $REV: 3.3$\n') test.pass_test() -- cgit v0.12 From a1f595e9dd4fefbcb3240c572cf39f29c3a39ae6 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 14 Mar 2017 13:23:03 -0400 Subject: fix py2/3 win32 --- test/srcchange.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test/srcchange.py b/test/srcchange.py index 8021827..bef3589 100644 --- a/test/srcchange.py +++ b/test/srcchange.py @@ -45,7 +45,7 @@ test = TestSCons.TestSCons() test.write('getrevision', """ #!/usr/bin/env python from __future__ import print_function -print(open('revnum.in','r').read().strip()) +print(open('revnum.in','r').read().strip(), end='') """) test.write('SConstruct', """ @@ -72,17 +72,18 @@ exe = env.Program('main.c') env.Default(exe) """ % locals()) -test.write('main.c', """\ +test.write('main.c', r"""\ #include #include #include int main(int argc, char *argv[]) { - printf("Revision $REV$\\n"); + printf("Revision $REV$\n"); exit (0); } -""", mode='w') + +""") test.write('revnum.in', '3.2\n') @@ -94,7 +95,7 @@ light_build = test.wrap_stdout("""\ test.run(arguments='.') test.must_exist(program_name) -test.run(program_name=test.workpath(program_name), stdout='Revision $REV: 3.2$\n') +test.run(program=test.workpath(program_name), stdout='Revision $REV: 3.2$\n') test.run(arguments='.', stdout=light_build) test.must_exist(program_name) @@ -106,7 +107,7 @@ test.write('revnum.in', '3.3\n') test.run(arguments='.') test.must_exist(program_name) -test.run(program_name=test.workpath(program_name), stdout='Revision $REV: 3.3$\n') +test.run(program=test.workpath(program_name), stdout='Revision $REV: 3.3$\n') test.pass_test() -- cgit v0.12 From 5791123d2c41ce88de40853c8c1b768b122ea04e Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 14 Mar 2017 13:27:34 -0400 Subject: fix py2/3 win32 must_match needed mode='r' --- test/option/taskmastertrace.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/option/taskmastertrace.py b/test/option/taskmastertrace.py index 28f4574..c426692 100644 --- a/test/option/taskmastertrace.py +++ b/test/option/taskmastertrace.py @@ -218,7 +218,7 @@ Taskmaster: No candidate anymore. """ -test.must_match('trace.out', expect_trace) +test.must_match('trace.out', expect_trace, mode='r') test.pass_test() -- cgit v0.12 From dd25c86b45c6cdf9cce4107c33464ec46a80dc58 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 14 Mar 2017 13:49:37 -0400 Subject: fix py2/3 win32 use SCons.Util.UnicodeType to replace u --- src/engine/SCons/Taskmaster.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/Taskmaster.py b/src/engine/SCons/Taskmaster.py index 1fe7668..c44ccee 100644 --- a/src/engine/SCons/Taskmaster.py +++ b/src/engine/SCons/Taskmaster.py @@ -772,7 +772,7 @@ class Taskmaster(object): self.ready_exc = None T = self.trace - if T: T.write('\n' + self.trace_message('Looking for a node to evaluate')) + if T: T.write(SCons.Util.UnicodeType('\n') + self.trace_message('Looking for a node to evaluate')) while True: node = self.next_candidate() -- cgit v0.12 From d2bd5c35b04a70cc4778bdf3fb7b1c9cc48cb2cb Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 14 Mar 2017 16:28:22 -0400 Subject: fix py2/3 mode=r and/rb, and remove native line ending translation. fixes win32 --- QMTest/TestSCons.py | 2 +- test/Configure/ConfigureDryRunError.py | 32 ++++++++++++++++---------------- test/Configure/config-h.py | 2 +- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index a8651d9..d33eae7 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -1028,7 +1028,7 @@ SConscript( sconscript ) nols = nols + "|" nols = nols + ")" lastEnd = 0 - logfile = self.read(self.workpath(logfile),mode='r') + logfile = self.read(self.workpath(logfile)) # Some debug code to keep around.. # sys.stderr.write("LOGFILE[%s]:%s"%(type(logfile),logfile)) diff --git a/test/Configure/ConfigureDryRunError.py b/test/Configure/ConfigureDryRunError.py index fa85042..b87162c 100644 --- a/test/Configure/ConfigureDryRunError.py +++ b/test/Configure/ConfigureDryRunError.py @@ -78,25 +78,25 @@ scons: *** Cannot update configure test "%(conftest_0_c)s" within a dry-run. test.run(arguments='-n', status=2, stderr=expect) test.run() -test.checkLogAndStdout( ["Checking for C library %s... " % lib, - "Checking for C library hopefullynolib... "], - ["yes", "no"], - [[((".c", NCR), (_obj, NCR))], - [((".c", NCR), (_obj, NCF))]], - "config.log", ".sconf_temp", "SConstruct") +test.checkLogAndStdout(["Checking for C library %s... " % lib, + "Checking for C library hopefullynolib... "], + ["yes", "no"], + [[((".c", NCR), (_obj, NCR))], + [((".c", NCR), (_obj, NCF))]], + "config.log", ".sconf_temp", "SConstruct") -oldLog = test.read(test.workpath('config.log')) +oldLog = test.read(test.workpath('config.log'), mode='r') test.run(arguments='-n') -test.checkLogAndStdout( ["Checking for C library %s... " % lib, - "Checking for C library hopefullynolib... "], - ["yes", "no"], - [[((".c", CR), (_obj, CR))], - [((".c", CR), (_obj, CF))]], - "config.log", ".sconf_temp", "SConstruct", - doCheckLog=0) - -newLog = test.read(test.workpath('config.log')) +test.checkLogAndStdout(["Checking for C library %s... " % lib, + "Checking for C library hopefullynolib... "], + ["yes", "no"], + [[((".c", CR), (_obj, CR))], + [((".c", CR), (_obj, CF))]], + "config.log", ".sconf_temp", "SConstruct", + doCheckLog=0) + +newLog = test.read(test.workpath('config.log'), mode='r') if newLog != oldLog: print("Unexpected update of log file within a dry run") test.fail_test() diff --git a/test/Configure/config-h.py b/test/Configure/config-h.py index ff5e5b2..a5c1998 100644 --- a/test/Configure/config-h.py +++ b/test/Configure/config-h.py @@ -130,7 +130,7 @@ expected_config_h = ("""\ /* #undef HAVE_LIBHOPEFULLYNOLIB2 */ #endif /* CONFIG_H_SEEN */ -""" % locals()).replace("\n", os.linesep) +""" % locals()) test.run(stdout=expected_stdout) -- cgit v0.12 From 44fb9210fa89a8e7717848475efd4b62d6463eb2 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 14 Mar 2017 18:44:29 -0400 Subject: move comment for method to docstring --- src/engine/SCons/Node/FS.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 907bc75..c3841eb 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -2659,10 +2659,12 @@ class File(Base): def get_contents(self): return SCons.Node._get_contents_map[self._func_get_contents](self) - # This attempts to figure out what the encoding of the text is - # based upon the BOM bytes, and then decodes the contents so that - # it's a valid python string. def get_text_contents(self): + """ + This attempts to figure out what the encoding of the text is + based upon the BOM bytes, and then decodes the contents so that + it's a valid python string. + """ contents = self.get_contents() # The behavior of various decode() methods and functions # w.r.t. the initial BOM bytes is different for different -- cgit v0.12 From 41a1bb6e1d337ba69b89ff52bf9c4680c7ec24cb Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 14 Mar 2017 18:55:22 -0400 Subject: scanner.py works for win32 py27, but fails py3 --- test/Scanner/Scanner.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/test/Scanner/Scanner.py b/test/Scanner/Scanner.py index d5e5c3a..45eddb9 100644 --- a/test/Scanner/Scanner.py +++ b/test/Scanner/Scanner.py @@ -25,6 +25,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import os _python_ = TestSCons._python_ @@ -183,7 +184,14 @@ test.run(arguments = '.', stdout=expect) test.must_match('foo', "foo.k 1 line 1\nxxx 1\nyyy 1\nfoo.k 1 line 4\n", mode='r') test.must_match('bar', "yyy 1\nbar.in 1 line 2\nbar.in 1 line 3\nzzz 1\n", mode='r') test.must_match('junk', "yyy 1\njunk.k2 1 line 2\njunk.k2 1 line 3\nzzz 1\n", mode='r') -test.must_match('moo.ork', "xxx 1\nmoo.lork 1 line 2\nyyy 1\nmoo.lork 1 line 4\ninclude zzz\n", mode='r') + +import sys +thingy = "xxx 1\nmoo.lork 1 line 2\nyyy 1\nmoo.lork 1 line 4\ninclude zzz\n".replace('\n','\r\n') +thingy2 = "xxx 1\nmoo.lork 1 line 2\nyyy 1\nmoo.lork 1 line 4\ninclude zzz\n".replace('\n',os.linesep) +if thingy != thingy2: + sys.stderr.write("FARGINBAKJKJDLFKJSLDKFJ") +test.must_match('moo.ork', "xxx 1\nmoo.lork 1 line 2\nyyy 1\nmoo.lork 1 line 4\ninclude zzz\n".replace('\n','\r\n'), + mode='r') test.up_to_date(arguments = '.') @@ -200,7 +208,7 @@ test.run(arguments = '.', stdout=expect) test.must_match('foo', "foo.k 1 line 1\nxxx 2\nyyy 1\nfoo.k 1 line 4\n", mode='r') test.must_match('bar', "yyy 1\nbar.in 1 line 2\nbar.in 1 line 3\nzzz 1\n", mode='r') test.must_match('junk', "yyy 1\njunk.k2 1 line 2\njunk.k2 1 line 3\nzzz 1\n", mode='r') -test.must_match('moo.ork', "xxx 2\nmoo.lork 1 line 2\nyyy 1\nmoo.lork 1 line 4\ninclude zzz\n", mode='r') +test.must_match('moo.ork', "xxx 2\nmoo.lork 1 line 2\nyyy 1\nmoo.lork 1 line 4\ninclude zzz\n".replace('\n',os.linesep), mode='r') test.write('yyy', "yyy 2\n") @@ -217,7 +225,7 @@ test.run(arguments = '.', stdout=expect) test.must_match('foo', "foo.k 1 line 1\nxxx 2\nyyy 2\nfoo.k 1 line 4\n", mode='r') test.must_match('bar', "yyy 2\nbar.in 1 line 2\nbar.in 1 line 3\nzzz 1\n", mode='r') test.must_match('junk', "yyy 2\njunk.k2 1 line 2\njunk.k2 1 line 3\nzzz 1\n", mode='r') -test.must_match('moo.ork', "xxx 2\nmoo.lork 1 line 2\nyyy 2\nmoo.lork 1 line 4\ninclude zzz\n", mode='r') +test.must_match('moo.ork', "xxx 2\nmoo.lork 1 line 2\nyyy 2\nmoo.lork 1 line 4\ninclude zzz\n".replace('\n',os.linesep), mode='r') test.write('zzz', "zzz 2\n") @@ -231,7 +239,7 @@ test.run(arguments = '.', stdout=expect) test.must_match('foo', "foo.k 1 line 1\nxxx 2\nyyy 2\nfoo.k 1 line 4\n", mode='r') test.must_match('bar', "yyy 2\nbar.in 1 line 2\nbar.in 1 line 3\nzzz 2\n", mode='r') test.must_match('junk', "yyy 2\njunk.k2 1 line 2\njunk.k2 1 line 3\nzzz 2\n", mode='r') -test.must_match('moo.ork', "xxx 2\nmoo.lork 1 line 2\nyyy 2\nmoo.lork 1 line 4\ninclude zzz\n", mode='r') +test.must_match('moo.ork', "xxx 2\nmoo.lork 1 line 2\nyyy 2\nmoo.lork 1 line 4\ninclude zzz\n".replace('\n',os.linesep), mode='r') test.up_to_date(arguments = 'foo') -- cgit v0.12 From de8222ae421c323b5e5776086fd260effb05bd58 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 17 Mar 2017 14:17:24 -0400 Subject: incremental checkin --- test/Scanner/Scanner.py | 86 +++++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 45 deletions(-) diff --git a/test/Scanner/Scanner.py b/test/Scanner/Scanner.py index 45eddb9..bc868e0 100644 --- a/test/Scanner/Scanner.py +++ b/test/Scanner/Scanner.py @@ -51,14 +51,14 @@ def process(infp, outfp): process(input, output) sys.exit(0) -""") +""", mode='w') # Execute a subsidiary SConscript just to make sure we can # get at the Scanner keyword from there. test.write('SConstruct', """ SConscript('SConscript') -""") +""", mode='w') test.write('SConscript', """ import re @@ -68,6 +68,7 @@ include_re = re.compile(r'^include\s+(\S+)$', re.M) def kfile_scan(node, env, scanpaths, arg): contents = node.get_text_contents() includes = include_re.findall(contents) + print("TEXT:%%s Include:%%s"%%(contents,includes)) return includes kscan = Scanner(name = 'kfile', @@ -114,69 +115,71 @@ bar = env.BarBld(target='bar', source='bar.in') # Test specifying a source scanner for a Builder that gets # automatically applied to targets generated from that Builder -def blork(env, target, source): - open(str(target[0]), 'w').write( - source[0].get_text_contents().replace('getfile', 'MISSEDME')) +def third(env, target, source): + contents = source[0].get_contents() + # print("TYPE:"+str(type(contents))) + contents = contents.replace(b'getfile', b'MISSEDME') + open(str(target[0]), 'wb').write(contents) kbld = Builder(action=r'%(_python_)s build.py $SOURCES $TARGET', - src_suffix='.lork', - suffix='.blork', + src_suffix='.first', + suffix='.second', source_scanner=kscan) -blorkbld = Builder(action=blork, - src_suffix='.blork', - suffix='.ork') +thirdbld = Builder(action=third, + src_suffix='.second', + suffix='.third') -env.Append(BUILDERS={'BLORK':blorkbld, 'KB':kbld}) +env.Append(BUILDERS={'Second':thirdbld, 'KB':kbld}) -blork = env.KB('moo.lork') -ork = env.BLORK(blork) +blork = env.KB('moo.first') +ork = env.Second(blork) Alias('make_ork', ork) -""" % locals()) +""" % locals(),mode='w') test.write('foo.k', """foo.k 1 line 1 include xxx include yyy foo.k 1 line 4 -""") +""", mode='w') -test.write('bar.in', +test.write('bar.in', """include yyy bar.in 1 line 2 bar.in 1 line 3 include zzz -""") +""", mode='w') test.write('junk.k2', """include yyy junk.k2 1 line 2 junk.k2 1 line 3 include zzz -""") +""", mode='w') -test.write('moo.lork', +test.write('moo.first', """include xxx -moo.lork 1 line 2 +moo.first 1 line 2 include yyy -moo.lork 1 line 4 +moo.first 1 line 4 include moo.inc -""") +""", mode='w') test.write('moo.inc', """getfile zzz -""") +""", mode='w') -test.write('xxx', "xxx 1\n") -test.write('yyy', "yyy 1\n") -test.write('zzz', "zzz 1\n") +test.write('xxx', "xxx 1\n",mode='w') +test.write('yyy', "yyy 1\n",mode='w') +test.write('zzz', "zzz 1\n",mode='w') expect = test.wrap_stdout("""\ %(_python_)s build.py bar.in bar %(_python_)s build.py foo.k foo %(_python_)s build.py junk.k2 junk -%(_python_)s build.py moo.lork moo.blork -blork(["moo.ork"], ["moo.blork"]) +%(_python_)s build.py moo.first moo.second +third(["moo.third"], ["moo.second"]) """ % locals()) test.run(arguments = '.', stdout=expect) @@ -184,23 +187,16 @@ test.run(arguments = '.', stdout=expect) test.must_match('foo', "foo.k 1 line 1\nxxx 1\nyyy 1\nfoo.k 1 line 4\n", mode='r') test.must_match('bar', "yyy 1\nbar.in 1 line 2\nbar.in 1 line 3\nzzz 1\n", mode='r') test.must_match('junk', "yyy 1\njunk.k2 1 line 2\njunk.k2 1 line 3\nzzz 1\n", mode='r') - -import sys -thingy = "xxx 1\nmoo.lork 1 line 2\nyyy 1\nmoo.lork 1 line 4\ninclude zzz\n".replace('\n','\r\n') -thingy2 = "xxx 1\nmoo.lork 1 line 2\nyyy 1\nmoo.lork 1 line 4\ninclude zzz\n".replace('\n',os.linesep) -if thingy != thingy2: - sys.stderr.write("FARGINBAKJKJDLFKJSLDKFJ") -test.must_match('moo.ork', "xxx 1\nmoo.lork 1 line 2\nyyy 1\nmoo.lork 1 line 4\ninclude zzz\n".replace('\n','\r\n'), - mode='r') +test.must_match('moo.third', "xxx 1\nmoo.first 1 line 2\nyyy 1\nmoo.first 1 line 4\ninclude zzz\n", mode='r') test.up_to_date(arguments = '.') -test.write('xxx', "xxx 2\n") +test.write('xxx', "xxx 2\n",mode='w') expect = test.wrap_stdout("""\ %(_python_)s build.py foo.k foo -%(_python_)s build.py moo.lork moo.blork -blork(["moo.ork"], ["moo.blork"]) +%(_python_)s build.py moo.first moo.second +third(["moo.third"], ["moo.second"]) """ % locals()) test.run(arguments = '.', stdout=expect) @@ -208,16 +204,16 @@ test.run(arguments = '.', stdout=expect) test.must_match('foo', "foo.k 1 line 1\nxxx 2\nyyy 1\nfoo.k 1 line 4\n", mode='r') test.must_match('bar', "yyy 1\nbar.in 1 line 2\nbar.in 1 line 3\nzzz 1\n", mode='r') test.must_match('junk', "yyy 1\njunk.k2 1 line 2\njunk.k2 1 line 3\nzzz 1\n", mode='r') -test.must_match('moo.ork', "xxx 2\nmoo.lork 1 line 2\nyyy 1\nmoo.lork 1 line 4\ninclude zzz\n".replace('\n',os.linesep), mode='r') +test.must_match('moo.third', "xxx 2\nmoo.first 1 line 2\nyyy 1\nmoo.first 1 line 4\ninclude zzz\n".replace('\n',os.linesep), mode='r') -test.write('yyy', "yyy 2\n") +test.write('yyy', "yyy 2\n",mode='w') expect = test.wrap_stdout("""\ %(_python_)s build.py bar.in bar %(_python_)s build.py foo.k foo %(_python_)s build.py junk.k2 junk -%(_python_)s build.py moo.lork moo.blork -blork(["moo.ork"], ["moo.blork"]) +%(_python_)s build.py moo.first moo.second +third(["moo.third"], ["moo.second"]) """ % locals()) test.run(arguments = '.', stdout=expect) @@ -225,7 +221,7 @@ test.run(arguments = '.', stdout=expect) test.must_match('foo', "foo.k 1 line 1\nxxx 2\nyyy 2\nfoo.k 1 line 4\n", mode='r') test.must_match('bar', "yyy 2\nbar.in 1 line 2\nbar.in 1 line 3\nzzz 1\n", mode='r') test.must_match('junk', "yyy 2\njunk.k2 1 line 2\njunk.k2 1 line 3\nzzz 1\n", mode='r') -test.must_match('moo.ork', "xxx 2\nmoo.lork 1 line 2\nyyy 2\nmoo.lork 1 line 4\ninclude zzz\n".replace('\n',os.linesep), mode='r') +test.must_match('moo.third', "xxx 2\nmoo.first 1 line 2\nyyy 2\nmoo.first 1 line 4\ninclude zzz\n".replace('\n',os.linesep), mode='r') test.write('zzz', "zzz 2\n") @@ -239,7 +235,7 @@ test.run(arguments = '.', stdout=expect) test.must_match('foo', "foo.k 1 line 1\nxxx 2\nyyy 2\nfoo.k 1 line 4\n", mode='r') test.must_match('bar', "yyy 2\nbar.in 1 line 2\nbar.in 1 line 3\nzzz 2\n", mode='r') test.must_match('junk', "yyy 2\njunk.k2 1 line 2\njunk.k2 1 line 3\nzzz 2\n", mode='r') -test.must_match('moo.ork', "xxx 2\nmoo.lork 1 line 2\nyyy 2\nmoo.lork 1 line 4\ninclude zzz\n".replace('\n',os.linesep), mode='r') +test.must_match('moo.third', "xxx 2\nmoo.first 1 line 2\nyyy 2\nmoo.first 1 line 4\ninclude zzz\n".replace('\n',os.linesep), mode='r') test.up_to_date(arguments = 'foo') -- cgit v0.12 From 8c6e0083ca86b6ea3c778361a79d8ffaeb2fd563 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 14 Jan 2017 18:12:33 -0800 Subject: try using win32 native CopyFile --- src/engine/SCons/Platform/win32.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/engine/SCons/Platform/win32.py b/src/engine/SCons/Platform/win32.py index b9defbb..827931f 100644 --- a/src/engine/SCons/Platform/win32.py +++ b/src/engine/SCons/Platform/win32.py @@ -92,6 +92,37 @@ else: setattr(io, io_class, _scons_file) + + +# Now swap out shutil.filecopy and filecopy2 for win32 api native CopyFile +try: + from ctypes import windll + import shutil + + CopyFile = windll.kernel32.CopyFileA + SetFileTime = windll.kernel32.SetFileTime + + _shutil_copy = shutil.copy + _shutil_copy2 = shutil.copy2 + + shutil.copy2 = CopyFile + + def win_api_copyfile(src,dst): + CopyFile(src,dst) + os.utime(dst) + + shutil.copy = win_api_copyfile + +except AttributeError: + parallel_msg = \ + "Couldn't override shutil.copy or shutil.copy2 falling back to shutil defaults" + + + + + + + try: import threading spawn_lock = threading.Lock() -- cgit v0.12 From c20e4add922d4a2a74853f5a3af41115dd4f884c Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 14 Jan 2017 18:12:56 -0800 Subject: merged from upstream --- src/engine/SCons/Tool/ar.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/engine/SCons/Tool/ar.py b/src/engine/SCons/Tool/ar.py index 2cd15c8..14910b7 100644 --- a/src/engine/SCons/Tool/ar.py +++ b/src/engine/SCons/Tool/ar.py @@ -48,7 +48,11 @@ def generate(env): env['LIBPREFIX'] = 'lib' env['LIBSUFFIX'] = '.a' +<<<<<<< working copy + if env.get('RANLIB',False) or env.Detect('ranlib'): +======= if env.get('RANLIB',env.Detect('ranlib')) : +>>>>>>> merge rev env['RANLIB'] = env.get('RANLIB','ranlib') env['RANLIBFLAGS'] = SCons.Util.CLVar('') env['RANLIBCOM'] = '$RANLIB $RANLIBFLAGS $TARGET' -- cgit v0.12 From 7b514fb2f9cf65c0fcc6b719d788a20fbad6104f Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 14 Jan 2017 18:19:49 -0800 Subject: Fix merge errors --- src/engine/SCons/Tool/ar.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/engine/SCons/Tool/ar.py b/src/engine/SCons/Tool/ar.py index 14910b7..2cd15c8 100644 --- a/src/engine/SCons/Tool/ar.py +++ b/src/engine/SCons/Tool/ar.py @@ -48,11 +48,7 @@ def generate(env): env['LIBPREFIX'] = 'lib' env['LIBSUFFIX'] = '.a' -<<<<<<< working copy - if env.get('RANLIB',False) or env.Detect('ranlib'): -======= if env.get('RANLIB',env.Detect('ranlib')) : ->>>>>>> merge rev env['RANLIB'] = env.get('RANLIB','ranlib') env['RANLIBFLAGS'] = SCons.Util.CLVar('') env['RANLIBCOM'] = '$RANLIB $RANLIBFLAGS $TARGET' -- cgit v0.12 From a9f6cd1ccef091f79f52c210a9c4cea89eaf0a40 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 14 Jan 2017 18:27:16 -0800 Subject: merge from upstream --- src/engine/SCons/Tool/ar.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/engine/SCons/Tool/ar.py b/src/engine/SCons/Tool/ar.py index 14910b7..2cd15c8 100644 --- a/src/engine/SCons/Tool/ar.py +++ b/src/engine/SCons/Tool/ar.py @@ -48,11 +48,7 @@ def generate(env): env['LIBPREFIX'] = 'lib' env['LIBSUFFIX'] = '.a' -<<<<<<< working copy - if env.get('RANLIB',False) or env.Detect('ranlib'): -======= if env.get('RANLIB',env.Detect('ranlib')) : ->>>>>>> merge rev env['RANLIB'] = env.get('RANLIB','ranlib') env['RANLIBFLAGS'] = SCons.Util.CLVar('') env['RANLIBCOM'] = '$RANLIB $RANLIBFLAGS $TARGET' -- cgit v0.12 From 1702eb64b1e803a3fe3760d706524bb238a4a286 Mon Sep 17 00:00:00 2001 From: philippe coval Date: Fri, 20 Jan 2017 13:46:32 +0100 Subject: Fix missing quote in user documentation about Substfile --- src/engine/SCons/Tool/textfile.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/Tool/textfile.xml b/src/engine/SCons/Tool/textfile.xml index aa6b0b1..08bbb76 100644 --- a/src/engine/SCons/Tool/textfile.xml +++ b/src/engine/SCons/Tool/textfile.xml @@ -150,7 +150,7 @@ and the result replaces the key. env = Environment(tools = ['default', 'textfile']) env['prefix'] = '/usr/bin' -script_dict = {'@prefix@': '/bin', @exec_prefix@: '$prefix'} +script_dict = {'@prefix@': '/bin', '@exec_prefix@': '$prefix'} env.Substfile('script.in', SUBST_DICT = script_dict) conf_dict = {'%VERSION%': '1.2.3', '%BASE%': 'MyProg'} -- cgit v0.12 From cdac4f74fcad946a05754842a00c8ce1648751eb Mon Sep 17 00:00:00 2001 From: Gaurav Juvekar Date: Sat, 28 Jan 2017 14:14:53 +0530 Subject: Fix documentation example output to match actual output (Fix #2788) --- doc/user/sconf.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/user/sconf.xml b/doc/user/sconf.xml index fe933f1..109e468 100644 --- a/doc/user/sconf.xml +++ b/doc/user/sconf.xml @@ -2,7 +2,7 @@ %scons; - + %builders-mod; @@ -287,7 +287,7 @@ env = conf.Finish() Check the size of a datatype by using the &CheckTypeSize; method: - + env = Environment() conf = Configure(env) @@ -295,7 +295,7 @@ int_size = conf.CheckTypeSize('unsigned int') print 'sizeof unsigned int is', int_size env = conf.Finish() - + % scons -Q sizeof unsigned int is 4 @@ -456,7 +456,7 @@ env = conf.Finish() % scons scons: Reading SConscript file ... -Checking for MyLibrary... failed +Checking for MyLibrary... no MyLibrary is not installed! @@ -470,7 +470,7 @@ MyLibrary is not installed! % scons scons: Reading SConscript file ... -Checking for MyLibrary... failed +Checking for MyLibrary... yes scons: done reading SConscript scons: Building targets ... . -- cgit v0.12 From 6a4a2981fe1134e63a00e141ca1c3774f66ba353 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 20 Feb 2017 15:57:43 -0800 Subject: PY3 porting work. Also moved comments for methods into docstrings --- src/engine/SCons/Action.py | 168 +++++++++++++++++++++++++++------------- src/engine/SCons/ActionTests.py | 54 ++++++++++++- 2 files changed, 164 insertions(+), 58 deletions(-) diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index 4e17f19..c5133de 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -60,6 +60,7 @@ this module: get_presig() Fetches the "contents" of a subclass for signature calculation. The varlist is added to this to produce the Action's contents. + TODO(?): Change this to always return ascii/bytes and not unicode (or py3 strings) strfunction() Returns a substituted string representation of the Action. @@ -99,7 +100,6 @@ way for wrapping up the functions. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import dis import os import pickle import re @@ -123,12 +123,22 @@ print_actions = 1 execute_actions = 1 print_actions_presub = 0 +# Use pickle protocol 1 when pickling functions for signature +# otherwise python3 and python2 will yield different pickles +# for the same object. +# This is due to default being 1 for python 2.7, and 3 for 3.x +# TODO: We can roll this forward to 2 (if it has value), but not +# before a deprecation cycle as the sconsigns will change +ACTION_SIGNATURE_PICKLE_PROTOCOL = 1 + + def rfile(n): try: return n.rfile() except AttributeError: return n + def default_exitstatfunc(s): return s @@ -185,14 +195,14 @@ def _object_contents(obj): except AttributeError as ae: # Should be a pickle-able Python object. try: - return pickle.dumps(obj) + return pickle.dumps(obj,ACTION_SIGNATURE_PICKLE_PROTOCOL) except (pickle.PicklingError, TypeError, AttributeError): # This is weird, but it seems that nested classes # are unpickable. The Python docs say it should # always be a PicklingError, but some Python # versions seem to return TypeError. Just do # the best we can. - return repr(obj) + return bytearray(repr(obj),'utf-8') def _code_contents(code): @@ -233,10 +243,10 @@ def _code_contents(code): # but not their actual names. contents = bytearray("{}, {}".format(code.co_argcount, len(code.co_varnames)),'utf-8') - # part1 = str(code.co_argcount) + ", " + str(len(code.co_varnames)) - - contents.append(bytearray(", {}, {}".format(len(code.co_cellvars), len(code.co_freevars)),'utf-8')) - # part2 = ", " + str(len(code.co_cellvars)) + ", " + str(len(code.co_freevars)) + contents.extend(b", ") + contents.extend(bytearray(str(len(code.co_cellvars)), 'utf-8')) + contents.extend(b", ") + contents.extend(bytearray(str(len(code.co_freevars)), 'utf-8')) # The code contents depends on any constants accessed by the # function. Note that we have to call _object_contents on each @@ -246,9 +256,12 @@ def _code_contents(code): # Note that we also always ignore the first entry of co_consts # which contains the function doc string. We assume that the # function does not access its doc string. - z= [str(_object_contents(cc)) for cc in code.co_consts[1:]] - # contents.append(bytearray(',(' + ','.join(map(_object_contents,code.co_consts[1:])) + ')','utf-8')) - contents.append(bytearray(',(' + ','.join(z) + ')','utf-8')) + # NOTE: This is not necessarily true. If no docstring, then co_consts[0] does + # have a string which is used. + z= [_object_contents(cc) for cc in code.co_consts[1:]] + contents.extend(b',(') + contents.extend(b','.join(z)) + contents.extend(b')') # The code contents depends on the variable names used to # accessed global variable, as changing the variable name changes @@ -256,12 +269,15 @@ def _code_contents(code): # function result. z= [str(_object_contents(cc)) for cc in code.co_names] # contents.append(bytearray(',(' + ','.join(map(_object_contents,code.co_names)) + ')','utf-8')) - contents.append(bytearray(',(' + ','.join(z) + ')','utf-8')) + # contents.extend(',(' + ','.join(z) + ')') + contents.extend(bytearray(str(',(' + ','.join(z) + ')'),'utf-8')) # The code contents depends on its actual code!!! - contents.append(bytearray(',(','utf-8') + code.co_code + bytearray(')','utf-8')) + contents.extend(b',(') + contents.extend(code.co_code) + contents.extend(b')') - return bytearray('').join(contents) + return contents def _function_contents(func): @@ -284,9 +300,16 @@ def _function_contents(func): # The function contents depends on the value of defaults arguments if func.__defaults__: - function_defaults_contents = [str(_object_contents(cc)) for cc in func.__defaults__] - contents.append(bytearray(',(','utf-8') + b','.join(function_defaults_contents) + bytearray(')','utf-8')) + function_defaults_contents = [_object_contents(cc) for cc in func.__defaults__] + + defaults = bytearray(b',(') + defaults.extend(bytearray(b',').join(function_defaults_contents)) + defaults.extend(b')') + + contents.append(defaults) + + # contents.append(bytearray(',(','utf-8') + b','.join(function_defaults_contents) + bytearray(')','utf-8')) else: contents.append(b',()') @@ -324,6 +347,7 @@ def _actionAppend(act1, act2): else: return ListAction([ a1, a2 ]) + def _do_create_keywords(args, kw): """This converts any arguments after the action argument into their equivalent keywords and adds them to the kw argument. @@ -351,6 +375,7 @@ def _do_create_keywords(args, kw): raise SCons.Errors.UserError( 'Cannot have both strfunction and cmdstr args to Action()') + def _do_create_action(act, kw): """This is the actual "implementation" for the Action factory method, below. This handles the @@ -403,6 +428,7 @@ def _do_create_action(act, kw): # Else fail silently (???) return None + def _do_create_list_action(act, kw): """A factory for list actions. Convert the input list into Actions and then wrap them in a ListAction.""" @@ -417,6 +443,7 @@ def _do_create_list_action(act, kw): else: return ListAction(acts) + def Action(act, *args, **kw): """A factory for action objects.""" # Really simple: the _do_create_* routines do the heavy lifting. @@ -443,8 +470,17 @@ class ActionBase(object): return str(self) def get_contents(self, target, source, env): - result = [ self.get_presig(target, source, env) ] - result = [ SCons.Util.to_bytes(r) for r in result ] + result = self.get_presig(target, source, env) + + # if not isinstance(result,bytearray): + # raise Exception("1result is:%s [%s] [[%s]] >>%s<< ]]%s[[" % (type(result), [type(l) for l in result],result,type(self),repr(self.get_presig))) + + if not isinstance(result,(bytes, bytearray)): + result = [ SCons.Util.to_bytes(r) for r in result ] + + # raise Exception("result is:%s"%[type(l) for l in result]) + saveit = result + # This should never happen, as the Action() factory should wrap # the varlist, but just in case an action is created directly, # we duplicate this check here. @@ -452,9 +488,19 @@ class ActionBase(object): if is_String(vl): vl = (vl,) for v in vl: # do the subst this way to ignore $(...$) parts: - result.append(SCons.Util.to_bytes(env.subst_target_source('${'+v+'}', SCons.Subst.SUBST_SIG, target, source))) + if isinstance(result, bytearray): + result.extend(SCons.Util.to_bytes(env.subst_target_source('${'+v+'}', SCons.Subst.SUBST_SIG, target, source))) + else: + result.append(SCons.Util.to_bytes(env.subst_target_source('${'+v+'}', SCons.Subst.SUBST_SIG, target, source))) + + # if not isinstance(result,bytearray): + # raise Exception("Presult is:%s [%s] (saved:%s)" % (type(result), [type(l) for l in result],type(saveit))) - return b''.join(result) + if isinstance(result, (bytes,bytearray)): + return result + else: + # raise Exception("Result is:%s [%s]" % (type(result), [type(l) for l in result])) + return b''.join(result) def __add__(self, other): return _actionAppend(self, other) @@ -518,14 +564,16 @@ class _ActionAction(ActionBase): SCons.Util.AddMethod(self, batch_key, 'batch_key') def print_cmd_line(self, s, target, source, env): - # In python 3, and in some of our tests, sys.stdout is - # a String io object, and it takes unicode strings only - # In other cases it's a regular Python 2.x file object - # which takes strings (bytes), and if you pass those a - # unicode object they try to decode with 'ascii' codec - # which fails if the cmd line has any hi-bit-set chars. - # This code assumes s is a regular string, but should - # work if it's unicode too. + """ + In python 3, and in some of our tests, sys.stdout is + a String io object, and it takes unicode strings only + In other cases it's a regular Python 2.x file object + which takes strings (bytes), and if you pass those a + unicode object they try to decode with 'ascii' codec + which fails if the cmd line has any hi-bit-set chars. + This code assumes s is a regular string, but should + work if it's unicode too. + """ try: sys.stdout.write(s + u"\n") except UnicodeDecodeError: @@ -624,13 +672,17 @@ def _string_from_cmd_list(cmd_list): cl.append(arg) return ' '.join(cl) -# A fiddlin' little function that has an 'import SCons.Environment' which -# can't be moved to the top level without creating an import loop. Since -# this import creates a local variable named 'SCons', it blocks access to -# the global variable, so we move it here to prevent complaints about local -# variables being used uninitialized. default_ENV = None + + def get_default_ENV(env): + """ + A fiddlin' little function that has an 'import SCons.Environment' which + can't be moved to the top level without creating an import loop. Since + this import creates a local variable named 'SCons', it blocks access to + the global variable, so we move it here to prevent complaints about local + variables being used uninitialized. + """ global default_ENV try: return env['ENV'] @@ -645,12 +697,15 @@ def get_default_ENV(env): default_ENV = SCons.Environment.Environment()['ENV'] return default_ENV -# This function is still in draft mode. We're going to need something like -# it in the long run as more and more places use subprocess, but I'm sure -# it'll have to be tweaked to get the full desired functionality. -# one special arg (so far?), 'error', to tell what to do with exceptions. + def _subproc(scons_env, cmd, error = 'ignore', **kw): - """Do common setup for a subprocess.Popen() call""" + """Do common setup for a subprocess.Popen() call + + This function is still in draft mode. We're going to need something like + it in the long run as more and more places use subprocess, but I'm sure + it'll have to be tweaked to get the full desired functionality. + one special arg (so far?), 'error', to tell what to do with exceptions. + """ # allow std{in,out,err} to be "'devnull'" io = kw.get('stdin') if is_String(io) and io == 'devnull': @@ -702,6 +757,7 @@ def _subproc(scons_env, cmd, error = 'ignore', **kw): stdout = stderr = f() return dummyPopen(e) + class CommandAction(_ActionAction): """Class for command-execution actions.""" def __init__(self, cmd, **kw): @@ -868,6 +924,7 @@ class CommandAction(_ActionAction): res.append(env.fs.File(d)) return res + class CommandGeneratorAction(ActionBase): """Class for command-generator actions.""" def __init__(self, generator, kw): @@ -940,24 +997,26 @@ class CommandGeneratorAction(ActionBase): -# A LazyAction is a kind of hybrid generator and command action for -# strings of the form "$VAR". These strings normally expand to other -# strings (think "$CCCOM" to "$CC -c -o $TARGET $SOURCE"), but we also -# want to be able to replace them with functions in the construction -# environment. Consequently, we want lazy evaluation and creation of -# an Action in the case of the function, but that's overkill in the more -# normal case of expansion to other strings. -# -# So we do this with a subclass that's both a generator *and* -# a command action. The overridden methods all do a quick check -# of the construction variable, and if it's a string we just call -# the corresponding CommandAction method to do the heavy lifting. -# If not, then we call the same-named CommandGeneratorAction method. -# The CommandGeneratorAction methods work by using the overridden -# _generate() method, that is, our own way of handling "generation" of -# an action based on what's in the construction variable. class LazyAction(CommandGeneratorAction, CommandAction): + """ + A LazyAction is a kind of hybrid generator and command action for + strings of the form "$VAR". These strings normally expand to other + strings (think "$CCCOM" to "$CC -c -o $TARGET $SOURCE"), but we also + want to be able to replace them with functions in the construction + environment. Consequently, we want lazy evaluation and creation of + an Action in the case of the function, but that's overkill in the more + normal case of expansion to other strings. + + So we do this with a subclass that's both a generator *and* + a command action. The overridden methods all do a quick check + of the construction variable, and if it's a string we just call + the corresponding CommandAction method to do the heavy lifting. + If not, then we call the same-named CommandGeneratorAction method. + The CommandGeneratorAction methods work by using the overridden + _generate() method, that is, our own way of handling "generation" of + an action based on what's in the construction variable. + """ def __init__(self, var, kw): if SCons.Debug.track_instances: logInstanceCreation(self, 'Action.LazyAction') @@ -1109,7 +1168,6 @@ class FunctionAction(_ActionAction): # more information about this issue. del exc_info - def get_presig(self, target, source, env): """Return the signature contents of this callable action.""" try: @@ -1195,7 +1253,7 @@ class ActionCaller(object): actfunc = self.parent.actfunc try: # "self.actfunc" is a function. - contents = bytearray(actfunc.__code__.co_code,'utf-8') + contents = actfunc.__code__.co_code except AttributeError: # "self.actfunc" is a callable object. try: diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py index 711b1b6..4a233f1 100644 --- a/src/engine/SCons/ActionTests.py +++ b/src/engine/SCons/ActionTests.py @@ -1448,7 +1448,7 @@ class CommandGeneratorActionTestCase(unittest.TestCase): a = self.factory(f_global) c = a.get_contents(target=[], source=[], env=env) - assert c in func_matches, repr(c) + assert c in func_matches, "Got\n"+repr(c)+"\nExpected on of \n"+"\n".join([repr(f) for f in func_matches]) a = self.factory(f_local) c = a.get_contents(target=[], source=[], env=env) @@ -1605,7 +1605,9 @@ class FunctionActionTestCase(unittest.TestCase): a = factory(GlobalFunc) c = a.get_contents(target=[], source=[], env=Environment()) - assert c in func_matches, repr(c) + # assert c in func_matches, repr(c) + assert c in func_matches, "Got\n"+repr(c)+"\nExpected one of \n"+"\n".join([repr(f) for f in func_matches]) + a = factory(LocalFunc) c = a.get_contents(target=[], source=[], env=Environment()) @@ -2023,6 +2025,51 @@ class ActionCompareTestCase(unittest.TestCase): assert dog.get_name(env) == 'DOG', dog.get_name(env) +class TestClass: + """A test class used by ObjectContentsTestCase.test_object_contents""" + def __init__(self): + self.a = "a" + self.b = "b" + def method(self, arg): + pass + + +class ObjectContentsTestCase(unittest.TestCase): + + def test_function_contents(self): + """Test that Action._function_contents works""" + + def func1(a, b, c): + """A test function""" + return a + + c = SCons.Action._function_contents(func1) + assert bytearray('3, 3, 0, 0,(),(),(|\x00\x00S),(),()','utf-8') == c, repr(c) + + + @unittest.skip("Results vary between py2 and py3, not sure if test makes sense to implement") + def test_object_contents(self): + """Test that Action._object_contents works""" + + # See definition above + o = TestClass() + c = SCons.Action._object_contents(o) + expected = bytearray("(i__main__\nTestClass\np1\n(dp2\nS'a'\nS'a'\nsS'b'\nS'b'\nsb.", 'utf-8') + assert expected == c, "Got\n" + repr(c) + "\nExpected\n" + repr(expected) + + @unittest.skip("Results vary between py2 and py3, not sure if test makes sense to implement") + def test_code_contents(self): + """Test that Action._code_contents works""" + + code = compile("print('Hello, World!')", '', 'exec') + c = SCons.Action._code_contents(code) + expected = bytearray("0, 0, 0, 0,(N.),(),(d\x00\x00GHd\x01\x00S)", 'utf-8') + assert expected == c, "Got\n" + repr(c) + "\nExpected\n" + repr(expected) + + + + + if __name__ == "__main__": suite = unittest.TestSuite() tclasses = [ _ActionActionTestCase, @@ -2034,7 +2081,8 @@ if __name__ == "__main__": LazyActionTestCase, ActionCallerTestCase, ActionFactoryTestCase, - ActionCompareTestCase ] + ActionCompareTestCase, + ObjectContentsTestCase ] for tclass in tclasses: names = unittest.getTestCaseNames(tclass, 'test_') suite.addTests(list(map(tclass, names))) -- cgit v0.12 From 567f5aa089a1ad664df268cdb128e8c92808522d Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 20 Feb 2017 20:05:40 -0800 Subject: fix string/bytearray issue for py2/3 port --- src/engine/SCons/Executor.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/engine/SCons/Executor.py b/src/engine/SCons/Executor.py index dd5088d..aadca01 100644 --- a/src/engine/SCons/Executor.py +++ b/src/engine/SCons/Executor.py @@ -26,6 +26,7 @@ Nodes. # 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. +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -455,10 +456,16 @@ class Executor(object, with_metaclass(NoSlotsPyPy)): except KeyError: pass env = self.get_build_env() - result = b"".join([action.get_contents(self.get_all_targets(), + sga = self.get_action_list() + sga_contents = [action.get_contents(self.get_all_targets(), self.get_all_sources(), env) - for action in self.get_action_list()]) + for action in self.get_action_list()] + + result = bytearray() + for a in sga_contents: + result.extend(a) + self._memo['get_contents'] = result return result -- cgit v0.12 From b3fbe913fe07395fff65da4f968a5e70c2fe753b Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 25 Feb 2017 15:02:50 -0800 Subject: Reformat file to modern python standards. (With hope towards PEP-8) --- src/engine/SCons/dblite.py | 413 +++++++++++++++++++++++---------------------- 1 file changed, 213 insertions(+), 200 deletions(-) diff --git a/src/engine/SCons/dblite.py b/src/engine/SCons/dblite.py index 588a7ab..19a8693 100644 --- a/src/engine/SCons/dblite.py +++ b/src/engine/SCons/dblite.py @@ -12,245 +12,258 @@ from SCons.compat import PICKLE_PROTOCOL keep_all_files = 00000 ignore_corrupt_dbfiles = 0 + def corruption_warning(filename): print("Warning: Discarding corrupt database:", filename) -try: unicode + +try: + unicode except NameError: def is_string(s): return isinstance(s, str) else: def is_string(s): return type(s) in (str, unicode) + + def is_bytes(s): - return isinstance (s, bytes) + return isinstance(s, bytes) + + try: unicode('a') except NameError: - def unicode(s): return s + def unicode(s): + return s dblite_suffix = '.dblite' if bytes is not str: dblite_suffix += '.p3' tmp_suffix = '.tmp' + class dblite(object): + # Squirrel away references to the functions in various modules + # that we'll use when our __del__() method calls our sync() method + # during shutdown. We might get destroyed when Python is in the midst + # of tearing down the different modules we import in an essentially + # arbitrary order, and some of the various modules's global attributes + # may already be wiped out from under us. + # + # See the discussion at: + # http://mail.python.org/pipermail/python-bugs-list/2003-March/016877.html - # Squirrel away references to the functions in various modules - # that we'll use when our __del__() method calls our sync() method - # during shutdown. We might get destroyed when Python is in the midst - # of tearing down the different modules we import in an essentially - # arbitrary order, and some of the various modules's global attributes - # may already be wiped out from under us. - # - # See the discussion at: - # http://mail.python.org/pipermail/python-bugs-list/2003-March/016877.html - - _open = open - _pickle_dump = staticmethod(pickle.dump) - _pickle_protocol = PICKLE_PROTOCOL - _os_chmod = os.chmod - try: - _os_chown = os.chown - except AttributeError: - _os_chown = None - _os_rename = os.rename - _os_unlink = os.unlink - _shutil_copyfile = shutil.copyfile - _time_time = time.time - - def __init__(self, file_base_name, flag, mode): - assert flag in (None, "r", "w", "c", "n") - if (flag is None): flag = "r" - base, ext = os.path.splitext(file_base_name) - if ext == dblite_suffix: - # There's already a suffix on the file name, don't add one. - self._file_name = file_base_name - self._tmp_name = base + tmp_suffix - else: - self._file_name = file_base_name + dblite_suffix - self._tmp_name = file_base_name + tmp_suffix - self._flag = flag - self._mode = mode - self._dict = {} - self._needs_sync = 00000 - if self._os_chown is not None and (os.geteuid()==0 or os.getuid()==0): - # running as root; chown back to current owner/group when done - try: - statinfo = os.stat(self._file_name) - self._chown_to = statinfo.st_uid - self._chgrp_to = statinfo.st_gid - except OSError as e: - # db file doesn't exist yet. - # Check os.environ for SUDO_UID, use if set - self._chown_to = int(os.environ.get('SUDO_UID', -1)) - self._chgrp_to = int(os.environ.get('SUDO_GID', -1)) - else: - self._chown_to = -1 # don't chown - self._chgrp_to = -1 # don't chgrp - if (self._flag == "n"): - self._open(self._file_name, "wb", self._mode) - else: - try: - f = self._open(self._file_name, "rb") - except IOError as e: - if (self._flag != "c"): - raise e - self._open(self._file_name, "wb", self._mode) - else: - p = f.read() - if (len(p) > 0): - try: - self._dict = pickle.loads(p) - except (pickle.UnpicklingError, EOFError, KeyError): - # Note how we catch KeyErrors too here, which might happen - # when we don't have cPickle available (default pickle - # throws it). - if (ignore_corrupt_dbfiles == 0): raise - if (ignore_corrupt_dbfiles == 1): - corruption_warning(self._file_name) - - def close(self): - if (self._needs_sync): - self.sync() - - def __del__(self): - self.close() - - def sync(self): - self._check_writable() - f = self._open(self._tmp_name, "wb", self._mode) - 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 - # may not be able to chmod the file if it's owned by someone else - # (e.g. from a previous run as root). We should still be able to - # unlink() the file if the directory's writable, though, so ignore - # any OSError exception thrown by the chmod() call. - try: self._os_chmod(self._file_name, 0o777) - except OSError: pass - self._os_unlink(self._file_name) - self._os_rename(self._tmp_name, self._file_name) - if self._os_chown is not None and self._chown_to > 0: # don't chown to root or -1 - try: - self._os_chown(self._file_name, self._chown_to, self._chgrp_to) - except OSError: - pass - self._needs_sync = 00000 - if (keep_all_files): - self._shutil_copyfile( - self._file_name, - self._file_name + "_" + str(int(self._time_time()))) + _open = open + _pickle_dump = staticmethod(pickle.dump) + _pickle_protocol = PICKLE_PROTOCOL + _os_chmod = os.chmod + try: + _os_chown = os.chown + except AttributeError: + _os_chown = None + _os_rename = os.rename + _os_unlink = os.unlink + _shutil_copyfile = shutil.copyfile + _time_time = time.time + + def __init__(self, file_base_name, flag, mode): + assert flag in (None, "r", "w", "c", "n") + if (flag is None): flag = "r" + base, ext = os.path.splitext(file_base_name) + if ext == dblite_suffix: + # There's already a suffix on the file name, don't add one. + self._file_name = file_base_name + self._tmp_name = base + tmp_suffix + else: + self._file_name = file_base_name + dblite_suffix + self._tmp_name = file_base_name + tmp_suffix + self._flag = flag + self._mode = mode + self._dict = {} + self._needs_sync = 00000 + if self._os_chown is not None and (os.geteuid() == 0 or os.getuid() == 0): + # running as root; chown back to current owner/group when done + try: + statinfo = os.stat(self._file_name) + self._chown_to = statinfo.st_uid + self._chgrp_to = statinfo.st_gid + except OSError as e: + # db file doesn't exist yet. + # Check os.environ for SUDO_UID, use if set + self._chown_to = int(os.environ.get('SUDO_UID', -1)) + self._chgrp_to = int(os.environ.get('SUDO_GID', -1)) + else: + self._chown_to = -1 # don't chown + self._chgrp_to = -1 # don't chgrp + if (self._flag == "n"): + self._open(self._file_name, "wb", self._mode) + else: + try: + f = self._open(self._file_name, "rb") + except IOError as e: + if (self._flag != "c"): + raise e + self._open(self._file_name, "wb", self._mode) + else: + p = f.read() + if (len(p) > 0): + try: + self._dict = pickle.loads(p) + except (pickle.UnpicklingError, EOFError, KeyError): + # Note how we catch KeyErrors too here, which might happen + # when we don't have cPickle available (default pickle + # throws it). + if (ignore_corrupt_dbfiles == 0): raise + if (ignore_corrupt_dbfiles == 1): + corruption_warning(self._file_name) + + def close(self): + if (self._needs_sync): + self.sync() + + def __del__(self): + self.close() - def _check_writable(self): - if (self._flag == "r"): - raise IOError("Read-only database: %s" % self._file_name) + def sync(self): + self._check_writable() + f = self._open(self._tmp_name, "wb", self._mode) + 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 + # may not be able to chmod the file if it's owned by someone else + # (e.g. from a previous run as root). We should still be able to + # unlink() the file if the directory's writable, though, so ignore + # any OSError exception thrown by the chmod() call. + try: + self._os_chmod(self._file_name, 0o777) + except OSError: + pass + self._os_unlink(self._file_name) + self._os_rename(self._tmp_name, self._file_name) + if self._os_chown is not None and self._chown_to > 0: # don't chown to root or -1 + try: + self._os_chown(self._file_name, self._chown_to, self._chgrp_to) + except OSError: + pass + self._needs_sync = 00000 + if (keep_all_files): + self._shutil_copyfile( + self._file_name, + self._file_name + "_" + str(int(self._time_time()))) - def __getitem__(self, key): - return self._dict[key] + def _check_writable(self): + if (self._flag == "r"): + raise IOError("Read-only database: %s" % self._file_name) - def __setitem__(self, key, value): - self._check_writable() - if (not is_string(key)): - raise TypeError("key `%s' must be a string but is %s" % (key, type(key))) - if (not is_bytes(value)): - raise TypeError("value `%s' must be a bytes but is %s" % (value, type(value))) - self._dict[key] = value - self._needs_sync = 0o001 + def __getitem__(self, key): + return self._dict[key] - def keys(self): - return list(self._dict.keys()) + def __setitem__(self, key, value): + self._check_writable() + if (not is_string(key)): + raise TypeError("key `%s' must be a string but is %s" % (key, type(key))) + if (not is_bytes(value)): + raise TypeError("value `%s' must be a bytes but is %s" % (value, type(value))) + self._dict[key] = value + self._needs_sync = 0o001 - def has_key(self, key): - return key in self._dict + def keys(self): + return list(self._dict.keys()) - def __contains__(self, key): - return key in self._dict + def has_key(self, key): + return key in self._dict - def iterkeys(self): - # Wrapping name in () prevents fixer from "fixing" this - return (self._dict.iterkeys)() + def __contains__(self, key): + return key in self._dict - __iter__ = iterkeys + def iterkeys(self): + # Wrapping name in () prevents fixer from "fixing" this + return (self._dict.iterkeys)() + + __iter__ = iterkeys + + def __len__(self): + return len(self._dict) - def __len__(self): - return len(self._dict) def open(file, flag=None, mode=0o666): - return dblite(file, flag, mode) + return dblite(file, flag, mode) + def _exercise(): - db = open("tmp", "n") - assert len(db) == 0 - db["foo"] = "bar" - assert db["foo"] == "bar" - db[unicode("ufoo")] = unicode("ubar") - assert db[unicode("ufoo")] == unicode("ubar") - db.sync() - db = open("tmp", "c") - assert len(db) == 2, len(db) - assert db["foo"] == "bar" - db["bar"] = "foo" - assert db["bar"] == "foo" - db[unicode("ubar")] = unicode("ufoo") - assert db[unicode("ubar")] == unicode("ufoo") - db.sync() - db = open("tmp", "r") - assert len(db) == 4, len(db) - assert db["foo"] == "bar" - assert db["bar"] == "foo" - assert db[unicode("ufoo")] == unicode("ubar") - assert db[unicode("ubar")] == unicode("ufoo") - try: + db = open("tmp", "n") + assert len(db) == 0 + db["foo"] = "bar" + assert db["foo"] == "bar" + db[unicode("ufoo")] = unicode("ubar") + assert db[unicode("ufoo")] == unicode("ubar") + db.sync() + db = open("tmp", "c") + assert len(db) == 2, len(db) + assert db["foo"] == "bar" + db["bar"] = "foo" + assert db["bar"] == "foo" + db[unicode("ubar")] = unicode("ufoo") + assert db[unicode("ubar")] == unicode("ufoo") db.sync() - except IOError as e: - assert str(e) == "Read-only database: tmp.dblite" - else: - raise RuntimeError("IOError expected.") - db = open("tmp", "w") - assert len(db) == 4 - db["ping"] = "pong" - db.sync() - try: - db[(1,2)] = "tuple" - except TypeError as e: - assert str(e) == "key `(1, 2)' must be a string but is ", str(e) - else: - raise RuntimeError("TypeError exception expected") - try: - db["list"] = [1,2] - except TypeError as e: - assert str(e) == "value `[1, 2]' must be a string but is ", str(e) - else: - raise RuntimeError("TypeError exception expected") - db = open("tmp", "r") - assert len(db) == 5 - db = open("tmp", "n") - assert len(db) == 0 - dblite._open("tmp.dblite", "w") - db = open("tmp", "r") - dblite._open("tmp.dblite", "w").write("x") - try: db = open("tmp", "r") - except pickle.UnpicklingError: - pass - else: - raise RuntimeError("pickle exception expected.") - global ignore_corrupt_dbfiles - ignore_corrupt_dbfiles = 2 - db = open("tmp", "r") - assert len(db) == 0 - os.unlink("tmp.dblite") - try: + assert len(db) == 4, len(db) + assert db["foo"] == "bar" + assert db["bar"] == "foo" + assert db[unicode("ufoo")] == unicode("ubar") + assert db[unicode("ubar")] == unicode("ufoo") + try: + db.sync() + except IOError as e: + assert str(e) == "Read-only database: tmp.dblite" + else: + raise RuntimeError("IOError expected.") db = open("tmp", "w") - except IOError as e: - assert str(e) == "[Errno 2] No such file or directory: 'tmp.dblite'", str(e) - else: - raise RuntimeError("IOError expected.") + assert len(db) == 4 + db["ping"] = "pong" + db.sync() + try: + db[(1, 2)] = "tuple" + except TypeError as e: + assert str(e) == "key `(1, 2)' must be a string but is ", str(e) + else: + raise RuntimeError("TypeError exception expected") + try: + db["list"] = [1, 2] + except TypeError as e: + assert str(e) == "value `[1, 2]' must be a string but is ", str(e) + else: + raise RuntimeError("TypeError exception expected") + db = open("tmp", "r") + assert len(db) == 5 + db = open("tmp", "n") + assert len(db) == 0 + dblite._open("tmp.dblite", "w") + db = open("tmp", "r") + dblite._open("tmp.dblite", "w").write("x") + try: + db = open("tmp", "r") + except pickle.UnpicklingError: + pass + else: + raise RuntimeError("pickle exception expected.") + global ignore_corrupt_dbfiles + ignore_corrupt_dbfiles = 2 + db = open("tmp", "r") + assert len(db) == 0 + os.unlink("tmp.dblite") + try: + db = open("tmp", "w") + except IOError as e: + assert str(e) == "[Errno 2] No such file or directory: 'tmp.dblite'", str(e) + else: + raise RuntimeError("IOError expected.") + if (__name__ == "__main__"): - _exercise() + _exercise() # Local Variables: # tab-width:4 -- cgit v0.12 From d672220f05ecd77beeaab90042f3dd31def0a102 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 25 Feb 2017 20:41:16 -0800 Subject: Added ability for must_match to pass message to be output if it fails --- QMTest/TestCommon.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/QMTest/TestCommon.py b/QMTest/TestCommon.py index 9093cc9..cd9e990 100644 --- a/QMTest/TestCommon.py +++ b/QMTest/TestCommon.py @@ -469,7 +469,7 @@ class TestCommon(TestCmd): print("Missing one of: `%s'" % "', `".join(missing)) self.fail_test(missing) - def must_match(self, file, expect, mode = 'rb', match=None): + def must_match(self, file, expect, mode = 'rb', match=None, message=None): """Matches the contents of the specified file (first argument) against the expected contents (second argument). The expected contents are a list of lines or a string which will be split @@ -479,7 +479,7 @@ class TestCommon(TestCmd): if not match: match = self.match try: - self.fail_test(not match(to_str(file_contents), to_str(expect))) + self.fail_test(not match(to_str(file_contents), to_str(expect)), message=message) except KeyboardInterrupt: raise except: -- cgit v0.12 From 26b9ebbba49e0ace12eef8e03f80b5ee8e1b955d Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 25 Feb 2017 20:44:13 -0800 Subject: fix issue which was modifying the function signature and causing incorrect rebuilds in test/Action/function.py --- src/engine/SCons/Executor.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/engine/SCons/Executor.py b/src/engine/SCons/Executor.py index aadca01..2fa3f05 100644 --- a/src/engine/SCons/Executor.py +++ b/src/engine/SCons/Executor.py @@ -456,15 +456,11 @@ class Executor(object, with_metaclass(NoSlotsPyPy)): except KeyError: pass env = self.get_build_env() - sga = self.get_action_list() - sga_contents = [action.get_contents(self.get_all_targets(), + + result = bytearray("").join([action.get_contents(self.get_all_targets(), self.get_all_sources(), env) - for action in self.get_action_list()] - - result = bytearray() - for a in sga_contents: - result.extend(a) + for action in self.get_action_list()]) self._memo['get_contents'] = result return result -- cgit v0.12 From fb6c9bebf7006132df1cdff5ea34401abe7364d7 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 25 Feb 2017 20:44:35 -0800 Subject: PEP-8 fixes --- src/engine/SCons/Node/FS.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 0de3989..9b057be 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -2434,6 +2434,7 @@ class RootDir(Dir): def src_builder(self): return _null + class FileNodeInfo(SCons.Node.NodeInfoBase): __slots__ = ('csig', 'timestamp', 'size') current_version_id = 2 @@ -2485,6 +2486,7 @@ class FileNodeInfo(SCons.Node.NodeInfoBase): if key not in ('__weakref__',): setattr(self, key, value) + class FileBuildInfo(SCons.Node.BuildInfoBase): __slots__ = () current_version_id = 2 @@ -2515,6 +2517,7 @@ class FileBuildInfo(SCons.Node.BuildInfoBase): pass else: setattr(self, attr, list(map(node_to_str, val))) + def convert_from_sconsign(self, dir, name): """ Converts a newly-read FileBuildInfo object for in-SCons use @@ -2523,6 +2526,7 @@ class FileBuildInfo(SCons.Node.BuildInfoBase): perform--but we're leaving this method here to make that clear. """ pass + def prepare_dependencies(self): """ Prepares a FileBuildInfo object for explaining what changed @@ -2551,6 +2555,7 @@ class FileBuildInfo(SCons.Node.BuildInfoBase): s = ni.str_to_node(s) nodes.append(s) setattr(self, nattr, nodes) + def format(self, names=0): result = [] bkids = self.bsources + self.bdepends + self.bimplicit @@ -2563,6 +2568,7 @@ class FileBuildInfo(SCons.Node.BuildInfoBase): result.append('%s [%s]' % (self.bactsig, self.bact)) return '\n'.join(result) + class File(Base): """A class for files in a file system. """ -- cgit v0.12 From 048d75b8aa9ac50c7aaab8b7c0c31923482be8b2 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 25 Feb 2017 20:46:40 -0800 Subject: leave some debug logic for detecting build action change signature changes commented out in file --- src/engine/SCons/Node/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 2bf38c2..8e00fdb 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -350,6 +350,7 @@ class NodeInfoBase(object): """ __slots__ = ('__weakref__',) current_version_id = 2 + def update(self, node): try: field_list = self.field_list @@ -366,8 +367,10 @@ class NodeInfoBase(object): pass else: setattr(self, f, func()) + def convert(self, node, val): pass + def merge(self, other): """ Merge the fields of another object into this object. Already existing @@ -445,6 +448,7 @@ class BuildInfoBase(object): __slots__ = ("bsourcesigs", "bdependsigs", "bimplicitsigs", "bactsig", "bsources", "bdepends", "bact", "bimplicit", "__weakref__") current_version_id = 2 + def __init__(self): # Create an object attribute from the class attribute so it ends up # in the pickled data in the .sconsign file. @@ -452,6 +456,7 @@ class BuildInfoBase(object): self.bdependsigs = [] self.bimplicitsigs = [] self.bactsig = None + def merge(self, other): """ Merge the fields of another object into this object. Already existing @@ -1651,6 +1656,9 @@ class Node(object, with_metaclass(NoSlotsPyPy)): if old.bact == new.bact: lines.append("the contents of the build action changed\n" + fmt_with_title('action: ', new.bact)) + + # lines.append("the contents of the build action changed [%s] [%s]\n"%(old.bactsig,new.bactsig) + + # fmt_with_title('action: ', new.bact)) else: lines.append("the build action changed:\n" + fmt_with_title('old: ', old.bact) + -- cgit v0.12 From 6e643ad60b518a61663c6d9ca32ebe901df04ff8 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 25 Feb 2017 20:48:43 -0800 Subject: fix signature calc issues for functions actions --- src/engine/SCons/Action.py | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index c5133de..ceda168 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -260,17 +260,17 @@ def _code_contents(code): # have a string which is used. z= [_object_contents(cc) for cc in code.co_consts[1:]] contents.extend(b',(') - contents.extend(b','.join(z)) + contents.extend(bytearray(',','utf-8').join(z)) contents.extend(b')') # The code contents depends on the variable names used to # accessed global variable, as changing the variable name changes # the variable actually accessed and therefore changes the # function result. - z= [str(_object_contents(cc)) for cc in code.co_names] - # contents.append(bytearray(',(' + ','.join(map(_object_contents,code.co_names)) + ')','utf-8')) - # contents.extend(',(' + ','.join(z) + ')') - contents.extend(bytearray(str(',(' + ','.join(z) + ')'),'utf-8')) + z= [bytearray(_object_contents(cc)) for cc in code.co_names] + contents.extend(b',(') + contents.extend(bytearray(',','utf-8').join(z)) + contents.extend(b')') # The code contents depends on its actual code!!! contents.extend(b',(') @@ -321,9 +321,13 @@ def _function_contents(func): closure_contents = [_object_contents(x.cell_contents) for x in closure] except AttributeError: closure_contents = [] - contents.append(b',(' + ','.join(closure_contents).encode('ascii') + b')') - return bytearray('','utf-8').join(contents) + contents.append(b',(') + contents.append(bytearray(b',').join(closure_contents)) + contents.append(b')') + # contents.append(b'BBBBBBBB') + + return bytearray(b'').join(contents) def _actionAppend(act1, act2): @@ -472,14 +476,15 @@ class ActionBase(object): def get_contents(self, target, source, env): result = self.get_presig(target, source, env) - # if not isinstance(result,bytearray): - # raise Exception("1result is:%s [%s] [[%s]] >>%s<< ]]%s[[" % (type(result), [type(l) for l in result],result,type(self),repr(self.get_presig))) - if not isinstance(result,(bytes, bytearray)): - result = [ SCons.Util.to_bytes(r) for r in result ] + result = bytearray("").join([ SCons.Util.to_bytes(r) for r in result ]) + else: + # Make a copy and put in bytearray, without this the contents returned by get_presig + # can be changed by the logic below, appending with each call and causing very + # hard to track down issues... + result = bytearray(result) - # raise Exception("result is:%s"%[type(l) for l in result]) - saveit = result + # At this point everything should be a bytearray # This should never happen, as the Action() factory should wrap # the varlist, but just in case an action is created directly, @@ -491,16 +496,15 @@ class ActionBase(object): if isinstance(result, bytearray): result.extend(SCons.Util.to_bytes(env.subst_target_source('${'+v+'}', SCons.Subst.SUBST_SIG, target, source))) else: - result.append(SCons.Util.to_bytes(env.subst_target_source('${'+v+'}', SCons.Subst.SUBST_SIG, target, source))) + raise Exception("WE SHOULD NEVER GET HERE result should be bytearray not:%s"%type(result)) + # result.append(SCons.Util.to_bytes(env.subst_target_source('${'+v+'}', SCons.Subst.SUBST_SIG, target, source))) - # if not isinstance(result,bytearray): - # raise Exception("Presult is:%s [%s] (saved:%s)" % (type(result), [type(l) for l in result],type(saveit))) if isinstance(result, (bytes,bytearray)): return result else: - # raise Exception("Result is:%s [%s]" % (type(result), [type(l) for l in result])) - return b''.join(result) + raise Exception("WE SHOULD NEVER GET HERE - #2 result should be bytearray not:%s" % type(result)) + # return b''.join(result) def __add__(self, other): return _actionAppend(self, other) @@ -996,8 +1000,6 @@ class CommandGeneratorAction(ActionBase): return self._generate(None, None, env, 1, executor).get_targets(env, executor) - - class LazyAction(CommandGeneratorAction, CommandAction): """ A LazyAction is a kind of hybrid generator and command action for @@ -1095,6 +1097,7 @@ class FunctionAction(_ActionAction): c = env.subst(self.cmdstr, SUBST_RAW, target, source) if c: return c + def array(a): def quote(s): try: @@ -1207,7 +1210,7 @@ class ListAction(ActionBase): Simple concatenation of the signatures of the elements. """ - return b"".join([x.get_contents(target, source, env) for x in self.list]) + return b"".join([bytes(x.get_contents(target, source, env)) for x in self.list]) def __call__(self, target, source, env, exitstatfunc=_null, presub=_null, show=_null, execute=_null, chdir=_null, executor=None): -- cgit v0.12 From 58bd2a948ecf3089ac3a1ea47888748a8b6693bb Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 25 Feb 2017 20:49:07 -0800 Subject: PEP-8 fixes --- src/engine/SCons/SConsign.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/engine/SCons/SConsign.py b/src/engine/SCons/SConsign.py index 75d2c41..3bd4b71 100644 --- a/src/engine/SCons/SConsign.py +++ b/src/engine/SCons/SConsign.py @@ -41,6 +41,7 @@ import SCons.Warnings from SCons.compat import PICKLE_PROTOCOL + def corrupt_dblite_warning(filename): SCons.Warnings.warn(SCons.Warnings.CorruptSConsignWarning, "Ignoring corrupt .sconsign file: %s"%filename) @@ -48,7 +49,7 @@ def corrupt_dblite_warning(filename): SCons.dblite.ignore_corrupt_dbfiles = 1 SCons.dblite.corruption_warning = corrupt_dblite_warning -#XXX Get rid of the global array so this becomes re-entrant. +# XXX Get rid of the global array so this becomes re-entrant. sig_files = [] # Info for the database SConsign implementation (now the default): @@ -62,6 +63,7 @@ DB_Module = SCons.dblite DB_Name = ".sconsign" DB_sync_list = [] + def Get_DataBase(dir): global DataBase, DB_Module, DB_Name top = dir.fs.Top @@ -90,6 +92,7 @@ def Get_DataBase(dir): print("DataBase =", DataBase) raise + def Reset(): """Reset global state. Used by unit tests that end up using SConsign multiple times to get a clean slate for each test.""" @@ -99,6 +102,7 @@ def Reset(): normcase = os.path.normcase + def write(): global sig_files for sig_file in sig_files: @@ -117,6 +121,7 @@ def write(): else: closemethod() + class SConsignEntry(object): """ Wrapper class for the generic entry in a .sconsign file. @@ -159,6 +164,7 @@ class SConsignEntry(object): if key not in ('_version_id','__weakref__'): setattr(self, key, value) + class Base(object): """ This is the controlling class for the signatures for the collection of @@ -213,6 +219,7 @@ class Base(object): self.entries[key] = entry self.to_be_merged = {} + class DB(Base): """ A Base subclass that reads and writes signature information @@ -285,6 +292,7 @@ class DB(Base): else: syncmethod() + class Dir(Base): def __init__(self, fp=None, dir=None): """ @@ -304,6 +312,7 @@ class Dir(Base): for key, entry in list(self.entries.items()): entry.convert_from_sconsign(dir, key) + class DirFile(Dir): """ Encapsulates reading and writing a per-directory .sconsign file. @@ -394,6 +403,7 @@ class DirFile(Dir): ForDirectory = DB + def File(name, dbm_module=None): """ Arrange for all signatures to be stored in a global .sconsign.db* -- cgit v0.12 From 3f1009759b233ba552b4fb496c3663bb24230f0e Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 25 Feb 2017 20:49:27 -0800 Subject: PEP-8 changes --- src/engine/SCons/Script/Main.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py index f8cb24c..b82b6a5 100644 --- a/src/engine/SCons/Script/Main.py +++ b/src/engine/SCons/Script/Main.py @@ -65,6 +65,7 @@ import SCons.Warnings import SCons.Script.Interactive + def fetch_win32_parallel_msg(): # A subsidiary function that exists solely to isolate this import # so we don't have to pull it in on all platforms, and so that an @@ -75,6 +76,7 @@ def fetch_win32_parallel_msg(): import SCons.Platform.win32 return SCons.Platform.win32.parallel_msg + def revert_io(): # This call is added to revert stderr and stdout to the original # ones just in case some build rule or something else in the system @@ -91,6 +93,7 @@ progress_display = SCons.Util.DisplayEngine() first_command_start = None last_command_end = None + class Progressor(object): prev = '' count = 0 @@ -154,9 +157,11 @@ def Progress(*args, **kw): _BuildFailures = [] + def GetBuildFailures(): return _BuildFailures + class BuildTask(SCons.Taskmaster.OutOfDateTask): """An SCons build task.""" progress = ProgressObject @@ -306,6 +311,7 @@ class BuildTask(SCons.Taskmaster.OutOfDateTask): if explanation: sys.stdout.write("scons: " + explanation) + class CleanTask(SCons.Taskmaster.AlwaysTask): """An SCons clean task.""" def fs_delete(self, path, pathstr, remove=True): -- cgit v0.12 From 67e2e4f4f9b93bc2187f48bc0fecb6129d7aa286 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 25 Feb 2017 20:50:33 -0800 Subject: remove code to check if python version supports lexical closures (has been supported since python 2.2). Use must_match()'s message param --- test/Actions/function.py | 48 +++++++++--------------------------------------- 1 file changed, 9 insertions(+), 39 deletions(-) diff --git a/test/Actions/function.py b/test/Actions/function.py index 02dbcc7..941498b 100644 --- a/test/Actions/function.py +++ b/test/Actions/function.py @@ -74,7 +74,7 @@ def toto(header='%(header)s', trailer='%(trailer)s'): f = open(str(target[0]),'wb') f.write(header) for d in env['ENVDEPS']: - f.write(d+'%(separator)s') + f.write(bytearray(d+'%(separator)s')) f.write(trailer+'\\n') f.write(str(foo())+'\\n') f.write(r.match('aaaa').group(1)+'\\n') @@ -88,43 +88,8 @@ def toto(header='%(header)s', trailer='%(trailer)s'): return writeDeps ''' -NoClosure = \ -r''' -def toto(header='%(header)s', trailer='%(trailer)s'): - xxx = %(closure_cell_value)s - def writeDeps(target, source, env, b=%(b)s, r=r %(extraarg)s , - header=header, trailer=trailer, xxx=xxx): - """+'"""%(docstring)s"""'+""" - def foo(b=b, xxx=xxx): - return %(nestedfuncexp)s - f = open(str(target[0]),'wb') - f.write(header) - for d in env['ENVDEPS']: - f.write(d+'%(separator)s') - f.write(trailer+'\\n') - f.write(str(foo())+'\\n') - f.write(r.match('aaaa').group(1)+'\\n') - %(extracode)s - try: - f.write(str(xarg)+'\\n') - except NameError: - pass - f.close() - return writeDeps -''' - -try: - # Check that lexical closure are supported - def a(): - x = 0 - def b(): - return x - return b - a().func_closure[0].cell_contents - exec( withClosure % optEnv ) -except (AttributeError, TypeError): - exec( NoClosure % optEnv ) +exec( withClosure % optEnv ) genHeaderBld = SCons.Builder.Builder( action = SCons.Action.Action( @@ -164,13 +129,18 @@ def runtest(arguments, expectedOutFile, expectedRebuild=True, stderr=""): test.run(arguments=arguments, stdout=expectedRebuild and rebuildstr or nobuildstr, stderr="") - test.must_match('Out.gen.h', expectedOutFile) + + sys.stdout.write('First Build.\n') + + test.must_match('Out.gen.h', expectedOutFile, message="First Build") # Should not be rebuild when run a second time with the same # arguments. + sys.stdout.write('Rebuild.\n') + test.run(arguments = arguments, stdout=nobuildstr, stderr="") - test.must_match('Out.gen.h', expectedOutFile) + test.must_match('Out.gen.h', expectedOutFile, message="Should not rebuild") # We're making this script chatty to prevent timeouts on really really -- cgit v0.12 From ac2848f315fd4cdfb37098355795aa5ada10c45e Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 25 Feb 2017 20:50:56 -0800 Subject: Move comment to docstring --- src/engine/SCons/dblite.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/engine/SCons/dblite.py b/src/engine/SCons/dblite.py index 19a8693..e11fe77 100644 --- a/src/engine/SCons/dblite.py +++ b/src/engine/SCons/dblite.py @@ -44,15 +44,17 @@ tmp_suffix = '.tmp' class dblite(object): - # Squirrel away references to the functions in various modules - # that we'll use when our __del__() method calls our sync() method - # during shutdown. We might get destroyed when Python is in the midst - # of tearing down the different modules we import in an essentially - # arbitrary order, and some of the various modules's global attributes - # may already be wiped out from under us. - # - # See the discussion at: - # http://mail.python.org/pipermail/python-bugs-list/2003-March/016877.html + """ + Squirrel away references to the functions in various modules + that we'll use when our __del__() method calls our sync() method + during shutdown. We might get destroyed when Python is in the midst + of tearing down the different modules we import in an essentially + arbitrary order, and some of the various modules's global attributes + may already be wiped out from under us. + + See the discussion at: + http://mail.python.org/pipermail/python-bugs-list/2003-March/016877.html + """ _open = open _pickle_dump = staticmethod(pickle.dump) -- cgit v0.12 From 6324fe12c09c33d9453571f4ccc34601dee8b7de Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 25 Feb 2017 20:51:12 -0800 Subject: PEP-8 changes --- src/engine/SCons/Util.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 7653acd..4519c34 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -1454,9 +1454,12 @@ def RenameFunction(function, name): md5 = False + + def MD5signature(s): return str(s) + def MD5filesignature(fname, chunksize=65536): f = open(fname, "rb") result = f.read() @@ -1470,6 +1473,7 @@ except ImportError: else: if hasattr(hashlib, 'md5'): md5 = True + def MD5signature(s): m = hashlib.md5() m.update(to_bytes(str(s))) -- cgit v0.12 From 17221cd2d5f675b5ec0989cf1eb6e6af22b60cc1 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 25 Feb 2017 20:51:34 -0800 Subject: PEP-8 changes --- src/engine/SCons/Taskmaster.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/SCons/Taskmaster.py b/src/engine/SCons/Taskmaster.py index a620ba1..be075cc 100644 --- a/src/engine/SCons/Taskmaster.py +++ b/src/engine/SCons/Taskmaster.py @@ -851,13 +851,13 @@ class Taskmaster(object): if childstate <= NODE_EXECUTING: children_not_ready.append(child) - # These nodes have not even been visited yet. Add # them to the list so that on some next pass we can # take a stab at evaluating them (or their children). children_not_visited.reverse() self.candidates.extend(self.order(children_not_visited)) - #if T and children_not_visited: + + # if T and children_not_visited: # T.write(self.trace_message(' adding to candidates: %s' % map(str, children_not_visited))) # T.write(self.trace_message(' candidates now: %s\n' % map(str, self.candidates))) -- cgit v0.12 From e4d4c47f90da6b5c6604da8730f302f1acdd9d96 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 25 Feb 2017 20:52:00 -0800 Subject: start some changes to show pass/fail stats along with progress --- runtest.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/runtest.py b/runtest.py index d636b73..d0de6d1 100755 --- a/runtest.py +++ b/runtest.py @@ -99,6 +99,9 @@ except ImportError: print("Can't import threading or queue") threading_ok = False +import subprocess + + cwd = os.getcwd() baseline = 0 @@ -343,6 +346,7 @@ sp.append(cwd) # _ws = re.compile('\s') + def escape(s): if _ws.search(s): s = '"' + s + '"' @@ -350,8 +354,6 @@ def escape(s): return s -import subprocess - if not suppress_stdout and not suppress_stderr: # Without any output suppressed, we let the subprocess # write its stuff freely to stdout/stderr. @@ -423,6 +425,7 @@ else: spawned_stderr = p.stderr.read() return (spawned_stderr, spawned_stdout, p.wait()) + class Base(object): def __init__(self, path, spe=None): self.path = path @@ -435,6 +438,7 @@ class Base(object): break self.status = None + class SystemExecutor(Base): def execute(self): self.stderr, self.stdout, s = spawn_it(self.command_args) @@ -442,6 +446,7 @@ class SystemExecutor(Base): if s < 0 or s > 2: sys.stdout.write("Unexpected exit status %d\n" % s) + class PopenExecutor(Base): # For an explanation of the following 'if ... else' # and the 'allow_pipe_files' option, please check out the @@ -641,6 +646,7 @@ tests = [] unittests = [] endtests = [] + def find_Tests_py(directory): """ Look for unit tests """ result = [] @@ -653,6 +659,7 @@ def find_Tests_py(directory): result.append(os.path.join(dirpath, fname)) return sorted(result) + def find_py(directory): """ Look for end-to-end tests """ result = [] @@ -760,9 +767,12 @@ else: total_start_time = time_func() total_num_tests = len(tests) tests_completed = 0 +tests_passing = 0 +tests_failing = 0 + def run_test(t, io_lock, async=True): - global tests_completed + global tests_completed, tests_passing, tests_failing header = "" command_args = ['-tt'] if debug: @@ -796,6 +806,11 @@ def run_test(t, io_lock, async=True): if execute_tests: t.execute() + if t.status == 0: + tests_passing += 1 + else: + tests_failing += 1 + t.test_time = time_func() - test_start_time if io_lock: io_lock.acquire() -- cgit v0.12 From cd9c89842a278f284728a966209cf22a8057e5ce Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 26 Feb 2017 11:35:19 -0800 Subject: fix mocked action get_contents() to return bytearray() --- src/engine/SCons/CacheDirTests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/CacheDirTests.py b/src/engine/SCons/CacheDirTests.py index 8a52928..494db98 100644 --- a/src/engine/SCons/CacheDirTests.py +++ b/src/engine/SCons/CacheDirTests.py @@ -44,7 +44,7 @@ class Action(object): def genstring(self, target, source, env): return str(self) def get_contents(self, target, source, env): - return '' + return bytearray('','utf-8') class Builder(object): def __init__(self, environment, action): -- cgit v0.12 From 399b2673152321c3f719d27334e036c03a579997 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 26 Feb 2017 11:52:16 -0800 Subject: fix test which depended on order of dictionary.items() which changed between py2 and py3 --- src/engine/SCons/EnvironmentTests.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index e3259d4..c51dd30 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -247,7 +247,9 @@ class SubstitutionTestCase(unittest.TestCase): """ env = SubstitutionEnvironment(XXX = 'x', YYY = 'y') items = list(env.items()) - assert items == [('XXX','x'), ('YYY','y')], items + assert len(items) == 2 and ('XXX','x') in items and ('YYY','y') in items, items + # Was. This fails under py3 as order changes + # assert items == [('XXX','x'), ('YYY','y')], items def test_arg2nodes(self): """Test the arg2nodes method -- cgit v0.12 From f51b065a8e4c009d58038d96b27eb0a6f7fb4189 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 26 Feb 2017 12:48:39 -0800 Subject: Must use bytes when writing to os.open()'d file on py3, bytearray works on both py3 and py2 --- src/engine/SCons/Platform/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/Platform/__init__.py b/src/engine/SCons/Platform/__init__.py index ebdbb4c..1654d0a 100644 --- a/src/engine/SCons/Platform/__init__.py +++ b/src/engine/SCons/Platform/__init__.py @@ -217,7 +217,7 @@ class TempFileMunge(object): prefix = '@' args = list(map(SCons.Subst.quote_spaces, cmd[1:])) - os.write(fd, " ".join(args) + "\n") + os.write(fd, bytearray(" ".join(args) + "\n",'utf-8')) os.close(fd) # XXX Using the SCons.Action.print_actions value directly # like this is bogus, but expedient. This class should -- cgit v0.12 From a9e4f59187b57fe5907d4f19dff3464d1effbc54 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 26 Feb 2017 12:49:06 -0800 Subject: define cmp() as it's not available on py3 for tests --- src/engine/SCons/Variables/VariablesTests.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/engine/SCons/Variables/VariablesTests.py b/src/engine/SCons/Variables/VariablesTests.py index 7f2a978..69f1e01 100644 --- a/src/engine/SCons/Variables/VariablesTests.py +++ b/src/engine/SCons/Variables/VariablesTests.py @@ -49,6 +49,14 @@ class Environment(object): return key in self.dict +def cmp(a, b): + """ + Define cmp because it's no longer available in python3 + Works under python 2 as well + """ + return (a > b) - (a < b) + + def check(key, value, env): assert int(value) == 6 * 9, "key %s = %s" % (key, repr(value)) -- cgit v0.12 From ef8cafb9b6ae66f428bc08b5c97f03d9ae6f1789 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 26 Feb 2017 12:49:38 -0800 Subject: Fix test for py3 & py2 compat --- src/engine/SCons/Node/FSTests.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index b9c19bc..d168e49 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -86,7 +86,7 @@ class Action(object): def show(self, string): pass def get_contents(self, target, source, env): - return "" + return bytearray("",'utf-8') def genstring(self, target, source, env): return "" def strfunction(self, targets, sources, env): @@ -231,7 +231,7 @@ class VariantDirTestCase(unittest.TestCase): # Build path exists assert f2.exists() # ...and exists() should copy the file from src to build path - assert test.read(['work', 'build', 'var2', 'test.in']) == 'test.in',\ + assert test.read(['work', 'build', 'var2', 'test.in']) == bytearray('test.in','utf-8'),\ test.read(['work', 'build', 'var2', 'test.in']) # Since exists() is true, so should rexists() be assert f2.rexists() @@ -260,7 +260,7 @@ class VariantDirTestCase(unittest.TestCase): # Build path should exist assert f4.exists() # ...and copy over the file into the local build path - assert test.read(['work', 'build', 'var2', 'test2.in']) == 'test2.in' + assert test.read(['work', 'build', 'var2', 'test2.in']) == bytearray('test2.in','utf-8') # should exist in repository, since exists() is true assert f4.rexists() # rfile() should point to ourselves @@ -273,12 +273,12 @@ class VariantDirTestCase(unittest.TestCase): assert f5.exists() # We should not copy the file from the source dir, since this is # a derived file. - assert test.read(['work', 'build', 'var1', 'test.out']) == 'test.old' + assert test.read(['work', 'build', 'var1', 'test.out']) == bytearray('test.old','utf-8') assert f6.exists() # We should not copy the file from the source dir, since this is # a derived file. - assert test.read(['work', 'build', 'var2', 'test.out']) == 'test.old' + assert test.read(['work', 'build', 'var2', 'test.out']) == bytearray('test.old','utf-8') f7 = fs.File('build/var1/test2.out') f8 = fs.File('build/var2/test2.out') @@ -334,7 +334,7 @@ class VariantDirTestCase(unittest.TestCase): test.write([ 'work', 'build', 'var1', 'asourcefile' ], 'stuff') f10 = fs.File('build/var1/asourcefile') assert f10.exists() - assert f10.get_contents() == 'stuff', f10.get_contents() + assert f10.get_contents() == bytearray('stuff','utf-8'), f10.get_contents() f11 = fs.File('src/file11') t, m = f11.alter_targets() @@ -1298,7 +1298,7 @@ class FSTestCase(_tempdirTestCase): # get_contents() returns the binary contents. test.write("binary_file", "Foo\x1aBar") f1 = fs.File(test.workpath("binary_file")) - assert f1.get_contents() == "Foo\x1aBar", f1.get_contents() + assert f1.get_contents() == bytearray("Foo\x1aBar",'utf-8'), f1.get_contents() # This tests to make sure we can decode UTF-8 text files. test_string = u"Foo\x1aBar" @@ -1367,7 +1367,7 @@ class FSTestCase(_tempdirTestCase): try: e = fs.Entry('file') c = e.get_contents() - assert c == "file\n", c + assert c == bytearray("file\n",'utf-8'), c assert e.__class__ == SCons.Node.FS.File finally: test.unlink("file") @@ -3099,7 +3099,7 @@ class RepositoryTestCase(_tempdirTestCase): test.write(["rep3", "contents"], "Con\x1aTents\n") try: c = fs.File("contents").get_contents() - assert c == "Con\x1aTents\n", "got '%s'" % c + assert c == bytearray("Con\x1aTents\n",'utf-8'), "got '%s'" % c finally: test.unlink(["rep3", "contents"]) -- cgit v0.12 From 0b1f425c3336551ed3f100ac3894c61d294afff6 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 26 Feb 2017 12:50:01 -0800 Subject: Split out calls to simplify for debugging --- src/engine/SCons/Executor.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/engine/SCons/Executor.py b/src/engine/SCons/Executor.py index 2fa3f05..bce1549 100644 --- a/src/engine/SCons/Executor.py +++ b/src/engine/SCons/Executor.py @@ -457,10 +457,14 @@ class Executor(object, with_metaclass(NoSlotsPyPy)): pass env = self.get_build_env() - result = bytearray("").join([action.get_contents(self.get_all_targets(), - self.get_all_sources(), - env) - for action in self.get_action_list()]) + action_list = self.get_action_list() + all_targets = self.get_all_targets() + all_sources = self.get_all_sources() + + result = bytearray("",'utf-8').join([action.get_contents(all_targets, + all_sources, + env) + for action in action_list]) self._memo['get_contents'] = result return result -- cgit v0.12 From 1a05853801eee7dab9dc005cd3c525cccc9b027a Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 26 Feb 2017 12:50:22 -0800 Subject: fix for py2/3 compat --- src/engine/SCons/Action.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index ceda168..eb215fd 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -477,7 +477,7 @@ class ActionBase(object): result = self.get_presig(target, source, env) if not isinstance(result,(bytes, bytearray)): - result = bytearray("").join([ SCons.Util.to_bytes(r) for r in result ]) + result = bytearray("",'utf-8').join([ SCons.Util.to_bytes(r) for r in result ]) else: # Make a copy and put in bytearray, without this the contents returned by get_presig # can be changed by the logic below, appending with each call and causing very -- cgit v0.12 From c9762819c39ed205184e74872f08069b2f358bbc Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 26 Feb 2017 13:13:01 -0800 Subject: Fix test for py2/py3. Note fake Builder node had invalid state of None. This worked on py2, but on py3 None != 0, so imported proper SCons.Node.no_state to use --- src/engine/SCons/SConfTests.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/engine/SCons/SConfTests.py b/src/engine/SCons/SConfTests.py index 15499ed..ef01414 100644 --- a/src/engine/SCons/SConfTests.py +++ b/src/engine/SCons/SConfTests.py @@ -140,7 +140,7 @@ class SConfTestCase(unittest.TestCase): finally: sconf.Finish() # we should have exactly one one error cached - log = self.test.read( self.test.workpath('config.log') ) + log = str(self.test.read( self.test.workpath('config.log') )) expr = re.compile( ".*failed in a previous run and all", re.DOTALL ) firstOcc = expr.match( log ) assert firstOcc is not None, log @@ -171,6 +171,7 @@ class SConfTestCase(unittest.TestCase): conf_dir=self.test.workpath('config.tests'), log_file=self.test.workpath('config.log')) import SCons.Builder + import SCons.Node class MyBuilder(SCons.Builder.BuilderBase): def __init__(self): self.prefix = '' @@ -179,7 +180,7 @@ class SConfTestCase(unittest.TestCase): class MyNode(object): def __init__(self, name): self.name = name - self.state = None + self.state = SCons.Node.no_state self.waiting_parents = set() self.side_effects = [] self.builder = None @@ -265,7 +266,7 @@ int main() { log_file=self.test.workpath('config.log')) try: res = checks(sconf) - assert res[0][0] and res[0][1] == "Hello", res + assert res[0][0] and res[0][1] == bytearray("Hello",'utf-8'), res assert not res[1][0] and res[1][1] == "", res finally: sconf.Finish() @@ -278,12 +279,13 @@ int main() { log_file=self.test.workpath('config.log')) try: res = checks(sconf) - assert res[0][0] and res[0][1] == "Hello", res + assert res[0][0] and res[0][1] == bytearray("Hello",'utf-8'), res assert not res[1][0] and res[1][1] == "", res finally: sconf.Finish() - # we should have exactly one error cached - log = self.test.read( self.test.workpath('config.log') ) + # we should have exactly one error cached + # creating string here because it's bytes by default on py3 + log = str(self.test.read( self.test.workpath('config.log') )) expr = re.compile( ".*failed in a previous run and all", re.DOTALL ) firstOcc = expr.match( log ) assert firstOcc is not None, log @@ -305,7 +307,7 @@ int main() { log_file=self.test.workpath('config.log')) try: (ret, output) = sconf.TryAction(action=actionOK) - assert ret and output == "RUN OK" + os.linesep, (ret, output) + assert ret and output == bytearray("RUN OK"+os.linesep,'utf-8'), (ret, output) (ret, output) = sconf.TryAction(action=actionFAIL) assert not ret and output == "", (ret, output) finally: @@ -757,7 +759,7 @@ int main() { """ (ret, output) = test.TryRun( prog, ".c" ) test.Result( ret ) - assert ret and output == "Hello", (ret, output) + assert ret and output == b"Hello", (ret, output) return ret -- cgit v0.12 From c0590267c0c9c1cca7fedb4fcfb95ae42d1093b0 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 26 Feb 2017 14:19:41 -0800 Subject: remove using unicode and just prefix the string with u --- src/engine/SCons/UtilTests.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py index 9ebb924..616d419 100644 --- a/src/engine/SCons/UtilTests.py +++ b/src/engine/SCons/UtilTests.py @@ -237,7 +237,11 @@ class UtilTestCase(unittest.TestCase): def test_is_Dict(self): assert is_Dict({}) assert is_Dict(UserDict()) - assert is_Dict(os.environ) + + # os.environ is not a dictionary in python 3 + if sys.version_info < (3,0): + assert is_Dict(os.environ) + try: class mydict(dict): pass @@ -723,7 +727,7 @@ class UtilTestCase(unittest.TestCase): def test_LogicalLines(self): """Test the LogicalLines class""" - content = r""" + content = u""" foo \ bar \ baz @@ -732,7 +736,7 @@ bling \ bling \ bling bling """ - fobj = io.StringIO(unicode(content)) + fobj = io.StringIO(content) lines = LogicalLines(fobj).readlines() assert lines == [ '\n', -- cgit v0.12 From ff96cf5e3c5198935f9f83525359a02c28f6daa6 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 26 Feb 2017 14:20:20 -0800 Subject: implement __getitem__ on NodeList to allow calling methods/properties on underlying object. With py3, UserList[slice] is returning a list --- src/engine/SCons/Util.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 4519c34..a98ce08 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -151,6 +151,17 @@ class NodeList(UserList): result = [getattr(x, name) for x in self.data] return self.__class__(result) + def __getitem__(self, index): + """ + This comes for free on py2, + but py3 slices of NodeList are returning a list + breaking slicing nodelist and refering to + properties and methods on contained object + """ + return self.__class__(self.data[index]) + + + _get_env_var = re.compile(r'^\$([_a-zA-Z]\w*|{[_a-zA-Z]\w*})$') -- cgit v0.12 From 314e1ead8ce83fcdc187c551d2d49549c80eabf3 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 27 Feb 2017 11:29:17 -0800 Subject: change to test to make it easier to see failures --- src/engine/SCons/SubstTests.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/engine/SCons/SubstTests.py b/src/engine/SCons/SubstTests.py index 8eda845..c11f247 100644 --- a/src/engine/SCons/SubstTests.py +++ b/src/engine/SCons/SubstTests.py @@ -251,7 +251,7 @@ class SubstTestCase(unittest.TestCase): else: if result != expect: if failed == 0: print() - print(" input %s => %s did not match %s" % (repr(input), repr(result), repr(expect))) + print(" input %s => \n%s did not match \n%s" % (repr(input), repr(result), repr(expect))) failed = failed + 1 del cases[:2] fmt = "%d %s() cases failed" @@ -571,7 +571,10 @@ class scons_subst_TestCase(SubstTestCase): except SCons.Errors.UserError as e: expect = [ # Python 2.3, 2.4, 2.5 - "TypeError `func() takes exactly 3 arguments (1 given)' trying to evaluate `${func(1)}'" + "TypeError `func() takes exactly 3 arguments (1 given)' trying to evaluate `${func(1)}'", + + # Python 3.5 (and 3.x?) + "TypeError `func() missing 2 required positional arguments: 'b' and 'c'' trying to evaluate `${func(1)}'" ] assert str(e) in expect, repr(str(e)) else: -- cgit v0.12 From 4b917bc012fd755f4f72d67e2291bd06ef9ffa63 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 27 Feb 2017 11:30:51 -0800 Subject: change NodeList to work for both py2/py3. default __getitem__ didn't work with NodeList.method for slices under py3 --- src/engine/SCons/Util.py | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index a98ce08..6d307cb 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -42,6 +42,8 @@ try: except ImportError as e: from collections import UserList +from collections import Iterable + try: from UserString import UserString except ImportError as e: @@ -131,6 +133,22 @@ class NodeList(UserList): >>> someList.strip() [ 'foo', 'bar' ] """ + +# def __init__(self, initlist=None): +# self.data = [] +# # print("TYPE:%s"%type(initlist)) +# if initlist is not None: +# # XXX should this accept an arbitrary sequence? +# if type(initlist) == type(self.data): +# self.data[:] = initlist +# elif isinstance(initlist, (UserList, NodeList)): +# self.data[:] = initlist.data[:] +# elif isinstance(initlist, Iterable): +# self.data = list(initlist) +# else: +# self.data = [ initlist,] + + def __nonzero__(self): return len(self.data) != 0 @@ -158,9 +176,17 @@ class NodeList(UserList): breaking slicing nodelist and refering to properties and methods on contained object """ - return self.__class__(self.data[index]) - - +# return self.__class__(self.data[index]) + + if isinstance(index, slice): + # Expand the slice object using range() + # limited by number of items in self.data + indices = index.indices(len(self.data)) + return self.__class__([self[x] for x in + range(*indices)]) + else: + # Return one item of the tart + return self.data[index] _get_env_var = re.compile(r'^\$([_a-zA-Z]\w*|{[_a-zA-Z]\w*})$') -- cgit v0.12 From 721294589d2f7deec067ba52c91666606d062063 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 27 Feb 2017 11:32:14 -0800 Subject: fixed set_exception tests to work. Under py3, you can only save the exception details while in the except clause. In py2 it seems to work after an exception outside except clause. I couldn't find any actual usage in this fashion besides this test case which I've changed --- src/engine/SCons/TaskmasterTests.py | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/engine/SCons/TaskmasterTests.py b/src/engine/SCons/TaskmasterTests.py index e795f5c..d237d60 100644 --- a/src/engine/SCons/TaskmasterTests.py +++ b/src/engine/SCons/TaskmasterTests.py @@ -849,14 +849,18 @@ class TaskmasterTestCase(unittest.TestCase): t = tm.next_task() t.exception_set((MyException, "exception value")) exc_caught = None + exc_actually_caught = None + exc_value = None try: t.prepare() except MyException as e: exc_caught = 1 - except: + exc_value = e + except Exception as e: + exc_actually_caught = e pass - assert exc_caught, "did not catch expected MyException" - assert str(e) == "exception value", e + assert exc_caught, "did not catch expected MyException: %s"%exc_actually_caught + assert str(exc_value) == "exception value", exc_value assert built_text is None, built_text # Regression test, make sure we prepare not only @@ -1065,10 +1069,20 @@ class TaskmasterTestCase(unittest.TestCase): assert t.exception == 3 try: 1//0 - except: pass - t.exception_set(None) + except: + # Moved from below + t.exception_set(None) + #pass + +# import pdb; pdb.set_trace() + + # Having this here works for python 2.x, + # but it is a tuple (None, None, None) when called outside + # an except statement + # t.exception_set(None) + exc_type, exc_value, exc_tb = t.exception - assert exc_type is ZeroDivisionError, exc_type + assert exc_type is ZeroDivisionError, "Expecting ZeroDevisionError got:%s"%exc_type exception_values = [ "integer division or modulo", "integer division or modulo by zero", @@ -1078,13 +1092,14 @@ class TaskmasterTestCase(unittest.TestCase): class Exception1(Exception): pass - t.exception_set((Exception1, None)) + # Previously value was None, but while PY2 None = "", in Py3 None != "", so set to "" + t.exception_set((Exception1, "")) try: t.exception_raise() except: exc_type, exc_value = sys.exc_info()[:2] assert exc_type == Exception1, exc_type - assert str(exc_value) == '', exc_value + assert str(exc_value) == '', "Expecting empty string got:%s (type %s)"%(exc_value,type(exc_value)) else: assert 0, "did not catch expected exception" -- cgit v0.12 From ba3763414feb40d65e68d478587dea6747bbfb6d Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 27 Feb 2017 11:32:35 -0800 Subject: Fix exception handling code to work with py3 --- src/engine/SCons/Taskmaster.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/Taskmaster.py b/src/engine/SCons/Taskmaster.py index be075cc..47a4c90 100644 --- a/src/engine/SCons/Taskmaster.py +++ b/src/engine/SCons/Taskmaster.py @@ -545,7 +545,7 @@ class Task(object): if sys.version_info[0] == 2: exec("raise exc_type, exc_value, exc_traceback") else: # sys.version_info[0] == 3: - exec("raise exc_type(*exc_value.args).with_traceback(exc_traceback)") + exec("raise exc_type(exc_value).with_traceback(exc_traceback)") # raise e.__class__, e.__class__(e), sys.exc_info()[2] -- cgit v0.12 From 90f6531cd593597ba7a1ccc2a5050bf9394b54a2 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 27 Feb 2017 16:04:02 -0800 Subject: fix byte/str issue --- test/AS/ASFLAGS.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/test/AS/ASFLAGS.py b/test/AS/ASFLAGS.py index 2cc99e3..553ea67 100644 --- a/test/AS/ASFLAGS.py +++ b/test/AS/ASFLAGS.py @@ -89,7 +89,8 @@ infile = open(inf, 'rb') outfile = open(out, 'wb') outfile.write(optstring + "\n") for l in infile.readlines(): - if l[:3] != '#as': + print("LINE->%s<-"%l) + if l[:3] != bytearray('#as'): outfile.write(l) sys.exit(0) """) @@ -108,7 +109,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) """) @@ -118,15 +119,19 @@ import getopt import sys opts, args = getopt.getopt(sys.argv[1:], 'co:x') optstring = '' + for opt, arg in opts: if opt == '-o': out = arg else: optstring = optstring + ' ' + opt + infile = open(args[0], 'rb') outfile = open(out, 'wb') -outfile.write(optstring + "\n") +outfile.write(bytearray(optstring + "\n",'utf-8')) + for l in infile.readlines(): - if l[:3] != '#as': + if l[:3] != b'#as': outfile.write(l) + sys.exit(0) """) -- cgit v0.12 From 7605860fff6a4d27b4bfc47bbe589e682b7e3d80 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 27 Feb 2017 16:09:58 -0800 Subject: fix byte file reading issues for py3/2 port --- test/AS/ASFLAGS.py | 5 ++--- test/AS/ASPP.py | 12 ++++++------ test/AS/ASPPFLAGS.py | 12 ++++++------ 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/test/AS/ASFLAGS.py b/test/AS/ASFLAGS.py index 553ea67..56eb11b 100644 --- a/test/AS/ASFLAGS.py +++ b/test/AS/ASFLAGS.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) """) @@ -89,8 +89,7 @@ infile = open(inf, 'rb') outfile = open(out, 'wb') outfile.write(optstring + "\n") for l in infile.readlines(): - print("LINE->%s<-"%l) - if l[:3] != bytearray('#as'): + if l[:3] != b'#as': outfile.write(l) sys.exit(0) """) diff --git a/test/AS/ASPP.py b/test/AS/ASPP.py index 67f4071..22cc36a 100644 --- a/test/AS/ASPP.py +++ b/test/AS/ASPP.py @@ -53,7 +53,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) """) @@ -77,7 +77,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) """) @@ -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[:5] != '#link': + if l[:5] != 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[:3] != '#as': + if l[:3] != b'#as': outfile.write(l) sys.exit(0) """) @@ -143,9 +143,9 @@ test.write('test3.sx', r"""This is a .sx file. test.run(arguments = '.', stderr = None) -test.fail_test(test.read('test1' + _exe) != "This is a .spp file.\n") +test.fail_test(test.read('test1' + _exe) != b"This is a .spp file.\n") -test.fail_test(test.read('test2' + _exe) != "This is a .SPP file.\n") +test.fail_test(test.read('test2' + _exe) != b"This is a .SPP file.\n") # Ensure the source scanner was run on test3.sx by # checking for foo.h in the dependency tree output diff --git a/test/AS/ASPPFLAGS.py b/test/AS/ASPPFLAGS.py index 731413e..460cfcb 100644 --- a/test/AS/ASPPFLAGS.py +++ b/test/AS/ASPPFLAGS.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) """) @@ -87,9 +87,9 @@ while args: optstring = optstring + ' ' + a infile = open(inf, 'rb') outfile = open(out, 'wb') -outfile.write(optstring + "\n") +outfile.write(bytearray(optstring + "\n",'utf-8')) for l in infile.readlines(): - if l[:3] != '#as': + if l[:3] != b'#as': outfile.write(l) sys.exit(0) """) @@ -109,7 +109,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) """) @@ -124,9 +124,9 @@ for opt, arg in opts: else: optstring = optstring + ' ' + opt infile = open(args[0], 'rb') outfile = open(out, 'wb') -outfile.write(optstring + "\n") +outfile.write(bytearray(optstring + "\n",'utf-8')) for l in infile.readlines(): - if l[:3] != '#as': + if l[:3] != b'#as': outfile.write(l) sys.exit(0) """) -- cgit v0.12 From 5573ade4379a99cfd4d321fb8501836385ab584d Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 27 Feb 2017 20:14:44 -0800 Subject: fixed for py3 & py2 compat. Also added DefaultEnvironment(tools=[]) to speed it up a bit. Perhaps more tests would benefit from such --- test/Actions/function.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/Actions/function.py b/test/Actions/function.py index 941498b..5e5066f 100644 --- a/test/Actions/function.py +++ b/test/Actions/function.py @@ -72,15 +72,15 @@ def toto(header='%(header)s', trailer='%(trailer)s'): def foo(b=b): return %(nestedfuncexp)s f = open(str(target[0]),'wb') - f.write(header) + f.write(bytearray(header,'utf-8')) for d in env['ENVDEPS']: - f.write(bytearray(d+'%(separator)s')) - f.write(trailer+'\\n') - f.write(str(foo())+'\\n') - f.write(r.match('aaaa').group(1)+'\\n') + f.write(bytearray(d+'%(separator)s','utf-8')) + f.write(bytearray(trailer+'\\n','utf-8')) + f.write(bytearray(str(foo())+'\\n','utf-8')) + f.write(bytearray(r.match('aaaa').group(1)+'\\n','utf-8')) %(extracode)s try: - f.write(str(xarg)+'\\n') + f.write(bytearray(str(xarg),'utf-8')+b'\\n') except NameError: pass f.close() @@ -88,7 +88,6 @@ def toto(header='%(header)s', trailer='%(trailer)s'): return writeDeps ''' - exec( withClosure % optEnv ) genHeaderBld = SCons.Builder.Builder( @@ -100,7 +99,8 @@ genHeaderBld = SCons.Builder.Builder( suffix = '.gen.h' ) -env = Environment() +DefaultEnvironment(tools=[]) +env = Environment(tools=[]) env.Append(BUILDERS = {'GenHeader' : genHeaderBld}) envdeps = list(map(str, range(int(optEnv['NbDeps'])))) @@ -160,7 +160,7 @@ runtest('NbDeps=4', """Head:0:1:2:3:Tail\n18\naaa\n""") runtest('', """Head:0:1:Tail\n18\naaa\n""") sys.stdout.write('Changing the function code should cause a rebuild.\n') -runtest('extracode=f.write("XX\\n")', """Head:0:1:Tail\n18\naaa\nXX\n""") +runtest('extracode=f.write(bytearray("XX\\n","utf-8"))', """Head:0:1:Tail\n18\naaa\nXX\n""") runtest('extracode=a=2', """Head:0:1:Tail\n18\naaa\n""") runtest('', """Head:0:1:Tail\n18\naaa\n""") -- cgit v0.12 From 598439410d709dbfacec13c833e1461f4bec5316 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 27 Feb 2017 20:40:12 -0800 Subject: Fix py2/3 byte file issue --- test/Alias/action.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Alias/action.py b/test/Alias/action.py index 74eb6f9..2a10dbc 100644 --- a/test/Alias/action.py +++ b/test/Alias/action.py @@ -43,12 +43,12 @@ def cat(target, source, env): def foo(target, source, env): target = list(map(str, target)) source = list(map(str, source)) - open('foo', 'wb').write("foo(%s, %s)\\n" % (target, source)) + open('foo', 'wb').write(bytearray("foo(%s, %s)\\n" % (target, source),'utf-8')) def bar(target, source, env): target = list(map(str, target)) source = list(map(str, source)) - open('bar', 'wb').write("bar(%s, %s)\\n" % (target, source)) + open('bar', 'wb').write(bytearray("bar(%s, %s)\\n" % (target, source),'utf-8')) env = Environment(BUILDERS = {'Cat':Builder(action=cat)}) env.Alias(target = ['build-f1'], source = 'f1.out', action = foo) -- cgit v0.12 From b44a36ee6b1cb4ff9c58bd838fa43b6df16d1b0c Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 27 Feb 2017 20:41:08 -0800 Subject: Fix py2/3 byte file issue --- test/Batch/action-changed.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Batch/action-changed.py b/test/Batch/action-changed.py index d031432..1dc0f08 100644 --- a/test/Batch/action-changed.py +++ b/test/Batch/action-changed.py @@ -47,7 +47,7 @@ for i in range(len(targets)): t = targets[i] s = sources[i] fp = open(t, 'wb') - fp.write('%s\\n') + fp.write(bytearray('%s\\n','utf-8')) fp.write(open(s, 'rb').read()) fp.close() sys.exit(0) -- cgit v0.12 From b9d23c2e9507a502be94a44b90d5253229e22b93 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 27 Feb 2017 20:42:20 -0800 Subject: Fix py2/3 byte file issue --- test/Builder-factories.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Builder-factories.py b/test/Builder-factories.py index 673920c..45bf08f 100644 --- a/test/Builder-factories.py +++ b/test/Builder-factories.py @@ -43,14 +43,14 @@ import os.path def mkdir(env, source, target): t = str(target[0]) os.makedirs(t) - open(os.path.join(t, 'marker'), 'wb').write("MakeDirectory\\n") + open(os.path.join(t, 'marker'), 'wb').write(b"MakeDirectory\\n") MakeDirectory = Builder(action=mkdir, target_factory=Dir) def collect(env, source, target): out = open(str(target[0]), 'wb') dir = str(source[0]) for f in sorted(os.listdir(dir)): f = os.path.join(dir, f) - out.write(open(f, 'r').read()) + out.write(open(f, 'rb').read()) out.close() Collect = Builder(action=collect, source_factory=Dir) env = Environment(BUILDERS = {'MakeDirectory':MakeDirectory, -- cgit v0.12 From 35308fb1e42a1999f47f82543af8c74ff59c6455 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 27 Feb 2017 20:48:09 -0800 Subject: fix py2/3 not sure why it was calling string.replace, instead of .replace on the string..? --- test/Builder/wrapper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Builder/wrapper.py b/test/Builder/wrapper.py index 55a0f24..ae62846 100644 --- a/test/Builder/wrapper.py +++ b/test/Builder/wrapper.py @@ -43,7 +43,7 @@ def cat(target, source, env): Cat = Builder(action=cat) def Wrapper(env, target, source): if not target: - target = [string.replace(str(source[0]), '.in', '.wout')] + target = [str(source[0]).replace('.in', '.wout')] t1 = 't1-'+str(target[0]) source = 's-'+str(source[0]) env.Cat(t1, source) -- cgit v0.12 From 630728657a7d76c623d9929a309d594c9d823e6e Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 28 Feb 2017 08:45:05 -0800 Subject: Replace calling traceback to get format of traceback output to just a formatted string as the frmat is stable and we're not supporting older versions of python whose formats varied. The traceback approach broke with py3 and is honestly overcomplicated --- QMTest/TestSCons.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index 8049930..e7175fb 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -563,21 +563,26 @@ class TestSCons(TestCommon): Returns a Python error line for output comparisons. The exec of the traceback line gives us the correct format for - this version of Python. Before 2.5, this yielded: - - File "", line 1, ? - - Python 2.5 changed this to: + this version of Python. File "", line 1, We stick the requested file name and line number in the right places, abstracting out the version difference. """ - exec('import traceback; x = traceback.format_stack()[-1]') - x = x.lstrip() - x = x.replace('', file) - x = x.replace('line 1,', 'line %s,' % line) + # This routine used to use traceback to get the proper format + # that doesn't work well with py3. And the format of the + # traceback seems to be stable, so let's just format + # an appropriate string + # + #exec('import traceback; x = traceback.format_stack()[-1]') + # import traceback + # x = traceback.format_stack() + # x = # XXX: .lstrip() + # x = x.replace('', file) + # x = x.replace('line 1,', 'line %s,' % line) + # x="\n".join(x) + x='File "%s", line %s, in \n'%(file,line) return x def normalize_ps(self, s): -- cgit v0.12 From 743c37452359941e9358f8b08997a9e45524bd3a Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 28 Feb 2017 08:46:30 -0800 Subject: fix AddMethod to work with py2&3. No need to call MethodType to add to a class. We don't support old classes any more --- src/engine/SCons/Util.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 6d307cb..d6f18cc 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -1471,11 +1471,8 @@ def AddMethod(obj, function, name=None): else: method = MethodType(function, obj, obj.__class__) else: - # "obj" is a class, so it gets an unbound method. - if sys.version_info[:2] > (3, 2): - method = MethodType(function, None) - else: - method = MethodType(function, None, obj) + # Handle classes + method = function setattr(obj, name, method) -- cgit v0.12 From e6084586c573b2672245496740793c16ea309728 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 28 Feb 2017 08:50:09 -0800 Subject: py2/3 fix --- test/Alias/scanner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Alias/scanner.py b/test/Alias/scanner.py index fc78546..d20a729 100644 --- a/test/Alias/scanner.py +++ b/test/Alias/scanner.py @@ -52,7 +52,7 @@ test.write('file.x', "file.x\n") test.run() -test.fail_test(test.read('file.c') != "file.x\n") +test.fail_test(test.read('file.c') != b"file.x\n") test.pass_test() -- cgit v0.12 From c39f298d26094ade15d9c058b771e58eaf70138c Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 28 Feb 2017 08:51:09 -0800 Subject: py2/3 fix --- test/AlwaysBuild.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/AlwaysBuild.py b/test/AlwaysBuild.py index 2fcc5c4..dfd9fd4 100644 --- a/test/AlwaysBuild.py +++ b/test/AlwaysBuild.py @@ -55,7 +55,7 @@ c2 = env.Alias('clean2', [], [Delete('clean2-t1'), Delete('clean2-t2')]) env.AlwaysBuild(c2) def dir_build(target, source, env): - open('dir_build.txt', 'ab').write('dir_build()\\n') + open('dir_build.txt', 'ab').write(b'dir_build()\\n') env.Command(Dir('dir'), None, dir_build) env.AlwaysBuild('dir') """ % locals()) -- cgit v0.12 From 5a7473d2fd2add15c8489cb57c4820ea0d36c3d0 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 28 Feb 2017 09:15:48 -0800 Subject: Fix error message to output string and not bytearray(...) when two environments with different actions.. py2/3 fix --- src/engine/SCons/Builder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/Builder.py b/src/engine/SCons/Builder.py index c7bce3a..6f606ee 100644 --- a/src/engine/SCons/Builder.py +++ b/src/engine/SCons/Builder.py @@ -299,7 +299,7 @@ def _node_errors(builder, env, tlist, slist): msg = "Two different environments were specified for target %s,\n\tbut they appear to have the same action: %s" % (t, action.genstring(tlist, slist, t.env)) SCons.Warnings.warn(SCons.Warnings.DuplicateEnvironmentWarning, msg) else: - msg = "Two environments with different actions were specified for the same target: %s\n(action 1: %s)\n(action 2: %s)" % (t,t_contents,contents) + msg = "Two environments with different actions were specified for the same target: %s\n(action 1: %s)\n(action 2: %s)" % (t,t_contents.decode('utf-8'),contents.decode('utf-8')) raise UserError(msg) if builder.multi: if t.builder != builder: -- cgit v0.12 From 9eb0b9064b7eb0ec089be5fc643f26552c035315 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 28 Feb 2017 09:16:16 -0800 Subject: no need to write SConstruct as binary file change to normal file --- test/Builder/different-actions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Builder/different-actions.py b/test/Builder/different-actions.py index d84a9f9..f98db93 100644 --- a/test/Builder/different-actions.py +++ b/test/Builder/different-actions.py @@ -39,7 +39,7 @@ e2 = Environment() e1.Command('out.txt', [], 'echo 1 > $TARGET') e2.Command('out.txt', [], 'echo 2 > $TARGET') -""") +""",'w') expect = TestSCons.re_escape(""" scons: *** Two environments with different actions were specified for the same target: out.txt -- cgit v0.12 From 82acd51fa840fcefb03c8dc2e112693f18168615 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 28 Feb 2017 09:16:23 -0800 Subject: py2/3 fixes --- test/Builder/multi/same-overrides.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Builder/multi/same-overrides.py b/test/Builder/multi/same-overrides.py index ee169e4..95c0759 100644 --- a/test/Builder/multi/same-overrides.py +++ b/test/Builder/multi/same-overrides.py @@ -38,7 +38,7 @@ test.write('build.py', r"""#!/usr/bin/env python import sys def build(num, target, source): file = open(str(target), 'wb') - file.write('%s\n'%num) + file.write(bytearray('%s\n'%num,'utf-8')) for s in source: file.write(open(str(s), 'rb').read()) build(sys.argv[1],sys.argv[2],sys.argv[3:]) -- cgit v0.12 From 81d313cb7f3df275d0704f8f26c7bca9db467689 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 28 Feb 2017 11:09:02 -0800 Subject: py2/3 fixes --- test/site_scons/sys-path.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/site_scons/sys-path.py b/test/site_scons/sys-path.py index 46f84c7..40783ff 100644 --- a/test/site_scons/sys-path.py +++ b/test/site_scons/sys-path.py @@ -37,10 +37,10 @@ test.subdir('site_scons') test.subdir('sub1') test.write(['site_scons', 'testmod1.py'], """ -print "Imported site_scons/testmod1.py." +print("Imported site_scons/testmod1.py.") """) test.write(['site_scons', 'testmod2.py'], """ -print "Imported site_scons/testmod2.py." +print("Imported site_scons/testmod2.py.") """) test.write(['sub1', 'SConscript'], """ -- cgit v0.12 From 390448c9144b27fdb3529aa1c71355d1de0c447d Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 28 Feb 2017 11:12:31 -0800 Subject: comment out code which checks for py3 and fails --- src/script/sconsign.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/script/sconsign.py b/src/script/sconsign.py index e046a2c..13fac98 100644 --- a/src/script/sconsign.py +++ b/src/script/sconsign.py @@ -57,11 +57,11 @@ import sys # engine modules if they're in either directory. -if sys.version_info >= (3,0,0): - msg = "sconsign: *** Version %s does not run under Python version %s.\n\ -Python 3 is not yet supported.\n" - sys.stderr.write(msg % (__version__, sys.version.split()[0])) - sys.exit(1) +#if sys.version_info >= (3,0,0): +# msg = "sconsign: *** Version %s does not run under Python version %s.\n\ +#Python 3 is not yet supported.\n" +# sys.stderr.write(msg % (__version__, sys.version.split()[0])) +# sys.exit(1) script_dir = sys.path[0] -- cgit v0.12 From 8814bdd192c273ad9ee87fba6cf9be360335b6d5 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 28 Feb 2017 11:24:48 -0800 Subject: fix octal for py2/3 --- test/sconsign/nonwritable.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sconsign/nonwritable.py b/test/sconsign/nonwritable.py index 5ae55bb..6f12f18 100644 --- a/test/sconsign/nonwritable.py +++ b/test/sconsign/nonwritable.py @@ -59,7 +59,7 @@ def build2(target, source, env): import os.path open(str(target[0]), 'wb').write(open(str(source[0]), 'rb').read()) dir, file = os.path.split(str(target[0])) - os.chmod(dir, 0555) + os.chmod(dir, 0o555) return None B1 = Builder(action = build1) -- cgit v0.12 From 9dc001124dc72907556139a3b1f61148d1e539cf Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 28 Feb 2017 12:07:51 -0800 Subject: fix float formatting and change writting output from binary to non binary file for py2/3 --- src/script/scons-time.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/script/scons-time.py b/src/script/scons-time.py index edb9dad..9faf045 100644 --- a/src/script/scons-time.py +++ b/src/script/scons-time.py @@ -102,7 +102,7 @@ class Line(object): def print_label(self, inx, x, y): if self.label: - print('set label %s "%s" at %s,%s right' % (inx, self.label, x, y)) + print('set label %s "%s" at %0.1f,%0.1f right' % (inx, self.label, x, y)) def plot_string(self): if self.title: @@ -459,7 +459,9 @@ class SConsTimer(object): output = os.popen(command).read() if self.verbose: sys.stdout.write(output) - open(log, 'wb').write(output) + # TODO: Figure out + # Not sure we need to write binary here + open(log, 'w').write(output) # -- cgit v0.12 From e3b86af463e2a9eef98cd7c74469a5fff96f19c9 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 28 Feb 2017 12:08:24 -0800 Subject: py2/3 fixes --- QMTest/TestSCons_time.py | 7 ++++--- test/scons-time/run/config/scons.py | 3 ++- test/scons-time/run/option/scons.py | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/QMTest/TestSCons_time.py b/QMTest/TestSCons_time.py index ba7fbd8..6778d1b 100644 --- a/QMTest/TestSCons_time.py +++ b/QMTest/TestSCons_time.py @@ -28,8 +28,9 @@ __all__.extend([ 'TestSCons_time', ]) SConstruct = """\ +from __future__ import print_function import os -print "SConstruct file directory:", os.getcwd() +print("SConstruct file directory:", os.getcwd()) """ scons_py = """\ @@ -43,7 +44,7 @@ def write_args(fp, args): write_args(sys.stdout, sys.argv) for arg in sys.argv[1:]: if arg[:10] == '--profile=': - profile = open(arg[10:], 'wb') + profile = open(arg[10:], 'w') profile.write('--profile\\n') write_args(profile, sys.argv) break @@ -270,7 +271,7 @@ class TestSCons_time(TestCommon): tar = tarfile.open(archive, mode[suffix]) for name, content in files: path = os.path.join(dir, name) - open(path, 'wb').write(content) + open(path, 'wb').write(bytearray(content,'utf-8')) tarinfo = tar.gettarinfo(path, path) tarinfo.uid = 111 tarinfo.gid = 111 diff --git a/test/scons-time/run/config/scons.py b/test/scons-time/run/config/scons.py index 73f041d..0c8b643 100644 --- a/test/scons-time/run/config/scons.py +++ b/test/scons-time/run/config/scons.py @@ -42,13 +42,14 @@ scons = r'%(my_scons_py)s' """ % locals()) test.write(my_scons_py, """\ +from __future__ import print_function import sys profile = '' for arg in sys.argv[1:]: if arg.startswith('--profile='): profile = arg[10:] break -print 'my_scons.py: %s' % profile +print('my_scons.py: %s' % profile) """) test.run(arguments = 'run -f config foo.tar.gz') diff --git a/test/scons-time/run/option/scons.py b/test/scons-time/run/option/scons.py index 0bf883b..71d8ca2 100644 --- a/test/scons-time/run/option/scons.py +++ b/test/scons-time/run/option/scons.py @@ -43,7 +43,7 @@ for arg in sys.argv[1:]: if arg.startswith('--profile='): profile = arg[10:] break -print 'my_scons.py: %s' % profile +print('my_scons.py: %s' % profile) """) test.run(arguments = 'run --scons %s foo.tar.gz' % my_scons_py) -- cgit v0.12 From b8326ebfe788f9f165773cd4b2e649b6951a6e26 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 28 Feb 2017 12:11:59 -0800 Subject: fix test output read mode to not be binary py2/3 --- test/scons-time/run/aegis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/scons-time/run/aegis.py b/test/scons-time/run/aegis.py index 09c6aad..5235d98 100644 --- a/test/scons-time/run/aegis.py +++ b/test/scons-time/run/aegis.py @@ -64,7 +64,7 @@ expect = [ 'SCONS_LIB_DIR = %s' % test.tempdir_re('src', 'engine'), ] -content = test.read(test.workpath('foo-321-2.log')) +content = test.read(test.workpath('foo-321-2.log'),mode='r') def re_find(content, line): return re.search(line, content) -- cgit v0.12 From e9c61517581f4fc0299b81c4e6bb9069dab3b934 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 28 Feb 2017 12:18:49 -0800 Subject: fix binary/non-binary file writes where appropriate, previous all were binary. py2/3 --- QMTest/TestSCons_time.py | 4 ++-- src/script/scons-time.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/QMTest/TestSCons_time.py b/QMTest/TestSCons_time.py index 6778d1b..a9212f7 100644 --- a/QMTest/TestSCons_time.py +++ b/QMTest/TestSCons_time.py @@ -246,7 +246,7 @@ class TestSCons_time(TestCommon): d, f = os.path.split(path) if not os.path.isdir(d): os.makedirs(d) - open(path, 'wb').write(content) + open(path, 'w').write(content) return dir def write_sample_tarfile(self, archive, dir, files): @@ -296,7 +296,7 @@ class TestSCons_time(TestCommon): zip = zipfile.ZipFile(archive, 'w') for name, content in files: path = os.path.join(dir, name) - open(path, 'wb').write(content) + open(path, 'w').write(content) zip.write(path) zip.close() shutil.rmtree(dir) diff --git a/src/script/scons-time.py b/src/script/scons-time.py index 9faf045..c788e50 100644 --- a/src/script/scons-time.py +++ b/src/script/scons-time.py @@ -248,7 +248,7 @@ def unzip(fname): os.makedirs(dir) except: pass - open(name, 'w').write(zf.read(name)) + open(name, 'wb').write(zf.read(name)) def read_tree(dir): for dirpath, dirnames, filenames in os.walk(dir): -- cgit v0.12 From 04478163dde3e22b711bcfb4728c902e0b1a4d05 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 28 Feb 2017 12:20:01 -0800 Subject: byte string fix py2/3 --- test/runtest/xml/output.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/runtest/xml/output.py b/test/runtest/xml/output.py index 66d7911..e669a3a 100644 --- a/test/runtest/xml/output.py +++ b/test/runtest/xml/output.py @@ -92,7 +92,7 @@ expect = """\ # Just strip carriage returns so the regular expression matching works. contents = test.read('xml.out') -contents = contents.replace('\r', '') +contents = contents.replace(b'\r', b'') test.write('xml.out', contents) test.must_match('xml.out', expect) -- cgit v0.12 From 883c36995a2dc7d1b3c49e04b00aaf7af1dde4cd Mon Sep 17 00:00:00 2001 From: William Blevins Date: Tue, 28 Feb 2017 20:42:59 -0500 Subject: Additional fixture cleanup for test/AS directory. --- test/AS/AS.py | 81 ++---------------------------- test/AS/ASFLAGS.py | 109 ++++------------------------------------- test/AS/ASPP.py | 81 ++---------------------------- test/AS/ASPPFLAGS.py | 106 ++++----------------------------------- test/AS/fixture/myas.py | 35 +++++++++++++ test/AS/fixture/myas_args.py | 48 ++++++++++++++++++ test/AS/fixture/sconstest.skip | 0 7 files changed, 107 insertions(+), 353 deletions(-) create mode 100644 test/AS/fixture/myas.py create mode 100644 test/AS/fixture/myas_args.py create mode 100644 test/AS/fixture/sconstest.skip diff --git a/test/AS/AS.py b/test/AS/AS.py index 6ccf0cb..380afe3 100644 --- a/test/AS/AS.py +++ b/test/AS/AS.py @@ -29,6 +29,7 @@ Verify the ability to set the $AS construction variable to a different assembler (a wrapper we create). """ +import os import sys import TestSCons @@ -38,84 +39,8 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() - - -if sys.platform == 'win32': - - test.write('mylink.py', r""" -import sys -args = sys.argv[1:] -while args: - a = args[0] - if a == '-o': - out = args[1] - args = args[2:] - continue - if not a[0] in '/-': - break - args = args[1:] - if a[:5].lower() == '/out:': out = a[5:] -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:5] != b'#link': - outfile.write(l) -sys.exit(0) -""") - - test.write('myas.py', r""" -import sys -args = sys.argv[1:] -inf = None -while args: - a = args[0] - if a == '-o': - out = args[1] - args = args[2:] - continue - args = args[1:] - if not a[0] in "/-": - if not inf: - inf = a - continue - if a[:3] == '/Fo': out = a[3:] -infile = open(inf, 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:3] != b'#as': - outfile.write(l) -sys.exit(0) -""") - -else: - - test.write('mylink.py', r""" -import getopt -import sys -opts, args = getopt.getopt(sys.argv[1:], 'o:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:5] != b'#link': - outfile.write(l) -sys.exit(0) -""") - - test.write('myas.py', r""" -import getopt -import sys -opts, args = getopt.getopt(sys.argv[1:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:3] != b'#as': - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mylink.py') +test.file_fixture(os.path.join('fixture', 'myas.py')) test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', diff --git a/test/AS/ASFLAGS.py b/test/AS/ASFLAGS.py index 56eb11b..79fde8c 100644 --- a/test/AS/ASFLAGS.py +++ b/test/AS/ASFLAGS.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import sys import TestSCons @@ -33,114 +34,22 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() _exe = TestSCons._exe +test.file_fixture('mylink.py') +test.file_fixture(os.path.join('fixture', 'myas_args.py')) +o = ' -x' +o_c = ' -x -c' if sys.platform == 'win32': import SCons.Tool.MSCommon as msc - o = ' -x' - o_c = ' -x' - if not msc.msvc_exists(): - o_c = ' -x -c' - - test.write('mylink.py', r""" -import sys -args = sys.argv[1:] -while args: - a = args[0] - if a == '-o': - out = args[1] - args = args[2:] - continue - if not a[0] in '/-': - break - args = args[1:] - if a[:5].lower() == '/out:': out = a[5:] -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:5] != b'#link': - outfile.write(l) -sys.exit(0) -""") - - test.write('myas.py', r""" -import sys -args = sys.argv[1:] -inf = None -optstring = '' -while args: - a = args[0] - if a == '-o': - out = args[1] - args = args[2:] - continue - args = args[1:] - if not a[0] in '/-': - if not inf: - inf = a - continue - if a[:2] == '/c': - continue - if a[:3] == '/Fo': - out = a[3:] - continue - optstring = optstring + ' ' + a -infile = open(inf, 'rb') -outfile = open(out, 'wb') -outfile.write(optstring + "\n") -for l in infile.readlines(): - if l[:3] != b'#as': - outfile.write(l) -sys.exit(0) -""") - -else: - - o = ' -x' - o_c = ' -x -c' - - test.write('mylink.py', r""" -import getopt -import sys -opts, args = getopt.getopt(sys.argv[1:], 'o:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:5] != b'#link': - outfile.write(l) -sys.exit(0) -""") - - test.write('myas.py', r""" -import getopt -import sys -opts, args = getopt.getopt(sys.argv[1:], 'co:x') -optstring = '' - -for opt, arg in opts: - if opt == '-o': out = arg - else: optstring = optstring + ' ' + opt - -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -outfile.write(bytearray(optstring + "\n",'utf-8')) - -for l in infile.readlines(): - if l[:3] != b'#as': - outfile.write(l) - -sys.exit(0) -""") - - + if msc.msvc_exists(): + o_c = ' -x' test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', LINKFLAGS = [], - AS = r'%(_python_)s myas.py', ASFLAGS = '-x', - CC = r'%(_python_)s myas.py') + AS = r'%(_python_)s myas_args.py', ASFLAGS = '-x', + CC = r'%(_python_)s myas_args.py') env.Program(target = 'test1', source = 'test1.s') env.Program(target = 'test2', source = 'test2.S') env.Program(target = 'test3', source = 'test3.asm') diff --git a/test/AS/ASPP.py b/test/AS/ASPP.py index 22cc36a..18c067f 100644 --- a/test/AS/ASPP.py +++ b/test/AS/ASPP.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import sys import TestSCons @@ -33,84 +34,8 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() - - -if sys.platform == 'win32': - - test.write('mylink.py', r""" -import sys -args = sys.argv[1:] -while args: - a = args[0] - if a == '-o': - out = args[1] - args = args[2:] - continue - if not a[0] in '/-': - break - args = args[1:] - if a[:5].lower() == '/out:': out = a[5:] -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:5] != b'#link': - outfile.write(l) -sys.exit(0) -""") - - test.write('myas.py', r""" -import sys -args = sys.argv[1:] -inf = None -while args: - a = args[0] - if a == '-o': - out = args[1] - args = args[2:] - continue - args = args[1:] - if not a[0] in "/-": - if not inf: - inf = a - continue - if a[:3] == '/Fo': out = a[3:] -infile = open(inf, 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:3] != b'#as': - outfile.write(l) -sys.exit(0) -""") - -else: - - test.write('mylink.py', r""" -import getopt -import sys -opts, args = getopt.getopt(sys.argv[1:], 'o:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:5] != b'#link': - outfile.write(l) -sys.exit(0) -""") - - test.write('myas.py', r""" -import getopt -import sys -opts, args = getopt.getopt(sys.argv[1:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:3] != b'#as': - outfile.write(l) -sys.exit(0) -""") +test.file_fixture('mylink.py') +test.file_fixture(os.path.join('fixture', 'myas.py')) test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', diff --git a/test/AS/ASPPFLAGS.py b/test/AS/ASPPFLAGS.py index 460cfcb..254a458 100644 --- a/test/AS/ASPPFLAGS.py +++ b/test/AS/ASPPFLAGS.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import sys import TestSCons @@ -33,111 +34,22 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() _exe = TestSCons._exe +test.file_fixture('mylink.py') +test.file_fixture(os.path.join('fixture', 'myas_args.py')) +o = ' -x' +o_c = ' -x -c' if sys.platform == 'win32': import SCons.Tool.MSCommon as msc - o = ' -x' - o_c = ' -x' - if not msc.msvc_exists(): - o_c = ' -x -c' - - test.write('mylink.py', r""" -import sys -args = sys.argv[1:] -while args: - a = args[0] - if a == '-o': - out = args[1] - args = args[2:] - continue - if not a[0] in '/-': - break - args = args[1:] - if a[:5].lower() == '/out:': out = a[5:] -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:5] != b'#link': - outfile.write(l) -sys.exit(0) -""") - - test.write('myas.py', r""" -import sys -args = sys.argv[1:] -inf = None -optstring = '' -while args: - a = args[0] - if a == '-o': - out = args[1] - args = args[2:] - continue - args = args[1:] - if not a[0] in '/-': - if not inf: - inf = a - continue - if a[:2] == '/c': - continue - if a[:3] == '/Fo': - out = a[3:] - continue - optstring = optstring + ' ' + a -infile = open(inf, 'rb') -outfile = open(out, 'wb') -outfile.write(bytearray(optstring + "\n",'utf-8')) -for l in infile.readlines(): - if l[:3] != b'#as': - outfile.write(l) -sys.exit(0) -""") - -else: - - o = ' -x' - - o_c = ' -x -c' - - test.write('mylink.py', r""" -import getopt -import sys -opts, args = getopt.getopt(sys.argv[1:], 'o:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:5] != b'#link': - outfile.write(l) -sys.exit(0) -""") - - test.write('myas.py', r""" -import getopt -import sys -opts, args = getopt.getopt(sys.argv[1:], 'co:x') -optstring = '' -for opt, arg in opts: - if opt == '-o': out = arg - else: optstring = optstring + ' ' + opt -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -outfile.write(bytearray(optstring + "\n",'utf-8')) -for l in infile.readlines(): - if l[:3] != b'#as': - outfile.write(l) -sys.exit(0) -""") - - + if msc.msvc_exists(): + o_c = ' -x' test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', LINKFLAGS = [], - ASPP = r'%(_python_)s myas.py', ASPPFLAGS = '-x', - CC = r'%(_python_)s myas.py') + ASPP = r'%(_python_)s myas_args.py', ASPPFLAGS = '-x', + CC = r'%(_python_)s myas_args.py') env.Program(target = 'test1', source = 'test1.spp') env.Program(target = 'test2', source = 'test2.SPP') """ % locals()) diff --git a/test/AS/fixture/myas.py b/test/AS/fixture/myas.py new file mode 100644 index 0000000..bffae78 --- /dev/null +++ b/test/AS/fixture/myas.py @@ -0,0 +1,35 @@ +import sys + +if sys.platform == 'win32': + args = sys.argv[1:] + inf = None + while args: + a = args[0] + if a == '-o': + out = args[1] + args = args[2:] + continue + args = args[1:] + if not a[0] in "/-": + if not inf: + inf = a + continue + if a[:3] == '/Fo': out = a[3:] + infile = open(inf, 'rb') + outfile = open(out, 'wb') + for l in infile.readlines(): + if l[:3] != b'#as': + outfile.write(l) + sys.exit(0) + +else: + import getopt + opts, args = getopt.getopt(sys.argv[1:], 'co:') + for opt, arg in opts: + if opt == '-o': out = arg + infile = open(args[0], 'rb') + outfile = open(out, 'wb') + for l in infile.readlines(): + if l[:3] != b'#as': + outfile.write(l) + sys.exit(0) diff --git a/test/AS/fixture/myas_args.py b/test/AS/fixture/myas_args.py new file mode 100644 index 0000000..c7ca315 --- /dev/null +++ b/test/AS/fixture/myas_args.py @@ -0,0 +1,48 @@ +import sys + +if sys.platform == 'win32': + args = sys.argv[1:] + inf = None + optstring = '' + while args: + a = args[0] + if a == '-o': + out = args[1] + args = args[2:] + continue + args = args[1:] + if not a[0] in '/-': + if not inf: + inf = a + continue + if a[:2] == '/c': + continue + if a[:3] == '/Fo': + out = a[3:] + continue + optstring = optstring + ' ' + a + infile = open(inf, 'rb') + outfile = open(out, 'wb') + outfile.write(bytearray(optstring + "\n",'utf-8')) + for l in infile.readlines(): + if l[:3] != b'#as': + outfile.write(l) + sys.exit(0) +else: + import getopt + opts, args = getopt.getopt(sys.argv[1:], 'co:x') + optstring = '' + + for opt, arg in opts: + if opt == '-o': out = arg + else: optstring = optstring + ' ' + opt + + infile = open(args[0], 'rb') + outfile = open(out, 'wb') + outfile.write(bytearray(optstring + "\n",'utf-8')) + + for l in infile.readlines(): + if l[:3] != b'#as': + outfile.write(l) + + sys.exit(0) diff --git a/test/AS/fixture/sconstest.skip b/test/AS/fixture/sconstest.skip new file mode 100644 index 0000000..e69de29 -- cgit v0.12 From 44f20c13b64b2064d76aebaf7c367a18482d4b04 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 2 Mar 2017 16:48:15 -0800 Subject: fix byte/str py2/3 --- QMTest/TestCmd.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index 370101b..b97f103 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -783,7 +783,7 @@ class Popen(subprocess.Popen): return 0 try: - written = os.write(self.stdin.fileno(), input) + written = os.write(self.stdin.fileno(), bytearray(input,'utf-8')) except OSError as why: if why.args[0] == errno.EPIPE: #broken pipe return self._close('stdin') @@ -1355,6 +1355,7 @@ class TestCmd(object): if timeout: self.timer = threading.Timer(float(timeout), self._timeout) self.timer.start() + print("CMD:%s"%cmd) p = Popen(cmd, stdin=stdin, stdout=subprocess.PIPE, -- cgit v0.12 From 2ba9035552f09f80d0350e131b19b08f977f5159 Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Thu, 9 Mar 2017 21:28:20 -0800 Subject: Use print() function to fix py2/3 --- QMTest/TestCmdTests.py | 61 +++++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/QMTest/TestCmdTests.py b/QMTest/TestCmdTests.py index cd62d9f..b9226fd 100644 --- a/QMTest/TestCmdTests.py +++ b/QMTest/TestCmdTests.py @@ -245,11 +245,12 @@ class cleanup_TestCase(TestCmdTestCase): def test_atexit(self): """Test cleanup() when atexit is used""" - self.popen_python("""import sys + self.popen_python("""from __future__ import print_function +import sys sys.path = ['%s'] + sys.path import atexit def my_exitfunc(): - print "my_exitfunc()" + print("my_exitfunc()") atexit.register(my_exitfunc) import TestCmd result = TestCmd.TestCmd(workdir = '') @@ -258,10 +259,11 @@ sys.exit(0) def test_exitfunc(self): """Test cleanup() when sys.exitfunc is set""" - self.popen_python("""import sys + self.popen_python("""from __future__ import print_function +import sys sys.path = ['%s'] + sys.path def my_exitfunc(): - print "my_exitfunc()" + print("my_exitfunc()") sys.exitfunc = my_exitfunc import TestCmd result = TestCmd.TestCmd(workdir = '') @@ -594,13 +596,14 @@ sys.exit(0) def test_diff_stderr_not_affecting_diff_stdout(self): """Test diff_stderr() not affecting diff_stdout() behavior""" - self.popen_python(r"""import sys + self.popen_python(r"""from __future__ import print_function +import sys sys.path = ['%s'] + sys.path import TestCmd test = TestCmd.TestCmd(diff_stderr='diff_re') -print "diff_stderr:" +print("diff_stderr:") test.diff_stderr('a\nb.\nc\n', 'a\nbb\nc\n') -print "diff_stdout:" +print("diff_stdout:") test.diff_stdout('a\nb.\nc\n', 'a\nbb\nc\n') sys.exit(0) """ % self.orig_cwd, @@ -700,13 +703,14 @@ sys.exit(0) def test_diff_stdout_not_affecting_diff_stderr(self): """Test diff_stdout() not affecting diff_stderr() behavior""" - self.popen_python(r"""import sys + self.popen_python(r"""from __future__ import print_function +import sys sys.path = ['%s'] + sys.path import TestCmd test = TestCmd.TestCmd(diff_stdout='diff_re') -print "diff_stdout:" +print("diff_stdout:") test.diff_stdout('a\nb.\nc\n', 'a\nbb\nc\n') -print "diff_stderr:" +print("diff_stderr:") test.diff_stderr('a\nb.\nc\n', 'a\nbb\nc\n') sys.exit(0) """ % self.orig_cwd, @@ -2096,18 +2100,19 @@ sys.exit(0) def test_set_diff_function_stdout(self): """Test set_diff_function(): stdout""" - self.popen_python("""import sys + self.popen_python("""from __future__ import print_function +import sys sys.path = ['%s'] + sys.path import TestCmd test = TestCmd.TestCmd() -print "diff:" +print("diff:") test.diff("a\\n", "a\\n") -print "diff_stdout:" +print("diff_stdout:") test.diff_stdout("a\\n", "a\\n") test.set_diff_function(stdout='diff_re') -print "diff:" +print("diff:") test.diff(".\\n", "a\\n") -print "diff_stdout:" +print("diff_stdout:") test.diff_stdout(".\\n", "a\\n") sys.exit(0) """ % self.orig_cwd, @@ -2124,18 +2129,19 @@ diff_stdout: def test_set_diff_function_stderr(self): """Test set_diff_function(): stderr """ - self.popen_python("""import sys + self.popen_python("""from __future__ import print_function +import sys sys.path = ['%s'] + sys.path import TestCmd test = TestCmd.TestCmd() -print "diff:" +print("diff:") test.diff("a\\n", "a\\n") -print "diff_stderr:" +print("diff_stderr:") test.diff_stderr("a\\n", "a\\n") test.set_diff_function(stderr='diff_re') -print "diff:" +print("diff:") test.diff(".\\n", "a\\n") -print "diff_stderr:" +print("diff_stderr:") test.diff_stderr(".\\n", "a\\n") sys.exit(0) """ % self.orig_cwd, @@ -2696,9 +2702,10 @@ class stdin_TestCase(TestCmdTestCase): def test_stdin(self): """Test stdin()""" run_env = TestCmd.TestCmd(workdir = '') - run_env.write('run', """import fileinput + run_env.write('run', """from __future__ import print_function +import fileinput for line in fileinput.input(): - print 'Y'.join(line[:-1].split('X')) + print('Y'.join(line[:-1].split('X'))) """) run_env.write('input', "X on X this X line X\n") os.chdir(run_env.workdir) @@ -3327,14 +3334,16 @@ class variables_TestCase(TestCmdTestCase): 'TestCmd', ] - script = "import TestCmd\n" + \ - '\n'.join([ "print TestCmd.%s\n" % v for v in variables ]) + script = "from __future__ import print_function\n" + \ + "import TestCmd\n" + \ + '\n'.join([ "print(TestCmd.%s\n)" % v for v in variables ]) run_env.run(program=sys.executable, stdin=script) stderr = run_env.stderr() assert stderr == "", stderr - script = "from TestCmd import *\n" + \ - '\n'.join([ "print %s" % v for v in variables ]) + script = "from __future__ import print_function\n" + \ + "from TestCmd import *\n" + \ + '\n'.join([ "print(%s)" % v for v in variables ]) run_env.run(program=sys.executable, stdin=script) stderr = run_env.stderr() assert stderr == "", stderr -- cgit v0.12 From b4a807726365f963db3c5b0f0ba8b459c40a64d2 Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Thu, 9 Mar 2017 21:29:07 -0800 Subject: Use print() function to fix py2/3 --- test/CXX/CXXVERSION.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/CXX/CXXVERSION.py b/test/CXX/CXXVERSION.py index 6017001..abe6ce0 100644 --- a/test/CXX/CXXVERSION.py +++ b/test/CXX/CXXVERSION.py @@ -38,16 +38,17 @@ if sys.platform == 'win32': test.write("versioned.py", -"""import os +"""from __future__ import print_function +import os import sys if '-dumpversion' in sys.argv: - print '3.9.9' + print('3.9.9') sys.exit(0) if '--version' in sys.argv: - print 'this is version 2.9.9 wrapping', sys.argv[2] + 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] + print('wrong version', sys.argv[1], 'when wrapping', sys.argv[2]) sys.exit(1) os.system(" ".join(sys.argv[2:])) """) -- cgit v0.12 From f286773d5da1c938954131e93f39d3259e14b640 Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Thu, 9 Mar 2017 22:31:02 -0800 Subject: Use print() function to fix py2/3 --- test/explain/save-info.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/explain/save-info.py b/test/explain/save-info.py index af4c3f5..545f624 100644 --- a/test/explain/save-info.py +++ b/test/explain/save-info.py @@ -42,6 +42,8 @@ inc_ddd = test.workpath('inc', 'ddd') inc_eee = test.workpath('inc', 'eee') test.write(cat_py, r""" +from __future__ import print_function + import sys def process(outfp, infp): @@ -52,7 +54,7 @@ def process(outfp, infp): fp = open(file, 'rb') except IOError: import os - print "os.getcwd() =", os.getcwd() + print("os.getcwd() =", os.getcwd()) raise process(outfp, fp) else: -- cgit v0.12 From 914e670bb555a3a412253eff57eda9ce6e3e4a3a Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Thu, 9 Mar 2017 22:31:30 -0800 Subject: Use print() function to fix py2/3 --- test/explain/basic.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/explain/basic.py b/test/explain/basic.py index 1072ac4..7079e44 100644 --- a/test/explain/basic.py +++ b/test/explain/basic.py @@ -53,6 +53,8 @@ inc_bbb_k = test.workpath('inc', 'bbb.k') test.write(cat_py, r"""#!/usr/bin/env python +from __future__ import print_function + import sys def process(outfp, infp): @@ -63,7 +65,7 @@ def process(outfp, infp): fp = open(file, 'rb') except IOError: import os - print "os.getcwd() =", os.getcwd() + print("os.getcwd() =", os.getcwd()) raise process(outfp, fp) else: -- cgit v0.12 From 85e7b4542ee2cf378db46a09e7d0b7a1aca802b7 Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Thu, 9 Mar 2017 22:33:59 -0800 Subject: Use print() function to fix py2/3 --- test/SWIG/build-dir.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/SWIG/build-dir.py b/test/SWIG/build-dir.py index 304932f..eba3fea 100644 --- a/test/SWIG/build-dir.py +++ b/test/SWIG/build-dir.py @@ -145,11 +145,13 @@ public: test.write(['source', 'test.py'], """\ #!/usr/bin/env python +from __future__ import print_function + import linalg x = linalg.Vector(5) -print x +print(x) x[1] = 99.5 x[3] = 8.3 @@ -157,7 +159,7 @@ x[4] = 11.1 for i, v in enumerate(x): - print "\tx[%d] = %g" % (i, v) + print("\tx[%d] = %g" % (i, v)) """) -- cgit v0.12 From e179b10881ed0e61226a500ef45e35b76dbe2b4b Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Thu, 9 Mar 2017 22:34:46 -0800 Subject: Use print() function to fix py2/3 --- test/SCONS_LIB_DIR.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/SCONS_LIB_DIR.py b/test/SCONS_LIB_DIR.py index 95a377a..65ec3de 100644 --- a/test/SCONS_LIB_DIR.py +++ b/test/SCONS_LIB_DIR.py @@ -31,8 +31,10 @@ test = TestSCons.TestSCons() test.subdir('SCons') test.write(['SCons','Script.py'], """ +from __future__ import print_function + def main (): - print "SCons.Script" + print("SCons.Script") """) test.write(['SCons','__init__.py'], """ -- cgit v0.12 From 390c4c431abef8b0809a3c30ec07dc6900cb32ce Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Thu, 9 Mar 2017 22:36:28 -0800 Subject: Use print() function to fix py2/3 --- test/QT/Tool.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/test/QT/Tool.py b/test/QT/Tool.py index 63fb113..9e4a277 100644 --- a/test/QT/Tool.py +++ b/test/QT/Tool.py @@ -22,6 +22,8 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function + __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ @@ -98,7 +100,7 @@ def CheckForQt(context): if os.path.isfile(uic_path): potential_qt_dirs.insert(0, env[ 'qt_directory' ]) else: - print "QT not found. Invalid qt_directory value - failed to find uic." + print("QT not found. Invalid qt_directory value - failed to find uic.") return 0 for i in potential_qt_dirs: @@ -106,21 +108,21 @@ def CheckForQt(context): if CheckForQtAt(context, i): # additional checks to validate QT installation if not os.path.isfile(os.path.join(i, 'bin', 'uic')): - print "QT - failed to find uic." + print("QT - failed to find uic.") return 0 if not os.path.isfile(os.path.join(i, 'bin', 'moc')): - print "QT - failed to find moc." + print("QT - failed to find moc.") return 0 if not os.path.exists(os.path.join(i, 'lib')): - print "QT - failed to find QT lib path." + print("QT - failed to find QT lib path.") return 0 if not os.path.exists(os.path.join(i, 'include')): - print "QT - failed to find QT include path." + print("QT - failed to find QT include path.") return 0 return 1 else: if i==env['qt_directory']: - print "QT directory not valid. Failed QT test build." + print("QT directory not valid. Failed QT test build.") return 0 return 0 @@ -140,7 +142,7 @@ config = env.Configure(custom_tests = { }) if not config.CheckForQt(): - print "Failed to find valid QT environment." + print("Failed to find valid QT environment.") Exit(1) env.Tool('qt', ['$TOOL_PATH']) -- cgit v0.12 From ef2b52bbda4aa2ff98b73d13a0ff32782b25e0fd Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Thu, 9 Mar 2017 22:38:50 -0800 Subject: Use print() function to fix py2/3 --- runtest.py | 4 ++-- src/engine/SCons/Platform/posix.py | 2 +- src/engine/SCons/Tool/FortranCommon.py | 6 +++--- src/engine/SCons/cpp.py | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/runtest.py b/runtest.py index d0de6d1..ae456a2 100755 --- a/runtest.py +++ b/runtest.py @@ -210,8 +210,8 @@ parser.add_option('--xml', help="Save results to file in SCons XML format.") (options, args) = parser.parse_args() -#print "options:", options -#print "args:", args +#print("options:", options) +#print("args:", args) opts, args = getopt.getopt(args, "b:def:hj:klnP:p:qsv:Xx:t", diff --git a/src/engine/SCons/Platform/posix.py b/src/engine/SCons/Platform/posix.py index 190a2a6..8db08db 100644 --- a/src/engine/SCons/Platform/posix.py +++ b/src/engine/SCons/Platform/posix.py @@ -56,7 +56,7 @@ def escape(arg): for c in special: arg = arg.replace(c, slash+c) - # print "ESCAPE RESULT: %s"%arg + # print("ESCAPE RESULT: %s" % arg) return '"' + arg + '"' diff --git a/src/engine/SCons/Tool/FortranCommon.py b/src/engine/SCons/Tool/FortranCommon.py index e450730..ec409c0 100644 --- a/src/engine/SCons/Tool/FortranCommon.py +++ b/src/engine/SCons/Tool/FortranCommon.py @@ -207,7 +207,7 @@ def add_f90_to_env(env): except KeyError: F90Suffixes = ['.f90'] - #print "Adding %s to f90 suffixes" % F90Suffixes + #print("Adding %s to f90 suffixes" % F90Suffixes) try: F90PPSuffixes = env['F90PPFILESUFFIXES'] except KeyError: @@ -223,7 +223,7 @@ def add_f95_to_env(env): except KeyError: F95Suffixes = ['.f95'] - #print "Adding %s to f95 suffixes" % F95Suffixes + #print("Adding %s to f95 suffixes" % F95Suffixes) try: F95PPSuffixes = env['F95PPFILESUFFIXES'] except KeyError: @@ -239,7 +239,7 @@ def add_f03_to_env(env): except KeyError: F03Suffixes = ['.f03'] - #print "Adding %s to f95 suffixes" % F95Suffixes + #print("Adding %s to f95 suffixes" % F95Suffixes) try: F03PPSuffixes = env['F03PPFILESUFFIXES'] except KeyError: diff --git a/src/engine/SCons/cpp.py b/src/engine/SCons/cpp.py index 18f154a..8212cc1 100644 --- a/src/engine/SCons/cpp.py +++ b/src/engine/SCons/cpp.py @@ -312,7 +312,7 @@ class PreProcessor(object): t = self.tuples.pop(0) # Uncomment to see the list of tuples being processed (e.g., # to validate the CPP lines are being translated correctly). - #print t + #print(t) self.dispatch_table[t[0]](t) return self.finalize_result(fname) @@ -510,7 +510,7 @@ class PreProcessor(object): t = self.resolve_include(t) include_file = self.find_include_file(t) if include_file: - #print "include_file =", include_file + #print("include_file =", include_file) self.result.append(include_file) contents = self.read_file(include_file) new_tuples = [('scons_current_file', include_file)] + \ @@ -547,7 +547,7 @@ class PreProcessor(object): """ s = t[1] while not s[0] in '<"': - #print "s =", s + #print("s =", s) try: s = self.cpp_namespace[s] except KeyError: -- cgit v0.12 From 201e568bed7c69fcc89229db1ed68be6ff75b3bc Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Thu, 9 Mar 2017 22:40:59 -0800 Subject: Use print() function to fix py2/3 --- doc/man/scons.xml | 36 ++++++++++++++++++------------------ doc/user/builders-writing.xml | 4 ++-- doc/user/command-line.xml | 14 +++++++------- doc/user/environments.xml | 30 +++++++++++++++--------------- doc/user/misc.xml | 30 +++++++++++++++--------------- doc/user/nodes.xml | 12 ++++++------ doc/user/output.xml | 8 ++++---- doc/user/simple.xml | 6 +++--- src/engine/SCons/Environment.xml | 2 +- src/engine/SCons/Script/Main.xml | 4 ++-- 10 files changed, 73 insertions(+), 73 deletions(-) diff --git a/doc/man/scons.xml b/doc/man/scons.xml index 41ef607..b68f27a 100644 --- a/doc/man/scons.xml +++ b/doc/man/scons.xml @@ -2483,7 +2483,7 @@ foo = Object('foo.c') bar = Object('bar.c') objects = ['begin.o'] + foo + ['middle.o'] + bar + ['end.o'] for object in objects: - print str(object) + print(str(object)) Or you can use the @@ -2497,7 +2497,7 @@ foo = Object('foo.c') bar = Object('bar.c') objects = Flatten(['begin.o', foo, 'middle.o', bar, 'end.o']) for object in objects: - print str(object) + print(str(object)) Note also that because Builder calls return @@ -2541,7 +2541,7 @@ function: bar_obj_list = env.StaticObject('bar.c', CPPDEFINES='-DBAR') -print "The path to bar_obj is:", str(bar_obj_list[0]) +print("The path to bar_obj is:", str(bar_obj_list[0])) Note again that because the Builder call returns a list, @@ -2842,10 +2842,10 @@ of the tuple, respectively. Example: -print "first keyword, value =", ARGLIST[0][0], ARGLIST[0][1] -print "second keyword, value =", ARGLIST[1][0], ARGLIST[1][1] +print("first keyword, value =", ARGLIST[0][0], ARGLIST[0][1]) +print("second keyword, value =", ARGLIST[1][0], ARGLIST[1][1]) third_tuple = ARGLIST[2] -print "third keyword, value =", third_tuple[0], third_tuple[1] +print("third keyword, value =", third_tuple[0], third_tuple[1]) for key, value in ARGLIST: # process key and value @@ -2913,7 +2913,7 @@ for additional information. if 'foo' in BUILD_TARGETS: - print "Don't forget to test the `foo' program!" + print("Don't forget to test the `foo' program!") if 'special/program' in BUILD_TARGETS: SConscript('special') @@ -2951,7 +2951,7 @@ is explicitly being built. if 'foo' in COMMAND_LINE_TARGETS: - print "Don't forget to test the `foo' program!" + print("Don't forget to test the `foo' program!") if 'special/program' in COMMAND_LINE_TARGETS: SConscript('special') @@ -2975,9 +2975,9 @@ function to get at the path name for each Node. Example: -print str(DEFAULT_TARGETS[0]) +print(str(DEFAULT_TARGETS[0])) if 'foo' in map(str, DEFAULT_TARGETS): - print "Don't forget to test the `foo' program!" + print("Don't forget to test the `foo' program!") @@ -2990,13 +2990,13 @@ list change on on each successive call to the function: -print map(str, DEFAULT_TARGETS) # originally [] +print(map(str, DEFAULT_TARGETS)) # originally [] Default('foo') -print map(str, DEFAULT_TARGETS) # now a node ['foo'] +print(map(str, DEFAULT_TARGETS)) # now a node ['foo'] Default('bar') -print map(str, DEFAULT_TARGETS) # now a node ['foo', 'bar'] +print(map(str, DEFAULT_TARGETS)) # now a node ['foo', 'bar'] Default(None) -print map(str, DEFAULT_TARGETS) # back to [] +print(map(str, DEFAULT_TARGETS)) # back to [] Consequently, be sure to use @@ -3525,7 +3525,7 @@ a shared library, only that the compilation (not link) succeeds. env = Environment() conf = Configure( env ) if not conf.CheckCHeader( 'math.h' ): - print 'We really need math.h!' + print('We really need math.h!') Exit(1) if conf.CheckLibWithHeader( 'qt', 'qapp.h', 'c++', 'QApplication qapp(0,0);' ): @@ -3815,7 +3815,7 @@ int main(int argc, char **argv) { env = Environment() conf = Configure( env, custom_tests = { 'CheckQt' : CheckQt } ) if not conf.CheckQt('/usr/lib/qt'): - print 'We really need qt!' + print('We really need qt!') Exit(1) env = conf.Finish() @@ -3995,7 +3995,7 @@ not configured. env = Environment(variables=vars) for key, value in vars.UnknownVariables(): - print "unknown variable: %s=%s" % (key, value) + print("unknown variable: %s=%s" % (key, value)) @@ -4400,7 +4400,7 @@ File('foo.c').srcnode().path # source path of the given source file. # Builders also return File objects: foo = env.Program('foo.c') -print "foo will be built in %s"%foo.path +print("foo will be built in %s"%foo.path) A diff --git a/doc/user/builders-writing.xml b/doc/user/builders-writing.xml index dec176a..07f2dec 100644 --- a/doc/user/builders-writing.xml +++ b/doc/user/builders-writing.xml @@ -1047,7 +1047,7 @@ def MakeWorkDir(workdir): import my_utils MakeWorkDir('/tmp/work') -print "build_id=" + my_utils.build_id() +print("build_id=" + my_utils.build_id()) @@ -1060,7 +1060,7 @@ print "build_id=" + my_utils.build_id() import my_utils -print "build_id=" + my_utils.build_id() +print("build_id=" + my_utils.build_id()) my_utils.MakeWorkDir('/tmp/work') diff --git a/doc/user/command-line.xml b/doc/user/command-line.xml index 85c2da0..a4bbf21 100644 --- a/doc/user/command-line.xml +++ b/doc/user/command-line.xml @@ -317,7 +317,7 @@ if not GetOption('help'): import os num_cpu = int(os.environ.get('NUM_CPU', 2)) SetOption('num_jobs', num_cpu) -print "running with -j", GetOption('num_jobs') +print("running with -j", GetOption('num_jobs')) foo.in @@ -1863,7 +1863,7 @@ env = Environment(variables = vars, CPPDEFINES={'RELEASE_BUILD' : '${RELEASE}'}) unknown = vars.UnknownVariables() if unknown: - print "Unknown variables:", unknown.keys() + print("Unknown variables:", unknown.keys()) Exit(1) env.Program('foo.c') @@ -1945,7 +1945,7 @@ foo.c if 'bar' in COMMAND_LINE_TARGETS: - print "Don't forget to copy `bar' to the archive!" + print("Don't forget to copy `bar' to the archive!") Default(Program('foo.c')) Program('bar.c') @@ -2210,7 +2210,7 @@ prog2.c prog1 = Program('prog1.c') Default(prog1) -print "DEFAULT_TARGETS is", map(str, DEFAULT_TARGETS) +print("DEFAULT_TARGETS is", map(str, DEFAULT_TARGETS)) prog1.c @@ -2244,10 +2244,10 @@ prog1.c prog1 = Program('prog1.c') Default(prog1) -print "DEFAULT_TARGETS is now", map(str, DEFAULT_TARGETS) +print("DEFAULT_TARGETS is now", map(str, DEFAULT_TARGETS)) prog2 = Program('prog2.c') Default(prog2) -print "DEFAULT_TARGETS is now", map(str, DEFAULT_TARGETS) +print("DEFAULT_TARGETS is now", map(str, DEFAULT_TARGETS)) prog1.c @@ -2338,7 +2338,7 @@ else: prog1 = Program('prog1.c') Program('prog2.c') Default(prog1) -print "BUILD_TARGETS is", map(str, BUILD_TARGETS) +print("BUILD_TARGETS is", map(str, BUILD_TARGETS)) prog1.c diff --git a/doc/user/environments.xml b/doc/user/environments.xml index 66abdcc..d1da3f9 100644 --- a/doc/user/environments.xml +++ b/doc/user/environments.xml @@ -627,7 +627,7 @@ int main() { } env = Environment() -print "CC is:", env['CC'] +print("CC is:", env['CC']) @@ -658,7 +658,7 @@ print "CC is:", env['CC'] env = Environment(FOO = 'foo', BAR = 'bar') dict = env.Dictionary() for key in ['OBJSUFFIX', 'LIBSUFFIX', 'PROGSUFFIX']: - print "key = %s, value = %s" % (key, dict[key]) + print("key = %s, value = %s" % (key, dict[key])) @@ -695,7 +695,7 @@ for key in ['OBJSUFFIX', 'LIBSUFFIX', 'PROGSUFFIX']: env = Environment() for item in sorted(env.Dictionary().items()): - print "construction variable = '%s', value = '%s'" % item + print("construction variable = '%s', value = '%s'" % item) @@ -721,7 +721,7 @@ for item in sorted(env.Dictionary().items()): env = Environment() -print "CC is:", env.subst('$CC') +print("CC is:", env.subst('$CC')) @@ -738,7 +738,7 @@ print "CC is:", env.subst('$CC') env = Environment(CCFLAGS = '-DFOO') -print "CCCOM is:", env['CCCOM'] +print("CCCOM is:", env['CCCOM']) @@ -764,7 +764,7 @@ scons: `.' is up to date. env = Environment(CCFLAGS = '-DFOO') -print "CCCOM is:", env.subst('$CCCOM') +print("CCCOM is:", env.subst('$CCCOM')) @@ -806,7 +806,7 @@ scons: `.' is up to date. env = Environment() -print "value is:", env.subst( '->$MISSING<-' ) +print("value is:", env.subst( '->$MISSING<-' )) @@ -834,7 +834,7 @@ print "value is:", env.subst( '->$MISSING<-' ) AllowSubstExceptions() env = Environment() -print "value is:", env.subst( '->$MISSING<-' ) +print("value is:", env.subst( '->$MISSING<-' )) @@ -854,7 +854,7 @@ print "value is:", env.subst( '->$MISSING<-' ) AllowSubstExceptions(IndexError, NameError, ZeroDivisionError) env = Environment() -print "value is:", env.subst( '->${1 / 0}<-' ) +print("value is:", env.subst( '->${1 / 0}<-' )) @@ -1216,7 +1216,7 @@ int main() { } env = Environment() env.Replace(NEW_VARIABLE = 'xyzzy') -print "NEW_VARIABLE =", env['NEW_VARIABLE'] +print("NEW_VARIABLE =", env['NEW_VARIABLE']) @@ -1251,11 +1251,11 @@ print "NEW_VARIABLE =", env['NEW_VARIABLE'] env = Environment(CCFLAGS = '-DDEFINE1') -print "CCFLAGS =", env['CCFLAGS'] +print("CCFLAGS =", env['CCFLAGS']) env.Program('foo.c') env.Replace(CCFLAGS = '-DDEFINE2') -print "CCFLAGS =", env['CCFLAGS'] +print("CCFLAGS =", env['CCFLAGS']) env.Program('bar.c') @@ -1375,7 +1375,7 @@ int main() { } env = Environment() env.Append(NEW_VARIABLE = 'added') -print "NEW_VARIABLE =", env['NEW_VARIABLE'] +print("NEW_VARIABLE =", env['NEW_VARIABLE']) @@ -1475,7 +1475,7 @@ int main() { } env = Environment() env.Prepend(NEW_VARIABLE = 'added') -print "NEW_VARIABLE =", env['NEW_VARIABLE'] +print("NEW_VARIABLE =", env['NEW_VARIABLE']) @@ -1650,7 +1650,7 @@ if len(sys.argv) > 1: else: keys = sorted(os.environ.keys()) for key in keys: - print " " + key + "=" + os.environ[key] + print(" " + key + "=" + os.environ[key]) diff --git a/doc/user/misc.xml b/doc/user/misc.xml index 286963d..1690639 100644 --- a/doc/user/misc.xml +++ b/doc/user/misc.xml @@ -212,7 +212,7 @@ SCons 1.0 or greater required, but you have SCons 0.98.5 if ARGUMENTS.get('FUTURE'): - print "The FUTURE option is not supported yet!" + print("The FUTURE option is not supported yet!") Exit(2) env = Environment() env.Program('hello.c') @@ -268,9 +268,9 @@ hello.c # one directory -print FindFile('missing', '.') +print(FindFile('missing', '.')) t = FindFile('exists', '.') -print t.__class__, t +print(t.__class__, t) exists @@ -287,7 +287,7 @@ print t.__class__, t includes = [ '.', 'include', 'src/include'] headers = [ 'nonesuch.h', 'config.h', 'private.h', 'dist.h'] for hdr in headers: - print '%-12s' % ('%s:' % hdr), FindFile(hdr, includes) + print('%-12s' % ('%s:' % hdr), FindFile(hdr, includes)) exists @@ -320,7 +320,7 @@ exists # several directories includes = [ '.', 'include', 'src/include'] headers = [ 'nonesuch.h', 'config.h', 'private.h', 'dist.h'] -print FindFile(headers, includes) +print(FindFile(headers, includes)) exists @@ -350,9 +350,9 @@ exists -print FindFile('multiple', ['sub1', 'sub2', 'sub3']) -print FindFile('multiple', ['sub2', 'sub3', 'sub1']) -print FindFile('multiple', ['sub3', 'sub1', 'sub2']) +print(FindFile('multiple', ['sub1', 'sub2', 'sub3'])) +print(FindFile('multiple', ['sub2', 'sub3', 'sub1'])) +print(FindFile('multiple', ['sub3', 'sub1', 'sub2'])) @@ -386,8 +386,8 @@ exists # Neither file exists, so build will fail Command('derived', 'leaf', 'cat >$TARGET $SOURCE') -print FindFile('leaf', '.') -print FindFile('derived', '.') +print(FindFile('leaf', '.')) +print(FindFile('derived', '.')) @@ -399,8 +399,8 @@ print FindFile('derived', '.') # Only 'leaf' exists Command('derived', 'leaf', 'cat >$TARGET $SOURCE') -print FindFile('leaf', '.') -print FindFile('derived', '.') +print(FindFile('leaf', '.')) +print(FindFile('derived', '.')) leaf @@ -422,7 +422,7 @@ leaf # Only 'src/leaf' exists VariantDir('build', 'src') -print FindFile('leaf', 'build') +print(FindFile('leaf', 'build')) @@ -507,7 +507,7 @@ objects = [ Program(objects) for object_file in objects: - print object_file.abspath + print(object_file.abspath) prog1.c @@ -548,7 +548,7 @@ objects = [ Program(objects) for object_file in Flatten(objects): - print object_file.abspath + print(object_file.abspath) prog1.c diff --git a/doc/user/nodes.xml b/doc/user/nodes.xml index a04b6ad..b17bb7c 100644 --- a/doc/user/nodes.xml +++ b/doc/user/nodes.xml @@ -265,8 +265,8 @@ xyzzy = Entry('xyzzy') object_list = Object('hello.c') program_list = Program(object_list) -print "The object file is:", object_list[0] -print "The program file is:", program_list[0] +print("The object file is:", object_list[0]) +print("The program file is:", program_list[0]) int main() { printf("Hello, world!\n"); } @@ -334,7 +334,7 @@ import os.path program_list = Program('hello.c') program_name = str(program_list[0]) if not os.path.exists(program_name): - print program_name, "does not exist!" + print(program_name, "does not exist!") int main() { printf("Hello, world!\n"); } @@ -374,7 +374,7 @@ int main() { printf("Hello, world!\n"); } env=Environment(VAR="value") n=File("foo.c") -print env.GetBuildPath([n, "sub/dir/$VAR"]) +print(env.GetBuildPath([n, "sub/dir/$VAR"])) @@ -414,8 +414,8 @@ print env.GetBuildPath([n, "sub/dir/$VAR"]) hello_c = File('hello.c') contents = hello_c.read() -print "contents are:" -print contents +print("contents are:") +print(contents) int main() { printf("Hello, world!\n"); } diff --git a/doc/user/output.xml b/doc/user/output.xml index 78dcca4..ca4707d 100644 --- a/doc/user/output.xml +++ b/doc/user/output.xml @@ -622,7 +622,7 @@ import atexit def print_build_failures(): from SCons.Script import GetBuildFailures for bf in GetBuildFailures(): - print "%s failed: %s" % (bf.node, bf.errstr) + print("%s failed: %s" % (bf.node, bf.errstr)) atexit.register(print_build_failures) @@ -701,10 +701,10 @@ def display_build_status(): Here you could do all kinds of complicated things.""" status, failures_message = build_status() if status == 'failed': - print "FAILED!!!!" # could display alert, ring bell, etc. + print("FAILED!!!!") # could display alert, ring bell, etc. elif status == 'ok': - print "Build succeeded." - print failures_message + print("Build succeeded.") + print(failures_message) atexit.register(display_build_status) diff --git a/doc/user/simple.xml b/doc/user/simple.xml index a015c91..acc438b 100644 --- a/doc/user/simple.xml +++ b/doc/user/simple.xml @@ -442,11 +442,11 @@ Program('hello.c') # "hello.c" is the source file. -print "Calling Program('hello.c')" +print("Calling Program('hello.c')") Program('hello.c') -print "Calling Program('goodbye.c')" +print("Calling Program('goodbye.c')") Program('goodbye.c') -print "Finished calling Program()" +print("Finished calling Program()") int main() { printf("Hello, world!\n"); } diff --git a/src/engine/SCons/Environment.xml b/src/engine/SCons/Environment.xml index 65d71ff..92bc21a 100644 --- a/src/engine/SCons/Environment.xml +++ b/src/engine/SCons/Environment.xml @@ -327,7 +327,7 @@ Examples: # which the method will be called; the Python # convention is to call it 'self'. def my_method(self, arg): - print "my_method() got", arg + print("my_method() got", arg) # Use the global AddMethod() function to add a method # to the Environment class. This diff --git a/src/engine/SCons/Script/Main.xml b/src/engine/SCons/Script/Main.xml index 07dce9a..98db5bf 100644 --- a/src/engine/SCons/Script/Main.xml +++ b/src/engine/SCons/Script/Main.xml @@ -256,7 +256,7 @@ import atexit def print_build_failures(): from SCons.Script import GetBuildFailures for bf in GetBuildFailures(): - print "%s failed: %s" % (bf.node, bf.errstr) + print("%s failed: %s" % (bf.node, bf.errstr)) atexit.register(print_build_failures) @@ -577,7 +577,7 @@ every 10 Nodes: def my_progress_function(node, *args, **kw): - print 'Evaluating node %s!' % node + print('Evaluating node %s!' % node) Progress(my_progress_function, interval=10) -- cgit v0.12 From 2ff5df2eb4e694e1c7e53fab71e0125d277c111e Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Thu, 9 Mar 2017 23:24:12 -0800 Subject: Use syntax for octal integers as specified in PEP 3127 --- test/Chmod.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/test/Chmod.py b/test/Chmod.py index e5bb85f..316800b 100644 --- a/test/Chmod.py +++ b/test/Chmod.py @@ -36,13 +36,13 @@ import TestSCons test = TestSCons.TestSCons() # Note: Windows basically has two modes that it can os.chmod() files to -# 0444 and 0666, and directories to 0555 and 0777, so we can only really +# 0o444 and 0o666, and directories to 0o555 and 0o777, so we can only really # oscillate between those values. test.write('SConstruct', """ -Execute(Chmod('f1', 0666)) -Execute(Chmod(('f1-File'), 0666)) -Execute(Chmod('d2', 0777)) -Execute(Chmod(Dir('d2-Dir'), 0777)) +Execute(Chmod('f1', 0o666)) +Execute(Chmod(('f1-File'), 0o666)) +Execute(Chmod('d2', 0o777)) +Execute(Chmod(Dir('d2-Dir'), 0o777)) def cat(env, source, target): target = str(target[0]) f = open(target, "wb") @@ -52,18 +52,18 @@ def cat(env, source, target): Cat = Action(cat) env = Environment() env.Command('bar.out', 'bar.in', [Cat, - Chmod("f3", 0666), - Chmod("d4", 0777)]) + Chmod("f3", 0o666), + Chmod("d4", 0o777)]) env = Environment(FILE = 'f5') -env.Command('f6.out', 'f6.in', [Chmod('$FILE', 0666), Cat]) +env.Command('f6.out', 'f6.in', [Chmod('$FILE', 0o666), Cat]) env.Command('f7.out', 'f7.in', [Cat, - Chmod('Chmod-$SOURCE', 0666), - Chmod('${TARGET}-Chmod', 0666)]) + Chmod('Chmod-$SOURCE', 0o666), + Chmod('${TARGET}-Chmod', 0o666)]) # Make sure Chmod works with a list of arguments env = Environment(FILE = 'f9') -env.Command('f8.out', 'f8.in', [Chmod(['$FILE', File('f10')], 0666), Cat]) -Execute(Chmod(['d11', Dir('d12')], 0777)) +env.Command('f8.out', 'f8.in', [Chmod(['$FILE', File('f10')], 0o666), Cat]) +Execute(Chmod(['d11', Dir('d12')], 0o777)) Execute(Chmod('f13', "a=r")) Execute(Chmod('f14', "ogu+w")) Execute(Chmod('f15', "ug=rw, go+ rw")) -- cgit v0.12 From 48074f8237304d335e8699f5d544fdfe02eb103c Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Thu, 9 Mar 2017 23:27:13 -0800 Subject: Use print() function to fix py2/3 --- test/VariantDir/reflect.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/VariantDir/reflect.py b/test/VariantDir/reflect.py index ea5689a..72f3af7 100644 --- a/test/VariantDir/reflect.py +++ b/test/VariantDir/reflect.py @@ -44,11 +44,15 @@ _python_ = TestSCons._python_ re_python = re.escape(TestSCons._python_) test.write("mycc.py", """ -print 'Compile' +from __future__ import print_function + +print('Compile') """) test.write("mylink.py", """ -print 'Link' +from __future__ import print_function + +print('Link') """) sconstruct = """ -- cgit v0.12 From d3dbe8e9502534149b1ca175c483882f7b4e551d Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Thu, 9 Mar 2017 23:29:20 -0800 Subject: Use print() function to fix py2/3 --- test/scons-time/run/config/python.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/scons-time/run/config/python.py b/test/scons-time/run/config/python.py index 57b732d..2660927 100644 --- a/test/scons-time/run/config/python.py +++ b/test/scons-time/run/config/python.py @@ -44,13 +44,14 @@ python = r'%(my_python_py)s' test.write(my_python_py, """\ #!/usr/bin/env python +from __future__ import print_function import sys profile = '' for arg in sys.argv[1:]: if arg.startswith('--profile='): profile = arg[10:] break -print 'my_python.py: %s' % profile +print('my_python.py: %s' % profile) """) os.chmod(my_python_py, 0o755) -- cgit v0.12 From 029cc649663f8e833a380018c73144b6c8c4c2fe Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 10 Mar 2017 16:19:42 -0500 Subject: Fixing SConsValues to work with py2/3. Turns out because in py2 optparse.Values is a classic class deepcopy works different than in py3 when it's a modern class (no more classic classes). The net of which is deepcopy will look for various methods to copy the objects state, __deepcopy__, something else, then __setstate__. When it checks for __setstate__ it trys on a blank SConsValue instance which doesn't have __defaults__ and so SConsValues ends up throwing a KeyError exception. deepcopy is looking for an AttributeError exception to know that __setstate__ is not available. Once it receives the appropriate exception, it then properly copies the object and scons interactive mode works with py3 --- src/engine/SCons/Script/SConsOptions.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/engine/SCons/Script/SConsOptions.py b/src/engine/SCons/Script/SConsOptions.py index 501e4ce..288a7a5 100644 --- a/src/engine/SCons/Script/SConsOptions.py +++ b/src/engine/SCons/Script/SConsOptions.py @@ -63,6 +63,7 @@ def diskcheck_convert(value): raise ValueError(v) return result + class SConsValues(optparse.Values): """ Holder class for uniform access to SCons options, regardless @@ -112,7 +113,18 @@ class SConsValues(optparse.Values): try: return self.__dict__['__SConscript_settings__'][attr] except KeyError: - return getattr(self.__dict__['__defaults__'], attr) + try: + return getattr(self.__dict__['__defaults__'], attr) + except KeyError: + # Added because with py3 this is a new class, + # not a classic class, and due to the way + # In that case it will create an object without + # __defaults__, and then query for __setstate__ + # which will throw an exception of KeyError + # deepcopy() is expecting AttributeError if __setstate__ + # is not available. + raise AttributeError(attr) + settable = [ 'clean', @@ -186,6 +198,7 @@ class SConsValues(optparse.Values): self.__SConscript_settings__[name] = value + class SConsOption(optparse.Option): def convert_value(self, opt, value): if value is not None: -- cgit v0.12 From 2968cb59b7c8a7a634cca60a3afafd0132bfa683 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 10 Mar 2017 17:00:31 -0500 Subject: remove debug logic --- QMTest/TestCmd.py | 1 - 1 file changed, 1 deletion(-) diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index b97f103..96e07a9 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -1355,7 +1355,6 @@ class TestCmd(object): if timeout: self.timer = threading.Timer(float(timeout), self._timeout) self.timer.start() - print("CMD:%s"%cmd) p = Popen(cmd, stdin=stdin, stdout=subprocess.PIPE, -- cgit v0.12 From 2c9d9a6282c6a92d04023dec7e926a6de7f7a71c Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 10 Mar 2017 22:58:38 -0500 Subject: remove rb/wb from file opens, not needed py2/3 --- test/subdivide.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/subdivide.py b/test/subdivide.py index 44402c9..770870d 100644 --- a/test/subdivide.py +++ b/test/subdivide.py @@ -61,19 +61,19 @@ fake_link_py = test.workpath('fake_link.py') test.write(fake_cc_py, """\ #!/usr/bin/env python import sys -ofp = open(sys.argv[1], 'wb') +ofp = open(sys.argv[1], 'w') ofp.write('fake_cc.py: %s\\n' % sys.argv) for s in sys.argv[2:]: - ofp.write(open(s, 'rb').read()) + ofp.write(open(s, 'r').read()) """) test.write(fake_link_py, """\ #!/usr/bin/env python import sys -ofp = open(sys.argv[1], 'wb') +ofp = open(sys.argv[1], 'w') ofp.write('fake_link.py: %s\\n' % sys.argv) for s in sys.argv[2:]: - ofp.write(open(s, 'rb').read()) + ofp.write(open(s, 'r').read()) """) test.chmod(fake_cc_py, 0o755) -- cgit v0.12 From 11db768c8615a97cbc8364784e6fa55b283c4396 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 10 Mar 2017 22:59:38 -0500 Subject: remove rb/wb from file opens, not needed py2/3 --- test/srcchange.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/srcchange.py b/test/srcchange.py index f2fde91..bbad4e7 100644 --- a/test/srcchange.py +++ b/test/srcchange.py @@ -44,7 +44,8 @@ test = TestSCons.TestSCons() test.write('getrevision', """ #!/usr/bin/env python -print open('revnum.in','rb').read().strip() +from __future__ import print_function +print(open('revnum.in','r').read().strip()) """) test.write('SConstruct', """ @@ -55,7 +56,7 @@ def subrevision(target, source ,env): new = re.sub('\$REV.*?\$', '$REV: %%s$'%%source[0].get_text_contents().strip(), target[0].get_text_contents()) - outf = open(str(target[0]),'wb') + outf = open(str(target[0]),'w') outf.write(new) outf.close() -- cgit v0.12 From d4d304a0d134d8be28bf1ded268fb118eb86c2da Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 10 Mar 2017 23:02:37 -0500 Subject: remove rb/wb from file opens, not needed py2/3 --- test/CPPFLAGS.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/test/CPPFLAGS.py b/test/CPPFLAGS.py index 216984a..e132876 100644 --- a/test/CPPFLAGS.py +++ b/test/CPPFLAGS.py @@ -51,8 +51,8 @@ while args: break args.pop(0) if a[:5] == '/OUT:': out = a[5:] -infile = open(args[0], 'rb') -outfile = open(out, 'wb') +infile = open(args[0], 'r') +outfile = open(out, 'w') for l in infile.readlines(): if l[:5] != '#link': outfile.write(l) @@ -67,9 +67,9 @@ import sys opts, args = getopt.getopt(sys.argv[1:], 'o:s:') for opt, arg in opts: if opt == '-o': out = arg -outfile = open(out, 'wb') +outfile = open(out, 'w') for f in args: - infile = open(f, 'rb') + infile = open(f, 'r') for l in infile.readlines(): if l[:5] != '#link': outfile.write(l) @@ -85,15 +85,17 @@ clen = len(compiler) + 1 opts, args = getopt.getopt(sys.argv[2:], 'co:xf:K:') for opt, arg in opts: if opt == '-o': out = arg - elif opt == '-x': open('mygcc.out', 'ab').write(compiler + "\n") -infile = open(args[0], 'rb') -outfile = open(out, 'wb') + elif opt == '-x': open('mygcc.out', 'a').write(compiler + "\n") +infile = open(args[0], 'r') +outfile = open(out, 'w') for l in infile.readlines(): if l[:clen] != '#' + compiler: outfile.write(l) sys.exit(0) """) + + test.write('SConstruct', """ env = Environment(CPPFLAGS = '-x', LINK = r'%(_python_)s mylink.py', -- cgit v0.12 From c3c542af56fd2fe3d5eb3351561ef64a94cafb8c Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 10 Mar 2017 23:03:35 -0500 Subject: remove rb/wb from file opens, not needed py2/3 --- test/CPPSUFFIXES.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/CPPSUFFIXES.py b/test/CPPSUFFIXES.py index b2e6369..6aa5596 100644 --- a/test/CPPSUFFIXES.py +++ b/test/CPPSUFFIXES.py @@ -37,12 +37,12 @@ test = TestSCons.TestSCons() test.write('mycc.py', r""" import sys def do_file(outf, inf): - for line in open(inf, 'rb').readlines(): + for line in open(inf, 'r').readlines(): if line[:10] == '#include <': do_file(outf, line[10:-2]) else: outf.write(line) -outf = open(sys.argv[1], 'wb') +outf = open(sys.argv[1], 'w') for f in sys.argv[2:]: do_file(outf, f) sys.exit(0) -- cgit v0.12 From 0850cf4f87576efcd31570fd5dcd0cc2b2a23e63 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 10 Mar 2017 23:05:09 -0500 Subject: remove rb/wb from file opens, not needed py2/3 --- test/CXX/CXX.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/CXX/CXX.py b/test/CXX/CXX.py index c9dbf1c..1a07b09 100644 --- a/test/CXX/CXX.py +++ b/test/CXX/CXX.py @@ -50,8 +50,8 @@ while args: break args = args[1:] if a[:5].lower() == '/out:': out = a[5:] -infile = open(args[0], 'rb') -outfile = open(out, 'wb') +infile = open(args[0], 'r') +outfile = open(out, 'w') for l in infile.readlines(): if l[:8] != '/*link*/': outfile.write(l) @@ -74,8 +74,8 @@ while args: inf = a continue if a[:3] == '/Fo': out = a[3:] -infile = open(inf, 'rb') -outfile = open(out, 'wb') +infile = open(inf, 'r') +outfile = open(out, 'w') for l in infile.readlines(): if l[:7] != '/*c++*/': outfile.write(l) @@ -90,8 +90,8 @@ import sys opts, args = getopt.getopt(sys.argv[1:], 'o:') for opt, arg in opts: if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') +infile = open(args[0], 'r') +outfile = open(out, 'w') for l in infile.readlines(): if l[:8] != '/*link*/': outfile.write(l) @@ -104,8 +104,8 @@ import sys opts, args = getopt.getopt(sys.argv[1:], 'co:') for opt, arg in opts: if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') +infile = open(args[0], 'r') +outfile = open(out, 'w') for l in infile.readlines(): if l[:7] != '/*c++*/': outfile.write(l) -- cgit v0.12 From 3ae12152167ab6df56a84bf2212ec47052b12472 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 10 Mar 2017 23:06:36 -0500 Subject: remove rb/wb from file opens, not needed py2/3 --- test/CXX/CXXFILESUFFIX.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/CXX/CXXFILESUFFIX.py b/test/CXX/CXXFILESUFFIX.py index 8439aef..9442408 100644 --- a/test/CXX/CXXFILESUFFIX.py +++ b/test/CXX/CXXFILESUFFIX.py @@ -37,7 +37,7 @@ import getopt import sys cmd_opts, args = getopt.getopt(sys.argv[1:], 't', []) for a in args: - contents = open(a, 'rb').read() + contents = open(a, 'r').read() sys.stdout.write(contents.replace('LEX', 'mylex.py')) sys.exit(0) """) -- cgit v0.12 From 31020a6f6f41969e1c0a953109de9457b6d1f812 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 10 Mar 2017 23:10:29 -0500 Subject: remove rb/wb from file opens, not needed py2/3 --- test/CacheDir/CacheDir.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/CacheDir/CacheDir.py b/test/CacheDir/CacheDir.py index 4c05634..fe73cad 100644 --- a/test/CacheDir/CacheDir.py +++ b/test/CacheDir/CacheDir.py @@ -52,10 +52,10 @@ SConscript('SConscript') test.write(['src', 'SConscript'], """\ def cat(env, source, target): target = str(target[0]) - open('cat.out', 'ab').write(target + "\\n") - f = open(target, "wb") + open('cat.out', 'a').write(target + "\\n") + f = open(target, "w") for src in source: - f.write(open(str(src), "rb").read()) + f.write(open(str(src), "r").read()) f.close() env = Environment(BUILDERS={'Cat':Builder(action=cat)}) env.Cat('aaa.out', 'aaa.in') -- cgit v0.12 From 987ab157d85b4966e7ad6cfa8b7bb9031ab042fc Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 10 Mar 2017 23:10:58 -0500 Subject: remove rb/wb from file opens, not needed py2/3 --- test/CacheDir/SideEffect.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/CacheDir/SideEffect.py b/test/CacheDir/SideEffect.py index e84ab09..386b16a 100644 --- a/test/CacheDir/SideEffect.py +++ b/test/CacheDir/SideEffect.py @@ -38,14 +38,14 @@ cache = test.workpath('cache') test.write(['work', 'SConstruct'], """\ def copy(source, target): - open(target, "wb").write(open(source, "rb").read()) + open(target, "w").write(open(source, "r").read()) def build(env, source, target): s = str(source[0]) t = str(target[0]) copy(s, t) if target[0].side_effects: - side_effect = open(str(target[0].side_effects[0]), "ab") + side_effect = open(str(target[0].side_effects[0]), "a") side_effect.write(s + ' -> ' + t + '\\n') CacheDir(r'%(cache)s') -- cgit v0.12 From 3416f3c5408fefa8ac42cc6c618f44645b2d4b13 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 10 Mar 2017 23:11:50 -0500 Subject: remove rb/wb from file opens, not needed py2/3 --- test/CacheDir/VariantDir.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/CacheDir/VariantDir.py b/test/CacheDir/VariantDir.py index b665fe3..30325d2 100644 --- a/test/CacheDir/VariantDir.py +++ b/test/CacheDir/VariantDir.py @@ -42,10 +42,10 @@ cat_out = test.workpath('cat.out') test.write(['src', 'SConscript'], """\ def cat(env, source, target): target = str(target[0]) - open('cat.out', 'ab').write(target + "\\n") - f = open(target, "wb") + open('cat.out', 'a').write(target + "\\n") + f = open(target, "w") for src in source: - f.write(open(str(src), "rb").read()) + f.write(open(str(src), "r").read()) f.close() env = Environment(BUILDERS={'Cat':Builder(action=cat)}) env.Cat('aaa.out', 'aaa.in') -- cgit v0.12 From 06b116289bd399ee6c9dddaa92a62063160b491e Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 10 Mar 2017 23:12:38 -0500 Subject: remove rb/wb from file opens, not needed py2/3 --- test/CacheDir/debug.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/CacheDir/debug.py b/test/CacheDir/debug.py index 307687d..e3186b0 100644 --- a/test/CacheDir/debug.py +++ b/test/CacheDir/debug.py @@ -52,10 +52,10 @@ SConscript('SConscript') test.write(['src', 'SConscript'], """\ def cat(env, source, target): target = str(target[0]) - open('cat.out', 'ab').write(target + "\\n") - f = open(target, "wb") + open('cat.out', 'a').write(target + "\\n") + f = open(target, "w") for src in source: - f.write(open(str(src), "rb").read()) + f.write(open(str(src), "r").read()) f.close() env = Environment(BUILDERS={'Cat':Builder(action=cat)}) env.Cat('aaa.out', 'aaa.in') -- cgit v0.12 From 886027ad490ea6ff9e8a4b5ecaa8396e24842211 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 10 Mar 2017 23:13:22 -0500 Subject: remove rb/wb from file opens, not needed py2/3 --- test/CacheDir/environment.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/CacheDir/environment.py b/test/CacheDir/environment.py index 1378bb2..eb28c19 100644 --- a/test/CacheDir/environment.py +++ b/test/CacheDir/environment.py @@ -53,10 +53,10 @@ SConscript('SConscript') test.write(['src', 'SConscript'], """\ def cat(env, source, target): target = str(target[0]) - open('cat.out', 'ab').write(target + "\\n") - f = open(target, "wb") + open('cat.out', 'a').write(target + "\\n") + f = open(target, "w") for src in source: - f.write(open(str(src), "rb").read()) + f.write(open(str(src), "r").read()) f.close() env_cache = Environment(BUILDERS={'Cat':Builder(action=cat)}) env_nocache = env_cache.Clone() -- cgit v0.12 From 32c43164f036af6e9f83eaf1826274fcf5332fba Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 10 Mar 2017 23:18:20 -0500 Subject: remove rb/wb from file opens, not needed py2/3 --- test/CacheDir/option--cd.py | 6 +++--- test/CacheDir/option--cf.py | 6 +++--- test/CacheDir/option--cr.py | 6 +++--- test/CacheDir/option--cs.py | 12 ++++++------ 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/test/CacheDir/option--cd.py b/test/CacheDir/option--cd.py index b77cfeb..efcf843 100644 --- a/test/CacheDir/option--cd.py +++ b/test/CacheDir/option--cd.py @@ -41,10 +41,10 @@ test.subdir('cache', 'src') test.write(['src', 'SConstruct'], """ def cat(env, source, target): target = str(target[0]) - open('cat.out', 'ab').write(target + "\\n") - f = open(target, "wb") + open('cat.out', 'a').write(target + "\\n") + f = open(target, "w") for src in source: - f.write(open(str(src), "rb").read()) + f.write(open(str(src), "r").read()) f.close() env = Environment(BUILDERS={'Cat':Builder(action=cat)}) env.Cat('aaa.out', 'aaa.in') diff --git a/test/CacheDir/option--cf.py b/test/CacheDir/option--cf.py index 6d64059..ace0df6 100644 --- a/test/CacheDir/option--cf.py +++ b/test/CacheDir/option--cf.py @@ -40,10 +40,10 @@ test.subdir('cache', 'src') test.write(['src', 'SConstruct'], """ def cat(env, source, target): target = str(target[0]) - open('cat.out', 'ab').write(target + "\\n") - f = open(target, "wb") + open('cat.out', 'a').write(target + "\\n") + f = open(target, "w") for src in source: - f.write(open(str(src), "rb").read()) + f.write(open(str(src), "r").read()) f.close() env = Environment(BUILDERS={'Cat':Builder(action=cat)}) env.Cat('aaa.out', 'aaa.in') diff --git a/test/CacheDir/option--cr.py b/test/CacheDir/option--cr.py index de6bbc8..165e049 100644 --- a/test/CacheDir/option--cr.py +++ b/test/CacheDir/option--cr.py @@ -41,10 +41,10 @@ test.subdir('cache', 'src') test.write(['src', 'SConstruct'], """ def cat(env, source, target): target = str(target[0]) - open('cat.out', 'ab').write(target + "\\n") - f = open(target, "wb") + open('cat.out', 'a').write(target + "\\n") + f = open(target, "w") for src in source: - f.write(open(str(src), "rb").read()) + f.write(open(str(src), "r").read()) f.close() env = Environment(BUILDERS={'Cat':Builder(action=cat)}) env.Cat('aaa.out', 'aaa.in') diff --git a/test/CacheDir/option--cs.py b/test/CacheDir/option--cs.py index 6d22814..bff585d 100644 --- a/test/CacheDir/option--cs.py +++ b/test/CacheDir/option--cs.py @@ -45,10 +45,10 @@ test.subdir('cache', 'src1', 'src2') test.write(['src1', 'build.py'], r""" import sys -open('cat.out', 'ab').write(sys.argv[1] + "\n") -file = open(sys.argv[1], 'wb') +open('cat.out', 'a').write(sys.argv[1] + "\n") +file = open(sys.argv[1], 'w') for src in sys.argv[2:]: - file.write(open(src, 'rb').read()) + file.write(open(src, 'r').read()) file.close() """) @@ -57,10 +57,10 @@ cache = test.workpath('cache') test.write(['src1', 'SConstruct'], """ def cat(env, source, target): target = str(target[0]) - open('cat.out', 'ab').write(target + "\\n") - f = open(target, "wb") + open('cat.out', 'a').write(target + "\\n") + f = open(target, "w") for src in source: - f.write(open(str(src), "rb").read()) + f.write(open(str(src), "r").read()) f.close() env = Environment(BUILDERS={'Internal':Builder(action=cat), 'External':Builder(action=r'%(_python_)s build.py $TARGET $SOURCES')}) -- cgit v0.12 From 1bb14fca2a72f0f97a0738a7819624edfa6756b3 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 10 Mar 2017 23:28:39 -0500 Subject: use whichdb from dbm for py3, and whichdb from whichdb for py2 --- src/script/sconsign.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/script/sconsign.py b/src/script/sconsign.py index 13fac98..239979f 100644 --- a/src/script/sconsign.py +++ b/src/script/sconsign.py @@ -186,10 +186,12 @@ sys.path = libs + sys.path import SCons.compat -import whichdb +try: + import whichdb + whichdb = whichdb.whichdb +except ImportError as e: + from dbm import whichdb -# was added for py3, but breaks py2 on windows.. -#import dbm import time import pickle import imp @@ -209,8 +211,8 @@ def my_whichdb(filename): # Should work on python2 -_orig_whichdb = whichdb.whichdb -whichdb.whichdb = my_whichdb +_orig_whichdb = whichdb +whichdb = my_whichdb # was changed for python3 #_orig_whichdb = whichdb.whichdb @@ -531,9 +533,7 @@ if Do_Call: Do_Call(a) else: for a in args: - # changed for py3 compat, broke py2 on windows - # dbm_name = dbm.whichdb(a) - dbm_name = whichdb.whichdb(a) + dbm_name = whichdb(a) if dbm_name: Map_Module = {'SCons.dblite' : 'dblite'} if dbm_name != "SCons.dblite": -- cgit v0.12 From 9b0ebfa042fb8b05515b80ec2d6b323f22883bca Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 10 Mar 2017 23:30:17 -0500 Subject: remove rb/wb from file opens, not needed py2/3 --- test/DVIPDF/DVIPDFFLAGS.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/DVIPDF/DVIPDFFLAGS.py b/test/DVIPDF/DVIPDFFLAGS.py index 4d03644..51a4c42 100644 --- a/test/DVIPDF/DVIPDFFLAGS.py +++ b/test/DVIPDF/DVIPDFFLAGS.py @@ -38,8 +38,8 @@ import sys import getopt cmd_opts, arg = getopt.getopt(sys.argv[1:], 'i:r:', []) base_name = os.path.splitext(arg[0])[0] -infile = open(arg[0], 'rb') -out_file = open(base_name+'.dvi', 'wb') +infile = open(arg[0], 'r') +out_file = open(base_name+'.dvi', 'w') for l in infile.readlines(): if l[:4] != '#tex': out_file.write(l) @@ -52,8 +52,8 @@ import sys import getopt cmd_opts, arg = getopt.getopt(sys.argv[1:], 'i:r:', []) base_name = os.path.splitext(arg[0])[0] -infile = open(arg[0], 'rb') -out_file = open(base_name+'.dvi', 'wb') +infile = open(arg[0], 'r') +out_file = open(base_name+'.dvi', 'w') for l in infile.readlines(): if l[:6] != '#latex': out_file.write(l) @@ -68,8 +68,8 @@ cmd_opts, args = getopt.getopt(sys.argv[1:], 'x', []) opt_string = '' for opt, arg in cmd_opts: opt_string = opt_string + ' ' + opt -infile = open(args[0], 'rb') -out_file = open(args[1], 'wb') +infile = open(args[0], 'r') +out_file = open(args[1], 'w') out_file.write(opt_string + "\n") for l in infile.readlines(): if l[:7] != '#dvipdf': -- cgit v0.12 From 18eb9a66c2f676a224f14dd8965ec064d09786fd Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 10 Mar 2017 23:32:42 -0500 Subject: remove rb/wb from file opens, not needed py2/3. Also remove unneeded test for having latex on test system --- test/DVIPS/DVIPSFLAGS.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/DVIPS/DVIPSFLAGS.py b/test/DVIPS/DVIPSFLAGS.py index 4ab1b53..d651ee0 100644 --- a/test/DVIPS/DVIPSFLAGS.py +++ b/test/DVIPS/DVIPSFLAGS.py @@ -38,8 +38,8 @@ import sys import getopt cmd_opts, arg = getopt.getopt(sys.argv[1:], 'i:r:', []) base_name = os.path.splitext(arg[0])[0] -infile = open(arg[0], 'rb') -out_file = open(base_name+'.dvi', 'wb') +infile = open(arg[0], 'r') +out_file = open(base_name+'.dvi', 'w') for l in infile.readlines(): if l[:4] != '#tex': out_file.write(l) @@ -52,8 +52,8 @@ import sys import getopt cmd_opts, arg = getopt.getopt(sys.argv[1:], 'i:r:', []) base_name = os.path.splitext(arg[0])[0] -infile = open(arg[0], 'rb') -out_file = open(base_name+'.dvi', 'wb') +infile = open(arg[0], 'r') +out_file = open(base_name+'.dvi', 'w') for l in infile.readlines(): if l[:6] != '#latex': out_file.write(l) @@ -69,8 +69,8 @@ opt_string = '' for opt, arg in cmd_opts: if opt == '-o': outfile = arg else: opt_string = opt_string + ' ' + opt -infile = open(args[0], 'rb') -out_file = open(outfile, 'wb') +infile = open(args[0], 'r') +out_file = open(outfile, 'w') out_file.write(opt_string + "\n") for l in infile.readlines(): if l[:6] != '#dvips': @@ -120,9 +120,9 @@ test.must_match('test3.ps', " -x\nThis is a .ltx test.\n") test.must_match('test4.ps', " -x\nThis is a .latex test.\n") -have_latex = test.where_is('latex') -if not have_latex: - test.skip_test('Could not find latex; skipping test(s).\n') +# have_latex = test.where_is('latex') +# if not have_latex: +# test.skip_test('Could not find latex; skipping test(s).\n') dvips = test.where_is('dvips') -- cgit v0.12 From 0bf5d6c1d813096e28e8975d9a1276ccbd75ff62 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 10 Mar 2017 23:35:34 -0500 Subject: remove rb/wb from file opens, not needed py2/3. Also remove unneeded test for having latex on test system --- test/DVIPS/DVIPSFLAGS.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/DVIPS/DVIPSFLAGS.py b/test/DVIPS/DVIPSFLAGS.py index d651ee0..7aedf24 100644 --- a/test/DVIPS/DVIPSFLAGS.py +++ b/test/DVIPS/DVIPSFLAGS.py @@ -120,10 +120,6 @@ test.must_match('test3.ps', " -x\nThis is a .ltx test.\n") test.must_match('test4.ps', " -x\nThis is a .latex test.\n") -# have_latex = test.where_is('latex') -# if not have_latex: -# test.skip_test('Could not find latex; skipping test(s).\n') - dvips = test.where_is('dvips') -- cgit v0.12 From 4e9cc49ad30d0055856868ae9b1c8a6047ca1ca8 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 10 Mar 2017 23:42:12 -0500 Subject: remove rb/wb from file opens, not needed py2/3. --- test/Requires/eval-order.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Requires/eval-order.py b/test/Requires/eval-order.py index 51539a2..8600221 100644 --- a/test/Requires/eval-order.py +++ b/test/Requires/eval-order.py @@ -34,11 +34,11 @@ test = TestSCons.TestSCons() test.write('SConstruct', """ def copy_and_create_func(target, source, env): - fp = open(str(target[0]), 'wb') + fp = open(str(target[0]), 'w') for s in source: - fp.write(open(str(s), 'rb').read()) + fp.write(open(str(s), 'r').read()) fp.close() - open('file.in', 'wb').write("file.in 1\\n") + open('file.in', 'w').write("file.in 1\\n") return None copy_and_create = Action(copy_and_create_func) env = Environment() -- cgit v0.12 From a4e39240a8ce9bcedbf7fb2e34675ec170591bc7 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 10 Mar 2017 23:42:54 -0500 Subject: remove rb/wb from file opens, not needed py2/3. --- test/Rpcgen/RPCGEN.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Rpcgen/RPCGEN.py b/test/Rpcgen/RPCGEN.py index dd3669b..f79e18e 100644 --- a/test/Rpcgen/RPCGEN.py +++ b/test/Rpcgen/RPCGEN.py @@ -38,10 +38,10 @@ import getopt import sys cmd_opts, args = getopt.getopt(sys.argv[1:], 'chlmo:', []) for opt, arg in cmd_opts: - if opt == '-o': output = open(arg, 'wb') + if opt == '-o': output = open(arg, 'w') output.write(" ".join(sys.argv) + "\\n") for a in args: - contents = open(a, 'rb').read() + contents = open(a, 'r').read() output.write(contents.replace('RPCGEN', 'myrpcgen.py')) output.close() sys.exit(0) -- cgit v0.12 From 85f03de79b672d577294ad6c567033f7bbeb6d1d Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 10 Mar 2017 23:43:46 -0500 Subject: remove rb/wb from file opens, not needed py2/3. --- test/Rpcgen/RPCGENCLIENTFLAGS.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Rpcgen/RPCGENCLIENTFLAGS.py b/test/Rpcgen/RPCGENCLIENTFLAGS.py index 7cf0144..9440d57 100644 --- a/test/Rpcgen/RPCGENCLIENTFLAGS.py +++ b/test/Rpcgen/RPCGENCLIENTFLAGS.py @@ -38,10 +38,10 @@ import getopt import sys cmd_opts, args = getopt.getopt(sys.argv[1:], 'chlmo:x', []) for opt, arg in cmd_opts: - if opt == '-o': output = open(arg, 'wb') + if opt == '-o': output = open(arg, 'w') output.write(" ".join(sys.argv) + "\\n") for a in args: - contents = open(a, 'rb').read() + contents = open(a, 'r').read() output.write(contents.replace('RPCGEN', 'myrpcgen.py')) output.close() sys.exit(0) -- cgit v0.12 From a9c931733f6d310279f541706ca3ce6306b23f29 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 10 Mar 2017 23:44:15 -0500 Subject: remove rb/wb from file opens, not needed py2/3. --- test/Rpcgen/RPCGENFLAGS.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Rpcgen/RPCGENFLAGS.py b/test/Rpcgen/RPCGENFLAGS.py index 4af5da8..b94ffe5 100644 --- a/test/Rpcgen/RPCGENFLAGS.py +++ b/test/Rpcgen/RPCGENFLAGS.py @@ -38,10 +38,10 @@ import getopt import sys cmd_opts, args = getopt.getopt(sys.argv[1:], 'chlmo:x', []) for opt, arg in cmd_opts: - if opt == '-o': output = open(arg, 'wb') + if opt == '-o': output = open(arg, 'w') output.write(" ".join(sys.argv) + "\\n") for a in args: - contents = open(a, 'rb').read() + contents = open(a, 'r').read() output.write(contents.replace('RPCGEN', 'myrpcgen.py')) output.close() sys.exit(0) -- cgit v0.12 From a8fd7512f750ee9023750217787566d25038925e Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 10 Mar 2017 23:44:50 -0500 Subject: remove rb/wb from file opens, not needed py2/3. --- test/Rpcgen/RPCGENHEADERFLAGS.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Rpcgen/RPCGENHEADERFLAGS.py b/test/Rpcgen/RPCGENHEADERFLAGS.py index 0c93fe7..f65da8e 100644 --- a/test/Rpcgen/RPCGENHEADERFLAGS.py +++ b/test/Rpcgen/RPCGENHEADERFLAGS.py @@ -38,10 +38,10 @@ import getopt import sys cmd_opts, args = getopt.getopt(sys.argv[1:], 'chlmo:x', []) for opt, arg in cmd_opts: - if opt == '-o': output = open(arg, 'wb') + if opt == '-o': output = open(arg, 'w') output.write(" ".join(sys.argv) + "\\n") for a in args: - contents = open(a, 'rb').read() + contents = open(a, 'r').read() output.write(contents.replace('RPCGEN', 'myrpcgen.py')) output.close() sys.exit(0) -- cgit v0.12 From 5422f3bcc3e369272f06a8cfb8a9b29f048da790 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 10 Mar 2017 23:45:49 -0500 Subject: remove rb/wb from file opens, not needed py2/3. --- test/Rpcgen/RPCGENSERVICEFLAGS.py | 4 ++-- test/Rpcgen/RPCGENXDRFLAGS.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/Rpcgen/RPCGENSERVICEFLAGS.py b/test/Rpcgen/RPCGENSERVICEFLAGS.py index 9b8962f..a956d4f 100644 --- a/test/Rpcgen/RPCGENSERVICEFLAGS.py +++ b/test/Rpcgen/RPCGENSERVICEFLAGS.py @@ -38,10 +38,10 @@ import getopt import sys cmd_opts, args = getopt.getopt(sys.argv[1:], 'chlmo:x', []) for opt, arg in cmd_opts: - if opt == '-o': output = open(arg, 'wb') + if opt == '-o': output = open(arg, 'w') output.write(" ".join(sys.argv) + "\\n") for a in args: - contents = open(a, 'rb').read() + contents = open(a, 'r').read() output.write(contents.replace('RPCGEN', 'myrpcgen.py')) output.close() sys.exit(0) diff --git a/test/Rpcgen/RPCGENXDRFLAGS.py b/test/Rpcgen/RPCGENXDRFLAGS.py index 8f90d5a..0dc1366 100644 --- a/test/Rpcgen/RPCGENXDRFLAGS.py +++ b/test/Rpcgen/RPCGENXDRFLAGS.py @@ -38,10 +38,10 @@ import getopt import sys cmd_opts, args = getopt.getopt(sys.argv[1:], 'chlmo:x', []) for opt, arg in cmd_opts: - if opt == '-o': output = open(arg, 'wb') + if opt == '-o': output = open(arg, 'w') output.write(" ".join(sys.argv) + "\\n") for a in args: - contents = open(a, 'rb').read() + contents = open(a, 'r').read() output.write(contents.replace('RPCGEN', 'myrpcgen.py')) output.close() sys.exit(0) -- cgit v0.12 From 806a46d96ce3eba5547371c3acc851d480a4c9a2 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 10 Mar 2017 23:48:25 -0500 Subject: Fix except syntax, replacing comma with as --- test/Subst/AllowSubstExceptions.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/Subst/AllowSubstExceptions.py b/test/Subst/AllowSubstExceptions.py index 7f2a9aa..0332e68 100644 --- a/test/Subst/AllowSubstExceptions.py +++ b/test/Subst/AllowSubstExceptions.py @@ -52,37 +52,37 @@ assert env.subst_list('${INDEX[999]}') == [[]] AllowSubstExceptions() try: env.subst('$NAME') -except SCons.Errors.UserError, e: print(e) +except SCons.Errors.UserError as e: print(e) else: raise Exception("did not catch expected SCons.Errors.UserError") try: env.subst('${NAME}') -except SCons.Errors.UserError, e: print(e) +except SCons.Errors.UserError as e: print(e) else: raise Exception("did not catch expected SCons.Errors.UserError") try: env.subst('${INDEX[999]}') -except SCons.Errors.UserError, e: print(e) +except SCons.Errors.UserError as e: print(e) else: raise Exception("did not catch expected SCons.Errors.UserError") try: env.subst_list('$NAME') -except SCons.Errors.UserError, e: print(e) +except SCons.Errors.UserError as e: print(e) else: raise Exception("did not catch expected SCons.Errors.UserError") try: env.subst_list('${NAME}') -except SCons.Errors.UserError, e: print(e) +except SCons.Errors.UserError as e: print(e) else: raise Exception("did not catch expected SCons.Errors.UserError") try: env.subst_list('${INDEX[999]}') -except SCons.Errors.UserError, e: print(e) +except SCons.Errors.UserError as e: print(e) else: raise Exception("did not catch expected SCons.Errors.UserError") try: env.subst('${1/0}') -except SCons.Errors.UserError, e: print(e) +except SCons.Errors.UserError as e: print(e) else: raise Exception("did not catch expected SCons.Errors.UserError") try: env.subst_list('${1/0}') -except SCons.Errors.UserError, e: print(e) +except SCons.Errors.UserError as e: print(e) else: raise Exception("did not catch expected SCons.Errors.UserError") AllowSubstExceptions(ZeroDivisionError) -- cgit v0.12 From 01b45568cb32ef365d71d47ace917b201ca98c92 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 10 Mar 2017 23:51:47 -0500 Subject: init DefaultEnvironment with no tools to speed up py2/3 --- test/Interactive/taskmastertrace.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Interactive/taskmastertrace.py b/test/Interactive/taskmastertrace.py index 48089e3..93ee068 100644 --- a/test/Interactive/taskmastertrace.py +++ b/test/Interactive/taskmastertrace.py @@ -33,6 +33,7 @@ import TestSCons test = TestSCons.TestSCons() test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) Command('foo.out', 'foo.in', Copy('$TARGET', '$SOURCE')) Command('1', [], Touch('$TARGET')) Command('2', [], Touch('$TARGET')) -- cgit v0.12 From e1aa8d2b2d64eb147cedc24016c38f209d9d397f Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Sat, 11 Mar 2017 03:51:29 -0800 Subject: Remove 'U' flag to open() which is deprecated. --- QMTest/TestSCons_time.py | 2 +- bench/bench.py | 2 +- bin/update-release-info.py | 2 +- src/engine/SCons/Variables/VariablesTests.py | 2 +- src/engine/SCons/Variables/__init__.py | 2 +- src/script/scons-time.py | 6 +++--- test/Deprecated/Options/Options.py | 2 +- test/Deprecated/Options/chdir.py | 2 +- test/SConscript/SConscriptChdir.py | 10 +++++----- test/Variables/Variables.py | 2 +- test/Variables/chdir.py | 2 +- 11 files changed, 17 insertions(+), 17 deletions(-) diff --git a/QMTest/TestSCons_time.py b/QMTest/TestSCons_time.py index a9212f7..bc116ec 100644 --- a/QMTest/TestSCons_time.py +++ b/QMTest/TestSCons_time.py @@ -49,7 +49,7 @@ for arg in sys.argv[1:]: write_args(profile, sys.argv) break sys.stdout.write('SCONS_LIB_DIR = ' + os.environ['SCONS_LIB_DIR'] + '\\n') -exec(open('SConstruct', 'rU').read()) +exec(open('SConstruct', 'r').read()) """ aegis_py = """\ diff --git a/bench/bench.py b/bench/bench.py index cfdac2d..3f7dbc6 100644 --- a/bench/bench.py +++ b/bench/bench.py @@ -88,7 +88,7 @@ if len(args) != 1: sys.exit(1) -exec(open(args[0], 'rU').read()) +exec(open(args[0], 'r').read()) try: diff --git a/bin/update-release-info.py b/bin/update-release-info.py index 49f2788..81e0df5 100644 --- a/bin/update-release-info.py +++ b/bin/update-release-info.py @@ -152,7 +152,7 @@ class UpdateFile(object): ''' if orig is None: orig = file try: - self.content = open(orig, 'rU').read() + self.content = open(orig, 'r').read() except IOError: # Couldn't open file; don't try to write anything in __del__ self.file = None diff --git a/src/engine/SCons/Variables/VariablesTests.py b/src/engine/SCons/Variables/VariablesTests.py index 69f1e01..7ee66ca 100644 --- a/src/engine/SCons/Variables/VariablesTests.py +++ b/src/engine/SCons/Variables/VariablesTests.py @@ -65,7 +65,7 @@ def check(key, value, env): def checkSave(file, expected): gdict = {} ldict = {} - exec(open(file, 'rU').read(), gdict, ldict) + exec(open(file, 'r').read(), gdict, ldict) assert expected == ldict, "%s\n...not equal to...\n%s" % (expected, ldict) class VariablesTestCase(unittest.TestCase): diff --git a/src/engine/SCons/Variables/__init__.py b/src/engine/SCons/Variables/__init__.py index ce3541c..54b97a4 100644 --- a/src/engine/SCons/Variables/__init__.py +++ b/src/engine/SCons/Variables/__init__.py @@ -175,7 +175,7 @@ class Variables(object): sys.path.insert(0, dir) try: values['__name__'] = filename - exec(open(filename, 'rU').read(), {}, values) + exec(open(filename, 'r').read(), {}, values) finally: if dir: del sys.path[0] diff --git a/src/script/scons-time.py b/src/script/scons-time.py index c788e50..f12280c 100644 --- a/src/script/scons-time.py +++ b/src/script/scons-time.py @@ -814,7 +814,7 @@ class SConsTimer(object): self.title = a if self.config_file: - exec(open(self.config_file, 'rU').read(), self.__dict__) + exec(open(self.config_file, 'r').read(), self.__dict__) if self.chdir: os.chdir(self.chdir) @@ -933,7 +933,7 @@ class SConsTimer(object): self.title = a if self.config_file: - HACK_for_exec(open(self.config_file, 'rU').read(), self.__dict__) + HACK_for_exec(open(self.config_file, 'r').read(), self.__dict__) if self.chdir: os.chdir(self.chdir) @@ -1053,7 +1053,7 @@ class SConsTimer(object): object_name = args.pop(0) if self.config_file: - HACK_for_exec(open(self.config_file, 'rU').read(), self.__dict__) + HACK_for_exec(open(self.config_file, 'r').read(), self.__dict__) if self.chdir: os.chdir(self.chdir) diff --git a/test/Deprecated/Options/Options.py b/test/Deprecated/Options/Options.py index e435b9e..6c021f0 100644 --- a/test/Deprecated/Options/Options.py +++ b/test/Deprecated/Options/Options.py @@ -237,7 +237,7 @@ opts.Save('options.saved', env) def checkSave(file, expected): gdict = {} ldict = {} - exec(open(file, 'rU').read(), gdict, ldict) + exec(open(file, 'r').read(), gdict, ldict) assert expected == ldict, "%s\n...not equal to...\n%s" % (expected, ldict) # First test with no command line options diff --git a/test/Deprecated/Options/chdir.py b/test/Deprecated/Options/chdir.py index 977a351..ed0aab1 100644 --- a/test/Deprecated/Options/chdir.py +++ b/test/Deprecated/Options/chdir.py @@ -52,7 +52,7 @@ print("VARIABLE =", repr(env['VARIABLE'])) test.write(['bin', 'opts.cfg'], """\ import os os.chdir(os.path.split(__name__)[0]) -exec(open('opts2.cfg', 'rU').read()) +exec(open('opts2.cfg', 'r').read()) """) test.write(['bin', 'opts2.cfg'], """\ diff --git a/test/SConscript/SConscriptChdir.py b/test/SConscript/SConscriptChdir.py index 4c55844..211d55b 100644 --- a/test/SConscript/SConscriptChdir.py +++ b/test/SConscript/SConscriptChdir.py @@ -44,27 +44,27 @@ SConscript('dir5/SConscript') """) test.write(['dir1', 'SConscript'], """ -exec(open("create_test.py", 'rU').read()) +exec(open("create_test.py", 'r').read()) """) test.write(['dir2', 'SConscript'], """ -exec(open("create_test.py", 'rU').read()) +exec(open("create_test.py", 'r').read()) """) test.write(['dir3', 'SConscript'], """ import os.path name = os.path.join('dir3', 'create_test.py') -exec(open(name, 'rU').read()) +exec(open(name, 'r').read()) """) test.write(['dir4', 'SConscript'], """ -exec(open("create_test.py", 'rU').read()) +exec(open("create_test.py", 'r').read()) """) test.write(['dir5', 'SConscript'], """ import os.path name = os.path.join('dir5', 'create_test.py') -exec(open(name, 'rU').read()) +exec(open(name, 'r').read()) """) for dir in ['dir1', 'dir2', 'dir3','dir4', 'dir5']: diff --git a/test/Variables/Variables.py b/test/Variables/Variables.py index 1c60635..d08594d 100644 --- a/test/Variables/Variables.py +++ b/test/Variables/Variables.py @@ -231,7 +231,7 @@ opts.Save('variables.saved', env) def checkSave(file, expected): gdict = {} ldict = {} - exec(open(file, 'rU').read(), gdict, ldict) + exec(open(file, 'r').read(), gdict, ldict) assert expected == ldict, "%s\n...not equal to...\n%s" % (expected, ldict) # First test with no command line variables diff --git a/test/Variables/chdir.py b/test/Variables/chdir.py index 2d097d5..0e9abaa 100644 --- a/test/Variables/chdir.py +++ b/test/Variables/chdir.py @@ -52,7 +52,7 @@ print("VARIABLE =", repr(env['VARIABLE'])) test.write(['bin', 'opts.cfg'], """\ import os os.chdir(os.path.split(__name__)[0]) -exec(open('opts2.cfg', 'rU').read()) +exec(open('opts2.cfg', 'r').read()) """) test.write(['bin', 'opts2.cfg'], """\ -- cgit v0.12 From c14936494d79a00b533e7e8ce9a41e5176c1295f Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Sat, 11 Mar 2017 04:09:11 -0800 Subject: Use print() function. Fixes py2/3 --- QMTest/TestCommonTests.py | 13 ++++++++----- src/engine/SCons/Util.py | 4 ++-- test/Configure/custom-tests.py | 4 +++- test/ENV.py | 5 +++-- test/Interactive/shell.py | 4 +++- test/SConscript/Return.py | 32 ++++++++++++++++---------------- test/SConscript/SConscript.py | 4 ++-- test/SWIG/live.py | 8 +++++--- test/TEMPFILEPREFIX.py | 3 ++- test/builderrors.py | 3 ++- 10 files changed, 46 insertions(+), 34 deletions(-) diff --git a/QMTest/TestCommonTests.py b/QMTest/TestCommonTests.py index 30b7d6a..7949cb8 100644 --- a/QMTest/TestCommonTests.py +++ b/QMTest/TestCommonTests.py @@ -168,10 +168,11 @@ class __init__TestCase(TestCommonTestCase): os.chdir(run_env.workdir) script = lstrip("""\ + from __future__ import print_function from TestCommon import TestCommon tc = TestCommon(workdir='') import os - print os.getcwd() + print(os.getcwd()) """) run_env.run(program=sys.executable, stdin=script) stdout = run_env.stdout()[:-1] @@ -2285,14 +2286,16 @@ class variables_TestCase(TestCommonTestCase): 'dll_suffix', ] - script = "import TestCommon\n" + \ - '\n'.join([ "print TestCommon.%s\n" % v for v in variables ]) + script = "from __future__ import print_function" + \ + "import TestCommon\n" + \ + '\n'.join([ "print(TestCommon.%s)\n" % v for v in variables ]) run_env.run(program=sys.executable, stdin=script) stderr = run_env.stderr() assert stderr == "", stderr - script = "from TestCommon import *\n" + \ - '\n'.join([ "print %s" % v for v in variables ]) + script = "from __future__ import print_function" + \ + "from TestCommon import *\n" + \ + '\n'.join([ "print(%s)" % v for v in variables ]) run_env.run(program=sys.executable, stdin=script) stderr = run_env.stderr() assert stderr == "", stderr diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index d6f18cc..018a776 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -1453,9 +1453,9 @@ def AddMethod(obj, function, name=None): self.z = x + y AddMethod(f, A, "add") a.add(2, 4) - print a.z + print(a.z) AddMethod(lambda self, i: self.l[i], a, "listIndex") - print a.listIndex(5) + print(a.listIndex(5)) """ if name is None: name = function.__name__ diff --git a/test/Configure/custom-tests.py b/test/Configure/custom-tests.py index 503eb4e..7bb2366 100644 --- a/test/Configure/custom-tests.py +++ b/test/Configure/custom-tests.py @@ -49,8 +49,10 @@ runOK = compileOK runFAIL = "int main() { return 1; }" test.write('pyAct.py', """\ +from __future__ import print_function + import sys -print sys.argv[1] +print(sys.argv[1]) sys.exit(int(sys.argv[1])) """) diff --git a/test/ENV.py b/test/ENV.py index dc97ec8..5cb2362 100644 --- a/test/ENV.py +++ b/test/ENV.py @@ -71,9 +71,10 @@ env['ENV']['FOO'] = foo test.write('build.py', r""" +from __future__ import print_function import os -print 'LIST:', os.environ['LIST'] -print 'FOO:', os.environ['FOO'] +print('LIST:', os.environ['LIST']) +print('FOO:', os.environ['FOO']) """) test.run() diff --git a/test/Interactive/shell.py b/test/Interactive/shell.py index 842a12e..40df86f 100644 --- a/test/Interactive/shell.py +++ b/test/Interactive/shell.py @@ -40,7 +40,9 @@ shell_command_py = test.workpath('shell_command.py') _shell_command_py_ = '"%s"' % shell_command_py.replace('\\', '\\\\') test.write(shell_command_py, """\ -print 'hello from shell_command.py' +from __future__ import print_function + +print('hello from shell_command.py') """) test.write('SConstruct', """\ diff --git a/test/SConscript/Return.py b/test/SConscript/Return.py index 997de9d..1f678af 100644 --- a/test/SConscript/Return.py +++ b/test/SConscript/Return.py @@ -39,50 +39,50 @@ x = SConscript('SConscript2') y, z = SConscript('SConscript3') a4, b4 = SConscript('SConscript4') foo, bar = SConscript('SConscript5') -print ("x =", x) -print ("y =", y) -print ("z =", z) -print ("a4 =", a4) -print ("b4 =", b4) -print ("foo =", foo) -print ("bar =", bar) +print("x =", x) +print("y =", y) +print("z =", z) +print("a4 =", a4) +print("b4 =", b4) +print("foo =", foo) +print("bar =", bar) """) test.write('SConscript1', """\ -print ("line 1") +print("line 1") Return() -print ("line 2") +print("line 2") """) test.write('SConscript2', """\ -print ("line 3") +print("line 3") x = 7 Return('x') -print ("line 4") +print("line 4") """) test.write('SConscript3', """\ -print ("line 5") +print("line 5") y = 8 z = 9 Return('y z') -print ("line 6") +print("line 6") """) test.write('SConscript4', """\ a4 = 'aaa' b4 = 'bbb' -print ("line 7") +print("line 7") Return('a4', 'b4', stop=False) b4 = 'b-after' -print ("line 8") +print("line 8") """) test.write('SConscript5', """\ foo = 'foo' bar = 'bar' Return(["foo", "bar"]) -print ("line 9") +print("line 9") """) expect = """\ diff --git a/test/SConscript/SConscript.py b/test/SConscript/SConscript.py index d1e09ce..2eeb211 100644 --- a/test/SConscript/SConscript.py +++ b/test/SConscript/SConscript.py @@ -37,7 +37,7 @@ import foo assert foo.foo == 4 -print ("SConstruct", os.getcwd()) +print("SConstruct", os.getcwd()) SConscript('SConscript') x1 = "SConstruct x1" @@ -89,7 +89,7 @@ test.write('SConscript', """\ assert "os" not in globals() import os -print ("SConscript " + os.getcwd()) +print("SConscript " + os.getcwd()) """) test.write('SConscript1', """ diff --git a/test/SWIG/live.py b/test/SWIG/live.py index 5e95dc7..05971aa 100644 --- a/test/SWIG/live.py +++ b/test/SWIG/live.py @@ -131,8 +131,9 @@ test.run(arguments = ldmodule_prefix+'foo' + _dll) test.must_not_exist(test.workpath('wrapper.out')) test.run(program = python, stdin = """\ +from __future__ import print_function import foo -print foo.foo_string() +print(foo.foo_string()) """, stdout="""\ This is foo.c! """) @@ -144,10 +145,11 @@ test.run(arguments = ldmodule_prefix+'bar' + _dll) test.must_match('wrapper.out', "wrapper.py\n") test.run(program = python, stdin = """\ +from __future__ import print_function import foo import bar -print foo.foo_string() -print bar.bar_string() +print(foo.foo_string()) +print(bar.bar_string()) """, stdout="""\ This is foo.c! This is bar.c! diff --git a/test/TEMPFILEPREFIX.py b/test/TEMPFILEPREFIX.py index 8e756af..f0743e6 100644 --- a/test/TEMPFILEPREFIX.py +++ b/test/TEMPFILEPREFIX.py @@ -38,8 +38,9 @@ test = TestSCons.TestSCons(match = TestSCons.match_re) test.write('echo.py', """\ #!/usr/bin/env python +from __future__ import print_function import sys -print sys.argv +print(sys.argv) """) echo_py = test.workpath('echo.py') diff --git a/test/builderrors.py b/test/builderrors.py index 3d443bf..88015f1 100644 --- a/test/builderrors.py +++ b/test/builderrors.py @@ -171,6 +171,7 @@ test.must_not_contain_any_line(test.stderr(), ['Exception', 'Traceback']) # Should not give traceback; the task error should get converted # to a BuildError. test.write('SConstruct', """ +from __future__ import print_function import atexit env = Environment() @@ -182,7 +183,7 @@ env2.Install("target", "dir2/myFile") def print_build_failures(): from SCons.Script import GetBuildFailures for bf in GetBuildFailures(): - print bf.action + print(bf.action) atexit.register(print_build_failures) """) -- cgit v0.12 From 5c8b6da1dbbe718939c70dc926cb160f758ed9f7 Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Sat, 11 Mar 2017 04:10:59 -0800 Subject: Remove 'U' flag to open() which is deprecated. --- src/script/scons-time.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/script/scons-time.py b/src/script/scons-time.py index f12280c..b4db35f 100644 --- a/src/script/scons-time.py +++ b/src/script/scons-time.py @@ -1191,7 +1191,7 @@ class SConsTimer(object): sys.exit(1) if self.config_file: - exec(open(self.config_file, 'rU').read(), self.__dict__) + exec(open(self.config_file, 'r').read(), self.__dict__) if args: self.archive_list = args @@ -1431,7 +1431,7 @@ class SConsTimer(object): which = a if self.config_file: - HACK_for_exec(open(self.config_file, 'rU').read(), self.__dict__) + HACK_for_exec(open(self.config_file, 'r').read(), self.__dict__) if self.chdir: os.chdir(self.chdir) -- cgit v0.12 From 29a14c8408a30393ae4f03e361d27770f7619d3f Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Sat, 11 Mar 2017 04:13:51 -0800 Subject: Use print() function --- bench/env.__setitem__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bench/env.__setitem__.py b/bench/env.__setitem__.py index 9c27b6d..510dcc7 100644 --- a/bench/env.__setitem__.py +++ b/bench/env.__setitem__.py @@ -4,6 +4,8 @@ # env.__setitem__() method(s) in the src/engine/SCons/Environment.py # module. +from __future__ import print_function + import os.path import re import sys -- cgit v0.12 From 92c24f24619954e214cca853ae12cde2f5159bcb Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Sat, 11 Mar 2017 04:21:26 -0800 Subject: Use print() function. Fixes py2/3. --- src/script/scons-configure-cache.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/script/scons-configure-cache.py b/src/script/scons-configure-cache.py index 2648acd..369f817 100644 --- a/src/script/scons-configure-cache.py +++ b/src/script/scons-configure-cache.py @@ -23,6 +23,8 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +from __future__ import print_function + __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" __version__ = "__VERSION__" @@ -41,14 +43,14 @@ import json import os def rearrange_cache_entries(current_prefix_len, new_prefix_len): - print 'Changing prefix length from', current_prefix_len, 'to', new_prefix_len + print('Changing prefix length from', current_prefix_len, 'to', new_prefix_len) dirs = set() old_dirs = set() for file in glob.iglob(os.path.join('*', '*')): name = os.path.basename(file) dir = name[:current_prefix_len].upper() if dir not in old_dirs: - print 'Migrating', dir + print('Migrating', dir) old_dirs.add(dir) dir = name[:new_prefix_len].upper() if dir not in dirs: @@ -136,4 +138,4 @@ for key in args: # and write the updated config file with open('config', 'w') as conf: - json.dump(config, conf) \ No newline at end of file + json.dump(config, conf) -- cgit v0.12 From 80aba339e2acac074840aedd0ceb8553ed77d127 Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Sat, 11 Mar 2017 04:21:48 -0800 Subject: Remove 'b' from open, not needed py2/3 --- test/option--.py | 2 +- test/option--Q.py | 2 +- test/option-i.py | 2 +- test/option-j.py | 2 +- test/option-k.py | 2 +- test/option-n.py | 2 +- test/option-s.py | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/option--.py b/test/option--.py index 3c932c0..8e06260 100644 --- a/test/option--.py +++ b/test/option--.py @@ -34,7 +34,7 @@ test = TestSCons.TestSCons() test.write('build.py', r""" import sys -file = open(sys.argv[1], 'wb') +file = open(sys.argv[1], 'w') file.write("build.py: %s\n" % sys.argv[1]) file.close() """) diff --git a/test/option--Q.py b/test/option--Q.py index 4322bcd..da6d2e1 100644 --- a/test/option--Q.py +++ b/test/option--Q.py @@ -34,7 +34,7 @@ test = TestSCons.TestSCons() test.write('build.py', r""" import sys -file = open(sys.argv[1], 'wb') +file = open(sys.argv[1], 'w') file.write("build.py: %s\n" % sys.argv[1]) file.close() """) diff --git a/test/option-i.py b/test/option-i.py index b32bd9c..3301bf5 100644 --- a/test/option-i.py +++ b/test/option-i.py @@ -34,7 +34,7 @@ test = TestSCons.TestSCons() test.write('succeed.py', r""" import sys -file = open(sys.argv[1], 'wb') +file = open(sys.argv[1], 'w') file.write("succeed.py: %s\n" % sys.argv[1]) file.close() sys.exit(0) diff --git a/test/option-j.py b/test/option-j.py index 69ef414..acd97f8 100644 --- a/test/option-j.py +++ b/test/option-j.py @@ -51,7 +51,7 @@ test = TestSCons.TestSCons() test.write('build.py', r""" import time import sys -file = open(sys.argv[1], 'wb') +file = open(sys.argv[1], 'w') file.write(str(time.time()) + '\n') time.sleep(1) file.write(str(time.time())) diff --git a/test/option-k.py b/test/option-k.py index a367c65..5cd9be9 100644 --- a/test/option-k.py +++ b/test/option-k.py @@ -38,7 +38,7 @@ test.subdir('work1', 'work2', 'work3') test.write('succeed.py', r""" import sys -file = open(sys.argv[1], 'wb') +file = open(sys.argv[1], 'w') file.write("succeed.py: %s\n" % sys.argv[1]) file.close() sys.exit(0) diff --git a/test/option-n.py b/test/option-n.py index a32dfb7..0fd7bfe 100644 --- a/test/option-n.py +++ b/test/option-n.py @@ -52,7 +52,7 @@ test.subdir('build', 'src') test.write('build.py', r""" import sys -file = open(sys.argv[1], 'wb') +file = open(sys.argv[1], 'w') file.write("build.py: %s\n" % sys.argv[1]) file.close() """) diff --git a/test/option-s.py b/test/option-s.py index f79c347..bbde2d1 100644 --- a/test/option-s.py +++ b/test/option-s.py @@ -34,7 +34,7 @@ test = TestSCons.TestSCons() test.write('build.py', r""" import sys -file = open(sys.argv[1], 'wb') +file = open(sys.argv[1], 'w') file.write("build.py: %s\n" % sys.argv[1]) file.close() """) -- cgit v0.12 From 9a379c58daf528d1875bb0e902651162bc4f7bc6 Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Sat, 11 Mar 2017 12:19:23 -0800 Subject: exec() must take a string, not a file object. Fixes py2/3 --- src/engine/SCons/Script/SConscript.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py index a7c8a37..4e63f6c 100644 --- a/src/engine/SCons/Script/SConscript.py +++ b/src/engine/SCons/Script/SConscript.py @@ -165,7 +165,7 @@ def _SConscript(fs, *files, **kw): try: SCons.Script.sconscript_reading = SCons.Script.sconscript_reading + 1 if fn == "-": - exec(sys.stdin, call_stack[-1].globals) + exec(sys.stdin.read(), call_stack[-1].globals) else: if isinstance(fn, SCons.Node.Node): f = fn -- cgit v0.12 From b1d250a09a7a1d38b596f9672d0084c364788b68 Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Sat, 11 Mar 2017 12:29:29 -0800 Subject: Use proper syntax for octal numeric literal. Fixes py2/3 --- test/implicit/IMPLICIT_COMMAND_DEPENDENCIES.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/implicit/IMPLICIT_COMMAND_DEPENDENCIES.py b/test/implicit/IMPLICIT_COMMAND_DEPENDENCIES.py index 3365688..bb3a5db 100644 --- a/test/implicit/IMPLICIT_COMMAND_DEPENDENCIES.py +++ b/test/implicit/IMPLICIT_COMMAND_DEPENDENCIES.py @@ -53,7 +53,7 @@ for infile in sys.argv[2:]: fp.write(open(infile, 'rb').read()) fp.close() ''') -os.chmod(sys.argv[1], 0755) +os.chmod(sys.argv[1], 0o755) """ -- cgit v0.12 From 4da977010029bbe4d94e5c6ad8db10f62cab6276 Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Sat, 11 Mar 2017 13:03:23 -0800 Subject: Replace list(filter()) with list comprehension. --- QMTest/TestCommon.py | 2 +- src/engine/SCons/Action.py | 2 +- src/engine/SCons/Scanner/Dir.py | 2 +- src/engine/SCons/Script/Interactive.py | 2 +- src/engine/SCons/Script/Main.py | 2 +- src/engine/SCons/Tool/dvipdf.py | 2 +- src/engine/SCons/Tool/packaging/__init__.py | 4 ++-- src/test_aegistests.py | 2 +- test/Java/Java-1.4.py | 2 +- test/Java/Java-1.5.py | 2 +- test/Java/Java-1.6.py | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/QMTest/TestCommon.py b/QMTest/TestCommon.py index cd9e990..c1adc37 100644 --- a/QMTest/TestCommon.py +++ b/QMTest/TestCommon.py @@ -582,7 +582,7 @@ class TestCommon(TestCmd): """ files = [is_List(x) and os.path.join(*x) or x for x in files] existing, missing = separate_files(files) - writable = list(filter(is_writable, existing)) + writable = [file for file in existing if is_writable(file)] if missing: print("Missing files: `%s'" % "', `".join(missing)) if writable: diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index eb215fd..be70293 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -778,7 +778,7 @@ class CommandAction(_ActionAction): _ActionAction.__init__(self, **kw) if is_List(cmd): - if list(filter(is_List, cmd)): + if [c for c in cmd if is_List(c)]: raise TypeError("CommandAction should be given only " \ "a single command") self.cmd_list = cmd diff --git a/src/engine/SCons/Scanner/Dir.py b/src/engine/SCons/Scanner/Dir.py index cbfb6fb..3b33fe5 100644 --- a/src/engine/SCons/Scanner/Dir.py +++ b/src/engine/SCons/Scanner/Dir.py @@ -27,7 +27,7 @@ import SCons.Scanner def only_dirs(nodes): is_Dir = lambda n: isinstance(n.disambiguate(), SCons.Node.FS.Dir) - return list(filter(is_Dir, nodes)) + return [node for node in nodes if is_Dir(node)] def DirScanner(**kw): """Return a prototype Scanner instance for scanning diff --git a/src/engine/SCons/Script/Interactive.py b/src/engine/SCons/Script/Interactive.py index 3c3d23a..cf6e247 100644 --- a/src/engine/SCons/Script/Interactive.py +++ b/src/engine/SCons/Script/Interactive.py @@ -222,7 +222,7 @@ class SConsInteractiveCmd(cmd.Cmd): def get_unseen_children(node, parent, seen_nodes=seen_nodes): def is_unseen(node, seen_nodes=seen_nodes): return node not in seen_nodes - return list(filter(is_unseen, node.children(scan=1))) + return [child for child in node.children(scan=1) if is_unseen(child)] def add_to_seen_nodes(node, parent, seen_nodes=seen_nodes): seen_nodes[node] = 1 diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py index b82b6a5..aea6bea 100644 --- a/src/engine/SCons/Script/Main.py +++ b/src/engine/SCons/Script/Main.py @@ -1168,7 +1168,7 @@ def _build_targets(fs, options, targets, target_top): # or not a file, so go ahead and keep it as a default # target and let the engine sort it out: return 1 - d = list(filter(check_dir, SCons.Script.DEFAULT_TARGETS)) + d = [tgt for tgt in SCons.Script.DEFAULT_TARGETS if check_dir(tgt)] SCons.Script.DEFAULT_TARGETS[:] = d target_top = None lookup_top = None diff --git a/src/engine/SCons/Tool/dvipdf.py b/src/engine/SCons/Tool/dvipdf.py index 374b9c5..f1e9513 100644 --- a/src/engine/SCons/Tool/dvipdf.py +++ b/src/engine/SCons/Tool/dvipdf.py @@ -87,7 +87,7 @@ def PDFEmitter(target, source, env): """ def strip_suffixes(n): return not SCons.Util.splitext(str(n))[1] in ['.aux', '.log'] - source = list(filter(strip_suffixes, source)) + source = [src for src in source if strip_suffixes(src)] return (target, source) def generate(env): diff --git a/src/engine/SCons/Tool/packaging/__init__.py b/src/engine/SCons/Tool/packaging/__init__.py index 1727938..8aa4787 100644 --- a/src/engine/SCons/Tool/packaging/__init__.py +++ b/src/engine/SCons/Tool/packaging/__init__.py @@ -233,7 +233,7 @@ def copy_attr(f1, f2): """ copyit = lambda x: not hasattr(f2, x) and x[:10] == 'PACKAGING_' if f1._tags: - pattrs = list(filter(copyit, f1._tags)) + pattrs = [tag for tag in f1._tags if copyit(tag)] for attr in pattrs: f2.Tag(attr, f1.GetTag(attr)) @@ -288,7 +288,7 @@ def stripinstallbuilder(target, source, env): (file.builder.name=="InstallBuilder" or\ file.builder.name=="InstallAsBuilder")) - if len(list(filter(has_no_install_location, source))): + if len([src for src in source if has_no_install_location(src)]): warn(Warning, "there are files to package which have no\ InstallBuilder attached, this might lead to irreproducible packages") diff --git a/src/test_aegistests.py b/src/test_aegistests.py index 67b0e3f..57adc1d 100644 --- a/src/test_aegistests.py +++ b/src/test_aegistests.py @@ -65,7 +65,7 @@ re3 = re.compile(r' test/.*\.py') def filename_is_a_test(x): return re1.search(x) or re2.search(x) or re3.search(x) -test_files = list(filter(filename_is_a_test, sources)) +test_files = [file for file in sources if filename_is_a_test(file)] if test_files: sys.stderr.write("Found the following files with test names not marked as Aegis tests:\n") diff --git a/test/Java/Java-1.4.py b/test/Java/Java-1.4.py index c1eb5e5..4076783 100644 --- a/test/Java/Java-1.4.py +++ b/test/Java/Java-1.4.py @@ -350,7 +350,7 @@ def classes_must_match(dir, expect): def classes_must_not_exist(dir, expect): global failed - present = list(filter(os.path.exists, expect)) + present = [path for path in expect if os.path.exists(path)] if present: sys.stderr.write("Found the following unexpected class files in '%s' after cleaning:\n" % dir) for c in present: diff --git a/test/Java/Java-1.5.py b/test/Java/Java-1.5.py index 0f93a00..6659a16 100644 --- a/test/Java/Java-1.5.py +++ b/test/Java/Java-1.5.py @@ -346,7 +346,7 @@ def classes_must_match(dir, expect): def classes_must_not_exist(dir, expect): global failed - present = list(filter(os.path.exists, expect)) + present = [path for path in expect if os.path.exists(path)] if present: sys.stderr.write("Found the following unexpected class files in '%s' after cleaning:\n" % dir) for c in present: diff --git a/test/Java/Java-1.6.py b/test/Java/Java-1.6.py index bd7a48f..be46919 100644 --- a/test/Java/Java-1.6.py +++ b/test/Java/Java-1.6.py @@ -346,7 +346,7 @@ def classes_must_match(dir, expect): def classes_must_not_exist(dir, expect): global failed - present = list(filter(os.path.exists, expect)) + present = [path for path in expect if os.path.exists(path)] if present: sys.stderr.write("Found the following unexpected class files in '%s' after cleaning:\n" % dir) for c in present: -- cgit v0.12 From 056622b43309af38e4b6dcbbdcdd0e7b9b176a0d Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Sat, 11 Mar 2017 18:46:09 -0800 Subject: When iterating over dict.items(), we do not need a new list. --- QMTest/TestSCons.py | 6 +++--- QMTest/scons_tdb.py | 2 +- bin/SConsDoc.py | 2 +- bin/SConsExamples.py | 4 ++-- bin/scons-proc.py | 2 +- src/engine/SCons/Action.py | 4 ++-- src/engine/SCons/ActionTests.py | 6 +++--- src/engine/SCons/BuilderTests.py | 4 ++-- src/engine/SCons/Debug.py | 4 ++-- src/engine/SCons/Defaults.py | 2 +- src/engine/SCons/Environment.py | 28 ++++++++++++------------- src/engine/SCons/EnvironmentTests.py | 2 +- src/engine/SCons/Node/Alias.py | 2 +- src/engine/SCons/Node/FS.py | 4 ++-- src/engine/SCons/Node/Python.py | 2 +- src/engine/SCons/Node/__init__.py | 4 ++-- src/engine/SCons/SConsign.py | 12 +++++------ src/engine/SCons/Scanner/LaTeX.py | 4 ++-- src/engine/SCons/Script/Interactive.py | 2 +- src/engine/SCons/Script/SConscript.py | 2 +- src/engine/SCons/Taskmaster.py | 2 +- src/engine/SCons/Tool/MSCommon/common.py | 2 +- src/engine/SCons/Tool/MSCommon/vc.py | 2 +- src/engine/SCons/Tool/MSCommon/vs.py | 2 +- src/engine/SCons/Tool/aixlink.py | 2 +- src/engine/SCons/Tool/gnulink.py | 2 +- src/engine/SCons/Tool/msvs.py | 12 +++++------ src/engine/SCons/Tool/packaging/__init__.py | 2 +- src/engine/SCons/Tool/packaging/msi.py | 6 +++--- src/engine/SCons/Tool/packaging/rpm.py | 2 +- src/engine/SCons/Tool/rpmutils.py | 2 +- src/engine/SCons/Util.py | 6 +++--- src/engine/SCons/Variables/EnumVariableTests.py | 4 ++-- src/engine/SCons/Variables/__init__.py | 2 +- src/engine/SCons/cpp.py | 2 +- src/script/scons-configure-cache.py | 4 ++-- src/script/scons-time.py | 2 +- src/test_files.py | 2 +- test/AS/nasm.py | 2 +- test/QT/QTFLAGS.py | 2 +- 40 files changed, 80 insertions(+), 80 deletions(-) diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index e7175fb..f75a3cc 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -1239,7 +1239,7 @@ class TimeSCons(TestSCons): self.variables = kw.get('variables') default_calibrate_variables = [] if self.variables is not None: - for variable, value in list(self.variables.items()): + for variable, value in self.variables.items(): value = os.environ.get(variable, value) try: value = int(value) @@ -1295,7 +1295,7 @@ class TimeSCons(TestSCons): """ if 'options' not in kw and self.variables: options = [] - for variable, value in list(self.variables.items()): + for variable, value in self.variables.items(): options.append('%s=%s' % (variable, value)) kw['options'] = ' '.join(options) if self.calibrate: @@ -1321,7 +1321,7 @@ class TimeSCons(TestSCons): self.elapsed_time(), "seconds", sort=0) - for name, args in list(stats.items()): + for name, args in stats.items(): self.trace(name, trace, **args) def uptime(self): diff --git a/QMTest/scons_tdb.py b/QMTest/scons_tdb.py index f5c0ae5..76c7fe1 100644 --- a/QMTest/scons_tdb.py +++ b/QMTest/scons_tdb.py @@ -92,7 +92,7 @@ def get_explicit_arguments(e): # Determine which subset of the 'arguments' have been set # explicitly. explicit_arguments = {} - for name, field in list(arguments.items()): + for name, field in arguments.items(): # Do not record computed fields. if field.IsComputed(): continue diff --git a/bin/SConsDoc.py b/bin/SConsDoc.py index 2fe4f73..d566644 100644 --- a/bin/SConsDoc.py +++ b/bin/SConsDoc.py @@ -598,7 +598,7 @@ class SConsDocTree: # Create xpath context self.xpath_context = self.doc.xpathNewContext() # Register namespaces - for key, val in list(self.nsmap.items()): + for key, val in self.nsmap.items(): self.xpath_context.xpathRegisterNs(key, val) def __del__(self): diff --git a/bin/SConsExamples.py b/bin/SConsExamples.py index a86968d..dd9bfaf 100644 --- a/bin/SConsExamples.py +++ b/bin/SConsExamples.py @@ -267,7 +267,7 @@ def ensureExampleOutputsExist(dpath): os.mkdir(generated_examples) examples = readAllExampleInfos(dpath) - for key, value in list(examples.items()): + for key, value in examples.items(): # Process all scons_output tags for o in value.outputs: cpath = os.path.join(generated_examples, @@ -305,7 +305,7 @@ def createAllExampleOutputs(dpath): examples = readAllExampleInfos(dpath) total = len(examples) idx = 0 - for key, value in list(examples.items()): + for key, value in examples.items(): # Process all scons_output tags print("%.2f%s (%d/%d) %s" % (float(idx + 1) * 100.0 / float(total), perc, idx + 1, total, key)) diff --git a/bin/scons-proc.py b/bin/scons-proc.py index 0747b2c..e09c853 100644 --- a/bin/scons-proc.py +++ b/bin/scons-proc.py @@ -104,7 +104,7 @@ Link_Entities_Header = """\ class SCons_XML(object): def __init__(self, entries, **kw): self.values = entries - for k, v in list(kw.items()): + for k, v in kw.items(): setattr(self, k, v) def fopen(self, name): diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index be70293..fa45f10 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -727,7 +727,7 @@ def _subproc(scons_env, cmd, error = 'ignore', **kw): # Ensure that the ENV values are all strings: new_env = {} - for key, value in list(ENV.items()): + for key, value in ENV.items(): if is_List(value): # If the value is a list, then we assume it is a path list, # because that's a pretty common list-like value to stick @@ -855,7 +855,7 @@ class CommandAction(_ActionAction): ENV = get_default_ENV(env) # Ensure that the ENV values are all strings: - for key, value in list(ENV.items()): + for key, value in ENV.items(): if not is_String(value): if is_List(value): # If the value is a list, then we assume it is a diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py index 4a233f1..e437c51 100644 --- a/src/engine/SCons/ActionTests.py +++ b/src/engine/SCons/ActionTests.py @@ -132,7 +132,7 @@ class Environment(object): self.d['SPAWN'] = scons_env['SPAWN'] self.d['PSPAWN'] = scons_env['PSPAWN'] self.d['ESCAPE'] = scons_env['ESCAPE'] - for k, v in list(kw.items()): + for k, v in kw.items(): self.d[k] = v # Just use the underlying scons_subst*() utility methods. def subst(self, strSubst, raw=0, target=[], source=[], conv=None): @@ -157,12 +157,12 @@ class Environment(object): def Clone(self, **kw): res = Environment() res.d = SCons.Util.semi_deepcopy(self.d) - for k, v in list(kw.items()): + for k, v in kw.items(): res.d[k] = v return res def sig_dict(self): d = {} - for k,v in list(self.items()): d[k] = v + for k,v in self.items(): d[k] = v d['TARGETS'] = ['__t1__', '__t2__', '__t3__', '__t4__', '__t5__', '__t6__'] d['TARGET'] = d['TARGETS'][0] d['SOURCES'] = ['__s1__', '__s2__', '__s3__', '__s4__', '__s5__', '__s6__'] diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py index ca35abc..1e544a1 100644 --- a/src/engine/SCons/BuilderTests.py +++ b/src/engine/SCons/BuilderTests.py @@ -79,7 +79,7 @@ class Environment(object): self.d['SHELL'] = scons_env['SHELL'] self.d['SPAWN'] = scons_env['SPAWN'] self.d['ESCAPE'] = scons_env['ESCAPE'] - for k, v in list(kw.items()): + for k, v in kw.items(): self.d[k] = v global env_arg2nodes_called env_arg2nodes_called = None @@ -140,7 +140,7 @@ class Environment(object): return list(self.d.items()) def sig_dict(self): d = {} - for k,v in list(self.items()): d[k] = v + for k,v in self.items(): d[k] = v d['TARGETS'] = ['__t1__', '__t2__', '__t3__', '__t4__', '__t5__', '__t6__'] d['TARGET'] = d['TARGETS'][0] d['SOURCES'] = ['__s1__', '__s2__', '__s3__', '__s4__', '__s5__', '__s6__'] diff --git a/src/engine/SCons/Debug.py b/src/engine/SCons/Debug.py index 6ac5f27..9e520ff 100644 --- a/src/engine/SCons/Debug.py +++ b/src/engine/SCons/Debug.py @@ -89,7 +89,7 @@ def dumpLoggedInstances(classes, file=sys.stdout): obj = ref() if obj is not None: file.write(' %s:\n' % obj) - for key, value in list(obj.__dict__.items()): + for key, value in obj.__dict__.items(): file.write(' %20s : %s\n' % (key, value)) @@ -163,7 +163,7 @@ def caller_trace(back=0): # print a single caller and its callers, if any def _dump_one_caller(key, file, level=0): leader = ' '*level - for v,c in sorted([(-v,c) for c,v in list(caller_dicts[key].items())]): + for v,c in sorted([(-v,c) for c,v in caller_dicts[key].items()]): file.write("%s %6d %s:%d(%s)\n" % ((leader,-v) + func_shorten(c[-3:]))) if c in caller_dicts: _dump_one_caller(c, file, level+1) diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py index f095982..f1d5bca 100644 --- a/src/engine/SCons/Defaults.py +++ b/src/engine/SCons/Defaults.py @@ -459,7 +459,7 @@ def processDefines(defs): else: l.append(str(d[0])) elif SCons.Util.is_Dict(d): - for macro,value in list(d.items()): + for macro,value in d.items(): if value is not None: l.append(str(macro) + '=' + str(value)) else: diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index ed8ef78..85f9fa7 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -152,7 +152,7 @@ def _set_BUILDERS(env, key, value): except KeyError: bd = BuilderDict(kwbd, env) env._dict[key] = bd - for k, v in list(value.items()): + for k, v in value.items(): if not SCons.Builder.is_a_Builder(v): raise SCons.Errors.UserError('%s is not a Builder.' % repr(v)) bd.update(value) @@ -324,7 +324,7 @@ class BuilderDict(UserDict): delattr(self.env, item) def update(self, dict): - for i, v in list(dict.items()): + for i, v in dict.items(): self.__setitem__(i, v) @@ -515,7 +515,7 @@ class SubstitutionEnvironment(object): def subst_kw(self, kw, raw=0, target=None, source=None): nkw = {} - for k, v in list(kw.items()): + for k, v in kw.items(): k = self.subst(k, raw, target, source) if SCons.Util.is_String(v): v = self.subst(v, raw, target, source) @@ -627,7 +627,7 @@ class SubstitutionEnvironment(object): if not o: return self overrides = {} merges = None - for key, value in list(o.items()): + for key, value in o.items(): if key == 'parse_flags': merges = value else: @@ -815,7 +815,7 @@ class SubstitutionEnvironment(object): if not unique: self.Append(**args) return self - for key, value in list(args.items()): + for key, value in args.items(): if not value: continue try: @@ -984,7 +984,7 @@ class Base(SubstitutionEnvironment): # Now restore the passed-in and customized variables # to the environment, since the values the user set explicitly # should override any values set by the tools. - for key, val in list(save.items()): + for key, val in save.items(): self._dict[key] = val # Finally, apply any flags to be merged in @@ -1131,7 +1131,7 @@ class Base(SubstitutionEnvironment): in an Environment. """ kw = copy_non_reserved_keywords(kw) - for key, val in list(kw.items()): + for key, val in kw.items(): # It would be easier on the eyes to write this using # "continue" statements whenever we finish processing an item, # but Python 1.5.2 apparently doesn't let you use "continue" @@ -1201,7 +1201,7 @@ class Base(SubstitutionEnvironment): update_dict(val) except (AttributeError, TypeError, ValueError): if SCons.Util.is_Dict(val): - for k, v in list(val.items()): + for k, v in val.items(): orig[k] = v else: orig[val] = None @@ -1247,7 +1247,7 @@ class Base(SubstitutionEnvironment): values move to end. """ kw = copy_non_reserved_keywords(kw) - for key, val in list(kw.items()): + for key, val in kw.items(): if SCons.Util.is_List(val): val = _delete_duplicates(val, delete_existing) if key not in self._dict or self._dict[key] in ('', None): @@ -1363,7 +1363,7 @@ class Base(SubstitutionEnvironment): val = [val] elif SCons.Util.is_Dict(val): tmp = [] - for i,j in list(val.items()): + for i,j in val.items(): if j is not None: tmp.append((i,j)) else: @@ -1405,7 +1405,7 @@ class Base(SubstitutionEnvironment): # so the tools can use the new variables kw = copy_non_reserved_keywords(kw) new = {} - for key, value in list(kw.items()): + for key, value in kw.items(): new[key] = SCons.Subst.scons_subst_once(value, self, key) clone.Replace(**new) @@ -1605,7 +1605,7 @@ class Base(SubstitutionEnvironment): in an Environment. """ kw = copy_non_reserved_keywords(kw) - for key, val in list(kw.items()): + for key, val in kw.items(): # It would be easier on the eyes to write this using # "continue" statements whenever we finish processing an item, # but Python 1.5.2 apparently doesn't let you use "continue" @@ -1659,7 +1659,7 @@ class Base(SubstitutionEnvironment): update_dict(val) except (AttributeError, TypeError, ValueError): if SCons.Util.is_Dict(val): - for k, v in list(val.items()): + for k, v in val.items(): orig[k] = v else: orig[val] = None @@ -1696,7 +1696,7 @@ class Base(SubstitutionEnvironment): values move to front. """ kw = copy_non_reserved_keywords(kw) - for key, val in list(kw.items()): + for key, val in kw.items(): if SCons.Util.is_List(val): val = _delete_duplicates(val, not delete_existing) if key not in self._dict or self._dict[key] in ('', None): diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index c51dd30..5a14ffc 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -164,7 +164,7 @@ class TestEnvironmentFixture(object): default_keys = { 'CC' : 'cc', 'CCFLAGS' : '-DNDEBUG', 'ENV' : { 'TMP' : '/tmp' } } - for key, value in list(default_keys.items()): + for key, value in default_keys.items(): if key not in kw: kw[key] = value if 'BUILDERS' not in kw: diff --git a/src/engine/SCons/Node/Alias.py b/src/engine/SCons/Node/Alias.py index f229a9f..a035816 100644 --- a/src/engine/SCons/Node/Alias.py +++ b/src/engine/SCons/Node/Alias.py @@ -89,7 +89,7 @@ class AliasNodeInfo(SCons.Node.NodeInfoBase): """ # TODO check or discard version del state['_version_id'] - for key, value in list(state.items()): + for key, value in state.items(): if key not in ('__weakref__',): setattr(self, key, value) diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 9b057be..907bc75 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -2203,7 +2203,7 @@ class Dir(Base): # We use the .name attribute from the Node because the keys of # the dir.entries dictionary are normalized (that is, all upper # case) on case-insensitive systems like Windows. - node_names = [ v.name for k, v in list(dir.entries.items()) + node_names = [ v.name for k, v in dir.entries.items() if k not in ('.', '..') ] names.extend(node_names) if not strings: @@ -2482,7 +2482,7 @@ class FileNodeInfo(SCons.Node.NodeInfoBase): """ # TODO check or discard version del state['_version_id'] - for key, value in list(state.items()): + for key, value in state.items(): if key not in ('__weakref__',): setattr(self, key, value) diff --git a/src/engine/SCons/Node/Python.py b/src/engine/SCons/Node/Python.py index 92cc320..f151fc5 100644 --- a/src/engine/SCons/Node/Python.py +++ b/src/engine/SCons/Node/Python.py @@ -67,7 +67,7 @@ class ValueNodeInfo(SCons.Node.NodeInfoBase): """ # TODO check or discard version del state['_version_id'] - for key, value in list(state.items()): + for key, value in state.items(): if key not in ('__weakref__',): setattr(self, key, value) diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 8e00fdb..f7d2082 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -430,7 +430,7 @@ class NodeInfoBase(object): # TODO check or discard version del state['_version_id'] - for key, value in list(state.items()): + for key, value in state.items(): if key not in ('__weakref__',): setattr(self, key, value) @@ -493,7 +493,7 @@ class BuildInfoBase(object): """ # TODO check or discard version del state['_version_id'] - for key, value in list(state.items()): + for key, value in state.items(): if key not in ('__weakref__',): setattr(self, key, value) diff --git a/src/engine/SCons/SConsign.py b/src/engine/SCons/SConsign.py index 3bd4b71..5042aa1 100644 --- a/src/engine/SCons/SConsign.py +++ b/src/engine/SCons/SConsign.py @@ -160,7 +160,7 @@ class SConsignEntry(object): return state def __setstate__(self, state): - for key, value in list(state.items()): + for key, value in state.items(): if key not in ('_version_id','__weakref__'): setattr(self, key, value) @@ -205,7 +205,7 @@ class Base(object): pass def merge(self): - for key, node in list(self.to_be_merged.items()): + for key, node in self.to_be_merged.items(): entry = node.get_stored_info() try: ninfo = entry.ninfo @@ -252,7 +252,7 @@ class DB(Base): except Exception as e: SCons.Warnings.warn(SCons.Warnings.CorruptSConsignWarning, "Ignoring corrupt sconsign entry : %s (%s)\n"%(self.dir.get_tpath(), e)) - for key, entry in list(self.entries.items()): + for key, entry in self.entries.items(): entry.convert_from_sconsign(dir, key) if mode == "r": @@ -279,7 +279,7 @@ class DB(Base): # the Repository; we only write to our own .sconsign file, # not to .sconsign files in Repositories. path = normcase(self.dir.get_internal_path()) - for key, entry in list(self.entries.items()): + for key, entry in self.entries.items(): entry.convert_to_sconsign() db[path] = pickle.dumps(self.entries, PICKLE_PROTOCOL) @@ -309,7 +309,7 @@ class Dir(Base): raise TypeError if dir: - for key, entry in list(self.entries.items()): + for key, entry in self.entries.items(): entry.convert_from_sconsign(dir, key) @@ -369,7 +369,7 @@ class DirFile(Dir): fname = self.sconsign except IOError: return - for key, entry in list(self.entries.items()): + for key, entry in self.entries.items(): entry.convert_to_sconsign() pickle.dump(self.entries, file, PICKLE_PROTOCOL) file.close() diff --git a/src/engine/SCons/Scanner/LaTeX.py b/src/engine/SCons/Scanner/LaTeX.py index cb89cf0..0c54bf3 100644 --- a/src/engine/SCons/Scanner/LaTeX.py +++ b/src/engine/SCons/Scanner/LaTeX.py @@ -224,14 +224,14 @@ class LaTeX(SCons.Scanner.Base): """ def __init__(self, dictionary): self.dictionary = {} - for k,n in list(dictionary.items()): + for k,n in dictionary.items(): self.dictionary[k] = ( SCons.Scanner.FindPathDirs(n), FindENVPathDirs(n) ) def __call__(self, env, dir=None, target=None, source=None, argument=None): di = {} - for k,(c,cENV) in list(self.dictionary.items()): + for k,(c,cENV) in self.dictionary.items(): di[k] = ( c(env, dir=None, target=None, source=None, argument=None) , cENV(env, dir=None, target=None, source=None, diff --git a/src/engine/SCons/Script/Interactive.py b/src/engine/SCons/Script/Interactive.py index cf6e247..6be7b27 100644 --- a/src/engine/SCons/Script/Interactive.py +++ b/src/engine/SCons/Script/Interactive.py @@ -121,7 +121,7 @@ class SConsInteractiveCmd(cmd.Cmd): def __init__(self, **kw): cmd.Cmd.__init__(self) - for key, val in list(kw.items()): + for key, val in kw.items(): setattr(self, key, val) if sys.platform == 'win32': diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py index 4e63f6c..8609892 100644 --- a/src/engine/SCons/Script/SConscript.py +++ b/src/engine/SCons/Script/SConscript.py @@ -526,7 +526,7 @@ class SConsEnvironment(SCons.Environment.Base): return x ls = list(map(subst_element, ls)) subst_kw = {} - for key, val in list(kw.items()): + for key, val in kw.items(): if SCons.Util.is_String(val): val = self.subst(val) elif SCons.Util.is_List(val): diff --git a/src/engine/SCons/Taskmaster.py b/src/engine/SCons/Taskmaster.py index 47a4c90..bd94972 100644 --- a/src/engine/SCons/Taskmaster.py +++ b/src/engine/SCons/Taskmaster.py @@ -479,7 +479,7 @@ class Task(object): if p.ref_count == 0: self.tm.candidates.append(p) - for p, subtract in list(parents.items()): + for p, subtract in parents.items(): p.ref_count = p.ref_count - subtract if T: T.write(self.trace_message(u'Task.postprocess()', p, diff --git a/src/engine/SCons/Tool/MSCommon/common.py b/src/engine/SCons/Tool/MSCommon/common.py index b14eba1..41cd889 100644 --- a/src/engine/SCons/Tool/MSCommon/common.py +++ b/src/engine/SCons/Tool/MSCommon/common.py @@ -219,7 +219,7 @@ def parse_output(output, keep = ("INCLUDE", "LIB", "LIBPATH", "PATH")): dkeep[key].append(p) for line in output.splitlines(): - for k,v in list(rdk.items()): + for k,v in rdk.items(): m = v.match(line) if m: add_env(m, k) diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py index 588fe98..7b8dd9d 100644 --- a/src/engine/SCons/Tool/MSCommon/vc.py +++ b/src/engine/SCons/Tool/MSCommon/vc.py @@ -515,7 +515,7 @@ def msvc_setup_env(env): SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning, warn_msg) return None - for k, v in list(d.items()): + for k, v in d.items(): debug('vc.py:msvc_setup_env() env:%s -> %s'%(k,v)) env.PrependENVPath(k, v, delete_existing=True) diff --git a/src/engine/SCons/Tool/MSCommon/vs.py b/src/engine/SCons/Tool/MSCommon/vs.py index 4bda406..31197ef 100644 --- a/src/engine/SCons/Tool/MSCommon/vs.py +++ b/src/engine/SCons/Tool/MSCommon/vs.py @@ -545,7 +545,7 @@ def msvs_setup_env(env): env['ENV'] = save_ENV vars = parse_output(output, vars) - for k, v in list(vars.items()): + for k, v in vars.items(): env.PrependENVPath(k, v, delete_existing=1) def query_versions(): diff --git a/src/engine/SCons/Tool/aixlink.py b/src/engine/SCons/Tool/aixlink.py index 3117c55..bfddf0a 100644 --- a/src/engine/SCons/Tool/aixlink.py +++ b/src/engine/SCons/Tool/aixlink.py @@ -65,7 +65,7 @@ def exists(env): # TODO: sync with link.smart_link() to choose a linker linkers = { 'CXX': ['aixc++'], 'CC': ['aixcc'] } alltools = [] - for langvar, linktools in list(linkers.items()): + for langvar, linktools in linkers.items(): if langvar in env: # use CC over CXX when user specified CC but not CXX return SCons.Tool.FindTool(linktools, env) alltools.extend(linktools) diff --git a/src/engine/SCons/Tool/gnulink.py b/src/engine/SCons/Tool/gnulink.py index cf1ce85..b1d5088 100644 --- a/src/engine/SCons/Tool/gnulink.py +++ b/src/engine/SCons/Tool/gnulink.py @@ -67,7 +67,7 @@ def exists(env): # TODO: sync with link.smart_link() to choose a linker linkers = { 'CXX': ['g++'], 'CC': ['gcc'] } alltools = [] - for langvar, linktools in list(linkers.items()): + for langvar, linktools in linkers.items(): if langvar in env: # use CC over CXX when user specified CC but not CXX return SCons.Tool.FindTool(linktools, env) alltools.extend(linktools) diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py index 939668e..67f9ada 100644 --- a/src/engine/SCons/Tool/msvs.py +++ b/src/engine/SCons/Tool/msvs.py @@ -213,7 +213,7 @@ class _UserGenerator(object): if self.createfile: dbg_settings = dict(list(zip(variants, dbg_settings))) - for var, src in list(dbg_settings.items()): + for var, src in dbg_settings.items(): # Update only expected keys trg = {} for key in [k for k in list(self.usrdebg.keys()) if k in src]: @@ -303,7 +303,7 @@ class _GenerateV7User(_UserGenerator): debug = self.configs[kind].debug if debug: debug_settings = '\n'.join(['\t\t\t\t%s="%s"' % (key, xmlify(value)) - for key, value in list(debug.items()) + for key, value in debug.items() if value is not None]) self.usrfile.write(self.usrconf % locals()) self.usrfile.write('\t\n') @@ -365,7 +365,7 @@ class _GenerateV10User(_UserGenerator): debug = self.configs[kind].debug if debug: debug_settings = '\n'.join(['\t\t<%s>%s' % (key, xmlify(value), key) - for key, value in list(debug.items()) + for key, value in debug.items() if value is not None]) self.usrfile.write(self.usrconf % locals()) self.usrfile.write('') @@ -924,7 +924,7 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User): self.file.write(pdata + '-->\n') def printSources(self, hierarchy, commonprefix): - sorteditems = sorted(list(hierarchy.items()), key=lambda a: a[0].lower()) + sorteditems = sorted(hierarchy.items(), key=lambda a: a[0].lower()) # First folders, then files for key, value in sorteditems: @@ -1243,7 +1243,7 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): self.file.write(pdata + '-->\n') def printFilters(self, hierarchy, name): - sorteditems = sorted(list(hierarchy.items()), key = lambda a: a[0].lower()) + sorteditems = sorted(hierarchy.items(), key = lambda a: a[0].lower()) for key, value in sorteditems: if SCons.Util.is_Dict(value): @@ -1260,7 +1260,7 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): 'Resource Files': 'None', 'Other Files': 'None'} - sorteditems = sorted(list(hierarchy.items()), key = lambda a: a[0].lower()) + sorteditems = sorted(hierarchy.items(), key = lambda a: a[0].lower()) # First folders, then files for key, value in sorteditems: diff --git a/src/engine/SCons/Tool/packaging/__init__.py b/src/engine/SCons/Tool/packaging/__init__.py index 8aa4787..dc4b80d 100644 --- a/src/engine/SCons/Tool/packaging/__init__.py +++ b/src/engine/SCons/Tool/packaging/__init__.py @@ -72,7 +72,7 @@ def Tag(env, target, source, *more_tags, **kw_tags): target=env.Flatten(target) for t in target: - for (k,v) in list(kw_tags.items()): + for (k,v) in kw_tags.items(): # all file tags have to start with PACKAGING_, so we can later # differentiate between "normal" object attributes and the # packaging attributes. As the user should not be bothered with diff --git a/src/engine/SCons/Tool/packaging/msi.py b/src/engine/SCons/Tool/packaging/msi.py index 73d3567..c25f856 100644 --- a/src/engine/SCons/Tool/packaging/msi.py +++ b/src/engine/SCons/Tool/packaging/msi.py @@ -172,7 +172,7 @@ def generate_guids(root): # find all XMl nodes matching the key, retrieve their attribute, hash their # subtree, convert hash to string and add as a attribute to the xml node. - for (key,value) in list(needs_id.items()): + for (key,value) in needs_id.items(): node_list = root.getElementsByTagName(key) attribute = value for node in node_list: @@ -335,7 +335,7 @@ def build_wxsfile_file_section(root, files, NAME, VERSION, VENDOR, filename_set, } # fill in the default tags given above. - for k,v in [ (k, v) for (k,v) in list(h.items()) if not hasattr(file, k) ]: + for k,v in [ (k, v) for (k,v) in h.items() if not hasattr(file, k) ]: setattr( file, k, v ) File = factory.createElement( 'File' ) @@ -382,7 +382,7 @@ def build_wxsfile_features_section(root, files, NAME, VERSION, SUMMARY, id_set): Feature.attributes['Description'] = escape( SUMMARY ) Feature.attributes['Display'] = 'expand' - for (feature, files) in list(create_feature_dict(files).items()): + for (feature, files) in create_feature_dict(files).items(): SubFeature = factory.createElement('Feature') SubFeature.attributes['Level'] = '1' diff --git a/src/engine/SCons/Tool/packaging/rpm.py b/src/engine/SCons/Tool/packaging/rpm.py index 0931c77..a3481a4 100644 --- a/src/engine/SCons/Tool/packaging/rpm.py +++ b/src/engine/SCons/Tool/packaging/rpm.py @@ -332,7 +332,7 @@ class SimpleTagCompiler(object): international = [t for t in replacements if is_international(t[0])] for key, replacement in international: try: - x = [t for t in list(values.items()) if strip_country_code(t[0]) == key] + x = [t for t in values.items() if strip_country_code(t[0]) == key] int_values_for_key = [(get_country_code(t[0]),t[1]) for t in x] for v in int_values_for_key: str = str + replacement % v diff --git a/src/engine/SCons/Tool/rpmutils.py b/src/engine/SCons/Tool/rpmutils.py index d4db417..3eeed1d 100644 --- a/src/engine/SCons/Tool/rpmutils.py +++ b/src/engine/SCons/Tool/rpmutils.py @@ -520,7 +520,7 @@ def updateRpmDicts(rpmrc, pyfile): if l.startswith('# Start of rpmrc dictionaries'): pm = 1 # Write data sections to single dictionaries - for key, entries in list(data.items()): + for key, entries in data.items(): out.write("%s = {\n" % key) for arch in sorted(entries.keys()): out.write(" '%s' : ['%s'],\n" % (arch, "','".join(entries[arch]))) diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index d6f18cc..83202a5 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -514,7 +514,7 @@ _semi_deepcopy_dispatch = d = {} def semi_deepcopy_dict(x, exclude = [] ): copy = {} - for key, val in list(x.items()): + for key, val in x.items(): # The regular Python copy.deepcopy() also deepcopies the key, # as follows: # @@ -1074,7 +1074,7 @@ class OrderedDict(UserDict): if key not in self._keys: self._keys.append(key) def update(self, dict): - for (key, val) in list(dict.items()): + for (key, val) in dict.items(): self.__setitem__(key, val) def values(self): @@ -1096,7 +1096,7 @@ class Selector(OrderedDict): # Try to perform Environment substitution on the keys of # the dictionary before giving up. s_dict = {} - for (k,v) in list(self.items()): + for (k,v) in self.items(): if k is not None: s_k = env.subst(k) if s_k in s_dict: diff --git a/src/engine/SCons/Variables/EnumVariableTests.py b/src/engine/SCons/Variables/EnumVariableTests.py index edc2973..931dfe2 100644 --- a/src/engine/SCons/Variables/EnumVariableTests.py +++ b/src/engine/SCons/Variables/EnumVariableTests.py @@ -124,7 +124,7 @@ class EnumVariableTestCase(unittest.TestCase): 'C' : ['C', 'three', 'three'], } - for k, l in list(table.items()): + for k, l in table.items(): x = o0.converter(k) assert x == l[0], "o0 got %s, expected %s" % (x, l[0]) x = o1.converter(k) @@ -188,7 +188,7 @@ class EnumVariableTestCase(unittest.TestCase): 'no_v' : [invalid, invalid, invalid], } - for v, l in list(table.items()): + for v, l in table.items(): l[0](o0, v) l[1](o1, v) l[2](o2, v) diff --git a/src/engine/SCons/Variables/__init__.py b/src/engine/SCons/Variables/__init__.py index ce3541c..b03e5b5 100644 --- a/src/engine/SCons/Variables/__init__.py +++ b/src/engine/SCons/Variables/__init__.py @@ -185,7 +185,7 @@ class Variables(object): if args is None: args = self.args - for arg, value in list(args.items()): + for arg, value in args.items(): added = False for option in self.options: if arg in list(option.aliases) + [ option.key ]: diff --git a/src/engine/SCons/cpp.py b/src/engine/SCons/cpp.py index 8212cc1..f282ba7 100644 --- a/src/engine/SCons/cpp.py +++ b/src/engine/SCons/cpp.py @@ -72,7 +72,7 @@ cpp_lines_dict = { # the corresponding compiled regular expression that fetches the arguments # we care about. Table = {} -for op_list, expr in list(cpp_lines_dict.items()): +for op_list, expr in cpp_lines_dict.items(): e = re.compile(expr) for op in op_list: Table[op] = e diff --git a/src/script/scons-configure-cache.py b/src/script/scons-configure-cache.py index 2648acd..73ccf18 100644 --- a/src/script/scons-configure-cache.py +++ b/src/script/scons-configure-cache.py @@ -99,7 +99,7 @@ for param in config_entries: parser.add_argument('--version', action='version', version='%(prog)s 1.0') # Get the command line as a dict without any of the unspecified entries. -args = dict([x for x in list(vars(parser.parse_args()).items()) if x[1]]) +args = dict([x for x in vars(parser.parse_args()).items() if x[1]]) # It seems somewhat strange to me, but positional arguments don't get the - # in the name changed to _, whereas optional arguments do... @@ -136,4 +136,4 @@ for key in args: # and write the updated config file with open('config', 'w') as conf: - json.dump(config, conf) \ No newline at end of file + json.dump(config, conf) diff --git a/src/script/scons-time.py b/src/script/scons-time.py index c788e50..1473c42 100644 --- a/src/script/scons-time.py +++ b/src/script/scons-time.py @@ -654,7 +654,7 @@ class SConsTimer(object): sys.stderr.write('%s Cannot use the "func" subcommand.\n' % self.name_spaces) sys.exit(1) statistics = pstats.Stats(file).stats - matches = [ e for e in list(statistics.items()) if e[0][2] == function ] + matches = [ e for e in statistics.items() if e[0][2] == function ] r = matches[0] return r[0][0], r[0][1], r[0][2], r[1][3] diff --git a/src/test_files.py b/src/test_files.py index ef27606..1eee11d 100644 --- a/src/test_files.py +++ b/src/test_files.py @@ -78,7 +78,7 @@ check = { missing = [] no_result = [] -for directory, check_list in list(check.items()): +for directory, check_list in check.items(): if os.path.exists(directory): for c in check_list: f = os.path.join(directory, c) diff --git a/test/AS/nasm.py b/test/AS/nasm.py index b436a75..1733789 100644 --- a/test/AS/nasm.py +++ b/test/AS/nasm.py @@ -69,7 +69,7 @@ else: # anyway...). nasm_format = 'elf' format_map = {} -for k, v in list(format_map.items()): +for k, v in format_map.items(): if sys.platform.find(k) != -1: nasm_format = v break diff --git a/test/QT/QTFLAGS.py b/test/QT/QTFLAGS.py index e29ee80..f6aa00f 100644 --- a/test/QT/QTFLAGS.py +++ b/test/QT/QTFLAGS.py @@ -147,7 +147,7 @@ test.must_exist(['work1', 'mmmmocFromH.cxx'], ['work1', 'mmmanother_ui_file.cxx']) def _flagTest(test,fileToContentsStart): - for f,c in list(fileToContentsStart.items()): + for f,c in fileToContentsStart.items(): if test.read(test.workpath('work1', f)).find(c) != 0: return 1 return 0 -- cgit v0.12 From 60d939bcb085cafe0c990487d8a01ecf21150eba Mon Sep 17 00:00:00 2001 From: Russel Winder Date: Sun, 12 Mar 2017 13:19:04 +0000 Subject: Change the search order for D compilers. --- src/engine/SCons/Tool/__init__.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index 0e5f364..dbc6d0c 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -291,7 +291,7 @@ def _call_linker_cb(env, callback, args, result = None): if Verbose: print('_call_linker_cb: args=%r' % args) print('_call_linker_cb: callback=%r' % callback) - + try: cbfun = env['LINKCALLBACKS'][callback] except (KeyError, TypeError): @@ -423,7 +423,7 @@ class _LibInfoGeneratorBase(object): def generate_versioned_lib_info(self, env, args, result = None, **kw): callback = self.get_versioned_lib_info_generator(**kw) - return _call_linker_cb(env, callback, args, result) + return _call_linker_cb(env, callback, args, result) class _LibPrefixGenerator(_LibInfoGeneratorBase): """Library prefix generator, used as target_prefix in SharedLibrary and @@ -534,7 +534,7 @@ ImpLibSymlinkGenerator = _LibSymlinkGenerator('ImpLib') class _LibNameGenerator(_LibInfoGeneratorBase): """Generates "unmangled" library name from a library file node. - + Generally, it's thought to revert modifications done by prefix/suffix generators (_LibPrefixGenerator/_LibSuffixGenerator) used by a library builder. For example, on gnulink the suffix generator used by SharedLibrary @@ -544,7 +544,7 @@ class _LibNameGenerator(_LibInfoGeneratorBase): "$SHLIBSUFFIX" in the node's basename. So that, if $SHLIBSUFFIX is ".so", $SHLIBVERSION is "0.1.2" and the node path is "/foo/bar/libfoo.so.0.1.2", the _LibNameGenerator shall return "libfoo.so". Other link tools may - implement it's own way of library name unmangling. + implement it's own way of library name unmangling. """ def __init__(self, libtype): super(_LibNameGenerator, self).__init__(libtype, 'Name') @@ -585,7 +585,7 @@ LdModNameGenerator = _LibNameGenerator('LdMod') ImpLibNameGenerator = _LibNameGenerator('ImpLib') class _LibSonameGenerator(_LibInfoGeneratorBase): - """Library soname generator. Returns library soname (e.g. libfoo.so.0) for + """Library soname generator. Returns library soname (e.g. libfoo.so.0) for a given node (e.g. /foo/bar/libfoo.so.0.1.2)""" def __init__(self, libtype): super(_LibSonameGenerator, self).__init__(libtype, 'Soname') @@ -648,7 +648,7 @@ def EmitLibSymlinks(env, symlinks, libnode, **kw): clean_targets = kw.get('clean_targets', []) if not SCons.Util.is_List(clean_targets): clean_targets = [ clean_targets ] - + for link, linktgt in symlinks: env.SideEffect(link, linktgt) if(Verbose): @@ -663,7 +663,7 @@ def CreateLibSymlinks(env, symlinks): form [ (link, linktarget), ... ], where link and linktarget are SCons nodes. """ - + Verbose = False for link, linktgt in symlinks: linktgt = link.get_dir().rel_path(linktgt) @@ -705,7 +705,7 @@ def LibSymlinksStrFun(target, source, env, *args): else: cmd += ": %s" % linkstr return cmd - + LibSymlinksAction = SCons.Action.Action(LibSymlinksActionFunction, LibSymlinksStrFun) @@ -1137,7 +1137,7 @@ def tool_list(platform, env): fortran_compiler = FindTool(fortran_compilers, env) or fortran_compilers[0] ar = FindTool(ars, env) or ars[0] - d_compilers = ['dmd', 'gdc', 'ldc'] + d_compilers = ['dmd', 'ldc', 'gdc'] d_compiler = FindTool(d_compilers, env) or d_compilers[0] other_tools = FindAllTools(other_plat_tools + [ @@ -1172,4 +1172,3 @@ def tool_list(platform, env): # indent-tabs-mode:nil # End: # vim: set expandtab tabstop=4 shiftwidth=4: - -- cgit v0.12 From 9011a84a8660e2b79b2b51bc3160f8abc9694c19 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 12 Mar 2017 17:37:41 -0400 Subject: set mode=r and not rb for must_match. py2/3 --- test/CPPSUFFIXES.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/CPPSUFFIXES.py b/test/CPPSUFFIXES.py index 6aa5596..141df29 100644 --- a/test/CPPSUFFIXES.py +++ b/test/CPPSUFFIXES.py @@ -49,6 +49,7 @@ sys.exit(0) """) test.write('SConstruct', """ +DefaultEnvironment(tools=[]) env = Environment(CPPPATH = ['.'], CC = r'%(_python_)s mycc.py', CCFLAGS = [], @@ -94,7 +95,7 @@ test1.h 1 foo.h 1 test1.x 1 foo.h 1 -""") +""", mode='r') test.up_to_date(arguments='.') @@ -112,7 +113,7 @@ test1.h 1 foo.h 2 test1.x 1 foo.h 2 -""") +""", mode='r') test.up_to_date(arguments='.') @@ -134,7 +135,7 @@ test1.h 1 foo.h 2 test1.x 2 foo.h 2 -""") +""", mode='r') test.up_to_date(arguments='.') @@ -156,7 +157,7 @@ test1.h 2 foo.h 2 test1.x 2 foo.h 2 -""") +""", mode='r') test.up_to_date(arguments='.') -- cgit v0.12 From a0484dfdd42420f93823aad868c73bd6b3565f82 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 12 Mar 2017 17:39:12 -0400 Subject: set mode=r and not rb. py2/3 --- test/option-k.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/option-k.py b/test/option-k.py index 5cd9be9..7a01ed3 100644 --- a/test/option-k.py +++ b/test/option-k.py @@ -55,6 +55,7 @@ sys.exit(1) # test.write(['work1', 'SConstruct'], """\ +DefaultEnvironment(tools=[]) Succeed = Builder(action = r'%(_python_)s ../succeed.py $TARGETS') Fail = Builder(action = r'%(_python_)s ../fail.py $TARGETS') env = Environment(BUILDERS = { 'Succeed' : Succeed, 'Fail' : Fail }) @@ -82,7 +83,7 @@ test.run(chdir = 'work1', test.must_not_exist(test.workpath('work1', 'aaa.1')) test.must_not_exist(test.workpath('work1', 'aaa.out')) -test.must_match(['work1', 'bbb.out'], "succeed.py: bbb.out\n") +test.must_match(['work1', 'bbb.out'], "succeed.py: bbb.out\n", mode='r') test.unlink(['work1', 'bbb.out']) @@ -93,7 +94,7 @@ test.run(chdir = 'work1', test.must_not_exist(test.workpath('work1', 'aaa.1')) test.must_not_exist(test.workpath('work1', 'aaa.out')) -test.must_match(['work1', 'bbb.out'], "succeed.py: bbb.out\n") +test.must_match(['work1', 'bbb.out'], "succeed.py: bbb.out\n", mode='r') expect = """\ scons: Reading SConscript files ... @@ -118,6 +119,7 @@ test.must_not_exist(test.workpath('work1', 'bbb.out')) # test.write(['work2', 'SConstruct'], """\ +DefaultEnvironment(tools=[]) Succeed = Builder(action = r'%(_python_)s ../succeed.py $TARGETS') Fail = Builder(action = r'%(_python_)s ../fail.py $TARGETS') env = Environment(BUILDERS = { 'Succeed' : Succeed, 'Fail' : Fail }) @@ -146,8 +148,8 @@ scons: done building targets (errors occurred during build). test.must_not_exist(['work2', 'aaa.out']) test.must_not_exist(['work2', 'bbb.out']) -test.must_match(['work2', 'ccc.out'], "succeed.py: ccc.out\n") -test.must_match(['work2', 'ddd.out'], "succeed.py: ddd.out\n") +test.must_match(['work2', 'ccc.out'], "succeed.py: ccc.out\n", mode='r') +test.must_match(['work2', 'ddd.out'], "succeed.py: ddd.out\n", mode='r') @@ -173,6 +175,7 @@ test.must_match(['work2', 'ddd.out'], "succeed.py: ddd.out\n") # test.write(['work3', 'SConstruct'], """\ +DefaultEnvironment(tools=[]) Succeed = Builder(action = r'%(_python_)s ../succeed.py $TARGETS') Fail = Builder(action = r'%(_python_)s ../fail.py $TARGETS') env = Environment(BUILDERS = { 'Succeed' : Succeed, 'Fail' : Fail }) -- cgit v0.12 From cc31754c1f74e8f6206329f6b267660cfc72c993 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 12 Mar 2017 17:40:03 -0400 Subject: set mode=r and not rb. py2/3 --- test/option-i.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test/option-i.py b/test/option-i.py index 3301bf5..9b5212d 100644 --- a/test/option-i.py +++ b/test/option-i.py @@ -73,22 +73,21 @@ test.run(arguments = '-i aaa.1 aaa.out bbb.1 bbb.out', 'scons: *** [bbb.1] Error 1\n') test.fail_test(os.path.exists(test.workpath('aaa.1'))) -test.fail_test(test.read('aaa.out') != "succeed.py: aaa.out\n") +test.fail_test(test.read('aaa.out',mode='r') != "succeed.py: aaa.out\n") test.fail_test(os.path.exists(test.workpath('bbb.1'))) -test.fail_test(test.read('bbb.out') != "succeed.py: bbb.out\n") +test.fail_test(test.read('bbb.out',mode='r') != "succeed.py: bbb.out\n") test.unlink("aaa.out") test.unlink("bbb.out") -test.run(arguments = '--ignore-errors aaa.1 aaa.out bbb.1 bbb.out', - stderr = - 'scons: *** [aaa.1] Error 1\n' +test.run(arguments='--ignore-errors aaa.1 aaa.out bbb.1 bbb.out', + stderr='scons: *** [aaa.1] Error 1\n' 'scons: *** [bbb.1] Error 1\n') test.fail_test(os.path.exists(test.workpath('aaa.1'))) -test.fail_test(test.read('aaa.out') != "succeed.py: aaa.out\n") +test.fail_test(test.read('aaa.out', mode='r') != "succeed.py: aaa.out\n") test.fail_test(os.path.exists(test.workpath('bbb.1'))) -test.fail_test(test.read('bbb.out') != "succeed.py: bbb.out\n") +test.fail_test(test.read('bbb.out', mode='r') != "succeed.py: bbb.out\n") test.pass_test() -- cgit v0.12 From 462c39afe68bd7e936eb86e094c777242ad9764f Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 12 Mar 2017 17:41:09 -0400 Subject: Remove check for subprocess.mswindows used to detect running on windows py2/3 --- QMTest/TestCmd.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index 96e07a9..e76b2e3 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -499,7 +499,7 @@ def match_re(lines = None, res = None): msg = "Regular expression error in %s: %s" raise re.error(msg % (repr(s), e.args[0])) if not expr.search(lines[i]): - print("match_re: mismatch at line %d:\n search re='%s'\n line='%s'"%(i,s,lines[i])) + print("match_re: mismatch at line %d:\n search re='%s'\n line='%s'"%(i, s, lines[i])) return return 1 @@ -672,7 +672,7 @@ except AttributeError: PIPE = subprocess.PIPE -if sys.platform == 'win32' and subprocess.mswindows: +if sys.platform == 'win32':# and subprocess.mswindows: try: from win32file import ReadFile, WriteFile from win32pipe import PeekNamedPipe @@ -734,7 +734,7 @@ class Popen(subprocess.Popen): getattr(self, which).close() setattr(self, which, None) - if sys.platform == 'win32' and subprocess.mswindows: + if sys.platform == 'win32':# and subprocess.mswindows: def send(self, input): if not self.stdin: return None -- cgit v0.12 From 80691453682f5af7fc863b9a6b7e790005bbb562 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 12 Mar 2017 17:44:13 -0400 Subject: Add mode=r (default rb) in test.must_match() py2/3 --- test/CXX/CXX.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/CXX/CXX.py b/test/CXX/CXX.py index 1a07b09..83c4285 100644 --- a/test/CXX/CXX.py +++ b/test/CXX/CXX.py @@ -151,15 +151,15 @@ test.write('test5.C++', r"""This is a .C++ file. test.run(arguments = '.', stderr = None) -test.must_match('test1' + _exe, "This is a .cc file.\n") +test.must_match('test1' + _exe, "This is a .cc file.\n", mode='r') -test.must_match('test2' + _exe, "This is a .cpp file.\n") +test.must_match('test2' + _exe, "This is a .cpp file.\n", mode='r') -test.must_match('test3' + _exe, "This is a .cxx file.\n") +test.must_match('test3' + _exe, "This is a .cxx file.\n", mode='r') -test.must_match('test4' + _exe, "This is a .c++ file.\n") +test.must_match('test4' + _exe, "This is a .c++ file.\n", mode='r') -test.must_match('test5' + _exe, "This is a .C++ file.\n") +test.must_match('test5' + _exe, "This is a .C++ file.\n", mode='r') if TestSCons.case_sensitive_suffixes('.c', '.C'): -- cgit v0.12 From 1e010cb43dabeda08a5882f4f93969d217c8eecc Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 12 Mar 2017 18:24:00 -0400 Subject: py2/3 fixes. mostly mode=r on must_match. Also skip the symlink test on windows because os.symlink exists on py3 (didn't in py2), but requires permissions to work on windows which aren't default --- test/CacheDir/CacheDir.py | 10 +++++----- test/CacheDir/SideEffect.py | 6 +++--- test/CacheDir/VariantDir.py | 10 +++++----- test/CacheDir/environment.py | 14 +++++++------- test/CacheDir/option--cd.py | 14 +++++++------- test/CacheDir/option--cf.py | 7 +++++-- test/CacheDir/option--cr.py | 14 +++++++------- test/CacheDir/option--cs.py | 6 +++--- test/CacheDir/symlink.py | 10 +++++++--- 9 files changed, 49 insertions(+), 42 deletions(-) diff --git a/test/CacheDir/CacheDir.py b/test/CacheDir/CacheDir.py index fe73cad..45c5db5 100644 --- a/test/CacheDir/CacheDir.py +++ b/test/CacheDir/CacheDir.py @@ -89,8 +89,8 @@ test.fail_test(os.listdir(cache) != ['config']) # This should populate the cache with our derived files. test.run(chdir = 'src', arguments = '.') -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") -test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') +test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') @@ -130,7 +130,7 @@ test.must_not_exist(src_all) # even though it doesn't report anything. test.run(chdir = 'src', arguments = '-s .', stdout = "") -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') test.must_not_exist(src_cat_out) test.up_to_date(chdir = 'src', arguments = '.') @@ -148,8 +148,8 @@ Retrieved `ccc.out' from cache cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) """)) -test.must_match(['src', 'all'], "aaa.in\nbbb.in 2\nccc.in\n") -test.must_match(['src', 'cat.out'], "bbb.out\nall\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in 2\nccc.in\n", mode='r') +test.must_match(['src', 'cat.out'], "bbb.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') diff --git a/test/CacheDir/SideEffect.py b/test/CacheDir/SideEffect.py index 386b16a..2ddba31 100644 --- a/test/CacheDir/SideEffect.py +++ b/test/CacheDir/SideEffect.py @@ -69,7 +69,7 @@ f1.in -> f1.out f2.in -> f2.out """ -test.must_match(['work', 'log.txt'], expect) +test.must_match(['work', 'log.txt'], expect, mode='r') @@ -84,7 +84,7 @@ f2.in -> f2.out f3.in -> f3.out """ -test.must_match(['work', 'log.txt'], expect) +test.must_match(['work', 'log.txt'], expect, mode='r') @@ -100,7 +100,7 @@ f3.in -> f3.out f1.in -> f1.out """ -test.must_match(['work', 'log.txt'], expect) +test.must_match(['work', 'log.txt'], expect, mode='r') diff --git a/test/CacheDir/VariantDir.py b/test/CacheDir/VariantDir.py index 30325d2..d31b9ed 100644 --- a/test/CacheDir/VariantDir.py +++ b/test/CacheDir/VariantDir.py @@ -75,8 +75,8 @@ SConscript('build/SConscript') # This should populate the cache with our derived files. test.run() -test.must_match(['build', 'all'], "aaa.in\nbbb.in\nccc.in\n") -test.must_match('cat.out', "%s\n%s\n%s\n%s\n" % (build_aaa_out, build_bbb_out, build_ccc_out, build_all)) +test.must_match(['build', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') +test.must_match('cat.out', "%s\n%s\n%s\n%s\n" % (build_aaa_out, build_bbb_out, build_ccc_out, build_all), mode='r') test.up_to_date(arguments = '.') @@ -116,7 +116,7 @@ test.must_not_exist(test.workpath('build', 'all')) # even though it doesn't report anything. test.run(arguments = '-s .', stdout = "") -test.must_match(['build', 'all'], "aaa.in\nbbb.in\nccc.in\n") +test.must_match(['build', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') test.must_not_exist(cat_out) test.up_to_date(arguments = '.') @@ -137,8 +137,8 @@ cat(["%s"], ["%s", "%s", "%s"]) build_ccc_out, build_all, build_aaa_out, build_bbb_out, build_ccc_out))) -test.must_match(['build', 'all'], "aaa.in\nbbb.in 2\nccc.in\n") -test.must_match('cat.out', "%s\n%s\n" % (build_bbb_out, build_all)) +test.must_match(['build', 'all'], "aaa.in\nbbb.in 2\nccc.in\n", mode='r') +test.must_match('cat.out', "%s\n%s\n" % (build_bbb_out, build_all), mode='r') test.up_to_date(arguments = '.') diff --git a/test/CacheDir/environment.py b/test/CacheDir/environment.py index eb28c19..e37b999 100644 --- a/test/CacheDir/environment.py +++ b/test/CacheDir/environment.py @@ -92,8 +92,8 @@ test.fail_test(os.listdir(cache) != ['config']) # This should populate the cache with our derived files. test.run(chdir = 'src', arguments = '.') -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") -test.must_match(src_cat_out, "aaa.out\nbbb.out\nccc.out\nall\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') +test.must_match(src_cat_out, "aaa.out\nbbb.out\nccc.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') @@ -109,7 +109,7 @@ Retrieved `ccc.out' from cache cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) """)) -test.must_match(src_cat_out, "bbb.out\nall\n") +test.must_match(src_cat_out, "bbb.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') @@ -134,9 +134,9 @@ test.must_not_exist(src_all) # even though it doesn't report anything. test.run(chdir = 'src', arguments = '-s .', stdout = "") -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') -test.must_match(src_cat_out, "bbb.out\nall\n") +test.must_match(src_cat_out, "bbb.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') @@ -154,8 +154,8 @@ Retrieved `ccc.out' from cache cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) """)) -test.must_match(['src', 'all'], "aaa.in\nbbb.in 2\nccc.in\n") -test.must_match(src_cat_out, "bbb.out\nall\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in 2\nccc.in\n", mode='r') +test.must_match(src_cat_out, "bbb.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') diff --git a/test/CacheDir/option--cd.py b/test/CacheDir/option--cd.py index efcf843..fad5add 100644 --- a/test/CacheDir/option--cd.py +++ b/test/CacheDir/option--cd.py @@ -62,8 +62,8 @@ test.write(['src', 'ccc.in'], "ccc.in\n") # This should populate the cache with our derived files. test.run(chdir = 'src', arguments = '.') -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") -test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') +test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') @@ -79,7 +79,7 @@ Retrieved `ccc.out' from cache Retrieved `all' from cache """)) -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') test.must_not_exist(test.workpath('src', 'cat.out')) test.up_to_date(chdir = 'src', arguments = '.') @@ -97,8 +97,8 @@ cat(["ccc.out"], ["ccc.in"]) cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) """)) -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") -test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') +test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') @@ -116,8 +116,8 @@ cat(["ccc.out"], ["ccc.in"]) cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) """)) -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") -test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') +test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') diff --git a/test/CacheDir/option--cf.py b/test/CacheDir/option--cf.py index ace0df6..bb9d1cc 100644 --- a/test/CacheDir/option--cf.py +++ b/test/CacheDir/option--cf.py @@ -38,6 +38,7 @@ test = TestSCons.TestSCons() test.subdir('cache', 'src') test.write(['src', 'SConstruct'], """ +DefaultEnvironment(tools=[]) def cat(env, source, target): target = str(target[0]) open('cat.out', 'a').write(target + "\\n") @@ -61,8 +62,10 @@ test.write(['src', 'ccc.in'], "ccc.in\n") # This should populate the cache with our derived files. test.run(chdir = 'src', arguments = '.') -test.fail_test(test.read(['src', 'all']) != "aaa.in\nbbb.in\nccc.in\n") -test.fail_test(test.read(['src', 'cat.out']) != "aaa.out\nbbb.out\nccc.out\nall\n") +test.must_match(['src','all'],"aaa.in\nbbb.in\nccc.in\n", mode='r') +# test.fail_test(test.read(['src', 'all']) != "aaa.in\nbbb.in\nccc.in\n") +test.must_match(['src','cat.out'],"aaa.out\nbbb.out\nccc.out\nall\n", mode='r') +# test.fail_test(test.read(['src', 'cat.out']) != "aaa.out\nbbb.out\nccc.out\nall\n") test.up_to_date(chdir = 'src', arguments = '.') diff --git a/test/CacheDir/option--cr.py b/test/CacheDir/option--cr.py index 165e049..792dede 100644 --- a/test/CacheDir/option--cr.py +++ b/test/CacheDir/option--cr.py @@ -62,8 +62,8 @@ test.write(['src', 'ccc.in'], "ccc.in\n") # This should populate the cache with our derived files. test.run(chdir = 'src', arguments = '.') -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") -test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') +test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') @@ -80,7 +80,7 @@ Retrieved `ccc.out' from cache Retrieved `all' from cache """)) -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n") +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') test.must_not_exist(test.workpath('src', 'cat.out')) test.up_to_date(chdir = 'src', arguments = '.') @@ -100,9 +100,9 @@ Retrieved `ccc.out' from cache cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) """)) -test.must_match(['src', 'all'], "aaa.rebuild\nbbb.in\nccc.in\n") +test.must_match(['src', 'all'], "aaa.rebuild\nbbb.in\nccc.in\n", mode='r') # cat.out contains only the things we built (not got from cache) -test.must_match(['src', 'cat.out'], "aaa.out\nall\n") +test.must_match(['src', 'cat.out'], "aaa.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') @@ -120,8 +120,8 @@ Retrieved `ccc.out' from cache cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) """)) -test.must_match(['src', 'all'], "aaa.rebuild\nbbb.in\nccc.in\n") -test.must_match(['src', 'cat.out'], "aaa.out\nall\n") +test.must_match(['src', 'all'], "aaa.rebuild\nbbb.in\nccc.in\n", mode='r') +test.must_match(['src', 'cat.out'], "aaa.out\nall\n", mode='r') test.up_to_date(chdir = 'src', arguments = '.') diff --git a/test/CacheDir/option--cs.py b/test/CacheDir/option--cs.py index bff585d..2e37e5a 100644 --- a/test/CacheDir/option--cs.py +++ b/test/CacheDir/option--cs.py @@ -79,9 +79,9 @@ test.write(['src1', 'ccc.in'], "ccc.in\n") # This should populate the cache with our derived files. test.run(chdir = 'src1', arguments = '.') -test.must_match(['src1', 'all'], "aaa.in\nbbb.in\nccc.in\n") +test.must_match(['src1', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') -test.must_match(['src1', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n") +test.must_match(['src1', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n", mode='r') test.up_to_date(chdir = 'src1', arguments = '.') @@ -145,7 +145,7 @@ test.run(chdir = 'src1', arguments = '--cache-show -s .', stdout = "") -test.must_match(['src1', 'all'], "aaa.in\nbbb.in\nccc.in\n") +test.must_match(['src1', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') test.must_not_exist(test.workpath('src1', 'cat.out')) # diff --git a/test/CacheDir/symlink.py b/test/CacheDir/symlink.py index ca3bbe2..e23c25e 100644 --- a/test/CacheDir/symlink.py +++ b/test/CacheDir/symlink.py @@ -21,6 +21,10 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +import os +import sys + +import TestSCons __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -29,13 +33,13 @@ Verify that we push and retrieve a built symlink to/from a CacheDir() as an actualy symlink, not by copying the file contents. """ -import os -import TestSCons + test = TestSCons.TestSCons() -if not hasattr(os, 'symlink'): +if not hasattr(os, 'symlink') or sys.platform == 'win32': + # Skip test on windows as well, because this requires permissions which aren't default import sys test.skip_test('%s has no os.symlink() method; skipping test\n' % sys.executable) -- cgit v0.12 From fac6a93b2fef46b7f0e66caf0dc4cc98d27fa2fb Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 12 Mar 2017 18:35:12 -0400 Subject: py2/3 fix mostly adding mode='r' to must_match --- test/DVIPDF/DVIPDFFLAGS.py | 12 ++++++------ test/DVIPS/DVIPSFLAGS.py | 14 +++++++------- test/Rpcgen/RPCGEN.py | 14 +++++++------- test/Rpcgen/RPCGENCLIENTFLAGS.py | 8 ++++---- test/Rpcgen/RPCGENFLAGS.py | 8 ++++---- test/Rpcgen/RPCGENHEADERFLAGS.py | 8 ++++---- test/Rpcgen/RPCGENSERVICEFLAGS.py | 8 ++++---- test/Rpcgen/RPCGENXDRFLAGS.py | 8 ++++---- 8 files changed, 40 insertions(+), 40 deletions(-) diff --git a/test/DVIPDF/DVIPDFFLAGS.py b/test/DVIPDF/DVIPDFFLAGS.py index 51a4c42..b8c53c9 100644 --- a/test/DVIPDF/DVIPDFFLAGS.py +++ b/test/DVIPDF/DVIPDFFLAGS.py @@ -100,9 +100,9 @@ test.write('test2.tex', r"""This is a .tex test. test.run(arguments = '.', stderr = None) -test.must_match('test1.pdf', " -x\nThis is a .dvi test.\n") +test.must_match('test1.pdf', " -x\nThis is a .dvi test.\n", mode='r') -test.must_match('test2.pdf', " -x\nThis is a .tex test.\n") +test.must_match('test2.pdf', " -x\nThis is a .tex test.\n", mode='r') @@ -149,21 +149,21 @@ This is the %s LaTeX file. test.write('bar.tex', tex % 'bar.tex') - test.run(arguments = 'foo.pdf', stderr = None) + test.run(arguments='foo.pdf', stderr=None) test.must_not_exist(test.workpath('wrapper.out')) test.must_exist(test.workpath('foo.pdf')) - test.run(arguments = 'xxx.pdf', stderr = None) + test.run(arguments='xxx.pdf', stderr=None) test.must_not_exist(test.workpath('wrapper.out')) test.must_not_exist(test.workpath('xxx.dvi')) - test.run(arguments = 'bar.pdf', stderr = None) + test.run(arguments='bar.pdf', stderr=None) - test.must_match('wrapper.out', "dvipdf bar.dvi bar.pdf\n") + test.must_match('wrapper.out', "dvipdf bar.dvi bar.pdf\n", mode='r') test.must_exist(test.workpath('bar.pdf')) diff --git a/test/DVIPS/DVIPSFLAGS.py b/test/DVIPS/DVIPSFLAGS.py index 7aedf24..814c8aa 100644 --- a/test/DVIPS/DVIPSFLAGS.py +++ b/test/DVIPS/DVIPSFLAGS.py @@ -112,13 +112,13 @@ test.write('test4.latex', r"""This is a .latex test. test.run(arguments = '.', stderr = None) -test.must_match('test1.ps', " -x\nThis is a .dvi test.\n") +test.must_match('test1.ps', " -x\nThis is a .dvi test.\n", mode='r') -test.must_match('test2.ps', " -x\nThis is a .tex test.\n") +test.must_match('test2.ps', " -x\nThis is a .tex test.\n", mode='r') -test.must_match('test3.ps', " -x\nThis is a .ltx test.\n") +test.must_match('test3.ps', " -x\nThis is a .ltx test.\n", mode='r') -test.must_match('test4.ps', " -x\nThis is a .latex test.\n") +test.must_match('test4.ps', " -x\nThis is a .latex test.\n", mode='r') dvips = test.where_is('dvips') @@ -161,20 +161,20 @@ This is the %s LaTeX file. test.write('bar2.ltx', latex % 'bar2.ltx') test.write('bar3.latex', latex % 'bar3.latex') - test.run(arguments = 'foo.dvi', stderr = None) + test.run(arguments='foo.dvi', stderr=None) test.must_not_exist(test.workpath('wrapper.out')) test.must_exist(test.workpath('foo.dvi')) - test.run(arguments = 'bar1.ps bar2.ps bar3.ps', stderr = None) + test.run(arguments='bar1.ps bar2.ps bar3.ps', stderr=None) expect = """dvips -o bar1.ps bar1.dvi dvips -o bar2.ps bar2.dvi dvips -o bar3.ps bar3.dvi """ - test.must_match('wrapper.out', expect) + test.must_match('wrapper.out', expect, mode='r') test.must_exist(test.workpath('bar1.ps')) test.must_exist(test.workpath('bar2.ps')) diff --git a/test/Rpcgen/RPCGEN.py b/test/Rpcgen/RPCGEN.py index f79e18e..2f793e2 100644 --- a/test/Rpcgen/RPCGEN.py +++ b/test/Rpcgen/RPCGEN.py @@ -26,10 +26,10 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -_python_ = TestSCons._python_ -_exe = TestSCons._exe +_python_=TestSCons._python_ +_exe=TestSCons._exe -test = TestSCons.TestSCons() +test=TestSCons.TestSCons() @@ -68,10 +68,10 @@ expect_h = output % ('-h', test.workpath('rpcif.h')) expect_svc = output % ('-m', test.workpath('rpcif_svc.c')) expect_xdr = output % ('-c', test.workpath('rpcif_xdr.c')) -test.must_match('rpcif_clnt.c', expect_clnt) -test.must_match('rpcif.h', expect_h) -test.must_match('rpcif_svc.c', expect_svc) -test.must_match('rpcif_xdr.c', expect_xdr) +test.must_match('rpcif_clnt.c', expect_clnt, mode='r') +test.must_match('rpcif.h', expect_h, mode='r') +test.must_match('rpcif_svc.c', expect_svc, mode='r') +test.must_match('rpcif_xdr.c', expect_xdr, mode='r') diff --git a/test/Rpcgen/RPCGENCLIENTFLAGS.py b/test/Rpcgen/RPCGENCLIENTFLAGS.py index 9440d57..9612952 100644 --- a/test/Rpcgen/RPCGENCLIENTFLAGS.py +++ b/test/Rpcgen/RPCGENCLIENTFLAGS.py @@ -71,10 +71,10 @@ expect_h = output % ('-h', test.workpath('rpcif.h')) expect_svc = output % ('-m', test.workpath('rpcif_svc.c')) expect_xdr = output % ('-c', test.workpath('rpcif_xdr.c')) -test.must_match('rpcif_clnt.c', expect_clnt) -test.must_match('rpcif.h', expect_h) -test.must_match('rpcif_svc.c', expect_svc) -test.must_match('rpcif_xdr.c', expect_xdr) +test.must_match('rpcif_clnt.c', expect_clnt, mode='r') +test.must_match('rpcif.h', expect_h, mode='r') +test.must_match('rpcif_svc.c', expect_svc, mode='r') +test.must_match('rpcif_xdr.c', expect_xdr, mode='r') diff --git a/test/Rpcgen/RPCGENFLAGS.py b/test/Rpcgen/RPCGENFLAGS.py index b94ffe5..d4be92c 100644 --- a/test/Rpcgen/RPCGENFLAGS.py +++ b/test/Rpcgen/RPCGENFLAGS.py @@ -70,10 +70,10 @@ expect_h = output % ('-h', test.workpath('rpcif.h')) expect_svc = output % ('-m', test.workpath('rpcif_svc.c')) expect_xdr = output % ('-c', test.workpath('rpcif_xdr.c')) -test.must_match('rpcif_clnt.c', expect_clnt) -test.must_match('rpcif.h', expect_h) -test.must_match('rpcif_svc.c', expect_svc) -test.must_match('rpcif_xdr.c', expect_xdr) +test.must_match('rpcif_clnt.c', expect_clnt, mode='r') +test.must_match('rpcif.h', expect_h, mode='r') +test.must_match('rpcif_svc.c', expect_svc, mode='r') +test.must_match('rpcif_xdr.c', expect_xdr, mode='r') diff --git a/test/Rpcgen/RPCGENHEADERFLAGS.py b/test/Rpcgen/RPCGENHEADERFLAGS.py index f65da8e..4beca64 100644 --- a/test/Rpcgen/RPCGENHEADERFLAGS.py +++ b/test/Rpcgen/RPCGENHEADERFLAGS.py @@ -71,10 +71,10 @@ expect_h = output_h % ('-h', test.workpath('rpcif.h')) expect_svc = output % ('-m', test.workpath('rpcif_svc.c')) expect_xdr = output % ('-c', test.workpath('rpcif_xdr.c')) -test.must_match('rpcif_clnt.c', expect_clnt) -test.must_match('rpcif.h', expect_h) -test.must_match('rpcif_svc.c', expect_svc) -test.must_match('rpcif_xdr.c', expect_xdr) +test.must_match('rpcif_clnt.c', expect_clnt, mode='r') +test.must_match('rpcif.h', expect_h, mode='r') +test.must_match('rpcif_svc.c', expect_svc, mode='r') +test.must_match('rpcif_xdr.c', expect_xdr, mode='r') diff --git a/test/Rpcgen/RPCGENSERVICEFLAGS.py b/test/Rpcgen/RPCGENSERVICEFLAGS.py index a956d4f..7644485 100644 --- a/test/Rpcgen/RPCGENSERVICEFLAGS.py +++ b/test/Rpcgen/RPCGENSERVICEFLAGS.py @@ -71,10 +71,10 @@ expect_h = output % ('-h', test.workpath('rpcif.h')) expect_svc = output_svc % ('-m', test.workpath('rpcif_svc.c')) expect_xdr = output % ('-c', test.workpath('rpcif_xdr.c')) -test.must_match('rpcif_clnt.c', expect_clnt) -test.must_match('rpcif.h', expect_h) -test.must_match('rpcif_svc.c', expect_svc) -test.must_match('rpcif_xdr.c', expect_xdr) +test.must_match('rpcif_clnt.c', expect_clnt, mode='r') +test.must_match('rpcif.h', expect_h, mode='r') +test.must_match('rpcif_svc.c', expect_svc, mode='r') +test.must_match('rpcif_xdr.c', expect_xdr, mode='r') diff --git a/test/Rpcgen/RPCGENXDRFLAGS.py b/test/Rpcgen/RPCGENXDRFLAGS.py index 0dc1366..41da70c 100644 --- a/test/Rpcgen/RPCGENXDRFLAGS.py +++ b/test/Rpcgen/RPCGENXDRFLAGS.py @@ -71,10 +71,10 @@ expect_h = output % ('-h', test.workpath('rpcif.h')) expect_svc = output % ('-m', test.workpath('rpcif_svc.c')) expect_xdr = output_xdr % ('-c', test.workpath('rpcif_xdr.c')) -test.must_match('rpcif_clnt.c', expect_clnt) -test.must_match('rpcif.h', expect_h) -test.must_match('rpcif_svc.c', expect_svc) -test.must_match('rpcif_xdr.c', expect_xdr) +test.must_match('rpcif_clnt.c', expect_clnt, mode='r') +test.must_match('rpcif.h', expect_h, mode='r') +test.must_match('rpcif_svc.c', expect_svc, mode='r') +test.must_match('rpcif_xdr.c', expect_xdr, mode='r') -- cgit v0.12 From 8bbebd78a9c00d713f3b53d5e3bbd1df28cb2e74 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 12 Mar 2017 18:39:53 -0400 Subject: py2/3 fix mode=r for must_match to fix win32 --- test/Requires/eval-order.py | 6 +++--- test/subdivide.py | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/test/Requires/eval-order.py b/test/Requires/eval-order.py index 8600221..696b5e9 100644 --- a/test/Requires/eval-order.py +++ b/test/Requires/eval-order.py @@ -53,10 +53,10 @@ test.write('prereq.in', "prereq.in 1\n") # not, we'll get an error when the build action tries to use it to # build file.out. -test.run(arguments = 'file.out') +test.run(arguments='file.out') -test.must_match('prereq.out', "prereq.in 1\n") -test.must_match('file.out', "file.in 1\n") +test.must_match('prereq.out', "prereq.in 1\n", mode='r') +test.must_match('file.out', "file.in 1\n", mode='r') test.pass_test() diff --git a/test/subdivide.py b/test/subdivide.py index 770870d..8c8eff0 100644 --- a/test/subdivide.py +++ b/test/subdivide.py @@ -80,6 +80,7 @@ test.chmod(fake_cc_py, 0o755) test.chmod(fake_link_py, 0o755) test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) SConsignFile(None) env = Environment(PROGSUFFIX = '.exe', OBJSUFFIX = '.obj', @@ -91,6 +92,7 @@ env.Object('foo.c') """ % locals()) test.write(['src', 'SConstruct'], """\ +DefaultEnvironment(tools=[]) SConsignFile(None) env = Environment(PROGSUFFIX = '.exe', OBJSUFFIX = '.obj', @@ -134,7 +136,7 @@ src/sub/bar.c if os.sep == '\\': expect = expect.replace('\\', '\\\\') -test.must_match(['src', 'prog.exe'], expect) +test.must_match(['src', 'prog.exe'], expect, mode='r') test.up_to_date(chdir='src', arguments = test.workpath()) -- cgit v0.12 From 5304f2d061f336e7ee6dcc45b07d4271fb6be21f Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 12 Mar 2017 18:46:25 -0400 Subject: fix rb/wb py2/3 --- test/Command.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/Command.py b/test/Command.py index 5f72c94..49b9117 100644 --- a/test/Command.py +++ b/test/Command.py @@ -35,8 +35,8 @@ test.subdir('sub') test.write('build.py', r""" import sys -contents = open(sys.argv[2], 'rb').read() -file = open(sys.argv[1], 'wb') +contents = open(sys.argv[2], 'r').read() +file = open(sys.argv[1], 'w') file.write(contents) file.close() """) @@ -45,8 +45,8 @@ test.write('SConstruct', """ import os def buildIt(env, target, source): - contents = open(str(source[0]), 'rb').read() - file = open(str(target[0]), 'wb') + contents = open(str(source[0]), 'r').read() + file = open(str(target[0]), 'w') xyzzy = env.get('XYZZY', '') if xyzzy: file.write(xyzzy + '\\n') @@ -57,9 +57,9 @@ def buildIt(env, target, source): def sub(env, target, source): target = str(target[0]) source = str(source[0]) - t = open(target, 'wb') + t = open(target, 'w') for f in sorted(os.listdir(source)): - t.write(open(os.path.join(source, f), 'rb').read()) + t.write(open(os.path.join(source, f), 'r').read()) t.close() return 0 -- cgit v0.12 From 60e00b62a9c494cc9c31e7cb95f65d0c22b9e777 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 12 Mar 2017 18:48:07 -0400 Subject: py2/3 fix mode=r for must_match to fix win32 --- test/Command.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/Command.py b/test/Command.py index 49b9117..38aceb5 100644 --- a/test/Command.py +++ b/test/Command.py @@ -103,16 +103,16 @@ test.write('f10.in', "f10.in\n") test.run(arguments = '.') -test.must_match('f1.out', "f1.in\n") -test.must_match('f2.out', "f2.in\n") -test.must_match('f3.out', "f3.in\n") -test.must_match('f4.out', "sub/f4a\nsub/f4b\nsub/f4c\n") -test.must_match('f5.out', "XYZZY is set\nf5.in\n") -test.must_match('f6.out', "f6.in\n") -test.must_match('f7.out', "f7.in\n") -test.must_match('f8.out', "f8.in\n") -test.must_match('f9.out', "f9.in\n") -test.must_match('f10.out', "f10.in\n") +test.must_match('f1.out', "f1.in\n", mode='r') +test.must_match('f2.out', "f2.in\n", mode='r') +test.must_match('f3.out', "f3.in\n", mode='r') +test.must_match('f4.out', "sub/f4a\nsub/f4b\nsub/f4c\n", mode='r') +test.must_match('f5.out', "XYZZY is set\nf5.in\n", mode='r') +test.must_match('f6.out', "f6.in\n", mode='r') +test.must_match('f7.out', "f7.in\n", mode='r') +test.must_match('f8.out', "f8.in\n", mode='r') +test.must_match('f9.out', "f9.in\n", mode='r') +test.must_match('f10.out', "f10.in\n", mode='r') test.pass_test() -- cgit v0.12 From 77640a33ca2963d88320208895a3de193712566b Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 12 Mar 2017 18:58:48 -0400 Subject: no more cmp in py3, define a compare function and use it. Also specify DefaultEnvironment(tools=[]) to speed up the test slightly --- test/Deprecated/Options/Options.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/Deprecated/Options/Options.py b/test/Deprecated/Options/Options.py index e435b9e..2a2d26c 100644 --- a/test/Deprecated/Options/Options.py +++ b/test/Deprecated/Options/Options.py @@ -29,6 +29,7 @@ import TestSCons test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) test.write('SConstruct', """ +DefaultEnvironment(tools=[]) env = Environment() print(env['CC']) print(" ".join(env['CCFLAGS'])) @@ -38,6 +39,7 @@ test.run() cc, ccflags = test.stdout().split('\n')[1:3] test.write('SConstruct', """ +DefaultEnvironment(tools=[]) # test validator. Change a key and add a new one to the environment def validator(key, value, environ): environ[key] = "v" @@ -208,6 +210,8 @@ Use scons -H for help about command-line options. # Test saving of options and multi loading # test.write('SConstruct', """ +DefaultEnvironment(tools=[]) + opts = Options(['custom.py', 'options.saved']) opts.Add('RELEASE_BUILD', 'Set to 1 to build a release build', @@ -259,6 +263,8 @@ checkSave('options.saved', {'DEBUG_BUILD':3, 'RELEASE_BUILD':1}) # Load no options from file(s) # Used to test for correct output in save option file test.write('SConstruct', """ +DefaultEnvironment(tools=[]) + opts = Options() opts.Add('RELEASE_BUILD', 'Set to 1 to build a release build', @@ -305,6 +311,8 @@ check(['0','0']) checkSave('options.saved',{'DEBUG_BUILD':0, 'LISTOPTION_TEST':'a,b'}) test.write('SConstruct', """ +DefaultEnvironment(tools=[]) + opts = Options('custom.py') opts.Add('RELEASE_BUILD', 'Set to 1 to build a release build', @@ -326,7 +334,10 @@ opts.Add('UNSPECIFIED', env = Environment(options=opts) -Help('Variables settable in custom.py or on the command line:\\n' + opts.GenerateHelpText(env,sort=cmp)) +def compare(a,b): + return a < b + +Help('Variables settable in custom.py or on the command line:\\n' + opts.GenerateHelpText(env,sort=compare)) """) @@ -357,6 +368,8 @@ Use scons -H for help about command-line options. stderr=warnings) test.write('SConstruct', """ +DefaultEnvironment(tools=[]) + import SCons.Options env1 = Environment(options = Options()) env2 = Environment(options = SCons.Options.Options()) -- cgit v0.12 From 63da1b9c6083285e5c4d92126ad2e173d34cef6b Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 12 Mar 2017 19:04:29 -0400 Subject: no unicode in py3, u() works in py2 --- src/engine/SCons/Util.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 018a776..9d125ae 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -271,6 +271,7 @@ def render_tree(root, child_func, prune=0, margin=[0], visited=None): IDX = lambda N: N and 1 or 0 + def print_tree(root, child_func, prune=0, showtags=0, margin=[0], visited=None): """ Print a tree of nodes. This is like render_tree, except it prints @@ -307,7 +308,7 @@ def print_tree(root, child_func, prune=0, showtags=0, margin=[0], visited=None): ' N = no clean\n' + ' H = no cache\n' + '\n') - sys.stdout.write(unicode(legend)) + sys.stdout.write(u(legend)) tags = ['['] tags.append(' E'[IDX(root.exists())]) -- cgit v0.12 From d8c8ae8fd87952d4cb334c4a634087503c40673e Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 12 Mar 2017 19:06:43 -0400 Subject: py2/3 mode=r and swap to use must_match --- test/CXX/SHCXX.py | 3 ++- test/CommandGenerator.py | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/test/CXX/SHCXX.py b/test/CXX/SHCXX.py index d6a314e..0d1ad36 100644 --- a/test/CXX/SHCXX.py +++ b/test/CXX/SHCXX.py @@ -73,7 +73,8 @@ test.fail_test(os.path.exists(test.workpath('wrapper.out'))) test.run(arguments = 'bar') -test.fail_test(test.read('wrapper.out') != "wrapper.py\n") +test.must_match('wrapper.out', "wrapper.py\n", mode='r') +# test.fail_test(test.read('wrapper.out') != "wrapper.py\n") test.pass_test() diff --git a/test/CommandGenerator.py b/test/CommandGenerator.py index 063999d..a3a995b 100644 --- a/test/CommandGenerator.py +++ b/test/CommandGenerator.py @@ -34,8 +34,8 @@ test = TestSCons.TestSCons() test.write('build.py', r""" import sys -contents = open(sys.argv[2], 'rb').read() -file = open(sys.argv[1], 'wb') +contents = open(sys.argv[2], 'r').read() +file = open(sys.argv[1], 'w') file.write(contents) file.close() sys.exit(0) @@ -64,9 +64,9 @@ test.write('foo3.in', "foo3.in\n") test.run(arguments = 'foo1.out foo2.out foo3.out') -test.fail_test(test.read(test.workpath('foo1.out')) != "foo1.in\n") -test.fail_test(test.read(test.workpath('foo2.out')) != "foo2.in\n") -test.fail_test(test.read(test.workpath('foo3.out')) != "foo3.in\n") +test.must_match('foo1.out','foo1.in\n', mode='r') +test.must_match('foo2.out','foo2.in\n', mode='r') +test.must_match('foo3.out','foo3.in\n', mode='r') test.pass_test() -- cgit v0.12 From d6823296e39adc6f147ae64f9be6ce64b8bb4a3e Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Sun, 12 Mar 2017 16:21:07 -0700 Subject: Fix some bytes/str issues to fix py2/3. --- test/DSUFFIXES.py | 4 ++-- test/DVIPDF/DVIPDFFLAGS.py | 4 ++-- test/DVIPS/DVIPSFLAGS.py | 4 ++-- test/Dir/source.py | 2 +- test/Ghostscript/GS.py | 6 +++--- test/Ghostscript/GSFLAGS.py | 6 +++--- test/HeaderGen.py | 6 +++--- test/Install/Install.py | 4 ++-- test/Repository/LIBPATH.py | 2 +- test/Value.py | 4 ++-- test/VariantDir/Clean.py | 2 +- test/VariantDir/File-create.py | 4 ++-- test/VariantDir/errors.py | 2 +- test/explain/get_csig.py | 2 +- test/gnutools.py | 46 +++++++++++++++++++++--------------------- 15 files changed, 49 insertions(+), 49 deletions(-) diff --git a/test/DSUFFIXES.py b/test/DSUFFIXES.py index bc441a5..46bdf83 100644 --- a/test/DSUFFIXES.py +++ b/test/DSUFFIXES.py @@ -38,8 +38,8 @@ test.write('mydc.py', r""" import sys def do_file(outf, inf): for line in open(inf, 'rb').readlines(): - if line[:7] == 'import ': - do_file(outf, line[7:-2]+'.d') + if line[:7] == b'import ': + do_file(outf, line[7:-2] + b'.d') else: outf.write(line) outf = open(sys.argv[1], 'wb') diff --git a/test/DVIPDF/DVIPDFFLAGS.py b/test/DVIPDF/DVIPDFFLAGS.py index 51a4c42..3704d60 100644 --- a/test/DVIPDF/DVIPDFFLAGS.py +++ b/test/DVIPDF/DVIPDFFLAGS.py @@ -55,7 +55,7 @@ base_name = os.path.splitext(arg[0])[0] infile = open(arg[0], 'r') out_file = open(base_name+'.dvi', 'w') for l in infile.readlines(): - if l[:6] != '#latex': + if l[:6] != b'#latex': out_file.write(l) sys.exit(0) """) @@ -114,7 +114,7 @@ if dvipdf and tex: test.write("wrapper.py", """import os import sys cmd = " ".join(sys.argv[1:]) -open('%s', 'ab').write("%%s\\n" %% cmd) +open('%s', 'a').write("%%s\\n" %% cmd) os.system(cmd) """ % test.workpath('wrapper.out').replace('\\', '\\\\')) diff --git a/test/DVIPS/DVIPSFLAGS.py b/test/DVIPS/DVIPSFLAGS.py index 7aedf24..43b5be5 100644 --- a/test/DVIPS/DVIPSFLAGS.py +++ b/test/DVIPS/DVIPSFLAGS.py @@ -41,7 +41,7 @@ base_name = os.path.splitext(arg[0])[0] infile = open(arg[0], 'r') out_file = open(base_name+'.dvi', 'w') for l in infile.readlines(): - if l[:4] != '#tex': + if l[:4] != b'#tex': out_file.write(l) sys.exit(0) """) @@ -55,7 +55,7 @@ base_name = os.path.splitext(arg[0])[0] infile = open(arg[0], 'r') out_file = open(base_name+'.dvi', 'w') for l in infile.readlines(): - if l[:6] != '#latex': + if l[:6] != b'#latex': out_file.write(l) sys.exit(0) """) diff --git a/test/Dir/source.py b/test/Dir/source.py index 8dbee1a..8e3bea6 100644 --- a/test/Dir/source.py +++ b/test/Dir/source.py @@ -44,7 +44,7 @@ test.subdir('tstamp', [ 'tstamp', 'subdir' ], test.write('SConstruct', """\ def writeTarget(target, source, env): f=open(str(target[0]), 'wb') - f.write("stuff\\n") + f.write(b"stuff\\n") f.close() return 0 diff --git a/test/Ghostscript/GS.py b/test/Ghostscript/GS.py index daeea09..d7a7456 100644 --- a/test/Ghostscript/GS.py +++ b/test/Ghostscript/GS.py @@ -41,7 +41,7 @@ import sys outfile = open(sys.argv[1], 'wb') infile = open(sys.argv[2], 'rb') for l in infile.readlines(): - if l[:3] != '#ps': + if l[:3] != b'#ps': outfile.write(l) sys.exit(0) """) @@ -60,8 +60,8 @@ test.write('test1.ps', r"""This is a .ps test. test.run(arguments = '.', stderr = None) -test.fail_test(test.read('test1.pdf') != "This is a .ps test.\n") -test.fail_test(test.read('test2.pdf') != "This is a .ps test.\n") +test.fail_test(test.read('test1.pdf') != b"This is a .ps test.\n") +test.fail_test(test.read('test2.pdf') != b"This is a .ps test.\n") diff --git a/test/Ghostscript/GSFLAGS.py b/test/Ghostscript/GSFLAGS.py index c8e0668..2e58ec1 100644 --- a/test/Ghostscript/GSFLAGS.py +++ b/test/Ghostscript/GSFLAGS.py @@ -48,9 +48,9 @@ for opt, arg in cmd_opts: else: opt_string = opt_string + ' ' + opt infile = open(args[0], 'rb') -out_file.write(opt_string + "\n") +out_file.write(opt_string.encode("utf-8") + b"\n") for l in infile.readlines(): - if l[:3] != '#ps': + if l[:3] != b'#ps': out_file.write(l) sys.exit(0) """) @@ -68,7 +68,7 @@ This is a .ps test. test.run(arguments = '.', stderr = None) -test.fail_test(test.read('test1.pdf') != " -x\nThis is a .ps test.\n") +test.fail_test(test.read('test1.pdf') != b" -x\nThis is a .ps test.\n") diff --git a/test/HeaderGen.py b/test/HeaderGen.py index 5a7fdbe..2763b34 100644 --- a/test/HeaderGen.py +++ b/test/HeaderGen.py @@ -35,7 +35,7 @@ test = TestSCons.TestSCons() test.write('SConstruct', """\ def writeFile(target, contents): - file = open(str(target[0]), 'wb') + file = open(str(target[0]), 'w') file.write(contents) file.close() return 0 @@ -60,8 +60,8 @@ test.write('SConstruct', """\ env = Environment() def gen_a_h(target, source, env): - t = open(str(target[0]), 'wb') - s = open(str(source[0]), 'rb') + t = open(str(target[0]), 'w') + s = open(str(source[0]), 'r') s.readline() t.write(s.readline()[:-1] + ';\\n') diff --git a/test/Install/Install.py b/test/Install/Install.py index d66660b..8c3bccd 100644 --- a/test/Install/Install.py +++ b/test/Install/Install.py @@ -58,7 +58,7 @@ def cat(env, source, target): def my_install(dest, source, env): import shutil shutil.copy2(source, dest) - open('my_install.out', 'ab').write(dest) + open('my_install.out', 'a').write(dest) env1 = Environment() env1.Append(BUILDERS={'Cat':Builder(action=cat)}) @@ -122,7 +122,7 @@ test.fail_test(oldtime1 == os.path.getmtime(f1_out)) test.fail_test(oldtime2 != os.path.getmtime(f2_out)) # Verify that we didn't link to the Installed file. -open(f2_out, 'wb').write("xyzzy\n") +open(f2_out, 'wb').write(b"xyzzy\n") test.must_match(['work', 'f2.out'], "f2.in\n") # Verify that scons prints an error message diff --git a/test/Repository/LIBPATH.py b/test/Repository/LIBPATH.py index c95d29a..166060e 100644 --- a/test/Repository/LIBPATH.py +++ b/test/Repository/LIBPATH.py @@ -46,7 +46,7 @@ bbb_exe = env_yyy.Program('bbb', 'bbb.c') def write_LIBDIRFLAGS(env, target, source): pre = env.subst('$LIBDIRPREFIX') suf = env.subst('$LIBDIRSUFFIX') - f = open(str(target[0]), 'wb') + f = open(str(target[0]), 'w') for arg in env.subst('$_LIBDIRFLAGS', target=target).split(): if arg[:len(pre)] == pre: arg = arg[len(pre):] diff --git a/test/Value.py b/test/Value.py index 7abe758..34b036b 100644 --- a/test/Value.py +++ b/test/Value.py @@ -59,7 +59,7 @@ env.B('f3.out', Value(C)) env.S('f4.out', Value(L)) def create_value (target, source, env): - target[0].write(source[0].get_contents ()) + target[0].write(source[0].get_contents()) def create_value_file (target, source, env): open(str(target[0]), 'wb').write(source[0].read()) @@ -75,7 +75,7 @@ env.B3('f5.out', V) test.write('put.py', """\ import os import sys -open(sys.argv[-1],'wb').write(" ".join(sys.argv[1:-2])) +open(sys.argv[-1],'w').write(" ".join(sys.argv[1:-2])) """) # Run all of the tests with both types of source signature diff --git a/test/VariantDir/Clean.py b/test/VariantDir/Clean.py index d1e0bb8..ca14738 100644 --- a/test/VariantDir/Clean.py +++ b/test/VariantDir/Clean.py @@ -44,7 +44,7 @@ def build_sample(target, source, env): targetdir = str(target[0].dir) target = str(target[0]) open(target, 'wb').write(open(str(source[0]), 'rb').read()) - open(targetdir+'/sample.junk', 'wb').write('Side effect!\\n') + open(targetdir+'/sample.junk', 'wb').write(b'Side effect!\\n') t0 = Command("build0/sample.out", "sample.in", build_sample) t1 = Command("build1/sample.out", "sample.in", build_sample) diff --git a/test/VariantDir/File-create.py b/test/VariantDir/File-create.py index 725404c..1386020 100644 --- a/test/VariantDir/File-create.py +++ b/test/VariantDir/File-create.py @@ -49,12 +49,12 @@ SConscript('src/SConscript', variant_dir='build1', chdir=1, duplicate=1) test.write(['src', 'SConscript'], """\ #f1_in = File('f1.in') #Command('f1.out', f1_in, Copy('$TARGET', '$SOURCE')) -#open('f1.in', 'wb').write("f1.in\\n") +#open('f1.in', 'wb').write(b"f1.in\\n") f2_in = File('f2.in') str(f2_in) Command('f2.out', f2_in, Copy('$TARGET', '$SOURCE')) -open('f2.in', 'wb').write("f2.in\\n") +open('f2.in', 'wb').write(b"f2.in\\n") """) test.run(arguments = '--tree=all .') diff --git a/test/VariantDir/errors.py b/test/VariantDir/errors.py index d1490d4..256734e 100644 --- a/test/VariantDir/errors.py +++ b/test/VariantDir/errors.py @@ -77,7 +77,7 @@ env.Build('file.out', 'file.in') # Just verify that the normal case works fine. test.run(chdir = 'normal', arguments = ".") -test.fail_test(test.read(['normal', 'build', 'file.out']) != "normal/src/file.in\n") +test.fail_test(test.read(['normal', 'build', 'file.out']) != b"normal/src/file.in\n") # Verify the error when the VariantDir itself is read-only. Don't bother # to test this on Windows, because the ACL (I think) still allows the diff --git a/test/explain/get_csig.py b/test/explain/get_csig.py index d35a315..8a0266a 100644 --- a/test/explain/get_csig.py +++ b/test/explain/get_csig.py @@ -43,7 +43,7 @@ env = Environment() def action( source, target, env ): target[0].get_csig() - f = open( str(target[0]), 'w' ) + f = open( str(target[0]), 'wb' ) for s in source: f.write( s.get_contents() ) f.close() diff --git a/test/gnutools.py b/test/gnutools.py index b0ebc1c..65d699b 100644 --- a/test/gnutools.py +++ b/test/gnutools.py @@ -49,11 +49,11 @@ cmd_opts, args = getopt.getopt(sys.argv[1:], 'f:s:co:', []) output = None opt_string = '' for opt, arg in cmd_opts: - if opt == '-o': output = open(arg, 'wb') + if opt == '-o': output = open(arg, 'w') else: opt_string = opt_string + ' ' + opt + arg output.write('gcc ' + opt_string + '\\n') for a in args: - contents = open(a, 'rb').read() + contents = open(a, 'r').read() output.write(contents) output.close() sys.exit(0) @@ -66,11 +66,11 @@ cmd_opts, args = getopt.getopt(sys.argv[1:], 'f:s:co:', []) output = None opt_string = '' for opt, arg in cmd_opts: - if opt == '-o': output = open(arg, 'wb') + if opt == '-o': output = open(arg, 'w') else: opt_string = opt_string + ' ' + opt + arg output.write('g++ ' + opt_string + '\\n') for a in args: - contents = open(a, 'rb').read() + contents = open(a, 'r').read() output.write(contents) output.close() sys.exit(0) @@ -116,31 +116,31 @@ test.run(chdir='work1') def testObject(test, obj, expect): contents = test.read(test.workpath('work1', obj)) - line1 = contents.split('\n')[0] - actual = ' '.join(line1.split()) + line1 = contents.split(b'\n')[0] + actual = b' '.join(line1.split()) if not expect == actual: print("%s: %s != %s\n" % (obj, repr(expect), repr(actual))) test.fail_test() if sys.platform in ('win32', 'cygwin'): - c_fpic = '' + c_fpic = b'' else: - c_fpic = ' -fPIC' - -testObject(test, 'cfile1.o', 'gcc -c') -testObject(test, 'cfile2.o', 'gcc -c') -testObject(test, 'cppfile1.o', 'g++ -c') -testObject(test, 'cppfile2.o', 'g++ -c') -testObject(test, 'cfile1.os', 'gcc -c' + c_fpic) -testObject(test, 'cfile2.os', 'gcc -c' + c_fpic) -testObject(test, 'cppfile1.os', 'g++ -c' + c_fpic) -testObject(test, 'cppfile2.os', 'g++ -c' + c_fpic) -testObject(test, 'c-only' + _exe, 'gcc') -testObject(test, 'cpp-only' + _exe, 'g++') -testObject(test, 'c-and-cpp' + _exe, 'g++') -testObject(test, dll('c-only'), 'gcc -shared') -testObject(test, dll('cpp-only'), 'g++ -shared') -testObject(test, dll('c-and-cpp'), 'g++ -shared') + c_fpic = b' -fPIC' + +testObject(test, 'cfile1.o', b'gcc -c') +testObject(test, 'cfile2.o', b'gcc -c') +testObject(test, 'cppfile1.o', b'g++ -c') +testObject(test, 'cppfile2.o', b'g++ -c') +testObject(test, 'cfile1.os', b'gcc -c' + c_fpic) +testObject(test, 'cfile2.os', b'gcc -c' + c_fpic) +testObject(test, 'cppfile1.os', b'g++ -c' + c_fpic) +testObject(test, 'cppfile2.os', b'g++ -c' + c_fpic) +testObject(test, 'c-only' + _exe, b'gcc') +testObject(test, 'cpp-only' + _exe, b'g++') +testObject(test, 'c-and-cpp' + _exe, b'g++') +testObject(test, dll('c-only'), b'gcc -shared') +testObject(test, dll('cpp-only'), b'g++ -shared') +testObject(test, dll('c-and-cpp'), b'g++ -shared') test.pass_test() -- cgit v0.12 From 7b63fc3c251725270516572ec1663d7b5157fca0 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 12 Mar 2017 19:46:59 -0400 Subject: switch to use must_match, mode=r, and get rid of rb/wb --- test/ENV.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/ENV.py b/test/ENV.py index 5cb2362..326f8c5 100644 --- a/test/ENV.py +++ b/test/ENV.py @@ -50,16 +50,18 @@ test.write('build.py', r"""#!/usr/bin/env python import os import sys -contents = open(sys.argv[2], 'rb').read() -open(sys.argv[1], 'wb').write("build.py %s\n%s" % (os.environ['X'], contents)) +contents = open(sys.argv[2], 'r').read() +open(sys.argv[1], 'w').write("build.py %s\n%s" % (os.environ['X'], contents)) """) test.write('input', "input file\n") test.run(arguments = '.') -test.fail_test(test.read('env1.out') != "build.py env1\ninput file\n") -test.fail_test(test.read('env2.out') != "build.py env2\ninput file\n") +test.must_match('env1.out', "build.py env1\ninput file\n", mode='r') +# test.fail_test(test.read('env1.out') != "build.py env1\ninput file\n") +test.must_match('env2.out', "build.py env2\ninput file\n", mode='r') +# test.fail_test(test.read('env2.out') != "build.py env2\ninput file\n") test.write('SConstruct', """ -- cgit v0.12 From c4af5550a346787ea81616048f091010cde3debd Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 12 Mar 2017 19:47:07 -0400 Subject: switch to use must_match, mode=r, and get rid of rb/wb --- test/ENV.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/ENV.py b/test/ENV.py index 326f8c5..59b1cdb 100644 --- a/test/ENV.py +++ b/test/ENV.py @@ -59,9 +59,7 @@ test.write('input', "input file\n") test.run(arguments = '.') test.must_match('env1.out', "build.py env1\ninput file\n", mode='r') -# test.fail_test(test.read('env1.out') != "build.py env1\ninput file\n") test.must_match('env2.out', "build.py env2\ninput file\n", mode='r') -# test.fail_test(test.read('env2.out') != "build.py env2\ninput file\n") test.write('SConstruct', """ -- cgit v0.12 From 2a815ecf9af4b2e05bbbd059f627cfa9e43a207d Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 12 Mar 2017 19:51:10 -0400 Subject: switch to use must_match, mode=r, and get rid of rb/wb --- test/Ghostscript/GSFLAGS.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Ghostscript/GSFLAGS.py b/test/Ghostscript/GSFLAGS.py index c8e0668..e1471fa 100644 --- a/test/Ghostscript/GSFLAGS.py +++ b/test/Ghostscript/GSFLAGS.py @@ -44,10 +44,10 @@ opt_string = '' for opt, arg in cmd_opts: if opt == '-s': if arg[:11] == 'OutputFile=': - out_file = open(arg[11:], 'wb') + out_file = open(arg[11:], 'w') else: opt_string = opt_string + ' ' + opt -infile = open(args[0], 'rb') +infile = open(args[0], 'r') out_file.write(opt_string + "\n") for l in infile.readlines(): if l[:3] != '#ps': @@ -68,7 +68,7 @@ This is a .ps test. test.run(arguments = '.', stderr = None) -test.fail_test(test.read('test1.pdf') != " -x\nThis is a .ps test.\n") +test.must_match('test1.pdf', " -x\nThis is a .ps test.\n", mode='r') -- cgit v0.12 From 4ebf54bf58ea17b50cae986c501bfa04338cba84 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 12 Mar 2017 19:53:42 -0400 Subject: get rid of rb/wb --- test/HeaderGen.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/HeaderGen.py b/test/HeaderGen.py index 5a7fdbe..2763b34 100644 --- a/test/HeaderGen.py +++ b/test/HeaderGen.py @@ -35,7 +35,7 @@ test = TestSCons.TestSCons() test.write('SConstruct', """\ def writeFile(target, contents): - file = open(str(target[0]), 'wb') + file = open(str(target[0]), 'w') file.write(contents) file.close() return 0 @@ -60,8 +60,8 @@ test.write('SConstruct', """\ env = Environment() def gen_a_h(target, source, env): - t = open(str(target[0]), 'wb') - s = open(str(source[0]), 'rb') + t = open(str(target[0]), 'w') + s = open(str(source[0]), 'r') s.readline() t.write(s.readline()[:-1] + ';\\n') -- cgit v0.12 From e9a52c074c4382ddaab5bee8054acc490bb00874 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 12 Mar 2017 19:54:59 -0400 Subject: get rid of rb/wb --- test/Dir/source.py | 14 +++++++------- test/IDL/MIDLCOM.py | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/test/Dir/source.py b/test/Dir/source.py index 8dbee1a..c272c8f 100644 --- a/test/Dir/source.py +++ b/test/Dir/source.py @@ -43,7 +43,7 @@ test.subdir('tstamp', [ 'tstamp', 'subdir' ], test.write('SConstruct', """\ def writeTarget(target, source, env): - f=open(str(target[0]), 'wb') + f=open(str(target[0]), 'w') f.write("stuff\\n") f.close() return 0 @@ -92,12 +92,12 @@ test.write([ 'cmd-content', 'subdir', '#hash.txt' ], 'hash.txt 1\n') test.write('junk.txt', 'junk.txt\n') test.run(arguments=".", stderr=None) -test.must_match('tstamp.out', 'stuff\n') -test.must_match('content.out', 'stuff\n') -test.must_match('cmd-tstamp.out', 'stuff\n') -test.must_match('cmd-content.out', 'stuff\n') -test.must_match('cmd-tstamp-noscan.out', 'stuff\n') -test.must_match('cmd-content-noscan.out', 'stuff\n') +test.must_match('tstamp.out', 'stuff\n', mode='r') +test.must_match('content.out', 'stuff\n', mode='r') +test.must_match('cmd-tstamp.out', 'stuff\n', mode='r') +test.must_match('cmd-content.out', 'stuff\n', mode='r') +test.must_match('cmd-tstamp-noscan.out', 'stuff\n', mode='r') +test.must_match('cmd-content-noscan.out', 'stuff\n', mode='r') test.up_to_date(arguments='tstamp.out') test.up_to_date(arguments='content.out') diff --git a/test/IDL/MIDLCOM.py b/test/IDL/MIDLCOM.py index 0525592..a478da0 100644 --- a/test/IDL/MIDLCOM.py +++ b/test/IDL/MIDLCOM.py @@ -39,12 +39,12 @@ test = TestSCons.TestSCons() test.write('mymidl.py', """ import os.path import sys -out_tlb = open(sys.argv[1], 'wb') +out_tlb = open(sys.argv[1], 'w') base = os.path.splitext(sys.argv[1])[0] -out_h = open(base + '.h', 'wb') -out_c = open(base + '_i.c', 'wb') +out_h = open(base + '.h', 'w') +out_c = open(base + '_i.c', 'w') for f in sys.argv[2:]: - infile = open(f, 'rb') + infile = open(f, 'r') for l in [l for l in infile.readlines() if l != '/*midl*/\\n']: out_tlb.write(l) out_h.write(l) @@ -62,9 +62,9 @@ test.write('aaa.idl', "aaa.idl\n/*midl*/\n") test.run(arguments = '.') -test.must_match('aaa.tlb', "aaa.idl\n") -test.must_match('aaa.h', "aaa.idl\n") -test.must_match('aaa_i.c', "aaa.idl\n") +test.must_match('aaa.tlb', "aaa.idl\n", mode='r') +test.must_match('aaa.h', "aaa.idl\n", mode='r') +test.must_match('aaa_i.c', "aaa.idl\n", mode='r') test.up_to_date(options = '--debug=explain', arguments = 'aaa.tlb') -- cgit v0.12 From 91e275f3e1f334a15e4a338e9317d6f2078fc7df Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 12 Mar 2017 19:57:11 -0400 Subject: get rid of rb/wb --- test/Install/Install.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/Install/Install.py b/test/Install/Install.py index d66660b..d039d78 100644 --- a/test/Install/Install.py +++ b/test/Install/Install.py @@ -50,15 +50,15 @@ _SUBDIR_f4_out = os.path.join('$SUBDIR', 'f4.out') test.write(['work', 'SConstruct'], """\ def cat(env, source, target): target = str(target[0]) - f = open(target, "wb") + f = open(target, "w") for src in source: - f.write(open(str(src), "rb").read()) + f.write(open(str(src), "r").read()) f.close() def my_install(dest, source, env): import shutil shutil.copy2(source, dest) - open('my_install.out', 'ab').write(dest) + open('my_install.out', 'a').write(dest) env1 = Environment() env1.Append(BUILDERS={'Cat':Builder(action=cat)}) @@ -122,7 +122,7 @@ test.fail_test(oldtime1 == os.path.getmtime(f1_out)) test.fail_test(oldtime2 != os.path.getmtime(f2_out)) # Verify that we didn't link to the Installed file. -open(f2_out, 'wb').write("xyzzy\n") +open(f2_out, 'w').write("xyzzy\n") test.must_match(['work', 'f2.out'], "f2.in\n") # Verify that scons prints an error message -- cgit v0.12 From 0316ad1681b00b0c948f329db9c1eeedf709545b Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 12 Mar 2017 21:20:25 -0400 Subject: swap using wrapper.py fixture to wrapper_with_args.py. The fixture swap missed that java tests wrapper was different. Also mode rb/wb changes, and switch to must_match with mode='r' --- test/Java/JAR.py | 12 ++++++------ test/Java/JAVAC.py | 6 +++--- test/Java/JAVAH.py | 11 ++++++----- test/Java/RMIC.py | 14 ++++++++------ 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/test/Java/JAR.py b/test/Java/JAR.py index 98dfa38..a87b272 100644 --- a/test/Java/JAR.py +++ b/test/Java/JAR.py @@ -43,9 +43,9 @@ while args: else: break args = args[1:] -outfile = open(out, 'wb') +outfile = open(out, 'w') for file in args: - infile = open(file, 'rb') + infile = open(file, 'r') for l in infile.readlines(): if l[:7] != '/*jar*/': outfile.write(l) @@ -88,7 +88,7 @@ line 3 test.write('myjar2.py', r""" import sys -f=open(sys.argv[2], 'wb') +f=open(sys.argv[2], 'w') f.write(" ".join(sys.argv[1:])) f.write("\n") f.close() @@ -124,14 +124,14 @@ where_jar = test.java_where_jar() -test.file_fixture('wrapper.py') +test.file_fixture('wrapper_with_args.py') test.write('SConstruct', """ foo = Environment(tools = ['javac', 'jar'], JAVAC = r'%(where_javac)s', JAR = r'%(where_jar)s') jar = foo.Dictionary('JAR') -bar = foo.Clone(JAR = r'%(_python_)s wrapper.py ' + jar) +bar = foo.Clone(JAR = r'%(_python_)s wrapper_with_args.py ' + jar) foo.Java(target = 'classes', source = 'com/sub/foo') bar.Java(target = 'classes', source = 'com/sub/bar') foo.Jar(target = 'foo', source = 'classes/com/sub/foo') @@ -229,7 +229,7 @@ public class Example6 test.run(arguments = '.') -expected_wrapper_out = "wrapper.py %(where_jar)s cf bar.jar classes/com/sub/bar\n" +expected_wrapper_out = "wrapper_with_args.py %(where_jar)s cf bar.jar classes/com/sub/bar\n" expected_wrapper_out = expected_wrapper_out.replace('/', os.sep) test.must_match('wrapper.out', expected_wrapper_out % locals()) diff --git a/test/Java/JAVAC.py b/test/Java/JAVAC.py index 06b1969..da42fc6 100644 --- a/test/Java/JAVAC.py +++ b/test/Java/JAVAC.py @@ -51,8 +51,8 @@ while args: break args = args[1:] for file in args: - infile = open(file, 'rb') - outfile = open(file[:-5] + '.class', 'wb') + infile = open(file, 'r') + outfile = open(file[:-5] + '.class', 'w') for l in infile.readlines(): if l[:9] != '/*javac*/': outfile.write(l) @@ -73,7 +73,7 @@ line 3 test.run(arguments = '.', stderr = None) -test.must_match('test1.class', "test1.java\nline 3\n") +test.must_match('test1.class', "test1.java\nline 3\n", mode='r') if os.path.normcase('.java') == os.path.normcase('.JAVA'): diff --git a/test/Java/JAVAH.py b/test/Java/JAVAH.py index f647b03..589a822 100644 --- a/test/Java/JAVAH.py +++ b/test/Java/JAVAH.py @@ -41,7 +41,7 @@ while args: outdir = args[1] args = args[1:] elif a == '-o': - outfile = open(args[1], 'wb') + outfile = open(args[1], 'w') args = args[1:] elif a == '-classpath': args = args[1:] @@ -51,7 +51,7 @@ while args: break args = args[1:] for file in args: - infile = open(file, 'rb') + infile = open(file, 'r') for l in infile.readlines(): if l[:9] != '/*javah*/': outfile.write(l) @@ -105,7 +105,7 @@ if java_version: if test.javac_is_gcj: test.skip_test('Test not valid for gcj (gnu java); skipping test(s).\n') -test.file_fixture('wrapper.py') +test.file_fixture('wrapper_with_args.py') test.write('SConstruct', """ foo = Environment(tools = ['javac', 'javah', 'install'], @@ -115,7 +115,7 @@ jv = %(java_version)s if jv: foo['JAVAVERSION'] = jv javah = foo.Dictionary('JAVAH') -bar = foo.Clone(JAVAH = r'%(_python_)s wrapper.py ' + javah) +bar = foo.Clone(JAVAH = r'%(_python_)s wrapper_with_args.py ' + javah) foo.Java(target = 'class1', source = 'com/sub/foo') bar_classes = bar.Java(target = 'class2', source = 'com/sub/bar') foo_classes = foo.Java(target = 'class3', source = 'src') @@ -282,7 +282,8 @@ class Private { test.run(arguments = '.') -test.fail_test(test.read('wrapper.out') != "wrapper.py %(where_javah)s -d outdir2 -classpath class2 com.sub.bar.Example4 com.other.Example5 com.sub.bar.Example6\n" % locals()) +test.must_match('wrapper.out', "wrapper_with_args.py %(where_javah)s -d outdir2 -classpath class2 com.sub.bar.Example4 com.other.Example5 com.sub.bar.Example6\n" % locals(), + mode='r') test.must_exist(['outdir1', 'com_sub_foo_Example1.h']) test.must_exist(['outdir1', 'com_other_Example2.h']) diff --git a/test/Java/RMIC.py b/test/Java/RMIC.py index 5f5decd..e94fda6 100644 --- a/test/Java/RMIC.py +++ b/test/Java/RMIC.py @@ -49,8 +49,8 @@ while args: break args = args[1:] for file in args: - infile = open(file, 'rb') - outfile = open(os.path.join(outdir, file[:-5] + '.class'), 'wb') + infile = open(file, 'r') + outfile = open(os.path.join(outdir, file[:-5] + '.class'), 'w') for l in infile.readlines(): if l[:8] != '/*rmic*/': outfile.write(l) @@ -71,7 +71,7 @@ line 3 test.run(arguments = '.', stderr = None) -test.fail_test(test.read(['outdir', 'test1.class']) != "test1.java\nline 3\n") +test.must_match(['outdir', 'test1.class'], "test1.java\nline 3\n", mode='r') if os.path.normcase('.java') == os.path.normcase('.JAVA'): @@ -111,7 +111,7 @@ if java_version.count('.') == 1: # Note, how we allow simple version strings like "5" and # "6" to successfully pass this test. if curver < (1, 8): - test.file_fixture('wrapper.py') + test.file_fixture('wrapper_with_args.py') test.write('SConstruct', """ foo = Environment(tools = ['javac', 'rmic'], @@ -124,7 +124,7 @@ foo.RMIC(target = 'outdir1', JAVACLASSDIR = 'class1') rmic = foo.Dictionary('RMIC') -bar = foo.Clone(RMIC = r'%(_python_)s wrapper.py ' + rmic) +bar = foo.Clone(RMIC = r'%(_python_)s wrapper_with_args.py ' + rmic) bar_classes = bar.Java(target = 'class2', source = 'com/sub/bar') # XXX This is kind of a Python brute-force way to do what Ant # does with its "excludes" attribute. We should probably find @@ -321,7 +321,9 @@ public class Example4 extends UnicastRemoteObject implements Hello { test.run(arguments = '.') - test.fail_test(test.read('wrapper.out') != "wrapper.py %s -d outdir2 -classpath class2 com.sub.bar.Example3 com.sub.bar.Example4\n" % where_rmic) + test.must_match('wrapper.out', + "wrapper_with_args.py %s -d outdir2 -classpath class2 com.sub.bar.Example3 com.sub.bar.Example4\n" % where_rmic, + mode='r') test.must_exist(test.workpath('outdir1', 'com', 'sub', 'foo', 'Example1_Stub.class')) test.must_exist(test.workpath('outdir1', 'com', 'sub', 'foo', 'Example2_Stub.class')) -- cgit v0.12 From 0da1117ef3e2d6dc28e1df8a5d2c898a6a316c8a Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 12 Mar 2017 21:21:00 -0400 Subject: copied old wrapper logic from java tests. --- test/fixture/wrapper_with_args.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 test/fixture/wrapper_with_args.py diff --git a/test/fixture/wrapper_with_args.py b/test/fixture/wrapper_with_args.py new file mode 100644 index 0000000..fccab72 --- /dev/null +++ b/test/fixture/wrapper_with_args.py @@ -0,0 +1,7 @@ +import os +import sys + +path = os.path.join(os.path.dirname(os.path.relpath(__file__)), 'wrapper.out') + +open(path, 'a').write("wrapper_with_args.py %s\n" % " ".join(sys.argv[1:])) +os.system(" ".join(sys.argv[1:])) -- cgit v0.12 From eac948ded21626e43fccf9e816b2cf7db3af17c7 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 12 Mar 2017 21:21:15 -0400 Subject: removed b from file open py2/3 --- test/fixture/wrapper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/fixture/wrapper.py b/test/fixture/wrapper.py index f02ea03..bd8187c 100644 --- a/test/fixture/wrapper.py +++ b/test/fixture/wrapper.py @@ -2,5 +2,5 @@ import os import sys if '--version' not in sys.argv and '-dumpversion' not in sys.argv: path = os.path.join(os.path.dirname(os.path.relpath(__file__)), 'wrapper.out') - open(path, 'wb').write(b"wrapper.py\n") + open(path, 'w').write("wrapper.py\n") os.system(" ".join(sys.argv[1:])) -- cgit v0.12 From b7749493e21490935398ca359c70eb5f8546ea62 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 12 Mar 2017 21:31:17 -0400 Subject: py2/3 must_match mode='r' changes --- test/Java/JAR.py | 14 +++++++------- test/Java/JAVAC.py | 6 +++--- test/Java/JAVAH.py | 8 ++++---- test/Java/RMIC.py | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/test/Java/JAR.py b/test/Java/JAR.py index a87b272..476bfcd 100644 --- a/test/Java/JAR.py +++ b/test/Java/JAR.py @@ -64,9 +64,9 @@ test1.class line 3 """) -test.run(arguments = '.', stderr = None) +test.run(arguments='.', stderr=None) -test.must_match('test1.jar', "test1.class\nline 3\n") +test.must_match('test1.jar', "test1.class\nline 3\n", mode='r') if os.path.normcase('.class') == os.path.normcase('.CLASS'): @@ -82,9 +82,9 @@ test2.CLASS line 3 """) - test.run(arguments = '.', stderr = None) + test.run(arguments='.', stderr=None) - test.must_match('test2.jar', "test2.CLASS\nline 3\n") + test.must_match('test2.jar', "test2.CLASS\nline 3\n", mode='r') test.write('myjar2.py', r""" import sys @@ -106,7 +106,7 @@ env.Jar(target = 'classes.jar', source = [ 'testdir/bar.class', """ % locals()) test.subdir('testdir') -test.write([ 'testdir', 'bar.class' ], 'foo') +test.write(['testdir', 'bar.class'], 'foo') test.write('foo.mf', """Manifest-Version : 1.0 blah @@ -115,7 +115,7 @@ test.write('foo.mf', """) test.run(arguments='classes.jar') test.must_match('classes.jar', - 'cvfm classes.jar foo.mf -C testdir bar.class\n') + 'cvfm classes.jar foo.mf -C testdir bar.class\n', mode='r') @@ -232,7 +232,7 @@ test.run(arguments = '.') expected_wrapper_out = "wrapper_with_args.py %(where_jar)s cf bar.jar classes/com/sub/bar\n" expected_wrapper_out = expected_wrapper_out.replace('/', os.sep) test.must_match('wrapper.out', - expected_wrapper_out % locals()) + expected_wrapper_out % locals(), mode='r') test.must_exist('foo.jar') test.must_exist('bar.jar') diff --git a/test/Java/JAVAC.py b/test/Java/JAVAC.py index da42fc6..aaaa8f5 100644 --- a/test/Java/JAVAC.py +++ b/test/Java/JAVAC.py @@ -71,7 +71,7 @@ test1.java line 3 """) -test.run(arguments = '.', stderr = None) +test.run(arguments='.', stderr=None) test.must_match('test1.class', "test1.java\nline 3\n", mode='r') @@ -89,9 +89,9 @@ test2.JAVA line 3 """) - test.run(arguments = '.', stderr = None) + test.run(arguments='.', stderr=None) - test.must_match('test2.class', "test2.JAVA\nline 3\n") + test.must_match('test2.class', "test2.JAVA\nline 3\n", mode='r') diff --git a/test/Java/JAVAH.py b/test/Java/JAVAH.py index 589a822..f07ebb9 100644 --- a/test/Java/JAVAH.py +++ b/test/Java/JAVAH.py @@ -70,9 +70,9 @@ test1.java line 3 """) -test.run(arguments = '.', stderr = None) +test.run(arguments='.', stderr=None) -test.must_match('test1.h', "test1.java\nline 3\n") +test.must_match('test1.h', "test1.java\nline 3\n", mode='r') if os.path.normcase('.java') == os.path.normcase('.JAVA'): @@ -88,9 +88,9 @@ test2.JAVA line 3 """) - test.run(arguments = '.', stderr = None) + test.run(arguments='.', stderr=None) - test.must_match('test2.h', "test2.JAVA\nline 3\n") + test.must_match('test2.h', "test2.JAVA\nline 3\n", mode='r') where_javac, java_version = test.java_where_javac() diff --git a/test/Java/RMIC.py b/test/Java/RMIC.py index e94fda6..b29a466 100644 --- a/test/Java/RMIC.py +++ b/test/Java/RMIC.py @@ -89,7 +89,7 @@ line 3 test.run(arguments = '.', stderr = None) - test.fail_test(test.read(['outdir', 'test2.class']) != "test2.JAVA\nline 3\n") + test.must_match(['outdir', 'test2.class'], "test2.JAVA\nline 3\n", mode='r') where_javac, java_version = test.java_where_javac() where_rmic = test.java_where_rmic() -- cgit v0.12 From 947fa5299ab999820bfe4486c0a03d10dbdf80d6 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 12 Mar 2017 21:31:38 -0400 Subject: remove mode b's py2/3 --- test/MSVC/batch.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/MSVC/batch.py b/test/MSVC/batch.py index 8648292..97d7f3a 100644 --- a/test/MSVC/batch.py +++ b/test/MSVC/batch.py @@ -55,20 +55,20 @@ else: # Delay writing the .log output until here so any trailing slash or # backslash has been stripped, and the output comparisons later in this # script don't have to account for the difference. -open('fake_cl.log', 'ab').write(" ".join(sys.argv[1:]) + '\\n') +open('fake_cl.log', 'a').write(" ".join(sys.argv[1:]) + '\\n') for infile in input_files: if dir: outfile = os.path.join(dir, infile.replace('.c', '.obj')) else: outfile = output - open(outfile, 'wb').write(open(infile, 'rb').read()) + open(outfile, 'w').write(open(infile, 'r').read()) """) test.write('fake_link.py', """\ import sys -ofp = open(sys.argv[1], 'wb') +ofp = open(sys.argv[1], 'w') for infile in sys.argv[2:]: - ofp.write(open(infile, 'rb').read()) + ofp.write(open(infile, 'r').read()) """) test.write('SConstruct', """ -- cgit v0.12 From 4d20bdbb93fbb9053eee9430a2ab759d8e502a2f Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 12 Mar 2017 21:35:07 -0400 Subject: py2/3 must_match mode='r' changes --- test/MSVC/batch.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/MSVC/batch.py b/test/MSVC/batch.py index 97d7f3a..8b7945b 100644 --- a/test/MSVC/batch.py +++ b/test/MSVC/batch.py @@ -94,10 +94,10 @@ test.write('f2.c', "f2.c\n") test.run(arguments = 'MSVC_BATCH=1 .') -test.must_match('prog.exe', "prog.c\nf1.c\nf2.c\n") +test.must_match('prog.exe', "prog.c\nf1.c\nf2.c\n", mode='r') test.must_match('fake_cl.log', """\ /Fo. prog.c f1.c f2.c -""") +""", mode='r') test.up_to_date(options = 'MSVC_BATCH=1', arguments = '.') @@ -107,11 +107,11 @@ test.write('f1.c', "f1.c 2\n") test.run(arguments = 'MSVC_BATCH=1 .') -test.must_match('prog.exe', "prog.c\nf1.c 2\nf2.c\n") +test.must_match('prog.exe', "prog.c\nf1.c 2\nf2.c\n", mode='r') test.must_match('fake_cl.log', """\ /Fo. prog.c f1.c f2.c /Fo. f1.c -""") +""", mode='r') test.up_to_date(options = 'MSVC_BATCH=1', arguments = '.') @@ -125,12 +125,12 @@ test.unlink('fake_cl.log') test.run(arguments = '. MSVC_BATCH=0') -test.must_match('prog.exe', "prog.c\nf1.c 2\nf2.c\n") +test.must_match('prog.exe', "prog.c\nf1.c 2\nf2.c\n", mode='r') test.must_match('fake_cl.log', """\ /Fof1.obj f1.c /Fof2.obj f2.c /Foprog.obj prog.c -""") +""", mode='r') test.run(arguments = '-c .') test.unlink('fake_cl.log') @@ -138,12 +138,12 @@ test.unlink('fake_cl.log') test.run(arguments = '. MSVC_BATCH=False') -test.must_match('prog.exe', "prog.c\nf1.c 2\nf2.c\n") +test.must_match('prog.exe', "prog.c\nf1.c 2\nf2.c\n", mode='r') test.must_match('fake_cl.log', """\ /Fof1.obj f1.c /Fof2.obj f2.c /Foprog.obj prog.c -""") +""", mode='r') @@ -151,13 +151,13 @@ test.write('f1.c', "f1.c 3\n") test.run(arguments = '. MSVC_BATCH=0') -test.must_match('prog.exe', "prog.c\nf1.c 3\nf2.c\n") +test.must_match('prog.exe', "prog.c\nf1.c 3\nf2.c\n", mode='r') test.must_match('fake_cl.log', """\ /Fof1.obj f1.c /Fof2.obj f2.c /Foprog.obj prog.c /Fof1.obj f1.c -""") +""", mode='r') -- cgit v0.12 From b895d0ec04017a7e276d0643465d1866a72e4605 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 12 Mar 2017 21:51:38 -0400 Subject: fix py2/3 issues mostly rb/wb mode='r' fixes --- test/MSVC/embed-manifest.py | 6 +++--- test/MSVC/generate-rc.py | 10 +++++----- test/MSVC/msvc.py | 3 +++ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/test/MSVC/embed-manifest.py b/test/MSVC/embed-manifest.py index 13f1def..c0f8408 100644 --- a/test/MSVC/embed-manifest.py +++ b/test/MSVC/embed-manifest.py @@ -76,14 +76,14 @@ testdll(int argc, char *argv) } """) -test.run(arguments = '.') +test.run(arguments='.') test.must_exist('test%s' % _exe) test.must_exist('test%s.manifest' % _exe) -test.must_contain('exe-extracted.manifest', '') +test.must_contain('exe-extracted.manifest', '', mode='r') test.must_exist('testdll%s' % _dll) test.must_exist('testdll%s.manifest' % _dll) -test.must_contain('dll-extracted.manifest', '') +test.must_contain('dll-extracted.manifest', '', mode='r') test.pass_test() diff --git a/test/MSVC/generate-rc.py b/test/MSVC/generate-rc.py index 40ef95e..00e9090 100644 --- a/test/MSVC/generate-rc.py +++ b/test/MSVC/generate-rc.py @@ -39,15 +39,15 @@ fake_rc = test.workpath('fake_rc.py') test.write(fake_rc, """\ import sys -contents = open(sys.argv[2], 'rb').read() -open(sys.argv[1], 'wb').write("fake_rc.py\\n" + contents) +contents = open(sys.argv[2], 'r').read() +open(sys.argv[1], 'w').write("fake_rc.py\\n" + contents) """) test.write('SConstruct', """ def generate_rc(target, source, env): t = str(target[0]) s = str(source[0]) - tfp = open(t, 'wb') + tfp = open(t, 'w') tfp.write('generate_rc\\n' + open(s, 'r').read()) env = Environment(tools=['msvc'], @@ -64,8 +64,8 @@ test.write('my.in', "my.in\n") test.run(arguments = '.') -test.must_match('my.rc', "generate_rc\nmy.in\n") -test.must_match('my.res', "fake_rc.py\ngenerate_rc\nmy.in\n") +test.must_match('my.rc', "generate_rc\nmy.in\n", mode='r') +test.must_match('my.res', "fake_rc.py\ngenerate_rc\nmy.in\n", mode='r') test.pass_test() diff --git a/test/MSVC/msvc.py b/test/MSVC/msvc.py index a70ed67..838922c 100644 --- a/test/MSVC/msvc.py +++ b/test/MSVC/msvc.py @@ -43,6 +43,7 @@ test.skip_if_not_msvc() test.write('SConstruct',""" import os +DefaultEnvironment(tools=[]) # TODO: this is order-dependent (putting 'mssdk' second or third breaks), # and ideally we shouldn't need to specify the tools= list anyway. env = Environment(tools=['mssdk', 'msvc', 'mslink']) @@ -179,6 +180,8 @@ start = time.time() test.run(arguments='slow.obj', stderr=None) slow = time.time() - start + +# TODO: Reevaluate if having this part of the test makes sense any longer # using precompiled headers should be faster limit = slow*0.90 if fast >= limit: -- cgit v0.12 From c18ff7c41334123ae82fc641eb62c258847f9f5f Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 12 Mar 2017 21:57:14 -0400 Subject: fix must_match mode='r' --- test/scons-time/run/config/python.py | 6 +++--- test/scons-time/run/config/scons.py | 6 +++--- test/scons-time/run/option/python.py | 6 +++--- test/scons-time/run/option/scons.py | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/test/scons-time/run/config/python.py b/test/scons-time/run/config/python.py index 2660927..0734730 100644 --- a/test/scons-time/run/config/python.py +++ b/test/scons-time/run/config/python.py @@ -62,9 +62,9 @@ prof0 = test.workpath('foo-000-0.prof') prof1 = test.workpath('foo-000-1.prof') prof2 = test.workpath('foo-000-2.prof') -test.must_match('foo-000-0.log', "my_python.py: %s\n" % prof0) -test.must_match('foo-000-1.log', "my_python.py: %s\n" % prof1) -test.must_match('foo-000-2.log', "my_python.py: %s\n" % prof2) +test.must_match('foo-000-0.log', "my_python.py: %s\n" % prof0, mode='r') +test.must_match('foo-000-1.log', "my_python.py: %s\n" % prof1, mode='r') +test.must_match('foo-000-2.log', "my_python.py: %s\n" % prof2, mode='r') test.pass_test() diff --git a/test/scons-time/run/config/scons.py b/test/scons-time/run/config/scons.py index 0c8b643..b782e83 100644 --- a/test/scons-time/run/config/scons.py +++ b/test/scons-time/run/config/scons.py @@ -58,9 +58,9 @@ prof0 = test.workpath('foo-000-0.prof') prof1 = test.workpath('foo-000-1.prof') prof2 = test.workpath('foo-000-2.prof') -test.must_match('foo-000-0.log', "my_scons.py: %s\n" % prof0) -test.must_match('foo-000-1.log', "my_scons.py: %s\n" % prof1) -test.must_match('foo-000-2.log', "my_scons.py: %s\n" % prof2) +test.must_match('foo-000-0.log', "my_scons.py: %s\n" % prof0, mode='r') +test.must_match('foo-000-1.log', "my_scons.py: %s\n" % prof1, mode='r') +test.must_match('foo-000-2.log', "my_scons.py: %s\n" % prof2, mode='r') test.pass_test() diff --git a/test/scons-time/run/option/python.py b/test/scons-time/run/option/python.py index 70feb70..d0592b6 100644 --- a/test/scons-time/run/option/python.py +++ b/test/scons-time/run/option/python.py @@ -57,9 +57,9 @@ prof0 = test.workpath('foo-000-0.prof') prof1 = test.workpath('foo-000-1.prof') prof2 = test.workpath('foo-000-2.prof') -test.must_match('foo-000-0.log', "my_python.py: %s\n" % prof0) -test.must_match('foo-000-1.log', "my_python.py: %s\n" % prof1) -test.must_match('foo-000-2.log', "my_python.py: %s\n" % prof2) +test.must_match('foo-000-0.log', "my_python.py: %s\n" % prof0, mode='r') +test.must_match('foo-000-1.log', "my_python.py: %s\n" % prof1, mode='r') +test.must_match('foo-000-2.log', "my_python.py: %s\n" % prof2, mode='r') test.pass_test() diff --git a/test/scons-time/run/option/scons.py b/test/scons-time/run/option/scons.py index 71d8ca2..e2479c3 100644 --- a/test/scons-time/run/option/scons.py +++ b/test/scons-time/run/option/scons.py @@ -52,9 +52,9 @@ prof0 = test.workpath('foo-000-0.prof') prof1 = test.workpath('foo-000-1.prof') prof2 = test.workpath('foo-000-2.prof') -test.must_match('foo-000-0.log', "my_scons.py: %s\n" % prof0) -test.must_match('foo-000-1.log', "my_scons.py: %s\n" % prof1) -test.must_match('foo-000-2.log', "my_scons.py: %s\n" % prof2) +test.must_match('foo-000-0.log', "my_scons.py: %s\n" % prof0, mode='r') +test.must_match('foo-000-1.log', "my_scons.py: %s\n" % prof1, mode='r') +test.must_match('foo-000-2.log', "my_scons.py: %s\n" % prof2, mode='r') test.pass_test() -- cgit v0.12 From 25335d29099874e0574a79d9a8644d66f1533838 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 12 Mar 2017 22:55:21 -0400 Subject: Fix byte issues, module import issue remains --- test/Repository/Install-Local.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/Repository/Install-Local.py b/test/Repository/Install-Local.py index 3631043..fe64feb 100644 --- a/test/Repository/Install-Local.py +++ b/test/Repository/Install-Local.py @@ -51,8 +51,8 @@ test.write(['repository', 'file2'], "repository/file2\n") test.run(chdir = 'repository', options = opts, arguments = 'install') -test.fail_test(test.read(repository_install_file1) != "repository/file1\n") -test.fail_test(test.read(repository_install_file2) != "repository/file2\n") +test.must_match(repository_install_file1, "repository/file1\n", mode='r') +test.must_match(repository_install_file2, "repository/file2\n", mode='r') test.up_to_date(chdir = 'repository', options = opts, arguments = 'install') @@ -62,8 +62,8 @@ test.writable('repository', 0) test.run(chdir = 'work', options = opts, arguments = 'install') -test.fail_test(test.read(work_install_file1) != "repository/file1\n") -test.fail_test(test.read(work_install_file2) != "repository/file2\n") +test.must_match(work_install_file1, "repository/file1\n", mode='r') +test.must_match(work_install_file2, "repository/file2\n", mode='r') test.up_to_date(chdir = 'work', options = opts, arguments = 'install') @@ -73,8 +73,8 @@ test.write(['work', 'file2'], "work/file2\n") test.run(chdir = 'work', options = opts, arguments = 'install') -test.fail_test(test.read(work_install_file1) != "work/file1\n") -test.fail_test(test.read(work_install_file2) != "work/file2\n") +test.must_match(work_install_file1, "work/file1\n", mode='r') +test.must_match(work_install_file2, "work/file2\n", mode='r') test.up_to_date(chdir = 'work', options = opts, arguments = 'install') -- cgit v0.12 From 57f2bc39219ec1fdb609bb979294487512407963 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 12 Mar 2017 23:33:00 -0400 Subject: py2/3 byte fixes --- test/Parallel/ref_count.py | 8 ++--- test/RANLIB/RANLIBFLAGS.py | 2 +- test/Repository/Default.py | 14 ++++----- test/Repository/Install.py | 2 +- test/Repository/InstallAs.py | 6 ++-- test/Repository/LIBPATH.py | 14 ++++----- test/Repository/Local.py | 16 +++++----- test/Repository/SConscript.py | 12 ++++---- test/Repository/VariantDir.py | 28 +++++++++--------- test/Repository/option-c.py | 66 +++++++++++++++++++++--------------------- test/Repository/option-f.py | 10 +++---- test/Repository/option-n.py | 6 ++-- test/Repository/targets.py | 14 ++++----- test/Scanner/FindPathDirs.py | 6 ++-- test/Scanner/Scanner.py | 8 ++--- test/Scanner/generated.py | 2 +- test/Scanner/no-Dir-node.py | 10 +++---- test/TAR/TAR.py | 14 ++++----- test/TAR/TARFLAGS.py | 14 ++++----- test/TEX/LATEXFLAGS.py | 10 +++---- test/Variables/Variables.py | 5 +++- test/VariantDir/Clean.py | 4 +-- test/VariantDir/File-create.py | 4 +-- test/VariantDir/errors.py | 6 ++-- test/builderrors.py | 10 +++---- 25 files changed, 141 insertions(+), 150 deletions(-) diff --git a/test/Parallel/ref_count.py b/test/Parallel/ref_count.py index ce59668..7ce5910 100644 --- a/test/Parallel/ref_count.py +++ b/test/Parallel/ref_count.py @@ -74,9 +74,9 @@ while args: time.sleep(int(args.pop(0))) contents = '' for ifile in args: - contents = contents + open(ifile, 'rb').read() + contents = contents + open(ifile, 'r').read() for ofile in outputs: - ofp = open(ofile, 'wb') + ofp = open(ofile, 'w') ofp.write('%s: building from %s\\n' % (ofile, " ".join(args))) ofp.write(contents) ofp.close() @@ -136,7 +136,7 @@ test.run(arguments = '-j4 after.out') test.must_match('after.out', """\ after.out: building from after.in after.in -""") +""", mode='r') test.write('file5.c', "file5.c modified\n") @@ -147,7 +147,7 @@ test.run(arguments = '-j4 after.out') test.must_match('after.out', """\ after.out: building from after.in after.in modified -""") +""", mode='r') test.pass_test() diff --git a/test/RANLIB/RANLIBFLAGS.py b/test/RANLIB/RANLIBFLAGS.py index e13bac8..93a5abf 100644 --- a/test/RANLIB/RANLIBFLAGS.py +++ b/test/RANLIB/RANLIBFLAGS.py @@ -101,7 +101,7 @@ test.run(arguments = 'b' + _exe, stderr=TestSCons.noisy_ar, match=TestSCons.match_re_dotall) -test.fail_test(test.read('wrapper.out') != "wrapper.py\n") +test.must_match('wrapper.out', "wrapper.py\n", mode='r') test.pass_test() diff --git a/test/Repository/Default.py b/test/Repository/Default.py index 44aecfb..bd9d5f8 100644 --- a/test/Repository/Default.py +++ b/test/Repository/Default.py @@ -47,7 +47,7 @@ def copy(env, source, target): source = str(source[0]) target = str(target[0]) print('copy() < %s > %s' % (source, target)) - open(target, "wb").write(open(source, "rb").read()) + open(target, "w").write(open(source, "r").read()) Build = Builder(action=copy) env = Environment(BUILDERS={'Build':Build}) @@ -80,19 +80,19 @@ test.writable('repository', 0) test.run(chdir = 'work', options = opts, arguments = '') test.fail_test(os.path.exists(work_aaa_out)) -test.fail_test(test.read(work_bbb_out) != "repository/bbb.in\n") +test.must_match(work_bbb_out, "repository/bbb.in\n", mode='r') test.fail_test(os.path.exists(work_ccc_out)) test.fail_test(os.path.exists(work_subdir_ddd_out)) -test.fail_test(test.read(work_subdir_eee_out) != "repository/subdir/eee.in\n") +test.must_match(work_subdir_eee_out, "repository/subdir/eee.in\n", mode='r') test.fail_test(os.path.exists(work_subdir_fff_out)) # test.run(chdir = 'work', options = opts, arguments = '.') -test.fail_test(test.read(work_aaa_out) != "repository/aaa.in\n") -test.fail_test(test.read(work_ccc_out) != "repository/ccc.in\n") -test.fail_test(test.read(work_subdir_ddd_out) != "repository/subdir/ddd.in\n") -test.fail_test(test.read(work_subdir_fff_out) != "repository/subdir/fff.in\n") +test.must_match(work_aaa_out, "repository/aaa.in\n", mode='r') +test.must_match(work_ccc_out, "repository/ccc.in\n", mode='r') +test.must_match(work_subdir_ddd_out, "repository/subdir/ddd.in\n", mode='r') +test.must_match(work_subdir_fff_out, "repository/subdir/fff.in\n", mode='r') test.up_to_date(chdir = 'work', options = opts, arguments = '.') diff --git a/test/Repository/Install.py b/test/Repository/Install.py index 5e64d55..75052e7 100644 --- a/test/Repository/Install.py +++ b/test/Repository/Install.py @@ -51,7 +51,7 @@ test.writable('repository', 0) test.run(chdir = 'work', options = opts, arguments = install) -test.fail_test(test.read(install_file) != "repository/file\n") +test.must_match(install_file, "repository/file\n", mode='r') test.up_to_date(chdir = 'work', options = opts, arguments = install) diff --git a/test/Repository/InstallAs.py b/test/Repository/InstallAs.py index 0923d88..d717254 100644 --- a/test/Repository/InstallAs.py +++ b/test/Repository/InstallAs.py @@ -56,9 +56,9 @@ test.writable('repository', 0) test.run(chdir = 'work', options = opts, arguments = install) -test.fail_test(test.read(install_file1_out) != "repository/file1.in\n") -test.fail_test(test.read(install_file2_out) != "repository/file2.in\n") -test.fail_test(test.read(install_file3_out) != "repository/file3.in\n") +test.must_match(install_file1_out, "repository/file1.in\n", mode='r') +test.must_match(install_file2_out, "repository/file2.in\n", mode='r') +test.must_match(install_file3_out, "repository/file3.in\n", mode='r') test.up_to_date(chdir = 'work', options = opts, arguments = install) diff --git a/test/Repository/LIBPATH.py b/test/Repository/LIBPATH.py index c95d29a..8b396fa 100644 --- a/test/Repository/LIBPATH.py +++ b/test/Repository/LIBPATH.py @@ -46,7 +46,7 @@ bbb_exe = env_yyy.Program('bbb', 'bbb.c') def write_LIBDIRFLAGS(env, target, source): pre = env.subst('$LIBDIRPREFIX') suf = env.subst('$LIBDIRSUFFIX') - f = open(str(target[0]), 'wb') + f = open(str(target[0]), 'w') for arg in env.subst('$_LIBDIRFLAGS', target=target).split(): if arg[:len(pre)] == pre: arg = arg[len(pre):] @@ -97,14 +97,12 @@ test.run(chdir = 'work', options = opts, arguments = ".") #dirs = ['.', workpath_foo, workpath_bar, workpath_foo_zzz] dirs = ['.', workpath_foo, workpath_bar, 'zzz', workpath_foo_zzz, workpath_bar_zzz] -test.fail_test(test.read(['work', 'zzz.out']) != - '\n'.join(dirs) + '\n') +test.must_match(['work', 'zzz.out'],'\n'.join(dirs) + '\n', mode='r') #dirs = [workpath_bar_yyy, '.', workpath_foo, workpath_bar] dirs = ['yyy', workpath_foo_yyy, workpath_bar_yyy, '.', workpath_foo, workpath_bar] -test.fail_test(test.read(['work', 'yyy.out']) != - '\n'.join(dirs) + '\n') +test.must_match(['work', 'yyy.out'], '\n'.join(dirs) + '\n', mode='r') # test.run(chdir = 'work', options = '-c', arguments = ".") @@ -117,14 +115,12 @@ test.run(chdir = 'work', options = opts, arguments = ".") #dirs = ['.', workpath_foo, workpath_bar, 'zzz', workpath_foo_zzz] dirs = ['.', workpath_foo, workpath_bar, 'zzz', workpath_foo_zzz, workpath_bar_zzz] -test.fail_test(test.read(['work', 'zzz.out']) != - '\n'.join(dirs) + '\n') +test.must_match(['work', 'zzz.out'], '\n'.join(dirs) + '\n', mode='r') #dirs = ['yyy', workpath_bar_yyy, '.', workpath_foo, workpath_bar] dirs = ['yyy', workpath_foo_yyy, workpath_bar_yyy, '.', workpath_foo, workpath_bar] -test.fail_test(test.read(['work', 'yyy.out']) != - '\n'.join(dirs) + '\n') +test.must_match(['work', 'yyy.out'], '\n'.join(dirs) + '\n', mode='r') # test.pass_test() diff --git a/test/Repository/Local.py b/test/Repository/Local.py index ea03281..95fd898 100644 --- a/test/Repository/Local.py +++ b/test/Repository/Local.py @@ -49,7 +49,7 @@ def copy(env, source, target): source = str(source[0]) target = str(target[0]) print('copy() < %s > %s' % (source, target)) - open(target, "wb").write(open(source, "rb").read()) + open(target, "w").write(open(source, "r").read()) Build = Builder(action=copy) env = Environment(BUILDERS={'Build':Build}, BBB='bbb') @@ -66,7 +66,7 @@ test.write(['repository', 'src', 'SConscript'], r""" def bbb_copy(env, source, target): target = str(target[0]) print('bbb_copy()') - open(target, "wb").write(open('build/bbb.1', "rb").read()) + open(target, "w").write(open('build/bbb.1', "r").read()) Import("env") env.Build('bbb.1', 'bbb.0') @@ -82,8 +82,8 @@ test.write(['repository', 'src', 'bbb.x'], "repository/src/bbb.x\n") # test.run(chdir = 'repository', options = opts, arguments = '.') -test.fail_test(test.read(repository_aaa_out) != "repository/aaa.in\n") -test.fail_test(test.read(repository_build_bbb_2) != "repository/src/bbb.0\n") +test.must_match(repository_aaa_out, "repository/aaa.in\n", mode='r') +test.must_match(repository_build_bbb_2, "repository/src/bbb.0\n", mode='r') test.up_to_date(chdir = 'repository', options = opts, arguments = '.') @@ -95,8 +95,8 @@ test.writable('repository', 0) test.run(chdir = 'work', options = opts, arguments = 'aaa.out build/bbb.2') test.fail_test(os.path.exists(work_aaa_mid)) -test.fail_test(test.read(work_aaa_out) != "repository/aaa.in\n") -test.fail_test(test.read(work_build_bbb_1) != "repository/src/bbb.0\n") +test.must_match(work_aaa_out, "repository/aaa.in\n", mode='r') +test.must_match(work_build_bbb_1, "repository/src/bbb.0\n", mode='r') test.fail_test(os.path.exists(work_build_bbb_2)) # @@ -105,8 +105,8 @@ test.write(['work', 'aaa.in'], "work/aaa.in\n") # test.run(chdir = 'work', options = opts, arguments = '.') -test.fail_test(test.read(work_aaa_mid) != "work/aaa.in\n") -test.fail_test(test.read(work_aaa_out) != "work/aaa.in\n") +test.must_match(work_aaa_mid, "work/aaa.in\n", mode='r') +test.must_match(work_aaa_out, "work/aaa.in\n", mode='r') test.up_to_date(chdir = 'work', options = opts, arguments = '.') diff --git a/test/Repository/SConscript.py b/test/Repository/SConscript.py index 22956ac..1b67c07 100644 --- a/test/Repository/SConscript.py +++ b/test/Repository/SConscript.py @@ -61,9 +61,9 @@ SConscript('src/SConscript') test.write(['rep1', 'src', 'SConscript'], """\ def cat(env, source, target): target = str(target[0]) - f = open(target, "wb") + f = open(target, "w") for src in source: - f.write(open(str(src), "rb").read()) + f.write(open(str(src), "r").read()) f.close() env = Environment(BUILDERS={'Cat':Builder(action=cat)}) env.Cat(target = 'foo', source = ['aaa.in', 'bbb.in', 'ccc.in']) @@ -79,11 +79,11 @@ test.writable('rep1', 0) test.run(chdir = 'work', arguments = ".") -test.fail_test(test.read(['work', 'src', 'foo']) != """\ +test.must_match(['work', 'src', 'foo'], """\ rep1/src/aaa.in rep1/src/bbb.in rep1/src/ccc.in -""") +""", mode='r') test.up_to_date(chdir = 'work', arguments = ".") @@ -115,11 +115,11 @@ test.write(['rep2', 'src', 'ccc.in'], "rep2/src/ccc.in\n") test.run(chdir = 'rep2/build', arguments = ".") -test.fail_test(test.read(['rep2', 'build', 'src', 'foo']) != """\ +test.must_match(['rep2', 'build', 'src', 'foo'], """\ rep2/src/aaa.in rep2/src/bbb.in rep2/src/ccc.in -""") +""", mode='r') # test.pass_test() diff --git a/test/Repository/VariantDir.py b/test/Repository/VariantDir.py index 0258ff5..8887f86 100644 --- a/test/Repository/VariantDir.py +++ b/test/Repository/VariantDir.py @@ -49,9 +49,9 @@ def cat(env, source, target): target = str(target[0]) source = list(map(str, source)) print('cat(%s) > %s' % (source, target)) - f = open(target, "wb") + f = open(target, "w") for src in source: - f.write(open(src, "rb").read()) + f.write(open(src, "r").read()) f.close() env = Environment(BUILDERS={'Build':Builder(action=cat)}) @@ -72,11 +72,11 @@ test.writable('repository', 0) # test.run(chdir = 'work1', options = opts, arguments = '.') -test.fail_test(test.read(['work1', 'build0', 'output']) != +test.must_match(['work1', 'build0', 'output'], """repository/src/aaa.in repository/src/bbb.in repository/src/ccc.in -""") +""", mode='r') test.fail_test(os.path.exists('work1/build0/aaa.in')) test.fail_test(os.path.exists('work1/build0/bbb.in')) @@ -85,11 +85,11 @@ test.fail_test(not os.path.exists('work1/build0/aaa.mid')) test.fail_test(not os.path.exists('work1/build0/bbb.mid')) test.fail_test(not os.path.exists('work1/build0/ccc.mid')) -test.fail_test(test.read(['work1', 'build1', 'output']) != +test.must_match(['work1', 'build1', 'output'], """repository/src/aaa.in repository/src/bbb.in repository/src/ccc.in -""") +""", mode='r') test.fail_test(not os.path.exists('work1/build1/aaa.in')) test.fail_test(not os.path.exists('work1/build1/bbb.in')) @@ -105,11 +105,11 @@ test.write(['work1', 'src', 'bbb.in'], "work1/src/bbb.in\n") test.run(chdir = 'work1', options = opts, arguments = '.') -test.fail_test(test.read(['work1', 'build0', 'output']) != +test.must_match(['work1', 'build0', 'output'], """repository/src/aaa.in work1/src/bbb.in repository/src/ccc.in -""") +""", mode='r') test.fail_test(os.path.exists('work1/build0/aaa.in')) test.fail_test(os.path.exists('work1/build0/bbb.in')) @@ -118,11 +118,11 @@ test.fail_test(not os.path.exists('work1/build0/aaa.mid')) test.fail_test(not os.path.exists('work1/build0/bbb.mid')) test.fail_test(not os.path.exists('work1/build0/ccc.mid')) -test.fail_test(test.read(['work1', 'build1', 'output']) != +test.must_match(['work1', 'build1', 'output'], """repository/src/aaa.in work1/src/bbb.in repository/src/ccc.in -""") +""", mode='r') test.fail_test(not os.path.exists('work1/build1/aaa.in')) test.fail_test(not os.path.exists('work1/build1/bbb.in')) @@ -167,11 +167,11 @@ test.write(['work2', 'src', 'bbb.in'], "work2/src/bbb.in\n") test.run(chdir = 'work2', options = opts, arguments = '.') -test.fail_test(test.read(['work2', 'build0', 'output']) != +test.must_match(['work2', 'build0', 'output'], """repository/src/aaa.in work2/src/bbb.in repository/src/ccc.in -""") +""", mode='r') test.fail_test(os.path.exists('work2/build0/aaa.in')) test.fail_test(os.path.exists('work2/build0/bbb.in')) @@ -180,11 +180,11 @@ test.fail_test(os.path.exists('work2/build0/aaa.mid')) test.fail_test(not os.path.exists('work2/build0/bbb.mid')) test.fail_test(os.path.exists('work2/build0/ccc.mid')) -test.fail_test(test.read(['work2', 'build1', 'output']) != +test.must_match(['work2', 'build1', 'output'], """repository/src/aaa.in work2/src/bbb.in repository/src/ccc.in -""") +""", mode='r') test.fail_test(not os.path.exists('work2/build1/aaa.in')) test.fail_test(not os.path.exists('work2/build1/bbb.in')) diff --git a/test/Repository/option-c.py b/test/Repository/option-c.py index c06c7d8..b0d8533 100644 --- a/test/Repository/option-c.py +++ b/test/Repository/option-c.py @@ -66,7 +66,7 @@ def copy(env, source, target): source = str(source[0]) target = str(target[0]) print('copy() < %s > %s' % (source, target)) - open(target, "wb").write(open(source, "rb").read()) + open(target, "w").write(open(source, "r").read()) Build = Builder(action=copy) env = Environment(BUILDERS={'Build':Build}) @@ -100,14 +100,14 @@ test.writable('repository', 0) # copying them from the Repository. test.run(chdir = 'work', options = opts, arguments = '.') -test.fail_test(test.read(work_aaa_mid) != "repository/aaa.in\n") -test.fail_test(test.read(work_aaa_out) != "repository/aaa.in\n") -test.fail_test(test.read(work_bbb_mid) != "repository/bbb.in\n") -test.fail_test(test.read(work_bbb_out) != "repository/bbb.in\n") -test.fail_test(test.read(work_subdir_ccc_mid) != "repository/subdir/ccc.in\n") -test.fail_test(test.read(work_subdir_ccc_out) != "repository/subdir/ccc.in\n") -test.fail_test(test.read(work_subdir_ddd_mid) != "repository/subdir/ddd.in\n") -test.fail_test(test.read(work_subdir_ddd_out) != "repository/subdir/ddd.in\n") +test.must_match(work_aaa_mid, "repository/aaa.in\n", mode='r') +test.must_match(work_aaa_out, "repository/aaa.in\n", mode='r') +test.must_match(work_bbb_mid, "repository/bbb.in\n", mode='r') +test.must_match(work_bbb_out, "repository/bbb.in\n", mode='r') +test.must_match(work_subdir_ccc_mid, "repository/subdir/ccc.in\n", mode='r') +test.must_match(work_subdir_ccc_out, "repository/subdir/ccc.in\n", mode='r') +test.must_match(work_subdir_ddd_mid, "repository/subdir/ddd.in\n", mode='r') +test.must_match(work_subdir_ddd_out, "repository/subdir/ddd.in\n", mode='r') test.up_to_date(chdir = 'work', options = opts, arguments = '.') @@ -117,14 +117,14 @@ test.writable('repository', 1) # Now build everything in the repository. test.run(chdir = 'repository', options = opts, arguments = '.') -test.fail_test(test.read(repository_aaa_mid) != "repository/aaa.in\n") -test.fail_test(test.read(repository_aaa_out) != "repository/aaa.in\n") -test.fail_test(test.read(repository_bbb_mid) != "repository/bbb.in\n") -test.fail_test(test.read(repository_bbb_out) != "repository/bbb.in\n") -test.fail_test(test.read(repository_subdir_ccc_mid) != "repository/subdir/ccc.in\n") -test.fail_test(test.read(repository_subdir_ccc_out) != "repository/subdir/ccc.in\n") -test.fail_test(test.read(repository_subdir_ddd_mid) != "repository/subdir/ddd.in\n") -test.fail_test(test.read(repository_subdir_ddd_out) != "repository/subdir/ddd.in\n") +test.must_match(repository_aaa_mid, "repository/aaa.in\n", mode='r') +test.must_match(repository_aaa_out, "repository/aaa.in\n", mode='r') +test.must_match(repository_bbb_mid, "repository/bbb.in\n", mode='r') +test.must_match(repository_bbb_out, "repository/bbb.in\n", mode='r') +test.must_match(repository_subdir_ccc_mid, "repository/subdir/ccc.in\n", mode='r') +test.must_match(repository_subdir_ccc_out, "repository/subdir/ccc.in\n", mode='r') +test.must_match(repository_subdir_ddd_mid, "repository/subdir/ddd.in\n", mode='r') +test.must_match(repository_subdir_ddd_out, "repository/subdir/ddd.in\n", mode='r') test.up_to_date(chdir = 'repository', options = opts, arguments = '.') @@ -135,20 +135,20 @@ test.writable('repository', 0) # test.run(chdir = 'work', options = opts + ' -c', arguments = 'bbb.mid bbb.out') -test.fail_test(test.read(work_aaa_mid) != "repository/aaa.in\n") -test.fail_test(test.read(work_aaa_out) != "repository/aaa.in\n") +test.must_match(work_aaa_mid, "repository/aaa.in\n", mode='r') +test.must_match(work_aaa_out, "repository/aaa.in\n", mode='r') test.fail_test(os.path.exists(work_bbb_mid)) test.fail_test(os.path.exists(work_bbb_out)) -test.fail_test(test.read(work_subdir_ccc_mid) != "repository/subdir/ccc.in\n") -test.fail_test(test.read(work_subdir_ccc_out) != "repository/subdir/ccc.in\n") -test.fail_test(test.read(work_subdir_ddd_mid) != "repository/subdir/ddd.in\n") -test.fail_test(test.read(work_subdir_ddd_out) != "repository/subdir/ddd.in\n") +test.must_match(work_subdir_ccc_mid, "repository/subdir/ccc.in\n", mode='r') +test.must_match(work_subdir_ccc_out, "repository/subdir/ccc.in\n", mode='r') +test.must_match(work_subdir_ddd_mid, "repository/subdir/ddd.in\n", mode='r') +test.must_match(work_subdir_ddd_out, "repository/subdir/ddd.in\n", mode='r') # test.run(chdir = 'work', options = opts + ' -c', arguments = 'subdir') -test.fail_test(test.read(work_aaa_mid) != "repository/aaa.in\n") -test.fail_test(test.read(work_aaa_out) != "repository/aaa.in\n") +test.must_match(work_aaa_mid, "repository/aaa.in\n", mode='r') +test.must_match(work_aaa_out, "repository/aaa.in\n", mode='r') test.fail_test(os.path.exists(work_bbb_mid)) test.fail_test(os.path.exists(work_bbb_out)) test.fail_test(os.path.exists(work_subdir_ccc_mid)) @@ -169,14 +169,14 @@ test.fail_test(os.path.exists(work_subdir_ddd_mid)) test.fail_test(os.path.exists(work_subdir_ddd_out)) # Double-check that nothing in the repository got deleted. -test.fail_test(test.read(repository_aaa_mid) != "repository/aaa.in\n") -test.fail_test(test.read(repository_aaa_out) != "repository/aaa.in\n") -test.fail_test(test.read(repository_bbb_mid) != "repository/bbb.in\n") -test.fail_test(test.read(repository_bbb_out) != "repository/bbb.in\n") -test.fail_test(test.read(repository_subdir_ccc_mid) != "repository/subdir/ccc.in\n") -test.fail_test(test.read(repository_subdir_ccc_out) != "repository/subdir/ccc.in\n") -test.fail_test(test.read(repository_subdir_ddd_mid) != "repository/subdir/ddd.in\n") -test.fail_test(test.read(repository_subdir_ddd_out) != "repository/subdir/ddd.in\n") +test.must_match(repository_aaa_mid, "repository/aaa.in\n", mode='r') +test.must_match(repository_aaa_out, "repository/aaa.in\n", mode='r') +test.must_match(repository_bbb_mid, "repository/bbb.in\n", mode='r') +test.must_match(repository_bbb_out, "repository/bbb.in\n", mode='r') +test.must_match(repository_subdir_ccc_mid, "repository/subdir/ccc.in\n", mode='r') +test.must_match(repository_subdir_ccc_out, "repository/subdir/ccc.in\n", mode='r') +test.must_match(repository_subdir_ddd_mid, "repository/subdir/ddd.in\n", mode='r') +test.must_match(repository_subdir_ddd_out, "repository/subdir/ddd.in\n", mode='r') # test.pass_test() diff --git a/test/Repository/option-f.py b/test/Repository/option-f.py index 8511f6a..c990f2f 100644 --- a/test/Repository/option-f.py +++ b/test/Repository/option-f.py @@ -76,7 +76,7 @@ test.writable('repository', 0) # test.run(chdir = 'work', options = opts, arguments = 'aaa.out') -test.fail_test(test.read(['work', 'aaa.out']) != "repository/aaa.in\n") +test.must_match(['work', 'aaa.out'], "repository/aaa.in\n", mode='r') test.fail_test(os.path.exists(test.workpath('work', 'bbb.out'))) test.fail_test(os.path.exists(test.workpath('work', 'ccc.out'))) test.fail_test(os.path.exists(test.workpath('work', 'src', 'xxx.out'))) @@ -84,15 +84,15 @@ test.fail_test(os.path.exists(test.workpath('work', 'src', 'yyy.out'))) test.run(chdir = 'work', options = opts, arguments = 'bbb.out src') -test.fail_test(test.read(['work', 'bbb.out']) != "repository/bbb.in\n") +test.must_match(['work', 'bbb.out'], "repository/bbb.in\n", mode='r') test.fail_test(os.path.exists(test.workpath('work', 'ccc.out'))) -test.fail_test(test.read(['work', 'src', 'xxx.out']) != "repository/src/xxx.in\n") -test.fail_test(test.read(['work', 'src', 'yyy.out']) != "repository/src/yyy.in\n") +test.must_match(['work', 'src', 'xxx.out'], "repository/src/xxx.in\n", mode='r') +test.must_match(['work', 'src', 'yyy.out'], "repository/src/yyy.in\n", mode='r') # test.run(chdir = 'work', options = opts, arguments = '.') -test.fail_test(test.read(['work', 'ccc.out']) != "repository/ccc.in\n") +test.must_match(['work', 'ccc.out'], "repository/ccc.in\n", mode='r') # test.pass_test() diff --git a/test/Repository/option-n.py b/test/Repository/option-n.py index 2a0ae5d..d23a200 100644 --- a/test/Repository/option-n.py +++ b/test/Repository/option-n.py @@ -49,7 +49,7 @@ def copy(env, source, target): source = str(source[0]) target = str(target[0]) print('copy() < %s > %s' % (source, target)) - open(target, "wb").write(open(source, "rb").read()) + open(target, "w").write(open(source, "r").read()) Build = Builder(action=copy) env = Environment(BUILDERS={'Build':Build}) @@ -62,7 +62,7 @@ test.write(['repository', 'aaa.in'], "repository/aaa.in\n") # test.run(chdir = 'repository', options = opts, arguments = '.') -test.fail_test(test.read(repository_aaa_out) != "repository/aaa.in\n") +test.must_match(repository_aaa_out,"repository/aaa.in\n", mode='r') test.up_to_date(chdir = 'repository', options = opts, arguments = '.') @@ -88,7 +88,7 @@ test.run(chdir = 'work', arguments = 'aaa.out', stdout = expect) -test.fail_test(test.read(work_aaa_out) != "repository/aaa.in\n") +test.must_match(work_aaa_out, "repository/aaa.in\n", mode='r') # test.pass_test() diff --git a/test/Repository/targets.py b/test/Repository/targets.py index 0fbc896..0bc625a 100644 --- a/test/Repository/targets.py +++ b/test/Repository/targets.py @@ -44,9 +44,9 @@ def cat(env, source, target): target = str(target[0]) source = list(map(str, source)) print('cat(%s) > %s' % (source, target)) - f = open(target, "wb") + f = open(target, "w") for src in source: - f.write(open(src, "rb").read()) + f.write(open(src, "r").read()) f.close() env = Environment(BUILDERS={'Build':Builder(action=cat)}) @@ -77,7 +77,7 @@ test.writable('repository', 0) # test.run(chdir = 'work', options = opts, arguments = 'aaa.out') -test.fail_test(test.read(['work', 'aaa.out']) != "repository/aaa.in\n") +test.must_match(['work', 'aaa.out'], "repository/aaa.in\n", mode='r') test.fail_test(os.path.exists(test.workpath('work', 'bbb.out'))) test.fail_test(os.path.exists(test.workpath('work', 'ccc.out'))) test.fail_test(os.path.exists(test.workpath('work', 'src', 'xxx.out'))) @@ -85,15 +85,15 @@ test.fail_test(os.path.exists(test.workpath('work', 'src', 'yyy.out'))) test.run(chdir = 'work', options = opts, arguments = 'bbb.out src') -test.fail_test(test.read(['work', 'bbb.out']) != "repository/bbb.in\n") +test.must_match(['work', 'bbb.out'], "repository/bbb.in\n", mode='r') test.fail_test(os.path.exists(test.workpath('work', 'ccc.out'))) -test.fail_test(test.read(['work', 'src', 'xxx.out']) != "repository/src/xxx.in\n") -test.fail_test(test.read(['work', 'src', 'yyy.out']) != "repository/src/yyy.in\n") +test.must_match(['work', 'src', 'xxx.out'], "repository/src/xxx.in\n", mode='r') +test.must_match(['work', 'src', 'yyy.out'], "repository/src/yyy.in\n", mode='r') # test.run(chdir = 'work', options = opts, arguments = '.') -test.fail_test(test.read(['work', 'ccc.out']) != "repository/ccc.in\n") +test.must_match(['work', 'ccc.out'], "repository/ccc.in\n", mode='r') # test.pass_test() diff --git a/test/Scanner/FindPathDirs.py b/test/Scanner/FindPathDirs.py index ef3ea46..7f8b993 100644 --- a/test/Scanner/FindPathDirs.py +++ b/test/Scanner/FindPathDirs.py @@ -41,14 +41,14 @@ test.write('build.py', r""" import os.path import sys path = sys.argv[1].split() -input = open(sys.argv[2], 'rb') -output = open(sys.argv[3], 'wb') +input = open(sys.argv[2], 'r') +output = open(sys.argv[3], 'w') def find_file(f): for dir in path: p = dir + os.sep + f if os.path.exists(p): - return open(p, 'rb') + return open(p, 'r') return None def process(infp, outfp): diff --git a/test/Scanner/Scanner.py b/test/Scanner/Scanner.py index 8d48b73..625b372 100644 --- a/test/Scanner/Scanner.py +++ b/test/Scanner/Scanner.py @@ -32,14 +32,14 @@ test = TestSCons.TestSCons() test.write('build.py', r""" import sys -input = open(sys.argv[1], 'rb') -output = open(sys.argv[2], 'wb') +input = open(sys.argv[1], 'r') +output = open(sys.argv[2], 'w') def process(infp, outfp): for line in infp.readlines(): if line[:8] == 'include ': file = line[8:-1] - process(open(file, 'rb'), outfp) + process(open(file, 'r'), outfp) elif line[:8] == 'getfile ': outfp.write('include ') outfp.write(line[8:]) @@ -114,7 +114,7 @@ bar = env.BarBld(target='bar', source='bar.in') # automatically applied to targets generated from that Builder def blork(env, target, source): - open(str(target[0]), 'wb').write( + open(str(target[0]), 'w').write( source[0].get_text_contents().replace('getfile', 'MISSEDME')) kbld = Builder(action=r'%(_python_)s build.py $SOURCES $TARGET', diff --git a/test/Scanner/generated.py b/test/Scanner/generated.py index 7246cbe..9dd2a86 100644 --- a/test/Scanner/generated.py +++ b/test/Scanner/generated.py @@ -301,7 +301,7 @@ import os Scanned = {} def write_out(file, dict): - f = open(file, 'wb') + f = open(file, 'w') for k in sorted(dict.keys()): file = os.path.split(k)[1] f.write(file + ": " + str(dict[k]) + "\\n") diff --git a/test/Scanner/no-Dir-node.py b/test/Scanner/no-Dir-node.py index 3a918bf..123764e 100644 --- a/test/Scanner/no-Dir-node.py +++ b/test/Scanner/no-Dir-node.py @@ -54,16 +54,16 @@ test.write('build.py', r""" import os.path import sys path = sys.argv[1].split() -input = open(sys.argv[2], 'rb') -output = open(sys.argv[3], 'wb') +input = open(sys.argv[2], 'r') +output = open(sys.argv[3], 'w') def find_file(f): if os.path.isabs(f): - return open(f, 'rb') + return open(f, 'r') for dir in path: p = dir + os.sep + f if os.path.exists(p): - return open(p, 'rb') + return open(p, 'r') return None def process(infp, outfp): @@ -81,7 +81,7 @@ sys.exit(0) test.write('SConstruct', """\ def foo(target, source, env): - fp = open(str(target[0]), 'wb') + fp = open(str(target[0]), 'w') for c in sorted(source[0].children(), key=lambda t: t.name): fp.write('%s\\n' % c) fp.close() diff --git a/test/TAR/TAR.py b/test/TAR/TAR.py index 8aa2747..65e6182 100644 --- a/test/TAR/TAR.py +++ b/test/TAR/TAR.py @@ -44,15 +44,11 @@ for opt, arg in opts: if opt == '-f': out = arg def process(outfile, name): if os.path.isdir(name): - ## TODO 2.4: the next three lines can be replaced by - #for entry in sorted(os.listdir(name)): - list = os.listdir(name) - list.sort() - for entry in list: + for entry in sorted(os.listdir(name)): process(outfile, os.path.join(name, entry)) else: - outfile.write(open(name, 'rb').read()) -outfile = open(out, 'wb') + outfile.write(open(name, 'r').read()) +outfile = open(out, 'w') for infile in args: process(outfile, infile) outfile.close() @@ -77,11 +73,11 @@ test.write(['sub1', 'file6'], "sub1/file6\n") test.run(arguments = 'aaa.tar', stderr = None) -test.fail_test(test.read('aaa.tar') != "file1\nfile2\nfile3\n") +test.must_match('aaa.tar', "file1\nfile2\nfile3\n", mode='r') test.run(arguments = 'bbb.tar', stderr = None) -test.fail_test(test.read('bbb.tar') != "sub1/file5\nsub1/file6\nfile4\n") +test.must_match('bbb.tar', "sub1/file5\nsub1/file6\nfile4\n", mode='r') tar = test.detect('TAR', 'tar') diff --git a/test/TAR/TARFLAGS.py b/test/TAR/TARFLAGS.py index 034539c..e1eae0f 100644 --- a/test/TAR/TARFLAGS.py +++ b/test/TAR/TARFLAGS.py @@ -46,15 +46,11 @@ for opt, arg in cmd_opts: else: opt_string = opt_string + ' ' + opt def process(outfile, name): if os.path.isdir(name): - ## TODO 2.5: the next three lines can be replaced by - #for entry in sorted(os.listdir(name)): - entries = os.listdir(name) - entries.sort() - for entry in entries: + for entry in sorted(os.listdir(name)): process(outfile, os.path.join(name, entry)) else: - outfile.write(open(name, 'rb').read()) -outfile = open(out, 'wb') + outfile.write(open(name, 'r').read()) +outfile = open(out, 'w') outfile.write('options: %s\\n' % opt_string) for infile in args: process(outfile, infile) @@ -82,11 +78,11 @@ test.write(['sub1', 'file6'], "sub1/file6\n") test.run(arguments = 'aaa.tar', stderr = None) -test.fail_test(test.read('aaa.tar') != "options: -x\nfile1\nfile2\nfile3\n") +test.must_match('aaa.tar', "options: -x\nfile1\nfile2\nfile3\n", mode='r') test.run(arguments = 'bbb.tar', stderr = None) -test.fail_test(test.read('bbb.tar') != "options: -x\nsub1/file5\nsub1/file6\nfile4\n") +test.must_match('bbb.tar', "options: -x\nsub1/file5\nsub1/file6\nfile4\n", mode='r') diff --git a/test/TEX/LATEXFLAGS.py b/test/TEX/LATEXFLAGS.py index 46e0479..48cfa9c 100644 --- a/test/TEX/LATEXFLAGS.py +++ b/test/TEX/LATEXFLAGS.py @@ -43,8 +43,8 @@ opt_string = '' for opt, arg in cmd_opts: opt_string = opt_string + ' ' + opt base_name = os.path.splitext(args[0])[0] -infile = open(args[0], 'rb') -out_file = open(base_name+'.dvi', 'wb') +infile = open(args[0], 'r') +out_file = open(base_name+'.dvi', 'w') out_file.write(opt_string + "\n") for l in infile.readlines(): if l[0] != '\\': @@ -70,9 +70,9 @@ test.write('test2.latex', r"""This is a .latex test. test.run(arguments = '.', stderr = None) -test.fail_test(test.read('test1.dvi') != " -x\nThis is a .ltx test.\n") +test.must_match('test1.dvi', " -x\nThis is a .ltx test.\n", mode='r') -test.fail_test(test.read('test2.dvi') != " -t\nThis is a .latex test.\n") +test.must_match('test2.dvi', " -t\nThis is a .latex test.\n", mode='r') @@ -111,7 +111,7 @@ This is the %s LaTeX file. test.run(arguments = 'bar.dvi', stderr = None) - test.fail_test(test.read('wrapper.out') != "wrapper.py\n") + test.must_match('wrapper.out', "wrapper.py\n", mode='r') test.fail_test(not os.path.exists(test.workpath('bar.dvi'))) diff --git a/test/Variables/Variables.py b/test/Variables/Variables.py index 1c60635..2f4f69e 100644 --- a/test/Variables/Variables.py +++ b/test/Variables/Variables.py @@ -320,7 +320,10 @@ opts.Add('UNSPECIFIED', env = Environment(variables=opts) -Help('Variables settable in custom.py or on the command line:\\n' + opts.GenerateHelpText(env,sort=cmp)) +def compare(a,b): + return a < b + +Help('Variables settable in custom.py or on the command line:\\n' + opts.GenerateHelpText(env,sort=compare)) """) diff --git a/test/VariantDir/Clean.py b/test/VariantDir/Clean.py index d1e0bb8..b2e93a3 100644 --- a/test/VariantDir/Clean.py +++ b/test/VariantDir/Clean.py @@ -43,8 +43,8 @@ VariantDir('build1', '.', duplicate=1) def build_sample(target, source, env): targetdir = str(target[0].dir) target = str(target[0]) - open(target, 'wb').write(open(str(source[0]), 'rb').read()) - open(targetdir+'/sample.junk', 'wb').write('Side effect!\\n') + open(target, 'w').write(open(str(source[0]), 'r').read()) + open(targetdir+'/sample.junk', 'w').write('Side effect!\\n') t0 = Command("build0/sample.out", "sample.in", build_sample) t1 = Command("build1/sample.out", "sample.in", build_sample) diff --git a/test/VariantDir/File-create.py b/test/VariantDir/File-create.py index 725404c..50db618 100644 --- a/test/VariantDir/File-create.py +++ b/test/VariantDir/File-create.py @@ -49,12 +49,12 @@ SConscript('src/SConscript', variant_dir='build1', chdir=1, duplicate=1) test.write(['src', 'SConscript'], """\ #f1_in = File('f1.in') #Command('f1.out', f1_in, Copy('$TARGET', '$SOURCE')) -#open('f1.in', 'wb').write("f1.in\\n") +#open('f1.in', 'w').write("f1.in\\n") f2_in = File('f2.in') str(f2_in) Command('f2.out', f2_in, Copy('$TARGET', '$SOURCE')) -open('f2.in', 'wb').write("f2.in\\n") +open('f2.in', 'w').write("f2.in\\n") """) test.run(arguments = '--tree=all .') diff --git a/test/VariantDir/errors.py b/test/VariantDir/errors.py index d1490d4..c74d103 100644 --- a/test/VariantDir/errors.py +++ b/test/VariantDir/errors.py @@ -57,9 +57,9 @@ def fake_scan(node, env, target): def cat(env, source, target): target = str(target[0]) - f = open(target, "wb") + f = open(target, "w") for src in source: - f.write(open(str(src), "rb").read()) + f.write(open(str(src), "r").read()) f.close() env = Environment(BUILDERS={'Build':Builder(action=cat)}, @@ -77,7 +77,7 @@ env.Build('file.out', 'file.in') # Just verify that the normal case works fine. test.run(chdir = 'normal', arguments = ".") -test.fail_test(test.read(['normal', 'build', 'file.out']) != "normal/src/file.in\n") +test.must_match(['normal', 'build', 'file.out'], "normal/src/file.in\n", mode='r') # Verify the error when the VariantDir itself is read-only. Don't bother # to test this on Windows, because the ACL (I think) still allows the diff --git a/test/builderrors.py b/test/builderrors.py index 88015f1..a3e2f4d 100644 --- a/test/builderrors.py +++ b/test/builderrors.py @@ -38,8 +38,8 @@ test.write('build.py', r""" import sys exitval = int(sys.argv[1]) if exitval == 0: - contents = open(sys.argv[3], 'rb').read() - file = open(sys.argv[2], 'wb') + contents = open(sys.argv[3], 'r').read() + file = open(sys.argv[2], 'w') file.write(contents) file.close() sys.exit(exitval) @@ -81,7 +81,7 @@ test.write(['two', 'f3.in'], "two/f3.in\n") test.run(chdir = 'two', arguments = "f1.out f2.out f3.out", stderr = "scons: *** [f2.out] Error 1\n", status = 2) -test.fail_test(test.read(['two', 'f1.out']) != "two/f1.in\n") +test.must_match(['two', 'f1.out'], "two/f1.in\n", mode='r') test.fail_test(os.path.exists(test.workpath('f2.out'))) test.fail_test(os.path.exists(test.workpath('f3.out'))) @@ -101,8 +101,8 @@ test.write(['three', 'f3.in'], "three/f3.in\n") test.run(chdir = 'three', arguments = "f1.out f2.out f3.out", stderr = "scons: *** [f3.out] Error 1\n", status = 2) -test.fail_test(test.read(['three', 'f1.out']) != "three/f1.in\n") -test.fail_test(test.read(['three', 'f2.out']) != "three/f2.in\n") +test.must_match(['three', 'f1.out'], "three/f1.in\n", mode='r') +test.must_match(['three', 'f2.out'], "three/f2.in\n", mode='r') test.fail_test(os.path.exists(test.workpath('f3.out'))) test.write('SConstruct', """ -- cgit v0.12 From ad37a0b5edfc7b942b3122fed7780ca07b54aec0 Mon Sep 17 00:00:00 2001 From: Russel Winder Date: Mon, 13 Mar 2017 08:58:20 +0000 Subject: Update the changes file for the change of default D tool ordering. --- src/CHANGES.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 4a7576e..d6eed68 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -13,6 +13,9 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER RELEASE VERSION/DATE TO BE FILLED IN LATER + From Russel Winder: + - Reordered the default D tools from "dmd, gdc, ldc" to "dmd, ldc, gdc". + From William Blevins: - Updated D language scanner support to latest: 2.071.1. (PR #1924) https://dlang.org/spec/module.html accessed 11 August 2016 @@ -146,7 +149,7 @@ RELEASE 2.4.1 - Mon, 07 Nov 2015 10:37:21 -0700 and continuing. From Hiroaki Itoh : - - Add support `Microsoft Visual C++ Compiler for Python 2.7' + - Add support `Microsoft Visual C++ Compiler for Python 2.7' Compiler can be obtained at: https://www.microsoft.com/en-us/download/details.aspx?id=44266 From Florian Miedniak: -- cgit v0.12 From 8d600a70cdbdaf648e0ef5405cb8d321de12a4a2 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 13 Mar 2017 09:10:21 -0400 Subject: fix unicode usage for --debug=tree py2/3 --- src/engine/SCons/Util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 9d125ae..6d7b0a7 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -308,7 +308,7 @@ def print_tree(root, child_func, prune=0, showtags=0, margin=[0], visited=None): ' N = no clean\n' + ' H = no cache\n' + '\n') - sys.stdout.write(u(legend)) + sys.stdout.write(legend) tags = ['['] tags.append(' E'[IDX(root.exists())]) -- cgit v0.12 From 3b23df1f6b2135739b988a497d98d85dd8a806fa Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 13 Mar 2017 10:44:38 -0400 Subject: py2/3 fix rb/wb, switch to must_match and mode='r' --- test/Ghostscript/GS.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/Ghostscript/GS.py b/test/Ghostscript/GS.py index daeea09..3f5aa58 100644 --- a/test/Ghostscript/GS.py +++ b/test/Ghostscript/GS.py @@ -38,8 +38,8 @@ test = TestSCons.TestSCons() test.write('mygs.py', r""" import os import sys -outfile = open(sys.argv[1], 'wb') -infile = open(sys.argv[2], 'rb') +outfile = open(sys.argv[1], 'w') +infile = open(sys.argv[2], 'r') for l in infile.readlines(): if l[:3] != '#ps': outfile.write(l) @@ -60,8 +60,8 @@ test.write('test1.ps', r"""This is a .ps test. test.run(arguments = '.', stderr = None) -test.fail_test(test.read('test1.pdf') != "This is a .ps test.\n") -test.fail_test(test.read('test2.pdf') != "This is a .ps test.\n") +test.must_match('test1.pdf', "This is a .ps test.\n", mode='r') +test.must_match('test2.pdf', "This is a .ps test.\n", mode='r') @@ -79,7 +79,7 @@ if gs: import os import sys cmd = " ".join(sys.argv[1:]) -open('%s', 'ab').write("%%s\\n" %% cmd) +open('%s', 'a').write("%%s\\n" %% cmd) os.system(cmd) """ % test.workpath('wrapper.out').replace('\\', '\\\\')) @@ -110,7 +110,7 @@ bar.PDF(target = 'bar.pdf', source = 'bar.ps') test.run(arguments = 'bar.pdf', stderr = None) - test.fail_test(test.read('wrapper.out') != "%s -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=bar.pdf bar.ps\n" % gs_executable) + test.must_match('wrapper.out', "%s -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=bar.pdf bar.ps\n" % gs_executable, mode='r') test.fail_test(not os.path.exists(test.workpath('bar.pdf'))) -- cgit v0.12 -- cgit v0.12 From 13cb7953e6d2057252239a649364255280d69cfb Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 13 Mar 2017 13:53:31 -0400 Subject: Fix name shadowing trap brought to light by py3s changes in module import see: http://python-notes.curiousefficiency.org/en/latest/python_concepts/import_traps.html#the-name-shadowing-trap --- test/option/option_profile.py | 122 ++++++++++++++++++++++++++++++++++++++++++ test/option/profile.py | 118 ---------------------------------------- 2 files changed, 122 insertions(+), 118 deletions(-) create mode 100644 test/option/option_profile.py delete mode 100644 test/option/profile.py diff --git a/test/option/option_profile.py b/test/option/option_profile.py new file mode 100644 index 0000000..cb9d22c --- /dev/null +++ b/test/option/option_profile.py @@ -0,0 +1,122 @@ +#!/usr/bin/env python +# +# __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__" + +import sys + +if sys.version_info[0] < 3: + import io + _StringIO = io.StringIO + # TODO(2.6): In 2.6 and beyond, the io.StringIO.write() method + # requires unicode strings. This subclass can probably be removed + # when we drop support for Python 2.6. + class StringIO(_StringIO): + def write(self, s): + _StringIO.write(self, unicode(s)) +else: + from io import StringIO + +import TestSCons + +test = TestSCons.TestSCons() + +try: + import pstats +except ImportError: + test.skip_test('No pstats module, skipping test.\n') + +test.write('SConstruct', """\ +Command('file.out', 'file.in', Copy("$TARGET", "$SOURCE")) +""") + +test.write('file.in', "file.in\n") + +scons_prof = test.workpath('scons.prof') + +test.run(arguments = "--profile=%s -h" % scons_prof) +test.must_contain_all_lines(test.stdout(), ['usage: scons [OPTION]']) + +try: + save_stdout = sys.stdout + sys.stdout = StringIO() + + stats = pstats.Stats(scons_prof) + stats.sort_stats('time') + + stats.strip_dirs().print_stats() + + s = sys.stdout.getvalue() +finally: + sys.stdout = save_stdout + +test.must_contain_all_lines(s, ['Main.py', '_main']) + + + +scons_prof = test.workpath('scons2.prof') + +test.run(arguments = "--profile %s" % scons_prof) + +try: + save_stdout = sys.stdout + sys.stdout = StringIO() + + stats = pstats.Stats(scons_prof) + stats.sort_stats('time') + + stats.strip_dirs().print_stats() + + s = sys.stdout.getvalue() +finally: + sys.stdout = save_stdout + +test.must_contain_all_lines(s, ['Main.py', '_main', 'FS.py']) + + + +scons_prof = test.workpath('scons3.prof') + +test.run(arguments = "--profile %s --debug=memory -h" % scons_prof) +expect = [ + 'usage: scons [OPTION]', + 'Options:' +] +test.must_contain_all_lines(test.stdout(), expect) + +expect = 'Memory before reading SConscript files' +lines = test.stdout().split('\n') +memory_lines = [l for l in lines if l.find(expect) != -1] + +test.fail_test(len(memory_lines) != 1) + + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/option/profile.py b/test/option/profile.py deleted file mode 100644 index 4d942cf..0000000 --- a/test/option/profile.py +++ /dev/null @@ -1,118 +0,0 @@ -#!/usr/bin/env python -# -# __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__" - -import sys -import io -_StringIO = io.StringIO -# TODO(2.6): In 2.6 and beyond, the io.StringIO.write() method -# requires unicode strings. This subclass can probably be removed -# when we drop support for Python 2.6. -class StringIO(_StringIO): - def write(self, s): - _StringIO.write(self, unicode(s)) - -import TestSCons - -test = TestSCons.TestSCons() - -try: - import pstats -except ImportError: - test.skip_test('No pstats module, skipping test.\n') - -test.write('SConstruct', """\ -Command('file.out', 'file.in', Copy("$TARGET", "$SOURCE")) -""") - -test.write('file.in', "file.in\n") - -scons_prof = test.workpath('scons.prof') - -test.run(arguments = "--profile=%s -h" % scons_prof) -test.must_contain_all_lines(test.stdout(), ['usage: scons [OPTION]']) - -try: - save_stdout = sys.stdout - sys.stdout = StringIO() - - stats = pstats.Stats(scons_prof) - stats.sort_stats('time') - - stats.strip_dirs().print_stats() - - s = sys.stdout.getvalue() -finally: - sys.stdout = save_stdout - -test.must_contain_all_lines(s, ['Main.py', '_main']) - - - -scons_prof = test.workpath('scons2.prof') - -test.run(arguments = "--profile %s" % scons_prof) - -try: - save_stdout = sys.stdout - sys.stdout = StringIO() - - stats = pstats.Stats(scons_prof) - stats.sort_stats('time') - - stats.strip_dirs().print_stats() - - s = sys.stdout.getvalue() -finally: - sys.stdout = save_stdout - -test.must_contain_all_lines(s, ['Main.py', '_main', 'FS.py']) - - - -scons_prof = test.workpath('scons3.prof') - -test.run(arguments = "--profile %s --debug=memory -h" % scons_prof) -expect = [ - 'usage: scons [OPTION]', - 'Options:' -] -test.must_contain_all_lines(test.stdout(), expect) - -expect = 'Memory before reading SConscript files' -lines = test.stdout().split('\n') -memory_lines = [l for l in lines if l.find(expect) != -1] - -test.fail_test(len(memory_lines) != 1) - - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: -- cgit v0.12 From bebac35aa5673b46b7fde363b04e98bf416d4f18 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 13 Mar 2017 14:04:59 -0400 Subject: remove wb mode from creation of taskmaster trace file. Was breaking tests, and no reason to have such file be binary --- src/engine/SCons/Taskmaster.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/Taskmaster.py b/src/engine/SCons/Taskmaster.py index bd94972..1fe7668 100644 --- a/src/engine/SCons/Taskmaster.py +++ b/src/engine/SCons/Taskmaster.py @@ -772,7 +772,7 @@ class Taskmaster(object): self.ready_exc = None T = self.trace - if T: T.write(u'\n' + self.trace_message('Looking for a node to evaluate')) + if T: T.write('\n' + self.trace_message('Looking for a node to evaluate')) while True: node = self.next_candidate() -- cgit v0.12 From b3520594afe39b38e4b2a380f97798f0d663e37e Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 13 Mar 2017 12:54:39 -0700 Subject: read logfile in non-binary mode --- QMTest/TestSCons.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index f75a3cc..8d53e11 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -1013,7 +1013,7 @@ SConscript( sconscript ) nols = nols + "|" nols = nols + ")" lastEnd = 0 - logfile = self.read(self.workpath(logfile)) + logfile = self.read(self.workpath(logfile),mode='r') if (doCheckLog and logfile.find( "scons: warning: The stored build " "information has an unexpected class." ) >= 0): -- cgit v0.12 From 884bb12d7f4e3dc70e16ca9edfa807c4179bb9bb Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 13 Mar 2017 12:55:14 -0700 Subject: output from try run comes from get_content() which is bytes. So use SCons.Util.to_str to convert to string on py3 --- src/engine/SCons/SConf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/SConf.py b/src/engine/SCons/SConf.py index c68d1c6..31d9402 100644 --- a/src/engine/SCons/SConf.py +++ b/src/engine/SCons/SConf.py @@ -643,7 +643,7 @@ class SConfBase(object): node = self.env.Command(output, prog, [ [ pname, ">", "${TARGET}"] ]) ok = self.BuildNodes(node) if ok: - outputStr = output.get_contents() + outputStr = SCons.Util.to_str(output.get_contents()) return( 1, outputStr) return (0, "") -- cgit v0.12 From 1668a5976917e04d2d3349d9b2b0e4580676936f Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 13 Mar 2017 16:01:13 -0400 Subject: py2/3 remove wb from created taskmaster trace file --- src/engine/SCons/Script/Main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py index aea6bea..f9df813 100644 --- a/src/engine/SCons/Script/Main.py +++ b/src/engine/SCons/Script/Main.py @@ -1242,7 +1242,7 @@ def _build_targets(fs, options, targets, target_top): if options.taskmastertrace_file == '-': tmtrace = sys.stdout elif options.taskmastertrace_file: - tmtrace = open(options.taskmastertrace_file, 'wb') + tmtrace = open(options.taskmastertrace_file, 'w') else: tmtrace = None taskmaster = SCons.Taskmaster.Taskmaster(nodes, task_class, order, tmtrace) -- cgit v0.12 From f1c417cc221fa5635d85ec755cd64c4a0e173b39 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 13 Mar 2017 16:23:15 -0400 Subject: added and commented out some debug code which is useful for working on test failures --- QMTest/TestSCons.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index 8d53e11..76b903f 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -1014,6 +1014,10 @@ SConscript( sconscript ) nols = nols + ")" lastEnd = 0 logfile = self.read(self.workpath(logfile),mode='r') + + # Some debug code to keep around.. + # sys.stderr.write("LOGFILE[%s]:%s"%(type(logfile),logfile)) + if (doCheckLog and logfile.find( "scons: warning: The stored build " "information has an unexpected class." ) >= 0): -- cgit v0.12 From 696b6317906f07b9f473bbbdc416ebf81876dbf8 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 13 Mar 2017 16:34:29 -0400 Subject: py2/3 mode=r on test.read() --- test/Configure/config-h.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Configure/config-h.py b/test/Configure/config-h.py index ed95055..ff5e5b2 100644 --- a/test/Configure/config-h.py +++ b/test/Configure/config-h.py @@ -134,7 +134,7 @@ expected_config_h = ("""\ test.run(stdout=expected_stdout) -config_h = test.read(test.workpath('config.h')) +config_h = test.read(test.workpath('config.h'), mode='r') if expected_config_h != config_h: print("Unexpected config.h") print("Expected: ") @@ -161,7 +161,7 @@ expected_stdout = test.wrap_stdout(build_str=expected_build_str, test.run(stdout=expected_stdout) -config_h = test.read(test.workpath('config.h')) +config_h = test.read(test.workpath('config.h'),mode='r') if expected_config_h != config_h: print("Unexpected config.h") print("Expected: ") -- cgit v0.12 From 3fdddad8565973faea1f4e9a9aaf6101c4086a7e Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 13 Mar 2017 16:44:31 -0400 Subject: added TestSCons.unlink_sconsignfile(name) method to append .p3 to expected file name on py3. about 10 tests need to be changed to use this --- QMTest/TestSCons.py | 15 +++++++++++++++ test/Configure/VariantDir-SConscript.py | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index 76b903f..a8651d9 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -648,6 +648,21 @@ class TestSCons(TestCommon): result.extend(sorted(glob.glob(p))) return result + def unlink_sconsignfile(self,name='.sconsign.dblite'): + """ + Delete sconsign file. + Note on python it seems to append .p3 to the file name so we take care of that + Parameters + ---------- + name - expected name of sconsign file + + Returns + ------- + None + """ + if sys.version_info[0] == 3: + name += '.p3' + self.unlink(name) def java_ENV(self, version=None): """ diff --git a/test/Configure/VariantDir-SConscript.py b/test/Configure/VariantDir-SConscript.py index c82778a..ce26452 100644 --- a/test/Configure/VariantDir-SConscript.py +++ b/test/Configure/VariantDir-SConscript.py @@ -128,7 +128,7 @@ test.checkLogAndStdout( ["Checking for C header file math.h... ", import shutil shutil.rmtree(test.workpath(".sconf_temp")) -test.unlink(".sconsign.dblite") +test.unlink_sconsignfile(".sconsign.dblite") # now with SConscriptChdir(1) test.run(arguments='chdir=yes') -- cgit v0.12 From e3e844c8cf401233ea4cead6b834dc279f3eb44e Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 13 Mar 2017 17:31:05 -0400 Subject: remove py3 checking code --- src/script/sconsign.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/script/sconsign.py b/src/script/sconsign.py index 239979f..8f1722a 100644 --- a/src/script/sconsign.py +++ b/src/script/sconsign.py @@ -57,13 +57,6 @@ import sys # engine modules if they're in either directory. -#if sys.version_info >= (3,0,0): -# msg = "sconsign: *** Version %s does not run under Python version %s.\n\ -#Python 3 is not yet supported.\n" -# sys.stderr.write(msg % (__version__, sys.version.split()[0])) -# sys.exit(1) - - script_dir = sys.path[0] if script_dir in sys.path: @@ -528,6 +521,7 @@ for o, a in opts: elif o in ('-v', '--verbose'): Verbose = 1 + if Do_Call: for a in args: Do_Call(a) -- cgit v0.12 From 6badcc591014dc92e144e5339ffdaf98efe3c56a Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 13 Mar 2017 17:31:41 -0400 Subject: py2/3 remove code to handle dblite changing sconsigfile name --- test/Configure/VariantDir-SConscript.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Configure/VariantDir-SConscript.py b/test/Configure/VariantDir-SConscript.py index ce26452..c82778a 100644 --- a/test/Configure/VariantDir-SConscript.py +++ b/test/Configure/VariantDir-SConscript.py @@ -128,7 +128,7 @@ test.checkLogAndStdout( ["Checking for C header file math.h... ", import shutil shutil.rmtree(test.workpath(".sconf_temp")) -test.unlink_sconsignfile(".sconsign.dblite") +test.unlink(".sconsign.dblite") # now with SConscriptChdir(1) test.run(arguments='chdir=yes') -- cgit v0.12 From 75eec4b5eb4adbd3ee041021f3ee0a62c1d5b669 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 13 Mar 2017 17:32:20 -0400 Subject: remove adding .p3 suffix to dblite files for py3. TODO: make sure this doesn't cause weirdness --- src/engine/SCons/dblite.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/engine/SCons/dblite.py b/src/engine/SCons/dblite.py index e11fe77..4ef2222 100644 --- a/src/engine/SCons/dblite.py +++ b/src/engine/SCons/dblite.py @@ -38,11 +38,14 @@ except NameError: return s dblite_suffix = '.dblite' -if bytes is not str: - dblite_suffix += '.p3' + +# TODO: Does commenting this out break switching from py2/3? +# if bytes is not str: +# dblite_suffix += '.p3' tmp_suffix = '.tmp' + class dblite(object): """ Squirrel away references to the functions in various modules -- cgit v0.12 From f1fae7bc1c577ee990ae162a299bd918166454a7 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 13 Mar 2017 17:46:21 -0400 Subject: kick buildbot --- SConstruct | 1 + 1 file changed, 1 insertion(+) diff --git a/SConstruct b/SConstruct index 0cdf780..4c89ff7 100644 --- a/SConstruct +++ b/SConstruct @@ -1388,3 +1388,4 @@ for pf, help_text in packaging_flavors: os.path.join(build_dir, 'QMTest'), os.path.join(build_dir, 'runtest.py'), ]) + -- cgit v0.12 From 496d5d4655ec5eaaf5f47b70a0a5e9f08a310ff3 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 13 Mar 2017 23:07:10 -0400 Subject: py2/3 add mode='r' to must_match. Should fix some win32 failures --- test/AR/AR.py | 2 +- test/AR/ARFLAGS.py | 2 +- test/CC/CC.py | 6 +++--- test/CC/SHCC.py | 2 +- test/LINK/LINK.py | 2 +- test/LINK/SHLINK.py | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/AR/AR.py b/test/AR/AR.py index 11687d9..552b827 100644 --- a/test/AR/AR.py +++ b/test/AR/AR.py @@ -95,7 +95,7 @@ test.run(arguments = 'b' + _exe, stderr=TestSCons.noisy_ar, match=TestSCons.match_re_dotall) -test.must_match('wrapper.out', 'wrapper.py\n') +test.must_match('wrapper.out', 'wrapper.py\n', mode='r') test.pass_test() diff --git a/test/AR/ARFLAGS.py b/test/AR/ARFLAGS.py index 2d90752..2aa1a14 100644 --- a/test/AR/ARFLAGS.py +++ b/test/AR/ARFLAGS.py @@ -94,7 +94,7 @@ test.run(arguments = 'b' + _exe, stderr=TestSCons.noisy_ar, match=TestSCons.match_re_dotall) -test.must_match('wrapper.out', 'wrapper.py\n') +test.must_match('wrapper.out', 'wrapper.py\n', mode='r') test.pass_test() diff --git a/test/CC/CC.py b/test/CC/CC.py index f6c2954..6363273 100644 --- a/test/CC/CC.py +++ b/test/CC/CC.py @@ -124,7 +124,7 @@ env.Program(target = 'test1', source = 'test1.c') test.run(arguments = '.', stderr = None) -test.must_match('test1' + _exe, "This is a .c file.\n") +test.must_match('test1' + _exe, "This is a .c file.\n", mode='r') if os.path.normcase('.c') == os.path.normcase('.C'): @@ -137,7 +137,7 @@ env.Program(target = 'test2', source = 'test2.C') """ % locals()) test.run(arguments = '.', stderr = None) - test.must_match('test2' + _exe, "This is a .C file.\n") + test.must_match('test2' + _exe, "This is a .C file.\n", mode='r') test.file_fixture('wrapper.py') @@ -157,7 +157,7 @@ test.up_to_date(arguments = 'foo' + _exe) test.run(arguments = 'bar' + _exe) -test.must_match('wrapper.out', "wrapper.py\n") +test.must_match('wrapper.out', "wrapper.py\n", mode='r') test.up_to_date(arguments = 'bar' + _exe) diff --git a/test/CC/SHCC.py b/test/CC/SHCC.py index beda8e4..c756219 100644 --- a/test/CC/SHCC.py +++ b/test/CC/SHCC.py @@ -75,7 +75,7 @@ test.must_not_exist(test.workpath('wrapper.out')) test.run(arguments = 'bar') -test.must_match('wrapper.out', "wrapper.py\n") +test.must_match('wrapper.out', "wrapper.py\n", mode='r') test.pass_test() diff --git a/test/LINK/LINK.py b/test/LINK/LINK.py index 533163c..6c99134 100644 --- a/test/LINK/LINK.py +++ b/test/LINK/LINK.py @@ -74,7 +74,7 @@ test.must_not_exist(test.workpath('wrapper.out')) test.run(arguments = 'bar' + _exe) -test.must_match('wrapper.out', "wrapper.py\n") +test.must_match('wrapper.out', "wrapper.py\n", mode='r') test.pass_test() diff --git a/test/LINK/SHLINK.py b/test/LINK/SHLINK.py index 9b546c7..9d406fc 100644 --- a/test/LINK/SHLINK.py +++ b/test/LINK/SHLINK.py @@ -72,7 +72,7 @@ test.must_not_exist(test.workpath('wrapper.out')) test.run(arguments = dll_ + 'bar' + _shlib) -test.must_match('wrapper.out', "wrapper.py\n") +test.must_match('wrapper.out', "wrapper.py\n", mode='r') test.pass_test() -- cgit v0.12 From 2da21594f9468283525c27992eb8565d3473841b Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 13 Mar 2017 23:24:15 -0400 Subject: py2/3 add mode=r to must_match to fix win32 py27,py3 --- test/CXX/CXX.py | 4 ++-- test/Install/Install.py | 24 ++++++++++++------------ test/Scanner/FindPathDirs.py | 6 +++--- test/Scanner/Scanner.py | 32 ++++++++++++++++---------------- test/Scanner/generated.py | 2 +- test/Scanner/no-Dir-node.py | 4 ++-- test/VariantDir/Clean.py | 4 ++-- test/VariantDir/File-create.py | 4 ++-- 8 files changed, 40 insertions(+), 40 deletions(-) diff --git a/test/CXX/CXX.py b/test/CXX/CXX.py index 83c4285..abccf1e 100644 --- a/test/CXX/CXX.py +++ b/test/CXX/CXX.py @@ -178,7 +178,7 @@ env.Program(target = 'test6', source = 'test6.C') test.run(arguments = '.', stderr = None) - test.must_match('test6' + _exe, "This is a .C file.\n") + test.must_match('test6' + _exe, "This is a .C file.\n", mode='r') @@ -224,7 +224,7 @@ test.must_not_exist(test.workpath('wrapper.out')) test.run(arguments = 'bar' + _exe) -test.must_match('wrapper.out', "wrapper.py\n") +test.must_match('wrapper.out', "wrapper.py\n", mode='r') test.pass_test() diff --git a/test/Install/Install.py b/test/Install/Install.py index d039d78..72a7545 100644 --- a/test/Install/Install.py +++ b/test/Install/Install.py @@ -96,17 +96,17 @@ test.write(f6_txt, "f6.txt\n") test.run(chdir = 'work', arguments = '.') -test.must_match(f1_out, "f1.in\n") -test.must_match(f2_out, "f2.in\n") -test.must_match(f3_out, "f3.in\n") -test.must_match(f4_out, "sub/f4.in\n") -test.must_match(['work', 'f5.txt'], "f5.txt\n") -test.must_match(['work', 'export', 'f5.txt'], "f5.txt\n") -test.must_match(['work', 'f6.txt'], "f6.txt\n") -test.must_match(['work', 'export', 'f6.txt'], "f6.txt\n") - -test.must_match(['work', 'my_install.out'], os.path.join('export', 'f3.out')) -test.must_match(['work', 'export', 'f1.in'], "f1.in\n") +test.must_match(f1_out, "f1.in\n", mode='r') +test.must_match(f2_out, "f2.in\n", mode='r') +test.must_match(f3_out, "f3.in\n", mode='r') +test.must_match(f4_out, "sub/f4.in\n", mode='r') +test.must_match(['work', 'f5.txt'], "f5.txt\n", mode='r') +test.must_match(['work', 'export', 'f5.txt'], "f5.txt\n", mode='r') +test.must_match(['work', 'f6.txt'], "f6.txt\n", mode='r') +test.must_match(['work', 'export', 'f6.txt'], "f6.txt\n", mode='r') + +test.must_match(['work', 'my_install.out'], os.path.join('export', 'f3.out'), mode='r') +test.must_match(['work', 'export', 'f1.in'], "f1.in\n", mode='r') # make sure the programs didn't get rebuilt, because nothing changed: oldtime1 = os.path.getmtime(f1_out) @@ -123,7 +123,7 @@ test.fail_test(oldtime2 != os.path.getmtime(f2_out)) # Verify that we didn't link to the Installed file. open(f2_out, 'w').write("xyzzy\n") -test.must_match(['work', 'f2.out'], "f2.in\n") +test.must_match(['work', 'f2.out'], "f2.in\n", mode='r') # Verify that scons prints an error message # if a target can not be unlinked before building it: diff --git a/test/Scanner/FindPathDirs.py b/test/Scanner/FindPathDirs.py index 7f8b993..c56f448 100644 --- a/test/Scanner/FindPathDirs.py +++ b/test/Scanner/FindPathDirs.py @@ -124,7 +124,7 @@ test.write(['inc2', 'yyy'], "inc2/yyy 1\n") test.run() -test.must_match('foo', "foo.k 1 line 1\ninc1/xxx 1\ninc2/yyy 1\nfoo.k 1 line 4\n") +test.must_match('foo', "foo.k 1 line 1\ninc1/xxx 1\ninc2/yyy 1\nfoo.k 1 line 4\n", mode='r') test.up_to_date(arguments = '.') @@ -134,7 +134,7 @@ test.write(['inc1', 'xxx'], "inc1/xxx 2\n") test.run() -test.must_match('foo', "foo.k 1 line 1\ninc1/xxx 2\ninc2/yyy 1\nfoo.k 1 line 4\n") +test.must_match('foo', "foo.k 1 line 1\ninc1/xxx 2\ninc2/yyy 1\nfoo.k 1 line 4\n", mode='r') @@ -142,7 +142,7 @@ test.write(['inc1', 'yyy'], "inc1/yyy 2\n") test.run() -test.must_match('foo', "foo.k 1 line 1\ninc1/xxx 2\ninc1/yyy 2\nfoo.k 1 line 4\n") +test.must_match('foo', "foo.k 1 line 1\ninc1/xxx 2\ninc1/yyy 2\nfoo.k 1 line 4\n", mode='r') diff --git a/test/Scanner/Scanner.py b/test/Scanner/Scanner.py index 625b372..d5e5c3a 100644 --- a/test/Scanner/Scanner.py +++ b/test/Scanner/Scanner.py @@ -180,10 +180,10 @@ blork(["moo.ork"], ["moo.blork"]) test.run(arguments = '.', stdout=expect) -test.must_match('foo', "foo.k 1 line 1\nxxx 1\nyyy 1\nfoo.k 1 line 4\n") -test.must_match('bar', "yyy 1\nbar.in 1 line 2\nbar.in 1 line 3\nzzz 1\n") -test.must_match('junk', "yyy 1\njunk.k2 1 line 2\njunk.k2 1 line 3\nzzz 1\n") -test.must_match('moo.ork', "xxx 1\nmoo.lork 1 line 2\nyyy 1\nmoo.lork 1 line 4\ninclude zzz\n") +test.must_match('foo', "foo.k 1 line 1\nxxx 1\nyyy 1\nfoo.k 1 line 4\n", mode='r') +test.must_match('bar', "yyy 1\nbar.in 1 line 2\nbar.in 1 line 3\nzzz 1\n", mode='r') +test.must_match('junk', "yyy 1\njunk.k2 1 line 2\njunk.k2 1 line 3\nzzz 1\n", mode='r') +test.must_match('moo.ork', "xxx 1\nmoo.lork 1 line 2\nyyy 1\nmoo.lork 1 line 4\ninclude zzz\n", mode='r') test.up_to_date(arguments = '.') @@ -197,10 +197,10 @@ blork(["moo.ork"], ["moo.blork"]) test.run(arguments = '.', stdout=expect) -test.must_match('foo', "foo.k 1 line 1\nxxx 2\nyyy 1\nfoo.k 1 line 4\n") -test.must_match('bar', "yyy 1\nbar.in 1 line 2\nbar.in 1 line 3\nzzz 1\n") -test.must_match('junk', "yyy 1\njunk.k2 1 line 2\njunk.k2 1 line 3\nzzz 1\n") -test.must_match('moo.ork', "xxx 2\nmoo.lork 1 line 2\nyyy 1\nmoo.lork 1 line 4\ninclude zzz\n") +test.must_match('foo', "foo.k 1 line 1\nxxx 2\nyyy 1\nfoo.k 1 line 4\n", mode='r') +test.must_match('bar', "yyy 1\nbar.in 1 line 2\nbar.in 1 line 3\nzzz 1\n", mode='r') +test.must_match('junk', "yyy 1\njunk.k2 1 line 2\njunk.k2 1 line 3\nzzz 1\n", mode='r') +test.must_match('moo.ork', "xxx 2\nmoo.lork 1 line 2\nyyy 1\nmoo.lork 1 line 4\ninclude zzz\n", mode='r') test.write('yyy', "yyy 2\n") @@ -214,10 +214,10 @@ blork(["moo.ork"], ["moo.blork"]) test.run(arguments = '.', stdout=expect) -test.must_match('foo', "foo.k 1 line 1\nxxx 2\nyyy 2\nfoo.k 1 line 4\n") -test.must_match('bar', "yyy 2\nbar.in 1 line 2\nbar.in 1 line 3\nzzz 1\n") -test.must_match('junk', "yyy 2\njunk.k2 1 line 2\njunk.k2 1 line 3\nzzz 1\n") -test.must_match('moo.ork', "xxx 2\nmoo.lork 1 line 2\nyyy 2\nmoo.lork 1 line 4\ninclude zzz\n") +test.must_match('foo', "foo.k 1 line 1\nxxx 2\nyyy 2\nfoo.k 1 line 4\n", mode='r') +test.must_match('bar', "yyy 2\nbar.in 1 line 2\nbar.in 1 line 3\nzzz 1\n", mode='r') +test.must_match('junk', "yyy 2\njunk.k2 1 line 2\njunk.k2 1 line 3\nzzz 1\n", mode='r') +test.must_match('moo.ork', "xxx 2\nmoo.lork 1 line 2\nyyy 2\nmoo.lork 1 line 4\ninclude zzz\n", mode='r') test.write('zzz', "zzz 2\n") @@ -228,10 +228,10 @@ expect = test.wrap_stdout("""\ test.run(arguments = '.', stdout=expect) -test.must_match('foo', "foo.k 1 line 1\nxxx 2\nyyy 2\nfoo.k 1 line 4\n") -test.must_match('bar', "yyy 2\nbar.in 1 line 2\nbar.in 1 line 3\nzzz 2\n") -test.must_match('junk', "yyy 2\njunk.k2 1 line 2\njunk.k2 1 line 3\nzzz 2\n") -test.must_match('moo.ork', "xxx 2\nmoo.lork 1 line 2\nyyy 2\nmoo.lork 1 line 4\ninclude zzz\n") +test.must_match('foo', "foo.k 1 line 1\nxxx 2\nyyy 2\nfoo.k 1 line 4\n", mode='r') +test.must_match('bar', "yyy 2\nbar.in 1 line 2\nbar.in 1 line 3\nzzz 2\n", mode='r') +test.must_match('junk', "yyy 2\njunk.k2 1 line 2\njunk.k2 1 line 3\nzzz 2\n", mode='r') +test.must_match('moo.ork', "xxx 2\nmoo.lork 1 line 2\nyyy 2\nmoo.lork 1 line 4\ninclude zzz\n", mode='r') test.up_to_date(arguments = 'foo') diff --git a/test/Scanner/generated.py b/test/Scanner/generated.py index 9dd2a86..4a368b4 100644 --- a/test/Scanner/generated.py +++ b/test/Scanner/generated.py @@ -431,7 +431,7 @@ libg_gx.h: 2 libg_gy.h: 1 libg_gz.h: 1 libg_w.h: 2 -""") +""", mode='r') test.pass_test() diff --git a/test/Scanner/no-Dir-node.py b/test/Scanner/no-Dir-node.py index 123764e..69b665a 100644 --- a/test/Scanner/no-Dir-node.py +++ b/test/Scanner/no-Dir-node.py @@ -122,13 +122,13 @@ test.must_match('subdir/foo', """\ subdir/foo.k inc1/include.h inc2/include.h -""") +""", mode='r') test.must_match('list.out', """\ %(subdir_SConscript)s %(subdir_foo)s %(subdir_foo_k)s -""" % locals()) +""" % locals(), mode='r') test.pass_test() diff --git a/test/VariantDir/Clean.py b/test/VariantDir/Clean.py index b2e93a3..1287034 100644 --- a/test/VariantDir/Clean.py +++ b/test/VariantDir/Clean.py @@ -57,10 +57,10 @@ test.write('sample.in', "sample.in\n") test.run(arguments = '.') -test.must_match(['build0', 'sample.out'], "sample.in\n") +test.must_match(['build0', 'sample.out'], "sample.in\n", mode='r') test.must_exist(['build0', 'sample.junk']) -test.must_match(['build1', 'sample.out'], "sample.in\n") +test.must_match(['build1', 'sample.out'], "sample.in\n", mode='r') test.must_exist(['build1', 'sample.junk']) test.run(arguments = '-c .') diff --git a/test/VariantDir/File-create.py b/test/VariantDir/File-create.py index 50db618..25e6c09 100644 --- a/test/VariantDir/File-create.py +++ b/test/VariantDir/File-create.py @@ -60,10 +60,10 @@ open('f2.in', 'w').write("f2.in\\n") test.run(arguments = '--tree=all .') #test.must_match(['build0', 'f1.out'], "f1.in\n") -test.must_match(['build0', 'f2.out'], "f2.in\n") +test.must_match(['build0', 'f2.out'], "f2.in\n", mode='r') #test.must_match(['build1', 'f1.out'], "f1.in\n") -test.must_match(['build1', 'f2.out'], "f2.in\n") +test.must_match(['build1', 'f2.out'], "f2.in\n", mode='r') test.up_to_date(arguments = '.') -- cgit v0.12 From 61d97ad8e9952cee608d02be682c40859bc87a1b Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Mon, 13 Mar 2017 23:54:18 -0700 Subject: Use byte strings to fix test on Python 3. --- test/DVIPDF/DVIPDF.py | 6 +++--- test/DVIPS/DVIPS.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/DVIPDF/DVIPDF.py b/test/DVIPDF/DVIPDF.py index e760741..5c72231 100644 --- a/test/DVIPDF/DVIPDF.py +++ b/test/DVIPDF/DVIPDF.py @@ -41,7 +41,7 @@ base_name = os.path.splitext(arg[0])[0] infile = open(arg[0], 'rb') out_file = open(base_name+'.dvi', 'wb') for l in infile.readlines(): - if l[:4] != '#tex': + if l[:4] != b'#tex': out_file.write(l) sys.exit(0) """) @@ -55,7 +55,7 @@ base_name = os.path.splitext(arg[0])[0] infile = open(arg[0], 'rb') out_file = open(base_name+'.dvi', 'wb') for l in infile.readlines(): - if l[:6] != '#latex': + if l[:6] != b'#latex': out_file.write(l) sys.exit(0) """) @@ -68,7 +68,7 @@ cmd_opts, arg = getopt.getopt(sys.argv[1:], 'i:r:', []) infile = open(arg[0], 'rb') out_file = open(arg[1], 'wb') for l in infile.readlines(): - if l[:7] != '#dvipdf': + if l[:7] != b'#dvipdf': out_file.write(l) sys.exit(0) """) diff --git a/test/DVIPS/DVIPS.py b/test/DVIPS/DVIPS.py index b243bfc..256258f 100644 --- a/test/DVIPS/DVIPS.py +++ b/test/DVIPS/DVIPS.py @@ -41,7 +41,7 @@ base_name = os.path.splitext(arg[0])[0] infile = open(arg[0], 'rb') out_file = open(base_name+'.dvi', 'wb') for l in infile.readlines(): - if l[:4] != '#tex': + if l[:4] != b'#tex': out_file.write(l) sys.exit(0) """) @@ -55,7 +55,7 @@ base_name = os.path.splitext(arg[0])[0] infile = open(arg[0], 'rb') out_file = open(base_name+'.dvi', 'wb') for l in infile.readlines(): - if l[:6] != '#latex': + if l[:6] != b'#latex': out_file.write(l) sys.exit(0) """) @@ -66,7 +66,7 @@ import sys infile = open(sys.argv[3], 'rb') out_file = open(sys.argv[2], 'wb') for l in infile.readlines(): - if l[:6] != '#dvips': + if l[:6] != b'#dvips': out_file.write(l) sys.exit(0) """) -- cgit v0.12 From 66996d32072e71e0e464c6e380c8d1555c0592a4 Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Tue, 14 Mar 2017 00:10:22 -0700 Subject: Use byte strings to fix test on Python 3. --- test/multiline.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/multiline.py b/test/multiline.py index 18b2f21..4537eae 100644 --- a/test/multiline.py +++ b/test/multiline.py @@ -60,9 +60,9 @@ test.write('foo3.in', "foo3.in\n") test.run(arguments = 'foo1.out foo2.out foo3.out') -test.fail_test(test.read(test.workpath('foo1.out')) != "foo1.in\n") -test.fail_test(test.read(test.workpath('foo2.out')) != "foo2.in\n") -test.fail_test(test.read(test.workpath('foo3.out')) != "foo3.in\n") +test.fail_test(test.read(test.workpath('foo1.out')) != b"foo1.in\n") +test.fail_test(test.read(test.workpath('foo2.out')) != b"foo2.in\n") +test.fail_test(test.read(test.workpath('foo3.out')) != b"foo3.in\n") test.pass_test() -- cgit v0.12 From 78219fcb29554b1b18fba6590dfec57a7b896a94 Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Tue, 14 Mar 2017 00:12:18 -0700 Subject: Use byte string to fix test on Python 3 --- test/preserve-source.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/preserve-source.py b/test/preserve-source.py index b7eccd1..74fbed5 100644 --- a/test/preserve-source.py +++ b/test/preserve-source.py @@ -50,7 +50,7 @@ test.write('aaa.in', "aaa.in\n") # test.run(arguments = '.') -test.fail_test(test.read('aaa.out') != "aaa.in\n") +test.fail_test(test.read('aaa.out') != b"aaa.in\n") # test.run(arguments = "aaa.in", -- cgit v0.12 From e9cf066b38ca1b23acc96f0fdd8c6a564a0b1239 Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Tue, 14 Mar 2017 00:12:33 -0700 Subject: Use mode='r' to fix test on Python 3 --- test/special-filenames.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/special-filenames.py b/test/special-filenames.py index de09a52..798bf09 100644 --- a/test/special-filenames.py +++ b/test/special-filenames.py @@ -78,7 +78,7 @@ test.run(arguments='.') for fn in file_names: out_name = fn.replace('$$', '$') + '.out' - test.fail_test(test.read(out_name) != fn + '\n') + test.fail_test(test.read(out_name, mode='r') != fn + '\n') test.pass_test() -- cgit v0.12 From af1fb178b53c2f1eb80ed8d8554d609249a3dbe6 Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Tue, 14 Mar 2017 00:21:01 -0700 Subject: Use byte string to fix test on Python 3 --- test/no-target.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/no-target.py b/test/no-target.py index be2cd51..bce5632 100644 --- a/test/no-target.py +++ b/test/no-target.py @@ -62,9 +62,9 @@ test.write(['subdir', 'ccc', 'ccc.in'], "subdir/ccc/ccc.in\n") # test.run(arguments = '.') -test.fail_test(test.read(['subdir', 'aaa.out']) != "subdir/aaa.in\n") -test.fail_test(test.read(['subdir', 'bbb.out']) != "subdir/bbb.input\n") -test.fail_test(test.read(['subdir', 'ccc', 'ccc.out']) != "subdir/ccc/ccc.in\n") +test.fail_test(test.read(['subdir', 'aaa.out']) != b"subdir/aaa.in\n") +test.fail_test(test.read(['subdir', 'bbb.out']) != b"subdir/bbb.input\n") +test.fail_test(test.read(['subdir', 'ccc', 'ccc.out']) != b"subdir/ccc/ccc.in\n") # test.pass_test() -- cgit v0.12 From 0d2f97cc08c78c8e85d9a5e3098477b6b5b0f8e9 Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Tue, 14 Mar 2017 00:33:47 -0700 Subject: Use mode='r' to fix errors on Python 3 --- test/option-j.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/option-j.py b/test/option-j.py index acd97f8..3dbedc0 100644 --- a/test/option-j.py +++ b/test/option-j.py @@ -91,10 +91,10 @@ def RunTest(args, extra): test.run(arguments = args) - str = test.read("f1") + str = test.read("f1", mode='r') start1,finish1 = list(map(float, str.split("\n"))) - str = test.read("f2") + str = test.read("f2", mode='r') start2,finish2 = list(map(float, str.split("\n"))) return start2, finish1 @@ -148,10 +148,10 @@ if sys.platform != 'win32': \tignoring -j or num_jobs option.""" test.must_contain_all_lines(test.stderr(), [warn]) - str = test.read("f1") + str = test.read("f1", mode='r') start1,finish1 = list(map(float, str.split("\n"))) - str = test.read("f2") + str = test.read("f2", mode='r') start2,finish2 = list(map(float, str.split("\n"))) test.fail_test(start2 < finish1) -- cgit v0.12 From 2d18dafe7492488b94756146cbdae72d66f9a2bb Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Tue, 14 Mar 2017 00:35:02 -0700 Subject: Replace string.uppercase with string.ascii_uppercase to fix test on Python 3. --- test/Win32/bad-drive.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Win32/bad-drive.py b/test/Win32/bad-drive.py index 67a287a..5e8e66a 100644 --- a/test/Win32/bad-drive.py +++ b/test/Win32/bad-drive.py @@ -33,7 +33,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os import sys -from string import uppercase +from string import ascii_uppercase import TestSCons @@ -44,8 +44,8 @@ if sys.platform != 'win32': test.skip_test(msg) bad_drive = None -for i in range(len(uppercase)-1, -1, -1): - d = uppercase[i] +for i in range(len(ascii_uppercase)-1, -1, -1): + d = ascii_uppercase[i] if not os.path.isdir(d + ':' + os.sep): bad_drive = d + ':' break -- cgit v0.12 From 948fe88f6115b50958f01dc5c065132bb27b5ed6 Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Tue, 14 Mar 2017 00:46:47 -0700 Subject: Use mode='r' to fix tests on Python 3. --- test/overrides.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/overrides.py b/test/overrides.py index 69d5207..343cea4 100644 --- a/test/overrides.py +++ b/test/overrides.py @@ -77,17 +77,17 @@ env.Program('hello', 'hello.c', test.write('hello.c',"this ain't no c file!\n") test.write('mycc.py',""" -open('hello.not_obj', 'wt').write('this is no object file!') +open('hello.not_obj', 'w').write('this is no object file!') """) test.write('mylink.py',""" -open('hello.not_exe', 'wt').write('this is not a program!') +open('hello.not_exe', 'w').write('this is not a program!') """) test.run(arguments='hello.not_exe') -assert test.read('hello.not_obj') == 'this is no object file!' -assert test.read('hello.not_exe') == 'this is not a program!' +assert test.read('hello.not_obj', mode='r') == 'this is no object file!' +assert test.read('hello.not_exe', mode='r') == 'this is not a program!' test.up_to_date(arguments='hello.not_exe') @@ -121,8 +121,8 @@ scons: warning: Did you mean to use `(target|source)' instead of `(targets|sourc scons: warning: Did you mean to use `(target|source)' instead of `(targets|sources)'\? """ + TestSCons.file_expr)) -assert test.read('goodbye.not_obj') == 'this is no object file!' -assert test.read('goodbye.not_exe') == 'this is not a program!' +assert test.read('goodbye.not_obj', mode='r') == 'this is no object file!' +assert test.read('goodbye.not_exe', mode='r') == 'this is not a program!' -- cgit v0.12 From bbcb88b0be70ae0bd3e578efa7a8558427b2f0ee Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Tue, 14 Mar 2017 01:07:38 -0700 Subject: Fix bytes issues to fix test on Python 3. --- test/Scanner/unicode.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/Scanner/unicode.py b/test/Scanner/unicode.py index 2737f7d..c698532 100644 --- a/test/Scanner/unicode.py +++ b/test/Scanner/unicode.py @@ -56,6 +56,8 @@ def process(outfp, infile): contents = contents[len(codecs.BOM_UTF16_LE):].decode('utf-16-le') elif contents.startswith(codecs.BOM_UTF16_BE): contents = contents[len(codecs.BOM_UTF16_BE):].decode('utf-16-be') + else: + contents = contents.decode('ascii') for line in contents.split('\n')[:-1]: if line[:8] == 'include ': process(outfp, line[8:]) @@ -65,7 +67,7 @@ def process(outfp, infile): else: outfp.write(line + '\n') -output = open(sys.argv[2], 'wb') +output = open(sys.argv[2], 'w') process(output, sys.argv[1]) sys.exit(0) -- cgit v0.12 From 6fd4619d43e01417d521cbf915b8344baf8210bc Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 16 Mar 2017 06:16:36 -0700 Subject: py2/3 wb/rb changed --- test/explain/save-info.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/explain/save-info.py b/test/explain/save-info.py index 545f624..150d7ef 100644 --- a/test/explain/save-info.py +++ b/test/explain/save-info.py @@ -51,7 +51,7 @@ def process(outfp, infp): if line[:8] == 'include ': file = line[8:-1] try: - fp = open(file, 'rb') + fp = open(file, 'r') except IOError: import os print("os.getcwd() =", os.getcwd()) @@ -60,10 +60,10 @@ def process(outfp, infp): else: outfp.write(line) -outfp = open(sys.argv[1], 'wb') +outfp = open(sys.argv[1], 'w') for f in sys.argv[2:]: if f != '-': - process(outfp, open(f, 'rb')) + process(outfp, open(f, 'r')) sys.exit(0) """) -- cgit v0.12 From bf5bd332e1a3821ee4d78816fa1e1a14954e61b7 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 19 Mar 2017 11:41:27 -0700 Subject: allow setting PRESERVE to 0, or False to disable preserving temporary test directory --- QMTest/TestCmd.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index e76b2e3..448553f 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -901,7 +901,8 @@ class TestCmd(object): self.set_diff_function(diff, diff_stdout, diff_stderr) self._dirlist = [] self._preserve = {'pass_test': 0, 'fail_test': 0, 'no_result': 0} - if 'PRESERVE' in os.environ and not os.environ['PRESERVE'] is '': + preserve_value = os.environ.get('PRESERVE',False) + if preserve_value not in [0,'0','False']: self._preserve['pass_test'] = os.environ['PRESERVE'] self._preserve['fail_test'] = os.environ['PRESERVE'] self._preserve['no_result'] = os.environ['PRESERVE'] -- cgit v0.12 From a37f0a9a2946c17f08d74cf5b4f4015903c22da0 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 19 Mar 2017 11:42:02 -0700 Subject: remove byte regular expression as no longer valid --- SConstruct | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index 0cdf780..2930aa7 100644 --- a/SConstruct +++ b/SConstruct @@ -421,7 +421,7 @@ def soelim(target, source, env): def soscan(node, env, path): c = node.get_text_contents() - return re.compile(br"^[\.']so\s+(\S+)", re.M).findall(c) + return re.compile(r"^[\.']so\s+(\S+)", re.M).findall(c) soelimbuilder = Builder(action = Action(soelim), source_scanner = Scanner(soscan)) -- cgit v0.12 From 5029529e1907f7340b3e9be9eee4c997ad74516c Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 19 Mar 2017 11:43:24 -0700 Subject: Allow whitespace after include file name in regex. This resolves issue running with py3 on win32 (which was adding carriage returns. Remove replacing new line with cr/lf in test.must_match, this was an incorrect path to fix the test failing on win32 py3 --- test/Scanner/Scanner.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/Scanner/Scanner.py b/test/Scanner/Scanner.py index bc868e0..e5516bd 100644 --- a/test/Scanner/Scanner.py +++ b/test/Scanner/Scanner.py @@ -63,12 +63,11 @@ SConscript('SConscript') test.write('SConscript', """ import re -include_re = re.compile(r'^include\s+(\S+)$', re.M) +include_re = re.compile(r'^include\s+(\S+)\s*$', re.M) def kfile_scan(node, env, scanpaths, arg): contents = node.get_text_contents() includes = include_re.findall(contents) - print("TEXT:%%s Include:%%s"%%(contents,includes)) return includes kscan = Scanner(name = 'kfile', @@ -204,7 +203,7 @@ test.run(arguments = '.', stdout=expect) test.must_match('foo', "foo.k 1 line 1\nxxx 2\nyyy 1\nfoo.k 1 line 4\n", mode='r') test.must_match('bar', "yyy 1\nbar.in 1 line 2\nbar.in 1 line 3\nzzz 1\n", mode='r') test.must_match('junk', "yyy 1\njunk.k2 1 line 2\njunk.k2 1 line 3\nzzz 1\n", mode='r') -test.must_match('moo.third', "xxx 2\nmoo.first 1 line 2\nyyy 1\nmoo.first 1 line 4\ninclude zzz\n".replace('\n',os.linesep), mode='r') +test.must_match('moo.third', "xxx 2\nmoo.first 1 line 2\nyyy 1\nmoo.first 1 line 4\ninclude zzz\n", mode='r') test.write('yyy', "yyy 2\n",mode='w') @@ -221,7 +220,7 @@ test.run(arguments = '.', stdout=expect) test.must_match('foo', "foo.k 1 line 1\nxxx 2\nyyy 2\nfoo.k 1 line 4\n", mode='r') test.must_match('bar', "yyy 2\nbar.in 1 line 2\nbar.in 1 line 3\nzzz 1\n", mode='r') test.must_match('junk', "yyy 2\njunk.k2 1 line 2\njunk.k2 1 line 3\nzzz 1\n", mode='r') -test.must_match('moo.third', "xxx 2\nmoo.first 1 line 2\nyyy 2\nmoo.first 1 line 4\ninclude zzz\n".replace('\n',os.linesep), mode='r') +test.must_match('moo.third', "xxx 2\nmoo.first 1 line 2\nyyy 2\nmoo.first 1 line 4\ninclude zzz\n", mode='r') test.write('zzz', "zzz 2\n") @@ -235,7 +234,7 @@ test.run(arguments = '.', stdout=expect) test.must_match('foo', "foo.k 1 line 1\nxxx 2\nyyy 2\nfoo.k 1 line 4\n", mode='r') test.must_match('bar', "yyy 2\nbar.in 1 line 2\nbar.in 1 line 3\nzzz 2\n", mode='r') test.must_match('junk', "yyy 2\njunk.k2 1 line 2\njunk.k2 1 line 3\nzzz 2\n", mode='r') -test.must_match('moo.third', "xxx 2\nmoo.first 1 line 2\nyyy 2\nmoo.first 1 line 4\ninclude zzz\n".replace('\n',os.linesep), mode='r') +test.must_match('moo.third', "xxx 2\nmoo.first 1 line 2\nyyy 2\nmoo.first 1 line 4\ninclude zzz\n", mode='r') test.up_to_date(arguments = 'foo') -- cgit v0.12 From 3a9b41372bb91a7ba7bcf6f80ee11df440202909 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 19 Mar 2017 12:54:14 -0700 Subject: disable experimental win32 native CopyFile usage --- src/engine/SCons/Platform/win32.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/engine/SCons/Platform/win32.py b/src/engine/SCons/Platform/win32.py index 827931f..c6887f1 100644 --- a/src/engine/SCons/Platform/win32.py +++ b/src/engine/SCons/Platform/win32.py @@ -93,29 +93,29 @@ else: +if False: + # Now swap out shutil.filecopy and filecopy2 for win32 api native CopyFile + try: + from ctypes import windll + import shutil -# Now swap out shutil.filecopy and filecopy2 for win32 api native CopyFile -try: - from ctypes import windll - import shutil - - CopyFile = windll.kernel32.CopyFileA - SetFileTime = windll.kernel32.SetFileTime + CopyFile = windll.kernel32.CopyFileA + SetFileTime = windll.kernel32.SetFileTime - _shutil_copy = shutil.copy - _shutil_copy2 = shutil.copy2 + _shutil_copy = shutil.copy + _shutil_copy2 = shutil.copy2 - shutil.copy2 = CopyFile + shutil.copy2 = CopyFile - def win_api_copyfile(src,dst): - CopyFile(src,dst) - os.utime(dst) + def win_api_copyfile(src,dst): + CopyFile(src,dst) + os.utime(dst) - shutil.copy = win_api_copyfile + shutil.copy = win_api_copyfile -except AttributeError: - parallel_msg = \ - "Couldn't override shutil.copy or shutil.copy2 falling back to shutil defaults" + except AttributeError: + parallel_msg = \ + "Couldn't override shutil.copy or shutil.copy2 falling back to shutil defaults" -- cgit v0.12 From 46fd61694e79ec07c9317f62914bd90dbc7fe5c6 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 19 Mar 2017 13:04:32 -0700 Subject: py2/3 fix unnecessary binary reads. pep8 format the file while we're out at --- test/SWIG/SWIG.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/test/SWIG/SWIG.py b/test/SWIG/SWIG.py index 38bdc97..31bc7d7 100644 --- a/test/SWIG/SWIG.py +++ b/test/SWIG/SWIG.py @@ -30,14 +30,14 @@ Verify that the swig tool generates file names that we expect. import TestSCons -_exe = TestSCons._exe -_obj = TestSCons._obj +_exe = TestSCons._exe +_obj = TestSCons._obj test = TestSCons.TestSCons() python = test.where_is('python') if not python: - test,skip_test('Can not find installed "python", skipping test.\n') + test.skip_test('Can not find installed "python", skipping test.\n') test.write('myswig.py', r""" @@ -57,8 +57,8 @@ for opt, arg in opts: print("") print("Please see http://www.swig.org for reporting bugs and further information") sys.exit(0) -infile = open(args[0], 'rb') -outfile = open(out, 'wb') +infile = open(args[0], 'r') +outfile = open(out, 'w') for l in infile.readlines(): if l[:4] != 'swig': outfile.write(l) @@ -102,15 +102,16 @@ main(int argc, char *argv[]) { swig """) -test.run(arguments = '.', stderr = None, stdout = r'.*Using SWIG 0.1.2.*', match = TestSCons.match_re_dotall) +test.run(arguments='.', stderr=None, stdout=r'.*Using SWIG 0.1.2.*', + match=TestSCons.match_re_dotall) -test.run(program = test.workpath('test1' + _exe), stdout = "test1.i\n") +test.run(program=test.workpath('test1' + _exe), stdout="test1.i\n") test.must_exist(test.workpath('test1_wrap.c')) test.must_exist(test.workpath('test1_wrap' + _obj)) -test.must_match('test2_wrap.c', "test2.i\n") +test.must_match('test2_wrap.c', "test2.i\n", mode='r') -test.run(program = test.workpath('test3' + _exe), stdout = "test3.i\n") +test.run(program=test.workpath('test3' + _exe), stdout="test3.i\n") test.must_exist(test.workpath('test3_wrap.cc')) test.must_exist(test.workpath('test3_wrap' + _obj)) -- cgit v0.12 From 415927988528083c1c5e719996e4f58684dc1301 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 19 Mar 2017 13:05:26 -0700 Subject: py2/3 convert output from running swig to get version string to string. On py3 it was binary yielding all outputs of SWIGVERSION to be b'actual version' --- src/engine/SCons/Tool/swig.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/SCons/Tool/swig.py b/src/engine/SCons/Tool/swig.py index 9935de8..da4472f 100644 --- a/src/engine/SCons/Tool/swig.py +++ b/src/engine/SCons/Tool/swig.py @@ -142,8 +142,8 @@ def _get_swig_version(env, swig): if pipe.wait() != 0: return # MAYBE: out = SCons.Util.to_str (pipe.stdout.read()) - out = pipe.stdout.read() - match = re.search(b'SWIG Version\s+(\S+).*', out, re.MULTILINE) + out = SCons.Util.to_str(pipe.stdout.read()) + match = re.search('SWIG Version\s+(\S+).*', out, re.MULTILINE) if match: if verbose: print("Version is:%s"%match.group(1)) return match.group(1) -- cgit v0.12 From f520c8213cc50c6074dced70b7c061e6aabdd11f Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 19 Mar 2017 14:28:21 -0700 Subject: py2/3 fix wb/rb --- test/implicit/IMPLICIT_COMMAND_DEPENDENCIES.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/implicit/IMPLICIT_COMMAND_DEPENDENCIES.py b/test/implicit/IMPLICIT_COMMAND_DEPENDENCIES.py index bb3a5db..e2e4866 100644 --- a/test/implicit/IMPLICIT_COMMAND_DEPENDENCIES.py +++ b/test/implicit/IMPLICIT_COMMAND_DEPENDENCIES.py @@ -46,11 +46,11 @@ open(sys.argv[1], 'w').write('''\ #!/usr/bin/env %(python)s import os import sys -fp = open(sys.argv[1], 'wb') +fp = open(sys.argv[1], 'w') args = [os.path.split(sys.argv[0])[1]] + sys.argv[1:] fp.write(" ".join(args) + '\\\\n' + '%(extra)s') for infile in sys.argv[2:]: - fp.write(open(infile, 'rb').read()) + fp.write(open(infile, 'r').read()) fp.close() ''') os.chmod(sys.argv[1], 0o755) -- cgit v0.12 From 065e06645e101442a4b2b795b413d447190c6e9d Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 19 Mar 2017 14:48:25 -0700 Subject: py2/3 must_match mode=r --- test/gettext/POInit/UserExamples.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/test/gettext/POInit/UserExamples.py b/test/gettext/POInit/UserExamples.py index a498a53..a701851 100644 --- a/test/gettext/POInit/UserExamples.py +++ b/test/gettext/POInit/UserExamples.py @@ -79,8 +79,8 @@ test.write(['ex1', 'messages.pot'], pot_contents) test.run(arguments = 'po-create', chdir = 'ex1', stderr = None) test.must_exist( ['ex1', 'en.po'] ) test.must_exist( ['ex1', 'pl.po'] ) -test.must_contain( ['ex1', 'en.po'], "Hello from a.cpp") -test.must_contain( ['ex1', 'pl.po'], "Hello from a.cpp") +test.must_contain( ['ex1', 'en.po'], "Hello from a.cpp", mode='r') +test.must_contain( ['ex1', 'pl.po'], "Hello from a.cpp", mode='r') ############################################################################### @@ -102,8 +102,8 @@ test.write(['ex2', 'foo.pot'], pot_contents) test.run(arguments = 'po-create', chdir = 'ex2', stderr = None) test.must_exist( ['ex2', 'en.po'] ) test.must_exist( ['ex2', 'pl.po'] ) -test.must_contain( ['ex2', 'en.po'], "Hello from a.cpp" ) -test.must_contain( ['ex2', 'pl.po'], "Hello from a.cpp" ) +test.must_contain( ['ex2', 'en.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex2', 'pl.po'], "Hello from a.cpp", mode='r' ) ############################################################################### # POInit: Example 3 @@ -124,8 +124,8 @@ test.write(['ex3', 'foo.pot'], pot_contents) test.run(arguments = 'po-create', chdir = 'ex3', stderr = None) test.must_exist( ['ex3', 'en.po'] ) test.must_exist( ['ex3', 'pl.po'] ) -test.must_contain( ['ex3', 'en.po'], "Hello from a.cpp") -test.must_contain( ['ex3', 'pl.po'], "Hello from a.cpp") +test.must_contain( ['ex3', 'en.po'], "Hello from a.cpp", mode='r') +test.must_contain( ['ex3', 'pl.po'], "Hello from a.cpp", mode='r') ############################################################################### # POInit: Example 4 @@ -150,8 +150,8 @@ test.write(['ex4', 'messages.pot'], pot_contents) test.run(arguments = 'po-create', chdir = 'ex4', stderr = None) test.must_exist( ['ex4', 'en.po'] ) test.must_exist( ['ex4', 'pl.po'] ) -test.must_contain( ['ex4', 'en.po'], "Hello from a.cpp") -test.must_contain( ['ex4', 'pl.po'], "Hello from a.cpp") +test.must_contain( ['ex4', 'en.po'], "Hello from a.cpp", mode='r') +test.must_contain( ['ex4', 'pl.po'], "Hello from a.cpp", mode='r') ############################################################################### # POInit: Example 5 @@ -178,10 +178,10 @@ test.must_exist( ['ex5', 'en.po'] ) test.must_exist( ['ex5', 'pl.po'] ) test.must_exist( ['ex5', 'de.po'] ) test.must_exist( ['ex5', 'fr.po'] ) -test.must_contain( ['ex5', 'en.po'], "Hello from a.cpp") -test.must_contain( ['ex5', 'pl.po'], "Hello from a.cpp") -test.must_contain( ['ex5', 'de.po'], "Hello from a.cpp") -test.must_contain( ['ex5', 'fr.po'], "Hello from a.cpp") +test.must_contain( ['ex5', 'en.po'], "Hello from a.cpp", mode='r') +test.must_contain( ['ex5', 'pl.po'], "Hello from a.cpp", mode='r') +test.must_contain( ['ex5', 'de.po'], "Hello from a.cpp", mode='r') +test.must_contain( ['ex5', 'fr.po'], "Hello from a.cpp", mode='r') ############################################################################### # POInit: Example 6 @@ -208,8 +208,8 @@ test.write(['ex6', 'foo.pot'], pot_contents) test.run(arguments = 'po-create', chdir = 'ex6', stderr = None) test.must_exist( ['ex6', 'en.po'] ) test.must_exist( ['ex6', 'pl.po'] ) -test.must_contain( ['ex6', 'en.po'], "Hello from a.cpp") -test.must_contain( ['ex6', 'pl.po'], "Hello from a.cpp") +test.must_contain( ['ex6', 'en.po'], "Hello from a.cpp", mode='r') +test.must_contain( ['ex6', 'pl.po'], "Hello from a.cpp", mode='r') test.pass_test() -- cgit v0.12 From d48e8589a5f3c896622368024082322b00adbb45 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 19 Mar 2017 14:50:39 -0700 Subject: typo fix --- test/gettext/POTUpdate/UserExamples.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/gettext/POTUpdate/UserExamples.py b/test/gettext/POTUpdate/UserExamples.py index 3c1f298..6269081 100644 --- a/test/gettext/POTUpdate/UserExamples.py +++ b/test/gettext/POTUpdate/UserExamples.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +2#!/usr/bin/env python # # __COPYRIGHT__ # @@ -25,7 +25,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ -End-to-end tests for POTUpdate. Assure, taht the examples from user's +End-to-end tests for POTUpdate. Assure, that the examples from user's documentation all work. """ -- cgit v0.12 From 786d07b7b643cf110f256d5de3afa450c0d175d4 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 19 Mar 2017 14:51:58 -0700 Subject: py2/3 rb/wb fix --- test/explain/basic.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/explain/basic.py b/test/explain/basic.py index 7079e44..fb331fe 100644 --- a/test/explain/basic.py +++ b/test/explain/basic.py @@ -62,7 +62,7 @@ def process(outfp, infp): if line[:8] == 'include ': file = line[8:-1] try: - fp = open(file, 'rb') + fp = open(file, 'r') except IOError: import os print("os.getcwd() =", os.getcwd()) @@ -71,10 +71,10 @@ def process(outfp, infp): else: outfp.write(line) -outfp = open(sys.argv[1], 'wb') +outfp = open(sys.argv[1], 'w') for f in sys.argv[2:]: if f != '-': - process(outfp, open(f, 'rb')) + process(outfp, open(f, 'r')) sys.exit(0) """) -- cgit v0.12 From 81ced582305f177bb43f9f9474100cb0688d51ca Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 19 Mar 2017 14:53:28 -0700 Subject: py2/3 fix. Add b to w open. Needed because we're dumping node.get_contents(), which is always bytes --- test/explain/alias-order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/explain/alias-order.py b/test/explain/alias-order.py index 3eed275..611c512 100644 --- a/test/explain/alias-order.py +++ b/test/explain/alias-order.py @@ -41,7 +41,7 @@ test.write(['src', 'SConstruct'],""" env = Environment() def action( source, target, env ): - f = open( str(target[0]), 'w' ) + f = open( str(target[0]), 'wb' ) f.write( source[0].get_contents()) f.close() -- cgit v0.12 From b2d2d74745f53efc06310369787c311a7a5ffe3a Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 19 Mar 2017 15:02:22 -0700 Subject: add pycharms dir to hgignore --- .hgignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgignore b/.hgignore index 15c093f..2323687 100644 --- a/.hgignore +++ b/.hgignore @@ -1,5 +1,6 @@ build bootstrap +.idea syntax:glob *.py[co] -- cgit v0.12 From 47b6a4d1c7da1e93bbfc7ec283746c72ff3d920e Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 19 Mar 2017 16:19:49 -0700 Subject: py2/3 switch from using starts with to a slice of the contents. With py3 contents is a byte array, not a string and so lacks the startswith method --- src/engine/SCons/Node/FS.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index c3841eb..7172c50 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -2672,11 +2672,11 @@ class File(Base): # them, but has a 'utf-8-sig' which does; 'utf-16' seems to # strip them; etc.) Just sidestep all the complication by # explicitly stripping the BOM before we decode(). - if contents.startswith(codecs.BOM_UTF8): + if contents[:len(codecs.BOM_UTF8)] == codecs.BOM_UTF8: return contents[len(codecs.BOM_UTF8):].decode('utf-8') - if contents.startswith(codecs.BOM_UTF16_LE): + if contents[:len(codecs.BOM_UTF16_LE)] == codecs.BOM_UTF16_LE: return contents[len(codecs.BOM_UTF16_LE):].decode('utf-16-le') - if contents.startswith(codecs.BOM_UTF16_BE): + if contents[:len(codecs.BOM_UTF16_BE)] == codecs.BOM_UTF16_BE: return contents[len(codecs.BOM_UTF16_BE):].decode('utf-16-be') try: return contents.decode() -- cgit v0.12 From aa0997f21bfe2d338601fe14108fb24b3655b9b1 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 19 Mar 2017 16:34:29 -0700 Subject: change test to use get_text_contents py2/3 --- test/VariantDir/VariantDir.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/VariantDir/VariantDir.py b/test/VariantDir/VariantDir.py index 1b620bb..d212b0d 100644 --- a/test/VariantDir/VariantDir.py +++ b/test/VariantDir/VariantDir.py @@ -379,7 +379,7 @@ import sys headers = ['existing.h', 'non_existing.h'] for header in headers: h = File( header ) - contents = h.get_contents() + contents = h.get_text_contents() sys.stderr.write( '%s:%s\\n' % (header, contents)) """) -- cgit v0.12 From 42bbf67f813abf2af05eb9b25c3de7e1ba64fe9c Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 19 Mar 2017 16:35:28 -0700 Subject: py2/3 get_text_contents() may be working when contents is a string (Value node), in which case the final except should handle AttributeError as decode is not a method on strings in py3 --- src/engine/SCons/Node/FS.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 7172c50..f455edb 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -2680,7 +2680,7 @@ class File(Base): return contents[len(codecs.BOM_UTF16_BE):].decode('utf-16-be') try: return contents.decode() - except UnicodeDecodeError: + except (UnicodeDecodeError, AttributeError) as e: return contents -- cgit v0.12 From 2b7f8ac804ff9063e5ba0bc18228a3f280c37255 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 19 Mar 2017 16:39:45 -0700 Subject: py2/3 remove rb from tex processing. --- src/engine/SCons/Tool/tex.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/engine/SCons/Tool/tex.py b/src/engine/SCons/Tool/tex.py index 85bd41f..8e09d56 100644 --- a/src/engine/SCons/Tool/tex.py +++ b/src/engine/SCons/Tool/tex.py @@ -297,7 +297,7 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None logfilename = targetbase + '.log' logContent = '' if os.path.isfile(logfilename): - logContent = open(logfilename, "rb").read() + logContent = open(logfilename, "r").read() # Read the fls file to find all .aux files @@ -305,7 +305,7 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None flsContent = '' auxfiles = [] if os.path.isfile(flsfilename): - flsContent = open(flsfilename, "rb").read() + flsContent = open(flsfilename, "r").read() auxfiles = openout_aux_re.findall(flsContent) # remove duplicates dups = {} @@ -315,7 +315,7 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None bcffiles = [] if os.path.isfile(flsfilename): - flsContent = open(flsfilename, "rb").read() + flsContent = open(flsfilename, "r").read() bcffiles = openout_bcf_re.findall(flsContent) # remove duplicates dups = {} @@ -338,7 +338,7 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None already_bibtexed.append(auxfilename) target_aux = os.path.join(targetdir, auxfilename) if os.path.isfile(target_aux): - content = open(target_aux, "rb").read() + content = open(target_aux, "r").read() if content.find("bibdata") != -1: if Verbose: print("Need to run bibtex on ",auxfilename) @@ -361,7 +361,7 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None already_bibtexed.append(bcffilename) target_bcf = os.path.join(targetdir, bcffilename) if os.path.isfile(target_bcf): - content = open(target_bcf, "rb").read() + content = open(target_bcf, "r").read() if content.find("bibdata") != -1: if Verbose: print("Need to run biber on ",bcffilename) @@ -813,7 +813,7 @@ def tex_emitter_core(target, source, env, graphics_extensions): # read fls file to get all other files that latex creates and will read on the next pass # remove files from list that we explicitly dealt with above if os.path.isfile(flsfilename): - content = open(flsfilename, "rb").read() + content = open(flsfilename, "r").read() out_files = openout_re.findall(content) myfiles = [auxfilename, logfilename, flsfilename, targetbase+'.dvi',targetbase+'.pdf'] for filename in out_files[:]: -- cgit v0.12 From 2ef8bb1c87905a5ce0c685d99a00a6741350f1fe Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 19 Mar 2017 16:48:24 -0700 Subject: py2/3 fix rb/wb also replace convoluted test logic with correct test methods to check for file exist/not exist --- test/TEX/PDFTEXFLAGS.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/TEX/PDFTEXFLAGS.py b/test/TEX/PDFTEXFLAGS.py index 06dc780..97b352e 100644 --- a/test/TEX/PDFTEXFLAGS.py +++ b/test/TEX/PDFTEXFLAGS.py @@ -43,8 +43,8 @@ opt_string = '' for opt, arg in cmd_opts: opt_string = opt_string + ' ' + opt base_name = os.path.splitext(args[0])[0] -infile = open(args[0], 'rb') -out_file = open(base_name+'.pdf', 'wb') +infile = open(args[0], 'r') +out_file = open(base_name+'.pdf', 'w') out_file.write(opt_string + "\n") for l in infile.readlines(): if l[0] != '\\': @@ -96,15 +96,15 @@ This is the %s TeX file. test.run(arguments = 'foo.pdf', stderr = None) - test.fail_test(os.path.exists(test.workpath('wrapper.out'))) + test.must_not_exist(test.workpath('wrapper.out')) - test.fail_test(not os.path.exists(test.workpath('foo.pdf'))) + test.must_exist(test.workpath('foo.pdf')) test.run(arguments = 'bar.pdf', stderr = None) - test.fail_test(not os.path.exists(test.workpath('wrapper.out'))) + test.must_exist(test.workpath('wrapper.out')) - test.fail_test(not os.path.exists(test.workpath('bar.pdf'))) + test.must_exist(test.workpath('bar.pdf')) test.pass_test() -- cgit v0.12 From 1e6772f1cdcd97e51b59f7d7702dd7476e28c3d9 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 19 Mar 2017 17:12:04 -0700 Subject: py2/3 fix wb/rb --- test/TEX/LATEX.py | 8 ++++---- test/TEX/PDFLATEXFLAGS.py | 6 +++--- test/TEX/TEX.py | 8 ++++---- test/TEX/TEXFLAGS.py | 6 +++--- test/TEX/multi-run.py | 8 ++++---- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/test/TEX/LATEX.py b/test/TEX/LATEX.py index c6f58e6..362bb62 100644 --- a/test/TEX/LATEX.py +++ b/test/TEX/LATEX.py @@ -44,10 +44,10 @@ import os import getopt cmd_opts, arg = getopt.getopt(sys.argv[1:], 'i:r:', []) base_name = os.path.splitext(arg[0])[0] -infile = open(arg[0], 'rb') -dvi_file = open(base_name+'.dvi', 'wb') -aux_file = open(base_name+'.aux', 'wb') -log_file = open(base_name+'.log', 'wb') +infile = open(arg[0], 'r') +dvi_file = open(base_name+'.dvi', 'w') +aux_file = open(base_name+'.aux', 'w') +log_file = open(base_name+'.log', 'w') for l in infile.readlines(): if l[0] != '\\': dvi_file.write(l) diff --git a/test/TEX/PDFLATEXFLAGS.py b/test/TEX/PDFLATEXFLAGS.py index ffed20b..47643e4 100644 --- a/test/TEX/PDFLATEXFLAGS.py +++ b/test/TEX/PDFLATEXFLAGS.py @@ -43,8 +43,8 @@ opt_string = '' for opt, arg in cmd_opts: opt_string = opt_string + ' ' + opt base_name = os.path.splitext(args[0])[0] -infile = open(args[0], 'rb') -out_file = open(base_name+'.pdf', 'wb') +infile = open(args[0], 'r') +out_file = open(base_name+'.pdf', 'w') out_file.write(opt_string + "\n") for l in infile.readlines(): if l[0] != '\\': @@ -111,7 +111,7 @@ This is the %s LaTeX file. test.run(arguments = 'bar.pdf', stderr = None) - test.fail_test(test.read('wrapper.out') != "wrapper.py\n") + test.must_match('wrapper.out',"wrapper.py\n", mode='r') test.fail_test(not os.path.exists(test.workpath('bar.pdf'))) diff --git a/test/TEX/TEX.py b/test/TEX/TEX.py index 3e48419..7b20106 100644 --- a/test/TEX/TEX.py +++ b/test/TEX/TEX.py @@ -47,10 +47,10 @@ import os import getopt cmd_opts, arg = getopt.getopt(sys.argv[1:], 'i:r:', []) base_name = os.path.splitext(arg[0])[0] -infile = open(arg[0], 'rb') -dvi_file = open(base_name+'.dvi', 'wb') -aux_file = open(base_name+'.aux', 'wb') -log_file = open(base_name+'.log', 'wb') +infile = open(arg[0], 'r') +dvi_file = open(base_name+'.dvi', 'w') +aux_file = open(base_name+'.aux', 'w') +log_file = open(base_name+'.log', 'w') for l in infile.readlines(): if l[0] != '\\': dvi_file.write(l) diff --git a/test/TEX/TEXFLAGS.py b/test/TEX/TEXFLAGS.py index e21aaa9..4b632f7 100644 --- a/test/TEX/TEXFLAGS.py +++ b/test/TEX/TEXFLAGS.py @@ -43,8 +43,8 @@ opt_string = '' for opt, arg in cmd_opts: opt_string = opt_string + ' ' + opt base_name = os.path.splitext(args[0])[0] -infile = open(args[0], 'rb') -out_file = open(base_name+'.dvi', 'wb') +infile = open(args[0], 'r') +out_file = open(base_name+'.dvi', 'w') out_file.write(opt_string + "\n") for l in infile.readlines(): if l[0] != '\\': @@ -65,7 +65,7 @@ test.write('test.tex', r"""This is a test. test.run(arguments = 'test.dvi', stderr = None) -test.fail_test(test.read('test.dvi') != " -x\nThis is a test.\n") +test.must_match('test.dvi'," -x\nThis is a test.\n") diff --git a/test/TEX/multi-run.py b/test/TEX/multi-run.py index 37a839b..ff4e82a 100644 --- a/test/TEX/multi-run.py +++ b/test/TEX/multi-run.py @@ -149,7 +149,7 @@ env.PDF( "foo.tex" ) test.must_exist(['work1', 'foo.bbl']) - foo_log = test.read(['work1', 'foo.log']) + foo_log = test.read(['work1', 'foo.log'], mode='r') test.must_not_contain_any_line(foo_log, ['undefined references'], 'foo.log') test.write(['work3', 'SConstruct'], """\ @@ -163,7 +163,7 @@ env.DVI( "foo3.tex" ) test.run(chdir = 'work3', arguments = '.') - foo_log = test.read(['work3', 'foo3.log']) + foo_log = test.read(['work3', 'foo3.log'], mode='r') test.must_not_contain_any_line(foo_log, ['Rerun LaTeX'], 'foo3.log') @@ -185,7 +185,7 @@ env.PDF( "foo.ltx" ) test.must_exist(['work2', 'foo.bbl']) - foo_log = test.read(['work2', 'foo.log']) + foo_log = test.read(['work2', 'foo.log'], mode='r') test.must_not_contain_any_line(foo_log, ['undefined references'], 'foo.log') test.write(['work3', 'SConstruct'], """\ @@ -200,7 +200,7 @@ env.PDF( "foo3.tex" ) test.run(chdir = 'work3', arguments = '.') - foo_log = test.read(['work3', 'foo3.log']) + foo_log = test.read(['work3', 'foo3.log'], mode='r') test.must_not_contain_any_line(foo_log, ['Rerun LaTeX'], 'foo3.log') -- cgit v0.12 From b0dbfb811f1408909d7587ae033139791e7509ca Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 19 Mar 2017 17:20:36 -0700 Subject: check for correct gdbm module to decide to skip or not py2/3 --- test/SConsignFile/use-gdbm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/SConsignFile/use-gdbm.py b/test/SConsignFile/use-gdbm.py index a7e4f59..1eb3645 100644 --- a/test/SConsignFile/use-gdbm.py +++ b/test/SConsignFile/use-gdbm.py @@ -35,7 +35,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() try: - import dbm.gnu + import gdbm except ImportError: test.skip_test('No gdbm in this version of Python; skipping test.\n') -- cgit v0.12 From 2c312564762cc54a119b74437566dc4aef4f7ca4 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 19 Mar 2017 17:26:53 -0700 Subject: py2/3 fix rb/wb --- test/Scanner/dictionary.py | 6 +++--- test/Scanner/multi-env.py | 6 +++--- test/Scanner/source_scanner-dict.py | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/test/Scanner/dictionary.py b/test/Scanner/dictionary.py index a65e777..f6f121e 100644 --- a/test/Scanner/dictionary.py +++ b/test/Scanner/dictionary.py @@ -36,8 +36,8 @@ test = TestSCons.TestSCons() test.write('build.py', r""" import sys -input = open(sys.argv[1], 'rb') -output = open(sys.argv[2], 'wb') +input = open(sys.argv[1], 'r') +output = open(sys.argv[2], 'w') include_prefix = 'include%s ' % sys.argv[1][-1] @@ -45,7 +45,7 @@ def process(infp, outfp): for line in infp.readlines(): if line[:len(include_prefix)] == include_prefix: file = line[len(include_prefix):-1] - process(open(file, 'rb'), outfp) + process(open(file, 'r'), outfp) else: outfp.write(line) diff --git a/test/Scanner/multi-env.py b/test/Scanner/multi-env.py index 3d9a62a..7cb052a 100644 --- a/test/Scanner/multi-env.py +++ b/test/Scanner/multi-env.py @@ -72,12 +72,12 @@ def process(infp, outfp): l = len(prefix) for line in infp.readlines(): if line[:l] == prefix: - process(open(line[l:-1], 'rb'), outfp) + process(open(line[l:-1], 'r'), outfp) else: outfp.write(line) -process(open(sys.argv[2], 'rb'), - open(sys.argv[1], 'wb')) +process(open(sys.argv[2], 'r'), + open(sys.argv[1], 'w')) sys.exit(0) """ diff --git a/test/Scanner/source_scanner-dict.py b/test/Scanner/source_scanner-dict.py index f796368..bb12364 100644 --- a/test/Scanner/source_scanner-dict.py +++ b/test/Scanner/source_scanner-dict.py @@ -39,9 +39,9 @@ test = TestSCons.TestSCons() test.write('build.py', r""" import sys -output = open(sys.argv[1], 'wb') +output = open(sys.argv[1], 'w') for infile in sys.argv[2:]: - input = open(infile, 'rb') + input = open(infile, 'r') include_prefix = 'include%s ' % infile[-1] @@ -49,7 +49,7 @@ for infile in sys.argv[2:]: for line in infp.readlines(): if line[:len(include_prefix)] == include_prefix: file = line[len(include_prefix):-1] - process(open(file, 'rb'), outfp) + process(open(file, 'r'), outfp) else: outfp.write(line) -- cgit v0.12 From 00d3efd103ce9bc00865517dac9b17275b3b8ab2 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 19 Mar 2017 18:15:23 -0700 Subject: py2/3 ab fix. Plus switch to must_match --- test/SConscript/SConscriptChdir.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/SConscript/SConscriptChdir.py b/test/SConscript/SConscriptChdir.py index 211d55b..2e25acf 100644 --- a/test/SConscript/SConscriptChdir.py +++ b/test/SConscript/SConscriptChdir.py @@ -69,17 +69,17 @@ exec(open(name, 'r').read()) for dir in ['dir1', 'dir2', 'dir3','dir4', 'dir5']: test.write([dir, 'create_test.py'], r""" -f = open("test.txt", "ab") +f = open("test.txt", "a") f.write("This is the %s test.\n") f.close() """ % dir) test.run(arguments=".", stderr=None) -test.fail_test(test.read(['dir1', 'test.txt']) != "This is the dir1 test.\n") -test.fail_test(test.read(['dir2', 'test.txt']) != "This is the dir2 test.\n") -test.fail_test(test.read('test.txt') != "This is the dir3 test.\nThis is the dir5 test.\n") -test.fail_test(test.read(['dir4', 'test.txt']) != "This is the dir4 test.\n") +test.must_match(['dir1', 'test.txt'],"This is the dir1 test.\n") +test.must_match(['dir2', 'test.txt'], "This is the dir2 test.\n") +test.must_match('test.txt',"This is the dir3 test.\nThis is the dir5 test.\n") +test.must_match(['dir4', 'test.txt'],"This is the dir4 test.\n") test.pass_test() -- cgit v0.12 From d9eacbb046154a04c1a32372d18b6d0614f2c7fe Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 19 Mar 2017 18:37:41 -0700 Subject: Fix pickled/base64 string to be string instead of bytecode before writing to file py2/3 --- src/engine/SCons/Tool/msvs.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py index 67f9ada..e1175e0 100644 --- a/src/engine/SCons/Tool/msvs.py +++ b/src/engine/SCons/Tool/msvs.py @@ -87,7 +87,7 @@ def _generateGUID(slnfile, name): # Normalize the slnfile path to a Windows path (\ separators) so # the generated file has a consistent GUID even if we generate # it on a non-Windows platform. - m.update(ntpath.normpath(str(slnfile)) + str(name)) + m.update(bytearray(ntpath.normpath(str(slnfile)) + str(name),'utf-8')) solution = m.hexdigest().upper() # convert most of the signature to GUID form (discard the rest) solution = "{" + solution[:8] + "-" + solution[8:12] + "-" + solution[12:16] + "-" + solution[16:20] + "-" + solution[20:32] + "}" @@ -645,10 +645,10 @@ class _GenerateV6DSP(_DSPGenerator): if self.nokeep == 0: # now we pickle some data and add it to the file -- MSDEV will ignore it. pdata = pickle.dumps(self.configs,PICKLE_PROTOCOL) - pdata = base64.encodestring(pdata) + pdata = base64.encodestring(pdata).decode() self.file.write(pdata + '\n') pdata = pickle.dumps(self.sources,PICKLE_PROTOCOL) - pdata = base64.encodestring(pdata) + pdata = base64.encodestring(pdata).decode() self.file.write(pdata + '\n') def PrintSourceFiles(self): @@ -917,10 +917,10 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User): if self.nokeep == 0: # now we pickle some data and add it to the file -- MSDEV will ignore it. pdata = pickle.dumps(self.configs,PICKLE_PROTOCOL) - pdata = base64.encodestring(pdata) + pdata = base64.encodestring(pdata).decode() self.file.write('\n') def printSources(self, hierarchy, commonprefix): @@ -1236,10 +1236,10 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): if self.nokeep == 0: # now we pickle some data and add it to the file -- MSDEV will ignore it. pdata = pickle.dumps(self.configs,PICKLE_PROTOCOL) - pdata = base64.encodestring(pdata) + pdata = base64.encodestring(pdata).decode() self.file.write('\n') def printFilters(self, hierarchy, name): @@ -1610,8 +1610,9 @@ class _GenerateV7DSW(_DSWGenerator): self.file.write('EndGlobal\n') if self.nokeep == 0: pdata = pickle.dumps(self.configs,PICKLE_PROTOCOL) - pdata = base64.encodestring(pdata) - self.file.write(pdata + '\n') + pdata = base64.encodestring(pdata).decode() + self.file.write(pdata) + self.file.write('\n') def Build(self): try: -- cgit v0.12 From a62a149a4a5745974217eb1c6859116898057cac Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 19 Mar 2017 20:31:09 -0700 Subject: fix ab flag py2/3 --- test/DVIPS/DVIPSFLAGS.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/DVIPS/DVIPSFLAGS.py b/test/DVIPS/DVIPSFLAGS.py index 814c8aa..b6625d7 100644 --- a/test/DVIPS/DVIPSFLAGS.py +++ b/test/DVIPS/DVIPSFLAGS.py @@ -125,10 +125,11 @@ dvips = test.where_is('dvips') if dvips: - test.write("wrapper.py", """import os + test.write("wrapper.py", """ +import os import sys cmd = " ".join(sys.argv[1:]) -open('%s', 'ab').write("%%s\\n" %% cmd) +open('%s', 'a').write("%%s\\n" %% cmd) os.system(cmd) """ % test.workpath('wrapper.out').replace('\\', '\\\\')) -- cgit v0.12 From 997414f66dc5fb741246a84f30eb7428374eee1e Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 19 Mar 2017 20:31:55 -0700 Subject: fix ab flag py2/3 --- test/DVIPS/DVIPS.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/DVIPS/DVIPS.py b/test/DVIPS/DVIPS.py index 256258f..1774695 100644 --- a/test/DVIPS/DVIPS.py +++ b/test/DVIPS/DVIPS.py @@ -38,10 +38,10 @@ import sys import getopt cmd_opts, arg = getopt.getopt(sys.argv[1:], 'i:r:', []) base_name = os.path.splitext(arg[0])[0] -infile = open(arg[0], 'rb') -out_file = open(base_name+'.dvi', 'wb') +infile = open(arg[0], 'r') +out_file = open(base_name+'.dvi', 'w') for l in infile.readlines(): - if l[:4] != b'#tex': + if l[:4] != '#tex': out_file.write(l) sys.exit(0) """) @@ -52,8 +52,8 @@ import sys import getopt cmd_opts, arg = getopt.getopt(sys.argv[1:], 'i:r:', []) base_name = os.path.splitext(arg[0])[0] -infile = open(arg[0], 'rb') -out_file = open(base_name+'.dvi', 'wb') +infile = open(arg[0], 'r') +out_file = open(base_name+'.dvi', 'w') for l in infile.readlines(): if l[:6] != b'#latex': out_file.write(l) @@ -63,10 +63,10 @@ sys.exit(0) test.write('mydvips.py', r""" import os import sys -infile = open(sys.argv[3], 'rb') -out_file = open(sys.argv[2], 'wb') +infile = open(sys.argv[3], 'r') +out_file = open(sys.argv[2], 'w') for l in infile.readlines(): - if l[:6] != b'#dvips': + if l[:6] != '#dvips': out_file.write(l) sys.exit(0) """) -- cgit v0.12 From ca08db4867f6437e783b1c9f5734065124a451b0 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 19 Mar 2017 20:34:46 -0700 Subject: fix ab flag py2/3 --- test/DVIPS/DVIPS.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/DVIPS/DVIPS.py b/test/DVIPS/DVIPS.py index 1774695..01f0078 100644 --- a/test/DVIPS/DVIPS.py +++ b/test/DVIPS/DVIPS.py @@ -55,7 +55,7 @@ base_name = os.path.splitext(arg[0])[0] infile = open(arg[0], 'r') out_file = open(base_name+'.dvi', 'w') for l in infile.readlines(): - if l[:6] != b'#latex': + if l[:6] != '#latex': out_file.write(l) sys.exit(0) """) @@ -122,10 +122,11 @@ dvips = test.where_is('dvips') if dvips: - test.write("wrapper.py", """import os + test.write("wrapper.py", """ +import os import sys cmd = " ".join(sys.argv[1:]) -open('%s', 'ab').write("%%s\\n" %% cmd) +open('%s', 'a').write("%%s\\n" %% cmd) os.system(cmd) """ % test.workpath('wrapper.out').replace('\\', '\\\\')) -- cgit v0.12 From 2ce34914cff387ad0db3e8d3dd4347a79a058640 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 19 Mar 2017 20:36:25 -0700 Subject: py2/3 rb/ab/wb fixes --- test/DVIPDF/DVIPDF.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/DVIPDF/DVIPDF.py b/test/DVIPDF/DVIPDF.py index 5c72231..b60107d 100644 --- a/test/DVIPDF/DVIPDF.py +++ b/test/DVIPDF/DVIPDF.py @@ -38,10 +38,10 @@ import sys import getopt cmd_opts, arg = getopt.getopt(sys.argv[1:], 'i:r:', []) base_name = os.path.splitext(arg[0])[0] -infile = open(arg[0], 'rb') -out_file = open(base_name+'.dvi', 'wb') +infile = open(arg[0], 'r') +out_file = open(base_name+'.dvi', 'w') for l in infile.readlines(): - if l[:4] != b'#tex': + if l[:4] != '#tex': out_file.write(l) sys.exit(0) """) @@ -52,10 +52,10 @@ import sys import getopt cmd_opts, arg = getopt.getopt(sys.argv[1:], 'i:r:', []) base_name = os.path.splitext(arg[0])[0] -infile = open(arg[0], 'rb') -out_file = open(base_name+'.dvi', 'wb') +infile = open(arg[0], 'r') +out_file = open(base_name+'.dvi', 'w') for l in infile.readlines(): - if l[:6] != b'#latex': + if l[:6] != '#latex': out_file.write(l) sys.exit(0) """) @@ -65,10 +65,10 @@ import os import sys import getopt cmd_opts, arg = getopt.getopt(sys.argv[1:], 'i:r:', []) -infile = open(arg[0], 'rb') -out_file = open(arg[1], 'wb') +infile = open(arg[0], 'r') +out_file = open(arg[1], 'w') for l in infile.readlines(): - if l[:7] != b'#dvipdf': + if l[:7] != '#dvipdf': out_file.write(l) sys.exit(0) """) @@ -110,7 +110,7 @@ if dvipdf and tex: test.write("wrapper.py", """import os import sys cmd = " ".join(sys.argv[1:]) -open('%s', 'ab').write("%%s\\n" %% cmd) +open('%s', 'a').write("%%s\\n" %% cmd) os.system(cmd) """ % test.workpath('wrapper.out').replace('\\', '\\\\')) -- cgit v0.12 From 18e4b000061b0cc22d5fbb44df4e68e740d7afb8 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 20 Mar 2017 09:50:54 -0700 Subject: py2/3 fix win32 py27 failures. Also resolve some py3 failures --- test/DVIPDF/DVIPDF.py | 4 +- test/DVIPS/DVIPS.py | 10 +- test/Repository/variants.py | 134 +++++++++++++++---------- test/SConscript/SConscriptChdir.py | 8 +- test/Scanner/dictionary.py | 12 +-- test/Scanner/multi-env.py | 8 +- test/Scanner/source_scanner-dict.py | 20 ++-- test/Scanner/unicode.py | 21 ++-- test/TEX/LATEX.py | 16 +-- test/TEX/TEXFLAGS.py | 2 +- test/explain/basic.py | 40 ++++---- test/explain/save-info.py | 18 ++-- test/implicit/IMPLICIT_COMMAND_DEPENDENCIES.py | 33 +++--- 13 files changed, 180 insertions(+), 146 deletions(-) diff --git a/test/DVIPDF/DVIPDF.py b/test/DVIPDF/DVIPDF.py index b60107d..87f4012 100644 --- a/test/DVIPDF/DVIPDF.py +++ b/test/DVIPDF/DVIPDF.py @@ -96,9 +96,9 @@ test.write('test2.tex', r"""This is a .tex test. test.run(arguments = '.', stderr = None) -test.must_match('test1.pdf', "This is a .dvi test.\n") +test.must_match('test1.pdf', "This is a .dvi test.\n", mode='r') -test.must_match('test2.pdf', "This is a .tex test.\n") +test.must_match('test2.pdf', "This is a .tex test.\n", mode='r') diff --git a/test/DVIPS/DVIPS.py b/test/DVIPS/DVIPS.py index 01f0078..27e89ba 100644 --- a/test/DVIPS/DVIPS.py +++ b/test/DVIPS/DVIPS.py @@ -105,13 +105,13 @@ test.write('test4.latex', r"""This is a .latex test. test.run(arguments = '.', stderr = None) -test.must_match('test1.ps', "This is a .dvi test.\n") +test.must_match('test1.ps', "This is a .dvi test.\n", mode='r') -test.must_match('test2.ps', "This is a .tex test.\n") +test.must_match('test2.ps', "This is a .tex test.\n", mode='r') -test.must_match('test3.ps', "This is a .ltx test.\n") +test.must_match('test3.ps', "This is a .ltx test.\n", mode='r') -test.must_match('test4.ps', "This is a .latex test.\n") +test.must_match('test4.ps', "This is a .latex test.\n", mode='r') have_latex = test.where_is('latex') @@ -172,7 +172,7 @@ dvips -o bar2.ps bar2.dvi dvips -o bar3.ps bar3.dvi """ - test.must_match('wrapper.out', expect) + test.must_match('wrapper.out', expect, mode='r') test.must_exist(test.workpath('bar1.ps')) test.must_exist(test.workpath('bar2.ps')) diff --git a/test/Repository/variants.py b/test/Repository/variants.py index e8c07a7..f6b53eb 100644 --- a/test/Repository/variants.py +++ b/test/Repository/variants.py @@ -215,33 +215,37 @@ main(int argc, char *argv[]) """) # -test.run(chdir = 'repository', options = opts + " OS=foo", arguments = '.') +test.run(chdir='repository', options=opts + " OS=foo", arguments='.') -test.run(program = repository_build1_foo_xxx, stdout = """\ +test.run(program=repository_build1_foo_xxx, stdout="""\ repository/src1/aaa.c: REPOSITORY_FOO repository/src1/bbb.c: REPOSITORY_FOO repository/src1/main.c: REPOSITORY_FOO """) -test.fail_test(os.path.exists(test.workpath('repository', 'src1', '.sconsign'))) -test.fail_test(os.path.exists(test.workpath('repository', 'src2', '.sconsign'))) +test.fail_test(os.path.exists( + test.workpath('repository', 'src1', '.sconsign'))) +test.fail_test(os.path.exists( + test.workpath('repository', 'src2', '.sconsign'))) test.fail_test(os.path.exists(test.workpath('work1', 'src1', '.sconsign'))) test.fail_test(os.path.exists(test.workpath('work2', 'src2', '.sconsign'))) -test.run(program = repository_build2_foo_src2_xxx_xxx, stdout = """\ +test.run(program=repository_build2_foo_src2_xxx_xxx, stdout="""\ repository/src2/include/my_string.h: FOO repository/src2/xxx/include.h: FOO repository/src2/xxx/main.c: FOO """) -test.run(program = repository_build2_bar_src2_xxx_xxx, stdout = """\ +test.run(program=repository_build2_bar_src2_xxx_xxx, stdout="""\ repository/src2/include/my_string.h: BAR repository/src2/xxx/include.h: BAR repository/src2/xxx/main.c: BAR """) -test.fail_test(os.path.exists(test.workpath('repository', 'src1', '.sconsign'))) -test.fail_test(os.path.exists(test.workpath('repository', 'src2', '.sconsign'))) +test.fail_test(os.path.exists( + test.workpath('repository', 'src1', '.sconsign'))) +test.fail_test(os.path.exists( + test.workpath('repository', 'src2', '.sconsign'))) test.fail_test(os.path.exists(test.workpath('work1', 'src1', '.sconsign'))) test.fail_test(os.path.exists(test.workpath('work2', 'src2', '.sconsign'))) @@ -250,30 +254,36 @@ test.fail_test(os.path.exists(test.workpath('work2', 'src2', '.sconsign'))) test.writable('repository', 0) # -test.up_to_date(chdir = 'work1', options = opts + " OS=foo", arguments = 'build1') +test.up_to_date(chdir='work1', options=opts + " OS=foo", arguments='build1') -test.fail_test(os.path.exists(test.workpath('work1', 'build1', 'foo', aaa_obj))) -test.fail_test(os.path.exists(test.workpath('work1', 'build1', 'foo', bbb_obj))) -test.fail_test(os.path.exists(test.workpath('work1', 'build1', 'foo', main_obj))) +test.fail_test(os.path.exists( + test.workpath('work1', 'build1', 'foo', aaa_obj))) +test.fail_test(os.path.exists( + test.workpath('work1', 'build1', 'foo', bbb_obj))) +test.fail_test(os.path.exists(test.workpath( + 'work1', 'build1', 'foo', main_obj))) -test.fail_test(os.path.exists(test.workpath('work1', 'build1', 'foo', xxx_exe))) +test.fail_test(os.path.exists( + test.workpath('work1', 'build1', 'foo', xxx_exe))) # -test.run(chdir = 'work1', options = opts, arguments = 'OS=bar .') +test.run(chdir='work1', options=opts, arguments='OS=bar .') -test.run(program = work1_build1_bar_xxx, stdout = """\ +test.run(program=work1_build1_bar_xxx, stdout="""\ Only when -DBAR. repository/src1/aaa.c: REPOSITORY_BAR repository/src1/bbb.c: REPOSITORY_BAR repository/src1/main.c: REPOSITORY_BAR """) -test.fail_test(os.path.exists(test.workpath('repository', 'src1', '.sconsign'))) -test.fail_test(os.path.exists(test.workpath('repository', 'src2', '.sconsign'))) +test.fail_test(os.path.exists( + test.workpath('repository', 'src1', '.sconsign'))) +test.fail_test(os.path.exists( + test.workpath('repository', 'src2', '.sconsign'))) test.fail_test(os.path.exists(test.workpath('work1', 'src1', '.sconsign'))) test.fail_test(os.path.exists(test.workpath('work2', 'src2', '.sconsign'))) -test.up_to_date(chdir = 'work1', options = opts + " OS=bar", arguments = 'build1') +test.up_to_date(chdir='work1', options=opts + " OS=bar", arguments='build1') # Ensure file time stamps will be newer. time.sleep(2) @@ -288,49 +298,61 @@ test.write(['work1', 'src1', 'iii.h'], r""" """) # -test.run(chdir = 'work1', options = opts + " OS=bar", arguments = 'build1') +test.run(chdir='work1', options=opts + " OS=bar", arguments='build1') -test.run(program = work1_build1_bar_xxx, stdout = """\ +test.run(program=work1_build1_bar_xxx, stdout="""\ Only when -DBAR. repository/src1/aaa.c: WORK_BAR repository/src1/bbb.c: WORK_BAR repository/src1/main.c: WORK_BAR """) -test.fail_test(os.path.exists(test.workpath('repository', 'src1', '.sconsign'))) -test.fail_test(os.path.exists(test.workpath('repository', 'src2', '.sconsign'))) +test.fail_test(os.path.exists( + test.workpath('repository', 'src1', '.sconsign'))) +test.fail_test(os.path.exists( + test.workpath('repository', 'src2', '.sconsign'))) test.fail_test(os.path.exists(test.workpath('work1', 'src1', '.sconsign'))) test.fail_test(os.path.exists(test.workpath('work2', 'src2', '.sconsign'))) -test.up_to_date(chdir = 'work1', options = opts + " OS=bar", arguments = 'build1') +test.up_to_date(chdir='work1', options=opts + " OS=bar", arguments='build1') # -test.run(chdir = 'work1', options = opts + " OS=foo", arguments = 'build1') +test.run(chdir='work1', options=opts + " OS=foo", arguments='build1') -test.run(program = work1_build1_foo_xxx, stdout = """\ +test.run(program=work1_build1_foo_xxx, stdout="""\ repository/src1/aaa.c: WORK_FOO repository/src1/bbb.c: WORK_FOO repository/src1/main.c: WORK_FOO """) -test.fail_test(os.path.exists(test.workpath('repository', 'src1', '.sconsign'))) -test.fail_test(os.path.exists(test.workpath('repository', 'src2', '.sconsign'))) +test.fail_test(os.path.exists( + test.workpath('repository', 'src1', '.sconsign'))) +test.fail_test(os.path.exists( + test.workpath('repository', 'src2', '.sconsign'))) test.fail_test(os.path.exists(test.workpath('work1', 'src1', '.sconsign'))) test.fail_test(os.path.exists(test.workpath('work2', 'src2', '.sconsign'))) -test.up_to_date(chdir = 'work1', options = opts + " OS=foo", arguments = 'build1') +test.up_to_date(chdir='work1', options=opts + " OS=foo", arguments='build1') # -test.up_to_date(chdir = 'work2', options = opts, arguments = 'build2') - -test.fail_test(os.path.exists(test.workpath('work2', 'build2', 'foo', 'src2', 'xxx', aaa_obj))) -test.fail_test(os.path.exists(test.workpath('work2', 'build2', 'foo', 'src2', 'xxx', bbb_obj))) -test.fail_test(os.path.exists(test.workpath('work2', 'build2', 'foo', 'src2', 'xxx', main_obj))) -test.fail_test(os.path.exists(test.workpath('work2', 'build2', 'foo', 'src2', 'xxx', xxx_exe))) -test.fail_test(os.path.exists(test.workpath('work2', 'build2', 'bar', 'src2', 'xxx', aaa_obj))) -test.fail_test(os.path.exists(test.workpath('work2', 'build2', 'bar', 'src2', 'xxx', bbb_obj))) -test.fail_test(os.path.exists(test.workpath('work2', 'build2', 'bar', 'src2', 'xxx', main_obj))) -test.fail_test(os.path.exists(test.workpath('work2', 'build2', 'bar', 'src2', 'xxx', xxx_exe))) +test.up_to_date(chdir='work2', options=opts, arguments='build2') + +test.fail_test(os.path.exists(test.workpath( + 'work2', 'build2', 'foo', 'src2', 'xxx', aaa_obj))) +test.fail_test(os.path.exists(test.workpath( + 'work2', 'build2', 'foo', 'src2', 'xxx', bbb_obj))) +test.fail_test(os.path.exists(test.workpath( + 'work2', 'build2', 'foo', 'src2', 'xxx', main_obj))) +test.fail_test(os.path.exists(test.workpath( + 'work2', 'build2', 'foo', 'src2', 'xxx', xxx_exe))) +test.fail_test(os.path.exists(test.workpath( + 'work2', 'build2', 'bar', 'src2', 'xxx', aaa_obj))) +test.fail_test(os.path.exists(test.workpath( + 'work2', 'build2', 'bar', 'src2', 'xxx', bbb_obj))) +test.fail_test(os.path.exists(test.workpath( + 'work2', 'build2', 'bar', 'src2', 'xxx', main_obj))) +test.fail_test(os.path.exists(test.workpath( + 'work2', 'build2', 'bar', 'src2', 'xxx', xxx_exe))) # Ensure file time stamps will be newer. time.sleep(2) @@ -346,22 +368,24 @@ test.write(['work2', 'src2', 'include', 'my_string.h'], r""" """) # -test.run(chdir = 'work2', options = opts, arguments = 'build2') +test.run(chdir='work2', options=opts, arguments='build2') -test.run(program = work2_build2_foo_src2_xxx_xxx, stdout = """\ +test.run(program=work2_build2_foo_src2_xxx_xxx, stdout="""\ work2/src2/include/my_string.h: FOO repository/src2/xxx/include.h: FOO repository/src2/xxx/main.c: FOO """) -test.run(program = work2_build2_bar_src2_xxx_xxx, stdout = """\ +test.run(program=work2_build2_bar_src2_xxx_xxx, stdout="""\ work2/src2/include/my_string.h: BAR repository/src2/xxx/include.h: BAR repository/src2/xxx/main.c: BAR """) -test.fail_test(os.path.exists(test.workpath('repository', 'src1', '.sconsign'))) -test.fail_test(os.path.exists(test.workpath('repository', 'src2', '.sconsign'))) +test.fail_test(os.path.exists( + test.workpath('repository', 'src1', '.sconsign'))) +test.fail_test(os.path.exists( + test.workpath('repository', 'src2', '.sconsign'))) test.fail_test(os.path.exists(test.workpath('work1', 'src1', '.sconsign'))) test.fail_test(os.path.exists(test.workpath('work2', 'src2', '.sconsign'))) @@ -379,44 +403,48 @@ test.write(['work2', 'src2', 'xxx', 'include.h'], r""" #define XXX_STRING "work2/src2/xxx/include.h: %s\n" """) -test.run(chdir = 'work2', options = opts, arguments = 'build2') +test.run(chdir='work2', options=opts, arguments='build2') -test.run(program = work2_build2_foo_src2_xxx_xxx, stdout = """\ +test.run(program=work2_build2_foo_src2_xxx_xxx, stdout="""\ work2/src2/include/my_string.h: FOO work2/src2/xxx/include.h: FOO repository/src2/xxx/main.c: FOO """) -test.run(program = work2_build2_bar_src2_xxx_xxx, stdout = """\ +test.run(program=work2_build2_bar_src2_xxx_xxx, stdout="""\ work2/src2/include/my_string.h: BAR work2/src2/xxx/include.h: BAR repository/src2/xxx/main.c: BAR """) -test.fail_test(os.path.exists(test.workpath('repository', 'src1', '.sconsign'))) -test.fail_test(os.path.exists(test.workpath('repository', 'src2', '.sconsign'))) +test.fail_test(os.path.exists( + test.workpath('repository', 'src1', '.sconsign'))) +test.fail_test(os.path.exists( + test.workpath('repository', 'src2', '.sconsign'))) test.fail_test(os.path.exists(test.workpath('work1', 'src1', '.sconsign'))) test.fail_test(os.path.exists(test.workpath('work2', 'src2', '.sconsign'))) # test.unlink(['work2', 'src2', 'include', 'my_string.h']) -test.run(chdir = 'work2', options = opts, arguments = 'build2') +test.run(chdir='work2', options=opts, arguments='build2') -test.run(program = work2_build2_foo_src2_xxx_xxx, stdout = """\ +test.run(program=work2_build2_foo_src2_xxx_xxx, stdout="""\ repository/src2/include/my_string.h: FOO work2/src2/xxx/include.h: FOO repository/src2/xxx/main.c: FOO """) -test.run(program = work2_build2_bar_src2_xxx_xxx, stdout = """\ +test.run(program=work2_build2_bar_src2_xxx_xxx, stdout="""\ repository/src2/include/my_string.h: BAR work2/src2/xxx/include.h: BAR repository/src2/xxx/main.c: BAR """) -test.fail_test(os.path.exists(test.workpath('repository', 'src1', '.sconsign'))) -test.fail_test(os.path.exists(test.workpath('repository', 'src2', '.sconsign'))) +test.fail_test(os.path.exists( + test.workpath('repository', 'src1', '.sconsign'))) +test.fail_test(os.path.exists( + test.workpath('repository', 'src2', '.sconsign'))) test.fail_test(os.path.exists(test.workpath('work1', 'src1', '.sconsign'))) test.fail_test(os.path.exists(test.workpath('work2', 'src2', '.sconsign'))) diff --git a/test/SConscript/SConscriptChdir.py b/test/SConscript/SConscriptChdir.py index 2e25acf..6cd4566 100644 --- a/test/SConscript/SConscriptChdir.py +++ b/test/SConscript/SConscriptChdir.py @@ -76,10 +76,10 @@ f.close() test.run(arguments=".", stderr=None) -test.must_match(['dir1', 'test.txt'],"This is the dir1 test.\n") -test.must_match(['dir2', 'test.txt'], "This is the dir2 test.\n") -test.must_match('test.txt',"This is the dir3 test.\nThis is the dir5 test.\n") -test.must_match(['dir4', 'test.txt'],"This is the dir4 test.\n") +test.must_match(['dir1', 'test.txt'],"This is the dir1 test.\n", mode='r') +test.must_match(['dir2', 'test.txt'], "This is the dir2 test.\n", mode='r') +test.must_match('test.txt',"This is the dir3 test.\nThis is the dir5 test.\n", mode='r') +test.must_match(['dir4', 'test.txt'],"This is the dir4 test.\n", mode='r') test.pass_test() diff --git a/test/Scanner/dictionary.py b/test/Scanner/dictionary.py index f6f121e..c587098 100644 --- a/test/Scanner/dictionary.py +++ b/test/Scanner/dictionary.py @@ -146,9 +146,9 @@ expect_aaa = 'aaa.k1 1\nline 2\nxxx 1\ninclude2 yyy\ninclude3 zzz\nline 6\n' expect_bbb = 'bbb.k2 1\nline 2\ninclude1 xxx\nyyy 1\ninclude3 zzz\nline 6\n' expect_ccc = 'ccc.k3 1\nline 2\ninclude1 xxx\ninclude2 yyy\nzzz 1\nline 6\n' -test.must_match('aaa', expect_aaa) -test.must_match('bbb', expect_bbb) -test.must_match('ccc', expect_ccc) +test.must_match('aaa', expect_aaa, mode='r') +test.must_match('bbb', expect_bbb, mode='r') +test.must_match('ccc', expect_ccc, mode='r') test.up_to_date(arguments = '.') @@ -164,7 +164,7 @@ test.run(stdout=expect) expect_ccc = 'ccc.k3 1\nline 2\ninclude1 xxx\ninclude2 yyy\nzzz 2\nline 6\n' -test.must_match('bbb', expect_bbb) +test.must_match('bbb', expect_bbb, mode='r') @@ -178,7 +178,7 @@ test.run(stdout=expect) expect_bbb = 'bbb.k2 1\nline 2\ninclude1 xxx\nyyy 2\ninclude3 zzz\nline 6\n' -test.must_match('bbb', expect_bbb) +test.must_match('bbb', expect_bbb, mode='r') @@ -192,7 +192,7 @@ test.run(stdout=expect) expect_aaa = 'aaa.k1 1\nline 2\nxxx 2\ninclude2 yyy\ninclude3 zzz\nline 6\n' -test.must_match('bbb', expect_bbb) +test.must_match('bbb', expect_bbb, mode='r') diff --git a/test/Scanner/multi-env.py b/test/Scanner/multi-env.py index 7cb052a..9cf86dc 100644 --- a/test/Scanner/multi-env.py +++ b/test/Scanner/multi-env.py @@ -99,8 +99,8 @@ expect = test.wrap_stdout("""\ test.run(arguments='.', stdout=expect) -test.must_match('frog.1', 'croak\ninput sound2\n') -test.must_match('frog.2', 'include sound1\nribbet\n') +test.must_match('frog.1', 'croak\ninput sound2\n', mode='r') +test.must_match('frog.2', 'include sound1\nribbet\n', mode='r') test.write('sound2', 'rudeep\n') @@ -110,8 +110,8 @@ expect = test.wrap_stdout("""\ test.run(arguments='.', stdout=expect) -test.must_match('frog.1', 'croak\ninput sound2\n') -test.must_match('frog.2', 'include sound1\nrudeep\n') +test.must_match('frog.1', 'croak\ninput sound2\n', mode='r') +test.must_match('frog.2', 'include sound1\nrudeep\n', mode='r') test.pass_test() diff --git a/test/Scanner/source_scanner-dict.py b/test/Scanner/source_scanner-dict.py index bb12364..47773b8 100644 --- a/test/Scanner/source_scanner-dict.py +++ b/test/Scanner/source_scanner-dict.py @@ -155,10 +155,10 @@ expect_bbb = 'bbb.k2 1\nline 2\ninclude1 xxx\nyyy 1\ninclude3 zzz\nline 6\n' expect_ccc = 'ccc.k3 1\nline 2\ninclude1 xxx\ninclude2 yyy\nzzz 1\nline 6\n' expect_ddd = 'ddd.k4 1\nline 2\nline 3\n' + expect_aaa + expect_bbb + expect_ccc -test.must_match('aaa', expect_aaa) -test.must_match('bbb', expect_bbb) -test.must_match('ccc', expect_ccc) -test.must_match('ddd', expect_ddd) +test.must_match('aaa', expect_aaa, mode='r') +test.must_match('bbb', expect_bbb, mode='r') +test.must_match('ccc', expect_ccc, mode='r') +test.must_match('ddd', expect_ddd, mode='r') test.up_to_date(arguments = '.') @@ -176,8 +176,8 @@ test.run(stdout=expect) expect_ccc = 'ccc.k3 1\nline 2\ninclude1 xxx\ninclude2 yyy\nzzz 2\nline 6\n' expect_ddd = 'ddd.k4 1\nline 2\nline 3\n' + expect_aaa + expect_bbb + expect_ccc -test.must_match('bbb', expect_bbb) -test.must_match('ddd', expect_ddd) +test.must_match('bbb', expect_bbb, mode='r') +test.must_match('ddd', expect_ddd, mode='r') @@ -193,8 +193,8 @@ test.run(stdout=expect) expect_bbb = 'bbb.k2 1\nline 2\ninclude1 xxx\nyyy 2\ninclude3 zzz\nline 6\n' expect_ddd = 'ddd.k4 1\nline 2\nline 3\n' + expect_aaa + expect_bbb + expect_ccc -test.must_match('bbb', expect_bbb) -test.must_match('ddd', expect_ddd) +test.must_match('bbb', expect_bbb, mode='r') +test.must_match('ddd', expect_ddd, mode='r') @@ -210,8 +210,8 @@ test.run(stdout=expect) expect_aaa = 'aaa.k1 1\nline 2\nxxx 2\ninclude2 yyy\ninclude3 zzz\nline 6\n' expect_ddd = 'ddd.k4 1\nline 2\nline 3\n' + expect_aaa + expect_bbb + expect_ccc -test.must_match('aaa', expect_aaa) -test.must_match('ddd', expect_ddd) +test.must_match('aaa', expect_aaa, mode='r') +test.must_match('ddd', expect_ddd, mode='r') diff --git a/test/Scanner/unicode.py b/test/Scanner/unicode.py index c698532..96010de 100644 --- a/test/Scanner/unicode.py +++ b/test/Scanner/unicode.py @@ -50,14 +50,17 @@ import sys def process(outfp, infile): contents = open(infile, 'rb').read() - if contents.startswith(codecs.BOM_UTF8): + if contents[:len(codecs.BOM_UTF8)] == codecs.BOM_UTF8: contents = contents[len(codecs.BOM_UTF8):].decode('utf-8') - elif contents.startswith(codecs.BOM_UTF16_LE): + elif contents[:len(codecs.BOM_UTF16_LE)] == codecs.BOM_UTF16_LE: contents = contents[len(codecs.BOM_UTF16_LE):].decode('utf-16-le') - elif contents.startswith(codecs.BOM_UTF16_BE): + elif contents[:len(codecs.BOM_UTF16_BE)] == codecs.BOM_UTF16_BE: contents = contents[len(codecs.BOM_UTF16_BE):].decode('utf-16-be') - else: + try: contents = contents.decode('ascii') + except (UnicodeDecodeError, AttributeError) as e: + contents = contents + for line in contents.split('\n')[:-1]: if line[:8] == 'include ': process(outfp, line[8:]) @@ -156,7 +159,7 @@ utf16be.k 1 line 3 foo.k 1 line 4 """ -test.must_match('foo', expect) +test.must_match('foo', expect, mode='r') test.up_to_date(arguments='foo') @@ -183,7 +186,7 @@ utf16be.k 1 line 3 foo.k 1 line 4 """ -test.must_match('foo', expect) +test.must_match('foo', expect, mode='r') test.up_to_date(arguments = 'foo') @@ -210,7 +213,7 @@ utf16be.k 1 line 3 foo.k 1 line 4 """ -test.must_match('foo', expect) +test.must_match('foo', expect, mode='r') test.up_to_date(arguments = 'foo') @@ -237,7 +240,7 @@ utf16be.k 1 line 3 foo.k 1 line 4 """ -test.must_match('foo', expect) +test.must_match('foo', expect, mode='r') test.up_to_date(arguments = 'foo') @@ -264,7 +267,7 @@ utf16be.k 1 line 3 foo.k 1 line 4 """ -test.must_match('foo', expect) +test.must_match('foo', expect, mode='r') test.up_to_date(arguments = 'foo') diff --git a/test/TEX/LATEX.py b/test/TEX/LATEX.py index 362bb62..dc5e535 100644 --- a/test/TEX/LATEX.py +++ b/test/TEX/LATEX.py @@ -72,13 +72,13 @@ test.write('test2.latex', r"""This is a .latex test. test.run(arguments = '.') -test.must_match('test1.dvi', "This is a .ltx test.\n") -test.must_match('test1.aux', "This is a .ltx test.\n") -test.must_match('test1.log', "This is a .ltx test.\n") +test.must_match('test1.dvi', "This is a .ltx test.\n", mode='r') +test.must_match('test1.aux', "This is a .ltx test.\n", mode='r') +test.must_match('test1.log', "This is a .ltx test.\n", mode='r') -test.must_match('test2.dvi', "This is a .latex test.\n") -test.must_match('test2.aux', "This is a .latex test.\n") -test.must_match('test2.log', "This is a .latex test.\n") +test.must_match('test2.dvi', "This is a .latex test.\n", mode='r') +test.must_match('test2.aux', "This is a .latex test.\n", mode='r') +test.must_match('test2.log', "This is a .latex test.\n", mode='r') test.run(arguments = '-c .') @@ -174,11 +174,11 @@ This is the include file. mod %s test.must_exist('foo.dvi') test.run(arguments = 'bar.dvi', stderr = None) - test.must_match('wrapper.out', "wrapper.py\n") + test.must_match('wrapper.out', "wrapper.py\n", mode='r') test.must_exist('bar.dvi') test.run(arguments = 'makeindex.dvi', stderr = None) - test.must_match('wrapper.out', "wrapper.py\n") + test.must_match('wrapper.out', "wrapper.py\n", mode='r') test.run(arguments = 'latexi.dvi', stderr = None) test.must_exist('latexi.dvi') diff --git a/test/TEX/TEXFLAGS.py b/test/TEX/TEXFLAGS.py index 4b632f7..7b4fd15 100644 --- a/test/TEX/TEXFLAGS.py +++ b/test/TEX/TEXFLAGS.py @@ -65,7 +65,7 @@ test.write('test.tex', r"""This is a test. test.run(arguments = 'test.dvi', stderr = None) -test.must_match('test.dvi'," -x\nThis is a test.\n") +test.must_match('test.dvi'," -x\nThis is a test.\n", mode='r') diff --git a/test/explain/basic.py b/test/explain/basic.py index fb331fe..ec7238e 100644 --- a/test/explain/basic.py +++ b/test/explain/basic.py @@ -207,15 +207,15 @@ test.set_match_function(TestSCons.match_caseinsensitive) test.run(chdir='src', arguments=args, stdout=expect) test.set_match_function(TestSCons.match_exact) -test.must_match(['src', 'file1'], "file1.in 1\n") +test.must_match(['src', 'file1'], "file1.in 1\n", mode='r') test.must_match(['src', 'file2'], """\ file2.k 1 line 1 xxx 1 yyy 1 file2.k 1 line 4 -""") -test.must_match(['src', 'file3'], "xxx 1\nyyy 1\nzzz 1\n") -test.must_match(['src', 'file4'], "file4.in 1\n") +""", mode='r') +test.must_match(['src', 'file3'], "xxx 1\nyyy 1\nzzz 1\n", mode='r') +test.must_match(['src', 'file4'], "file4.in 1\n", mode='r') test.must_match(['src', 'file5'], """\ file5.k 1 line 1 aaa 1 @@ -224,8 +224,8 @@ ccc 1 ddd 1 eee.in 1 file5.k 1 line 4 -""") -test.must_match(['src', 'file6'], "file6.in 1\n") +""", mode='r') +test.must_match(['src', 'file6'], "file6.in 1\n", mode='r') @@ -262,21 +262,21 @@ test.set_match_function(TestSCons.match_caseinsensitive) test.run(chdir='src', arguments=args, stdout=expect) test.set_match_function(TestSCons.match_exact) -test.must_match(['src', 'file1'], "file1.in 2\n") +test.must_match(['src', 'file1'], "file1.in 2\n", mode='r') test.must_match(['src', 'file2'], """\ file2.k 1 line 1 xxx 1 yyy 2 file2.k 1 line 4 -""") -test.must_match(['src', 'file3'], "xxx 1\nyyy 2\nzzz 2\n") +""", mode='r') +test.must_match(['src', 'file3'], "xxx 1\nyyy 2\nzzz 2\n", mode='r') test.must_match(['src', 'file5'], """\ file5.k 1 line 1 aaa 1 bbb.k 2 ccc 1 file5.k 1 line 4 -""") +""", mode='r') @@ -294,7 +294,7 @@ test.set_match_function(TestSCons.match_caseinsensitive) test.run(chdir='src', arguments=args, stdout=expect) test.set_match_function(TestSCons.match_exact) -test.must_match(['src', 'file3'], "xxx 1\nyyy 2\n") +test.must_match(['src', 'file3'], "xxx 1\nyyy 2\n", mode='r') @@ -312,7 +312,7 @@ test.set_match_function(TestSCons.match_caseinsensitive) test.run(chdir='src', arguments=args, stdout=expect) test.set_match_function(TestSCons.match_exact) -test.must_match(['src', 'file3'], "xxx 1\nyyy 2\nzzz 2\n") +test.must_match(['src', 'file3'], "xxx 1\nyyy 2\nzzz 2\n", mode='r') @@ -334,7 +334,7 @@ test.set_match_function(TestSCons.match_caseinsensitive) test.run(chdir='src', arguments=args, stdout=expect) test.set_match_function(TestSCons.match_exact) -test.must_match(['src', 'file3'], "zzz 2\nyyy 2\nxxx 1\n") +test.must_match(['src', 'file3'], "zzz 2\nyyy 2\nxxx 1\n", mode='r') @@ -361,9 +361,9 @@ test.set_match_function(TestSCons.match_caseinsensitive) test.run(chdir='src', arguments=args, stdout=expect) test.set_match_function(TestSCons.match_exact) -test.must_match(['src', 'file3'], "zzz 2\nyyy 2\nxxx 1\n") -test.must_match(['src', 'file3.alt'], "zzz 2\nyyy 2\nxxx 1\n") -test.must_match(['src', 'file3.yyy'], "zzz 2\nyyy 2\nxxx 1\nyyy 2\n") +test.must_match(['src', 'file3'], "zzz 2\nyyy 2\nxxx 1\n", mode='r') +test.must_match(['src', 'file3.alt'], "zzz 2\nyyy 2\nxxx 1\n", mode='r') +test.must_match(['src', 'file3.yyy'], "zzz 2\nyyy 2\nxxx 1\nyyy 2\n", mode='r') @@ -392,9 +392,9 @@ test.set_match_function(TestSCons.match_caseinsensitive) test.run(chdir='src', arguments=args, stdout=expect) test.set_match_function(TestSCons.match_exact) -test.must_match(['src', 'file3'], "zzz 2\nyyy 2\nxxx 1\n") -test.must_match(['src', 'file3.alt'], "zzz 2\nyyy 2\nxxx 1\n") -test.must_match(['src', 'file3.yyy'], "zzz 2\nyyy 2\nxxx 1\nxxx 1\n") +test.must_match(['src', 'file3'], "zzz 2\nyyy 2\nxxx 1\n", mode='r') +test.must_match(['src', 'file3.alt'], "zzz 2\nyyy 2\nxxx 1\n", mode='r') +test.must_match(['src', 'file3.yyy'], "zzz 2\nyyy 2\nxxx 1\nxxx 1\n", mode='r') @@ -415,7 +415,7 @@ test.set_match_function(TestSCons.match_caseinsensitive) test.run(chdir='src',arguments=args, stdout=expect) test.set_match_function(TestSCons.match_exact) -test.must_match(['src', 'file4'], "file4.in 1\n") +test.must_match(['src', 'file4'], "file4.in 1\n", mode='r') test.up_to_date(chdir='src',arguments='.') diff --git a/test/explain/save-info.py b/test/explain/save-info.py index 150d7ef..048ee8d 100644 --- a/test/explain/save-info.py +++ b/test/explain/save-info.py @@ -145,15 +145,15 @@ test.write(['src', 'subdir', 'file6.in'], "subdir/file6.in 1\n") # test.run(chdir='src', arguments='..') -test.must_match(['src', 'file1'], "file1.in 1\n") +test.must_match(['src', 'file1'], "file1.in 1\n", mode='r') test.must_match(['src', 'file2'], """\ file2.k 1 line 1 xxx 1 yyy 1 file2.k 1 line 4 -""") -test.must_match(['src', 'file3'], "xxx 1\nyyy 1\nzzz 1\n") -test.must_match(['src', 'file4'], "file4.in 1\n") +""", mode='r') +test.must_match(['src', 'file3'], "xxx 1\nyyy 1\nzzz 1\n", mode='r') +test.must_match(['src', 'file4'], "file4.in 1\n", mode='r') test.must_match(['src', 'file5'], """\ file5.k 1 line 1 aaa 1 @@ -162,7 +162,7 @@ ccc 1 ddd 1 eee.in 1 file5.k 1 line 4 -""") +""", mode='r') test.write(['src', 'file1.in'], "file1.in 2\n") test.write(['src', 'yyy'], "yyy 2\n") @@ -186,21 +186,21 @@ scons: rebuilding `file5' because `%(inc_bbb_k)s' changed test.run(chdir='src', arguments='--debug=explain .', stdout=expect) -test.must_match(['src', 'file1'], "file1.in 2\n") +test.must_match(['src', 'file1'], "file1.in 2\n", mode='r') test.must_match(['src', 'file2'], """\ file2.k 1 line 1 xxx 1 yyy 2 file2.k 1 line 4 -""") -test.must_match(['src', 'file3'], "xxx 1\nyyy 2\nzzz 2\n") +""", mode='r') +test.must_match(['src', 'file3'], "xxx 1\nyyy 2\nzzz 2\n", mode='r') test.must_match(['src', 'file5'], """\ file5.k 1 line 1 aaa 1 bbb.k 2 ccc 1 file5.k 1 line 4 -""") +""", mode='r') diff --git a/test/implicit/IMPLICIT_COMMAND_DEPENDENCIES.py b/test/implicit/IMPLICIT_COMMAND_DEPENDENCIES.py index e2e4866..2c9fd08 100644 --- a/test/implicit/IMPLICIT_COMMAND_DEPENDENCIES.py +++ b/test/implicit/IMPLICIT_COMMAND_DEPENDENCIES.py @@ -32,7 +32,10 @@ is added to targets. import TestSCons -python = TestSCons.python +# swap slashes because on py3 on win32 inside the generated build.py +# the backslashes are getting interpretted as unicode which is +# invalid. +python = TestSCons.python.replace('\\','//') _python_ = TestSCons._python_ test = TestSCons.TestSCons() @@ -98,13 +101,13 @@ test.run(arguments = '--tree=all .') expect_none = 'build.py %s file.in\nfile.in\n' -test.must_match('file.out', expect_none % 'file.out') -test.must_match('file0.out', expect_none % 'file0.out') -test.must_match('file1.out', expect_none % 'file1.out') -test.must_match('fileNone.out', expect_none % 'fileNone.out') -test.must_match('fileFalse.out', expect_none % 'fileFalse.out') -test.must_match('fileTrue.out', expect_none % 'fileTrue.out') -test.must_match('fileQuote.out', expect_none % 'fileQuote.out') +test.must_match('file.out', expect_none % 'file.out', mode='r') +test.must_match('file0.out', expect_none % 'file0.out', mode='r') +test.must_match('file1.out', expect_none % 'file1.out', mode='r') +test.must_match('fileNone.out', expect_none % 'fileNone.out', mode='r') +test.must_match('fileFalse.out', expect_none % 'fileFalse.out', mode='r') +test.must_match('fileTrue.out', expect_none % 'fileTrue.out', mode='r') +test.must_match('fileQuote.out', expect_none % 'fileQuote.out', mode='r') @@ -115,13 +118,13 @@ test.run(arguments = '--tree=all .') expect_extra = 'build.py %s file.in\nxyzzy\nfile.in\n' -test.must_match('file.out', expect_extra % 'file.out') -test.must_match('file0.out', expect_none % 'file0.out') -test.must_match('file1.out', expect_extra % 'file1.out') -test.must_match('fileNone.out', expect_none % 'fileNone.out') -test.must_match('fileFalse.out', expect_none % 'fileFalse.out') -test.must_match('fileTrue.out', expect_extra % 'fileTrue.out') -test.must_match('fileQuote.out', expect_extra % 'fileQuote.out') +test.must_match('file.out', expect_extra % 'file.out', mode='r') +test.must_match('file0.out', expect_none % 'file0.out', mode='r') +test.must_match('file1.out', expect_extra % 'file1.out', mode='r') +test.must_match('fileNone.out', expect_none % 'fileNone.out', mode='r') +test.must_match('fileFalse.out', expect_none % 'fileFalse.out', mode='r') +test.must_match('fileTrue.out', expect_extra % 'fileTrue.out', mode='r') +test.must_match('fileQuote.out', expect_extra % 'fileQuote.out', mode='r') test.pass_test() -- cgit v0.12 From 6659da8dda800c8d19d3efc01ec3c6607cbb04ab Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 20 Mar 2017 10:49:53 -0700 Subject: py2/3 doesn't fix py3 yet. --- test/Copy-Action.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/test/Copy-Action.py b/test/Copy-Action.py index ded158a..6003aa9 100644 --- a/test/Copy-Action.py +++ b/test/Copy-Action.py @@ -43,9 +43,9 @@ Execute(Copy(File('d2.out'), 'd2.in')) Execute(Copy('d3.out', File('f3.in'))) def cat(env, source, target): target = str(target[0]) - f = open(target, "wb") + f = open(target, "w") for src in source: - f.write(open(str(src), "rb").read()) + f.write(open(str(src), "r").read()) f.close() Cat = Action(cat) env = Environment() @@ -134,20 +134,20 @@ test.must_not_exist('f 13.out') test.run() -test.must_match('f1.out', "f1.in\n") -test.must_match(['d2.out', 'file'], "d2.in/file\n") -test.must_match(['d3.out', 'f3.in'], "f3.in\n") -test.must_match('f4.out', "f4.in\n") -test.must_match(['d5.out', 'file'], "d5.in/file\n") -test.must_match(['d6.out', 'f6.in'], "f6.in\n") -test.must_match('f7.out', "f7.in\n") -test.must_match('f8.out', "f8.in\n") -test.must_match('f9.out', "f9.in\n") -test.must_match('f9.out-Copy', "f9.in\n") -test.must_match('d4/f10.in', 'f10.in\n') -test.must_match('d4/f11.out', 'f11.in\n') -test.must_match('d4/f12.out', 'f12.in\n') -test.must_match('f 13.out', 'f 13.in\n') +test.must_match('f1.out', "f1.in\n", mode='r') +test.must_match(['d2.out', 'file'], "d2.in/file\n", mode='r') +test.must_match(['d3.out', 'f3.in'], "f3.in\n", mode='r') +test.must_match('f4.out', "f4.in\n", mode='r') +test.must_match(['d5.out', 'file'], "d5.in/file\n", mode='r') +test.must_match(['d6.out', 'f6.in'], "f6.in\n", mode='r') +test.must_match('f7.out', "f7.in\n", mode='r') +test.must_match('f8.out', "f8.in\n", mode='r') +test.must_match('f9.out', "f9.in\n", mode='r') +test.must_match('f9.out-Copy', "f9.in\n", mode='r') +test.must_match('d4/f10.in', 'f10.in\n', mode='r') +test.must_match('d4/f11.out', 'f11.in\n', mode='r') +test.must_match('d4/f12.out', 'f12.in\n', mode='r') +test.must_match('f 13.out', 'f 13.in\n', mode='r') errors = 0 -- cgit v0.12 From 826315a8e44157d41ab9f1eadaf364b06566ec02 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 20 Mar 2017 10:50:13 -0700 Subject: py2/3 fix must_match and rb/wb --- test/Default.py | 32 ++++++++++++++++---------------- test/subdir.py | 12 ++++++------ 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/test/Default.py b/test/Default.py index b8ccce2..e9ca96a 100644 --- a/test/Default.py +++ b/test/Default.py @@ -46,8 +46,8 @@ for dir in ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight']: test.write('build.py', r""" import sys -contents = open(sys.argv[2], 'rb').read() -file = open(sys.argv[1], 'wb') +contents = open(sys.argv[2], 'r').read() +file = open(sys.argv[1], 'w') file.write(contents) file.close() """) @@ -98,21 +98,21 @@ for dir in ['one', 'two', 'three', 'four', 'five']: test.run(chdir = dir) # no arguments, use the Default -test.fail_test(test.read(test.workpath('one', 'foo.out')) != "one/foo.in\n") +test.must_match(test.workpath('one', 'foo.out'), "one/foo.in\n") test.fail_test(os.path.exists(test.workpath('one', 'bar'))) -test.fail_test(test.read(test.workpath('two', 'foo.out')) != "two/foo.in\n") -test.fail_test(test.read(test.workpath('two', 'bar.out')) != "two/bar.in\n") +test.must_match(test.workpath('two', 'foo.out'), "two/foo.in\n") +test.must_match(test.workpath('two', 'bar.out'), "two/bar.in\n") -test.fail_test(test.read(test.workpath('three', 'foo.out')) != "three/foo.in\n") -test.fail_test(test.read(test.workpath('three', 'bar.out')) != "three/bar.in\n") +test.must_match(test.workpath('three', 'foo.out'), "three/foo.in\n") +test.must_match(test.workpath('three', 'bar.out'), "three/bar.in\n") test.fail_test(os.path.exists(test.workpath('four', 'foo'))) test.fail_test(os.path.exists(test.workpath('four', 'bar'))) -test.fail_test(test.read(test.workpath('four', 'foo bar')) != "four/foo.in\n") +test.must_match(test.workpath('four', 'foo bar'), "four/foo.in\n") -test.fail_test(test.read(test.workpath('five', 'foo.out')) != "five/foo.in\n") -test.fail_test(test.read(test.workpath('five', 'bar.out')) != "five/bar.in\n") +test.must_match(test.workpath('five', 'foo.out'), "five/foo.in\n") +test.must_match(test.workpath('five', 'bar.out'), "five/bar.in\n") @@ -150,7 +150,7 @@ Default(foo, None, bar) test.run(chdir = 'eight') # no arguments, use the Default test.fail_test(os.path.exists(test.workpath('eight', 'foo.out'))) -test.fail_test(test.read(test.workpath('eight', 'bar.out')) != "eight/bar.in\n") +test.must_match(test.workpath('eight', 'bar.out'), "eight/bar.in\n") @@ -178,7 +178,7 @@ test.write(['nine', 'sub1', 'xxx.in'], "sub1/xxx.in\n") test.run(chdir = 'nine') # no arguments, use the Default test.fail_test(os.path.exists(test.workpath('nine', 'xxx.out'))) -test.fail_test(test.read(test.workpath('nine', 'sub1', 'xxx.out')) != "sub1/xxx.in\n") +test.must_match(test.workpath('nine', 'sub1', 'xxx.out'), "sub1/xxx.in\n") @@ -205,7 +205,7 @@ test.write(['ten', 'sub2', 'xxx.in'], "sub2/xxx.in\n") test.run(chdir = 'ten') # no arguments, use the Default test.fail_test(os.path.exists(test.workpath('ten', 'xxx.out'))) -test.fail_test(test.read(test.workpath('ten', 'sub2', 'xxx.out')) != "sub2/xxx.in\n") +test.must_match(test.workpath('ten', 'sub2', 'xxx.out'), "sub2/xxx.in\n") test.subdir('eleven') @@ -218,13 +218,13 @@ env.B(target = 'bar.out', source = 'bar.in') env.Default('$XXX') """ % locals()) -test.write(os.path.join('eleven', 'foo.in'), "eleven/foo.in\n"); +test.write(os.path.join('eleven', 'foo.in'), "eleven/foo.in\n") -test.write(os.path.join('eleven', 'bar.in'), "eleven/bar.in\n"); +test.write(os.path.join('eleven', 'bar.in'), "eleven/bar.in\n") test.run(chdir = 'eleven') # no arguments, use the Default -test.fail_test(test.read(test.workpath('eleven', 'foo.out')) != "eleven/foo.in\n") +test.must_match(test.workpath('eleven', 'foo.out'), "eleven/foo.in\n") test.fail_test(os.path.exists(test.workpath('eleven', 'bar'))) diff --git a/test/subdir.py b/test/subdir.py index 22d0912..67e8450 100644 --- a/test/subdir.py +++ b/test/subdir.py @@ -35,8 +35,8 @@ test.subdir('subdir') test.write('build.py', r""" import sys -contents = open(sys.argv[2], 'rb').read() -file = open(sys.argv[1], 'wb') +contents = open(sys.argv[2], 'r').read() +file = open(sys.argv[1], 'w') file.write(contents) file.close() """) @@ -57,10 +57,10 @@ test.write(['subdir', 'f4.in'], "f4.in\n") test.run(arguments = 'subdir') -test.fail_test(test.read(['subdir', 'f1.out']) != "f1.in\n") -test.fail_test(test.read(['subdir', 'f2.out']) != "f2.in\n") -test.fail_test(test.read(['subdir', 'f3.out']) != "f3.in\n") -test.fail_test(test.read(['subdir', 'f4.out']) != "f4.in\n") +test.must_match(['subdir', 'f1.out'], "f1.in\n") +test.must_match(['subdir', 'f2.out'], "f2.in\n") +test.must_match(['subdir', 'f3.out'], "f3.in\n") +test.must_match(['subdir', 'f4.out'], "f4.in\n") test.up_to_date(arguments = 'subdir') -- cgit v0.12 From 6d602edd0c5f55e061d6f46aec06098d6a9e484b Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 20 Mar 2017 10:50:24 -0700 Subject: py2/3 fix must_match and rb/wb --- src/engine/SCons/SConfTests.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/SCons/SConfTests.py b/src/engine/SCons/SConfTests.py index ef01414..b2aa3b4 100644 --- a/src/engine/SCons/SConfTests.py +++ b/src/engine/SCons/SConfTests.py @@ -266,7 +266,7 @@ int main() { log_file=self.test.workpath('config.log')) try: res = checks(sconf) - assert res[0][0] and res[0][1] == bytearray("Hello",'utf-8'), res + assert res[0][0] and res[0][1] == "Hello", res assert not res[1][0] and res[1][1] == "", res finally: sconf.Finish() @@ -279,7 +279,7 @@ int main() { log_file=self.test.workpath('config.log')) try: res = checks(sconf) - assert res[0][0] and res[0][1] == bytearray("Hello",'utf-8'), res + assert res[0][0] and res[0][1] == "Hello", res assert not res[1][0] and res[1][1] == "", res finally: sconf.Finish() @@ -759,7 +759,7 @@ int main() { """ (ret, output) = test.TryRun( prog, ".c" ) test.Result( ret ) - assert ret and output == b"Hello", (ret, output) + assert ret and output == "Hello", (ret, output) return ret -- cgit v0.12 From b66404ee6d63522fe35b056cb7940531caafa804 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 20 Mar 2017 10:57:39 -0700 Subject: remove deprecated Perforce tool --- doc/generated/builders.gen | 2 +- doc/generated/functions.gen | 60 ++--------------- doc/generated/functions.mod | 4 -- doc/generated/tools.gen | 9 --- doc/generated/tools.mod | 2 - doc/generated/variables.gen | 39 +---------- doc/generated/variables.mod | 8 --- src/CHANGES.txt | 3 + src/engine/SCons/Tool/Perforce.py | 99 ---------------------------- src/engine/SCons/Tool/Perforce.xml | 129 ------------------------------------- src/engine/SCons/Tool/__init__.py | 2 +- 11 files changed, 12 insertions(+), 345 deletions(-) delete mode 100644 src/engine/SCons/Tool/Perforce.py delete mode 100644 src/engine/SCons/Tool/Perforce.xml diff --git a/doc/generated/builders.gen b/doc/generated/builders.gen index d49156f..b19d82d 100644 --- a/doc/generated/builders.gen +++ b/doc/generated/builders.gen @@ -2248,7 +2248,7 @@ and the result replaces the key. env = Environment(tools = ['default', 'textfile']) env['prefix'] = '/usr/bin' -script_dict = {'@prefix@': '/bin', @exec_prefix@: '$prefix'} +script_dict = {'@prefix@': '/bin', '@exec_prefix@': '$prefix'} env.Substfile('script.in', SUBST_DICT = script_dict) conf_dict = {'%VERSION%': '1.2.3', '%BASE%': 'MyProg'} diff --git a/doc/generated/functions.gen b/doc/generated/functions.gen index e80c1c9..d6e970a 100644 --- a/doc/generated/functions.gen +++ b/doc/generated/functions.gen @@ -96,7 +96,7 @@ Examples: # which the method will be called; the Python # convention is to call it 'self'. def my_method(self, arg): - print "my_method() got", arg + print("my_method() got", arg) # Use the global AddMethod() function to add a method # to the Environment class. This @@ -1114,7 +1114,7 @@ timestamp, such as can happen when restoring files from backup archives. Specifies that a target shall be considered out of date and rebuilt -if the dependency's content has changed sine the last time +if the dependency's content has changed since the last time the target was built, as determined be performing an MD5 checksum on the dependency's contents @@ -1131,7 +1131,7 @@ can be used as a synonym for Specifies that a target shall be considered out of date and rebuilt -if the dependency's content has changed sine the last time +if the dependency's content has changed since the last time the target was built, except that dependencies with a timestamp that matches the last time the target was rebuilt will be @@ -2102,7 +2102,7 @@ import atexit def print_build_failures(): from SCons.Script import GetBuildFailures for bf in GetBuildFailures(): - print "%s failed: %s" % (bf.node, bf.errstr) + print("%s failed: %s" % (bf.node, bf.errstr)) atexit.register(print_build_failures) @@ -3062,56 +3062,6 @@ dict = env.ParseFlags('-O2', '!echo -Dfoo -Dbar=1') - - - env.Perforce() - - - -A factory function that -returns a Builder object -to be used to fetch source files -from the Perforce source code management system. -The returned Builder -is intended to be passed to the -SourceCode -function. - - - -This function is deprecated. For details, see the entry for the -SourceCode -function. - - - -Example: - - - -env.SourceCode('.', env.Perforce()) - - - -Perforce uses a number of external -environment variables for its operation. -Consequently, this function adds the -following variables from the user's external environment -to the construction environment's -ENV dictionary: -P4CHARSET, -P4CLIENT, -P4LANGUAGE, -P4PASSWD, -P4PORT, -P4USER, -SystemRoot, -USER, -and -USERNAME. - - - Platform(string) @@ -3346,7 +3296,7 @@ every 10 Nodes: def my_progress_function(node, *args, **kw): - print 'Evaluating node %s!' % node + print('Evaluating node %s!' % node) Progress(my_progress_function, interval=10) diff --git a/doc/generated/functions.mod b/doc/generated/functions.mod index 99aaa48..03cef30 100644 --- a/doc/generated/functions.mod +++ b/doc/generated/functions.mod @@ -64,7 +64,6 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. ParseConfig"> ParseDepends"> ParseFlags"> -Perforce"> Platform"> Precious"> Prepend"> @@ -152,7 +151,6 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. env.ParseConfig"> env.ParseDepends"> env.ParseFlags"> -env.Perforce"> env.Platform"> env.Precious"> env.Prepend"> @@ -250,7 +248,6 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. ParseConfig"> ParseDepends"> ParseFlags"> -Perforce"> Platform"> Precious"> Prepend"> @@ -338,7 +335,6 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. env.ParseConfig"> env.ParseDepends"> env.ParseFlags"> -env.Perforce"> env.Platform"> env.Precious"> env.Prepend"> diff --git a/doc/generated/tools.gen b/doc/generated/tools.gen index ba12966..16aa688 100644 --- a/doc/generated/tools.gen +++ b/doc/generated/tools.gen @@ -820,15 +820,6 @@ Sets construction variables for the - Perforce - - -Sets construction variables for interacting with the -Perforce source code management system. - -Sets: &cv-link-P4;, &cv-link-P4COM;, &cv-link-P4FLAGS;.Uses: &cv-link-P4COMSTR;. - qt diff --git a/doc/generated/tools.mod b/doc/generated/tools.mod index 2ee2270..9fccf32 100644 --- a/doc/generated/tools.mod +++ b/doc/generated/tools.mod @@ -83,7 +83,6 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. pdf"> pdflatex"> pdftex"> -Perforce"> qt"> RCS"> rmic"> @@ -194,7 +193,6 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. pdf"> pdflatex"> pdftex"> -Perforce"> qt"> RCS"> rmic"> diff --git a/doc/generated/variables.gen b/doc/generated/variables.gen index b377102..add620c 100644 --- a/doc/generated/variables.gen +++ b/doc/generated/variables.gen @@ -3104,7 +3104,7 @@ The command line used to call the Java archive tool. The string displayed when the Java archive tool is called -If this is not set, then $JARCOM (the command line) is displayed. +If this is not set, then $JARCOM (the command line) is displayed. @@ -3114,7 +3114,7 @@ env = Environment(JARCOMSTR = "JARchiving $SOURCES into $TARGET") The string displayed when the Java archive tool is called -If this is not set, then $JARCOM (the command line) is displayed. +If this is not set, then $JARCOM (the command line) is displayed. @@ -4616,41 +4616,6 @@ The suffix used for (static) object file names. - - P4 - - -The Perforce executable. - - - - - P4COM - - -The command line used to -fetch source files from Perforce. - - - - - P4COMSTR - - -The string displayed when -fetching a source file from Perforce. -If this is not set, then $P4COM (the command line) is displayed. - - - - - P4FLAGS - - -General options that are passed to Perforce. - - - PACKAGEROOT diff --git a/doc/generated/variables.mod b/doc/generated/variables.mod index 955a9eb..6ec13f7 100644 --- a/doc/generated/variables.mod +++ b/doc/generated/variables.mod @@ -352,10 +352,6 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. $no_import_lib"> $OBJPREFIX"> $OBJSUFFIX"> -$P4"> -$P4COM"> -$P4COMSTR"> -$P4FLAGS"> $PACKAGEROOT"> $PACKAGETYPE"> $PACKAGEVERSION"> @@ -1006,10 +1002,6 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. $no_import_lib"> $OBJPREFIX"> $OBJSUFFIX"> -$P4"> -$P4COM"> -$P4COMSTR"> -$P4FLAGS"> $PACKAGEROOT"> $PACKAGETYPE"> $PACKAGEVERSION"> diff --git a/src/CHANGES.txt b/src/CHANGES.txt index d6eed68..67bd2a3 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -29,6 +29,9 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Updated Fortran-related tests to pass under GCC 5/6. - Fixed SCons.Tool.Packaging.rpm.package source nondeterminism across builds. + From William Deegan: + - Removed deprecated source code tool Perforce. + From Daniel Moody: - Fixed msvs.py for Visual Studio generated projects which were creating invalid xml for greater than and less than symbols. diff --git a/src/engine/SCons/Tool/Perforce.py b/src/engine/SCons/Tool/Perforce.py deleted file mode 100644 index c8cf931..0000000 --- a/src/engine/SCons/Tool/Perforce.py +++ /dev/null @@ -1,99 +0,0 @@ -"""SCons.Tool.Perforce.py - -Tool-specific initialization for Perforce Source Code Management system. - -There normally shouldn't be any need to import this module directly. -It will usually be imported through the generic SCons.Tool.Tool() -selection method. - -""" - -# __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__" - -import os - -import SCons.Action -import SCons.Builder -import SCons.Node.FS -import SCons.Util - - -# Variables that we want to import from the base OS environment. -_import_env = [ 'P4PORT', 'P4CLIENT', 'P4USER', 'USER', 'USERNAME', 'P4PASSWD', - 'P4CHARSET', 'P4LANGUAGE', 'SystemRoot' ] - -PerforceAction = SCons.Action.Action('$P4COM', '$P4COMSTR') - -def generate(env): - """Add a Builder factory function and construction variables for - Perforce to an Environment.""" - - def PerforceFactory(env=env): - """ """ - import SCons.Warnings as W - W.warn(W.DeprecatedSourceCodeWarning, """The Perforce() factory is deprecated and there is no replacement.""") - return SCons.Builder.Builder(action = PerforceAction, env = env) - - env.Perforce = PerforceFactory - - env['P4'] = 'p4' - env['P4FLAGS'] = SCons.Util.CLVar('') - env['P4COM'] = '$P4 $P4FLAGS sync $TARGET' - try: - environ = env['ENV'] - except KeyError: - environ = {} - env['ENV'] = environ - - # Perforce seems to use the PWD environment variable rather than - # calling getcwd() for itself, which is odd. If no PWD variable - # is present, p4 WILL call getcwd, but this seems to cause problems - # with good ol' Windows's tilde-mangling for long file names. - environ['PWD'] = env.Dir('#').get_abspath() - - for var in _import_env: - v = os.environ.get(var) - if v: - environ[var] = v - - if SCons.Util.can_read_reg: - # If we can read the registry, add the path to Perforce to our environment. - try: - k=SCons.Util.RegOpenKeyEx(SCons.Util.hkey_mod.HKEY_LOCAL_MACHINE, - 'Software\\Perforce\\environment') - val, tok = SCons.Util.RegQueryValueEx(k, 'P4INSTROOT') - SCons.Util.AddPathIfNotExists(environ, 'PATH', val) - except SCons.Util.RegError: - # Can't detect where Perforce is, hope the user has it set in the - # PATH. - pass - -def exists(env): - return env.Detect('p4') - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/src/engine/SCons/Tool/Perforce.xml b/src/engine/SCons/Tool/Perforce.xml deleted file mode 100644 index 918bbc9..0000000 --- a/src/engine/SCons/Tool/Perforce.xml +++ /dev/null @@ -1,129 +0,0 @@ - - - - -%scons; - -%builders-mod; - -%functions-mod; - -%tools-mod; - -%variables-mod; -]> - - - - - - -Sets construction variables for interacting with the -Perforce source code management system. - - - -P4 -P4FLAGS -P4COM - - -P4COMSTR - - - - - - -The Perforce executable. - - - - - - - -The command line used to -fetch source files from Perforce. - - - - - - - -The string displayed when -fetching a source file from Perforce. -If this is not set, then &cv-link-P4COM; (the command line) is displayed. - - - - - - - -General options that are passed to Perforce. - - - - - - -() - - - -A factory function that -returns a Builder object -to be used to fetch source files -from the Perforce source code management system. -The returned Builder -is intended to be passed to the -&f-SourceCode; -function. - - - -This function is deprecated. For details, see the entry for the -&f-SourceCode; -function. - - - -Example: - - - -env.SourceCode('.', env.Perforce()) - - - -Perforce uses a number of external -environment variables for its operation. -Consequently, this function adds the -following variables from the user's external environment -to the construction environment's -ENV dictionary: -P4CHARSET, -P4CLIENT, -P4LANGUAGE, -P4PASSWD, -P4PORT, -P4USER, -SystemRoot, -USER, -and -USERNAME. - - - - - diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index dbc6d0c..4647587 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -1157,7 +1157,7 @@ def tool_list(platform, env): # Archivers 'tar', 'zip', # SourceCode factories - 'BitKeeper', 'CVS', 'Perforce', + 'BitKeeper', 'CVS', 'RCS', 'SCCS', # 'Subversion', ], env) -- cgit v0.12 From cc3600de679eafd05414286af141d6215701018b Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 20 Mar 2017 10:58:07 -0700 Subject: remove deprecated Perforce tool --- test/Deprecated/SourceCode/Perforce/P4COM.py | 140 ------------ test/Deprecated/SourceCode/Perforce/P4COMSTR.py | 142 ------------ test/Deprecated/SourceCode/Perforce/Perforce.py | 287 ------------------------ 3 files changed, 569 deletions(-) delete mode 100644 test/Deprecated/SourceCode/Perforce/P4COM.py delete mode 100644 test/Deprecated/SourceCode/Perforce/P4COMSTR.py delete mode 100644 test/Deprecated/SourceCode/Perforce/Perforce.py diff --git a/test/Deprecated/SourceCode/Perforce/P4COM.py b/test/Deprecated/SourceCode/Perforce/P4COM.py deleted file mode 100644 index e58cb60..0000000 --- a/test/Deprecated/SourceCode/Perforce/P4COM.py +++ /dev/null @@ -1,140 +0,0 @@ -#!/usr/bin/env python -# -# __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__" - -""" -Test setting the $P4COM variable. -""" - -import os.path - -import TestSCons - -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) - -test.write('SConscript', """ -Environment(tools = ['Perforce']).Perforce() -""") - -msg_p4 = """The Perforce() factory is deprecated and there is no replacement.""" -warn_p4 = test.deprecated_fatal('deprecated-build-dir', msg_p4) -msg_sc = """SourceCode() has been deprecated and there is no replacement. -\tIf you need this function, please contact scons-dev@scons.org""" -warn_sc = test.deprecated_wrap(msg_sc) - -test.subdir('Perforce', ['Perforce', 'sub'], 'sub') - -sub_Perforce = os.path.join('sub', 'Perforce') -sub_SConscript = os.path.join('sub', 'SConscript') -sub_all = os.path.join('sub', 'all') -sub_ddd_in = os.path.join('sub', 'ddd.in') -sub_ddd_out = os.path.join('sub', 'ddd.out') -sub_eee_in = os.path.join('sub', 'eee.in') -sub_eee_out = os.path.join('sub', 'eee.out') -sub_fff_in = os.path.join('sub', 'fff.in') -sub_fff_out = os.path.join('sub', 'fff.out') - -test.write('my-p4.py', """ -import shutil -import sys -for f in sys.argv[1:]: - shutil.copy('Perforce/'+f, f) -""") - -test.write('SConstruct', """ -SetOption('warn', 'deprecated-source-code') -def cat(env, source, target): - target = str(target[0]) - f = open(target, "wb") - for src in source: - f.write(open(str(src), "rb").read()) - f.close() -env = Environment(TOOLS = ['default', 'Perforce'], - BUILDERS={'Cat':Builder(action=cat)}, - P4COM=r'%(_python_)s my-p4.py $TARGET') -env.Cat('aaa.out', 'aaa.in') -env.Cat('bbb.out', 'bbb.in') -env.Cat('ccc.out', 'ccc.in') -env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) -env.SourceCode('.', env.Perforce()) -SConscript('sub/SConscript', "env") -""" % locals()) - -test.write(['Perforce', 'sub', 'SConscript'], """\ -Import("env") -env.Cat('ddd.out', 'ddd.in') -env.Cat('eee.out', 'eee.in') -env.Cat('fff.out', 'fff.in') -env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) -""") - -test.write(['Perforce', 'aaa.in'], "Perforce/aaa.in\n") -test.write('bbb.in', "checked-out bbb.in\n") -test.write(['Perforce', 'ccc.in'], "Perforce/ccc.in\n") - -test.write(['Perforce', 'sub', 'ddd.in'], "Perforce/sub/ddd.in\n") -test.write(['sub', 'eee.in'], "checked-out sub/eee.in\n") -test.write(['Perforce', 'sub', 'fff.in'], "Perforce/sub/fff.in\n") - -read_str = """\ -%(_python_)s my-p4.py %(sub_SConscript)s -""" % locals() - -build_str = """\ -%(_python_)s my-p4.py aaa.in -cat(["aaa.out"], ["aaa.in"]) -cat(["bbb.out"], ["bbb.in"]) -%(_python_)s my-p4.py ccc.in -cat(["ccc.out"], ["ccc.in"]) -cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) -%(_python_)s my-p4.py %(sub_ddd_in)s -cat(["%(sub_ddd_out)s"], ["%(sub_ddd_in)s"]) -cat(["%(sub_eee_out)s"], ["%(sub_eee_in)s"]) -%(_python_)s my-p4.py %(sub_fff_in)s -cat(["%(sub_fff_out)s"], ["%(sub_fff_in)s"]) -cat(["%(sub_all)s"], ["%(sub_ddd_out)s", "%(sub_eee_out)s", "%(sub_fff_out)s"]) -""" % locals() - -stdout = test.wrap_stdout(read_str = read_str, build_str = build_str) - -test.run(arguments = '.', - stdout = TestSCons.re_escape(stdout), - stderr = warn_p4 + warn_sc) - -test.must_match('all', - "Perforce/aaa.in\nchecked-out bbb.in\nPerforce/ccc.in\n") - -test.must_match(['sub', 'all'], - "Perforce/sub/ddd.in\nchecked-out sub/eee.in\nPerforce/sub/fff.in\n") - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Deprecated/SourceCode/Perforce/P4COMSTR.py b/test/Deprecated/SourceCode/Perforce/P4COMSTR.py deleted file mode 100644 index 7b2fbba..0000000 --- a/test/Deprecated/SourceCode/Perforce/P4COMSTR.py +++ /dev/null @@ -1,142 +0,0 @@ -#!/usr/bin/env python -# -# __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__" - -""" -Test setting the $P4COMSTR variable. -""" - -import os.path - -import TestSCons - -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons() -test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) - -test.write('SConscript', """ -Environment(tools = ['Perforce']).Perforce() -""") - -msg_p4 = """The Perforce() factory is deprecated and there is no replacement.""" -warn_p4 = test.deprecated_fatal('deprecated-build-dir', msg_p4) -msg_sc = """SourceCode() has been deprecated and there is no replacement. -\tIf you need this function, please contact scons-dev@scons.org""" -warn_sc = test.deprecated_wrap(msg_sc) - -test.subdir('Perforce', ['Perforce', 'sub'], 'sub') - -sub_Perforce = os.path.join('sub', 'Perforce') -sub_SConscript = os.path.join('sub', 'SConscript') -sub_all = os.path.join('sub', 'all') -sub_ddd_in = os.path.join('sub', 'ddd.in') -sub_ddd_out = os.path.join('sub', 'ddd.out') -sub_eee_in = os.path.join('sub', 'eee.in') -sub_eee_out = os.path.join('sub', 'eee.out') -sub_fff_in = os.path.join('sub', 'fff.in') -sub_fff_out = os.path.join('sub', 'fff.out') - -test.write('my-p4.py', """ -import shutil -import sys -for f in sys.argv[1:]: - shutil.copy('Perforce/'+f, f) -""") - -test.write('SConstruct', """ -SetOption('warn', 'deprecated-source-code') -def cat(env, source, target): - target = str(target[0]) - f = open(target, "wb") - for src in source: - f.write(open(str(src), "rb").read()) - f.close() -env = Environment(TOOLS = ['default', 'Perforce'], - BUILDERS={'Cat':Builder(action=cat)}, - P4COM=r'%(_python_)s my-p4.py $TARGET', - P4COMSTR='Checking out $TARGET from our fake Perforce') -env.Cat('aaa.out', 'aaa.in') -env.Cat('bbb.out', 'bbb.in') -env.Cat('ccc.out', 'ccc.in') -env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) -env.SourceCode('.', env.Perforce()) -SConscript('sub/SConscript', "env") -""" % locals()) - -test.write(['Perforce', 'sub', 'SConscript'], """\ -Import("env") -env.Cat('ddd.out', 'ddd.in') -env.Cat('eee.out', 'eee.in') -env.Cat('fff.out', 'fff.in') -env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) -""") - -test.write(['Perforce', 'aaa.in'], "Perforce/aaa.in\n") -test.write('bbb.in', "checked-out bbb.in\n") -test.write(['Perforce', 'ccc.in'], "Perforce/ccc.in\n") - -test.write(['Perforce', 'sub', 'ddd.in'], "Perforce/sub/ddd.in\n") -test.write(['sub', 'eee.in'], "checked-out sub/eee.in\n") -test.write(['Perforce', 'sub', 'fff.in'], "Perforce/sub/fff.in\n") - -read_str = """\ -Checking out %(sub_SConscript)s from our fake Perforce -""" % locals() - -build_str = """\ -Checking out aaa.in from our fake Perforce -cat(["aaa.out"], ["aaa.in"]) -cat(["bbb.out"], ["bbb.in"]) -Checking out ccc.in from our fake Perforce -cat(["ccc.out"], ["ccc.in"]) -cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) -Checking out %(sub_ddd_in)s from our fake Perforce -cat(["%(sub_ddd_out)s"], ["%(sub_ddd_in)s"]) -cat(["%(sub_eee_out)s"], ["%(sub_eee_in)s"]) -Checking out %(sub_fff_in)s from our fake Perforce -cat(["%(sub_fff_out)s"], ["%(sub_fff_in)s"]) -cat(["%(sub_all)s"], ["%(sub_ddd_out)s", "%(sub_eee_out)s", "%(sub_fff_out)s"]) -""" % locals() - -stdout = test.wrap_stdout(read_str = read_str, build_str = build_str) - -test.run(arguments = '.', - stdout = TestSCons.re_escape(stdout), - stderr = warn_p4 + warn_sc) - -test.must_match('all', - "Perforce/aaa.in\nchecked-out bbb.in\nPerforce/ccc.in\n") - -test.must_match(['sub', 'all'], - "Perforce/sub/ddd.in\nchecked-out sub/eee.in\nPerforce/sub/fff.in\n") - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Deprecated/SourceCode/Perforce/Perforce.py b/test/Deprecated/SourceCode/Perforce/Perforce.py deleted file mode 100644 index 3be22d8..0000000 --- a/test/Deprecated/SourceCode/Perforce/Perforce.py +++ /dev/null @@ -1,287 +0,0 @@ -#!/usr/bin/env python -# -# __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__" - -""" -Test fetching source files from Perforce. - -This test requires that a Perforce server be running on the test system -on port 1666, as well as that of course a client must be present. -""" - -import os - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConscript', """ -Environment(tools = ['Perforce']).Perforce() -""") - -msg_p4 = """The Perforce() factory is deprecated and there is no replacement.""" -warn_p4 = test.deprecated_fatal('deprecated-build-dir', msg_p4) -msg_sc = """SourceCode() has been deprecated and there is no replacement. -\tIf you need this function, please contact scons-dev@scons.org""" -warn_sc = test.deprecated_wrap(msg_sc) - -class TestPerforce(TestSCons.TestSCons): - def __init__(self, *args, **kw): - TestSCons.TestSCons.__init__(self, *args, **kw) - - self.p4d = None - - self.p4path = self.where_is('p4') - if not self.p4path: - self.skip_test("Could not find 'p4'; skipping test(s).\n") - - #import socket - #self.host = socket.gethostname() - self.host = '127.0.0.1' - - self.user = os.environ.get('USER') - if not self.user: - self.user = os.environ.get('USERNAME') - if not self.user: - self.user = os.environ.get('P4USER') - - self.depot = 'testme' - - self.p4d = self.where_is('p4d') - if self.p4d: - self.p4portflags = ['-p', self.host + ':1777'] - self.subdir('depot', ['depot', 'testme']) - def quote_space(a): - if ' ' in a: - a = '"%s"' % a - return a - args = list(map(quote_space, [self.p4d, '-q', '-d'] + \ - self.p4portflags + \ - ['-J', 'Journal', - '-L', 'Log', - '-r', self.workpath('depot')])) - - # We don't use self.run() because the TestCmd logic will hang - # waiting for the daemon to exit, even when we pass it - # the -d option. - os.spawnv(os.P_NOWAIT, self.p4d, args) - self.sleep(2) - else: - import socket - s = socket.socket() - host_port = (self.host, 1666) - try: - s.connect(host_port) - except socket.error: - self.skip_test("No Perforce server found; skipping test(s).\n") - else: - s.close() - - self.p4portflags = ['-p', '%s:%s' % host_port] - try: - self.p4('obliterate -y //%s/...' % self.depot) - self.p4('depot -d %s' % self.depot) - except TestSCons.TestFailed: - # It's okay if this fails. It will fail if the depot - # is already clear. - pass - - self.portflag = ' '.join(self.p4portflags) - - def p4(self, *args, **kw): - try: - arguments = kw['arguments'] - except KeyError: - arguments = args[0] - args = args[1:] - kw['arguments'] = ' '.join(self.p4portflags + [arguments]) - kw['program'] = self.p4path - return self.run(*args, **kw) - - def substitute(self, s, **kw): - kw = kw.copy() - kw.update(self.__dict__) - return s % kw - - def cleanup(self, condition = None): - if self.p4d: - self.p4('admin stop') - self.p4d = None - - if TestSCons: - TestSCons.TestSCons.cleanup(self, condition) - -test = TestPerforce() - -# Set up a perforce depot for testing. -depotspec = test.substitute("""\ -# A Perforce Depot Specification. -Depot: %(depot)s - -Owner: %(user)s - -Date: 2003/02/19 17:21:41 - -Description: - A test depot. - -Type: local - -Address: subdir - -Map: %(depot)s/... -""") - -test.p4(arguments='depot -i', stdin = depotspec) - -# Now set up 2 clients, one to check in some files, and one to -# do the building. -clientspec = """\ -# A Perforce Client Specification. -Client: %(client)s - -Owner: %(user)s - -Description: - Created by %(user)s. - -Root: %(root)s - -Options: noallwrite noclobber nocompress unlocked nomodtime normdir - -LineEnd: local - -View: - //%(depot)s/%(subdir)s... //%(client)s/... -""" - -clientspec1 = test.substitute(clientspec, - client = 'testclient1', - root = test.workpath('import'), - subdir = 'foo/', - ) - -clientspec2 = test.substitute(clientspec, - client = 'testclient2', - root = test.workpath('work'), - subdir = '', - ) - -test.subdir('import', ['import', 'sub'], 'work') - -test.p4('client -i', stdin=clientspec1) -test.p4('client -i', stdin=clientspec2) - -test.write(['import', 'aaa.in'], "import/aaa.in\n") -test.write(['import', 'bbb.in'], "import/bbb.in\n") -test.write(['import', 'ccc.in'], "import/ccc.in\n") - -test.write(['import', 'sub', 'SConscript'], """ -Import("env") -env.Cat('ddd.out', 'ddd.in') -env.Cat('eee.out', 'eee.in') -env.Cat('fff.out', 'fff.in') -env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) -""") - -test.write(['import', 'sub', 'ddd.in'], "import/sub/ddd.in\n") -test.write(['import', 'sub', 'eee.in'], "import/sub/eee.in\n") -test.write(['import', 'sub', 'fff.in'], "import/sub/fff.in\n") - -# Perforce uses the PWD environment variable in preference to the actual cwd -os.environ["PWD"] = test.workpath('import') -paths = [ 'aaa.in', 'bbb.in', 'ccc.in', - 'sub/ddd.in', 'sub/eee.in', 'sub/fff.in', 'sub/SConscript' ] -paths = list(map(os.path.normpath, paths)) -args = '-c testclient1 add -t binary %s' % ' '.join(paths) -test.p4(args, chdir='import') - -changespec = test.substitute(""" -Change: new - -Client: testclient1 - -User: %(user)s - -Status: new - -Description: - A test check in - -Files: - //%(depot)s/foo/aaa.in # add - //%(depot)s/foo/bbb.in # add - //%(depot)s/foo/ccc.in # add - //%(depot)s/foo/sub/SConscript # add - //%(depot)s/foo/sub/ddd.in # add - //%(depot)s/foo/sub/eee.in # add - //%(depot)s/foo/sub/fff.in # add -""") - -test.p4('-c testclient1 opened') -test.p4('-c testclient1 submit -i', stdin=changespec) - -SConstruct_contents = test.substitute(""" -SetOption('warn', 'deprecated-source-code') -def cat(env, source, target): - target = str(target[0]) - f = open(target, "wb") - for src in source: - f.write(open(str(src), "rb").read()) - f.close() -env = Environment(tools = ['default', 'Perforce'], - BUILDERS={'Cat':Builder(action=cat)}, - P4=r'%(p4path)s', - P4FLAGS='%(portflag)s -c testclient2') -env.Cat('aaa.out', 'foo/aaa.in') -env.Cat('bbb.out', 'foo/bbb.in') -env.Cat('ccc.out', 'foo/ccc.in') -env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) -env.SourceCode('.', env.Perforce()) -SConscript('foo/sub/SConscript', 'env') -""") - -test.write(['work', 'SConstruct'], SConstruct_contents) - -test.subdir(['work', 'foo']) -test.write(['work', 'foo', 'bbb.in'], "work/foo/bbb.in\n") - -test.subdir(['work', 'foo', 'sub']) -test.write(['work', 'foo', 'sub', 'eee.in'], "work/foo/sub/eee.in\n") - -test.run(chdir = 'work', - arguments = '.', - stderr = warn_p4 + warn_sc, - match = TestSCons.match_re_dotall) - -test.fail_test(test.read(['work', 'all']) != "import/aaa.in\nwork/foo/bbb.in\nimport/ccc.in\n") -test.fail_test(test.read(['work', 'foo', 'sub', 'all']) != "import/sub/ddd.in\nwork/foo/sub/eee.in\nimport/sub/fff.in\n") - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: -- cgit v0.12 From 4e8fd3c0fcd3b2ac8d1509cc3fa7395d79ccd49c Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 20 Mar 2017 10:59:26 -0700 Subject: Remove deprecated tool BitKeeper --- src/CHANGES.txt | 4 +- src/engine/SCons/Tool/BitKeeper.py | 66 ---- src/engine/SCons/Tool/BitKeeper.xml | 123 ------- src/engine/SCons/Tool/__init__.py | 2 +- .../SourceCode/BitKeeper/BITKEEPERCOM.py | 140 -------- .../SourceCode/BitKeeper/BITKEEPERCOMSTR.py | 141 -------- test/Deprecated/SourceCode/BitKeeper/BitKeeper.py | 383 --------------------- 7 files changed, 3 insertions(+), 856 deletions(-) delete mode 100644 src/engine/SCons/Tool/BitKeeper.py delete mode 100644 src/engine/SCons/Tool/BitKeeper.xml delete mode 100644 test/Deprecated/SourceCode/BitKeeper/BITKEEPERCOM.py delete mode 100644 test/Deprecated/SourceCode/BitKeeper/BITKEEPERCOMSTR.py delete mode 100644 test/Deprecated/SourceCode/BitKeeper/BitKeeper.py diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 67bd2a3..cc9ab5a 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -30,8 +30,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Fixed SCons.Tool.Packaging.rpm.package source nondeterminism across builds. From William Deegan: - - Removed deprecated source code tool Perforce. - + - Removed deprecated source code tool Perforce, BitKeeper. + From Daniel Moody: - Fixed msvs.py for Visual Studio generated projects which were creating invalid xml for greater than and less than symbols. diff --git a/src/engine/SCons/Tool/BitKeeper.py b/src/engine/SCons/Tool/BitKeeper.py deleted file mode 100644 index 44632d7..0000000 --- a/src/engine/SCons/Tool/BitKeeper.py +++ /dev/null @@ -1,66 +0,0 @@ -"""SCons.Tool.BitKeeper.py - -Tool-specific initialization for the BitKeeper source code control -system. - -There normally shouldn't be any need to import this module directly. -It will usually be imported through the generic SCons.Tool.Tool() -selection method. - -""" - -# -# __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__" - -import SCons.Action -import SCons.Builder -import SCons.Util - -def generate(env): - """Add a Builder factory function and construction variables for - BitKeeper to an Environment.""" - - def BitKeeperFactory(env=env): - """ """ - import SCons.Warnings as W - W.warn(W.DeprecatedSourceCodeWarning, """The BitKeeper() factory is deprecated and there is no replacement.""") - act = SCons.Action.Action("$BITKEEPERCOM", "$BITKEEPERCOMSTR") - return SCons.Builder.Builder(action = act, env = env) - - env.BitKeeper = BitKeeperFactory - - env['BITKEEPER'] = 'bk' - env['BITKEEPERGET'] = '$BITKEEPER get' - env['BITKEEPERGETFLAGS'] = SCons.Util.CLVar('') - env['BITKEEPERCOM'] = '$BITKEEPERGET $BITKEEPERGETFLAGS $TARGET' - -def exists(env): - return env.Detect('bk') - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/src/engine/SCons/Tool/BitKeeper.xml b/src/engine/SCons/Tool/BitKeeper.xml deleted file mode 100644 index 30a5e77..0000000 --- a/src/engine/SCons/Tool/BitKeeper.xml +++ /dev/null @@ -1,123 +0,0 @@ - - - - -%scons; - -%builders-mod; - -%functions-mod; - -%tools-mod; - -%variables-mod; -]> - - - - - - -Sets construction variables for the BitKeeper -source code control system. - - - -BITKEEPER -BITKEEPERGET -BITKEEPERGETFLAGS -BITKEEPERCOM - - -BITKEEPERCOMSTR - - - - - - -The BitKeeper executable. - - - - - - - -The command line for -fetching source files using BitKeeper. - - - - - - - -The string displayed when fetching -a source file using BitKeeper. -If this is not set, then &cv-link-BITKEEPERCOM; -(the command line) is displayed. - - - - - - - -The command (&cv-link-BITKEEPER;) and subcommand -for fetching source files using BitKeeper. - - - - - - - -Options that are passed to the BitKeeper -get -subcommand. - - - - - - -() - - - -A factory function that -returns a Builder object -to be used to fetch source files -using BitKeeper. -The returned Builder -is intended to be passed to the -&f-SourceCode; -function. - - - -This function is deprecated. For details, see the entry for the -&f-SourceCode; -function. - - - -Example: - - - -env.SourceCode('.', env.BitKeeper()) - - - - - diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index 4647587..f95b175 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -1157,7 +1157,7 @@ def tool_list(platform, env): # Archivers 'tar', 'zip', # SourceCode factories - 'BitKeeper', 'CVS', + 'CVS', 'RCS', 'SCCS', # 'Subversion', ], env) diff --git a/test/Deprecated/SourceCode/BitKeeper/BITKEEPERCOM.py b/test/Deprecated/SourceCode/BitKeeper/BITKEEPERCOM.py deleted file mode 100644 index 8ff4ced..0000000 --- a/test/Deprecated/SourceCode/BitKeeper/BITKEEPERCOM.py +++ /dev/null @@ -1,140 +0,0 @@ -#!/usr/bin/env python -# -# __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__" - -""" -Test setting the $BITKEEPERCOM variable. -""" - -import os.path - -import TestSCons - -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) - -test.write('SConscript', """ -Environment(tools = ['BitKeeper']).BitKeeper() -""") - -msg_bk = """The BitKeeper() factory is deprecated and there is no replacement.""" -warn_bk = test.deprecated_fatal('deprecated-build-dir', msg_bk) -msg_sc = """SourceCode() has been deprecated and there is no replacement. -\tIf you need this function, please contact scons-dev@scons.org""" -warn_sc = test.deprecated_wrap(msg_sc) - -test.subdir('BitKeeper', ['BitKeeper', 'sub'], 'sub') - -sub_BitKeeper = os.path.join('sub', 'BitKeeper') -sub_SConscript = os.path.join('sub', 'SConscript') -sub_all = os.path.join('sub', 'all') -sub_ddd_in = os.path.join('sub', 'ddd.in') -sub_ddd_out = os.path.join('sub', 'ddd.out') -sub_eee_in = os.path.join('sub', 'eee.in') -sub_eee_out = os.path.join('sub', 'eee.out') -sub_fff_in = os.path.join('sub', 'fff.in') -sub_fff_out = os.path.join('sub', 'fff.out') - -test.write('my-bk-get.py', """ -import shutil -import sys -for f in sys.argv[1:]: - shutil.copy('BitKeeper/'+f, f) -""") - -test.write('SConstruct', """ -SetOption('warn', 'deprecated-source-code') -def cat(env, source, target): - target = str(target[0]) - f = open(target, "wb") - for src in source: - f.write(open(str(src), "rb").read()) - f.close() -env = Environment(TOOLS = ['default', 'BitKeeper'], - BUILDERS={'Cat':Builder(action=cat)}, - BITKEEPERCOM=r'%(_python_)s my-bk-get.py $TARGET') -env.Cat('aaa.out', 'aaa.in') -env.Cat('bbb.out', 'bbb.in') -env.Cat('ccc.out', 'ccc.in') -env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) -env.SourceCode('.', env.BitKeeper()) -SConscript('sub/SConscript', "env") -""" % locals()) - -test.write(['BitKeeper', 'sub', 'SConscript'], """\ -Import("env") -env.Cat('ddd.out', 'ddd.in') -env.Cat('eee.out', 'eee.in') -env.Cat('fff.out', 'fff.in') -env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) -""") - -test.write(['BitKeeper', 'aaa.in'], "BitKeeper/aaa.in\n") -test.write('bbb.in', "checked-out bbb.in\n") -test.write(['BitKeeper', 'ccc.in'], "BitKeeper/ccc.in\n") - -test.write(['BitKeeper', 'sub', 'ddd.in'], "BitKeeper/sub/ddd.in\n") -test.write(['sub', 'eee.in'], "checked-out sub/eee.in\n") -test.write(['BitKeeper', 'sub', 'fff.in'], "BitKeeper/sub/fff.in\n") - -read_str = """\ -%(_python_)s my-bk-get.py %(sub_SConscript)s -""" % locals() - -build_str = """\ -%(_python_)s my-bk-get.py aaa.in -cat(["aaa.out"], ["aaa.in"]) -cat(["bbb.out"], ["bbb.in"]) -%(_python_)s my-bk-get.py ccc.in -cat(["ccc.out"], ["ccc.in"]) -cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) -%(_python_)s my-bk-get.py %(sub_ddd_in)s -cat(["%(sub_ddd_out)s"], ["%(sub_ddd_in)s"]) -cat(["%(sub_eee_out)s"], ["%(sub_eee_in)s"]) -%(_python_)s my-bk-get.py %(sub_fff_in)s -cat(["%(sub_fff_out)s"], ["%(sub_fff_in)s"]) -cat(["%(sub_all)s"], ["%(sub_ddd_out)s", "%(sub_eee_out)s", "%(sub_fff_out)s"]) -""" % locals() - -stdout = test.wrap_stdout(read_str = read_str, build_str = build_str) - -test.run(arguments = '.', - stdout = TestSCons.re_escape(stdout), - stderr = warn_bk + warn_sc) - -test.must_match('all', - "BitKeeper/aaa.in\nchecked-out bbb.in\nBitKeeper/ccc.in\n") - -test.must_match(['sub', 'all'], - "BitKeeper/sub/ddd.in\nchecked-out sub/eee.in\nBitKeeper/sub/fff.in\n") - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Deprecated/SourceCode/BitKeeper/BITKEEPERCOMSTR.py b/test/Deprecated/SourceCode/BitKeeper/BITKEEPERCOMSTR.py deleted file mode 100644 index 5bbdea2..0000000 --- a/test/Deprecated/SourceCode/BitKeeper/BITKEEPERCOMSTR.py +++ /dev/null @@ -1,141 +0,0 @@ -#!/usr/bin/env python -# -# __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__" - -""" -Test customizing the output with the the $BITKEEPERCOMSTR variable. -""" - -import os.path - -import TestSCons - -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) - -test.write('SConscript', """ -Environment(tools = ['BitKeeper']).BitKeeper() -""") - -msg_bk = """The BitKeeper() factory is deprecated and there is no replacement.""" -warn_bk = test.deprecated_fatal('deprecated-build-dir', msg_bk) -msg_sc = """SourceCode() has been deprecated and there is no replacement. -\tIf you need this function, please contact scons-dev@scons.org""" -warn_sc = test.deprecated_wrap(msg_sc) - -test.subdir('BitKeeper', ['BitKeeper', 'sub'], 'sub') - -sub_BitKeeper = os.path.join('sub', 'BitKeeper') -sub_SConscript = os.path.join('sub', 'SConscript') -sub_all = os.path.join('sub', 'all') -sub_ddd_in = os.path.join('sub', 'ddd.in') -sub_ddd_out = os.path.join('sub', 'ddd.out') -sub_eee_in = os.path.join('sub', 'eee.in') -sub_eee_out = os.path.join('sub', 'eee.out') -sub_fff_in = os.path.join('sub', 'fff.in') -sub_fff_out = os.path.join('sub', 'fff.out') - -test.write('my-bk-get.py', """ -import shutil -import sys -for f in sys.argv[1:]: - shutil.copy('BitKeeper/'+f, f) -""") - -test.write('SConstruct', """ -SetOption('warn', 'deprecated-source-code') -def cat(env, source, target): - target = str(target[0]) - f = open(target, "wb") - for src in source: - f.write(open(str(src), "rb").read()) - f.close() -env = Environment(tools = ['default', 'BitKeeper'], - BUILDERS={'Cat':Builder(action=cat)}, - BITKEEPERCOM=r'%(_python_)s my-bk-get.py $TARGET', - BITKEEPERCOMSTR='Checking out $TARGET from our fake BitKeeper') -env.Cat('aaa.out', 'aaa.in') -env.Cat('bbb.out', 'bbb.in') -env.Cat('ccc.out', 'ccc.in') -env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) -env.SourceCode('.', env.BitKeeper()) -SConscript('sub/SConscript', "env") -""" % locals()) - -test.write(['BitKeeper', 'sub', 'SConscript'], """\ -Import("env") -env.Cat('ddd.out', 'ddd.in') -env.Cat('eee.out', 'eee.in') -env.Cat('fff.out', 'fff.in') -env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) -""") - -test.write(['BitKeeper', 'aaa.in'], "BitKeeper/aaa.in\n") -test.write('bbb.in', "checked-out bbb.in\n") -test.write(['BitKeeper', 'ccc.in'], "BitKeeper/ccc.in\n") - -test.write(['BitKeeper', 'sub', 'ddd.in'], "BitKeeper/sub/ddd.in\n") -test.write(['sub', 'eee.in'], "checked-out sub/eee.in\n") -test.write(['BitKeeper', 'sub', 'fff.in'], "BitKeeper/sub/fff.in\n") - -read_str = """\ -Checking out %(sub_SConscript)s from our fake BitKeeper -""" % locals() - -build_str = """\ -Checking out aaa.in from our fake BitKeeper -cat(["aaa.out"], ["aaa.in"]) -cat(["bbb.out"], ["bbb.in"]) -Checking out ccc.in from our fake BitKeeper -cat(["ccc.out"], ["ccc.in"]) -cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) -Checking out %(sub_ddd_in)s from our fake BitKeeper -cat(["%(sub_ddd_out)s"], ["%(sub_ddd_in)s"]) -cat(["%(sub_eee_out)s"], ["%(sub_eee_in)s"]) -Checking out %(sub_fff_in)s from our fake BitKeeper -cat(["%(sub_fff_out)s"], ["%(sub_fff_in)s"]) -cat(["%(sub_all)s"], ["%(sub_ddd_out)s", "%(sub_eee_out)s", "%(sub_fff_out)s"]) -""" % locals() - -stdout = test.wrap_stdout(read_str = read_str, build_str = build_str) - -test.run(arguments = '.', - stdout = TestSCons.re_escape(stdout), - stderr = warn_bk + warn_sc) - -test.must_match('all', - "BitKeeper/aaa.in\nchecked-out bbb.in\nBitKeeper/ccc.in\n") - -test.must_match(['sub', 'all'], - "BitKeeper/sub/ddd.in\nchecked-out sub/eee.in\nBitKeeper/sub/fff.in\n") - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Deprecated/SourceCode/BitKeeper/BitKeeper.py b/test/Deprecated/SourceCode/BitKeeper/BitKeeper.py deleted file mode 100644 index 04dfd9b..0000000 --- a/test/Deprecated/SourceCode/BitKeeper/BitKeeper.py +++ /dev/null @@ -1,383 +0,0 @@ -#!/usr/bin/env python -# -# __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. -from __future__ import print_function - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -""" -Test fetching source files from BitKeeper. -""" - -import os - -import TestSCons - -test = TestSCons.TestSCons() -test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) - -test.write('SConscript', """ -Environment(tools = ['BitKeeper']).BitKeeper() -""") - -msg_bk = """The BitKeeper() factory is deprecated and there is no replacement.""" -warn_bk = test.deprecated_fatal('deprecated-build-dir', msg_bk) -msg_sc = """SourceCode() has been deprecated and there is no replacement. -\tIf you need this function, please contact scons-dev@scons.org""" -warn_sc = test.deprecated_wrap(msg_sc) - -test.skip_test("Need BitKeeper to debug these tests.\n") - -bk = test.where_is('bk') -if not bk: - test.skip_test("Could not find 'bk'; skipping remaining tests.\n") - -try: - login = os.getlogin() -except (AttributeError, OSError): - try: - login = os.environ['USER'] - except KeyError: - login = 'USER' - -host = os.uname()[1] - -email = "%s@%s" % (login, host) - -test.subdir('BK', 'import', ['import', 'sub']) - -# Test using BitKeeper to fetch from SCCS/s.file files. -sccs = test.where_is('sccs') -if not sccs: - print("Could not find SCCS, skipping sub-test of BitKeeper using SCCS files.") -else: - test.subdir('work1', - ['work1', 'SCCS'], - ['work1', 'sub'], - ['work1', 'sub', 'SCCS']) - - for file in ['aaa.in', 'bbb.in', 'ccc.in']: - test.write(['work1', file], "work1/%s\n" % file) - args = "create %s" % file - test.run(chdir = 'work1', program = sccs, arguments = args, stderr = None) - test.unlink(['work1', file]) - test.unlink(['work1', ','+file]) - - test.write(['work1', 'sub', 'SConscript'], """if True: - Import("env") - env.Cat('ddd.out', 'ddd.in') - env.Cat('eee.out', 'eee.in') - env.Cat('fff.out', 'fff.in') - env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) - """) - args = "create SConscript" - test.run(chdir = 'work1/sub', program = sccs, arguments = args, stderr = None) - test.unlink(['work1', 'sub', 'SConscript']) - test.unlink(['work1', 'sub', ',SConscript']) - - for file in ['ddd.in', 'eee.in', 'fff.in']: - test.write(['work1', 'sub', file], "work1/sub/%s\n" % file) - args = "create %s" % file - test.run(chdir = 'work1/sub', program = sccs, arguments = args, stderr = None) - test.unlink(['work1', 'sub', file]) - test.unlink(['work1', 'sub', ','+file]) - - test.write(['work1', 'SConstruct'], """if True: - SetOption('warn', 'deprecated-source-code') - def cat(env, source, target): - target = str(target[0]) - f = open(target, "wb") - for src in source: - f.write(open(str(src), "rb").read()) - f.close() - env = Environment(BUILDERS={'Cat':Builder(action=cat)}, - BITKEEPERGETFLAGS='-e') - env.Cat('aaa.out', 'aaa.in') - env.Cat('bbb.out', 'bbb.in') - env.Cat('ccc.out', 'ccc.in') - env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) - env.SourceCode('.', env.BitKeeper()) - SConscript('sub/SConscript', "env") - """) - - test.write(['work1', 'bbb.in'], "checked-out work1/bbb.in\n") - - test.write(['work1', 'sub', 'eee.in'], "checked-out work1/sub/eee.in\n") - - read_str = """\ -bk get -e sub/SConscript -""" - - build_str = """\ -bk get -e aaa.in -cat(["aaa.out"], ["aaa.in"]) -cat(["bbb.out"], ["bbb.in"]) -bk get -e ccc.in -cat(["ccc.out"], ["ccc.in"]) -cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) -bk get -e sub/ddd.in -cat(["sub/ddd.out"], ["sub/ddd.in"]) -cat(["sub/eee.out"], ["sub/eee.in"]) -bk get -e sub/fff.in -cat(["sub/fff.out"], ["sub/fff.in"]) -cat(["sub/all"], ["sub/ddd.out", "sub/eee.out", "sub/fff.out"]) -""" - - stdout = test.wrap_stdout(read_str = read_str, build_str = build_str) - - stderr = """\ -sub/SConscript 1.1 -> 1.2: 5 lines -aaa.in 1.1 -> 1.2: 1 lines -ccc.in 1.1 -> 1.2: 1 lines -sub/ddd.in 1.1 -> 1.2: 1 lines -sub/fff.in 1.1 -> 1.2: 1 lines -""" - - test.run(arguments = '.', - stdout = TestSCons.re_escape(stdout), - stderr = warn_bk + warn_sc + TestSCons.re_escape(stderr)) - - test.must_match(['work1', 'all'], "work1/aaa.in\nchecked-out work1/bbb.in\nwork1/ccc.in\n") - - test.must_be_writable(test.workpath('work1', 'sub', 'SConscript')) - test.must_be_writable(test.workpath('work1', 'aaa.in')) - test.must_be_writable(test.workpath('work1', 'ccc.in')) - test.must_be_writable(test.workpath('work1', 'sub', 'ddd.in')) - test.must_be_writable(test.workpath('work1', 'sub', 'fff.in')) - -# Test using BitKeeper to fetch from RCS/file,v files. -rcs = test.where_is('rcs') -ci = test.where_is('ci') -if not rcs: - print("Could not find RCS,\nskipping sub-test of BitKeeper using RCS files.") -elif not ci: - print("Could not find the RCS ci command,\nskipping sub-test of BitKeeper using RCS files.") -else: - test.subdir('work2', - ['work2', 'RCS'], - ['work2', 'sub'], - ['work2', 'sub', 'RCS']) - - for file in ['aaa.in', 'bbb.in', 'ccc.in']: - test.write(['work2', file], "work2/%s\n" % file) - args = "-f -t%s %s" % (file, file) - test.run(chdir = 'work2', program = ci, arguments = args, stderr = None) - - test.write(['work2', 'sub', 'SConscript'], """\ -Import("env") -env.Cat('ddd.out', 'ddd.in') -env.Cat('eee.out', 'eee.in') -env.Cat('fff.out', 'fff.in') -env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) -""") - args = "-f -tsub/SConscript sub/SConscript" - test.run(chdir = 'work2', program = ci, arguments = args, stderr = None) - - for file in ['ddd.in', 'eee.in', 'fff.in']: - test.write(['work2', 'sub', file], "work2/sub/%s\n" % file) - args = "-f -tsub/%s sub/%s" % (file, file) - test.run(chdir = 'work2', program = ci, arguments = args, stderr = None) - - test.no_result(os.path.exists(test.workpath('work2', 'aaa.in'))) - test.no_result(os.path.exists(test.workpath('work2', 'bbb.in'))) - test.no_result(os.path.exists(test.workpath('work2', 'ccc.in'))) - - test.no_result(os.path.exists(test.workpath('work2', 'sub', 'SConscript'))) - - test.no_result(os.path.exists(test.workpath('work2', 'sub', 'ddd.in'))) - test.no_result(os.path.exists(test.workpath('work2', 'sub', 'eee.in'))) - test.no_result(os.path.exists(test.workpath('work2', 'sub', 'fff.in'))) - - test.write(['work2', 'SConstruct'], """if True: - SetOption('warn', 'deprecated-source-code') - def cat(env, source, target): - target = str(target[0]) - f = open(target, "wb") - for src in source: - f.write(open(str(src), "rb").read()) - f.close() - env = Environment(BUILDERS={'Cat':Builder(action=cat)}, - BITKEEPERGET='$BITKEEPER co', - BITKEEPERGETFLAGS='-q') - env.Cat('aaa.out', 'aaa.in') - env.Cat('bbb.out', 'bbb.in') - env.Cat('ccc.out', 'ccc.in') - env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) - env.SourceCode('.', env.BitKeeper()) - SConscript('sub/SConscript', "env") - """) - - test.write(['work2', 'bbb.in'], "checked-out work2/bbb.in\n") - - test.write(['work2', 'sub', 'eee.in'], "checked-out work2/sub/eee.in\n") - - read_str = """\ -bk co -q sub/SConscript -""" - - build_str = """\ -bk co -q aaa.in -cat(["aaa.out"], ["aaa.in"]) -cat(["bbb.out"], ["bbb.in"]) -bk co -q ccc.in -cat(["ccc.out"], ["ccc.in"]) -cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) -bk co -q sub/ddd.in -cat(["sub/ddd.out"], ["sub/ddd.in"]) -cat(["sub/eee.out"], ["sub/eee.in"]) -bk co -q sub/fff.in -cat(["sub/fff.out"], ["sub/fff.in"]) -cat(["sub/all"], ["sub/ddd.out", "sub/eee.out", "sub/fff.out"]) -""" - - stdout = test.wrap_stdout(read_str = read_str, build_str = build_str) - - test.run(arguments = '.', - stdout = TestSCons.re_escape(stdout), - stderr = warn_bk + warn_sc) - - test.must_match(['work2', 'all'], "work2/aaa.in\nchecked-out work2/bbb.in\nwork2/ccc.in\n") - - test.must_match(['work2', 'sub', 'all'], "work2/sub/ddd.in\nchecked-out work2/sub/eee.in\nwork2/sub/fff.in\n") - - test.must_not_be_writable(test.workpath('work2', 'sub', 'SConscript')) - test.must_not_be_writable(test.workpath('work2', 'aaa.in')) - test.must_not_be_writable(test.workpath('work2', 'ccc.in')) - test.must_not_be_writable(test.workpath('work2', 'sub', 'ddd.in')) - test.must_not_be_writable(test.workpath('work2', 'sub', 'fff.in')) - -# Set up a "pure" BitKeeper hierarchy. -# BitKeeper's licensing restrictions require a configuration file that -# specifies you're not using it multi-user. This seems to be the -# minimal configuration that satisfies these requirements. -test.write('bk.conf', """\ -description:test project 'foo' -logging:none -email:%s -single_user:%s -single_host:%s -""" % (email, login, host)) - -# Plus, we need to set the external environment variable that gets it to -# shut up and not prompt us to accept the license. -os.environ['BK_LICENSE'] = 'ACCEPTED' - -test.write(['import', 'aaa.in'], "import/aaa.in\n") -test.write(['import', 'bbb.in'], "import/bbb.in\n") -test.write(['import', 'ccc.in'], "import/ccc.in\n") - -test.write(['import', 'sub', 'SConscript'], """\ -Import("env") -env.Cat('ddd.out', 'ddd.in') -env.Cat('eee.out', 'eee.in') -env.Cat('fff.out', 'fff.in') -env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) -""") - -test.write(['import', 'sub', 'ddd.in'], "import/sub/ddd.in\n") -test.write(['import', 'sub', 'eee.in'], "import/sub/eee.in\n") -test.write(['import', 'sub', 'fff.in'], "import/sub/fff.in\n") - -# Test transparent source file checkouts using BitKeeper, by overriding -# the 'SCCS' construction variable in the default Environment. -work3 = test.workpath('work3') - -test.run(program = bk, - arguments = 'setup -f -c bk.conf work3') - -test.run(chdir = 'import', - program = bk, - arguments = 'import -q -f -tplain . %s' % test.workpath('work3')) - -test.write(['work3', 'SConstruct'], """ -SetOption('warn', 'deprecated-source-code') -def cat(env, source, target): - target = str(target[0]) - f = open(target, "wb") - for src in source: - f.write(open(str(src), "rb").read()) - f.close() -DefaultEnvironment(tools=['SCCS'])['SCCS'] = r'%s' -env = Environment(BUILDERS={'Cat':Builder(action=cat)}) -env.Cat('aaa.out', 'aaa.in') -env.Cat('bbb.out', 'bbb.in') -env.Cat('ccc.out', 'ccc.in') -env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) -SConscript('sub/SConscript', "env") -""" % bk) - -test.write(['work3', 'bbb.in'], "work3/bbb.in\n") - -test.subdir(['work3', 'sub']) -test.write(['work3', 'sub', 'eee.in'], "work3/sub/eee.in\n") - -read_str = """\ -%s get sub/SConscript -""" % bk - -build_str = """\ -%s get aaa.in -cat(["aaa.out"], ["aaa.in"]) -cat(["bbb.out"], ["bbb.in"]) -%s get ccc.in -cat(["ccc.out"], ["ccc.in"]) -cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) -%s get sub/ddd.in -cat(["sub/ddd.out"], ["sub/ddd.in"]) -cat(["sub/eee.out"], ["sub/eee.in"]) -%s get sub/fff.in -cat(["sub/fff.out"], ["sub/fff.in"]) -cat(["sub/all"], ["sub/ddd.out", "sub/eee.out", "sub/fff.out"]) -""" % (bk, bk, bk, bk) - -stdout = test.wrap_stdout(read_str = read_str, build_str = build_str) - -stderr = """\ -sub/SConscript 1.1: 5 lines -aaa.in 1.1: 1 lines -ccc.in 1.1: 1 lines -sub/ddd.in 1.1: 1 lines -sub/fff.in 1.1: 1 lines -""" - -test.run(chdir = 'work3', - arguments = '.', - stdout = TestSCons.re_escape(stdout), - stderr = TestSCons.re_escape(stderr)) - -test.must_match(['work3', 'all'], "import/aaa.in\nwork3/bbb.in\nimport/ccc.in\n") - -test.must_match(['work3', 'sub', 'all'], "import/sub/ddd.in\nwork3/sub/eee.in\nimport/sub/fff.in\n") - -test.must_not_be_writable(test.workpath('work3', 'sub', 'SConscript')) -test.must_not_be_writable(test.workpath('work3', 'aaa.in')) -test.must_not_be_writable(test.workpath('work3', 'ccc.in')) -test.must_not_be_writable(test.workpath('work3', 'sub', 'ddd.in')) -test.must_not_be_writable(test.workpath('work3', 'sub', 'fff.in')) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: -- cgit v0.12 From 3c0bddee1480d3d07f2f48dd11320f5bc72ac963 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 20 Mar 2017 11:00:11 -0700 Subject: Remove deprecated tool CVS --- src/CHANGES.txt | 2 +- src/engine/SCons/Tool/CVS.py | 72 ------ src/engine/SCons/Tool/CVS.xml | 159 ------------- test/Deprecated/SourceCode/CVS/CVS.py | 332 ---------------------------- test/Deprecated/SourceCode/CVS/CVSCOM.py | 140 ------------ test/Deprecated/SourceCode/CVS/CVSCOMSTR.py | 141 ------------ 6 files changed, 1 insertion(+), 845 deletions(-) delete mode 100644 src/engine/SCons/Tool/CVS.py delete mode 100644 src/engine/SCons/Tool/CVS.xml delete mode 100644 test/Deprecated/SourceCode/CVS/CVS.py delete mode 100644 test/Deprecated/SourceCode/CVS/CVSCOM.py delete mode 100644 test/Deprecated/SourceCode/CVS/CVSCOMSTR.py diff --git a/src/CHANGES.txt b/src/CHANGES.txt index cc9ab5a..7c07ca7 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -30,7 +30,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Fixed SCons.Tool.Packaging.rpm.package source nondeterminism across builds. From William Deegan: - - Removed deprecated source code tool Perforce, BitKeeper. + - Removed deprecated source code tool CVS, Perforce, BitKeeper. From Daniel Moody: - Fixed msvs.py for Visual Studio generated projects which were diff --git a/src/engine/SCons/Tool/CVS.py b/src/engine/SCons/Tool/CVS.py deleted file mode 100644 index 08cf04c..0000000 --- a/src/engine/SCons/Tool/CVS.py +++ /dev/null @@ -1,72 +0,0 @@ -"""SCons.Tool.CVS.py - -Tool-specific initialization for CVS. - -There normally shouldn't be any need to import this module directly. -It will usually be imported through the generic SCons.Tool.Tool() -selection method. - -""" - -# __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__" - -import SCons.Action -import SCons.Builder -import SCons.Util - -def generate(env): - """Add a Builder factory function and construction variables for - CVS to an Environment.""" - - def CVSFactory(repos, module='', env=env): - """ """ - import SCons.Warnings as W - W.warn(W.DeprecatedSourceCodeWarning, """The CVS() factory is deprecated and there is no replacement.""") - # fail if repos is not an absolute path name? - if module != '': - # Don't use os.path.join() because the name we fetch might - # be across a network and must use POSIX slashes as separators. - module = module + '/' - env['CVSCOM'] = '$CVS $CVSFLAGS co $CVSCOFLAGS -d ${TARGET.dir} $CVSMODULE${TARGET.posix}' - act = SCons.Action.Action('$CVSCOM', '$CVSCOMSTR') - return SCons.Builder.Builder(action = act, - env = env, - CVSREPOSITORY = repos, - CVSMODULE = module) - - env.CVS = CVSFactory - - env['CVS'] = 'cvs' - env['CVSFLAGS'] = SCons.Util.CLVar('-d $CVSREPOSITORY') - env['CVSCOFLAGS'] = SCons.Util.CLVar('') - env['CVSCOM'] = '$CVS $CVSFLAGS co $CVSCOFLAGS ${TARGET.posix}' - -def exists(env): - return env.Detect('cvs') - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/src/engine/SCons/Tool/CVS.xml b/src/engine/SCons/Tool/CVS.xml deleted file mode 100644 index 1e695c5..0000000 --- a/src/engine/SCons/Tool/CVS.xml +++ /dev/null @@ -1,159 +0,0 @@ - - - - -%scons; - -%builders-mod; - -%functions-mod; - -%tools-mod; - -%variables-mod; -]> - - - - - - -Sets construction variables for the CVS source code -management system. - - - -CVS -CVSCOM -CVSFLAGS -CVSCOFLAGS - - -CVSCOMSTR - - - - - - -The CVS executable. - - - - - - - -Options that are passed to the CVS checkout subcommand. - - - - - - - -The command line used to -fetch source files from a CVS repository. - - - - - - - -The string displayed when fetching -a source file from a CVS repository. -If this is not set, then &cv-link-CVSCOM; -(the command line) is displayed. - - - - - - - -General options that are passed to CVS. -By default, this is set to --d $CVSREPOSITORY -to specify from where the files must be fetched. - - - - - - - -The path to the CVS repository. -This is referenced in the default -&cv-link-CVSFLAGS; value. - - - - - - -(repository, module) - - - -A factory function that -returns a Builder object -to be used to fetch source files -from the specified -CVS -repository. -The returned Builder -is intended to be passed to the -&f-link-SourceCode; -function. - - - -This function is deprecated. For details, see the entry for the -&f-SourceCode; -function. - - - -The optional specified -module -will be added to the beginning -of all repository path names; -this can be used, in essence, -to strip initial directory names -from the repository path names, -so that you only have to -replicate part of the repository -directory hierarchy in your -local build directory. - - - -Examples: - - - -# Will fetch foo/bar/src.c -# from /usr/local/CVSROOT/foo/bar/src.c. -env.SourceCode('.', env.CVS('/usr/local/CVSROOT')) - -# Will fetch bar/src.c -# from /usr/local/CVSROOT/foo/bar/src.c. -env.SourceCode('.', env.CVS('/usr/local/CVSROOT', 'foo')) - -# Will fetch src.c -# from /usr/local/CVSROOT/foo/bar/src.c. -env.SourceCode('.', env.CVS('/usr/local/CVSROOT', 'foo/bar')) - - - - - diff --git a/test/Deprecated/SourceCode/CVS/CVS.py b/test/Deprecated/SourceCode/CVS/CVS.py deleted file mode 100644 index a1276fe..0000000 --- a/test/Deprecated/SourceCode/CVS/CVS.py +++ /dev/null @@ -1,332 +0,0 @@ -#!/usr/bin/env python -# -# __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__" - -""" -Test fetching source files from CVS. -""" - -import os - -import TestSCons - -test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) - -test.write('SConscript', """ -Environment(tools = ['CVS']).CVS('') -""") - -msg_cvs = """The CVS() factory is deprecated and there is no replacement.""" -warn_cvs = test.deprecated_fatal('deprecated-build-dir', msg_cvs) -msg_sc = """SourceCode() has been deprecated and there is no replacement. -\tIf you need this function, please contact scons-dev@scons.org""" -warn_sc = test.deprecated_wrap(msg_sc) - -cvs = test.where_is('cvs') -if not cvs: - test.skip_test("Could not find 'cvs'; skipping remaining tests.\n") - -test.subdir('CVS', 'import', ['import', 'sub'], 'work1', 'work2') - -foo_aaa_in = os.path.join('foo', 'aaa.in') -foo_bbb_in = os.path.join('foo', 'bbb.in') -foo_ccc_in = os.path.join('foo', 'ccc.in') -foo_sub_ddd_in = os.path.join('foo', 'sub', 'ddd.in') -foo_sub_ddd_out = os.path.join('foo', 'sub', 'ddd.out') -foo_sub_eee_in = os.path.join('foo', 'sub', 'eee.in') -foo_sub_eee_out = os.path.join('foo', 'sub', 'eee.out') -foo_sub_fff_in = os.path.join('foo', 'sub', 'fff.in') -foo_sub_fff_out = os.path.join('foo', 'sub', 'fff.out') -foo_sub_all = os.path.join('foo', 'sub', 'all') - -sub_SConscript = os.path.join('sub', 'SConscript') -sub_ddd_in = os.path.join('sub', 'ddd.in') -sub_ddd_out = os.path.join('sub', 'ddd.out') -sub_eee_in = os.path.join('sub', 'eee.in') -sub_eee_out = os.path.join('sub', 'eee.out') -sub_fff_in = os.path.join('sub', 'fff.in') -sub_fff_out = os.path.join('sub', 'fff.out') -sub_all = os.path.join('sub', 'all') - -# Set up the CVS repository. -cvsroot = test.workpath('CVS') - -os.environ['CVSROOT'] = cvsroot -test.run(program = cvs, arguments = 'init') - -test.write(['import', 'aaa.in'], "import/aaa.in\n") -test.write(['import', 'bbb.in'], "import/bbb.in\n") -test.write(['import', 'ccc.in'], "import/ccc.in\n") - -test.write(['import', 'sub', 'SConscript'], """\ -Import("env") -env.Cat('ddd.out', 'ddd.in') -env.Cat('eee.out', 'eee.in') -env.Cat('fff.out', 'fff.in') -env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) -""") - -test.write(['import', 'sub', 'ddd.in'], "import/sub/ddd.in\n") -test.write(['import', 'sub', 'eee.in'], "import/sub/eee.in\n") -test.write(['import', 'sub', 'fff.in'], "import/sub/fff.in\n") - -test.run(chdir = 'import', - program = cvs, - arguments = '-q import -m import foo v v-r') - -# Test the most straightforward CVS checkouts, using the module name. -test.write(['work1', 'SConstruct'], """ -SetOption('warn', 'deprecated-source-code') -import os -def cat(env, source, target): - target = str(target[0]) - f = open(target, "wb") - for src in source: - f.write(open(str(src), "rb").read()) - f.close() -env = Environment(ENV = { 'PATH' : os.environ['PATH'], - 'EDITOR' : os.environ.get('EDITOR', 'ed') }, - BUILDERS={'Cat':Builder(action=cat)}) -env.Prepend(CVSFLAGS='-Q') -env.Cat('aaa.out', 'foo/aaa.in') -env.Cat('bbb.out', 'foo/bbb.in') -env.Cat('ccc.out', 'foo/ccc.in') -env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) -env.SourceCode('.', env.CVS(r'%(cvsroot)s')) -SConscript('foo/sub/SConscript', "env") -""" % locals()) - -test.subdir(['work1', 'foo']) -test.write(['work1', 'foo', 'bbb.in'], "work1/foo/bbb.in\n") - -test.subdir(['work1', 'foo', 'sub',]) -test.write(['work1', 'foo', 'sub', 'eee.in'], "work1/foo/sub/eee.in\n") - -read_str = """\ -cvs -Q -d %(cvsroot)s co foo/sub/SConscript -""" % locals() - -build_str = """\ -cvs -Q -d %(cvsroot)s co foo/aaa.in -cat(["aaa.out"], ["%(foo_aaa_in)s"]) -cat(["bbb.out"], ["%(foo_bbb_in)s"]) -cvs -Q -d %(cvsroot)s co foo/ccc.in -cat(["ccc.out"], ["%(foo_ccc_in)s"]) -cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) -cvs -Q -d %(cvsroot)s co foo/sub/ddd.in -cat(["%(foo_sub_ddd_out)s"], ["%(foo_sub_ddd_in)s"]) -cat(["%(foo_sub_eee_out)s"], ["%(foo_sub_eee_in)s"]) -cvs -Q -d %(cvsroot)s co foo/sub/fff.in -cat(["%(foo_sub_fff_out)s"], ["%(foo_sub_fff_in)s"]) -cat(["%(foo_sub_all)s"], ["%(foo_sub_ddd_out)s", "%(foo_sub_eee_out)s", "%(foo_sub_fff_out)s"]) -""" % locals() - -stdout = test.wrap_stdout(read_str = read_str, build_str = build_str) - -test.run(chdir = 'work1', - arguments = '.', - stdout = TestSCons.re_escape(stdout), - stderr = warn_cvs + warn_sc) - -# Checking things back out of CVS apparently messes with the line -# endings, so read the result files in non-binary mode. - -test.must_match(['work1', 'all'], - "import/aaa.in\nwork1/foo/bbb.in\nimport/ccc.in\n", - mode='r') - -test.must_match(['work1', 'foo', 'sub', 'all'], - "import/sub/ddd.in\nwork1/foo/sub/eee.in\nimport/sub/fff.in\n", - mode='r') - -test.must_be_writable(test.workpath('work1', 'foo', 'sub', 'SConscript')) -test.must_be_writable(test.workpath('work1', 'foo', 'aaa.in')) -test.must_be_writable(test.workpath('work1', 'foo', 'ccc.in')) -test.must_be_writable(test.workpath('work1', 'foo', 'sub', 'ddd.in')) -test.must_be_writable(test.workpath('work1', 'foo', 'sub', 'fff.in')) - -# Test CVS checkouts when the module name is specified. -test.write(['work2', 'SConstruct'], """ -SetOption('warn', 'deprecated-source-code') -import os -def cat(env, source, target): - target = str(target[0]) - f = open(target, "wb") - for src in source: - f.write(open(str(src), "rb").read()) - f.close() -env = Environment(ENV = { 'PATH' : os.environ['PATH'], - 'EDITOR' : os.environ.get('EDITOR', 'ed') }, - BUILDERS={'Cat':Builder(action=cat)}) -env.Prepend(CVSFLAGS='-q') -env.Cat('aaa.out', 'aaa.in') -env.Cat('bbb.out', 'bbb.in') -env.Cat('ccc.out', 'ccc.in') -env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) -env.SourceCode('.', env.CVS(r'%(cvsroot)s', 'foo')) -SConscript('sub/SConscript', "env") -""" % locals()) - -test.write(['work2', 'bbb.in'], "work2/bbb.in\n") - -test.subdir(['work2', 'sub']) -test.write(['work2', 'sub', 'eee.in'], "work2/sub/eee.in\n") - -read_str = """\ -cvs -q -d %(cvsroot)s co -d sub foo/sub/SConscript -U sub/SConscript -""" % locals() - -build_str = """\ -cvs -q -d %(cvsroot)s co -d . foo/aaa.in -U ./aaa.in -cat(["aaa.out"], ["aaa.in"]) -cat(["bbb.out"], ["bbb.in"]) -cvs -q -d %(cvsroot)s co -d . foo/ccc.in -U ./ccc.in -cat(["ccc.out"], ["ccc.in"]) -cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) -cvs -q -d %(cvsroot)s co -d sub foo/sub/ddd.in -U sub/ddd.in -cat(["%(sub_ddd_out)s"], ["%(sub_ddd_in)s"]) -cat(["%(sub_eee_out)s"], ["%(sub_eee_in)s"]) -cvs -q -d %(cvsroot)s co -d sub foo/sub/fff.in -U sub/fff.in -cat(["%(sub_fff_out)s"], ["%(sub_fff_in)s"]) -cat(["%(sub_all)s"], ["%(sub_ddd_out)s", "%(sub_eee_out)s", "%(sub_fff_out)s"]) -""" % locals() - -stdout = test.wrap_stdout(read_str = read_str, build_str = build_str) - -test.run(chdir = 'work2', - arguments = '.', - stdout = TestSCons.re_escape(stdout), - stderr = warn_cvs + warn_sc) - -# Checking things back out of CVS apparently messes with the line -# endings, so read the result files in non-binary mode. - -test.must_match(['work2', 'all'], - "import/aaa.in\nwork2/bbb.in\nimport/ccc.in\n", - mode='r') - -test.must_match(['work2', 'sub', 'all'], - "import/sub/ddd.in\nwork2/sub/eee.in\nimport/sub/fff.in\n", - mode='r') - -test.must_be_writable(test.workpath('work2', 'sub', 'SConscript')) -test.must_be_writable(test.workpath('work2', 'aaa.in')) -test.must_be_writable(test.workpath('work2', 'ccc.in')) -test.must_be_writable(test.workpath('work2', 'sub', 'ddd.in')) -test.must_be_writable(test.workpath('work2', 'sub', 'fff.in')) - -# Test checking out specific file name(s), and expanding -# the repository name with a variable. -test.subdir(['work3']) - -test.write(['work3', 'SConstruct'], """\ -SetOption('warn', 'deprecated-source-code') -import os -def cat(env, source, target): - target = str(target[0]) - f = open(target, "wb") - for src in source: - f.write(open(str(src), "rb").read()) - f.close() -env = Environment(ENV = { 'PATH' : os.environ['PATH'], - 'EDITOR' : os.environ.get('EDITOR', 'ed') }, - BUILDERS={'Cat':Builder(action=cat)}, - CVSROOT=r'%s') -env.Prepend(CVSFLAGS='-q') -env.Cat('aaa.out', 'aaa.in') -env.Cat('bbb.out', 'bbb.in') -env.Cat('ccc.out', 'ccc.in') -env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) -cvs = env.CVS('$CVSROOT', 'foo') -env.SourceCode('aaa.in', cvs) -env.SourceCode('bbb.in', cvs) -env.SourceCode('ccc.in', cvs) -""" % cvsroot) - -build_str = """\ -cvs -q -d %(cvsroot)s co -d . foo/aaa.in -U ./aaa.in -cat(["aaa.out"], ["aaa.in"]) -cvs -q -d %(cvsroot)s co -d . foo/bbb.in -U ./bbb.in -cat(["bbb.out"], ["bbb.in"]) -cvs -q -d %(cvsroot)s co -d . foo/ccc.in -U ./ccc.in -cat(["ccc.out"], ["ccc.in"]) -cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) -""" % locals() - -stdout = test.wrap_stdout(build_str = build_str) - -test.run(chdir = 'work3', - arguments = '.', - stdout = TestSCons.re_escape(stdout), - stderr = warn_cvs + 3*warn_sc) - -test.must_match(['work3', 'aaa.out'], - "import/aaa.in\n", - mode='r') -test.must_match(['work3', 'bbb.out'], - "import/bbb.in\n", - mode='r') -test.must_match(['work3', 'ccc.out'], - "import/ccc.in\n", - mode='r') -test.must_match(['work3', 'all'], - "import/aaa.in\nimport/bbb.in\nimport/ccc.in\n", - mode='r') - -# Test CVS checkouts from a remote server (Tigris.org). -#test.subdir(['work4']) -# -#test.write(['work4', 'SConstruct'], """\ -#SetOption('warn', 'deprecated-source-code') -#import os -#env = Environment(ENV = { 'PATH' : os.environ['PATH'] }) -## We used to use the SourceForge server, but SourceForge has restrictions -## that make them deny access on occasion. Leave the incantation here -## in case we need to use it again some day. -##cvs = env.CVS(':pserver:anonymous@cvs.sourceforge.net:/cvsroot/scons') -#cvs = env.CVS(':pserver:anoncvs@cvs.tigris.org:/cvs') -#env.SourceCode('.', cvs) -#env.Install('install', 'scons/SConstruct') -#""") -# -#test.run(chdir = 'work4', arguments = '.') -# -#test.must_exist(test.workpath('work4', 'install', 'SConstruct')) - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Deprecated/SourceCode/CVS/CVSCOM.py b/test/Deprecated/SourceCode/CVS/CVSCOM.py deleted file mode 100644 index f3bd29d..0000000 --- a/test/Deprecated/SourceCode/CVS/CVSCOM.py +++ /dev/null @@ -1,140 +0,0 @@ -#!/usr/bin/env python -# -# __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__" - -""" -Test setting the $CVSCOM variable. -""" - -import os.path - -import TestSCons - -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) - -test.write('SConscript', """ -Environment(tools = ['CVS']).CVS('') -""") - -msg_cvs = """The CVS() factory is deprecated and there is no replacement.""" -warn_cvs = test.deprecated_fatal('deprecated-build-dir', msg_cvs) -msg_sc = """SourceCode() has been deprecated and there is no replacement. -\tIf you need this function, please contact scons-dev@scons.org""" -warn_sc = test.deprecated_wrap(msg_sc) - -test.subdir('CVS', ['CVS', 'sub'], 'sub') - -sub_CVS = os.path.join('sub', 'CVS') -sub_SConscript = os.path.join('sub', 'SConscript') -sub_all = os.path.join('sub', 'all') -sub_ddd_in = os.path.join('sub', 'ddd.in') -sub_ddd_out = os.path.join('sub', 'ddd.out') -sub_eee_in = os.path.join('sub', 'eee.in') -sub_eee_out = os.path.join('sub', 'eee.out') -sub_fff_in = os.path.join('sub', 'fff.in') -sub_fff_out = os.path.join('sub', 'fff.out') - -test.write('my-cvs-co-.py', """ -import shutil -import sys -for f in sys.argv[1:]: - shutil.copy('CVS/'+f, f) -""") - -test.write('SConstruct', """ -SetOption('warn', 'deprecated-source-code') -def cat(env, source, target): - target = str(target[0]) - f = open(target, "wb") - for src in source: - f.write(open(str(src), "rb").read()) - f.close() -env = Environment(TOOLS = ['default', 'CVS'], - BUILDERS={'Cat':Builder(action=cat)}, - CVSCOM=r'%(_python_)s my-cvs-co-.py $TARGET') -env.Cat('aaa.out', 'aaa.in') -env.Cat('bbb.out', 'bbb.in') -env.Cat('ccc.out', 'ccc.in') -env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) -env.SourceCode('.', env.CVS(None)) -SConscript('sub/SConscript', "env") -""" % locals()) - -test.write(['CVS', 'sub', 'SConscript'], """\ -Import("env") -env.Cat('ddd.out', 'ddd.in') -env.Cat('eee.out', 'eee.in') -env.Cat('fff.out', 'fff.in') -env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) -""") - -test.write(['CVS', 'aaa.in'], "CVS/aaa.in\n") -test.write('bbb.in', "checked-out bbb.in\n") -test.write(['CVS', 'ccc.in'], "CVS/ccc.in\n") - -test.write(['CVS', 'sub', 'ddd.in'], "CVS/sub/ddd.in\n") -test.write(['sub', 'eee.in'], "checked-out sub/eee.in\n") -test.write(['CVS', 'sub', 'fff.in'], "CVS/sub/fff.in\n") - -read_str = """\ -%(_python_)s my-cvs-co-.py %(sub_SConscript)s -""" % locals() - -build_str = """\ -%(_python_)s my-cvs-co-.py aaa.in -cat(["aaa.out"], ["aaa.in"]) -cat(["bbb.out"], ["bbb.in"]) -%(_python_)s my-cvs-co-.py ccc.in -cat(["ccc.out"], ["ccc.in"]) -cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) -%(_python_)s my-cvs-co-.py %(sub_ddd_in)s -cat(["%(sub_ddd_out)s"], ["%(sub_ddd_in)s"]) -cat(["%(sub_eee_out)s"], ["%(sub_eee_in)s"]) -%(_python_)s my-cvs-co-.py %(sub_fff_in)s -cat(["%(sub_fff_out)s"], ["%(sub_fff_in)s"]) -cat(["%(sub_all)s"], ["%(sub_ddd_out)s", "%(sub_eee_out)s", "%(sub_fff_out)s"]) -""" % locals() - -stdout = test.wrap_stdout(read_str = read_str, build_str = build_str) - -test.run(arguments = '.', - stdout = TestSCons.re_escape(stdout), - stderr = warn_cvs + warn_sc) - -test.must_match('all', - "CVS/aaa.in\nchecked-out bbb.in\nCVS/ccc.in\n") - -test.must_match(['sub', 'all'], - "CVS/sub/ddd.in\nchecked-out sub/eee.in\nCVS/sub/fff.in\n") - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Deprecated/SourceCode/CVS/CVSCOMSTR.py b/test/Deprecated/SourceCode/CVS/CVSCOMSTR.py deleted file mode 100644 index 483a0ae..0000000 --- a/test/Deprecated/SourceCode/CVS/CVSCOMSTR.py +++ /dev/null @@ -1,141 +0,0 @@ -#!/usr/bin/env python -# -# __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__" - -""" -Test customizing the output with the the $CVSCOMSTR variable. -""" - -import os.path - -import TestSCons - -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) - -test.write('SConscript', """ -Environment(tools = ['CVS']).CVS('') -""") - -msg_cvs = """The CVS() factory is deprecated and there is no replacement.""" -warn_cvs = test.deprecated_fatal('deprecated-build-dir', msg_cvs) -msg_sc = """SourceCode() has been deprecated and there is no replacement. -\tIf you need this function, please contact scons-dev@scons.org""" -warn_sc = test.deprecated_wrap(msg_sc) - -test.subdir('CVS', ['CVS', 'sub'], 'sub') - -sub_CVS = os.path.join('sub', 'CVS') -sub_SConscript = os.path.join('sub', 'SConscript') -sub_all = os.path.join('sub', 'all') -sub_ddd_in = os.path.join('sub', 'ddd.in') -sub_ddd_out = os.path.join('sub', 'ddd.out') -sub_eee_in = os.path.join('sub', 'eee.in') -sub_eee_out = os.path.join('sub', 'eee.out') -sub_fff_in = os.path.join('sub', 'fff.in') -sub_fff_out = os.path.join('sub', 'fff.out') - -test.write('my-cvs-co.py', """ -import shutil -import sys -for f in sys.argv[1:]: - shutil.copy('CVS/'+f, f) -""") - -test.write('SConstruct', """ -SetOption('warn', 'deprecated-source-code') -def cat(env, source, target): - target = str(target[0]) - f = open(target, "wb") - for src in source: - f.write(open(str(src), "rb").read()) - f.close() -env = Environment(TOOLS = ['default', 'CVS'], - BUILDERS={'Cat':Builder(action=cat)}, - CVSCOM=r'%(_python_)s my-cvs-co.py $TARGET', - CVSCOMSTR='Checking out $TARGET from our fake CVS') -env.Cat('aaa.out', 'aaa.in') -env.Cat('bbb.out', 'bbb.in') -env.Cat('ccc.out', 'ccc.in') -env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) -env.SourceCode('.', env.CVS(None)) -SConscript('sub/SConscript', "env") -""" % locals()) - -test.write(['CVS', 'sub', 'SConscript'], """\ -Import("env") -env.Cat('ddd.out', 'ddd.in') -env.Cat('eee.out', 'eee.in') -env.Cat('fff.out', 'fff.in') -env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) -""") - -test.write(['CVS', 'aaa.in'], "CVS/aaa.in\n") -test.write('bbb.in', "checked-out bbb.in\n") -test.write(['CVS', 'ccc.in'], "CVS/ccc.in\n") - -test.write(['CVS', 'sub', 'ddd.in'], "CVS/sub/ddd.in\n") -test.write(['sub', 'eee.in'], "checked-out sub/eee.in\n") -test.write(['CVS', 'sub', 'fff.in'], "CVS/sub/fff.in\n") - -read_str = """\ -Checking out %(sub_SConscript)s from our fake CVS -""" % locals() - -build_str = """\ -Checking out aaa.in from our fake CVS -cat(["aaa.out"], ["aaa.in"]) -cat(["bbb.out"], ["bbb.in"]) -Checking out ccc.in from our fake CVS -cat(["ccc.out"], ["ccc.in"]) -cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) -Checking out %(sub_ddd_in)s from our fake CVS -cat(["%(sub_ddd_out)s"], ["%(sub_ddd_in)s"]) -cat(["%(sub_eee_out)s"], ["%(sub_eee_in)s"]) -Checking out %(sub_fff_in)s from our fake CVS -cat(["%(sub_fff_out)s"], ["%(sub_fff_in)s"]) -cat(["%(sub_all)s"], ["%(sub_ddd_out)s", "%(sub_eee_out)s", "%(sub_fff_out)s"]) -""" % locals() - -stdout = test.wrap_stdout(read_str = read_str, build_str = build_str) - -test.run(arguments = '.', - stdout = TestSCons.re_escape(stdout), - stderr = warn_cvs + warn_sc) - -test.must_match('all', - "CVS/aaa.in\nchecked-out bbb.in\nCVS/ccc.in\n") - -test.must_match(['sub', 'all'], - "CVS/sub/ddd.in\nchecked-out sub/eee.in\nCVS/sub/fff.in\n") - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: -- cgit v0.12 From 45d00ece3e66ad3b2107f99837e0b52ac297bcd5 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 20 Mar 2017 11:01:16 -0700 Subject: Remove deprecated tool RCS --- src/CHANGES.txt | 2 +- src/engine/SCons/Tool/RCS.py | 63 -------- src/engine/SCons/Tool/RCS.xml | 142 ----------------- src/engine/SCons/Tool/__init__.py | 3 +- test/Deprecated/SourceCode/RCS/RCS_COCOM.py | 140 ----------------- test/Deprecated/SourceCode/RCS/RCS_COCOMSTR.py | 141 ----------------- test/Deprecated/SourceCode/RCS/changed.py | 107 ------------- test/Deprecated/SourceCode/RCS/diskcheck.py | 202 ------------------------- test/Deprecated/SourceCode/RCS/explicit.py | 176 --------------------- test/Deprecated/SourceCode/RCS/implicit.py | 100 ------------ test/Deprecated/SourceCode/RCS/transparent.py | 187 ----------------------- 11 files changed, 2 insertions(+), 1261 deletions(-) delete mode 100644 src/engine/SCons/Tool/RCS.py delete mode 100644 src/engine/SCons/Tool/RCS.xml delete mode 100644 test/Deprecated/SourceCode/RCS/RCS_COCOM.py delete mode 100644 test/Deprecated/SourceCode/RCS/RCS_COCOMSTR.py delete mode 100644 test/Deprecated/SourceCode/RCS/changed.py delete mode 100644 test/Deprecated/SourceCode/RCS/diskcheck.py delete mode 100644 test/Deprecated/SourceCode/RCS/explicit.py delete mode 100644 test/Deprecated/SourceCode/RCS/implicit.py delete mode 100644 test/Deprecated/SourceCode/RCS/transparent.py diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 7c07ca7..af4eb29 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -30,7 +30,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Fixed SCons.Tool.Packaging.rpm.package source nondeterminism across builds. From William Deegan: - - Removed deprecated source code tool CVS, Perforce, BitKeeper. + - Removed deprecated source code tool CVS, Perforce, BitKeeper, RCS. From Daniel Moody: - Fixed msvs.py for Visual Studio generated projects which were diff --git a/src/engine/SCons/Tool/RCS.py b/src/engine/SCons/Tool/RCS.py deleted file mode 100644 index e24b89a..0000000 --- a/src/engine/SCons/Tool/RCS.py +++ /dev/null @@ -1,63 +0,0 @@ -"""SCons.Tool.RCS.py - -Tool-specific initialization for RCS. - -There normally shouldn't be any need to import this module directly. -It will usually be imported through the generic SCons.Tool.Tool() -selection method. - -""" - -# __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__" - -import SCons.Action -import SCons.Builder -import SCons.Util - -def generate(env): - """Add a Builder factory function and construction variables for - RCS to an Environment.""" - - def RCSFactory(env=env): - """ """ - import SCons.Warnings as W - W.warn(W.DeprecatedSourceCodeWarning, """The RCS() factory is deprecated and there is no replacement.""") - act = SCons.Action.Action('$RCS_COCOM', '$RCS_COCOMSTR') - return SCons.Builder.Builder(action = act, env = env) - - env.RCS = RCSFactory - - env['RCS'] = 'rcs' - env['RCS_CO'] = 'co' - env['RCS_COFLAGS'] = SCons.Util.CLVar('') - env['RCS_COCOM'] = '$RCS_CO $RCS_COFLAGS $TARGET' - -def exists(env): - return env.Detect('rcs') - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/src/engine/SCons/Tool/RCS.xml b/src/engine/SCons/Tool/RCS.xml deleted file mode 100644 index 760f5c0..0000000 --- a/src/engine/SCons/Tool/RCS.xml +++ /dev/null @@ -1,142 +0,0 @@ - - - - -%scons; - -%builders-mod; - -%functions-mod; - -%tools-mod; - -%variables-mod; -]> - - - - - - -Sets construction variables for the interaction -with the Revision Control System. - - - -RCS -RCS_CO -RCS_COFLAGS -RCS_COCOM - - -RCS_COCOMSTR - - - - - - -The RCS executable. -Note that this variable is not actually used -for the command to fetch source files from RCS; -see the -&cv-link-RCS_CO; -construction variable, below. - - - - - - - -The RCS "checkout" executable, -used to fetch source files from RCS. - - - - - - - -The command line used to -fetch (checkout) source files from RCS. - - - - - - - -The string displayed when fetching -a source file from RCS. -If this is not set, then &cv-link-RCS_COCOM; -(the command line) is displayed. - - - - - - - -Options that are passed to the &cv-link-RCS_CO; command. - - - - - - -() - - - -A factory function that -returns a Builder object -to be used to fetch source files -from RCS. -The returned Builder -is intended to be passed to the -&f-SourceCode; -function: - - - -This function is deprecated. For details, see the entry for the -&f-SourceCode; -function. - - - -Examples: - - - -env.SourceCode('.', env.RCS()) - - - -Note that -&scons; -will fetch source files -from RCS subdirectories automatically, -so configuring RCS -as demonstrated in the above example -should only be necessary if -you are fetching from -RCS,v -files in the same -directory as the source files, -or if you need to explicitly specify RCS -for a specific subdirectory. - - - - - diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index f95b175..944e450 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -1157,8 +1157,7 @@ def tool_list(platform, env): # Archivers 'tar', 'zip', # SourceCode factories - 'CVS', - 'RCS', 'SCCS', # 'Subversion', + 'SCCS', # 'Subversion', ], env) tools = ([linker, c_compiler, cxx_compiler, diff --git a/test/Deprecated/SourceCode/RCS/RCS_COCOM.py b/test/Deprecated/SourceCode/RCS/RCS_COCOM.py deleted file mode 100644 index c5934ac..0000000 --- a/test/Deprecated/SourceCode/RCS/RCS_COCOM.py +++ /dev/null @@ -1,140 +0,0 @@ -#!/usr/bin/env python -# -# __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__" - -""" -Test setting the $RCS_COCOM variable. -""" - -import os - -import TestSCons - -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) - -test.write('SConscript', """ -Environment(tools = ['RCS']).RCS() -""") - -msg_rcs = """The RCS() factory is deprecated and there is no replacement.""" -warn_rcs = test.deprecated_fatal('deprecated-build-dir', msg_rcs) -msg_sc = """SourceCode() has been deprecated and there is no replacement. -\tIf you need this function, please contact scons-dev@scons.org""" -warn_sc = test.deprecated_wrap(msg_sc) - -test.subdir('RCS', ['RCS', 'sub'], 'sub') - -sub_RCS = os.path.join('sub', 'RCS') -sub_SConscript = os.path.join('sub', 'SConscript') -sub_all = os.path.join('sub', 'all') -sub_ddd_in = os.path.join('sub', 'ddd.in') -sub_ddd_out = os.path.join('sub', 'ddd.out') -sub_eee_in = os.path.join('sub', 'eee.in') -sub_eee_out = os.path.join('sub', 'eee.out') -sub_fff_in = os.path.join('sub', 'fff.in') -sub_fff_out = os.path.join('sub', 'fff.out') - -test.write('my-rcs-co.py', """ -import shutil -import sys -for f in sys.argv[1:]: - shutil.copy('RCS/'+f, f) -""") - -test.write('SConstruct', """ -SetOption('warn', 'deprecated-source-code') -def cat(env, source, target): - target = str(target[0]) - f = open(target, "wb") - for src in source: - f.write(open(str(src), "rb").read()) - f.close() -env = Environment(TOOLS = ['default', 'RCS'], - BUILDERS={'Cat':Builder(action=cat)}, - RCS_COCOM=r'%(_python_)s my-rcs-co.py $TARGET') -env.Cat('aaa.out', 'aaa.in') -env.Cat('bbb.out', 'bbb.in') -env.Cat('ccc.out', 'ccc.in') -env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) -env.SourceCode('.', env.RCS()) -SConscript('sub/SConscript', "env") -""" % locals()) - -test.write(['RCS', 'sub', 'SConscript'], """\ -Import("env") -env.Cat('ddd.out', 'ddd.in') -env.Cat('eee.out', 'eee.in') -env.Cat('fff.out', 'fff.in') -env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) -""") - -test.write(['RCS', 'aaa.in'], "RCS/aaa.in\n") -test.write('bbb.in', "checked-out bbb.in\n") -test.write(['RCS', 'ccc.in'], "RCS/ccc.in\n") - -test.write(['RCS', 'sub', 'ddd.in'], "RCS/sub/ddd.in\n") -test.write(['sub', 'eee.in'], "checked-out sub/eee.in\n") -test.write(['RCS', 'sub', 'fff.in'], "RCS/sub/fff.in\n") - -read_str = """\ -%(_python_)s my-rcs-co.py %(sub_SConscript)s -""" % locals() - -build_str = """\ -%(_python_)s my-rcs-co.py aaa.in -cat(["aaa.out"], ["aaa.in"]) -cat(["bbb.out"], ["bbb.in"]) -%(_python_)s my-rcs-co.py ccc.in -cat(["ccc.out"], ["ccc.in"]) -cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) -%(_python_)s my-rcs-co.py %(sub_ddd_in)s -cat(["%(sub_ddd_out)s"], ["%(sub_ddd_in)s"]) -cat(["%(sub_eee_out)s"], ["%(sub_eee_in)s"]) -%(_python_)s my-rcs-co.py %(sub_fff_in)s -cat(["%(sub_fff_out)s"], ["%(sub_fff_in)s"]) -cat(["%(sub_all)s"], ["%(sub_ddd_out)s", "%(sub_eee_out)s", "%(sub_fff_out)s"]) -""" % locals() - -stdout = test.wrap_stdout(read_str = read_str, build_str = build_str) - -test.run(arguments = '.', - stdout = TestSCons.re_escape(stdout), - stderr = warn_rcs + warn_sc) - -test.must_match('all', - "RCS/aaa.in\nchecked-out bbb.in\nRCS/ccc.in\n") - -test.must_match(['sub', 'all'], - "RCS/sub/ddd.in\nchecked-out sub/eee.in\nRCS/sub/fff.in\n") - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Deprecated/SourceCode/RCS/RCS_COCOMSTR.py b/test/Deprecated/SourceCode/RCS/RCS_COCOMSTR.py deleted file mode 100644 index cb54202..0000000 --- a/test/Deprecated/SourceCode/RCS/RCS_COCOMSTR.py +++ /dev/null @@ -1,141 +0,0 @@ -#!/usr/bin/env python -# -# __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__" - -""" -Test customizing the output with the the $RCS_COCOMSTR variable. -""" - -import os.path - -import TestSCons - -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) - -test.write('SConscript', """ -Environment(tools = ['RCS']).RCS() -""") - -msg_rcs = """The RCS() factory is deprecated and there is no replacement.""" -warn_rcs = test.deprecated_fatal('deprecated-build-dir', msg_rcs) -msg_sc = """SourceCode() has been deprecated and there is no replacement. -\tIf you need this function, please contact scons-dev@scons.org""" -warn_sc = test.deprecated_wrap(msg_sc) - -test.subdir('RCS', ['RCS', 'sub'], 'sub') - -sub_RCS = os.path.join('sub', 'RCS') -sub_SConscript = os.path.join('sub', 'SConscript') -sub_all = os.path.join('sub', 'all') -sub_ddd_in = os.path.join('sub', 'ddd.in') -sub_ddd_out = os.path.join('sub', 'ddd.out') -sub_eee_in = os.path.join('sub', 'eee.in') -sub_eee_out = os.path.join('sub', 'eee.out') -sub_fff_in = os.path.join('sub', 'fff.in') -sub_fff_out = os.path.join('sub', 'fff.out') - -test.write('my-rcs-co.py', """ -import shutil -import sys -for f in sys.argv[1:]: - shutil.copy('RCS/'+f, f) -""") - -test.write('SConstruct', """ -SetOption('warn', 'deprecated-source-code') -def cat(env, source, target): - target = str(target[0]) - f = open(target, "wb") - for src in source: - f.write(open(str(src), "rb").read()) - f.close() -env = Environment(TOOLS = ['default', 'RCS'], - BUILDERS={'Cat':Builder(action=cat)}, - RCS_COCOM=r'%(_python_)s my-rcs-co.py $TARGET', - RCS_COCOMSTR='Checking out $TARGET from our fake RCS') -env.Cat('aaa.out', 'aaa.in') -env.Cat('bbb.out', 'bbb.in') -env.Cat('ccc.out', 'ccc.in') -env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) -env.SourceCode('.', env.RCS()) -SConscript('sub/SConscript', "env") -""" % locals()) - -test.write(['RCS', 'sub', 'SConscript'], """\ -Import("env") -env.Cat('ddd.out', 'ddd.in') -env.Cat('eee.out', 'eee.in') -env.Cat('fff.out', 'fff.in') -env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) -""") - -test.write(['RCS', 'aaa.in'], "RCS/aaa.in\n") -test.write('bbb.in', "checked-out bbb.in\n") -test.write(['RCS', 'ccc.in'], "RCS/ccc.in\n") - -test.write(['RCS', 'sub', 'ddd.in'], "RCS/sub/ddd.in\n") -test.write(['sub', 'eee.in'], "checked-out sub/eee.in\n") -test.write(['RCS', 'sub', 'fff.in'], "RCS/sub/fff.in\n") - -read_str = """\ -Checking out %(sub_SConscript)s from our fake RCS -""" % locals() - -build_str = """\ -Checking out aaa.in from our fake RCS -cat(["aaa.out"], ["aaa.in"]) -cat(["bbb.out"], ["bbb.in"]) -Checking out ccc.in from our fake RCS -cat(["ccc.out"], ["ccc.in"]) -cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) -Checking out %(sub_ddd_in)s from our fake RCS -cat(["%(sub_ddd_out)s"], ["%(sub_ddd_in)s"]) -cat(["%(sub_eee_out)s"], ["%(sub_eee_in)s"]) -Checking out %(sub_fff_in)s from our fake RCS -cat(["%(sub_fff_out)s"], ["%(sub_fff_in)s"]) -cat(["%(sub_all)s"], ["%(sub_ddd_out)s", "%(sub_eee_out)s", "%(sub_fff_out)s"]) -""" % locals() - -stdout = test.wrap_stdout(read_str = read_str, build_str = build_str) - -test.run(arguments = '.', - stdout = TestSCons.re_escape(stdout), - stderr = warn_rcs + warn_sc) - -test.must_match('all', - "RCS/aaa.in\nchecked-out bbb.in\nRCS/ccc.in\n") - -test.must_match(['sub', 'all'], - "RCS/sub/ddd.in\nchecked-out sub/eee.in\nRCS/sub/fff.in\n") - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Deprecated/SourceCode/RCS/changed.py b/test/Deprecated/SourceCode/RCS/changed.py deleted file mode 100644 index fec1ba3..0000000 --- a/test/Deprecated/SourceCode/RCS/changed.py +++ /dev/null @@ -1,107 +0,0 @@ -#!/usr/bin/env python -# -# __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__" - -""" -Test explicit checkouts from local RCS files. -""" - -import TestSCons - -test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) - -test.write('SConscript', """ -Environment(tools = ['RCS']).RCS() -""") - -msg_rcs = """The RCS() factory is deprecated and there is no replacement.""" -warn_rcs = test.deprecated_fatal('deprecated-build-dir', msg_rcs) -msg_sc = """SourceCode() has been deprecated and there is no replacement. -\tIf you need this function, please contact scons-dev@scons.org""" -warn_sc = test.deprecated_wrap(msg_sc) - -rcs = test.where_is('rcs') -if not rcs: - test.skip_test("Could not find 'rcs'; skipping test(s).\n") - -ci = test.where_is('ci') -if not ci: - test.skip_test("Could not find `ci' command, skipping test(s).\n") - -co = test.where_is('co') -if not co: - test.skip_test("Could not find `co' command, skipping test(s).\n") - - -main_cpp_contents = """\ -#include -#include -int -main(int argc, char *argv[]) -{ - printf("main.c %s\\n"); - exit (0); -} -""" - -test.write('main.c', main_cpp_contents % 1) - -test.run(program = ci, arguments = '-f -tmain.c main.c', stderr = None) - - -test.write('SConstruct', """ -SetOption('warn', 'deprecated-source-code') -import os -for key in ['LOGNAME', 'USERNAME', 'USER']: - logname = os.environ.get(key) - if logname: break -ENV = {'PATH' : os.environ['PATH'], - 'LOGNAME' : logname} -env = Environment(ENV=ENV, RCS_COFLAGS='-q') -env.SourceCode('main.c', env.RCS()) -env2 = env.Clone() -env2.Program('main.exe', 'main.c') -""") - -test.run(stderr = warn_rcs + warn_sc) - -test.run(program = test.workpath('main.exe'), stdout = "main.c 1\n") - -test.run(program = co, arguments = '-l main.c', stderr = None) - - -test.write('main.c', main_cpp_contents % 2) - -test.not_up_to_date(arguments = 'main.exe', stderr = warn_rcs + warn_sc) - -test.run(program = test.workpath('main.exe'), stdout = "main.c 2\n") - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Deprecated/SourceCode/RCS/diskcheck.py b/test/Deprecated/SourceCode/RCS/diskcheck.py deleted file mode 100644 index 7183975..0000000 --- a/test/Deprecated/SourceCode/RCS/diskcheck.py +++ /dev/null @@ -1,202 +0,0 @@ -#!/usr/bin/env python -# -# __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__" - -""" -Test transparent RCS checkouts from an RCS subdirectory. -""" - -import os - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConscript', """ -Environment(tools = ['RCS']).RCS() -""") - -msg_rcs = """The RCS() factory is deprecated and there is no replacement.""" -test.deprecated_fatal('deprecated-build-dir', msg_rcs) - -rcs = test.where_is('rcs') -if not rcs: - test.skip_test("Could not find 'rcs'; skipping test(s).\n") - -ci = test.where_is('ci') -if not ci: - test.skip_test("Could not find 'ci'; skipping test(s).\n") - - -sub_RCS = os.path.join('sub', 'RCS') -sub_SConscript = os.path.join('sub', 'SConscript') -sub_all = os.path.join('sub', 'all') -sub_ddd_in = os.path.join('sub', 'ddd.in') -sub_ddd_out = os.path.join('sub', 'ddd.out') -sub_eee_in = os.path.join('sub', 'eee.in') -sub_eee_out = os.path.join('sub', 'eee.out') -sub_fff_in = os.path.join('sub', 'fff.in') -sub_fff_out = os.path.join('sub', 'fff.out') - -test.subdir('RCS', 'sub', ['sub', 'RCS']) - -for f in ['aaa.in', 'bbb.in', 'ccc.in']: - test.write(f, "%s\n" % f) - args = "-f -t%s %s" % (f, f) - test.run(program = ci, arguments = args, stderr = None) - -for f in ['ddd.in', 'eee.in', 'fff.in']: - test.write(['sub', f], "sub/%s\n" % f) - args = "-f -tsub/%s sub/%s" % (f, f) - test.run(program = ci, arguments = args, stderr = None) - -test.write(['sub', 'SConscript'], """\ -Import("env") -env.Cat('ddd.out', 'ddd.in') -env.Cat('eee.out', 'eee.in') -env.Cat('fff.out', 'fff.in') -env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) -""") -args = "-f -tsub/SConscript sub/SConscript" -test.run(program = ci, arguments = args, stderr = None) - -test.no_result(os.path.exists(test.workpath('aaa.in'))) -test.no_result(os.path.exists(test.workpath('bbb.in'))) -test.no_result(os.path.exists(test.workpath('ccc.in'))) - -test.no_result(os.path.exists(test.workpath('sub', 'SConscript'))) - -test.no_result(os.path.exists(test.workpath('sub', 'aaa.in'))) -test.no_result(os.path.exists(test.workpath('sub', 'bbb.in'))) -test.no_result(os.path.exists(test.workpath('sub', 'ccc.in'))) - -test.write('SConstruct', """ -SetOption('warn', 'deprecated-source-code') -import os -for key in ['LOGNAME', 'USERNAME', 'USER']: - logname = os.environ.get(key) - if logname: break -ENV = {'PATH' : os.environ['PATH'], - 'LOGNAME' : logname} -def cat(env, source, target): - target = str(target[0]) - f = open(target, "wb") - for src in source: - f.write(open(str(src), "rb").read()) - f.close() -SetOption('diskcheck', None) -DefaultEnvironment()['ENV'] = ENV -DefaultEnvironment()['RCS_COFLAGS'] = '-l' -env = Environment(ENV=ENV, BUILDERS={'Cat':Builder(action=cat)}) -env.Cat('aaa.out', 'aaa.in') -env.Cat('bbb.out', 'bbb.in') -env.Cat('ccc.out', 'ccc.in') -env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) -SConscript('sub/SConscript', "env") -""") - -test.write('bbb.in', "checked-out bbb.in\n") - -test.write(['sub', 'eee.in'], "checked-out sub/eee.in\n") - -sub_SConscript = os.path.join('sub', 'SConscript') -SConstruct_file_line = test.python_file_line(test.workpath('SConstruct'), 23)[:-1] - -expect = """\ - -scons: warning: Ignoring missing SConscript '%(sub_SConscript)s' -%(SConstruct_file_line)s -scons: *** [aaa.out] Source `aaa.in' not found, needed by target `aaa.out'. -""" % locals() - -test.run(status=2, stderr=expect) - -test.run(arguments = '--diskcheck=match,sccs', status=2, stderr=expect) - -read_str = """\ -co -l %(sub_SConscript)s -""" % locals() - -build_str = """\ -co -l aaa.in -cat(["aaa.out"], ["aaa.in"]) -cat(["bbb.out"], ["bbb.in"]) -co -l ccc.in -cat(["ccc.out"], ["ccc.in"]) -cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) -co -l %(sub_ddd_in)s -cat(["%(sub_ddd_out)s"], ["%(sub_ddd_in)s"]) -cat(["%(sub_eee_out)s"], ["%(sub_eee_in)s"]) -co -l %(sub_fff_in)s -cat(["%(sub_fff_out)s"], ["%(sub_fff_in)s"]) -cat(["%(sub_all)s"], ["%(sub_ddd_out)s", "%(sub_eee_out)s", "%(sub_fff_out)s"]) -""" % locals() - -stdout = test.wrap_stdout(read_str = read_str, build_str = build_str) - -stderr = """\ -%(sub_RCS)s/SConscript,v --> %(sub_SConscript)s -revision 1.1 (locked) -done -RCS/aaa.in,v --> aaa.in -revision 1.1 (locked) -done -RCS/ccc.in,v --> ccc.in -revision 1.1 (locked) -done -%(sub_RCS)s/ddd.in,v --> %(sub_ddd_in)s -revision 1.1 (locked) -done -%(sub_RCS)s/fff.in,v --> %(sub_fff_in)s -revision 1.1 (locked) -done -""" % locals() - -test.run(arguments = '--diskcheck=rcs', stdout = stdout, stderr = stderr) - -# Checking things back out of RCS apparently messes with the line -# endings, so read the result files in non-binary mode. - -test.must_match('all', - "aaa.in\nchecked-out bbb.in\nccc.in\n", - mode='r') - -test.must_match(['sub', 'all'], - "sub/ddd.in\nchecked-out sub/eee.in\nsub/fff.in\n", - mode='r') - -test.must_be_writable(test.workpath('sub', 'SConscript')) -test.must_be_writable(test.workpath('aaa.in')) -test.must_be_writable(test.workpath('ccc.in')) -test.must_be_writable(test.workpath('sub', 'ddd.in')) -test.must_be_writable(test.workpath('sub', 'fff.in')) - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Deprecated/SourceCode/RCS/explicit.py b/test/Deprecated/SourceCode/RCS/explicit.py deleted file mode 100644 index 96ce02f..0000000 --- a/test/Deprecated/SourceCode/RCS/explicit.py +++ /dev/null @@ -1,176 +0,0 @@ -#!/usr/bin/env python -# -# __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__" - -""" -Test explicit checkouts from local RCS files. -""" - -import os - -import TestSCons - -test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) - -test.write('SConscript', """ -Environment(tools = ['RCS']).RCS() -""") - -msg_rcs = """The RCS() factory is deprecated and there is no replacement.""" -warn_rcs = test.deprecated_fatal('deprecated-build-dir', msg_rcs) -msg_sc = """SourceCode() has been deprecated and there is no replacement. -\tIf you need this function, please contact scons-dev@scons.org""" -warn_sc = test.deprecated_wrap(msg_sc) - -rcs = test.where_is('rcs') -if not rcs: - test.skip_test("Could not find 'rcs'; skipping test(s).\n") - -ci = test.where_is('ci') -if not ci: - test.skip_test("Could not find `ci' command, skipping test(s).\n") - - -test.subdir('sub') - -sub_RCS = os.path.join('sub', 'RCS') -sub_SConscript = os.path.join('sub', 'SConscript') -sub_all = os.path.join('sub', 'all') -sub_ddd_in = os.path.join('sub', 'ddd.in') -sub_ddd_out = os.path.join('sub', 'ddd.out') -sub_eee_in = os.path.join('sub', 'eee.in') -sub_eee_out = os.path.join('sub', 'eee.out') -sub_fff_in = os.path.join('sub', 'fff.in') -sub_fff_out = os.path.join('sub', 'fff.out') - -for f in ['aaa.in', 'bbb.in', 'ccc.in']: - test.write(f, "%s\n" % f) - args = "-f -t%s %s" % (f, f) - test.run(program = ci, arguments = args, stderr = None) - -test.write(['sub', 'SConscript'], """\ -Import("env") -env.Cat('ddd.out', 'ddd.in') -env.Cat('eee.out', 'eee.in') -env.Cat('fff.out', 'fff.in') -env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) -""") -args = "-f -tsub/SConscript sub/SConscript" -test.run(program = ci, arguments = args, stderr = None) - -for f in ['ddd.in', 'eee.in', 'fff.in']: - test.write(['sub', f], "sub/%s\n" % f) - args = "-f -tsub/%s sub/%s" % (f, f) - test.run(program = ci, arguments = args, stderr = None) - -test.no_result(os.path.exists(test.workpath('aaa.in'))) -test.no_result(os.path.exists(test.workpath('bbb.in'))) -test.no_result(os.path.exists(test.workpath('ccc.in'))) - -test.no_result(os.path.exists(test.workpath('sub', 'SConscript'))) - -test.no_result(os.path.exists(test.workpath('sub', 'ddd.in'))) -test.no_result(os.path.exists(test.workpath('sub', 'eee.in'))) -test.no_result(os.path.exists(test.workpath('sub', 'fff.in'))) - -test.write('SConstruct', """ -SetOption('warn', 'deprecated-source-code') -import os -for key in ['LOGNAME', 'USERNAME', 'USER']: - logname = os.environ.get(key) - if logname: break -ENV = {'PATH' : os.environ['PATH'], - 'LOGNAME' : logname} -def cat(env, source, target): - target = str(target[0]) - f = open(target, "wb") - for src in source: - f.write(open(str(src), "rb").read()) - f.close() -env = Environment(ENV=ENV, - BUILDERS={'Cat':Builder(action=cat)}, - RCS_COFLAGS='-q') -DefaultEnvironment()['ENV'] = ENV -env.Cat('aaa.out', 'aaa.in') -env.Cat('bbb.out', 'bbb.in') -env.Cat('ccc.out', 'ccc.in') -env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) -env.SourceCode('.', env.RCS()) -SConscript('sub/SConscript', "env") -""") - -test.write('bbb.in', "checked-out bbb.in\n") - -test.write(['sub', 'eee.in'], "checked-out sub/eee.in\n") - -read_str = """\ -co -q %(sub_SConscript)s -""" % locals() - -build_str = """\ -co -q aaa.in -cat(["aaa.out"], ["aaa.in"]) -cat(["bbb.out"], ["bbb.in"]) -co -q ccc.in -cat(["ccc.out"], ["ccc.in"]) -cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) -co -q %(sub_ddd_in)s -cat(["%(sub_ddd_out)s"], ["%(sub_ddd_in)s"]) -cat(["%(sub_eee_out)s"], ["%(sub_eee_in)s"]) -co -q %(sub_fff_in)s -cat(["%(sub_fff_out)s"], ["%(sub_fff_in)s"]) -cat(["%(sub_all)s"], ["%(sub_ddd_out)s", "%(sub_eee_out)s", "%(sub_fff_out)s"]) -""" % locals() - -stdout = test.wrap_stdout(read_str = read_str, build_str = build_str) - -test.run(arguments = '.', - stdout = TestSCons.re_escape(stdout), - stderr = warn_rcs + warn_sc) - -# Checking things back out of RCS apparently messes with the line -# endings, so read the result files in non-binary mode. - -test.must_match('all', - "aaa.in\nchecked-out bbb.in\nccc.in\n", - mode='r') - -test.must_match(['sub', 'all'], - "sub/ddd.in\nchecked-out sub/eee.in\nsub/fff.in\n", - mode='r') - -test.must_not_be_writable(test.workpath('sub', 'SConscript')) -test.must_not_be_writable(test.workpath('aaa.in')) -test.must_not_be_writable(test.workpath('ccc.in')) -test.must_not_be_writable(test.workpath('sub', 'ddd.in')) -test.must_not_be_writable(test.workpath('sub', 'fff.in')) - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Deprecated/SourceCode/RCS/implicit.py b/test/Deprecated/SourceCode/RCS/implicit.py deleted file mode 100644 index ed1f1a2..0000000 --- a/test/Deprecated/SourceCode/RCS/implicit.py +++ /dev/null @@ -1,100 +0,0 @@ -#!/usr/bin/env python -# -# __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__" - -""" -Test transparent RCS checkouts of implicit dependencies. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConscript', """ -Environment(tools = ['RCS']).RCS() -""") - -msg_rcs = """The RCS() factory is deprecated and there is no replacement.""" -test.deprecated_fatal('deprecated-build-dir', msg_rcs) - -rcs = test.where_is('rcs') -if not rcs: - test.skip_test("Could not find 'rcs'; skipping test(s).\n") - -ci = test.where_is('ci') -if not ci: - test.skip_test("Could not find 'ci'; skipping test(s).\n") - -co = test.where_is('co') -if not co: - test.skip_test("Could not find 'co'; skipping test(s).\n") - - -test.subdir('RCS') - -test.write('foo.c', """\ -#include - -#include "foo.h" -int -main(int argc, char *argv[]) { - printf(STR); - printf("foo.c\\n"); -} -""") -test.run(program = ci, - arguments = "-f -tfoo.c foo.c", - stderr = None) - -test.write('foo.h', """\ -#define STR "foo.h\\n" -""") -test.run(program = ci, - arguments = "-f -tfoo.h foo.h", - stderr = None) - -test.write('SConstruct', """ -SetOption('warn', 'deprecated-source-code') -DefaultEnvironment(RCS_CO = r'%s') -env = Environment() -env.Program('foo.c') -""" % co) - -test.run(stderr="""\ -RCS/foo.c,v --> foo.c -revision 1.1 -done -RCS/foo.h,v --> foo.h -revision 1.1 -done -""") - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Deprecated/SourceCode/RCS/transparent.py b/test/Deprecated/SourceCode/RCS/transparent.py deleted file mode 100644 index 67d0512..0000000 --- a/test/Deprecated/SourceCode/RCS/transparent.py +++ /dev/null @@ -1,187 +0,0 @@ -#!/usr/bin/env python -# -# __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__" - -""" -Test transparent RCS checkouts from an RCS subdirectory. -""" - -import os - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConscript', """ -Environment(tools = ['RCS']).RCS() -""") - -msg_rcs = """The RCS() factory is deprecated and there is no replacement.""" -test.deprecated_fatal('deprecated-build-dir', msg_rcs) - -rcs = test.where_is('rcs') -if not rcs: - test.skip_test("Could not find 'rcs'; skipping test(s).\n") - -ci = test.where_is('ci') -if not ci: - test.skip_test("Could not find 'ci'; skipping test(s).\n") - - -sub_RCS = os.path.join('sub', 'RCS') -sub_SConscript = os.path.join('sub', 'SConscript') -sub_all = os.path.join('sub', 'all') -sub_ddd_in = os.path.join('sub', 'ddd.in') -sub_ddd_out = os.path.join('sub', 'ddd.out') -sub_eee_in = os.path.join('sub', 'eee.in') -sub_eee_out = os.path.join('sub', 'eee.out') -sub_fff_in = os.path.join('sub', 'fff.in') -sub_fff_out = os.path.join('sub', 'fff.out') - -test.subdir('RCS', 'sub', ['sub', 'RCS']) - -for f in ['aaa.in', 'bbb.in', 'ccc.in']: - test.write(f, "%s\n" % f) - args = "-f -t%s %s" % (f, f) - test.run(program = ci, arguments = args, stderr = None) - -for f in ['ddd.in', 'eee.in', 'fff.in']: - test.write(['sub', f], "sub/%s\n" % f) - args = "-f -tsub/%s sub/%s" % (f, f) - test.run(program = ci, arguments = args, stderr = None) - -test.write(['sub', 'SConscript'], """\ -Import("env") -env.Cat('ddd.out', 'ddd.in') -env.Cat('eee.out', 'eee.in') -env.Cat('fff.out', 'fff.in') -env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) -""") -args = "-f -tsub/SConscript sub/SConscript" -test.run(program = ci, arguments = args, stderr = None) - -test.no_result(os.path.exists(test.workpath('aaa.in'))) -test.no_result(os.path.exists(test.workpath('bbb.in'))) -test.no_result(os.path.exists(test.workpath('ccc.in'))) - -test.no_result(os.path.exists(test.workpath('sub', 'SConscript'))) - -test.no_result(os.path.exists(test.workpath('sub', 'aaa.in'))) -test.no_result(os.path.exists(test.workpath('sub', 'bbb.in'))) -test.no_result(os.path.exists(test.workpath('sub', 'ccc.in'))) - -test.write('SConstruct', """ -SetOption('warn', 'deprecated-source-code') -import os -for key in ['LOGNAME', 'USERNAME', 'USER']: - logname = os.environ.get(key) - if logname: break -ENV = {'PATH' : os.environ['PATH'], - 'LOGNAME' : logname} -def cat(env, source, target): - target = str(target[0]) - f = open(target, "wb") - for src in source: - f.write(open(str(src), "rb").read()) - f.close() -DefaultEnvironment()['ENV'] = ENV -DefaultEnvironment()['RCS_COFLAGS'] = '-l' -env = Environment(ENV=ENV, BUILDERS={'Cat':Builder(action=cat)}) -env.Cat('aaa.out', 'aaa.in') -env.Cat('bbb.out', 'bbb.in') -env.Cat('ccc.out', 'ccc.in') -env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) -SConscript('sub/SConscript', "env") -""") - -test.write('bbb.in', "checked-out bbb.in\n") - -test.write(['sub', 'eee.in'], "checked-out sub/eee.in\n") - -read_str = """\ -co -l %(sub_SConscript)s -""" % locals() - -build_str = """\ -co -l aaa.in -cat(["aaa.out"], ["aaa.in"]) -cat(["bbb.out"], ["bbb.in"]) -co -l ccc.in -cat(["ccc.out"], ["ccc.in"]) -cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) -co -l %(sub_ddd_in)s -cat(["%(sub_ddd_out)s"], ["%(sub_ddd_in)s"]) -cat(["%(sub_eee_out)s"], ["%(sub_eee_in)s"]) -co -l %(sub_fff_in)s -cat(["%(sub_fff_out)s"], ["%(sub_fff_in)s"]) -cat(["%(sub_all)s"], ["%(sub_ddd_out)s", "%(sub_eee_out)s", "%(sub_fff_out)s"]) -""" % locals() - -stdout = test.wrap_stdout(read_str = read_str, build_str = build_str) - -stderr = """\ -%(sub_RCS)s/SConscript,v --> %(sub_SConscript)s -revision 1.1 (locked) -done -RCS/aaa.in,v --> aaa.in -revision 1.1 (locked) -done -RCS/ccc.in,v --> ccc.in -revision 1.1 (locked) -done -%(sub_RCS)s/ddd.in,v --> %(sub_ddd_in)s -revision 1.1 (locked) -done -%(sub_RCS)s/fff.in,v --> %(sub_fff_in)s -revision 1.1 (locked) -done -""" % locals() - -test.run(arguments = '.', stdout = stdout, stderr = stderr) - -# Checking things back out of RCS apparently messes with the line -# endings, so read the result files in non-binary mode. - -test.must_match('all', - "aaa.in\nchecked-out bbb.in\nccc.in\n", - mode='r') - -test.must_match(['sub', 'all'], - "sub/ddd.in\nchecked-out sub/eee.in\nsub/fff.in\n", - mode='r') - -test.must_be_writable(test.workpath('sub', 'SConscript')) -test.must_be_writable(test.workpath('aaa.in')) -test.must_be_writable(test.workpath('ccc.in')) -test.must_be_writable(test.workpath('sub', 'ddd.in')) -test.must_be_writable(test.workpath('sub', 'fff.in')) - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: -- cgit v0.12 From 8306627ea9d19ee5aa424a50f8d14b670fec1c66 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 20 Mar 2017 11:02:07 -0700 Subject: Remove deprecated tool SCCS --- src/CHANGES.txt | 2 +- src/engine/SCons/Tool/SCCS.py | 63 ---------- src/engine/SCons/Tool/SCCS.xml | 133 --------------------- src/engine/SCons/Tool/__init__.py | 2 +- test/Deprecated/SourceCode/SCCS/SCCSCOM.py | 140 ---------------------- test/Deprecated/SourceCode/SCCS/SCCSCOMSTR.py | 141 ---------------------- test/Deprecated/SourceCode/SCCS/diskcheck.py | 154 ------------------------- test/Deprecated/SourceCode/SCCS/explicit.py | 136 ---------------------- test/Deprecated/SourceCode/SCCS/implicit.py | 90 --------------- test/Deprecated/SourceCode/SCCS/transparent.py | 135 ---------------------- 10 files changed, 2 insertions(+), 994 deletions(-) delete mode 100644 src/engine/SCons/Tool/SCCS.py delete mode 100644 src/engine/SCons/Tool/SCCS.xml delete mode 100644 test/Deprecated/SourceCode/SCCS/SCCSCOM.py delete mode 100644 test/Deprecated/SourceCode/SCCS/SCCSCOMSTR.py delete mode 100644 test/Deprecated/SourceCode/SCCS/diskcheck.py delete mode 100644 test/Deprecated/SourceCode/SCCS/explicit.py delete mode 100644 test/Deprecated/SourceCode/SCCS/implicit.py delete mode 100644 test/Deprecated/SourceCode/SCCS/transparent.py diff --git a/src/CHANGES.txt b/src/CHANGES.txt index af4eb29..26018a2 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -30,7 +30,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Fixed SCons.Tool.Packaging.rpm.package source nondeterminism across builds. From William Deegan: - - Removed deprecated source code tool CVS, Perforce, BitKeeper, RCS. + - Removed deprecated source code tool CVS, Perforce, BitKeeper, RCS, SCCS. From Daniel Moody: - Fixed msvs.py for Visual Studio generated projects which were diff --git a/src/engine/SCons/Tool/SCCS.py b/src/engine/SCons/Tool/SCCS.py deleted file mode 100644 index 92ded51..0000000 --- a/src/engine/SCons/Tool/SCCS.py +++ /dev/null @@ -1,63 +0,0 @@ -"""SCons.Tool.SCCS.py - -Tool-specific initialization for SCCS. - -There normally shouldn't be any need to import this module directly. -It will usually be imported through the generic SCons.Tool.Tool() -selection method. - -""" - -# __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__" - -import SCons.Action -import SCons.Builder -import SCons.Util - -def generate(env): - """Add a Builder factory function and construction variables for - SCCS to an Environment.""" - - def SCCSFactory(env=env): - """ """ - import SCons.Warnings as W - W.warn(W.DeprecatedSourceCodeWarning, """The SCCS() factory is deprecated and there is no replacement.""") - act = SCons.Action.Action('$SCCSCOM', '$SCCSCOMSTR') - return SCons.Builder.Builder(action = act, env = env) - - env.SCCS = SCCSFactory - - env['SCCS'] = 'sccs' - env['SCCSFLAGS'] = SCons.Util.CLVar('') - env['SCCSGETFLAGS'] = SCons.Util.CLVar('') - env['SCCSCOM'] = '$SCCS $SCCSFLAGS get $SCCSGETFLAGS $TARGET' - -def exists(env): - return env.Detect('sccs') - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/src/engine/SCons/Tool/SCCS.xml b/src/engine/SCons/Tool/SCCS.xml deleted file mode 100644 index de22177..0000000 --- a/src/engine/SCons/Tool/SCCS.xml +++ /dev/null @@ -1,133 +0,0 @@ - - - - -%scons; - -%builders-mod; - -%functions-mod; - -%tools-mod; - -%variables-mod; -]> - - - - - - -Sets construction variables for interacting with the -Source Code Control System. - - - -SCCS -SCCSFLAGS -SCCSGETFLAGS -SCCSCOM - - -SCCSCOMSTR - - - - - - -The SCCS executable. - - - - - - - -The command line used to -fetch source files from SCCS. - - - - - - - -The string displayed when fetching -a source file from a CVS repository. -If this is not set, then &cv-link-SCCSCOM; -(the command line) is displayed. - - - - - - - -General options that are passed to SCCS. - - - - - - - -Options that are passed specifically to the SCCS "get" subcommand. -This can be set, for example, to - -to check out editable files from SCCS. - - - - - - -() - - - -A factory function that -returns a Builder object -to be used to fetch source files -from SCCS. -The returned Builder -is intended to be passed to the -&f-link-SourceCode; -function. - - - -Example: - - - -env.SourceCode('.', env.SCCS()) - - - -Note that -&scons; -will fetch source files -from SCCS subdirectories automatically, -so configuring SCCS -as demonstrated in the above example -should only be necessary if -you are fetching from -s.SCCS -files in the same -directory as the source files, -or if you need to explicitly specify SCCS -for a specific subdirectory. - - - - - diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index 944e450..d9fb601 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -1157,7 +1157,7 @@ def tool_list(platform, env): # Archivers 'tar', 'zip', # SourceCode factories - 'SCCS', # 'Subversion', + # 'Subversion', ], env) tools = ([linker, c_compiler, cxx_compiler, diff --git a/test/Deprecated/SourceCode/SCCS/SCCSCOM.py b/test/Deprecated/SourceCode/SCCS/SCCSCOM.py deleted file mode 100644 index ba89d87..0000000 --- a/test/Deprecated/SourceCode/SCCS/SCCSCOM.py +++ /dev/null @@ -1,140 +0,0 @@ -#!/usr/bin/env python -# -# __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__" - -""" -Test setting the $SCCSCOM variable. -""" - -import os.path - -import TestSCons - -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) - -test.write('SConscript', """ -Environment(tools = ['SCCS']).SCCS() -""") - -msg_sccs = """The SCCS() factory is deprecated and there is no replacement.""" -warn_sccs = test.deprecated_fatal('deprecated-build-dir', msg_sccs) -msg_sc = """SourceCode() has been deprecated and there is no replacement. -\tIf you need this function, please contact scons-dev@scons.org""" -warn_sc = test.deprecated_wrap(msg_sc) - -test.subdir('SCCS', ['SCCS', 'sub'], 'sub') - -sub_SCCS = os.path.join('sub', 'SCCS') -sub_SConscript = os.path.join('sub', 'SConscript') -sub_all = os.path.join('sub', 'all') -sub_ddd_in = os.path.join('sub', 'ddd.in') -sub_ddd_out = os.path.join('sub', 'ddd.out') -sub_eee_in = os.path.join('sub', 'eee.in') -sub_eee_out = os.path.join('sub', 'eee.out') -sub_fff_in = os.path.join('sub', 'fff.in') -sub_fff_out = os.path.join('sub', 'fff.out') - -test.write('my-sccs-get.py', """ -import shutil -import sys -for f in sys.argv[1:]: - shutil.copy('SCCS/'+f, f) -""") - -test.write('SConstruct', """ -SetOption('warn', 'deprecated-source-code') -def cat(env, source, target): - target = str(target[0]) - f = open(target, "wb") - for src in source: - f.write(open(str(src), "rb").read()) - f.close() -env = Environment(TOOLS = ['default', 'SCCS'], - BUILDERS={'Cat':Builder(action=cat)}, - SCCSCOM=r'%(_python_)s my-sccs-get.py $TARGET') -env.Cat('aaa.out', 'aaa.in') -env.Cat('bbb.out', 'bbb.in') -env.Cat('ccc.out', 'ccc.in') -env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) -env.SourceCode('.', env.SCCS()) -SConscript('sub/SConscript', "env") -""" % locals()) - -test.write(['SCCS', 'sub', 'SConscript'], """\ -Import("env") -env.Cat('ddd.out', 'ddd.in') -env.Cat('eee.out', 'eee.in') -env.Cat('fff.out', 'fff.in') -env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) -""") - -test.write(['SCCS', 'aaa.in'], "SCCS/aaa.in\n") -test.write('bbb.in', "checked-out bbb.in\n") -test.write(['SCCS', 'ccc.in'], "SCCS/ccc.in\n") - -test.write(['SCCS', 'sub', 'ddd.in'], "SCCS/sub/ddd.in\n") -test.write(['sub', 'eee.in'], "checked-out sub/eee.in\n") -test.write(['SCCS', 'sub', 'fff.in'], "SCCS/sub/fff.in\n") - -read_str = """\ -%(_python_)s my-sccs-get.py %(sub_SConscript)s -""" % locals() - -build_str = """\ -%(_python_)s my-sccs-get.py aaa.in -cat(["aaa.out"], ["aaa.in"]) -cat(["bbb.out"], ["bbb.in"]) -%(_python_)s my-sccs-get.py ccc.in -cat(["ccc.out"], ["ccc.in"]) -cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) -%(_python_)s my-sccs-get.py %(sub_ddd_in)s -cat(["%(sub_ddd_out)s"], ["%(sub_ddd_in)s"]) -cat(["%(sub_eee_out)s"], ["%(sub_eee_in)s"]) -%(_python_)s my-sccs-get.py %(sub_fff_in)s -cat(["%(sub_fff_out)s"], ["%(sub_fff_in)s"]) -cat(["%(sub_all)s"], ["%(sub_ddd_out)s", "%(sub_eee_out)s", "%(sub_fff_out)s"]) -""" % locals() - -stdout = test.wrap_stdout(read_str = read_str, build_str = build_str) - -test.run(arguments = '.', - stdout = TestSCons.re_escape(stdout), - stderr = warn_sccs + warn_sc) - -test.must_match('all', - "SCCS/aaa.in\nchecked-out bbb.in\nSCCS/ccc.in\n") - -test.must_match(['sub', 'all'], - "SCCS/sub/ddd.in\nchecked-out sub/eee.in\nSCCS/sub/fff.in\n") - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Deprecated/SourceCode/SCCS/SCCSCOMSTR.py b/test/Deprecated/SourceCode/SCCS/SCCSCOMSTR.py deleted file mode 100644 index 2351c05..0000000 --- a/test/Deprecated/SourceCode/SCCS/SCCSCOMSTR.py +++ /dev/null @@ -1,141 +0,0 @@ -#!/usr/bin/env python -# -# __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__" - -""" -Test customizing the output with the the $SCCSCOMSTR variable. -""" - -import os.path - -import TestSCons - -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) - -test.write('SConscript', """ -Environment(tools = ['SCCS']).SCCS() -""") - -msg_sccs = """The SCCS() factory is deprecated and there is no replacement.""" -warn_sccs = test.deprecated_fatal('deprecated-build-dir', msg_sccs) -msg_sc = """SourceCode() has been deprecated and there is no replacement. -\tIf you need this function, please contact scons-dev@scons.org""" -warn_sc = test.deprecated_wrap(msg_sc) - -test.subdir('SCCS', ['SCCS', 'sub'], 'sub') - -sub_SCCS = os.path.join('sub', 'SCCS') -sub_SConscript = os.path.join('sub', 'SConscript') -sub_all = os.path.join('sub', 'all') -sub_ddd_in = os.path.join('sub', 'ddd.in') -sub_ddd_out = os.path.join('sub', 'ddd.out') -sub_eee_in = os.path.join('sub', 'eee.in') -sub_eee_out = os.path.join('sub', 'eee.out') -sub_fff_in = os.path.join('sub', 'fff.in') -sub_fff_out = os.path.join('sub', 'fff.out') - -test.write('my-sccs-get.py', """ -import shutil -import sys -for f in sys.argv[1:]: - shutil.copy('SCCS/'+f, f) -""") - -test.write('SConstruct', """ -SetOption('warn', 'deprecated-source-code') -def cat(env, source, target): - target = str(target[0]) - f = open(target, "wb") - for src in source: - f.write(open(str(src), "rb").read()) - f.close() -env = Environment(tools = ['default', 'SCCS'], - BUILDERS={'Cat':Builder(action=cat)}, - SCCSCOM=r'%(_python_)s my-sccs-get.py $TARGET', - SCCSCOMSTR='Checking out $TARGET from our fake SCCS') -env.Cat('aaa.out', 'aaa.in') -env.Cat('bbb.out', 'bbb.in') -env.Cat('ccc.out', 'ccc.in') -env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) -env.SourceCode('.', env.SCCS()) -SConscript('sub/SConscript', "env") -""" % locals()) - -test.write(['SCCS', 'sub', 'SConscript'], """\ -Import("env") -env.Cat('ddd.out', 'ddd.in') -env.Cat('eee.out', 'eee.in') -env.Cat('fff.out', 'fff.in') -env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) -""") - -test.write(['SCCS', 'aaa.in'], "SCCS/aaa.in\n") -test.write('bbb.in', "checked-out bbb.in\n") -test.write(['SCCS', 'ccc.in'], "SCCS/ccc.in\n") - -test.write(['SCCS', 'sub', 'ddd.in'], "SCCS/sub/ddd.in\n") -test.write(['sub', 'eee.in'], "checked-out sub/eee.in\n") -test.write(['SCCS', 'sub', 'fff.in'], "SCCS/sub/fff.in\n") - -read_str = """\ -Checking out %(sub_SConscript)s from our fake SCCS -""" % locals() - -build_str = """\ -Checking out aaa.in from our fake SCCS -cat(["aaa.out"], ["aaa.in"]) -cat(["bbb.out"], ["bbb.in"]) -Checking out ccc.in from our fake SCCS -cat(["ccc.out"], ["ccc.in"]) -cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) -Checking out %(sub_ddd_in)s from our fake SCCS -cat(["%(sub_ddd_out)s"], ["%(sub_ddd_in)s"]) -cat(["%(sub_eee_out)s"], ["%(sub_eee_in)s"]) -Checking out %(sub_fff_in)s from our fake SCCS -cat(["%(sub_fff_out)s"], ["%(sub_fff_in)s"]) -cat(["%(sub_all)s"], ["%(sub_ddd_out)s", "%(sub_eee_out)s", "%(sub_fff_out)s"]) -""" % locals() - -stdout = test.wrap_stdout(read_str = read_str, build_str = build_str) - -test.run(arguments = '.', - stdout = TestSCons.re_escape(stdout), - stderr = warn_sccs + warn_sc) - -test.must_match('all', - "SCCS/aaa.in\nchecked-out bbb.in\nSCCS/ccc.in\n") - -test.must_match(['sub', 'all'], - "SCCS/sub/ddd.in\nchecked-out sub/eee.in\nSCCS/sub/fff.in\n") - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Deprecated/SourceCode/SCCS/diskcheck.py b/test/Deprecated/SourceCode/SCCS/diskcheck.py deleted file mode 100644 index 060c7a2..0000000 --- a/test/Deprecated/SourceCode/SCCS/diskcheck.py +++ /dev/null @@ -1,154 +0,0 @@ -#!/usr/bin/env python -# -# __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__" - -""" -Test transparent checkouts from SCCS files in an SCCS subdirectory. -""" - -import os - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConscript', """ -Environment(tools = ['SCCS']).SCCS() -""") - -msg_sccs = """The SCCS() factory is deprecated and there is no replacement.""" -warn_sccs = test.deprecated_fatal('deprecated-build-dir', msg_sccs) -msg_sc = """SourceCode() has been deprecated and there is no replacement. -\tIf you need this function, please contact scons-dev@scons.org""" -warn_sc = test.deprecated_wrap(msg_sc) - -sccs = test.where_is('sccs') -if not sccs: - test.skip_test("Could not find 'sccs'; skipping test(s).\n") - - -test.subdir('SCCS', 'sub', ['sub', 'SCCS']) - -for f in ['aaa.in', 'bbb.in', 'ccc.in']: - test.write(f, "%%F%% %s\n" % f) - args = "create %s" % f - test.run(program = sccs, arguments = args, stderr = None) - test.unlink(f) - test.unlink(','+f) - -test.write(['sub', 'SConscript'], """\ -# %%F%% -Import("env") -env.Cat('ddd.out', 'ddd.in') -env.Cat('eee.out', 'eee.in') -env.Cat('fff.out', 'fff.in') -env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) -""") -args = "create SConscript" -test.run(chdir = 'sub', program = sccs, arguments = args, stderr = None) -test.unlink(['sub', 'SConscript']) -test.unlink(['sub', ',SConscript']) - -for f in ['ddd.in', 'eee.in', 'fff.in']: - test.write(['sub', f], "%%F%% sub/%s\n" % f) - args = "create %s" % f - test.run(chdir = 'sub', program = sccs, arguments = args, stderr = None) - test.unlink(['sub', f]) - test.unlink(['sub', ','+f]) - -test.write(['SConstruct'], """ -SetOption('warn', 'deprecated-source-code') -DefaultEnvironment()['SCCSCOM'] = 'cd ${TARGET.dir} && $SCCS get ${TARGET.file}' -def cat(env, source, target): - target = str(target[0]) - f = open(target, "wb") - for src in source: - f.write(open(str(src), "rb").read()) - f.close() -SetOption('diskcheck', ['match', 'rcs']) -env = Environment(BUILDERS={'Cat':Builder(action=cat)}, - SCCSFLAGS='-k') -env.Cat('aaa.out', 'aaa.in') -env.Cat('bbb.out', 'bbb.in') -env.Cat('ccc.out', 'ccc.in') -env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) -SConscript('sub/SConscript', "env") -""") - -test.write(['bbb.in'], "checked-out bbb.in\n") - -test.write(['sub', 'eee.in'], "checked-out sub/eee.in\n") - -sub_SConscript = os.path.join('sub', 'SConscript') -SConstruct_file_line = test.python_file_line(test.workpath('SConstruct'), 17)[:-1] - -expect = """\ - -scons: warning: Ignoring missing SConscript '%(sub_SConscript)s' -%(SConstruct_file_line)s -scons: *** [aaa.out] Source `aaa.in' not found, needed by target `aaa.out'. -""" % locals() - -test.run(status=2, stderr=expect) - -test.run(arguments = '--diskcheck=sccs', stderr = None) - -lines = """ -sccs get SConscript -sccs get aaa.in -cat(["aaa.out"], ["aaa.in"]) -cat(["bbb.out"], ["bbb.in"]) -sccs get ccc.in -cat(["ccc.out"], ["ccc.in"]) -cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) -sccs get ddd.in -cat(["sub/ddd.out"], ["sub/ddd.in"]) -cat(["sub/eee.out"], ["sub/eee.in"]) -sccs get fff.in -cat(["sub/fff.out"], ["sub/fff.in"]) -cat(["sub/all"], ["sub/ddd.out", "sub/eee.out", "sub/fff.out"]) -""".split('\n') - -test.must_contain_all_lines(test.stdout(), lines) - -test.must_match('all', """\ -s.aaa.in aaa.in -checked-out bbb.in -s.ccc.in ccc.in -""") - -test.must_not_be_writable(test.workpath('sub', 'SConscript')) -test.must_not_be_writable(test.workpath('aaa.in')) -test.must_not_be_writable(test.workpath('ccc.in')) -test.must_not_be_writable(test.workpath('sub', 'ddd.in')) -test.must_not_be_writable(test.workpath('sub', 'fff.in')) - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Deprecated/SourceCode/SCCS/explicit.py b/test/Deprecated/SourceCode/SCCS/explicit.py deleted file mode 100644 index 3288425..0000000 --- a/test/Deprecated/SourceCode/SCCS/explicit.py +++ /dev/null @@ -1,136 +0,0 @@ -#!/usr/bin/env python -# -# __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__" - -""" -Test explicit checkouts from local SCCS files. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConscript', """ -Environment(tools = ['SCCS']).SCCS() -""") - -msg_sccs = """The SCCS() factory is deprecated and there is no replacement.""" -test.deprecated_fatal('deprecated-build-dir', msg_sccs) - -sccs = test.where_is('sccs') -if not sccs: - test.skip_test("Could not find 'sccs'; skipping test(s).\n") - - -test.subdir('SCCS', 'sub', ['sub', 'SCCS']) - -for f in ['aaa.in', 'bbb.in', 'ccc.in']: - test.write(f, "%%F%% %s\n" % f) - args = "create %s" % f - test.run(program = sccs, arguments = args, stderr = None) - test.unlink(f) - test.unlink(','+f) - -test.write(['sub', 'SConscript'], """\ -Import("env") -env.Cat('ddd.out', 'ddd.in') -env.Cat('eee.out', 'eee.in') -env.Cat('fff.out', 'fff.in') -env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) -""") -args = "create SConscript" -test.run(chdir = 'sub', program = sccs, arguments = args, stderr = None) -test.unlink(['sub', 'SConscript']) -test.unlink(['sub', ',SConscript']) - -for f in ['ddd.in', 'eee.in', 'fff.in']: - test.write(['sub', f], "%%F%% sub/%s\n" % f) - args = "create %s" % f - test.run(chdir = 'sub', program = sccs, arguments = args, stderr = None) - test.unlink(['sub', f]) - test.unlink(['sub', ','+f]) - -test.write('SConstruct', """ -SetOption('warn', 'deprecated-source-code') -def cat(env, source, target): - target = str(target[0]) - f = open(target, "wb") - for src in source: - f.write(open(str(src), "rb").read()) - f.close() -env = Environment(BUILDERS={'Cat':Builder(action=cat)}, - SCCSCOM = 'cd ${TARGET.dir} && $SCCS get $SCCSGETFLAGS ${TARGET.file}', - SCCSGETFLAGS='-e') -env.Cat('aaa.out', 'aaa.in') -env.Cat('bbb.out', 'bbb.in') -env.Cat('ccc.out', 'ccc.in') -env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) -env.SourceCode('.', env.SCCS()) -SConscript('sub/SConscript', "env") -""") - -test.write('bbb.in', "checked-out bbb.in\n") - -test.write(['sub', 'eee.in'], "checked-out sub/eee.in\n") - -test.run(arguments = '.', stderr = None) - -lines = """ -sccs get -e SConscript -sccs get -e aaa.in -cat(["aaa.out"], ["aaa.in"]) -cat(["bbb.out"], ["bbb.in"]) -sccs get -e ccc.in -cat(["ccc.out"], ["ccc.in"]) -cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) -sccs get -e ddd.in -cat(["sub/ddd.out"], ["sub/ddd.in"]) -cat(["sub/eee.out"], ["sub/eee.in"]) -sccs get -e fff.in -cat(["sub/fff.out"], ["sub/fff.in"]) -cat(["sub/all"], ["sub/ddd.out", "sub/eee.out", "sub/fff.out"]) -""".split('\n') - -test.must_contain_all_lines(test.stdout(), lines) - -test.must_match('all', """\ -%F% aaa.in -checked-out bbb.in -%F% ccc.in -""") - -test.must_be_writable(test.workpath('sub', 'SConscript')) -test.must_be_writable(test.workpath('aaa.in')) -test.must_be_writable(test.workpath('ccc.in')) -test.must_be_writable(test.workpath('sub', 'ddd.in')) -test.must_be_writable(test.workpath('sub', 'fff.in')) - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Deprecated/SourceCode/SCCS/implicit.py b/test/Deprecated/SourceCode/SCCS/implicit.py deleted file mode 100644 index b3fbf7a..0000000 --- a/test/Deprecated/SourceCode/SCCS/implicit.py +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/env python -# -# __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__" - -""" -Test transparent SCCS checkouts of implicit dependencies. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConscript', """ -Environment(tools = ['SCCS']).SCCS() -""") - -msg_sccs = """The SCCS() factory is deprecated and there is no replacement.""" -test.deprecated_fatal('deprecated-build-dir', msg_sccs) - -sccs = test.where_is('sccs') -if not sccs: - test.skip_test("Could not find 'sccs'; skipping test(s).\n") - - -test.subdir('SCCS') - -test.write('foo.c', """\ -/* %%F%% */ -#include "foo.h" -int -main(int argc, char *argv[]) { - printf(STR); - printf("foo.c\\n"); -} -""") -test.run(program = sccs, arguments = "create foo.c", stderr = None) -test.unlink('foo.c') -test.unlink(',foo.c') - -test.write('foo.h', """\ -#define STR "foo.h\\n" -""") -test.run(program = sccs, arguments = "create foo.h", stderr = None) -test.unlink('foo.h') -test.unlink(',foo.h') - -test.write('SConstruct', """ -DefaultEnvironment()['SCCSCOM'] = 'cd ${TARGET.dir} && $SCCS get ${TARGET.file}' -env = Environment() -env.Program('foo.c') -""") - -test.run(stderr = None) - -lines = """ -sccs get foo.c -sccs get foo.h -""".split('\n') - -test.must_contain_all_lines(test.stdout(), lines) - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Deprecated/SourceCode/SCCS/transparent.py b/test/Deprecated/SourceCode/SCCS/transparent.py deleted file mode 100644 index bc482d0..0000000 --- a/test/Deprecated/SourceCode/SCCS/transparent.py +++ /dev/null @@ -1,135 +0,0 @@ -#!/usr/bin/env python -# -# __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__" - -""" -Test transparent checkouts from SCCS files in an SCCS subdirectory. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConscript', """ -Environment(tools = ['SCCS']).SCCS() -""") - -msg_sccs = """The SCCS() factory is deprecated and there is no replacement.""" -test.deprecated_fatal('deprecated-build-dir', msg_sccs) - -sccs = test.where_is('sccs') -if not sccs: - test.skip_test("Could not find 'sccs'; skipping test(s).\n") - - -test.subdir('SCCS', 'sub', ['sub', 'SCCS']) - -for f in ['aaa.in', 'bbb.in', 'ccc.in']: - test.write(f, "%%F%% %s\n" % f) - args = "create %s" % f - test.run(program = sccs, arguments = args, stderr = None) - test.unlink(f) - test.unlink(','+f) - -test.write(['sub', 'SConscript'], """\ -# %%F%% -Import("env") -env.Cat('ddd.out', 'ddd.in') -env.Cat('eee.out', 'eee.in') -env.Cat('fff.out', 'fff.in') -env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) -""") -args = "create SConscript" -test.run(chdir = 'sub', program = sccs, arguments = args, stderr = None) -test.unlink(['sub', 'SConscript']) -test.unlink(['sub', ',SConscript']) - -for f in ['ddd.in', 'eee.in', 'fff.in']: - test.write(['sub', f], "%%F%% sub/%s\n" % f) - args = "create %s" % f - test.run(chdir = 'sub', program = sccs, arguments = args, stderr = None) - test.unlink(['sub', f]) - test.unlink(['sub', ','+f]) - -test.write(['SConstruct'], """ -DefaultEnvironment()['SCCSCOM'] = 'cd ${TARGET.dir} && $SCCS get ${TARGET.file}' -def cat(env, source, target): - target = str(target[0]) - f = open(target, "wb") - for src in source: - f.write(open(str(src), "rb").read()) - f.close() -env = Environment(BUILDERS={'Cat':Builder(action=cat)}, - SCCSFLAGS='-k') -env.Cat('aaa.out', 'aaa.in') -env.Cat('bbb.out', 'bbb.in') -env.Cat('ccc.out', 'ccc.in') -env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) -SConscript('sub/SConscript', "env") -""") - -test.write(['bbb.in'], "checked-out bbb.in\n") - -test.write(['sub', 'eee.in'], "checked-out sub/eee.in\n") - -test.run(arguments = '.', stderr = None) - -lines = """ -sccs get SConscript -sccs get aaa.in -cat(["aaa.out"], ["aaa.in"]) -cat(["bbb.out"], ["bbb.in"]) -sccs get ccc.in -cat(["ccc.out"], ["ccc.in"]) -cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) -sccs get ddd.in -cat(["sub/ddd.out"], ["sub/ddd.in"]) -cat(["sub/eee.out"], ["sub/eee.in"]) -sccs get fff.in -cat(["sub/fff.out"], ["sub/fff.in"]) -cat(["sub/all"], ["sub/ddd.out", "sub/eee.out", "sub/fff.out"]) -""".split('\n') - -test.must_contain_all_lines(test.stdout(), lines) - -test.must_match('all', """\ -s.aaa.in aaa.in -checked-out bbb.in -s.ccc.in ccc.in -""") - -test.must_not_be_writable(test.workpath('sub', 'SConscript')) -test.must_not_be_writable(test.workpath('aaa.in')) -test.must_not_be_writable(test.workpath('ccc.in')) -test.must_not_be_writable(test.workpath('sub', 'ddd.in')) -test.must_not_be_writable(test.workpath('sub', 'fff.in')) - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: -- cgit v0.12 From 8027163652ed32fdc467542fd80bf7056ca4c1fb Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 20 Mar 2017 11:03:08 -0700 Subject: Remove deprecated tool Subversion --- src/CHANGES.txt | 2 +- src/engine/SCons/Tool/Subversion.py | 70 ------------ src/engine/SCons/Tool/Subversion.xml | 135 ---------------------- src/engine/SCons/Tool/__init__.py | 2 - test/Deprecated/SourceCode/Subversion.py | 186 ------------------------------- 5 files changed, 1 insertion(+), 394 deletions(-) delete mode 100644 src/engine/SCons/Tool/Subversion.py delete mode 100644 src/engine/SCons/Tool/Subversion.xml delete mode 100644 test/Deprecated/SourceCode/Subversion.py diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 26018a2..50a5bec 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -30,7 +30,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Fixed SCons.Tool.Packaging.rpm.package source nondeterminism across builds. From William Deegan: - - Removed deprecated source code tool CVS, Perforce, BitKeeper, RCS, SCCS. + - Removed deprecated tools CVS, Perforce, BitKeeper, RCS, SCCS, Subversion. From Daniel Moody: - Fixed msvs.py for Visual Studio generated projects which were diff --git a/src/engine/SCons/Tool/Subversion.py b/src/engine/SCons/Tool/Subversion.py deleted file mode 100644 index f1b3708..0000000 --- a/src/engine/SCons/Tool/Subversion.py +++ /dev/null @@ -1,70 +0,0 @@ -"""SCons.Tool.Subversion.py - -Tool-specific initialization for Subversion. - -There normally shouldn't be any need to import this module directly. -It will usually be imported through the generic SCons.Tool.Tool() -selection method. - -""" - -# __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__" - -import os.path - -import SCons.Action -import SCons.Builder -import SCons.Util - -def generate(env): - """Add a Builder factory function and construction variables for - Subversion to an Environment.""" - - def SubversionFactory(repos, module='', env=env): - """ """ - # fail if repos is not an absolute path name? - import SCons.Warnings as W - W.warn(W.DeprecatedSourceCodeWarning, """The Subversion() factory is deprecated and there is no replacement.""") - if module != '': - module = os.path.join(module, '') - act = SCons.Action.Action('$SVNCOM', '$SVNCOMSTR') - return SCons.Builder.Builder(action = act, - env = env, - SVNREPOSITORY = repos, - SVNMODULE = module) - - env.Subversion = SubversionFactory - - env['SVN'] = 'svn' - env['SVNFLAGS'] = SCons.Util.CLVar('') - env['SVNCOM'] = '$SVN $SVNFLAGS cat $SVNREPOSITORY/$SVNMODULE$TARGET > $TARGET' - -def exists(env): - return env.Detect('svn') - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/src/engine/SCons/Tool/Subversion.xml b/src/engine/SCons/Tool/Subversion.xml deleted file mode 100644 index 7c851b5..0000000 --- a/src/engine/SCons/Tool/Subversion.xml +++ /dev/null @@ -1,135 +0,0 @@ - - - - -%scons; - -%builders-mod; - -%functions-mod; - -%tools-mod; - -%variables-mod; -]> - - - - - - - - - - - - - - diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index d9fb601..e44ae34 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -1156,8 +1156,6 @@ def tool_list(platform, env): 'tex', 'latex', 'pdflatex', 'pdftex', # Archivers 'tar', 'zip', - # SourceCode factories - # 'Subversion', ], env) tools = ([linker, c_compiler, cxx_compiler, diff --git a/test/Deprecated/SourceCode/Subversion.py b/test/Deprecated/SourceCode/Subversion.py deleted file mode 100644 index 7ed4b15..0000000 --- a/test/Deprecated/SourceCode/Subversion.py +++ /dev/null @@ -1,186 +0,0 @@ -#!/usr/bin/env python -# -# __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. -# -from __future__ import print_function - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -""" -Test fetching source files from Subversion. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConscript', """ -Environment(tools = ['Subversion']).Subversion('') -""") - -msg_svn = """The Subversion() factory is deprecated and there is no replacement.""" -warn_svn = test.deprecated_fatal('deprecated-build-dir', msg_svn) -msg_sc = """SourceCode() has been deprecated and there is no replacement. -\tIf you need this function, please contact scons-dev@scons.org""" -warn_sc = test.deprecated_wrap(msg_sc) - -svn = test.where_is('svn') -if not svn: - test.skip_test("Could not find 'svn'; skipping test(s).\n") - -svnadmin = test.where_is('svnadmin') -if not svn: - test.skip_test("Could not find 'svnadmin'; skipping test(s).\n") - -print("Short-circuiting this test until we support Subversion") -test.pass_test() - -test.subdir('Subversion', 'import', ['import', 'sub'], 'work1', 'work2') - -# Set up the Subversion repository. -svnrootpath = test.workpath('Subversion') -svnrooturl = 'file://' + svnrootpath - -test.run(program = svnadmin, arguments = 'create %s' % svnrootpath) - -test.write(['import', 'aaa.in'], "import/aaa.in\n") -test.write(['import', 'bbb.in'], "import/bbb.in\n") -test.write(['import', 'ccc.in'], "import/ccc.in\n") - -test.write(['import', 'sub', 'SConscript'], """\ -Import("env") -env.Cat('ddd.out', 'ddd.in') -env.Cat('eee.out', 'eee.in') -env.Cat('fff.out', 'fff.in') -env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) -""") - -test.write(['import', 'sub', 'ddd.in'], "import/sub/ddd.in\n") -test.write(['import', 'sub', 'eee.in'], "import/sub/eee.in\n") -test.write(['import', 'sub', 'fff.in'], "import/sub/fff.in\n") - -test.run(chdir = 'import', - program = svn, - arguments = 'import %s . foo -m"import foo"' % svnrooturl) - -# Test the most straightforward Subversion checkouts, using the module name. -test.write(['work1', 'SConstruct'], """ -SetOption('warn', 'deprecated-source-code') -def cat(env, source, target): - target = str(target[0]) - f = open(target, "wb") - for src in source: - f.write(open(str(src), "rb").read()) - f.close() -env = Environment(BUILDERS={'Cat':Builder(action=cat)}) -env.Cat('aaa.out', 'foo/aaa.in') -env.Cat('bbb.out', 'foo/bbb.in') -env.Cat('ccc.out', 'foo/ccc.in') -env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) -env.SourceCode('.', env.Subversion(r'%s')) -SConscript('foo/sub/SConscript', "env") -""" % svnrooturl) - -test.subdir(['work1', 'foo']) -test.write(['work1', 'foo', 'bbb.in'], "work1/foo/bbb.in\n") - -test.subdir(['work1', 'foo', 'sub']) -test.write(['work1', 'foo', 'sub', 'eee.in'], "work1/foo/sub/eee.in\n") - -test.run(chdir = 'work1', - arguments = '.', - stdout = test.wrap_stdout(read_str = """\ -svn cat %s/foo/sub/SConscript > foo/sub/SConscript -""" % (svnrooturl), - build_str = """\ -svn cat %s/foo/aaa.in > foo/aaa.in -cat("aaa.out", "foo/aaa.in") -cat("bbb.out", "foo/bbb.in") -svn cat %s/foo/ccc.in > foo/ccc.in -cat("ccc.out", "foo/ccc.in") -cat("all", ["aaa.out", "bbb.out", "ccc.out"]) -svn cat %s/foo/sub/ddd.in > foo/sub/ddd.in -cat("foo/sub/ddd.out", "foo/sub/ddd.in") -cat("foo/sub/eee.out", "foo/sub/eee.in") -svn cat %s/foo/sub/fff.in > foo/sub/fff.in -cat("foo/sub/fff.out", "foo/sub/fff.in") -cat("foo/sub/all", ["foo/sub/ddd.out", "foo/sub/eee.out", "foo/sub/fff.out"]) -""" % (svnrooturl, svnrooturl, svnrooturl, svnrooturl))) - -test.fail_test(test.read(['work1', 'all']) != "import/aaa.in\nwork1/foo/bbb.in\nimport/ccc.in\n") - -test.fail_test(test.read(['work1', 'foo', 'sub', 'all']) != "import/sub/ddd.in\nwork1/foo/sub/eee.in\nimport/sub/fff.in\n") - -# Test Subversion checkouts when the module name is specified. -test.write(['work2', 'SConstruct'], """ -SetOption('warn', 'deprecated-source-code') -def cat(env, source, target): - target = str(target[0]) - f = open(target, "wb") - for src in source: - f.write(open(str(src), "rb").read()) - f.close() -env = Environment(BUILDERS={'Cat':Builder(action=cat)}) -env.Cat('aaa.out', 'aaa.in') -env.Cat('bbb.out', 'bbb.in') -env.Cat('ccc.out', 'ccc.in') -env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) -env.SourceCode('.', env.Subversion(r'%s', 'foo')) -SConscript('sub/SConscript', "env") -""" % svnrooturl) - -test.write(['work2', 'bbb.in'], "work2/bbb.in\n") - -test.subdir(['work2', 'sub']) -test.write(['work2', 'sub', 'eee.in'], "work2/sub/eee.in\n") - -test.run(chdir = 'work2', - arguments = '.', - stdout = test.wrap_stdout(read_str = """\ -svn cat %s/foo/sub/SConscript > sub/SConscript -""" % (svnrooturl), - build_str = """\ -svn cat %s/foo/aaa.in > aaa.in -cat("aaa.out", "aaa.in") -cat("bbb.out", "bbb.in") -svn cat %s/foo/ccc.in > ccc.in -cat("ccc.out", "ccc.in") -cat("all", ["aaa.out", "bbb.out", "ccc.out"]) -svn cat %s/foo/sub/ddd.in > sub/ddd.in -cat("sub/ddd.out", "sub/ddd.in") -cat("sub/eee.out", "sub/eee.in") -svn cat %s/foo/sub/fff.in > sub/fff.in -cat("sub/fff.out", "sub/fff.in") -cat("sub/all", ["sub/ddd.out", "sub/eee.out", "sub/fff.out"]) -""" % (svnrooturl, svnrooturl, svnrooturl, svnrooturl))) - -test.fail_test(test.read(['work2', 'all']) != "import/aaa.in\nwork2/bbb.in\nimport/ccc.in\n") - -test.fail_test(test.read(['work2', 'sub', 'all']) != "import/sub/ddd.in\nwork2/sub/eee.in\nimport/sub/fff.in\n") - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: -- cgit v0.12 From d8b448824f85dba57bb1a971d596dcd096edfd65 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 20 Mar 2017 11:12:17 -0700 Subject: Update docs to remove deprecated sourcecode tools --- doc/generated/examples/caching_ex-random_1.xml | 6 +- doc/generated/examples/environments_ex3_1.xml | 22 +- doc/generated/examples/environments_missing2_1.xml | 2 +- .../examples/mergeflags_MergeFlags1_1.xml | 9 +- .../examples/mergeflags_MergeFlags2_1.xml | 9 +- .../examples/mergeflags_MergeFlags3_1.xml | 10 +- doc/generated/examples/misc_Flatten2_1.xml | 2 +- doc/generated/examples/parseflags_ex1_1.xml | 12 +- doc/generated/examples/parseflags_ex1_2.xml | 13 +- doc/generated/examples/parseflags_ex2_1.xml | 10 +- doc/generated/examples/parseflags_ex3_1.xml | 12 +- doc/generated/examples/parseflags_ex4_1.xml | 12 +- doc/generated/examples/troubleshoot_Dump_1.xml | 82 +------ doc/generated/examples/troubleshoot_Dump_2.xml | 114 +-------- doc/generated/examples/troubleshoot_Dump_ENV_1.xml | 12 +- doc/generated/examples/troubleshoot_Dump_ENV_2.xml | 14 +- doc/generated/examples/troubleshoot_explain1_3.xml | 2 +- .../examples/troubleshoot_stacktrace_2.xml | 4 +- doc/generated/functions.gen | 176 -------------- doc/generated/functions.mod | 16 -- doc/generated/tools.gen | 36 --- doc/generated/tools.mod | 8 - doc/generated/variables.gen | 257 +++------------------ doc/generated/variables.mod | 46 +--- 24 files changed, 141 insertions(+), 745 deletions(-) diff --git a/doc/generated/examples/caching_ex-random_1.xml b/doc/generated/examples/caching_ex-random_1.xml index 232e96f..d3ac996 100644 --- a/doc/generated/examples/caching_ex-random_1.xml +++ b/doc/generated/examples/caching_ex-random_1.xml @@ -1,9 +1,9 @@ % scons -Q -cc -o f4.o -c f4.c -cc -o f2.o -c f2.c cc -o f1.o -c f1.c -cc -o f5.o -c f5.c +cc -o f4.o -c f4.c cc -o f3.o -c f3.c +cc -o f5.o -c f5.c +cc -o f2.o -c f2.c cc -o prog f1.o f2.o f3.o f4.o f5.o diff --git a/doc/generated/examples/environments_ex3_1.xml b/doc/generated/examples/environments_ex3_1.xml index 3262302..0679aec 100644 --- a/doc/generated/examples/environments_ex3_1.xml +++ b/doc/generated/examples/environments_ex3_1.xml @@ -1,6 +1,22 @@ % scons -Q - -scons: *** Two environments with different actions were specified for the same target: foo.o -File "/home/my/project/SConstruct", line 6, in <module> +UnicodeDecodeError: 'utf8' codec can't decode byte 0xc2 in position 249: invalid continuation byte: + File "/home/my/project/SConstruct", line 6: + dbg.Program('foo', 'foo.c') + File "bootstrap/src/engine/SCons/Environment.py", line 260: + return MethodWrapper.__call__(self, target, source, *args, **kw) + File "bootstrap/src/engine/SCons/Environment.py", line 224: + return self.method(*nargs, **kwargs) + File "bootstrap/src/engine/SCons/Builder.py", line 632: + return self._execute(env, target, source, OverrideWarner(kw), ekw) + File "bootstrap/src/engine/SCons/Builder.py", line 540: + source = self.src_builder_sources(env, source, overwarn) + File "bootstrap/src/engine/SCons/Builder.py", line 745: + tlist = bld._execute(env, None, [s], overwarn) + File "bootstrap/src/engine/SCons/Builder.py", line 556: + _node_errors(self, env, tlist, slist) + File "bootstrap/src/engine/SCons/Builder.py", line 302: + msg = "Two environments with different actions were specified for the same target: %s\n(action 1: %s)\n(action 2: %s)" % (t,t_contents.decode('utf-8'),contents.decode('utf-8')) + File "/usr/lib/python2.7/encodings/utf_8.py", line 16: + return codecs.utf_8_decode(input, errors, True) diff --git a/doc/generated/examples/environments_missing2_1.xml b/doc/generated/examples/environments_missing2_1.xml index 019099f..ffb308c 100644 --- a/doc/generated/examples/environments_missing2_1.xml +++ b/doc/generated/examples/environments_missing2_1.xml @@ -1,6 +1,6 @@ % scons -Q -value is: + scons: *** NameError `MISSING' trying to evaluate `$MISSING' File "/home/my/project/SConstruct", line 3, in <module> diff --git a/doc/generated/examples/mergeflags_MergeFlags1_1.xml b/doc/generated/examples/mergeflags_MergeFlags1_1.xml index 8f18fd8..8a0c336 100644 --- a/doc/generated/examples/mergeflags_MergeFlags1_1.xml +++ b/doc/generated/examples/mergeflags_MergeFlags1_1.xml @@ -1,5 +1,10 @@ % scons -Q -['-option', '-O1', '-whatever', '-O3'] -scons: `.' is up to date. + File "/home/my/project/SConstruct", line 5 + + print env['CCFLAGS'] + + ^ + +SyntaxError: invalid syntax diff --git a/doc/generated/examples/mergeflags_MergeFlags2_1.xml b/doc/generated/examples/mergeflags_MergeFlags2_1.xml index 8cae827..1312c47 100644 --- a/doc/generated/examples/mergeflags_MergeFlags2_1.xml +++ b/doc/generated/examples/mergeflags_MergeFlags2_1.xml @@ -1,5 +1,10 @@ % scons -Q -['/include', '/usr/local/include', '/usr/include', '/usr/opt/include'] -scons: `.' is up to date. + File "/home/my/project/SConstruct", line 5 + + print env['CPPPATH'] + + ^ + +SyntaxError: invalid syntax diff --git a/doc/generated/examples/mergeflags_MergeFlags3_1.xml b/doc/generated/examples/mergeflags_MergeFlags3_1.xml index d4f23d4..8a0c336 100644 --- a/doc/generated/examples/mergeflags_MergeFlags3_1.xml +++ b/doc/generated/examples/mergeflags_MergeFlags3_1.xml @@ -1,6 +1,10 @@ % scons -Q -['-option', '-O1', '-whatever', '-O3'] -['/include', '/usr/local/include', '/usr/include', '/usr/opt/include'] -scons: `.' is up to date. + File "/home/my/project/SConstruct", line 5 + + print env['CCFLAGS'] + + ^ + +SyntaxError: invalid syntax diff --git a/doc/generated/examples/misc_Flatten2_1.xml b/doc/generated/examples/misc_Flatten2_1.xml index 58ffe6b..66161ec 100644 --- a/doc/generated/examples/misc_Flatten2_1.xml +++ b/doc/generated/examples/misc_Flatten2_1.xml @@ -2,5 +2,5 @@ % scons -Q AttributeError: 'NodeList' object has no attribute 'abspath': File "/home/my/project/SConstruct", line 8: - print object_file.abspath + print(object_file.abspath) diff --git a/doc/generated/examples/parseflags_ex1_1.xml b/doc/generated/examples/parseflags_ex1_1.xml index d6e4d96..79cdad6 100644 --- a/doc/generated/examples/parseflags_ex1_1.xml +++ b/doc/generated/examples/parseflags_ex1_1.xml @@ -1,8 +1,10 @@ % scons -Q -CPPPATH ['/opt/include'] -LIBPATH ['/opt/lib'] -LIBS ['foo'] -cc -o f1.o -c -I/opt/include f1.c -cc -o f1 f1.o -L/opt/lib -lfoo + File "/home/my/project/SConstruct", line 5 + + print k, v + + ^ + +SyntaxError: invalid syntax diff --git a/doc/generated/examples/parseflags_ex1_2.xml b/doc/generated/examples/parseflags_ex1_2.xml index 4c115d0..b9c9cd2 100644 --- a/doc/generated/examples/parseflags_ex1_2.xml +++ b/doc/generated/examples/parseflags_ex1_2.xml @@ -1,9 +1,10 @@ C:\>scons -Q -CPPPATH ['/opt/include'] -LIBPATH ['/opt/lib'] -LIBS ['foo'] -cl /Fof1.obj /c f1.c /nologo /I\opt\include -link /nologo /OUT:f1.exe /LIBPATH:\opt\lib foo.lib f1.obj -embedManifestExeCheck(target, source, env) + File "/home/my/project/SConstruct", line 5 + + print k, v + + ^ + +SyntaxError: invalid syntax diff --git a/doc/generated/examples/parseflags_ex2_1.xml b/doc/generated/examples/parseflags_ex2_1.xml index da84ee3..79cdad6 100644 --- a/doc/generated/examples/parseflags_ex2_1.xml +++ b/doc/generated/examples/parseflags_ex2_1.xml @@ -1,6 +1,10 @@ % scons -Q -CCFLAGS -whatever -cc -o f1.o -c -whatever f1.c -cc -o f1 f1.o + File "/home/my/project/SConstruct", line 5 + + print k, v + + ^ + +SyntaxError: invalid syntax diff --git a/doc/generated/examples/parseflags_ex3_1.xml b/doc/generated/examples/parseflags_ex3_1.xml index d6e4d96..79cdad6 100644 --- a/doc/generated/examples/parseflags_ex3_1.xml +++ b/doc/generated/examples/parseflags_ex3_1.xml @@ -1,8 +1,10 @@ % scons -Q -CPPPATH ['/opt/include'] -LIBPATH ['/opt/lib'] -LIBS ['foo'] -cc -o f1.o -c -I/opt/include f1.c -cc -o f1 f1.o -L/opt/lib -lfoo + File "/home/my/project/SConstruct", line 5 + + print k, v + + ^ + +SyntaxError: invalid syntax diff --git a/doc/generated/examples/parseflags_ex4_1.xml b/doc/generated/examples/parseflags_ex4_1.xml index d6e4d96..79cdad6 100644 --- a/doc/generated/examples/parseflags_ex4_1.xml +++ b/doc/generated/examples/parseflags_ex4_1.xml @@ -1,8 +1,10 @@ % scons -Q -CPPPATH ['/opt/include'] -LIBPATH ['/opt/lib'] -LIBS ['foo'] -cc -o f1.o -c -I/opt/include f1.c -cc -o f1 f1.o -L/opt/lib -lfoo + File "/home/my/project/SConstruct", line 5 + + print k, v + + ^ + +SyntaxError: invalid syntax diff --git a/doc/generated/examples/troubleshoot_Dump_1.xml b/doc/generated/examples/troubleshoot_Dump_1.xml index 99d1399..281fed7 100644 --- a/doc/generated/examples/troubleshoot_Dump_1.xml +++ b/doc/generated/examples/troubleshoot_Dump_1.xml @@ -1,79 +1,11 @@ % scons scons: Reading SConscript files ... -{ 'BUILDERS': {'_InternalInstall': <function InstallBuilderWrapper at 0x700000&gt;, '_InternalInstallVersionedLib': <function InstallVersionedBuilderWrapper at 0x700000&gt;, '_InternalInstallAs': <function InstallAsBuilderWrapper at 0x700000&gt;}, - 'CONFIGUREDIR': '#/.sconf_temp', - 'CONFIGURELOG': '#/config.log', - 'CPPSUFFIXES': [ '.c', - '.C', - '.cxx', - '.cpp', - '.c++', - '.cc', - '.h', - '.H', - '.hxx', - '.hpp', - '.hh', - '.F', - '.fpp', - '.FPP', - '.m', - '.mm', - '.S', - '.spp', - '.SPP', - '.sx'], - 'DSUFFIXES': ['.d'], - 'Dir': <SCons.Defaults.Variable_Method_Caller object at 0x700000&gt;, - 'Dirs': <SCons.Defaults.Variable_Method_Caller object at 0x700000&gt;, - 'ENV': { 'PATH': '/usr/local/bin:/opt/bin:/bin:/usr/bin'}, - 'ESCAPE': <function escape at 0x700000&gt;, - 'File': <SCons.Defaults.Variable_Method_Caller object at 0x700000&gt;, - 'HOST_ARCH': None, - 'HOST_OS': None, - 'IDLSUFFIXES': ['.idl', '.IDL'], - 'INSTALL': <function copyFunc at 0x700000&gt;, - 'INSTALLVERSIONEDLIB': <function copyFuncVersionedLib at 0x700000&gt;, - 'LIBPREFIX': 'lib', - 'LIBPREFIXES': ['$LIBPREFIX'], - 'LIBSUFFIX': '.a', - 'LIBSUFFIXES': ['$LIBSUFFIX', '$SHLIBSUFFIX'], - 'MAXLINELENGTH': 128072, - 'OBJPREFIX': '', - 'OBJSUFFIX': '.o', - 'PLATFORM': 'posix', - 'PROGPREFIX': '', - 'PROGSUFFIX': '', - 'PSPAWN': <function piped_env_spawn at 0x700000&gt;, - 'RDirs': <SCons.Defaults.Variable_Method_Caller object at 0x700000&gt;, - 'SCANNERS': [<SCons.Scanner.Base object at 0x700000&gt;], - 'SHELL': 'sh', - 'SHLIBPREFIX': '$LIBPREFIX', - 'SHLIBSUFFIX': '.so', - 'SHOBJPREFIX': '$OBJPREFIX', - 'SHOBJSUFFIX': '$OBJSUFFIX', - 'SPAWN': <function subprocess_spawn at 0x700000&gt;, - 'TARGET_ARCH': None, - 'TARGET_OS': None, - 'TEMPFILE': <class 'SCons.Platform.TempFileMunge'>, - 'TEMPFILEPREFIX': '@', - 'TOOLS': ['install', 'install'], - '_CPPDEFFLAGS': '${_defines(CPPDEFPREFIX, CPPDEFINES, CPPDEFSUFFIX, __env__)}', - '_CPPINCFLAGS': '$( ${_concat(INCPREFIX, CPPPATH, INCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)', - '_LIBDIRFLAGS': '$( ${_concat(LIBDIRPREFIX, LIBPATH, LIBDIRSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)', - '_LIBFLAGS': '${_concat(LIBLINKPREFIX, LIBS, LIBLINKSUFFIX, __env__)}', - '__DRPATH': '$_DRPATH', - '__DSHLIBVERSIONFLAGS': '${__libversionflags(__env__,"DSHLIBVERSION","_DSHLIBVERSIONFLAGS")}', - '__LDMODULEVERSIONFLAGS': '${__libversionflags(__env__,"LDMODULEVERSION","_LDMODULEVERSIONFLAGS")}', - '__RPATH': '$_RPATH', - '__SHLIBVERSIONFLAGS': '${__libversionflags(__env__,"SHLIBVERSION","_SHLIBVERSIONFLAGS")}', - '__libversionflags': <function __libversionflags at 0x700000&gt;, - '_concat': <function _concat at 0x700000&gt;, - '_defines': <function _defines at 0x700000&gt;, - '_stripixes': <function _stripixes at 0x700000&gt;} -scons: done reading SConscript files. -scons: Building targets ... -scons: `.' is up to date. -scons: done building targets. + File "/home/my/project/SConstruct", line 2 + + print env.Dump() + + ^ + +SyntaxError: invalid syntax diff --git a/doc/generated/examples/troubleshoot_Dump_2.xml b/doc/generated/examples/troubleshoot_Dump_2.xml index a621422..78cd84b 100644 --- a/doc/generated/examples/troubleshoot_Dump_2.xml +++ b/doc/generated/examples/troubleshoot_Dump_2.xml @@ -1,111 +1,11 @@ C:\>scons scons: Reading SConscript files ... -{ 'BUILDERS': {'_InternalInstallVersionedLib': <function InstallVersionedBuilderWrapper at 0x700000&gt;, '_InternalInstall': <function InstallBuilderWrapper at 0x700000&gt;, 'Object': <SCons.Builder.CompositeBuilder object at 0x700000&gt;, 'PCH': <SCons.Builder.BuilderBase object at 0x700000&gt;, 'RES': <SCons.Builder.BuilderBase object at 0x700000&gt;, 'SharedObject': <SCons.Builder.CompositeBuilder object at 0x700000&gt;, 'StaticObject': <SCons.Builder.CompositeBuilder object at 0x700000&gt;, '_InternalInstallAs': <function InstallAsBuilderWrapper at 0x700000&gt;}, - 'CC': 'cl', - 'CCCOM': <SCons.Action.FunctionAction object at 0x700000&gt;, - 'CCFLAGS': ['/nologo'], - 'CCPCHFLAGS': ['${(PCH and "/Yu%s \\"/Fp%s\\""%(PCHSTOP or "",File(PCH))) or ""}'], - 'CCPDBFLAGS': ['${(PDB and "/Z7") or ""}'], - 'CFILESUFFIX': '.c', - 'CFLAGS': [], - 'CONFIGUREDIR': '#/.sconf_temp', - 'CONFIGURELOG': '#/config.log', - 'CPPDEFPREFIX': '/D', - 'CPPDEFSUFFIX': '', - 'CPPSUFFIXES': [ '.c', - '.C', - '.cxx', - '.cpp', - '.c++', - '.cc', - '.h', - '.H', - '.hxx', - '.hpp', - '.hh', - '.F', - '.fpp', - '.FPP', - '.m', - '.mm', - '.S', - '.spp', - '.SPP', - '.sx'], - 'CXX': '$CC', - 'CXXCOM': '${TEMPFILE("$CXX $_MSVC_OUTPUT_FLAG /c $CHANGED_SOURCES $CXXFLAGS $CCFLAGS $_CCCOMCOM","$CXXCOMSTR")}', - 'CXXFILESUFFIX': '.cc', - 'CXXFLAGS': ['$(', '/TP', '$)'], - 'DSUFFIXES': ['.d'], - 'Dir': <SCons.Defaults.Variable_Method_Caller object at 0x700000&gt;, - 'Dirs': <SCons.Defaults.Variable_Method_Caller object at 0x700000&gt;, - 'ENV': { 'PATH': 'C:\\WINDOWS\\System32', - 'PATHEXT': '.COM;.EXE;.BAT;.CMD', - 'SystemRoot': 'C:\\WINDOWS'}, - 'ESCAPE': <function escape at 0x700000&gt;, - 'File': <SCons.Defaults.Variable_Method_Caller object at 0x700000&gt;, - 'HOST_ARCH': '', - 'HOST_OS': 'win32', - 'IDLSUFFIXES': ['.idl', '.IDL'], - 'INCPREFIX': '/I', - 'INCSUFFIX': '', - 'INSTALL': <function copyFunc at 0x700000&gt;, - 'INSTALLVERSIONEDLIB': <function copyFuncVersionedLib at 0x700000&gt;, - 'LIBPREFIX': '', - 'LIBPREFIXES': ['$LIBPREFIX'], - 'LIBSUFFIX': '.lib', - 'LIBSUFFIXES': ['$LIBSUFFIX'], - 'MAXLINELENGTH': 2048, - 'MSVC_SETUP_RUN': True, - 'OBJPREFIX': '', - 'OBJSUFFIX': '.obj', - 'PCHCOM': '$CXX /Fo${TARGETS[1]} $CXXFLAGS $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS /c $SOURCES /Yc$PCHSTOP /Fp${TARGETS[0]} $CCPDBFLAGS $PCHPDBFLAGS', - 'PCHPDBFLAGS': ['${(PDB and "/Yd") or ""}'], - 'PLATFORM': 'win32', - 'PROGPREFIX': '', - 'PROGSUFFIX': '.exe', - 'PSPAWN': <function piped_spawn at 0x700000&gt;, - 'RC': 'rc', - 'RCCOM': <SCons.Action.FunctionAction object at 0x700000&gt;, - 'RCFLAGS': [], - 'RCSUFFIXES': ['.rc', '.rc2'], - 'RDirs': <SCons.Defaults.Variable_Method_Caller object at 0x700000&gt;, - 'SCANNERS': [<SCons.Scanner.Base object at 0x700000&gt;], - 'SHCC': '$CC', - 'SHCCCOM': <SCons.Action.FunctionAction object at 0x700000&gt;, - 'SHCCFLAGS': ['$CCFLAGS'], - 'SHCFLAGS': ['$CFLAGS'], - 'SHCXX': '$CXX', - 'SHCXXCOM': '${TEMPFILE("$SHCXX $_MSVC_OUTPUT_FLAG /c $CHANGED_SOURCES $SHCXXFLAGS $SHCCFLAGS $_CCCOMCOM","$SHCXXCOMSTR")}', - 'SHCXXFLAGS': ['$CXXFLAGS'], - 'SHELL': None, - 'SHLIBPREFIX': '', - 'SHLIBSUFFIX': '.dll', - 'SHOBJPREFIX': '$OBJPREFIX', - 'SHOBJSUFFIX': '$OBJSUFFIX', - 'SPAWN': <function spawn at 0x700000&gt;, - 'STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME': 1, - 'TARGET_ARCH': None, - 'TARGET_OS': None, - 'TEMPFILE': <class 'SCons.Platform.TempFileMunge'>, - 'TEMPFILEPREFIX': '@', - 'TOOLS': ['msvc', 'install', 'install'], - '_CCCOMCOM': '$CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS $CCPCHFLAGS $CCPDBFLAGS', - '_CPPDEFFLAGS': '${_defines(CPPDEFPREFIX, CPPDEFINES, CPPDEFSUFFIX, __env__)}', - '_CPPINCFLAGS': '$( ${_concat(INCPREFIX, CPPPATH, INCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)', - '_LIBDIRFLAGS': '$( ${_concat(LIBDIRPREFIX, LIBPATH, LIBDIRSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)', - '_LIBFLAGS': '${_concat(LIBLINKPREFIX, LIBS, LIBLINKSUFFIX, __env__)}', - '_MSVC_OUTPUT_FLAG': <function msvc_output_flag at 0x700000&gt;, - '__DSHLIBVERSIONFLAGS': '${__libversionflags(__env__,"DSHLIBVERSION","_DSHLIBVERSIONFLAGS")}', - '__LDMODULEVERSIONFLAGS': '${__libversionflags(__env__,"LDMODULEVERSION","_LDMODULEVERSIONFLAGS")}', - '__SHLIBVERSIONFLAGS': '${__libversionflags(__env__,"SHLIBVERSION","_SHLIBVERSIONFLAGS")}', - '__libversionflags': <function __libversionflags at 0x700000&gt;, - '_concat': <function _concat at 0x700000&gt;, - '_defines': <function _defines at 0x700000&gt;, - '_stripixes': <function _stripixes at 0x700000&gt;} -scons: done reading SConscript files. -scons: Building targets ... -scons: `.' is up to date. -scons: done building targets. + File "/home/my/project/SConstruct", line 2 + + print env.Dump() + + ^ + +SyntaxError: invalid syntax diff --git a/doc/generated/examples/troubleshoot_Dump_ENV_1.xml b/doc/generated/examples/troubleshoot_Dump_ENV_1.xml index 786491f..bd674a6 100644 --- a/doc/generated/examples/troubleshoot_Dump_ENV_1.xml +++ b/doc/generated/examples/troubleshoot_Dump_ENV_1.xml @@ -1,9 +1,11 @@ % scons scons: Reading SConscript files ... -{ 'PATH': '/usr/local/bin:/opt/bin:/bin:/usr/bin'} -scons: done reading SConscript files. -scons: Building targets ... -scons: `.' is up to date. -scons: done building targets. + File "/home/my/project/SConstruct", line 2 + + print env.Dump('ENV') + + ^ + +SyntaxError: invalid syntax diff --git a/doc/generated/examples/troubleshoot_Dump_ENV_2.xml b/doc/generated/examples/troubleshoot_Dump_ENV_2.xml index eb6b735..c9f9258 100644 --- a/doc/generated/examples/troubleshoot_Dump_ENV_2.xml +++ b/doc/generated/examples/troubleshoot_Dump_ENV_2.xml @@ -1,11 +1,11 @@ C:\>scons scons: Reading SConscript files ... -{ 'PATH': 'C:\\WINDOWS\\System32', - 'PATHEXT': '.COM;.EXE;.BAT;.CMD', - 'SystemRoot': 'C:\\WINDOWS'} -scons: done reading SConscript files. -scons: Building targets ... -scons: `.' is up to date. -scons: done building targets. + File "/home/my/project/SConstruct", line 2 + + print env.Dump('ENV') + + ^ + +SyntaxError: invalid syntax diff --git a/doc/generated/examples/troubleshoot_explain1_3.xml b/doc/generated/examples/troubleshoot_explain1_3.xml index 3d8592d..36d9139 100644 --- a/doc/generated/examples/troubleshoot_explain1_3.xml +++ b/doc/generated/examples/troubleshoot_explain1_3.xml @@ -3,5 +3,5 @@ cp file.in file.oout scons: warning: Cannot find target file.out after building -File "/scons/as_scons/bootstrap/src/script/scons.py", line 199, in <module> +File "/home/bdbaddog/devel/scons/scons/src/script/scons.py", line 201, in <module> diff --git a/doc/generated/examples/troubleshoot_stacktrace_2.xml b/doc/generated/examples/troubleshoot_stacktrace_2.xml index add59ff..a86a5dd 100644 --- a/doc/generated/examples/troubleshoot_stacktrace_2.xml +++ b/doc/generated/examples/troubleshoot_stacktrace_2.xml @@ -4,9 +4,9 @@ scons: *** [prog.o] Source `prog.c' not found, needed by target `prog.o'. scons: internal stack trace: File "bootstrap/src/engine/SCons/Job.py", line 199, in start task.prepare() - File "bootstrap/src/engine/SCons/Script/Main.py", line 173, in prepare + File "bootstrap/src/engine/SCons/Script/Main.py", line 174, in prepare return SCons.Taskmaster.OutOfDateTask.prepare(self) - File "bootstrap/src/engine/SCons/Taskmaster.py", line 191, in prepare + File "bootstrap/src/engine/SCons/Taskmaster.py", line 195, in prepare executor.prepare() File "bootstrap/src/engine/SCons/Executor.py", line 430, in prepare raise SCons.Errors.StopError(msg % (s, self.batches[0].targets[0])) diff --git a/doc/generated/functions.gen b/doc/generated/functions.gen index d6e970a..8181d56 100644 --- a/doc/generated/functions.gen +++ b/doc/generated/functions.gen @@ -532,37 +532,6 @@ env.AppendUnique(CCFLAGS = '-g', FOO = ['foo.yyy']) - - - env.BitKeeper() - - - -A factory function that -returns a Builder object -to be used to fetch source files -using BitKeeper. -The returned Builder -is intended to be passed to the -SourceCode -function. - - - -This function is deprecated. For details, see the entry for the -SourceCode -function. - - - -Example: - - - -env.SourceCode('.', env.BitKeeper()) - - - BuildDir(build_dir, src_dir, [duplicate]) @@ -999,63 +968,6 @@ A now-deprecated synonym for - - - env.CVS(repository, module) - - - -A factory function that -returns a Builder object -to be used to fetch source files -from the specified -CVS -repository. -The returned Builder -is intended to be passed to the -SourceCode -function. - - - -This function is deprecated. For details, see the entry for the -SourceCode -function. - - - -The optional specified -module -will be added to the beginning -of all repository path names; -this can be used, in essence, -to strip initial directory names -from the repository path names, -so that you only have to -replicate part of the repository -directory hierarchy in your -local build directory. - - - -Examples: - - - -# Will fetch foo/bar/src.c -# from /usr/local/CVSROOT/foo/bar/src.c. -env.SourceCode('.', env.CVS('/usr/local/CVSROOT')) - -# Will fetch bar/src.c -# from /usr/local/CVSROOT/foo/bar/src.c. -env.SourceCode('.', env.CVS('/usr/local/CVSROOT', 'foo')) - -# Will fetch src.c -# from /usr/local/CVSROOT/foo/bar/src.c. -env.SourceCode('.', env.CVS('/usr/local/CVSROOT', 'foo/bar')) - - - Decider(function) @@ -3408,53 +3320,6 @@ Multiple targets can be passed in to a single call to - - - env.RCS() - - - -A factory function that -returns a Builder object -to be used to fetch source files -from RCS. -The returned Builder -is intended to be passed to the -SourceCode -function: - - - -This function is deprecated. For details, see the entry for the -SourceCode -function. - - - -Examples: - - - -env.SourceCode('.', env.RCS()) - - - -Note that -scons -will fetch source files -from RCS subdirectories automatically, -so configuring RCS -as demonstrated in the above example -should only be necessary if -you are fetching from -RCS,v -files in the same -directory as the source files, -or if you need to explicitly specify RCS -for a specific subdirectory. - - - env.Replace(key=val, [...]) @@ -3631,47 +3496,6 @@ below, for a complete explanation of the arguments and behavior. - - - env.SCCS() - - - -A factory function that -returns a Builder object -to be used to fetch source files -from SCCS. -The returned Builder -is intended to be passed to the -SourceCode -function. - - - -Example: - - - -env.SourceCode('.', env.SCCS()) - - - -Note that -scons -will fetch source files -from SCCS subdirectories automatically, -so configuring SCCS -as demonstrated in the above example -should only be necessary if -you are fetching from -s.SCCS -files in the same -directory as the source files, -or if you need to explicitly specify SCCS -for a specific subdirectory. - - - SConscript(scripts, [exports, variant_dir, duplicate]) diff --git a/doc/generated/functions.mod b/doc/generated/functions.mod index 03cef30..6183293 100644 --- a/doc/generated/functions.mod +++ b/doc/generated/functions.mod @@ -19,7 +19,6 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. Append"> AppendENVPath"> AppendUnique"> -BitKeeper"> BuildDir"> Builder"> CacheDir"> @@ -28,7 +27,6 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. Command"> Configure"> Copy"> -CVS"> Decider"> Default"> DefaultEnvironment"> @@ -71,13 +69,11 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. PrependUnique"> Progress"> Pseudo"> -RCS"> Replace"> Repository"> Requires"> Return"> Scanner"> -SCCS"> SConscript"> SConscriptChdir"> SConsignFile"> @@ -106,7 +102,6 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. env.Append"> env.AppendENVPath"> env.AppendUnique"> -env.BitKeeper"> env.BuildDir"> env.Builder"> env.CacheDir"> @@ -115,7 +110,6 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. env.Command"> env.Configure"> env.Copy"> -env.CVS"> env.Decider"> env.Default"> env.DefaultEnvironment"> @@ -158,13 +152,11 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. env.PrependUnique"> env.Progress"> env.Pseudo"> -env.RCS"> env.Replace"> env.Repository"> env.Requires"> env.Return"> env.Scanner"> -env.SCCS"> env.SConscript"> env.SConscriptChdir"> env.SConsignFile"> @@ -203,7 +195,6 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. Append"> AppendENVPath"> AppendUnique"> -BitKeeper"> BuildDir"> Builder"> CacheDir"> @@ -212,7 +203,6 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. Command"> Configure"> Copy"> -CVS"> Decider"> Default"> DefaultEnvironment"> @@ -255,13 +245,11 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. PrependUnique"> Progress"> Pseudo"> -RCS"> Replace"> Repository"> Requires"> Return"> Scanner"> -SCCS"> SConscript"> SConscriptChdir"> SConsignFile"> @@ -290,7 +278,6 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. env.Append"> env.AppendENVPath"> env.AppendUnique"> -env.BitKeeper"> env.BuildDir"> env.Builder"> env.CacheDir"> @@ -299,7 +286,6 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. env.Command"> env.Configure"> env.Copy"> -env.CVS"> env.Decider"> env.Default"> env.DefaultEnvironment"> @@ -342,13 +328,11 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. env.PrependUnique"> env.Progress"> env.Pseudo"> -env.RCS"> env.Replace"> env.Repository"> env.Requires"> env.Return"> env.Scanner"> -env.SCCS"> env.SConscript"> env.SConscriptChdir"> env.SConsignFile"> diff --git a/doc/generated/tools.gen b/doc/generated/tools.gen index 16aa688..f31b3f3 100644 --- a/doc/generated/tools.gen +++ b/doc/generated/tools.gen @@ -87,15 +87,6 @@ Sets construction variables for the bcc32 compiler. Sets: &cv-link-CC;, &cv-link-CCCOM;, &cv-link-CCFLAGS;, &cv-link-CFILESUFFIX;, &cv-link-CFLAGS;, &cv-link-CPPDEFPREFIX;, &cv-link-CPPDEFSUFFIX;, &cv-link-INCPREFIX;, &cv-link-INCSUFFIX;, &cv-link-SHCC;, &cv-link-SHCCCOM;, &cv-link-SHCCFLAGS;, &cv-link-SHCFLAGS;, &cv-link-SHOBJSUFFIX;.Uses: &cv-link-_CPPDEFFLAGS;, &cv-link-_CPPINCFLAGS;. - - BitKeeper - - -Sets construction variables for the BitKeeper -source code control system. - -Sets: &cv-link-BITKEEPER;, &cv-link-BITKEEPERCOM;, &cv-link-BITKEEPERGET;, &cv-link-BITKEEPERGETFLAGS;.Uses: &cv-link-BITKEEPERCOMSTR;. - cc @@ -112,15 +103,6 @@ Sets construction variables for the Compaq Visual Fortran compiler. Sets: &cv-link-FORTRAN;, &cv-link-FORTRANCOM;, &cv-link-FORTRANMODDIR;, &cv-link-FORTRANMODDIRPREFIX;, &cv-link-FORTRANMODDIRSUFFIX;, &cv-link-FORTRANPPCOM;, &cv-link-OBJSUFFIX;, &cv-link-SHFORTRANCOM;, &cv-link-SHFORTRANPPCOM;.Uses: &cv-link-CPPFLAGS;, &cv-link-FORTRANFLAGS;, &cv-link-SHFORTRANFLAGS;, &cv-link-_CPPDEFFLAGS;, &cv-link-_FORTRANINCFLAGS;, &cv-link-_FORTRANMODFLAG;. - - CVS - - -Sets construction variables for the CVS source code -management system. - -Sets: &cv-link-CVS;, &cv-link-CVSCOFLAGS;, &cv-link-CVSCOM;, &cv-link-CVSFLAGS;.Uses: &cv-link-CVSCOMSTR;. - cXX @@ -828,15 +810,6 @@ Sets construction variables for building Qt applications. Sets: &cv-link-QTDIR;, &cv-link-QT_AUTOSCAN;, &cv-link-QT_BINPATH;, &cv-link-QT_CPPPATH;, &cv-link-QT_LIB;, &cv-link-QT_LIBPATH;, &cv-link-QT_MOC;, &cv-link-QT_MOCCXXPREFIX;, &cv-link-QT_MOCCXXSUFFIX;, &cv-link-QT_MOCFROMCXXCOM;, &cv-link-QT_MOCFROMCXXFLAGS;, &cv-link-QT_MOCFROMHCOM;, &cv-link-QT_MOCFROMHFLAGS;, &cv-link-QT_MOCHPREFIX;, &cv-link-QT_MOCHSUFFIX;, &cv-link-QT_UIC;, &cv-link-QT_UICCOM;, &cv-link-QT_UICDECLFLAGS;, &cv-link-QT_UICDECLPREFIX;, &cv-link-QT_UICDECLSUFFIX;, &cv-link-QT_UICIMPLFLAGS;, &cv-link-QT_UICIMPLPREFIX;, &cv-link-QT_UICIMPLSUFFIX;, &cv-link-QT_UISUFFIX;. - - RCS - - -Sets construction variables for the interaction -with the Revision Control System. - -Sets: &cv-link-RCS;, &cv-link-RCS_CO;, &cv-link-RCS_COCOM;, &cv-link-RCS_COFLAGS;.Uses: &cv-link-RCS_COCOMSTR;. - rmic @@ -853,15 +826,6 @@ Sets construction variables for building with RPCGEN. Sets: &cv-link-RPCGEN;, &cv-link-RPCGENCLIENTFLAGS;, &cv-link-RPCGENFLAGS;, &cv-link-RPCGENHEADERFLAGS;, &cv-link-RPCGENSERVICEFLAGS;, &cv-link-RPCGENXDRFLAGS;. - - SCCS - - -Sets construction variables for interacting with the -Source Code Control System. - -Sets: &cv-link-SCCS;, &cv-link-SCCSCOM;, &cv-link-SCCSFLAGS;, &cv-link-SCCSGETFLAGS;.Uses: &cv-link-SCCSCOMSTR;. - sgiar diff --git a/doc/generated/tools.mod b/doc/generated/tools.mod index 9fccf32..bf552c3 100644 --- a/doc/generated/tools.mod +++ b/doc/generated/tools.mod @@ -17,10 +17,8 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. ar"> as"> bcc32"> -BitKeeper"> cc"> cvf"> -CVS"> cXX"> cyglink"> default"> @@ -84,10 +82,8 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. pdflatex"> pdftex"> qt"> -RCS"> rmic"> rpcgen"> -SCCS"> sgiar"> sgic++"> sgicc"> @@ -127,10 +123,8 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. ar"> as"> bcc32"> -BitKeeper"> cc"> cvf"> -CVS"> cXX"> cyglink"> default"> @@ -194,10 +188,8 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. pdflatex"> pdftex"> qt"> -RCS"> rmic"> rpcgen"> -SCCS"> sgiar"> sgic++"> sgicc"> diff --git a/doc/generated/variables.gen b/doc/generated/variables.gen index add620c..d2bced9 100644 --- a/doc/generated/variables.gen +++ b/doc/generated/variables.gen @@ -205,53 +205,6 @@ and typesetter and the LaTeX structured formatter and typesetter. - - BITKEEPER - - -The BitKeeper executable. - - - - - BITKEEPERCOM - - -The command line for -fetching source files using BitKeeper. - - - - - BITKEEPERCOMSTR - - -The string displayed when fetching -a source file using BitKeeper. -If this is not set, then $BITKEEPERCOM -(the command line) is displayed. - - - - - BITKEEPERGET - - -The command ($BITKEEPER) and subcommand -for fetching source files using BitKeeper. - - - - - BITKEEPERGETFLAGS - - -Options that are passed to the BitKeeper -get -subcommand. - - - BUILDERS @@ -742,63 +695,6 @@ The default list is: - - CVS - - -The CVS executable. - - - - - CVSCOFLAGS - - -Options that are passed to the CVS checkout subcommand. - - - - - CVSCOM - - -The command line used to -fetch source files from a CVS repository. - - - - - CVSCOMSTR - - -The string displayed when fetching -a source file from a CVS repository. -If this is not set, then $CVSCOM -(the command line) is displayed. - - - - - CVSFLAGS - - -General options that are passed to CVS. -By default, this is set to --d $CVSREPOSITORY -to specify from where the files must be fetched. - - - - - CVSREPOSITORY - - -The path to the CVS repository. -This is referenced in the default -$CVSFLAGS value. - - - CXX @@ -2838,15 +2734,6 @@ is -dNOPAUSE -dBATCH -sDEVICE=pdfwrite HOST_ARCH - The name of the host hardware architecture used to create the Environment. - If a platform is specified when creating the Environment, then - that Platform's logic will handle setting this value. - This value is immutable, and should not be changed by the user after - the Environment is initialized. - Currently only set for Win32. - - - Sets the host architecture for Visual Studio compiler. If not set, default to the detected host architecture: note that this may depend on the python you are using. @@ -2862,7 +2749,16 @@ Valid values are the same as for This is currently only used on Windows, but in the future it will be used on other OSes as well. - + + + The name of the host hardware architecture used to create the Environment. + If a platform is specified when creating the Environment, then + that Platform's logic will handle setting this value. + This value is immutable, and should not be changed by the user after + the Environment is initialized. + Currently only set for Win32. + + HOST_OS @@ -5504,56 +5400,6 @@ when the $RCINCFLAGS vari - - RCS - - -The RCS executable. -Note that this variable is not actually used -for the command to fetch source files from RCS; -see the -$RCS_CO -construction variable, below. - - - - - RCS_CO - - -The RCS "checkout" executable, -used to fetch source files from RCS. - - - - - RCS_COCOM - - -The command line used to -fetch (checkout) source files from RCS. - - - - - RCS_COCOMSTR - - -The string displayed when fetching -a source file from RCS. -If this is not set, then $RCS_COCOM -(the command line) is displayed. - - - - - RCS_COFLAGS - - -Options that are passed to the $RCS_CO command. - - - RDirs @@ -5784,53 +5630,6 @@ below, for more information. - - SCCS - - -The SCCS executable. - - - - - SCCSCOM - - -The command line used to -fetch source files from SCCS. - - - - - SCCSCOMSTR - - -The string displayed when fetching -a source file from a CVS repository. -If this is not set, then $SCCSCOM -(the command line) is displayed. - - - - - SCCSFLAGS - - -General options that are passed to SCCS. - - - - - SCCSGETFLAGS - - -Options that are passed specifically to the SCCS "get" subcommand. -This can be set, for example, to - -to check out editable files from SCCS. - - - SCONS_HOME The @@ -6518,6 +6317,16 @@ Example + + SHLIBVERSIONFLAGS + + +Extra flags added to $SHLINKCOM when building versioned +SharedLibrary. These flags are only used when $SHLIBVERSION is +set. + + + _SHLIBVERSIONFLAGS @@ -6531,16 +6340,6 @@ and some extra dynamically generated options (such as - - SHLIBVERSIONFLAGS - - -Extra flags added to $SHLINKCOM when building versioned -SharedLibrary. These flags are only used when $SHLIBVERSION is -set. - - - SHLINK @@ -7003,13 +6802,6 @@ that may not be set or used in a construction environment. TARGET_ARCH - The name of the target hardware architecture for the compiled objects - created by this Environment. - This defaults to the value of HOST_ARCH, and the user can override it. - Currently only set for Win32. - - - Sets the target architecture for Visual Studio compiler (i.e. the arch of the binaries generated by the compiler). If not set, default to $HOST_ARCH, or, if that is unset, to the architecture of the @@ -7034,7 +6826,14 @@ and ia64 (Itanium). For example, if you want to compile 64-bit binaries, you would set TARGET_ARCH='x86_64' in your SCons environment. - + + + The name of the target hardware architecture for the compiled objects + created by this Environment. + This defaults to the value of HOST_ARCH, and the user can override it. + Currently only set for Win32. + + TARGET_OS diff --git a/doc/generated/variables.mod b/doc/generated/variables.mod index 6ec13f7..d176319 100644 --- a/doc/generated/variables.mod +++ b/doc/generated/variables.mod @@ -26,11 +26,6 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. $BIBTEXCOM"> $BIBTEXCOMSTR"> $BIBTEXFLAGS"> -$BITKEEPER"> -$BITKEEPERCOM"> -$BITKEEPERCOMSTR"> -$BITKEEPERGET"> -$BITKEEPERGETFLAGS"> $BUILDERS"> $CC"> $CCCOM"> @@ -56,12 +51,6 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. $_CPPINCFLAGS"> $CPPPATH"> $CPPSUFFIXES"> -$CVS"> -$CVSCOFLAGS"> -$CVSCOM"> -$CVSCOMSTR"> -$CVSFLAGS"> -$CVSREPOSITORY"> $CXX"> $CXXCOM"> $CXXCOMSTR"> @@ -429,11 +418,6 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. $RCINCFLAGS"> $RCINCPREFIX"> $RCINCSUFFIX"> -$RCS"> -$RCS_CO"> -$RCS_COCOM"> -$RCS_COCOMSTR"> -$RCS_COFLAGS"> $RDirs"> $REGSVR"> $REGSVRCOM"> @@ -454,11 +438,6 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. $RPCGENSERVICEFLAGS"> $RPCGENXDRFLAGS"> $SCANNERS"> -$SCCS"> -$SCCSCOM"> -$SCCSCOMSTR"> -$SCCSFLAGS"> -$SCCSGETFLAGS"> $SCONS_HOME"> $SHCC"> $SHCCCOM"> @@ -517,8 +496,8 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. $_SHLIBSONAME"> $SHLIBSUFFIX"> $SHLIBVERSION"> -$_SHLIBVERSIONFLAGS"> $SHLIBVERSIONFLAGS"> +$_SHLIBVERSIONFLAGS"> $SHLINK"> $SHLINKCOM"> $SHLINKCOMSTR"> @@ -676,11 +655,6 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. $BIBTEXCOM"> $BIBTEXCOMSTR"> $BIBTEXFLAGS"> -$BITKEEPER"> -$BITKEEPERCOM"> -$BITKEEPERCOMSTR"> -$BITKEEPERGET"> -$BITKEEPERGETFLAGS"> $BUILDERS"> $CC"> $CCCOM"> @@ -706,12 +680,6 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. $_CPPINCFLAGS"> $CPPPATH"> $CPPSUFFIXES"> -$CVS"> -$CVSCOFLAGS"> -$CVSCOM"> -$CVSCOMSTR"> -$CVSFLAGS"> -$CVSREPOSITORY"> $CXX"> $CXXCOM"> $CXXCOMSTR"> @@ -1079,11 +1047,6 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. $RCINCFLAGS"> $RCINCPREFIX"> $RCINCSUFFIX"> -$RCS"> -$RCS_CO"> -$RCS_COCOM"> -$RCS_COCOMSTR"> -$RCS_COFLAGS"> $RDirs"> $REGSVR"> $REGSVRCOM"> @@ -1104,11 +1067,6 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. $RPCGENSERVICEFLAGS"> $RPCGENXDRFLAGS"> $SCANNERS"> -$SCCS"> -$SCCSCOM"> -$SCCSCOMSTR"> -$SCCSFLAGS"> -$SCCSGETFLAGS"> $SCONS_HOME"> $SHCC"> $SHCCCOM"> @@ -1167,8 +1125,8 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. $_SHLIBSONAME"> $SHLIBSUFFIX"> $SHLIBVERSION"> -$_SHLIBVERSIONFLAGS"> $SHLIBVERSIONFLAGS"> +$_SHLIBVERSIONFLAGS"> $SHLINK"> $SHLINKCOM"> $SHLINKCOMSTR"> -- cgit v0.12 From 4c83816c2bdd84cc67a6935142b99312416f25d6 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 20 Mar 2017 15:18:31 -0700 Subject: added mode='r' for must_matches, and for one case added mode='w' for source file failing to compile with compiler complaining about mac formatted file --- test/Default.py | 61 ++++++++++++++++++++++++------------------------------- test/srcchange.py | 2 +- test/subdir.py | 8 ++++---- 3 files changed, 31 insertions(+), 40 deletions(-) diff --git a/test/Default.py b/test/Default.py index e9ca96a..05944a6 100644 --- a/test/Default.py +++ b/test/Default.py @@ -36,13 +36,10 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() -for dir in ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight']: - - test.subdir(dir) - - test.write(os.path.join(dir, 'foo.in'), dir + "/foo.in\n"); - - test.write(os.path.join(dir, 'bar.in'), dir + "/bar.in\n"); +for dirname in ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight']: + test.subdir(dirname) + test.write(os.path.join(dirname, 'foo.in'), dirname + "/foo.in\n") + test.write(os.path.join(dirname, 'bar.in'), dirname + "/bar.in\n") test.write('build.py', r""" import sys @@ -94,26 +91,24 @@ Default(env.B(target = 'bar.out', source = 'bar.in')) """ % locals()) -for dir in ['one', 'two', 'three', 'four', 'five']: +for dirname in ['one', 'two', 'three', 'four', 'five']: + test.run(chdir=dirname) # no arguments, use the Default - test.run(chdir = dir) # no arguments, use the Default - -test.must_match(test.workpath('one', 'foo.out'), "one/foo.in\n") +test.must_match(test.workpath('one', 'foo.out'), "one/foo.in\n", mode='r') test.fail_test(os.path.exists(test.workpath('one', 'bar'))) -test.must_match(test.workpath('two', 'foo.out'), "two/foo.in\n") -test.must_match(test.workpath('two', 'bar.out'), "two/bar.in\n") +test.must_match(test.workpath('two', 'foo.out'), "two/foo.in\n", mode='r') +test.must_match(test.workpath('two', 'bar.out'), "two/bar.in\n", mode='r') -test.must_match(test.workpath('three', 'foo.out'), "three/foo.in\n") -test.must_match(test.workpath('three', 'bar.out'), "three/bar.in\n") +test.must_match(test.workpath('three', 'foo.out'), "three/foo.in\n", mode='r') +test.must_match(test.workpath('three', 'bar.out'), "three/bar.in\n", mode='r') test.fail_test(os.path.exists(test.workpath('four', 'foo'))) test.fail_test(os.path.exists(test.workpath('four', 'bar'))) -test.must_match(test.workpath('four', 'foo bar'), "four/foo.in\n") - -test.must_match(test.workpath('five', 'foo.out'), "five/foo.in\n") -test.must_match(test.workpath('five', 'bar.out'), "five/bar.in\n") +test.must_match(test.workpath('four', 'foo bar'), "four/foo.in\n", mode='r') +test.must_match(test.workpath('five', 'foo.out'), "five/foo.in\n", mode='r') +test.must_match(test.workpath('five', 'bar.out'), "five/bar.in\n", mode='r') # Test how a None Default() argument works to disable/reset default targets. @@ -125,8 +120,8 @@ bar = env.B(target = 'bar.out', source = 'bar.in') Default(None) """ % locals()) -test.run(chdir = 'six', status = 2, stderr = -"scons: *** No targets specified and no Default() targets found. Stop.\n") +test.run(chdir='six', status=2, + stderr="scons: *** No targets specified and no Default() targets found. Stop.\n") test.write(['seven', 'SConstruct'], """\ B = Builder(action = r'%(_python_)s ../build.py $TARGET $SOURCES') @@ -136,8 +131,8 @@ bar = env.B(target = 'bar.out', source = 'bar.in') Default(foo, bar, None) """ % locals()) -test.run(chdir = 'seven', status = 2, stderr = -"scons: *** No targets specified and no Default() targets found. Stop.\n") +test.run(chdir='seven', status=2, + stderr="scons: *** No targets specified and no Default() targets found. Stop.\n") test.write(['eight', 'SConstruct'], """\ B = Builder(action = r'%(_python_)s ../build.py $TARGET $SOURCES') @@ -147,12 +142,10 @@ bar = env.B(target = 'bar.out', source = 'bar.in') Default(foo, None, bar) """ % locals()) -test.run(chdir = 'eight') # no arguments, use the Default +test.run(chdir='eight') # no arguments, use the Default test.fail_test(os.path.exists(test.workpath('eight', 'foo.out'))) -test.must_match(test.workpath('eight', 'bar.out'), "eight/bar.in\n") - - +test.must_match(test.workpath('eight', 'bar.out'), "eight/bar.in\n", mode='r') test.subdir('nine', ['nine', 'sub1']) @@ -175,11 +168,10 @@ Default('xxx.out') test.write(['nine', 'sub1', 'xxx.in'], "sub1/xxx.in\n") -test.run(chdir = 'nine') # no arguments, use the Default +test.run(chdir='nine') # no arguments, use the Default test.fail_test(os.path.exists(test.workpath('nine', 'xxx.out'))) -test.must_match(test.workpath('nine', 'sub1', 'xxx.out'), "sub1/xxx.in\n") - +test.must_match(test.workpath('nine', 'sub1', 'xxx.out'), "sub1/xxx.in\n", mode='r') test.subdir('ten', ['ten', 'sub2']) @@ -202,10 +194,10 @@ env.B(target = 'xxx.out', source = 'xxx.in') test.write(['ten', 'sub2', 'xxx.in'], "sub2/xxx.in\n") -test.run(chdir = 'ten') # no arguments, use the Default +test.run(chdir='ten') # no arguments, use the Default test.fail_test(os.path.exists(test.workpath('ten', 'xxx.out'))) -test.must_match(test.workpath('ten', 'sub2', 'xxx.out'), "sub2/xxx.in\n") +test.must_match(test.workpath('ten', 'sub2', 'xxx.out'), "sub2/xxx.in\n", mode='r') test.subdir('eleven') @@ -222,13 +214,12 @@ test.write(os.path.join('eleven', 'foo.in'), "eleven/foo.in\n") test.write(os.path.join('eleven', 'bar.in'), "eleven/bar.in\n") -test.run(chdir = 'eleven') # no arguments, use the Default +test.run(chdir='eleven') # no arguments, use the Default -test.must_match(test.workpath('eleven', 'foo.out'), "eleven/foo.in\n") +test.must_match(test.workpath('eleven', 'foo.out'), "eleven/foo.in\n", mode='r') test.fail_test(os.path.exists(test.workpath('eleven', 'bar'))) - test.pass_test() # Local Variables: diff --git a/test/srcchange.py b/test/srcchange.py index bef3589..f9e1523 100644 --- a/test/srcchange.py +++ b/test/srcchange.py @@ -103,7 +103,7 @@ test.must_exist(program_name) test.run(arguments='.', stdout=light_build) test.must_exist(program_name) -test.write('revnum.in', '3.3\n') +test.write('revnum.in', '3.3\n', mode='w') test.run(arguments='.') test.must_exist(program_name) diff --git a/test/subdir.py b/test/subdir.py index 67e8450..9a8b762 100644 --- a/test/subdir.py +++ b/test/subdir.py @@ -57,10 +57,10 @@ test.write(['subdir', 'f4.in'], "f4.in\n") test.run(arguments = 'subdir') -test.must_match(['subdir', 'f1.out'], "f1.in\n") -test.must_match(['subdir', 'f2.out'], "f2.in\n") -test.must_match(['subdir', 'f3.out'], "f3.in\n") -test.must_match(['subdir', 'f4.out'], "f4.in\n") +test.must_match(['subdir', 'f1.out'], "f1.in\n", mode='r') +test.must_match(['subdir', 'f2.out'], "f2.in\n", mode='r') +test.must_match(['subdir', 'f3.out'], "f3.in\n", mode='r') +test.must_match(['subdir', 'f4.out'], "f4.in\n", mode='r') test.up_to_date(arguments = 'subdir') -- cgit v0.12 From 001262877b19faabc0ad0f45d4abd1d8cfc38093 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 20 Mar 2017 16:04:50 -0700 Subject: py2/3 fixed binary/str issue, but test is still failing on py3 with _action signature changing. Need to investigate --- src/engine/SCons/Tool/textfile.py | 2 +- test/textfile.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/engine/SCons/Tool/textfile.py b/src/engine/SCons/Tool/textfile.py index e79badf..5ea2344 100644 --- a/src/engine/SCons/Tool/textfile.py +++ b/src/engine/SCons/Tool/textfile.py @@ -106,7 +106,7 @@ def _action(target, source, env): # write the file try: - fd = open(target[0].get_path(), "wb") + fd = open(target[0].get_path(), "w") except (OSError,IOError) as e: raise SCons.Errors.UserError("Can't write target file %s" % target[0]) # separate lines by 'linesep' only if linesep is not empty diff --git a/test/textfile.py b/test/textfile.py index 64f8605..3d336c6 100644 --- a/test/textfile.py +++ b/test/textfile.py @@ -130,7 +130,7 @@ s = env.Substfile('sub4', t, SUBST_DICT = sub2) s = env.Substfile('sub5', s, SUBST_DICT = sub1) # both s = env.Substfile('sub6', t, SUBST_DICT = sub3) -""") +""", mode='w') test.run(arguments = '.') @@ -142,7 +142,7 @@ line3b = 'This line has many substitutions' def matchem(file, lines): lines = os.linesep.join(lines) - test.must_match(file, lines) + test.must_match(file, lines, mode='r') matchem('text.txt', [line1, line2a, line3a]) matchem('sub1', [line1, line2a, line3a]) @@ -152,6 +152,6 @@ matchem('sub4', [line1, line2a, line3b]) matchem('sub5', [line1, line2b, line3b]) matchem('sub6', [line1, line2b, line3b]) -test.up_to_date(arguments = '.') +test.up_to_date(arguments = '. --debug=explain') test.pass_test() -- cgit v0.12 From 43464c5aafe4cbeb950dfda6c7ec33d472a6149a Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 20 Mar 2017 16:14:51 -0700 Subject: py2/3 to fix this test required several files/compares to be binary. --- test/redirection.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/test/redirection.py b/test/redirection.py index 98bfc04..cc8ebf9 100644 --- a/test/redirection.py +++ b/test/redirection.py @@ -33,10 +33,15 @@ test = TestSCons.TestSCons() test.write('cat.py', r""" import sys try: - input = open(sys.argv[1], 'r').read() + input = open(sys.argv[1], 'rb').read() + try: + sys.stdout.buffer.write(input) + except AttributeError: + sys.stdout.write(input) except IndexError: input = sys.stdin.read() -sys.stdout.write(input) + sys.stdout.write(input) + sys.exit(0) """) @@ -52,17 +57,17 @@ env.Command(target='foo4', source='bar4', action=r'%(_python_)s cat.py <$SOURCES |%(_python_)s cat.py >$TARGET') """ % locals()) -test.write('bar1', 'bar1\r\n') -test.write('bar2', 'bar2\r\n') -test.write('bar3', 'bar3\r\n') -test.write('bar4', 'bar4\r\n') +test.write('bar1', 'bar1\r\n', mode='w') +test.write('bar2', 'bar2\r\n', mode='w') +test.write('bar3', 'bar3\r\n', mode='w') +test.write('bar4', 'bar4\r\n', mode='w') test.run(arguments='.') -test.fail_test(test.read('foo1') != 'bar1\r\n') -test.fail_test(test.read('foo2') != 'bar2\r\n') -test.fail_test(test.read('foo3') != 'bar3\r\n') -test.fail_test(test.read('foo4') != 'bar4\r\n') +test.must_match('foo1', 'bar1\r\n') +test.must_match('foo2', 'bar2\r\n') +test.must_match('foo3', 'bar3\r\n') +test.must_match('foo4', 'bar4\r\n') test.pass_test() -- cgit v0.12 From 871e8747323c362ddbe01dc03323f775430c944a Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 20 Mar 2017 16:57:34 -0700 Subject: py3. Fix vendor specific compilers importing c++ module, instead of cxx. c++ is no longer legal module name in py3 --- src/engine/SCons/Tool/__init__.py | 18 +++++++++--------- src/engine/SCons/Tool/aixcxx.py | 4 +++- src/engine/SCons/Tool/aixlink.py | 5 ++++- src/engine/SCons/Tool/hpcxx.py | 5 ++++- src/engine/SCons/Tool/sgicxx.py | 5 ++++- src/engine/SCons/Tool/suncxx.py | 4 +++- test/textfile.py | 2 +- 7 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index e44ae34..c57a93b 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -1040,7 +1040,7 @@ def tool_list(platform, env): "prefer Microsoft tools on Windows" linkers = ['mslink', 'gnulink', 'ilink', 'linkloc', 'ilink32' ] c_compilers = ['msvc', 'mingw', 'gcc', 'intelc', 'icl', 'icc', 'cc', 'bcc32' ] - cxx_compilers = ['msvc', 'intelc', 'icc', 'g++', 'c++', 'bcc32' ] + cxx_compilers = ['msvc', 'intelc', 'icc', 'g++', 'cxx', 'bcc32' ] assemblers = ['masm', 'nasm', 'gas', '386asm' ] fortran_compilers = ['gfortran', 'g77', 'ifl', 'cvf', 'f95', 'f90', 'fortran'] ars = ['mslib', 'ar', 'tlib'] @@ -1049,7 +1049,7 @@ def tool_list(platform, env): "prefer IBM tools on OS/2" linkers = ['ilink', 'gnulink', ]#'mslink'] c_compilers = ['icc', 'gcc',]# 'msvc', 'cc'] - cxx_compilers = ['icc', 'g++',]# 'msvc', 'c++'] + cxx_compilers = ['icc', 'g++',]# 'msvc', 'cxx'] assemblers = ['nasm',]# 'masm', 'gas'] fortran_compilers = ['ifl', 'g77'] ars = ['ar',]# 'mslib'] @@ -1057,7 +1057,7 @@ def tool_list(platform, env): "prefer MIPSPro on IRIX" linkers = ['sgilink', 'gnulink'] c_compilers = ['sgicc', 'gcc', 'cc'] - cxx_compilers = ['sgic++', 'g++', 'c++'] + cxx_compilers = ['sgicxx', 'g++', 'cxx'] assemblers = ['as', 'gas'] fortran_compilers = ['f95', 'f90', 'f77', 'g77', 'fortran'] ars = ['sgiar'] @@ -1065,7 +1065,7 @@ def tool_list(platform, env): "prefer Forte tools on SunOS" linkers = ['sunlink', 'gnulink'] c_compilers = ['suncc', 'gcc', 'cc'] - cxx_compilers = ['sunc++', 'g++', 'c++'] + cxx_compilers = ['suncxx', 'g++', 'cxx'] assemblers = ['as', 'gas'] fortran_compilers = ['sunf95', 'sunf90', 'sunf77', 'f95', 'f90', 'f77', 'gfortran', 'g77', 'fortran'] @@ -1074,7 +1074,7 @@ def tool_list(platform, env): "prefer aCC tools on HP-UX" linkers = ['hplink', 'gnulink'] c_compilers = ['hpcc', 'gcc', 'cc'] - cxx_compilers = ['hpc++', 'g++', 'c++'] + cxx_compilers = ['hpcxx', 'g++', 'cxx'] assemblers = ['as', 'gas'] fortran_compilers = ['f95', 'f90', 'f77', 'g77', 'fortran'] ars = ['ar'] @@ -1082,7 +1082,7 @@ def tool_list(platform, env): "prefer AIX Visual Age tools on AIX" linkers = ['aixlink', 'gnulink'] c_compilers = ['aixcc', 'gcc', 'cc'] - cxx_compilers = ['aixc++', 'g++', 'c++'] + cxx_compilers = ['aixcxx', 'g++', 'cxx'] assemblers = ['as', 'gas'] fortran_compilers = ['f95', 'f90', 'aixf77', 'g77', 'fortran'] ars = ['ar'] @@ -1090,7 +1090,7 @@ def tool_list(platform, env): "prefer GNU tools on Mac OS X, except for some linkers and IBM tools" linkers = ['applelink', 'gnulink'] c_compilers = ['gcc', 'cc'] - cxx_compilers = ['g++', 'c++'] + cxx_compilers = ['g++', 'cxx'] assemblers = ['as'] fortran_compilers = ['gfortran', 'f95', 'f90', 'g77'] ars = ['ar'] @@ -1098,7 +1098,7 @@ def tool_list(platform, env): "prefer GNU tools on Cygwin, except for a platform-specific linker" linkers = ['cyglink', 'mslink', 'ilink'] c_compilers = ['gcc', 'msvc', 'intelc', 'icc', 'cc'] - cxx_compilers = ['g++', 'msvc', 'intelc', 'icc', 'c++'] + cxx_compilers = ['g++', 'msvc', 'intelc', 'icc', 'cxx'] assemblers = ['gas', 'nasm', 'masm'] fortran_compilers = ['gfortran', 'g77', 'ifort', 'ifl', 'f95', 'f90', 'f77'] ars = ['ar', 'mslib'] @@ -1106,7 +1106,7 @@ def tool_list(platform, env): "prefer GNU tools on all other platforms" linkers = ['gnulink', 'mslink', 'ilink'] c_compilers = ['gcc', 'msvc', 'intelc', 'icc', 'cc'] - cxx_compilers = ['g++', 'msvc', 'intelc', 'icc', 'c++'] + cxx_compilers = ['g++', 'msvc', 'intelc', 'icc', 'cxx'] assemblers = ['gas', 'nasm', 'masm'] fortran_compilers = ['gfortran', 'g77', 'ifort', 'ifl', 'f95', 'f90', 'f77'] ars = ['ar', 'mslib'] diff --git a/src/engine/SCons/Tool/aixcxx.py b/src/engine/SCons/Tool/aixcxx.py index f03f763..58d9ecc 100644 --- a/src/engine/SCons/Tool/aixcxx.py +++ b/src/engine/SCons/Tool/aixcxx.py @@ -37,7 +37,9 @@ import os.path import SCons.Platform.aix -cplusplus = __import__('c++', globals(), locals(), []) +import SCons.Tool.cxx +cplusplus = SCons.Tool.cxx +#cplusplus = __import__('cxx', globals(), locals(), []) packages = ['vacpp.cmp.core', 'vacpp.cmp.batch', 'vacpp.cmp.C', 'ibmcxx.cmp'] diff --git a/src/engine/SCons/Tool/aixlink.py b/src/engine/SCons/Tool/aixlink.py index bfddf0a..fed4342 100644 --- a/src/engine/SCons/Tool/aixlink.py +++ b/src/engine/SCons/Tool/aixlink.py @@ -40,7 +40,10 @@ import SCons.Util from . import aixcc from . import link -cplusplus = __import__('c++', globals(), locals(), []) +import SCons.Tool.cxx +cplusplus = SCons.Tool.cxx +#cplusplus = __import__('cxx', globals(), locals(), []) + def smart_linkflags(source, target, env, for_signature): if cplusplus.iscplusplus(source): diff --git a/src/engine/SCons/Tool/hpcxx.py b/src/engine/SCons/Tool/hpcxx.py index 2b8ed3f..1ba9198 100644 --- a/src/engine/SCons/Tool/hpcxx.py +++ b/src/engine/SCons/Tool/hpcxx.py @@ -37,7 +37,10 @@ import os.path import SCons.Util -cplusplus = __import__('c++', globals(), locals(), []) +import SCons.Tool.cxx +cplusplus = SCons.Tool.cxx +#cplusplus = __import__('cxx', globals(), locals(), []) + acc = None diff --git a/src/engine/SCons/Tool/sgicxx.py b/src/engine/SCons/Tool/sgicxx.py index 35547ac..48b04ea 100644 --- a/src/engine/SCons/Tool/sgicxx.py +++ b/src/engine/SCons/Tool/sgicxx.py @@ -35,7 +35,10 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.Util -cplusplus = __import__('c++', globals(), locals(), []) +import SCons.Tool.cxx +cplusplus = SCons.Tool.cxx +#cplusplus = __import__('cxx', globals(), locals(), []) + def generate(env): """Add Builders and construction variables for SGI MIPS C++ to an Environment.""" diff --git a/src/engine/SCons/Tool/suncxx.py b/src/engine/SCons/Tool/suncxx.py index 49f90ea..29226ea 100644 --- a/src/engine/SCons/Tool/suncxx.py +++ b/src/engine/SCons/Tool/suncxx.py @@ -39,7 +39,9 @@ import os import re import subprocess -cplusplus = __import__('c++', globals(), locals(), []) +import SCons.Tool.cxx +cplusplus = SCons.Tool.cxx +#cplusplus = __import__('c++', globals(), locals(), []) package_info = {} diff --git a/test/textfile.py b/test/textfile.py index 3d336c6..f82f50a 100644 --- a/test/textfile.py +++ b/test/textfile.py @@ -152,6 +152,6 @@ matchem('sub4', [line1, line2a, line3b]) matchem('sub5', [line1, line2b, line3b]) matchem('sub6', [line1, line2b, line3b]) -test.up_to_date(arguments = '. --debug=explain') +test.up_to_date(arguments = '.') test.pass_test() -- cgit v0.12 From 76aa6cb5d4ec8661223480aa9914c28f6f6b5e6d Mon Sep 17 00:00:00 2001 From: Manish Vachharajani Date: Wed, 22 Mar 2017 12:33:18 -0600 Subject: Make bootstrap.py work again and work on Ubuntu Xenial. Added *cxx.py files to Manifest.in, removed VCS modules that were deleted, and updated debian package build information. --- SConstruct | 6 ++++-- debian/changelog | 6 ++++++ debian/compat | 1 + debian/control | 2 +- debian/rules | 6 ++---- src/engine/MANIFEST.in | 12 ++++++------ 6 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 debian/compat diff --git a/SConstruct b/SConstruct index 5e84d98..08f7da5 100644 --- a/SConstruct +++ b/SConstruct @@ -443,7 +443,6 @@ env = Environment( MONTH_YEAR = month_year, REVISION = revision, VERSION = version, - DH_COMPAT = 2, TAR_HFLAG = tar_hflag, @@ -503,7 +502,8 @@ python_scons = { 'debian_deps' : [ 'debian/changelog', - 'debian/control', + 'debian/compat', + 'debian/control', 'debian/copyright', 'debian/dirs', 'debian/docs', @@ -625,6 +625,7 @@ scons_script = { 'debian_deps' : [ 'debian/changelog', + 'debian/compat', 'debian/control', 'debian/copyright', 'debian/dirs', @@ -669,6 +670,7 @@ scons = { 'debian_deps' : [ 'debian/changelog', + 'debian/compat', 'debian/control', 'debian/copyright', 'debian/dirs', diff --git a/debian/changelog b/debian/changelog index e3ab00c..0808546 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +scons (2.5.1) unstable; urgency=low + + * Maintenance Release + + -- William Deegan Mon, 03 Nov 2016 13:37:42 -0700 + scons (2.5.0) unstable; urgency=low * Feature Release diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +5 diff --git a/debian/control b/debian/control index c8ebf4c..afba6f6 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: scons Section: devel Priority: optional Maintainer: Moshe Zadka -Build-Depends-Indep: debhelper (>> 2.0.0), python-dev (>> 2.4) +Build-Depends-Indep: debhelper (>> 5.0.0), python-dev (>> 2.4) Standards-Version: 3.5.6 Package: scons diff --git a/debian/rules b/debian/rules index 1effa02..9d83723 100644 --- a/debian/rules +++ b/debian/rules @@ -15,8 +15,6 @@ PYTHON=$(PYTHON_PATH)$(PYTHON_VERSION) #export DH_VERBOSE=1 # This is the debhelper compatability version to use. -export DH_COMPAT=2 - configure: configure-stamp configure-stamp: dh_testdir @@ -41,7 +39,7 @@ clean: install: build dh_testdir dh_testroot - dh_clean -k + dh_prep dh_installdirs # Add here commands to install the package into debian/scons. @@ -106,7 +104,7 @@ binary-indep: build install dh_shlibdeps dh_gencontrol dh_md5sums - DH_COMPAT=$(DH_COMPAT) dh_builddeb $(BUILDDEB_OPTIONS) + dh_builddeb $(BUILDDEB_OPTIONS) # Build architecture-dependent files here. binary-arch: build install diff --git a/src/engine/MANIFEST.in b/src/engine/MANIFEST.in index f7d5aa7..af91b7c 100644 --- a/src/engine/MANIFEST.in +++ b/src/engine/MANIFEST.in @@ -53,6 +53,7 @@ SCons/Taskmaster.py SCons/Tool/__init__.py SCons/Tool/386asm.py SCons/Tool/aixc++.py +SCons/Tool/aixcxx.py SCons/Tool/aixcc.py SCons/Tool/aixf77.py SCons/Tool/aixlink.py @@ -60,12 +61,11 @@ SCons/Tool/applelink.py SCons/Tool/ar.py SCons/Tool/as.py SCons/Tool/bcc32.py -SCons/Tool/BitKeeper.py SCons/Tool/c++.py +SCons/Tool/cxx.py SCons/Tool/cc.py SCons/Tool/cyglink.py SCons/Tool/cvf.py -SCons/Tool/CVS.py SCons/Tool/DCommon.py SCons/Tool/default.py SCons/Tool/dmd.py @@ -81,6 +81,7 @@ SCons/Tool/filesystem.py SCons/Tool/fortran.py SCons/Tool/FortranCommon.py SCons/Tool/g++.py +SCons/Tool/gxx.py SCons/Tool/g77.py SCons/Tool/gas.py SCons/Tool/gcc.py @@ -89,6 +90,7 @@ SCons/Tool/gfortran.py SCons/Tool/gnulink.py SCons/Tool/gs.py SCons/Tool/hpc++.py +SCons/Tool/hpcxx.py SCons/Tool/hpcc.py SCons/Tool/hplink.py SCons/Tool/icc.py @@ -132,22 +134,20 @@ SCons/Tool/packaging/*.py SCons/Tool/pdf.py SCons/Tool/pdflatex.py SCons/Tool/pdftex.py -SCons/Tool/Perforce.py SCons/Tool/PharLapCommon.py SCons/Tool/qt.py -SCons/Tool/RCS.py SCons/Tool/rmic.py SCons/Tool/rpcgen.py SCons/Tool/rpm.py SCons/Tool/rpmutils.py -SCons/Tool/SCCS.py SCons/Tool/sgiar.py SCons/Tool/sgic++.py +SCons/Tool/sgicxx.py SCons/Tool/sgicc.py SCons/Tool/sgilink.py -SCons/Tool/Subversion.py SCons/Tool/sunar.py SCons/Tool/sunc++.py +SCons/Tool/suncxx.py SCons/Tool/suncc.py SCons/Tool/sunf77.py SCons/Tool/sunf90.py -- cgit v0.12 From c5eead8a1737e6ef4a63dfba11226a4ae2fb9c98 Mon Sep 17 00:00:00 2001 From: Manish Vachharajani Date: Wed, 22 Mar 2017 16:28:28 -0600 Subject: Push version to Python 2.7 as minimum required. --- debian/control | 2 +- src/engine/SCons/Node/FS.py | 2 ++ test/Dir/Dir.py | 25 +++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/debian/control b/debian/control index afba6f6..5fbf0eb 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: scons Section: devel Priority: optional Maintainer: Moshe Zadka -Build-Depends-Indep: debhelper (>> 5.0.0), python-dev (>> 2.4) +Build-Depends-Indep: debhelper (>> 5.0.0), python-dev (>> 2.7) Standards-Version: 3.5.6 Package: scons diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index f455edb..d846b7c 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -1872,6 +1872,8 @@ class Dir(Base): for kid in self.children(): if kid.get_state() > up_to_date: return 0 +# else if kid.changed_since_last_build_node(): +# return 0 return 1 def rdir(self): diff --git a/test/Dir/Dir.py b/test/Dir/Dir.py index 2e8204c..88763a4 100644 --- a/test/Dir/Dir.py +++ b/test/Dir/Dir.py @@ -71,6 +71,31 @@ env.MD(target='sub2', source=['SConstruct'], OVERRIDE='foo') test.run() +#The following test creates a builder with only a directory target, +#updates its source, and ensures that the directory target is +#considered out of date and rebuilt. + +test.write('foo-contents.txt', """Hello, """) +test.write('SConstruct', """\ +import os + +def mkdir_and_copy(target=None, source=None, env=None): + os.mkdir(str(target[0])) + os.copy(str(source[0]), str(target[0])) + +mac_builder = Builder(action=mkdir_and_copy) +env = Environment() +env.Append(BUILDERS = {'MAC': mac_builder} +env.MAC(target='foo', src='foo-contents.txt') +""") + +#Build foo +test.not_up_to_date('foo') +test.up_to) + +test.write('foo-contents.txt', """Hello, World!""") +test.not_up_to_date('foo') + test.pass_test() # Local Variables: -- cgit v0.12 From c19ac5639c091a03085f27a8e771b77779894242 Mon Sep 17 00:00:00 2001 From: Manish Vachharajani Date: Wed, 22 Mar 2017 16:56:43 -0600 Subject: Revert incomplete bug fix --- debian/control | 2 +- src/engine/SCons/Node/FS.py | 2 -- test/Dir/Dir.py | 25 ------------------------- 3 files changed, 1 insertion(+), 28 deletions(-) diff --git a/debian/control b/debian/control index 5fbf0eb..afba6f6 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: scons Section: devel Priority: optional Maintainer: Moshe Zadka -Build-Depends-Indep: debhelper (>> 5.0.0), python-dev (>> 2.7) +Build-Depends-Indep: debhelper (>> 5.0.0), python-dev (>> 2.4) Standards-Version: 3.5.6 Package: scons diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index d846b7c..f455edb 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -1872,8 +1872,6 @@ class Dir(Base): for kid in self.children(): if kid.get_state() > up_to_date: return 0 -# else if kid.changed_since_last_build_node(): -# return 0 return 1 def rdir(self): diff --git a/test/Dir/Dir.py b/test/Dir/Dir.py index 88763a4..2e8204c 100644 --- a/test/Dir/Dir.py +++ b/test/Dir/Dir.py @@ -71,31 +71,6 @@ env.MD(target='sub2', source=['SConstruct'], OVERRIDE='foo') test.run() -#The following test creates a builder with only a directory target, -#updates its source, and ensures that the directory target is -#considered out of date and rebuilt. - -test.write('foo-contents.txt', """Hello, """) -test.write('SConstruct', """\ -import os - -def mkdir_and_copy(target=None, source=None, env=None): - os.mkdir(str(target[0])) - os.copy(str(source[0]), str(target[0])) - -mac_builder = Builder(action=mkdir_and_copy) -env = Environment() -env.Append(BUILDERS = {'MAC': mac_builder} -env.MAC(target='foo', src='foo-contents.txt') -""") - -#Build foo -test.not_up_to_date('foo') -test.up_to) - -test.write('foo-contents.txt', """Hello, World!""") -test.not_up_to_date('foo') - test.pass_test() # Local Variables: -- cgit v0.12 From fc30b315d34d164a47e35e8a8ac5333f0c395768 Mon Sep 17 00:00:00 2001 From: Manish Vachharajani Date: Thu, 23 Mar 2017 09:34:35 -0600 Subject: Add myself to CHANGES, update python version to 2.7 --- debian/control | 2 +- src/CHANGES.txt | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/debian/control b/debian/control index afba6f6..5fbf0eb 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: scons Section: devel Priority: optional Maintainer: Moshe Zadka -Build-Depends-Indep: debhelper (>> 5.0.0), python-dev (>> 2.4) +Build-Depends-Indep: debhelper (>> 5.0.0), python-dev (>> 2.7) Standards-Version: 3.5.6 Package: scons diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 50a5bec..cb6ab21 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -13,6 +13,11 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER RELEASE VERSION/DATE TO BE FILLED IN LATER + From Manish Vachharajani: + - Update debian rules, compat, and control to not use features + deprecated or obsolete in later versions of debhelpers + - Update python version to 2.7 in debian/control + From Russel Winder: - Reordered the default D tools from "dmd, gdc, ldc" to "dmd, ldc, gdc". -- cgit v0.12 From 94424fe97f8a846a6ec1a97f4c363ac0737719b6 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 24 Mar 2017 14:55:07 -0700 Subject: fix py2/3. Also fix py2 win32 broken tests --- src/engine/SCons/Tool/textfile.py | 71 +++++++++++++++++++++++++-------------- test/redirection.py | 17 ++++------ test/textfile.py | 61 ++++++++++++++++++++------------- 3 files changed, 89 insertions(+), 60 deletions(-) diff --git a/src/engine/SCons/Tool/textfile.py b/src/engine/SCons/Tool/textfile.py index 5ea2344..0e4d943 100644 --- a/src/engine/SCons/Tool/textfile.py +++ b/src/engine/SCons/Tool/textfile.py @@ -53,7 +53,9 @@ import re from SCons.Node import Node from SCons.Node.Python import Value -from SCons.Util import is_String, is_Sequence, is_Dict +from SCons.Util import is_String, is_Sequence, is_Dict, to_bytes + +TEXTFILE_FILE_WRITE_MODE = 'wb' def _do_subst(node, subs): """ @@ -64,12 +66,19 @@ def _do_subst(node, subs): 1.2345 and so forth. """ contents = node.get_text_contents() - if not subs: return contents - for (k,v) in subs: - contents = re.sub(k, v, contents) + if subs: + for (k, v) in subs: + contents = re.sub(k, v, contents) + + if 'b' in TEXTFILE_FILE_WRITE_MODE: + contents = bytearray(contents, 'utf-8') + return contents + def _action(target, source, env): + # import pdb; pdb.set_trace() + # prepare the line separator linesep = env['LINESEPARATOR'] if linesep is None: @@ -79,9 +88,11 @@ def _action(target, source, env): elif isinstance(linesep, Value): linesep = linesep.get_text_contents() else: - raise SCons.Errors.UserError( - 'unexpected type/class for LINESEPARATOR: %s' - % repr(linesep), None) + raise SCons.Errors.UserError('unexpected type/class for LINESEPARATOR: %s' + % repr(linesep), None) + + if 'b' in TEXTFILE_FILE_WRITE_MODE: + linesep = to_bytes(linesep) # create a dictionary to use for the substitutions if 'SUBST_DICT' not in env: @@ -95,31 +106,36 @@ def _action(target, source, env): else: raise SCons.Errors.UserError('SUBST_DICT must be dict or sequence') subs = [] - for (k,v) in d: + for (k, v) in d: if callable(v): v = v() if is_String(v): v = env.subst(v) else: v = str(v) - subs.append((k,v)) + subs.append((k, v)) # write the file try: - fd = open(target[0].get_path(), "w") - except (OSError,IOError) as e: + fd = open(target[0].get_path(), TEXTFILE_FILE_WRITE_MODE) + except (OSError, IOError) as e: raise SCons.Errors.UserError("Can't write target file %s" % target[0]) + # separate lines by 'linesep' only if linesep is not empty lsep = None for s in source: - if lsep: fd.write(lsep) + if lsep: + fd.write(lsep) + fd.write(_do_subst(s, subs)) lsep = linesep fd.close() + def _strfunc(target, source, env): return "Creating '%s'" % target[0] + def _convert_list_R(newlist, sources): for elem in sources: if is_Sequence(elem): @@ -128,6 +144,8 @@ def _convert_list_R(newlist, sources): newlist.append(elem) else: newlist.append(Value(elem)) + + def _convert_list(target, source, env): if len(target) != 1: raise SCons.Errors.UserError("Only one target file allowed") @@ -135,26 +153,28 @@ def _convert_list(target, source, env): _convert_list_R(newlist, source) return target, newlist + _common_varlist = ['SUBST_DICT', 'LINESEPARATOR'] _text_varlist = _common_varlist + ['TEXTFILEPREFIX', 'TEXTFILESUFFIX'] _text_builder = SCons.Builder.Builder( - action = SCons.Action.Action(_action, _strfunc, varlist = _text_varlist), - source_factory = Value, - emitter = _convert_list, - prefix = '$TEXTFILEPREFIX', - suffix = '$TEXTFILESUFFIX', - ) + action=SCons.Action.Action(_action, _strfunc, varlist=_text_varlist), + source_factory=Value, + emitter=_convert_list, + prefix='$TEXTFILEPREFIX', + suffix='$TEXTFILESUFFIX', +) _subst_varlist = _common_varlist + ['SUBSTFILEPREFIX', 'TEXTFILESUFFIX'] _subst_builder = SCons.Builder.Builder( - action = SCons.Action.Action(_action, _strfunc, varlist = _subst_varlist), - source_factory = SCons.Node.FS.File, - emitter = _convert_list, - prefix = '$SUBSTFILEPREFIX', - suffix = '$SUBSTFILESUFFIX', - src_suffix = ['.in'], - ) + action=SCons.Action.Action(_action, _strfunc, varlist=_subst_varlist), + source_factory=SCons.Node.FS.File, + emitter=_convert_list, + prefix='$SUBSTFILEPREFIX', + suffix='$SUBSTFILESUFFIX', + src_suffix=['.in'], +) + def generate(env): env['LINESEPARATOR'] = os.linesep @@ -165,6 +185,7 @@ def generate(env): env['SUBSTFILEPREFIX'] = '' env['SUBSTFILESUFFIX'] = '' + def exists(env): return 1 diff --git a/test/redirection.py b/test/redirection.py index cc8ebf9..ffc76b5 100644 --- a/test/redirection.py +++ b/test/redirection.py @@ -33,15 +33,10 @@ test = TestSCons.TestSCons() test.write('cat.py', r""" import sys try: - input = open(sys.argv[1], 'rb').read() - try: - sys.stdout.buffer.write(input) - except AttributeError: - sys.stdout.write(input) + input = open(sys.argv[1], 'r').read() except IndexError: input = sys.stdin.read() - sys.stdout.write(input) - +sys.stdout.write(input) sys.exit(0) """) @@ -57,10 +52,10 @@ env.Command(target='foo4', source='bar4', action=r'%(_python_)s cat.py <$SOURCES |%(_python_)s cat.py >$TARGET') """ % locals()) -test.write('bar1', 'bar1\r\n', mode='w') -test.write('bar2', 'bar2\r\n', mode='w') -test.write('bar3', 'bar3\r\n', mode='w') -test.write('bar4', 'bar4\r\n', mode='w') +test.write('bar1', 'bar1\r\n') +test.write('bar2', 'bar2\r\n') +test.write('bar3', 'bar3\r\n') +test.write('bar4', 'bar4\r\n') test.run(arguments='.') diff --git a/test/textfile.py b/test/textfile.py index f82f50a..91e95e9 100644 --- a/test/textfile.py +++ b/test/textfile.py @@ -30,11 +30,13 @@ import os test = TestSCons.TestSCons() -foo1 = test.workpath('foo1.txt') +foo1 = test.workpath('foo1.txt') #foo2 = test.workpath('foo2.txt') #foo1a = test.workpath('foo1a.txt') #foo2a = test.workpath('foo2a.txt') +match_mode = 'rb' + test.write('SConstruct', """ env = Environment(tools=['textfile']) data0 = ['Goethe', 'Schiller'] @@ -55,43 +57,48 @@ env.Substfile('bar2', data, LINESEPARATOR='|*') data.append(Value('')) env.Substfile('bar1a.txt', data) env.Substfile('bar2a.txt', data, LINESEPARATOR='|*') -""") +""", mode='w') -test.run(arguments = '.') +test.run(arguments='.') textparts = ['lalala', '42', 'Goethe', 'Schiller', 'tanteratei'] -foo1Text = os.linesep.join(textparts) -foo2Text = '|*'.join(textparts) +foo1Text = os.linesep.join(textparts) +foo2Text = '|*'.join(textparts) foo1aText = foo1Text + os.linesep foo2aText = foo2Text + '|*' -test.up_to_date(arguments = '.') +test.up_to_date(arguments='.') files = list(map(test.workpath, ( - 'foo1.txt', 'foo2.txt', 'foo1a.txt', 'foo2a.txt', - 'bar1', 'bar2', 'bar1a.txt', 'bar2a.txt', - ))) + 'foo1.txt', 'foo2.txt', 'foo1a.txt', 'foo2a.txt', + 'bar1', 'bar2', 'bar1a.txt', 'bar2a.txt', +))) + + def check_times(): - # make sure the files didn't get rewritten, because nothing changed: + """ + make sure the files didn't get rewritten, because nothing changed: + """ before = list(map(os.path.getmtime, files)) # introduce a small delay, to make the test valid test.sleep() # should still be up-to-date - test.up_to_date(arguments = '.') + test.up_to_date(arguments='.') after = list(map(os.path.getmtime, files)) test.fail_test(before != after) + # make sure that the file content is as expected -test.must_match('foo1.txt', foo1Text) -test.must_match('bar1', foo1Text) -test.must_match('foo2.txt', foo2Text) -test.must_match('bar2', foo2Text) -test.must_match('foo1a.txt', foo1aText) -test.must_match('bar1a.txt', foo1aText) -test.must_match('foo2a.txt', foo2aText) -test.must_match('bar2a.txt', foo2aText) +test.must_match('foo1.txt', foo1Text, mode=match_mode) +test.must_match('bar1', foo1Text, mode=match_mode) +test.must_match('foo2.txt', foo2Text, mode=match_mode) +test.must_match('bar2', foo2Text, mode=match_mode) +test.must_match('foo1a.txt', foo1aText, mode=match_mode) +test.must_match('bar1a.txt', foo1aText, mode=match_mode) +test.must_match('foo2a.txt', foo2aText, mode=match_mode) +test.must_match('bar2a.txt', foo2aText, mode=match_mode) check_times() # write the contents and make sure the files @@ -132,17 +139,23 @@ s = env.Substfile('sub5', s, SUBST_DICT = sub1) s = env.Substfile('sub6', t, SUBST_DICT = sub3) """, mode='w') -test.run(arguments = '.') +test.run(arguments='.') -line1 = 'This line has no substitutions' +line1 = 'This line has no substitutions' line2a = 'This line has @subst@ substitutions' line2b = 'This line has most substitutions' line3a = 'This line has %subst% substitutions' line3b = 'This line has many substitutions' -def matchem(file, lines): + +def matchem(match_file, lines): + """ + Join all the lines with correct line separator, + then compare + """ lines = os.linesep.join(lines) - test.must_match(file, lines, mode='r') + test.must_match(match_file, lines, mode=match_mode) + matchem('text.txt', [line1, line2a, line3a]) matchem('sub1', [line1, line2a, line3a]) @@ -152,6 +165,6 @@ matchem('sub4', [line1, line2a, line3b]) matchem('sub5', [line1, line2b, line3b]) matchem('sub6', [line1, line2b, line3b]) -test.up_to_date(arguments = '.') +test.up_to_date(arguments='.') test.pass_test() -- cgit v0.12 From 916e4fa90ee512fedeba05665fb357ffd208319c Mon Sep 17 00:00:00 2001 From: Gaurav Juvekar Date: Sun, 26 Mar 2017 15:59:59 +0530 Subject: string-escape unicode characters while printing --tree Fixes #2910 --- src/engine/SCons/Util.py | 8 ++++---- test/option--tree.py | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index a8a6990..ecdd77f 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -148,7 +148,7 @@ class NodeList(UserList): # else: # self.data = [ initlist,] - + def __nonzero__(self): return len(self.data) != 0 @@ -170,10 +170,10 @@ class NodeList(UserList): return self.__class__(result) def __getitem__(self, index): - """ + """ This comes for free on py2, but py3 slices of NodeList are returning a list - breaking slicing nodelist and refering to + breaking slicing nodelist and refering to properties and methods on contained object """ # return self.__class__(self.data[index]) @@ -288,7 +288,7 @@ def print_tree(root, child_func, prune=0, showtags=0, margin=[0], visited=None): or in the whole tree if prune. """ - rname = str(root) + rname = str(root).encode('string-escape') # Initialize 'visited' dict, if required if visited is None: diff --git a/test/option--tree.py b/test/option--tree.py index a50433c..a8c360e 100644 --- a/test/option--tree.py +++ b/test/option--tree.py @@ -51,6 +51,23 @@ scons: warning: The --debug=tree option is deprecated; please use --tree=all ins """, status = 0, match=TestSCons.match_re_dotall) + +# Test that unicode characters can be printed with the --tree option +test.write('SConstruct', +""" +env = Environment() +env.Tool("textfile") +env.Textfile("Foo", unichr(0xe7).encode('utf-8')) +""") + +test.run(arguments = '-Q --tree=all', + stdout = """Creating 'Foo.txt' ++-. + +-Foo.txt + | +-\\xc3\\xa7 + +-SConstruct +""", + status = 0) test.pass_test() # Local Variables: -- cgit v0.12 From b34164950ee97eb57f28ed665137e95de70effb9 Mon Sep 17 00:00:00 2001 From: Gaurav Juvekar Date: Sun, 26 Mar 2017 16:06:01 +0530 Subject: Reword comment in test case to highlight that unicode is printed escaped --- test/option--tree.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/option--tree.py b/test/option--tree.py index a8c360e..1c1832b 100644 --- a/test/option--tree.py +++ b/test/option--tree.py @@ -52,7 +52,7 @@ scons: warning: The --debug=tree option is deprecated; please use --tree=all ins status = 0, match=TestSCons.match_re_dotall) -# Test that unicode characters can be printed with the --tree option +# Test that unicode characters can be printed (escaped) with the --tree option test.write('SConstruct', """ env = Environment() -- cgit v0.12 From 52f4d73e7b8577660ccf9d8c0a9f6fb5837c2e28 Mon Sep 17 00:00:00 2001 From: Gaurav Juvekar Date: Mon, 27 Mar 2017 12:32:29 +0530 Subject: Make --tree=all work with Python 3 The codecs module is used which is distributed in the python standard library. --- src/engine/SCons/Util.py | 14 +++++++++++++- test/option--tree.py | 9 ++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index ecdd77f..2d8e75a 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -31,6 +31,7 @@ import sys import copy import re import types +import codecs try: from UserDict import UserDict @@ -288,7 +289,18 @@ def print_tree(root, child_func, prune=0, showtags=0, margin=[0], visited=None): or in the whole tree if prune. """ - rname = str(root).encode('string-escape') + rname = str(root) + if sys.version_info.major < 3: + # Python 2 UTF-8 encoded str are str. escape_encode is a str to str + # encoding + rname = codecs.escape_encode(rname)[0] + else: + # Python 3 UTF-8 encoded str are bytes. escape_encode is a byte to byte + # encoding here. + rname = rname.encode('utf-8') + rname = codecs.escape_encode(rname)[0] + # Finally, we need a string again. + rname = rname.decode('ascii') # Initialize 'visited' dict, if required if visited is None: diff --git a/test/option--tree.py b/test/option--tree.py index 1c1832b..a9618d8 100644 --- a/test/option--tree.py +++ b/test/option--tree.py @@ -57,7 +57,14 @@ test.write('SConstruct', """ env = Environment() env.Tool("textfile") -env.Textfile("Foo", unichr(0xe7).encode('utf-8')) +try: + # Python 2 + write = unichr(0xe7).encode('utf-8') +except NameError: + # Python 3 + # str is utf-8 by default + write = chr(0xe7) +env.Textfile("Foo", write) """) test.run(arguments = '-Q --tree=all', -- cgit v0.12 From 4e4854aabb4f3283972737440aa64dd221e7aeee Mon Sep 17 00:00:00 2001 From: Gaurav Juvekar Date: Mon, 27 Mar 2017 12:40:17 +0530 Subject: Add contribution to src/CHANGES.txt --- src/CHANGES.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index cb6ab21..5127c51 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -13,6 +13,10 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER RELEASE VERSION/DATE TO BE FILLED IN LATER + From Gaurav Juvekar: + - Fix issue #2910: Make --tree=all handle Unicode. (PR #427) + - Fix issue #2788: Fix typo in documentation example for sconf. (PR #388) + From Manish Vachharajani: - Update debian rules, compat, and control to not use features deprecated or obsolete in later versions of debhelpers -- cgit v0.12 From d0d93abd56f3091f5fd423e474f799c7938e8243 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 30 Mar 2017 09:58:46 -0400 Subject: initial logic for dynamic tool loading for python. It currently will work for py 3.5 and above. Need to see if this is a viable restriction --- src/engine/SCons/Tool/__init__.py | 102 ++++++++++++++++++++++++++++---------- 1 file changed, 75 insertions(+), 27 deletions(-) diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index c57a93b..4cc60fb 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -97,6 +97,7 @@ for suffix in LaTeXSuffixes: SourceFileScanner.add_scanner(suffix, LaTeXScanner) SourceFileScanner.add_scanner(suffix, PDFLaTeXScanner) + class Tool(object): def __init__(self, name, toolpath=[], **kw): self.name = name @@ -114,9 +115,9 @@ class Tool(object): # TODO: Interchange zipimport with normal initialization for better error reporting oldpythonpath = sys.path sys.path = self.toolpath + sys.path + # sys.stderr.write("Tool:%s\nPATH:%s\n"%(self.name,sys.path)) - - if sys.version_info[0] < 3: + if sys.version_info[0] < 3 or (sys.version_info[0] == 3 and sys.version_info[1] in (0,1,2,3,4)): # Py 2 code try: try: @@ -143,34 +144,81 @@ class Tool(object): pass finally: sys.path = oldpythonpath - else: + elif sys.version_info[1] > 4: + # From: http://stackoverflow.com/questions/67631/how-to-import-a-module-given-the-full-path/67692#67692 + # import importlib.util + # spec = importlib.util.spec_from_file_location("module.name", "/path/to/file.py") + # foo = importlib.util.module_from_spec(spec) + # spec.loader.exec_module(foo) + # foo.MyClass() # Py 3 code - try: - # Try site_tools first - return importlib.import_module(self.name) - except ImportError as e: - # Then try modules in main distribution - try: - return importlib.import_module('SCons.Tool.'+self.name) - except ImportError as e: - if str(e) != "No module named %s" % self.name: - raise SCons.Errors.EnvironmentError(e) - try: - import zipimport - except ImportError: - pass - else: - for aPath in self.toolpath: - try: - importer = zipimport.zipimporter(aPath) - return importer.load_module(self.name) - except ImportError as e: - pass - - finally: - sys.path = oldpythonpath + import importlib.util + + # sys.stderr.write("toolpath:%s\n" % self.toolpath) + # sys.stderr.write("SCONS.TOOL path:%s\n" % sys.modules['SCons.Tool'].__path__) + debug = False + spec = None + for path in self.toolpath: + file_path = os.path.join(path, "%s.py"%self.name) + file_package = os.path.join(path, self.name) + + if debug: sys.stderr.write("Trying:%s %s\n"%(file_path, file_package)) + + if os.path.isfile(file_path): + spec = importlib.util.spec_from_file_location(self.name, file_path) + if debug: print("file_Path:%s FOUND"%file_path) + break + elif os.path.isdir(file_package): + spec = importlib.util.spec_from_file_location(self.name, file_package) + if debug: print("PACKAGE:%s Found"%file_package) + break + + else: + continue + + if spec is None: + if debug: sys.stderr.write("NO SPEC :%s\n"%self.name) + spec = importlib.util.find_spec("."+self.name, package='SCons.Tool') + if debug: sys.stderr.write("Spec Found? .%s :%s\n"%(self.name, spec)) + + module = importlib.util.module_from_spec(spec) + if module is None: + if debug: print("MODULE IS NONE:%s"%self.name) + pass + spec.loader.exec_module(module) + + sys.modules[self.name] = module + return module + + + # try: + # # Try site_tools first + # return importlib.import_module(self.name) + # except ImportError as e: + # # Then try modules in main distribution + # try: + # return importlib.import_module('SCons.Tool.'+self.name) + # except ImportError as e: + # if str(e) != "No module named %s" % self.name: + # raise SCons.Errors.EnvironmentError(e) + # try: + # import zipimport + # except ImportError: + # pass + # else: + # for aPath in self.toolpath: + # try: + # importer = zipimport.zipimporter(aPath) + # return importer.load_module(self.name) + # except ImportError as e: + # pass + # + # finally: + # sys.path = oldpythonpath + + sys.path = oldpythonpath full_name = 'SCons.Tool.' + self.name try: -- cgit v0.12 From c045a501d184f6f933fdc045c5f428e4e61efaea Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 30 Mar 2017 09:59:46 -0400 Subject: remove usage of SCCS tool as it's been removed. Switch to zip tool as it should be present on all platforms. Change some names to make it easier to debug when it fails --- test/toolpath/basic.py | 149 +++++++++++++++++++++++++------------------------ 1 file changed, 76 insertions(+), 73 deletions(-) diff --git a/test/toolpath/basic.py b/test/toolpath/basic.py index 509d4cb..ce90f35 100644 --- a/test/toolpath/basic.py +++ b/test/toolpath/basic.py @@ -39,65 +39,68 @@ print("env1['TOOL_FOO'] =", env1.get('TOOL_FOO')) print("env1['TOOL_BAR'] =", env1.get('TOOL_BAR')) # pick a built-in tool with pretty simple behavior -env2 = Environment(tools=['SCCS']) -print("env2['SCCS'] =", env2.get('SCCS')) -print("env2['TOOL_SCCS1'] =", env2.get('TOOL_SCCS1')) -print("env2['TOOL_SCCS2'] =", env2.get('TOOL_SCCS2')) - -env3 = Environment(tools=['SCCS'], toolpath=['.']) -print("env3['SCCS'] =", env3.get('SCCS')) -print("env3['TOOL_SCCS1'] =", env3.get('TOOL_SCCS1')) -print("env3['TOOL_SCCS2'] =", env3.get('TOOL_SCCS2')) - -env4 = Environment(tools=['SCCS'], toolpath=['tools']) -print("env4['SCCS'] =", env4.get('SCCS')) -print("env4['TOOL_SCCS1'] =", env4.get('TOOL_SCCS1')) -print("env4['TOOL_SCCS2'] =", env4.get('TOOL_SCCS2')) - -env5 = Environment(tools=['SCCS'], toolpath=['tools', '.']) -print("env5['SCCS'] =", env5.get('SCCS')) -print("env5['TOOL_SCCS1'] =", env5.get('TOOL_SCCS1')) -print("env5['TOOL_SCCS2'] =", env5.get('TOOL_SCCS2')) - -env6 = Environment(tools=['SCCS'], toolpath=['.', 'tools']) -print("env6['SCCS'] =", env6.get('SCCS')) -print("env6['TOOL_SCCS1'] =", env6.get('TOOL_SCCS1')) -print("env6['TOOL_SCCS2'] =", env6.get('TOOL_SCCS2')) - -env7 = Environment(TOOLPATH="tools", tools=['SCCS'], toolpath=['$TOOLPATH']) -print("env7['SCCS'] =", env7.get('SCCS')) -print("env7['TOOL_SCCS1'] =", env7.get('TOOL_SCCS1')) -print("env7['TOOL_SCCS2'] =", env7.get('TOOL_SCCS2')) +env2 = Environment(tools=['zip']) +print("env2['ZIP'] =", env2.get('ZIP')) +print("env2['TOOL_zip1'] =", env2.get('TOOL_zip1')) +print("env2['TOOLDIR_zip'] =", env2.get('TOOLDIR_zip')) + +env3 = Environment(tools=['zip'], toolpath=['.']) +print("env3['ZIP'] =", env3.get('ZIP')) +print("env3['TOOL_zip1'] =", env3.get('TOOL_zip1')) +print("env3['TOOLDIR_zip'] =", env3.get('TOOLDIR_zip')) + +env4 = Environment(tools=['zip'], toolpath=['tools']) +print("env4['ZIP'] =", env4.get('ZIP')) +print("env4['TOOL_zip1'] =", env4.get('TOOL_zip1')) +print("env4['TOOLDIR_zip'] =", env4.get('TOOLDIR_zip')) + +# Should pick up from tools dir, and then current dir +env5 = Environment(tools=['zip'], toolpath=['tools', '.']) +print("env5['ZIP'] =", env5.get('ZIP')) +print("env5['TOOL_zip1'] =", env5.get('TOOL_zip1')) +print("env5['TOOLDIR_zip'] =", env5.get('TOOLDIR_zip')) + + +# Should pick up from current dir, and then tools dir +env6 = Environment(tools=['zip'], toolpath=['.', 'tools']) +print("env6['ZIP'] =", env6.get('ZIP')) +print("env6['TOOL_zip1'] =", env6.get('TOOL_zip1')) +print("env6['TOOLDIR_zip'] =", env6.get('TOOLDIR_zip')) + +env7 = Environment(TOOLPATH="tools", tools=['zip'], toolpath=['$TOOLPATH']) +print("env7['ZIP'] =", env7.get('ZIP')) +print("env7['TOOL_zip1'] =", env7.get('TOOL_zip1')) +print("env7['TOOLDIR_zip'] =", env7.get('TOOLDIR_zip')) env8 = Environment(tools=[]) -env8.Tool('SCCS', toolpath=['tools']) -print("env8['SCCS'] =", env8.get('SCCS')) -print("env8['TOOL_SCCS1'] =", env8.get('TOOL_SCCS1')) -print("env8['TOOL_SCCS2'] =", env8.get('TOOL_SCCS2')) +env8.Tool('zip', toolpath=['tools']) +print("env8['ZIP'] =", env8.get('ZIP')) +print("env8['TOOL_zip1'] =", env8.get('TOOL_zip1')) +print("env8['TOOLDIR_zip'] =", env8.get('TOOLDIR_zip')) env9 = Environment(tools=[]) -Tool('SCCS', toolpath=['tools'])(env9) -print("env9['SCCS'] =", env9.get('SCCS')) -print("env9['TOOL_SCCS1'] =", env9.get('TOOL_SCCS1')) -print("env9['TOOL_SCCS2'] =", env9.get('TOOL_SCCS2')) +Tool('zip', toolpath=['tools'])(env9) +print("env9['ZIP'] =", env9.get('ZIP')) +print("env9['TOOL_zip1'] =", env9.get('TOOL_zip1')) +print("env9['TOOLDIR_zip'] =", env9.get('TOOLDIR_zip')) env0 = Environment(TOOLPATH='tools', tools=[]) -env0.Tool('SCCS', toolpath=['$TOOLPATH']) -print("env0['SCCS'] =", env0.get('SCCS')) -print("env0['TOOL_SCCS1'] =", env0.get('TOOL_SCCS1')) -print("env0['TOOL_SCCS2'] =", env0.get('TOOL_SCCS2')) +env0.Tool('zip', toolpath=['$TOOLPATH']) +print("env0['ZIP'] =", env0.get('ZIP')) +print("env0['TOOL_zip1'] =", env0.get('TOOL_zip1')) +print("env0['TOOLDIR_zip'] =", env0.get('TOOLDIR_zip')) base = Environment(tools=[], toolpath=['tools']) derived = base.Clone(tools=['bar']) print("derived['TOOL_BAR'] =", derived.get('TOOL_BAR')) """) -test.write('SCCS.py', r"""\ +test.write('zip.py', r""" def generate(env): - env['TOOL_SCCS1'] = 1 + env['TOOL_zip1'] = 1 def exists(env): return 1 -""") +""",mode='w') test.subdir('tools') @@ -105,10 +108,10 @@ test.write(['tools', 'Common.py'], r"""\ One = 1 """) -test.write(['tools', 'SCCS.py'], r"""\ +test.write(['tools', 'zip.py'], r"""\ import Common def generate(env): - env['TOOL_SCCS2'] = Common.One + env['TOOLDIR_zip'] = Common.One def exists(env): return Common.One """) @@ -124,33 +127,33 @@ test.run(arguments = '.', stdout = """\ scons: Reading SConscript files ... env1['TOOL_FOO'] = 1 env1['TOOL_BAR'] = 1 -env2['SCCS'] = sccs -env2['TOOL_SCCS1'] = None -env2['TOOL_SCCS2'] = None -env3['SCCS'] = None -env3['TOOL_SCCS1'] = 1 -env3['TOOL_SCCS2'] = None -env4['SCCS'] = None -env4['TOOL_SCCS1'] = None -env4['TOOL_SCCS2'] = 1 -env5['SCCS'] = None -env5['TOOL_SCCS1'] = None -env5['TOOL_SCCS2'] = 1 -env6['SCCS'] = None -env6['TOOL_SCCS1'] = 1 -env6['TOOL_SCCS2'] = None -env7['SCCS'] = None -env7['TOOL_SCCS1'] = None -env7['TOOL_SCCS2'] = 1 -env8['SCCS'] = None -env8['TOOL_SCCS1'] = None -env8['TOOL_SCCS2'] = 1 -env9['SCCS'] = None -env9['TOOL_SCCS1'] = None -env9['TOOL_SCCS2'] = 1 -env0['SCCS'] = None -env0['TOOL_SCCS1'] = None -env0['TOOL_SCCS2'] = 1 +env2['ZIP'] = zip +env2['TOOL_zip1'] = None +env2['TOOLDIR_zip'] = None +env3['ZIP'] = None +env3['TOOL_zip1'] = 1 +env3['TOOLDIR_zip'] = None +env4['ZIP'] = None +env4['TOOL_zip1'] = None +env4['TOOLDIR_zip'] = 1 +env5['ZIP'] = None +env5['TOOL_zip1'] = None +env5['TOOLDIR_zip'] = 1 +env6['ZIP'] = None +env6['TOOL_zip1'] = 1 +env6['TOOLDIR_zip'] = None +env7['ZIP'] = None +env7['TOOL_zip1'] = None +env7['TOOLDIR_zip'] = 1 +env8['ZIP'] = None +env8['TOOL_zip1'] = None +env8['TOOLDIR_zip'] = 1 +env9['ZIP'] = None +env9['TOOL_zip1'] = None +env9['TOOLDIR_zip'] = 1 +env0['ZIP'] = None +env0['TOOL_zip1'] = None +env0['TOOLDIR_zip'] = 1 derived['TOOL_BAR'] = 1 scons: done reading SConscript files. scons: Building targets ... -- cgit v0.12 From 505bd97fd79f0f5d8c18252d28dcfeafa5fe2fa4 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 30 Mar 2017 10:00:19 -0400 Subject: module named warnings.py is conflicting with system warnings module. rename. py2/3 issue --- test/QT/qt_warnings.py | 106 +++++++++++++++++++++++++++++++++++++++++++++++++ test/QT/warnings.py | 106 ------------------------------------------------- 2 files changed, 106 insertions(+), 106 deletions(-) create mode 100644 test/QT/qt_warnings.py delete mode 100644 test/QT/warnings.py diff --git a/test/QT/qt_warnings.py b/test/QT/qt_warnings.py new file mode 100644 index 0000000..a1cf221 --- /dev/null +++ b/test/QT/qt_warnings.py @@ -0,0 +1,106 @@ +#!/usr/bin/env python +# +# __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. +# +from __future__ import print_function + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test the Qt tool warnings. +""" + +import os +import re + +import TestSCons + +test = TestSCons.TestSCons() + +SConstruct_path = test.workpath('SConstruct') + +test.Qt_dummy_installation() + +test.Qt_create_SConstruct(SConstruct_path) + +test.write('aaa.cpp', r""" +#include "my_qobject.h" +void aaa(void) Q_OBJECT +""") + +test.write('SConscript', r""" +Import("env") +import os +env.StaticLibrary('aaa.cpp') +""") + +test.run(stderr=None) + +match12 = r""" +scons: warning: Generated moc file 'aaa.moc' is not included by 'aaa.cpp' +""" + TestSCons.file_expr + +if not re.search(match12, test.stderr()): + print("Did not find expected regular expression in stderr:") + print(test.stderr()) + test.fail_test() + +os.environ['QTDIR'] = test.QT + +test.run(arguments='-n noqtdir=1') + +# We'd like to eliminate $QTDIR from the environment as follows: +# del os.environ['QTDIR'] +# But unfortunately, in at least some versions of Python, the Environment +# class doesn't implement a __delitem__() method to make the library +# call to actually remove the deleted variable from the *external* +# environment, so it only gets removed from the Python dictionary. +# Consequently, we need to just wipe out its value as follows> +os.environ['QTDIR'] = '' +test.run(stderr=None, arguments='-n noqtdir=1') + +moc = test.where_is('moc') +if moc: + import os.path + qtdir = os.path.dirname(os.path.dirname(moc)) + qtdir = qtdir.replace('\\', '\\\\' ) + + expect = """ +scons: warning: Could not detect qt, using moc executable as a hint \(QTDIR=%s\) +File "%s", line \d+, in (\?|) +""" % (qtdir, re.escape(SConstruct_path)) +else: + + expect = r""" +scons: warning: Could not detect qt, using empty QTDIR +File "%s", line \d+, in (\?|) +""" % re.escape(SConstruct_path) + +test.fail_test(not test.match_re(test.stderr(), expect)) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/QT/warnings.py b/test/QT/warnings.py deleted file mode 100644 index a1cf221..0000000 --- a/test/QT/warnings.py +++ /dev/null @@ -1,106 +0,0 @@ -#!/usr/bin/env python -# -# __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. -# -from __future__ import print_function - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -""" -Test the Qt tool warnings. -""" - -import os -import re - -import TestSCons - -test = TestSCons.TestSCons() - -SConstruct_path = test.workpath('SConstruct') - -test.Qt_dummy_installation() - -test.Qt_create_SConstruct(SConstruct_path) - -test.write('aaa.cpp', r""" -#include "my_qobject.h" -void aaa(void) Q_OBJECT -""") - -test.write('SConscript', r""" -Import("env") -import os -env.StaticLibrary('aaa.cpp') -""") - -test.run(stderr=None) - -match12 = r""" -scons: warning: Generated moc file 'aaa.moc' is not included by 'aaa.cpp' -""" + TestSCons.file_expr - -if not re.search(match12, test.stderr()): - print("Did not find expected regular expression in stderr:") - print(test.stderr()) - test.fail_test() - -os.environ['QTDIR'] = test.QT - -test.run(arguments='-n noqtdir=1') - -# We'd like to eliminate $QTDIR from the environment as follows: -# del os.environ['QTDIR'] -# But unfortunately, in at least some versions of Python, the Environment -# class doesn't implement a __delitem__() method to make the library -# call to actually remove the deleted variable from the *external* -# environment, so it only gets removed from the Python dictionary. -# Consequently, we need to just wipe out its value as follows> -os.environ['QTDIR'] = '' -test.run(stderr=None, arguments='-n noqtdir=1') - -moc = test.where_is('moc') -if moc: - import os.path - qtdir = os.path.dirname(os.path.dirname(moc)) - qtdir = qtdir.replace('\\', '\\\\' ) - - expect = """ -scons: warning: Could not detect qt, using moc executable as a hint \(QTDIR=%s\) -File "%s", line \d+, in (\?|) -""" % (qtdir, re.escape(SConstruct_path)) -else: - - expect = r""" -scons: warning: Could not detect qt, using empty QTDIR -File "%s", line \d+, in (\?|) -""" % re.escape(SConstruct_path) - -test.fail_test(not test.match_re(test.stderr(), expect)) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: -- cgit v0.12 From 62491bb09fc2b9ff71d498bf24ea5f961acbea26 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 30 Mar 2017 10:01:52 -0400 Subject: py2/3 don't use __import_ c++, just load via import SCons.tool.cxx py2/3. py3 doesn't allow modules with + in them anymore --- src/engine/SCons/Tool/link.py | 5 ++++- src/engine/SCons/Tool/qt.py | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/engine/SCons/Tool/link.py b/src/engine/SCons/Tool/link.py index ae2c4b8..b7db947 100644 --- a/src/engine/SCons/Tool/link.py +++ b/src/engine/SCons/Tool/link.py @@ -46,7 +46,10 @@ import SCons.Warnings from SCons.Tool.FortranCommon import isfortran from SCons.Tool.DCommon import isD -cplusplus = __import__(__package__+'.c++', globals(), locals(), ['*']) + +import SCons.Tool.cxx +cplusplus = SCons.Tool.cxx +# cplusplus = __import__(__package__+'.cxx', globals(), locals(), ['*']) issued_mixed_link_warning = False diff --git a/src/engine/SCons/Tool/qt.py b/src/engine/SCons/Tool/qt.py index f01fff6..5f99054 100644 --- a/src/engine/SCons/Tool/qt.py +++ b/src/engine/SCons/Tool/qt.py @@ -59,7 +59,11 @@ SCons.Warnings.enableWarningClass(ToolQtWarning) header_extensions = [".h", ".hxx", ".hpp", ".hh"] if SCons.Util.case_sensitive_suffixes('.h', '.H'): header_extensions.append('.H') -cplusplus = __import__('c++', globals(), locals(), []) + +import SCons.Tool.cxx +cplusplus = SCons.Tool.cxx +#cplusplus = __import__('cxx', globals(), locals(), []) + cxx_suffixes = cplusplus.CXXSuffixes def checkMocIncluded(target, source, env): -- cgit v0.12 From edd59e83669be442f2a573e593995a23bdcfa1d1 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 30 Mar 2017 10:12:14 -0400 Subject: py2/3 handle not finding tools properly for py3 --- src/engine/SCons/Tool/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index 4cc60fb..96c6c20 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -182,10 +182,17 @@ class Tool(object): spec = importlib.util.find_spec("."+self.name, package='SCons.Tool') if debug: sys.stderr.write("Spec Found? .%s :%s\n"%(self.name, spec)) + if spec is None: + error_string = "No module named %s"%self.name + raise SCons.Errors.EnvironmentError(error_string) + + module = importlib.util.module_from_spec(spec) if module is None: if debug: print("MODULE IS NONE:%s"%self.name) - pass + error_string = "No module named %s"%self.name + raise SCons.Errors.EnvironmentError(error_string) + spec.loader.exec_module(module) -- cgit v0.12 From ebc6c70a3b7884b7aa79c3be260bdfe936a138d2 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 30 Mar 2017 10:16:00 -0400 Subject: pep8 --- src/engine/SCons/EnvironmentTests.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index 5a14ffc..229858f 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -1461,8 +1461,6 @@ def exists(env): assert env['SOURCE'] == 's', env['SOURCE'] assert env['SOURCES'] == 'sss', env['SOURCES'] - - def test_Append(self): """Test appending to construction variables in an Environment """ -- cgit v0.12 From bb2fa981318e1aeb7655790133c56d1a6a42da24 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 30 Mar 2017 10:16:34 -0400 Subject: py2/3 for py3, if the tool has already been loaded, just return that. no need to reload the tool --- src/engine/SCons/Tool/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index 96c6c20..f527433 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -153,6 +153,10 @@ class Tool(object): # foo.MyClass() # Py 3 code + # Don't reload a tool we already loaded. + if sys.modules.get(self.name, False): + return sys.modules[self.name] + import importlib.util # sys.stderr.write("toolpath:%s\n" % self.toolpath) -- cgit v0.12 From 4fca25549b129a1d843a93abc607f40c106e31b2 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 30 Mar 2017 21:25:13 -0400 Subject: py2/3 change logic to not reuse already loaded module from sys.modules if the file used to load it was not the same. Thus allowing two Environment()'s to pick up different versions of the same tool. --- src/engine/SCons/Tool/__init__.py | 48 +++++++++++---------------------------- 1 file changed, 13 insertions(+), 35 deletions(-) diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index f527433..6291b99 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -153,10 +153,7 @@ class Tool(object): # foo.MyClass() # Py 3 code - # Don't reload a tool we already loaded. - if sys.modules.get(self.name, False): - return sys.modules[self.name] - + # import pdb; pdb.set_trace() import importlib.util # sys.stderr.write("toolpath:%s\n" % self.toolpath) @@ -190,44 +187,25 @@ class Tool(object): error_string = "No module named %s"%self.name raise SCons.Errors.EnvironmentError(error_string) - module = importlib.util.module_from_spec(spec) if module is None: if debug: print("MODULE IS NONE:%s"%self.name) error_string = "No module named %s"%self.name raise SCons.Errors.EnvironmentError(error_string) + # Don't reload a tool we already loaded. + sys_modules_value = sys.modules.get(self.name,False) + if sys_modules_value and sys_modules_value.__file__ == spec.origin: + return sys.modules[self.name] + else: + # Not sure what to do in the case that there already + # exists sys.modules[self.name] but the source file is + # different.. ? + spec.loader.exec_module(module) + + sys.modules[self.name] = module + return module - spec.loader.exec_module(module) - - sys.modules[self.name] = module - return module - - - # try: - # # Try site_tools first - # return importlib.import_module(self.name) - # except ImportError as e: - # # Then try modules in main distribution - # try: - # return importlib.import_module('SCons.Tool.'+self.name) - # except ImportError as e: - # if str(e) != "No module named %s" % self.name: - # raise SCons.Errors.EnvironmentError(e) - # try: - # import zipimport - # except ImportError: - # pass - # else: - # for aPath in self.toolpath: - # try: - # importer = zipimport.zipimporter(aPath) - # return importer.load_module(self.name) - # except ImportError as e: - # pass - # - # finally: - # sys.path = oldpythonpath sys.path = oldpythonpath -- cgit v0.12 From a645a0b9a3a27d0408fb2ba2517bede305dc51c0 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 30 Mar 2017 21:25:44 -0400 Subject: More comments in test to highlight their purpose --- test/toolpath/basic.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/toolpath/basic.py b/test/toolpath/basic.py index ce90f35..86dafca 100644 --- a/test/toolpath/basic.py +++ b/test/toolpath/basic.py @@ -44,6 +44,7 @@ print("env2['ZIP'] =", env2.get('ZIP')) print("env2['TOOL_zip1'] =", env2.get('TOOL_zip1')) print("env2['TOOLDIR_zip'] =", env2.get('TOOLDIR_zip')) +# Only find tools in current dir, or Scons.Tool.TOOLNAME env3 = Environment(tools=['zip'], toolpath=['.']) print("env3['ZIP'] =", env3.get('ZIP')) print("env3['TOOL_zip1'] =", env3.get('TOOL_zip1')) -- cgit v0.12 From d925ff5bccb8c2a73fdc9e4395ffd4d2a4a3bab1 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 31 Mar 2017 15:25:39 -0400 Subject: py2/3 fix lineending on generated c file. Some MSVC's complain about non CR/LF line endings --- test/srcchange.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/srcchange.py b/test/srcchange.py index f9e1523..2f5692a 100644 --- a/test/srcchange.py +++ b/test/srcchange.py @@ -72,7 +72,7 @@ exe = env.Program('main.c') env.Default(exe) """ % locals()) -test.write('main.c', r"""\ +test.write('main.c', r""" #include #include #include @@ -83,7 +83,7 @@ main(int argc, char *argv[]) exit (0); } -""") +""",mode='w') test.write('revnum.in', '3.2\n') -- cgit v0.12 From e92f93fd89107e1e2288a739301f92d14fccb11c Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 31 Mar 2017 16:12:30 -0400 Subject: py2/3 fix test.read mode='r' --- test/SideEffect/parallel.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/SideEffect/parallel.py b/test/SideEffect/parallel.py index f750903..63538f3 100644 --- a/test/SideEffect/parallel.py +++ b/test/SideEffect/parallel.py @@ -35,7 +35,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() -test.write('build.py', """\ +test.write('build.py', """ import os import sys import time @@ -93,7 +93,7 @@ log_lines = [ 'g2.in -> g2.out', ] -test.must_contain_all_lines(test.read('log.txt'), log_lines) +test.must_contain_all_lines(test.read('log.txt', mode='r'), log_lines) test.pass_test() -- cgit v0.12 From 2fd850a8e13529b888cdd7532547bde9b4a8527e Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 31 Mar 2017 16:14:23 -0400 Subject: py2/3 fix test.read mode='r', swap fail_test(test.read( with must_match --- test/RANLIB/RANLIB.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/RANLIB/RANLIB.py b/test/RANLIB/RANLIB.py index 8d64b36..3bcb414 100644 --- a/test/RANLIB/RANLIB.py +++ b/test/RANLIB/RANLIB.py @@ -100,7 +100,7 @@ test.run(arguments = 'b' + _exe, stderr=TestSCons.noisy_ar, match=TestSCons.match_re_dotall) -test.fail_test(test.read('wrapper.out') != "wrapper.py\n") +test.must_match('wrapper.out',"wrapper.py\n", mode='r') test.pass_test() -- cgit v0.12 From a4c7581e1f85b76b7d9b6011aad390c97bb6d29d Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 1 Apr 2017 18:46:06 -0400 Subject: Fix locating java home on mac. fix mode='r' for py2/3 --- QMTest/TestSCons.py | 35 +++++++++++++++++++++++++++-------- test/Repository/Java.py | 2 +- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index d33eae7..6b087c0 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -22,6 +22,7 @@ import re import shutil import sys import time +import subprocess from TestCommon import * from TestCommon import __all__ @@ -729,16 +730,34 @@ class TestSCons(TestCommon): result.append(os.path.join(d,'linux')) return result - - def java_where_java_home(self,version=None): + def java_where_java_home(self, version=None): if sys.platform[:6] == 'darwin': + # osx 10.11, 10.12 + home_tool = '/usr/libexec/java_home' + java_home = False + if os.path.exists(home_tool): + java_home = subprocess.check_output(home_tool).strip() + java_home = java_home.decode() + if version is None: - home = '/System/Library/Frameworks/JavaVM.framework/Home' + if java_home: + return java_home + else: + homes = ['/System/Library/Frameworks/JavaVM.framework/Home', + # osx 10.10 + '/System/Library/Frameworks/JavaVM.framework/Versions/Current/Home'] + for home in homes: + if os.path.exists(home): + return home + else: - home = '/System/Library/Frameworks/JavaVM.framework/Versions/%s/Home' % version - if not os.path.exists(home): - # This works on OSX 10.10 - home = '/System/Library/Frameworks/JavaVM.framework/Versions/Current/' + if java_home.find('jdk%s'%version) != -1: + return java_home + else: + home = '/System/Library/Frameworks/JavaVM.framework/Versions/%s/Home' % version + if not os.path.exists(home): + # This works on OSX 10.10 + home = '/System/Library/Frameworks/JavaVM.framework/Versions/Current/' else: jar = self.java_where_jar(version) home = os.path.normpath('%s/..'%jar) @@ -1028,7 +1047,7 @@ SConscript( sconscript ) nols = nols + "|" nols = nols + ")" lastEnd = 0 - logfile = self.read(self.workpath(logfile)) + logfile = self.read(self.workpath(logfile), mode='r') # Some debug code to keep around.. # sys.stderr.write("LOGFILE[%s]:%s"%(type(logfile),logfile)) diff --git a/test/Repository/Java.py b/test/Repository/Java.py index dc6f202..fce85cd 100644 --- a/test/Repository/Java.py +++ b/test/Repository/Java.py @@ -43,8 +43,8 @@ java = test.java_where_java() os.environ['JAVA_HOME'] = test.java_where_java_home(java_version) ############################################################################### - # + test.subdir('rep1', ['rep1', 'src'], 'work1', 'work2') -- cgit v0.12 From 6b5a4152a892c3a66943ae7afdec2b28c71a08a0 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 1 Apr 2017 18:52:20 -0400 Subject: Fix dumbdbm/dbm.dumb for py2/3 --- test/SConsignFile/use-dumbdbm.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/test/SConsignFile/use-dumbdbm.py b/test/SConsignFile/use-dumbdbm.py index 02a52da..2dcfa61 100644 --- a/test/SConsignFile/use-dumbdbm.py +++ b/test/SConsignFile/use-dumbdbm.py @@ -35,9 +35,14 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() try: - import dbm.dumb + import dumbdbm + use_dbm = 'dumbdbm' except ImportError: - test.skip_test('No dumbdbm in this version of Python; skipping test.\n') + try: + import dbm.dumb + use_dbm='dbm.dumb' + except ImportError: + test.skip_test('No dumbdbm or dbm.dumb in this version of Python; skipping test.\n') test.subdir('subdir') @@ -53,8 +58,8 @@ sys.exit(0) # test.write('SConstruct', """ import sys -import dumbdbm -SConsignFile('.sconsign', dumbdbm) +import %(use_dbm)s +SConsignFile('.sconsign', %(use_dbm)s) B = Builder(action = r'%(_python_)s build.py $TARGETS $SOURCES') env = Environment(BUILDERS = { 'B' : B }) env.B(target = 'f1.out', source = 'f1.in') -- cgit v0.12 From 6759959aacf334da3589fb62a1d18899a652ebbd Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 1 Apr 2017 14:41:07 -0700 Subject: updates to finding java includes to work with oracle java 8 on linux --- QMTest/TestSCons.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index 6b087c0..ee10508 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -712,7 +712,8 @@ class TestSCons(TestCommon): if not version: version='' jni_dirs = ['/System/Library/Frameworks/JavaVM.framework/Headers/jni.h', - '/usr/lib/jvm/default-java/include/jni.h'] + '/usr/lib/jvm/default-java/include/jni.h', + '/usr/lib/jvm/java-*-oracle/include/jni.h'] else: jni_dirs = ['/System/Library/Frameworks/JavaVM.framework/Versions/%s*/Headers/jni.h'%version] jni_dirs.extend(['/usr/lib/jvm/java-*-sun-%s*/include/jni.h'%version, -- cgit v0.12 From 386952783dce90bbe08b5585ce76bf13565fcba5 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 1 Apr 2017 19:21:54 -0400 Subject: pep8 --- QMTest/TestCmd.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index 448553f..d9f59c0 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -452,6 +452,7 @@ def pass_test(self = None, condition = 1, function = None): sys.stderr.write("PASSED\n") sys.exit(0) + def match_exact(lines = None, matches = None): """ """ @@ -466,6 +467,7 @@ def match_exact(lines = None, matches = None): return return 1 + def match_caseinsensitive(lines = None, matches = None): """ """ -- cgit v0.12 From 11a00db9d5fd5f8f5377f65d3894ea90c25734fe Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 1 Apr 2017 19:22:18 -0400 Subject: macosx improve logic to find jni.h --- QMTest/TestSCons.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index ee10508..467d5a8 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -707,8 +707,15 @@ class TestSCons(TestCommon): """ Return java include paths compiling java jni code """ - import glob import sys + + result = [] + if sys.platform[:6] == 'darwin': + java_home = self.java_where_java_home(version) + jni_path = os.path.join(java_home,'include','jni.h') + if os.path.exists(jni_path): + result.append(os.path.dirname(jni_path)) + if not version: version='' jni_dirs = ['/System/Library/Frameworks/JavaVM.framework/Headers/jni.h', @@ -723,7 +730,7 @@ class TestSCons(TestCommon): if not dirs: return None d=os.path.dirname(self.paths(jni_dirs)[0]) - result=[d] + result.append(d) if sys.platform == 'win32': result.append(os.path.join(d,'win32')) -- cgit v0.12 From f4ddb6da81d58b0ed53ac3c15a4275768bfa49a4 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 1 Apr 2017 19:22:44 -0400 Subject: fix to run on mac. explicitly request swig tool --- test/Java/multi-step.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Java/multi-step.py b/test/Java/multi-step.py index b43d641..01a3163 100644 --- a/test/Java/multi-step.py +++ b/test/Java/multi-step.py @@ -74,7 +74,7 @@ test.subdir(['src'], test.write(['SConstruct'], """\ import os,sys -env=Environment(tools = ['default', 'javac', 'javah'], +env=Environment(tools = ['default', 'javac', 'javah', 'swig'], CPPPATH=%(where_java_include)s, JAVAC = r'%(where_javac)s', JAVAH = r'%(where_javah)s') -- cgit v0.12 From c0509b9bbd54b25cdc0e9752cea3d1a303e72ccc Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 1 Apr 2017 17:04:25 -0700 Subject: py2/3 fix binary file write issue --- test/TEX/auxiliaries.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/TEX/auxiliaries.py b/test/TEX/auxiliaries.py index 832e809..e471ad6 100644 --- a/test/TEX/auxiliaries.py +++ b/test/TEX/auxiliaries.py @@ -76,7 +76,7 @@ envc.Default(test_ps) envc.Default(test_pdf) """) -test.write(['docs', 'my.bib'], """\ +test.write(['docs', 'my.bib'], r"""\ @ARTICLE{Mikhin, author = "Dmitry {\uppercase{Y}u}. Mikhin", title = "Blah!", @@ -86,7 +86,7 @@ test.write(['docs', 'my.bib'], """\ number = "3", pages = "1--2" } -""") +""",mode='w') tex_input = r"""\documentclass{article} -- cgit v0.12 From 4bd38e06ea2bfe5a1c7b9fdb6a962eef33e8a1ef Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 2 Apr 2017 22:48:15 -0400 Subject: fix test/Configure/ConfigureDryRunTest read logfile as non binary --- QMTest/TestSCons.py | 1 - 1 file changed, 1 deletion(-) diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index 467d5a8..b9d7377 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -1043,7 +1043,6 @@ SConscript( sconscript ) raise NoMatch(lastEnd) return m.end() + lastEnd try: - #print(len(os.linesep)) ls = os.linesep nols = "(" for i in range(len(ls)): -- cgit v0.12 From 870764ac99c8fd4b0622d7dcf7ca3163aa32e5dc Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 2 Apr 2017 22:57:10 -0400 Subject: Fix runtest.py to work with win32 paths specified as .\test\xyz --- runtest.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/runtest.py b/runtest.py index ae456a2..75e9eb7 100755 --- a/runtest.py +++ b/runtest.py @@ -663,6 +663,7 @@ def find_Tests_py(directory): def find_py(directory): """ Look for end-to-end tests """ result = [] + for dirpath, dirnames, filenames in os.walk(directory): # Skip folders containing a sconstest.skip file if 'sconstest.skip' in filenames: @@ -707,6 +708,8 @@ else: testpaths = args for tp in testpaths: + # Clean up path so it can match startswith's below + tp = os.path.normpath(tp) for path in glob.glob(tp): if os.path.isdir(path): if path.startswith('src'): -- cgit v0.12 From 4c2f61436f4d48e487262dea9518b321629f7347 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 3 Apr 2017 10:32:45 -0400 Subject: Create docstring for checkLogAndStdout. Add useful comments as well --- QMTest/TestSCons.py | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index b9d7377..adc7db4 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -1031,7 +1031,24 @@ SConscript( sconscript ) def checkLogAndStdout(self, checks, results, cached, logfile, sconf_dir, sconstruct, - doCheckLog=1, doCheckStdout=1): + doCheckLog=True, doCheckStdout=True): + """ + + Parameters + ---------- + checks + results + cached + logfile + sconf_dir + sconstruct + doCheckLog : check specified log file, defaults to true + doCheckStdout : Check stdout, defaults to true + + Returns + ------- + + """ class NoMatch(Exception): def __init__(self, p): @@ -1043,6 +1060,13 @@ SConscript( sconscript ) raise NoMatch(lastEnd) return m.end() + lastEnd try: + + # Build regexp for a character which is not + # a linesep, and in the case of CR/LF + # build it with both CR and CR/LF + # TODO: Not sure why this is a good idea. A static string + # could do the same since we only have two variations + # to do with? ls = os.linesep nols = "(" for i in range(len(ls)): @@ -1054,6 +1078,8 @@ SConscript( sconscript ) nols = nols + "|" nols = nols + ")" lastEnd = 0 + + # Read the whole logfile logfile = self.read(self.workpath(logfile), mode='r') # Some debug code to keep around.. @@ -1063,13 +1089,16 @@ SConscript( sconscript ) logfile.find( "scons: warning: The stored build " "information has an unexpected class." ) >= 0): self.fail_test() + sconf_dir = sconf_dir sconstruct = sconstruct log = r'file\ \S*%s\,line \d+:' % re.escape(sconstruct) + ls if doCheckLog: lastEnd = matchPart(log, logfile, lastEnd) + log = "\t" + re.escape("Configure(confdir = %s)" % sconf_dir) + ls if doCheckLog: lastEnd = matchPart(log, logfile, lastEnd) + rdstr = "" cnt = 0 for check,result,cache_desc in zip(checks, results, cached): -- cgit v0.12 From 5eb18d24a338f99ee100c77c3e822f726de80cf7 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 3 Apr 2017 11:41:06 -0400 Subject: py2/3 and win/non-win Fixed: checkLogAndStdout to us \n's instead of platform native by using mode='r'. In addition to being simpler we now avoid mixing byte strings with normal strings on py3. --- QMTest/TestSCons.py | 78 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 23 deletions(-) diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index adc7db4..c35a2b3 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -1033,16 +1033,29 @@ SConscript( sconscript ) logfile, sconf_dir, sconstruct, doCheckLog=True, doCheckStdout=True): """ - + Used to verify the expected output from using Configure() + via the contents of one or both of stdout or config.log file. + The checks, results, cached parameters all are zipped together + for use in comparing results. + + TODO: Perhaps a better API makes sense? + Parameters ---------- - checks - results - cached - logfile - sconf_dir - sconstruct + checks : The Configure checks being run + + results : The expected results for each check + + cached : If the corresponding check is expected to be cached + + logfile : Name of the config log + + sconf_dir : Name of the sconf dir + + sconstruct : SConstruct file name + doCheckLog : check specified log file, defaults to true + doCheckStdout : Check stdout, defaults to true Returns @@ -1055,10 +1068,14 @@ SConscript( sconscript ) self.pos = p def matchPart(log, logfile, lastEnd, NoMatch=NoMatch): + """ + Match part of the logfile + """ m = re.match(log, logfile[lastEnd:]) if not m: raise NoMatch(lastEnd) return m.end() + lastEnd + try: # Build regexp for a character which is not @@ -1067,16 +1084,22 @@ SConscript( sconscript ) # TODO: Not sure why this is a good idea. A static string # could do the same since we only have two variations # to do with? - ls = os.linesep - nols = "(" - for i in range(len(ls)): - nols = nols + "(" - for j in range(i): - nols = nols + ls[j] - nols = nols + "[^" + ls[i] + "])" - if i < len(ls)-1: - nols = nols + "|" - nols = nols + ")" + # ls = os.linesep + # nols = "(" + # for i in range(len(ls)): + # nols = nols + "(" + # for j in range(i): + # nols = nols + ls[j] + # nols = nols + "[^" + ls[i] + "])" + # if i < len(ls)-1: + # nols = nols + "|" + # nols = nols + ")" + # + # Replaced above logic with \n as we're reading the file + # using non-binary read. Python will translate \r\n -> \n + # For us. + ls = '\n' + nols = '([^\n])' lastEnd = 0 # Read the whole logfile @@ -1086,30 +1109,35 @@ SConscript( sconscript ) # sys.stderr.write("LOGFILE[%s]:%s"%(type(logfile),logfile)) if (doCheckLog and - logfile.find( "scons: warning: The stored build " - "information has an unexpected class." ) >= 0): + logfile.find("scons: warning: The stored build information has an unexpected class.") >= 0): self.fail_test() sconf_dir = sconf_dir sconstruct = sconstruct log = r'file\ \S*%s\,line \d+:' % re.escape(sconstruct) + ls - if doCheckLog: lastEnd = matchPart(log, logfile, lastEnd) + if doCheckLog: + lastEnd = matchPart(log, logfile, lastEnd) log = "\t" + re.escape("Configure(confdir = %s)" % sconf_dir) + ls - if doCheckLog: lastEnd = matchPart(log, logfile, lastEnd) + if doCheckLog: + lastEnd = matchPart(log, logfile, lastEnd) rdstr = "" cnt = 0 for check,result,cache_desc in zip(checks, results, cached): log = re.escape("scons: Configure: " + check) + ls - if doCheckLog: lastEnd = matchPart(log, logfile, lastEnd) + + if doCheckLog: + lastEnd = matchPart(log, logfile, lastEnd) + log = "" result_cached = 1 for bld_desc in cache_desc: # each TryXXX for ext, flag in bld_desc: # each file in TryBuild file = os.path.join(sconf_dir,"conftest_%d%s" % (cnt, ext)) if flag == self.NCR: + # NCR = Non Cached Rebuild # rebuild will pass if ext in ['.c', '.cpp']: log=log + re.escape(file + " <-") + ls @@ -1118,6 +1146,7 @@ SConscript( sconscript ) log=log + "(" + nols + "*" + ls +")*?" result_cached = 0 if flag == self.CR: + # CR = cached rebuild (up to date)s # up to date log=log + \ re.escape("scons: Configure: \"%s\" is up to date." @@ -1143,7 +1172,10 @@ SConscript( sconscript ) result = "(cached) " + result rdstr = rdstr + re.escape(check) + re.escape(result) + "\n" log=log + re.escape("scons: Configure: " + result) + ls + ls - if doCheckLog: lastEnd = matchPart(log, logfile, lastEnd) + + if doCheckLog: + lastEnd = matchPart(log, logfile, lastEnd) + log = "" if doCheckLog: lastEnd = matchPart(ls, logfile, lastEnd) if doCheckLog and lastEnd != len(logfile): -- cgit v0.12 From ee1ea0e9f81bd520e2047b665f65f3596d2f7f51 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 3 Apr 2017 11:42:08 -0400 Subject: Change checkLogAndStdout() call to use boolean flag instead of 0/1 for clarity. --- test/Configure/ConfigureDryRunError.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Configure/ConfigureDryRunError.py b/test/Configure/ConfigureDryRunError.py index b87162c..2a8e449 100644 --- a/test/Configure/ConfigureDryRunError.py +++ b/test/Configure/ConfigureDryRunError.py @@ -94,7 +94,7 @@ test.checkLogAndStdout(["Checking for C library %s... " % lib, [[((".c", CR), (_obj, CR))], [((".c", CR), (_obj, CF))]], "config.log", ".sconf_temp", "SConstruct", - doCheckLog=0) + doCheckLog=False) newLog = test.read(test.workpath('config.log'), mode='r') if newLog != oldLog: -- cgit v0.12 From b62645bd92013b90b14a0835554f690a5acae61c Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 3 Apr 2017 13:07:02 -0400 Subject: change logic to drop ./ or .\ from front of specified test/testpath so logic to match test or src will work properly. This is mainly just useful on windows when autocompleting paths --- runtest.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/runtest.py b/runtest.py index 75e9eb7..0d9bbaf 100755 --- a/runtest.py +++ b/runtest.py @@ -709,7 +709,13 @@ else: for tp in testpaths: # Clean up path so it can match startswith's below - tp = os.path.normpath(tp) + # sys.stderr.write("Changed:%s->"%tp) + # remove leading ./ or .\ + if tp[0] == '.' and tp[1] in (os.sep, os.altsep): + tp = tp[2:] + # tp = os.path.normpath(tp) + # sys.stderr.write('->%s<-'%tp) + # sys.stderr.write("to:%s\n"%tp) for path in glob.glob(tp): if os.path.isdir(path): if path.startswith('src'): -- cgit v0.12 From c7f9a243285e7f2eff05a6d984491cf534909025 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 3 Apr 2017 14:15:37 -0400 Subject: py2/3. Rename SCons.Tool.gettext to SCons.Tool.gettext_tool and change tool loading logic to have a dictionary of TOOL_ALIASES to handle this. --- src/engine/SCons/Tool/__init__.py | 19 ++++++++++---- src/engine/SCons/Tool/gettext.py | 48 ----------------------------------- src/engine/SCons/Tool/gettext_tool.py | 48 +++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 53 deletions(-) delete mode 100644 src/engine/SCons/Tool/gettext.py create mode 100644 src/engine/SCons/Tool/gettext_tool.py diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index 6291b99..d3cd1c2 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -98,9 +98,16 @@ for suffix in LaTeXSuffixes: SourceFileScanner.add_scanner(suffix, PDFLaTeXScanner) +# Tool aliases are needed for those tools whos module names also +# occur in the python standard library. This causes module shadowing and +# can break using python library functions under python3 +TOOL_ALIASES = {'gettext':'gettext_tool'} + class Tool(object): def __init__(self, name, toolpath=[], **kw): - self.name = name + + # Rename if there's a TOOL_ALIAS for this tool + self.name = TOOL_ALIASES.get(name,name) self.toolpath = toolpath + DefaultToolpath # remember these so we can merge them into the call self.init_kw = kw @@ -112,7 +119,6 @@ class Tool(object): self.options = module.options def _tool_module(self): - # TODO: Interchange zipimport with normal initialization for better error reporting oldpythonpath = sys.path sys.path = self.toolpath + sys.path # sys.stderr.write("Tool:%s\nPATH:%s\n"%(self.name,sys.path)) @@ -160,6 +166,7 @@ class Tool(object): # sys.stderr.write("SCONS.TOOL path:%s\n" % sys.modules['SCons.Tool'].__path__) debug = False spec = None + found_name = self.name for path in self.toolpath: file_path = os.path.join(path, "%s.py"%self.name) file_package = os.path.join(path, self.name) @@ -181,6 +188,8 @@ class Tool(object): if spec is None: if debug: sys.stderr.write("NO SPEC :%s\n"%self.name) spec = importlib.util.find_spec("."+self.name, package='SCons.Tool') + if spec: + found_name = 'SCons.Tool.'+self.name if debug: sys.stderr.write("Spec Found? .%s :%s\n"%(self.name, spec)) if spec is None: @@ -194,16 +203,16 @@ class Tool(object): raise SCons.Errors.EnvironmentError(error_string) # Don't reload a tool we already loaded. - sys_modules_value = sys.modules.get(self.name,False) + sys_modules_value = sys.modules.get(found_name,False) if sys_modules_value and sys_modules_value.__file__ == spec.origin: - return sys.modules[self.name] + return sys.modules[found_name] else: # Not sure what to do in the case that there already # exists sys.modules[self.name] but the source file is # different.. ? spec.loader.exec_module(module) - sys.modules[self.name] = module + sys.modules[found_name] = module return module diff --git a/src/engine/SCons/Tool/gettext.py b/src/engine/SCons/Tool/gettext.py deleted file mode 100644 index 6031e49..0000000 --- a/src/engine/SCons/Tool/gettext.py +++ /dev/null @@ -1,48 +0,0 @@ -"""gettext tool -""" - - -# __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__" - -############################################################################# -def generate(env,**kw): - import SCons.Tool - from SCons.Tool.GettextCommon \ - import _translate, tool_list - for t in tool_list(env['PLATFORM'], env): - env.Tool(t) - env.AddMethod(_translate, 'Translate') -############################################################################# - -############################################################################# -def exists(env): - from SCons.Tool.GettextCommon \ - import _xgettext_exists, _msginit_exists, \ - _msgmerge_exists, _msgfmt_exists - try: - return _xgettext_exists(env) and _msginit_exists(env) \ - and _msgmerge_exists(env) and _msgfmt_exists(env) - except: - return False -############################################################################# diff --git a/src/engine/SCons/Tool/gettext_tool.py b/src/engine/SCons/Tool/gettext_tool.py new file mode 100644 index 0000000..6031e49 --- /dev/null +++ b/src/engine/SCons/Tool/gettext_tool.py @@ -0,0 +1,48 @@ +"""gettext tool +""" + + +# __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__" + +############################################################################# +def generate(env,**kw): + import SCons.Tool + from SCons.Tool.GettextCommon \ + import _translate, tool_list + for t in tool_list(env['PLATFORM'], env): + env.Tool(t) + env.AddMethod(_translate, 'Translate') +############################################################################# + +############################################################################# +def exists(env): + from SCons.Tool.GettextCommon \ + import _xgettext_exists, _msginit_exists, \ + _msgmerge_exists, _msgfmt_exists + try: + return _xgettext_exists(env) and _msginit_exists(env) \ + and _msgmerge_exists(env) and _msgfmt_exists(env) + except: + return False +############################################################################# -- cgit v0.12 From 01082e83bbd3676cd126bcd9a0fd1a0a77366978 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 3 Apr 2017 14:24:06 -0400 Subject: py2/3 another module shadowing issue... test file bz2.py blocking python lib module bz2.py --- test/packaging/tar/bz2.py | 69 ------------------------------------- test/packaging/tar/bz2_packaging.py | 69 +++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 69 deletions(-) delete mode 100644 test/packaging/tar/bz2.py create mode 100644 test/packaging/tar/bz2_packaging.py diff --git a/test/packaging/tar/bz2.py b/test/packaging/tar/bz2.py deleted file mode 100644 index 1552fd1..0000000 --- a/test/packaging/tar/bz2.py +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env python -# -# __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__" - -""" -This tests the SRC bz2 packager, which does the following: - - create a tar package from the specified files -""" - -import TestSCons - -python = TestSCons.python - -test = TestSCons.TestSCons() - -tar = test.detect('TAR', 'tar') - -if tar: - test.subdir('src') - - test.write( [ 'src', 'main.c' ], r""" -int main( int argc, char* argv[] ) -{ - return 0; -} -""") - - test.write('SConstruct', """ -Program( 'src/main.c' ) -env=Environment(tools=['default', 'packaging']) -env.Package( PACKAGETYPE = 'src_tarbz2', - target = 'src.tar.bz2', - PACKAGEROOT = 'test', - source = [ 'src/main.c', 'SConstruct' ] ) -""") - - test.run(arguments='', stderr = None) - - test.must_exist( 'src.tar.bz2' ) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/packaging/tar/bz2_packaging.py b/test/packaging/tar/bz2_packaging.py new file mode 100644 index 0000000..1552fd1 --- /dev/null +++ b/test/packaging/tar/bz2_packaging.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python +# +# __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__" + +""" +This tests the SRC bz2 packager, which does the following: + - create a tar package from the specified files +""" + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + +tar = test.detect('TAR', 'tar') + +if tar: + test.subdir('src') + + test.write( [ 'src', 'main.c' ], r""" +int main( int argc, char* argv[] ) +{ + return 0; +} +""") + + test.write('SConstruct', """ +Program( 'src/main.c' ) +env=Environment(tools=['default', 'packaging']) +env.Package( PACKAGETYPE = 'src_tarbz2', + target = 'src.tar.bz2', + PACKAGEROOT = 'test', + source = [ 'src/main.c', 'SConstruct' ] ) +""") + + test.run(arguments='', stderr = None) + + test.must_exist( 'src.tar.bz2' ) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: -- cgit v0.12 From 56159f75088d1ab79293ff6c23d5f5f8e1b8209d Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 3 Apr 2017 15:10:31 -0400 Subject: py2/3 define __lt__ for nodes, so sort will work on py3 --- src/engine/SCons/Node/FS.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index f455edb..33e4a2d 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -690,6 +690,10 @@ class Base(SCons.Node.Node): return self._save_str() return self._get_str() + def __lt__(self, other): + """ less than operator used by sorting on py3""" + return str(self) < str(other) + @SCons.Memoize.CountMethodCall def _save_str(self): try: -- cgit v0.12 From e7cfd6de947315b99c88ee74cab2b382bdd4046c Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 3 Apr 2017 15:10:51 -0400 Subject: py2/3 ensure that errstr is string and not bytes --- src/engine/SCons/Errors.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/engine/SCons/Errors.py b/src/engine/SCons/Errors.py index 3cc9c6d..d711818 100644 --- a/src/engine/SCons/Errors.py +++ b/src/engine/SCons/Errors.py @@ -32,8 +32,9 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.Util + class BuildError(Exception): - """ Errors occuring while building. + """ Errors occurring while building. BuildError have the following attributes: @@ -90,8 +91,9 @@ class BuildError(Exception): node=None, errstr="Unknown error", status=2, exitstatus=2, filename=None, executor=None, action=None, command=None, exc_info=(None, None, None)): - - self.errstr = errstr + + # py3: errstr should be string and not bytes. + self.errstr = SCons.Util.to_str(errstr) self.status = status self.exitstatus = exitstatus self.filename = filename -- cgit v0.12 From 8386649b64e49a2c009e6b6e47afe8a09ac225b1 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 3 Apr 2017 15:22:43 -0400 Subject: py2/3 fix possible byte string of machine name --- src/engine/SCons/Tool/rpmutils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/SCons/Tool/rpmutils.py b/src/engine/SCons/Tool/rpmutils.py index 3eeed1d..e2d6997 100644 --- a/src/engine/SCons/Tool/rpmutils.py +++ b/src/engine/SCons/Tool/rpmutils.py @@ -42,6 +42,8 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import platform import subprocess +import SCons.Util + # Start of rpmrc dictionaries (Marker, don't change or remove!) os_canon = { 'AIX' : ['AIX','5'], @@ -444,6 +446,7 @@ def defaultMachine(use_rpm_default=True): try: # This should be the most reliable way to get the default arch rmachine = subprocess.check_output(['rpm', '--eval=%_target_cpu'], shell=False).rstrip() + rmachine = SCons.Util.to_str(rmachine) except Exception as e: # Something went wrong, try again by looking up platform.machine() return defaultMachine(False) -- cgit v0.12 From 7801b74049c575614aaf1e73e571abf44919c4bc Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 3 Apr 2017 12:31:55 -0700 Subject: py2/3 ensure rpmbuild output from popen is string and not bytes --- src/engine/SCons/Tool/rpm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/Tool/rpm.py b/src/engine/SCons/Tool/rpm.py index b7d65a8..5198f84 100644 --- a/src/engine/SCons/Tool/rpm.py +++ b/src/engine/SCons/Tool/rpm.py @@ -71,7 +71,7 @@ def build_rpm(target, source, env): stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - output = handle.stdout.read() + output = SCons.Util.to_str(handle.stdout.read()) status = handle.wait() if status: -- cgit v0.12 From dd360684403d6c19649da9bca19212fab65fec86 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 3 Apr 2017 12:32:06 -0700 Subject: py2/3 mode=r fix --- test/packaging/rpm/tagging.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/packaging/rpm/tagging.py b/test/packaging/rpm/tagging.py index 3016274..a558242 100644 --- a/test/packaging/rpm/tagging.py +++ b/test/packaging/rpm/tagging.py @@ -96,7 +96,7 @@ test.fail_test( not os.popen('rpm -qpl %s' % machine_rpm).read()=='/bin/main\n') test.fail_test( not os.popen('rpm -qpl %s' % src_rpm).read()=='foo-1.2.3.spec\nfoo-1.2.3.tar.gz\n') expect = '(0755, root, users) /bin/main' -test.must_contain_all_lines(test.read('foo-1.2.3.spec'), [expect]) +test.must_contain_all_lines(test.read('foo-1.2.3.spec',mode='r'), [expect]) test.pass_test() -- cgit v0.12 From 9f917ba625b61071a4c181d98f1e9dada4dbd569 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 3 Apr 2017 17:43:37 -0400 Subject: py2/3 swap to must_match and mode=r --- test/Install/InstallAs.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/Install/InstallAs.py b/test/Install/InstallAs.py index fe860b0..537ea3a 100644 --- a/test/Install/InstallAs.py +++ b/test/Install/InstallAs.py @@ -75,10 +75,10 @@ Install file: "%(subdir_file3_in)s" as "%(install_file3_out)s" test.run(arguments = '.', stdout=expect) -test.fail_test(test.read(install_file1_out) != "file1.in\n") -test.fail_test(test.read(install_file2_out) != "file2.in\n") -test.fail_test(test.read(install_file3_out) != "subdir/file3.in\n") -test.fail_test(test.read(install_file1a_out) != "file1.in\n") +test.must_match(install_file1_out, "file1.in\n", mode='r') +test.must_match(install_file2_out, "file2.in\n", mode='r') +test.must_match(install_file3_out, "subdir/file3.in\n", mode='r') +test.must_match(install_file1a_out, "file1.in\n", mode='r') test.up_to_date(arguments = '.') -- cgit v0.12 From f80aee089f44d50877e65f049424df212c867ff3 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 3 Apr 2017 17:49:56 -0400 Subject: py2/3 mode=r/w fixes --- QMTest/TestSCons.py | 8 ++++---- test/QT/QTFLAGS.py | 2 +- test/QT/source-from-ui.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index c35a2b3..b6366a6 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -871,12 +871,12 @@ output = None impl = 0 opt_string = '' for opt, arg in cmd_opts: - if opt == '-o': output = open(arg, 'wb') + if opt == '-o': output = open(arg, 'w') elif opt == '-i': impl = 1 else: opt_string = opt_string + ' ' + opt output.write("/* mymoc.py%s */\\n" % opt_string) for a in args: - contents = open(a, 'rb').read() + contents = open(a, 'r').read() a = a.replace('\\\\', '\\\\\\\\') subst = r'{ my_qt_symbol( "' + a + '\\\\n" ); }' if impl: @@ -897,7 +897,7 @@ source = None opt_string = '' for arg in sys.argv[1:]: if output_arg: - output = open(arg, 'wb') + output = open(arg, 'w') output_arg = 0 elif impl_arg: impl = arg @@ -911,7 +911,7 @@ for arg in sys.argv[1:]: else: if source: sys.exit(1) - source = open(arg, 'rb') + source = open(arg, 'r') sourceFile = arg output.write("/* myuic.py%s */\\n" % opt_string) if impl: diff --git a/test/QT/QTFLAGS.py b/test/QT/QTFLAGS.py index f6aa00f..8d266ad 100644 --- a/test/QT/QTFLAGS.py +++ b/test/QT/QTFLAGS.py @@ -148,7 +148,7 @@ test.must_exist(['work1', 'mmmmocFromH.cxx'], def _flagTest(test,fileToContentsStart): for f,c in fileToContentsStart.items(): - if test.read(test.workpath('work1', f)).find(c) != 0: + if test.read(test.workpath('work1', f), mode='r').find(c) != 0: return 1 return 0 diff --git a/test/QT/source-from-ui.py b/test/QT/source-from-ui.py index b8be72e..7922717 100644 --- a/test/QT/source-from-ui.py +++ b/test/QT/source-from-ui.py @@ -124,7 +124,7 @@ test.must_not_exist(test.workpath(moc)) test.must_not_exist(test.workpath(cpp)) test.must_not_exist(test.workpath(h)) -cppContents = test.read(test.workpath('build', cpp)) +cppContents = test.read(test.workpath('build', cpp), mode='r') test.fail_test(cppContents.find('#include "aaa.ui.h"') == -1) test.run(arguments = "variant_dir=1 chdir=1 " + -- cgit v0.12 From 11e9e1615ceeb6a2ca8d3463b94df84a6fca6ac5 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 3 Apr 2017 20:33:13 -0400 Subject: added SCons.Tool loaded tools to SCons.Tool namespace --- src/engine/SCons/Tool/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index d3cd1c2..99e0770 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -167,6 +167,7 @@ class Tool(object): debug = False spec = None found_name = self.name + add_to_scons_tools_namespace = False for path in self.toolpath: file_path = os.path.join(path, "%s.py"%self.name) file_package = os.path.join(path, self.name) @@ -190,6 +191,7 @@ class Tool(object): spec = importlib.util.find_spec("."+self.name, package='SCons.Tool') if spec: found_name = 'SCons.Tool.'+self.name + add_to_scons_tools_namespace = True if debug: sys.stderr.write("Spec Found? .%s :%s\n"%(self.name, spec)) if spec is None: @@ -213,6 +215,10 @@ class Tool(object): spec.loader.exec_module(module) sys.modules[found_name] = module + if add_to_scons_tools_namespace: + # If we found it in SCons.Tool, then add it to the module + setattr(SCons.Tool, self.name, module) + return module -- cgit v0.12 From 441e03a5e41c7948f8978bc45fc6ca8e52d493ed Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 3 Apr 2017 20:33:51 -0400 Subject: py2/3 more work on getting exception handling to work properly on both py2/3 --- src/engine/SCons/Taskmaster.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/SCons/Taskmaster.py b/src/engine/SCons/Taskmaster.py index c44ccee..ec7b9f2 100644 --- a/src/engine/SCons/Taskmaster.py +++ b/src/engine/SCons/Taskmaster.py @@ -542,6 +542,7 @@ class Task(object): exc_type, exc_value = exc exc_traceback = None + # raise exc_type(exc_value).with_traceback(exc_traceback) if sys.version_info[0] == 2: exec("raise exc_type, exc_value, exc_traceback") else: # sys.version_info[0] == 3: @@ -960,7 +961,7 @@ class Taskmaster(object): task = self.tasker(self, tlist, node in self.original_top, node) try: task.make_ready() - except: + except Exception as e : # We had a problem just trying to get this task ready (like # a child couldn't be linked to a VariantDir when deciding # whether this node is current). Arrange to raise the -- cgit v0.12 From b65b808c7d08bae8887997f0a3120bf647f28212 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 3 Apr 2017 20:34:05 -0400 Subject: pep8 --- src/engine/SCons/Tool/install.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/SCons/Tool/install.py b/src/engine/SCons/Tool/install.py index ee15753..c0a193b 100644 --- a/src/engine/SCons/Tool/install.py +++ b/src/engine/SCons/Tool/install.py @@ -305,6 +305,7 @@ def InstallBuilderWrapper(env, target=None, source=None, dir=None, **kw): tgt.extend(BaseInstallBuilder(env, target, src, **kw)) return tgt + def InstallAsBuilderWrapper(env, target=None, source=None, **kw): result = [] for src, tgt in map(lambda x, y: (x, y), source, target): @@ -313,6 +314,7 @@ def InstallAsBuilderWrapper(env, target=None, source=None, **kw): BaseVersionedInstallBuilder = None + def InstallVersionedBuilderWrapper(env, target=None, source=None, dir=None, **kw): if target and dir: import SCons.Errors @@ -344,6 +346,7 @@ def InstallVersionedBuilderWrapper(env, target=None, source=None, dir=None, **kw added = None + def generate(env): from SCons.Script import AddOption, GetOption -- cgit v0.12 From 8422f0076020fe92e00aea2ac00c9d0e62f85ab6 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 3 Apr 2017 20:34:25 -0400 Subject: pep8 --- test/TEX/auxiliaries.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/TEX/auxiliaries.py b/test/TEX/auxiliaries.py index e471ad6..98cbf41 100644 --- a/test/TEX/auxiliaries.py +++ b/test/TEX/auxiliaries.py @@ -86,7 +86,7 @@ test.write(['docs', 'my.bib'], r"""\ number = "3", pages = "1--2" } -""",mode='w') +""", mode='w') tex_input = r"""\documentclass{article} -- cgit v0.12 From a000057085cfb29d255b9fc9965f113a459be1a2 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 4 Apr 2017 11:30:32 -0400 Subject: py2/3 os.symlink is now defined for win32, but unless user has privs it will always fail. For not skipping symlink tests --- src/engine/SCons/Node/FSTests.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index d168e49..7366b7b 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -673,7 +673,7 @@ class BaseTestCase(_tempdirTestCase): nonexistent = fs.Entry('nonexistent') assert not nonexistent.isfile() - if hasattr(os, 'symlink'): + if sys.platform != 'win32' and hasattr(os, 'symlink'): def test_islink(self): """Test the Base.islink() method""" test = self.test @@ -1399,7 +1399,7 @@ class FSTestCase(_tempdirTestCase): except SyntaxError: assert c == "" - if hasattr(os, 'symlink'): + if sys.platform != 'win32' and hasattr(os, 'symlink'): os.symlink('nonexistent', test.workpath('dangling_symlink')) e = fs.Entry('dangling_symlink') c = e.get_contents() @@ -1494,16 +1494,14 @@ class FSTestCase(_tempdirTestCase): assert r, r assert not os.path.exists(test.workpath('exists')), "exists was not removed" - symlink = test.workpath('symlink') - try: + if sys.platform != 'win32' and hasattr(os, 'symlink'): + symlink = test.workpath('symlink') os.symlink(test.workpath('does_not_exist'), symlink) assert os.path.islink(symlink) f = fs.File('symlink') r = f.remove() assert r, r assert not os.path.islink(symlink), "symlink was not removed" - except AttributeError: - pass test.write('can_not_remove', "can_not_remove\n") test.writable(test.workpath('.'), 0) -- cgit v0.12 From 35f1025ddee1d8017a35a7dcfcc7bd69620c0b25 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 4 Apr 2017 11:50:19 -0400 Subject: pep8 --- test/Interactive/Alias.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Interactive/Alias.py b/test/Interactive/Alias.py index ab4c64c..d8a46b0 100644 --- a/test/Interactive/Alias.py +++ b/test/Interactive/Alias.py @@ -42,7 +42,7 @@ test.write('foo.in', "foo.in 1\n") -scons = test.start(arguments = '-Q --interactive') +scons = test.start(arguments='-Q --interactive') scons.send("build foo-alias\n") -- cgit v0.12 From 3cc6d46aee79de51fe5017251a126725c72ceba5 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 4 Apr 2017 11:50:54 -0400 Subject: py2/3 ensure strings sent to process are bytes on win32. This fixes most fo the Interactive tests --- QMTest/TestCmd.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index d9f59c0..2c0c0d3 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -736,8 +736,20 @@ class Popen(subprocess.Popen): getattr(self, which).close() setattr(self, which, None) + + 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') + if sys.platform == 'win32':# and subprocess.mswindows: def send(self, input): + input = to_bytes(input) if not self.stdin: return None -- cgit v0.12 From 7284dcce49a1b67799b01245a9c8d48c7cd7d0ed Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 4 Apr 2017 20:53:36 -0400 Subject: pep8 --- src/engine/SCons/Defaults.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py index f1d5bca..ded9539 100644 --- a/src/engine/SCons/Defaults.py +++ b/src/engine/SCons/Defaults.py @@ -485,6 +485,7 @@ def processDefines(defs): l = [str(defs)] return l + def _defines(prefix, defs, suffix, env, c=_concat_ixes): """A wrapper around _concat_ixes that turns a list or string into a list of C preprocessor command-line definitions. @@ -492,6 +493,7 @@ def _defines(prefix, defs, suffix, env, c=_concat_ixes): return c(prefix, env.subst_path(processDefines(defs)), suffix, env) + class NullCmdGenerator(object): """This is a callable class that can be used in place of other command generators if you don't want them to do anything. @@ -510,6 +512,7 @@ class NullCmdGenerator(object): def __call__(self, target, source, env, for_signature=None): return self.cmd + class Variable_Method_Caller(object): """A class for finding a construction variable on the stack and calling one of its methods. -- cgit v0.12 From d30050a18db0ef88c5bc1baa2fd7a5dd094cc034 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 4 Apr 2017 21:48:51 -0400 Subject: py2/3 exceptions in py3 seem to have full package name --- test/Errors/InternalError.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Errors/InternalError.py b/test/Errors/InternalError.py index 8ed6da1..a709597 100644 --- a/test/Errors/InternalError.py +++ b/test/Errors/InternalError.py @@ -47,7 +47,7 @@ test.run(stdout = "scons: Reading SConscript files ...\ninternal error\n", File ".+", line \d+, in .+ File ".+SConstruct", line \d+, in .+ raise InternalError\('error inside'\) -InternalError: error inside +(SCons\.Errors\.|)InternalError: error inside """, status=2) test.pass_test() -- cgit v0.12 From 7f43e9a8008bd6c2830ee1852f238246e68c1252 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Wed, 5 Apr 2017 12:39:27 -0700 Subject: py2/3 fix escaped unicode space to work for both py2/3 --- test/MSVS/vs-10.0-scc-files.py | 4 ++-- test/MSVS/vs-11.0-scc-files.py | 4 ++-- test/MSVS/vs-14.0-scc-files.py | 4 ++-- test/MSVS/vs-7.0-scc-files.py | 4 ++-- test/MSVS/vs-7.1-scc-files.py | 4 ++-- test/MSVS/vs-8.0-scc-files.py | 4 ++-- test/MSVS/vs-9.0-scc-files.py | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/test/MSVS/vs-10.0-scc-files.py b/test/MSVS/vs-10.0-scc-files.py index 32dd9ef..0b8bd76 100644 --- a/test/MSVS/vs-10.0-scc-files.py +++ b/test/MSVS/vs-10.0-scc-files.py @@ -69,9 +69,9 @@ env.MSVSProject(target = 'Test.vcxproj', expected_sln_sccinfo = """\ \tGlobalSection(SourceCodeControl) = preSolution \t\tSccNumberOfProjects = 2 -\t\tSccProjectName0 = Perforce\u0020Project +\t\tSccProjectName0 = Perforce\\u0020Project \t\tSccLocalPath0 = . -\t\tSccProvider0 = MSSCCI:Perforce\u0020SCM +\t\tSccProvider0 = MSSCCI:Perforce\\u0020SCM \t\tCanCheckoutShared = true \t\tSccProjectUniqueName1 = Test.vcxproj \t\tSccLocalPath1 = . diff --git a/test/MSVS/vs-11.0-scc-files.py b/test/MSVS/vs-11.0-scc-files.py index 6d12c79..a25b954 100644 --- a/test/MSVS/vs-11.0-scc-files.py +++ b/test/MSVS/vs-11.0-scc-files.py @@ -69,9 +69,9 @@ env.MSVSProject(target = 'Test.vcxproj', expected_sln_sccinfo = """\ \tGlobalSection(SourceCodeControl) = preSolution \t\tSccNumberOfProjects = 2 -\t\tSccProjectName0 = Perforce\u0020Project +\t\tSccProjectName0 = Perforce\\u0020Project \t\tSccLocalPath0 = . -\t\tSccProvider0 = MSSCCI:Perforce\u0020SCM +\t\tSccProvider0 = MSSCCI:Perforce\\u0020SCM \t\tCanCheckoutShared = true \t\tSccProjectUniqueName1 = Test.vcxproj \t\tSccLocalPath1 = . diff --git a/test/MSVS/vs-14.0-scc-files.py b/test/MSVS/vs-14.0-scc-files.py index c934ac9..b6db6d5 100644 --- a/test/MSVS/vs-14.0-scc-files.py +++ b/test/MSVS/vs-14.0-scc-files.py @@ -69,9 +69,9 @@ env.MSVSProject(target = 'Test.vcxproj', expected_sln_sccinfo = """\ \tGlobalSection(SourceCodeControl) = preSolution \t\tSccNumberOfProjects = 2 -\t\tSccProjectName0 = Perforce\u0020Project +\t\tSccProjectName0 = Perforce\\u0020Project \t\tSccLocalPath0 = . -\t\tSccProvider0 = MSSCCI:Perforce\u0020SCM +\t\tSccProvider0 = MSSCCI:Perforce\\u0020SCM \t\tCanCheckoutShared = true \t\tSccProjectUniqueName1 = Test.vcxproj \t\tSccLocalPath1 = . diff --git a/test/MSVS/vs-7.0-scc-files.py b/test/MSVS/vs-7.0-scc-files.py index 76b4380..8586060 100644 --- a/test/MSVS/vs-7.0-scc-files.py +++ b/test/MSVS/vs-7.0-scc-files.py @@ -71,9 +71,9 @@ env.MSVSProject(target = 'Test.vcproj', expected_sln_sccinfo = """\ \tGlobalSection(SourceCodeControl) = preSolution \t\tSccNumberOfProjects = 2 -\t\tSccProjectName0 = Perforce\u0020Project +\t\tSccProjectName0 = Perforce\\u0020Project \t\tSccLocalPath0 = . -\t\tSccProvider0 = MSSCCI:Perforce\u0020SCM +\t\tSccProvider0 = MSSCCI:Perforce\\u0020SCM \t\tCanCheckoutShared = true \t\tSolutionUniqueID = {SLNGUID} \t\tSccProjectUniqueName1 = Test.vcproj diff --git a/test/MSVS/vs-7.1-scc-files.py b/test/MSVS/vs-7.1-scc-files.py index 219bd0a..8404422 100644 --- a/test/MSVS/vs-7.1-scc-files.py +++ b/test/MSVS/vs-7.1-scc-files.py @@ -71,9 +71,9 @@ env.MSVSProject(target = 'Test.vcproj', expected_sln_sccinfo = """\ \tGlobalSection(SourceCodeControl) = preSolution \t\tSccNumberOfProjects = 2 -\t\tSccProjectName0 = Perforce\u0020Project +\t\tSccProjectName0 = Perforce\\u0020Project \t\tSccLocalPath0 = . -\t\tSccProvider0 = MSSCCI:Perforce\u0020SCM +\t\tSccProvider0 = MSSCCI:Perforce\\u0020SCM \t\tCanCheckoutShared = true \t\tSolutionUniqueID = {SLNGUID} \t\tSccProjectUniqueName1 = Test.vcproj diff --git a/test/MSVS/vs-8.0-scc-files.py b/test/MSVS/vs-8.0-scc-files.py index 1baa407..05a8a5f 100644 --- a/test/MSVS/vs-8.0-scc-files.py +++ b/test/MSVS/vs-8.0-scc-files.py @@ -69,9 +69,9 @@ env.MSVSProject(target = 'Test.vcproj', expected_sln_sccinfo = """\ \tGlobalSection(SourceCodeControl) = preSolution \t\tSccNumberOfProjects = 2 -\t\tSccProjectName0 = Perforce\u0020Project +\t\tSccProjectName0 = Perforce\\u0020Project \t\tSccLocalPath0 = . -\t\tSccProvider0 = MSSCCI:Perforce\u0020SCM +\t\tSccProvider0 = MSSCCI:Perforce\\u0020SCM \t\tCanCheckoutShared = true \t\tSccProjectUniqueName1 = Test.vcproj \t\tSccLocalPath1 = . diff --git a/test/MSVS/vs-9.0-scc-files.py b/test/MSVS/vs-9.0-scc-files.py index e3d37c0..c270010 100644 --- a/test/MSVS/vs-9.0-scc-files.py +++ b/test/MSVS/vs-9.0-scc-files.py @@ -69,9 +69,9 @@ env.MSVSProject(target = 'Test.vcproj', expected_sln_sccinfo = """\ \tGlobalSection(SourceCodeControl) = preSolution \t\tSccNumberOfProjects = 2 -\t\tSccProjectName0 = Perforce\u0020Project +\t\tSccProjectName0 = Perforce\\u0020Project \t\tSccLocalPath0 = . -\t\tSccProvider0 = MSSCCI:Perforce\u0020SCM +\t\tSccProvider0 = MSSCCI:Perforce\\u0020SCM \t\tCanCheckoutShared = true \t\tSccProjectUniqueName1 = Test.vcproj \t\tSccLocalPath1 = . -- cgit v0.12 From d7cc098cde8306ddb8ec017ce3bbb24c7aa64e8d Mon Sep 17 00:00:00 2001 From: William Deegan Date: Wed, 5 Apr 2017 14:35:33 -0700 Subject: remove duplicate definitions for to_bytes and to_str --- QMTest/TestCmd.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index 2c0c0d3..07a3905 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -737,16 +737,6 @@ class Popen(subprocess.Popen): setattr(self, which, None) - 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') - if sys.platform == 'win32':# and subprocess.mswindows: def send(self, input): input = to_bytes(input) -- cgit v0.12 From 1e58c30fd679aca066f330df7d06aa8a4b5e4a1a Mon Sep 17 00:00:00 2001 From: William Deegan Date: Wed, 5 Apr 2017 15:26:35 -0700 Subject: py2/3 bytes/string issues. Added wrapper to re.sub to force items to bytes --- QMTest/TestSCons.py | 44 +++++++++++++++++++++++++++----------------- test/TEX/auxiliaries.py | 4 ++-- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index b6366a6..5a9d21f 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -598,23 +598,33 @@ class TestSCons(TestCommon): return s + @staticmethod + def to_bytes_re_sub(pattern, repl, str, count=0, flags=0): + """ + Wrapper around re.sub to change pattern and repl to bytes to work with + both python 2 & 3 + """ + pattern = to_bytes(pattern) + repl = to_bytes(repl) + return re.sub(pattern, repl, str, count, flags) + def normalize_pdf(self, s): - s = re.sub(r'/(Creation|Mod)Date \(D:[^)]*\)', - r'/\1Date (D:XXXX)', s) - s = re.sub(r'/ID \[<[0-9a-fA-F]*> <[0-9a-fA-F]*>\]', - r'/ID [ ]', s) - s = re.sub(r'/(BaseFont|FontName) /[A-Z]{6}', - r'/\1 /XXXXXX', s) - s = re.sub(r'/Length \d+ *\n/Filter /FlateDecode\n', - r'/Length XXXX\n/Filter /FlateDecode\n', s) + s = self.to_bytes_re_sub(r'/(Creation|Mod)Date \(D:[^)]*\)', + r'/\1Date (D:XXXX)', s) + s = self.to_bytes_re_sub(r'/ID \[<[0-9a-fA-F]*> <[0-9a-fA-F]*>\]', + r'/ID [ ]', s) + s = self.to_bytes_re_sub(r'/(BaseFont|FontName) /[A-Z]{6}', + r'/\1 /XXXXXX', s) + s = self.to_bytes_re_sub(r'/Length \d+ *\n/Filter /FlateDecode\n', + r'/Length XXXX\n/Filter /FlateDecode\n', s) try: import zlib except ImportError: pass else: - begin_marker = '/FlateDecode\n>>\nstream\n' - end_marker = 'endstream\nendobj' + begin_marker = to_bytes('/FlateDecode\n>>\nstream\n') + end_marker = to_bytes('endstream\nendobj') encoded = [] b = s.find(begin_marker, 0) @@ -629,16 +639,16 @@ class TestSCons(TestCommon): for b, e in encoded: r.append(s[x:b]) d = zlib.decompress(s[b:e]) - d = re.sub(r'%%CreationDate: [^\n]*\n', - r'%%CreationDate: 1970 Jan 01 00:00:00\n', d) - d = re.sub(r'%DVIPSSource: TeX output \d\d\d\d\.\d\d\.\d\d:\d\d\d\d', - r'%DVIPSSource: TeX output 1970.01.01:0000', d) - d = re.sub(r'/(BaseFont|FontName) /[A-Z]{6}', - r'/\1 /XXXXXX', d) + d = self.to_bytes_re_sub(r'%%CreationDate: [^\n]*\n', + r'%%CreationDate: 1970 Jan 01 00:00:00\n', d) + d = self.to_bytes_re_sub(r'%DVIPSSource: TeX output \d\d\d\d\.\d\d\.\d\d:\d\d\d\d', + r'%DVIPSSource: TeX output 1970.01.01:0000', d) + d = self.to_bytes_re_sub(r'/(BaseFont|FontName) /[A-Z]{6}', + r'/\1 /XXXXXX', d) r.append(d) x = e r.append(s[x:]) - s = ''.join(r) + s = to_bytes('').join(r) return s diff --git a/test/TEX/auxiliaries.py b/test/TEX/auxiliaries.py index 98cbf41..8d220c5 100644 --- a/test/TEX/auxiliaries.py +++ b/test/TEX/auxiliaries.py @@ -120,7 +120,7 @@ test.write(['docs', 'test.tex'], tex_input) test.run(stderr=None) pdf_output_1 = test.read(['build', 'docs', 'test.pdf']) -ps_output_1 = test.read(['build', 'docs', 'test.ps']) +ps_output_1 = test.read(['build', 'docs', 'test.ps'], mode='r') # Adding blank lines will cause SCons to re-run the builds, but the # actual contents of the output files should be the same modulo @@ -130,7 +130,7 @@ test.write(['docs', 'test.tex'], tex_input + "\n\n\n") test.run(stderr=None) pdf_output_2 = test.read(['build', 'docs', 'test.pdf']) -ps_output_2 = test.read(['build', 'docs', 'test.ps']) +ps_output_2 = test.read(['build', 'docs', 'test.ps'], mode='r') -- cgit v0.12 From f03149b32d1bb216bdfcc5352102982eed19f6e0 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Wed, 5 Apr 2017 20:12:54 -0700 Subject: py2/3 Remove pdf from list of files to scan. This was causing errors as the binary files can't be regexed with strings on py3. A more complete solution may be called for as it likely doesn't make sense to try to scan: '.png', '.jpg', '.gif', '.tif' files either. --- src/engine/SCons/Scanner/LaTeX.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/engine/SCons/Scanner/LaTeX.py b/src/engine/SCons/Scanner/LaTeX.py index 0c54bf3..e5abb0c 100644 --- a/src/engine/SCons/Scanner/LaTeX.py +++ b/src/engine/SCons/Scanner/LaTeX.py @@ -37,7 +37,9 @@ import SCons.Util # list of graphics file extensions for TeX and LaTeX TexGraphics = ['.eps', '.ps'] -LatexGraphics = ['.pdf', '.png', '.jpg', '.gif', '.tif'] +#LatexGraphics = ['.pdf', '.png', '.jpg', '.gif', '.tif'] +LatexGraphics = [ '.png', '.jpg', '.gif', '.tif'] + # Used as a return value of modify_env_var if the variable is not set. class _Null(object): @@ -397,6 +399,7 @@ class LaTeX(SCons.Scanner.Base): include = queue.pop() inc_type, inc_subdir, inc_filename = include + try: if seen[inc_filename] == 1: continue -- cgit v0.12 From 1ae09a28744a7e3059576ddc732cd81902d41594 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 6 Apr 2017 07:57:41 -0700 Subject: handle gettext.py rename to gettext_tool.py for bootstrap.py --- src/engine/MANIFEST.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/MANIFEST.in b/src/engine/MANIFEST.in index af91b7c..c70466d 100644 --- a/src/engine/MANIFEST.in +++ b/src/engine/MANIFEST.in @@ -170,7 +170,7 @@ SCons/Variables/PackageVariable.py SCons/Variables/PathVariable.py SCons/Warnings.py SCons/Tool/GettextCommon.py -SCons/Tool/gettext.py +SCons/Tool/gettext_tool.py SCons/Tool/msgfmt.py SCons/Tool/msginit.py SCons/Tool/msgmerge.py -- cgit v0.12 From a890bcba24887fa0519be96dfcab6476c1c3205d Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 6 Apr 2017 09:33:33 -0700 Subject: pep8 --- src/engine/SCons/Tool/GettextCommon.py | 650 ++++++++++++++++++--------------- 1 file changed, 353 insertions(+), 297 deletions(-) diff --git a/src/engine/SCons/Tool/GettextCommon.py b/src/engine/SCons/Tool/GettextCommon.py index e23a2d7..3b840a6 100644 --- a/src/engine/SCons/Tool/GettextCommon.py +++ b/src/engine/SCons/Tool/GettextCommon.py @@ -29,15 +29,32 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.Warnings import re + ############################################################################# class XgettextToolWarning(SCons.Warnings.Warning): pass + + class XgettextNotFound(XgettextToolWarning): pass + + class MsginitToolWarning(SCons.Warnings.Warning): pass + + class MsginitNotFound(MsginitToolWarning): pass + + class MsgmergeToolWarning(SCons.Warnings.Warning): pass + + class MsgmergeNotFound(MsgmergeToolWarning): pass + + class MsgfmtToolWarning(SCons.Warnings.Warning): pass + + class MsgfmtNotFound(MsgfmtToolWarning): pass + + ############################################################################# SCons.Warnings.enableWarningClass(XgettextToolWarning) SCons.Warnings.enableWarningClass(XgettextNotFound) @@ -47,367 +64,406 @@ SCons.Warnings.enableWarningClass(MsgmergeToolWarning) SCons.Warnings.enableWarningClass(MsgmergeNotFound) SCons.Warnings.enableWarningClass(MsgfmtToolWarning) SCons.Warnings.enableWarningClass(MsgfmtNotFound) + + ############################################################################# ############################################################################# class _POTargetFactory(object): - """ A factory of `PO` target files. - - Factory defaults differ from these of `SCons.Node.FS.FS`. We set `precious` - (this is required by builders and actions gettext) and `noclean` flags by - default for all produced nodes. - """ - def __init__( self, env, nodefault = True, alias = None, precious = True - , noclean = True ): - """ Object constructor. - - **Arguments** - - - *env* (`SCons.Environment.Environment`) - - *nodefault* (`boolean`) - if `True`, produced nodes will be ignored - from default target `'.'` - - *alias* (`string`) - if provided, produced nodes will be automatically - added to this alias, and alias will be set as `AlwaysBuild` - - *precious* (`boolean`) - if `True`, the produced nodes will be set as - `Precious`. - - *noclen* (`boolean`) - if `True`, the produced nodes will be excluded - from `Clean`. + """ A factory of `PO` target files. + + Factory defaults differ from these of `SCons.Node.FS.FS`. We set `precious` + (this is required by builders and actions gettext) and `noclean` flags by + default for all produced nodes. """ - self.env = env - self.alias = alias - self.precious = precious - self.noclean = noclean - self.nodefault = nodefault - - def _create_node(self, name, factory, directory = None, create = 1): - """ Create node, and set it up to factory settings. """ - import SCons.Util - node = factory(name, directory, create) - node.set_noclean(self.noclean) - node.set_precious(self.precious) - if self.nodefault: - self.env.Ignore('.', node) - if self.alias: - self.env.AlwaysBuild(self.env.Alias(self.alias, node)) - return node - - def Entry(self, name, directory = None, create = 1): - """ Create `SCons.Node.FS.Entry` """ - return self._create_node(name, self.env.fs.Entry, directory, create) - - def File(self, name, directory = None, create = 1): - """ Create `SCons.Node.FS.File` """ - return self._create_node(name, self.env.fs.File, directory, create) + + def __init__(self, env, nodefault=True, alias=None, precious=True + , noclean=True): + """ Object constructor. + + **Arguments** + + - *env* (`SCons.Environment.Environment`) + - *nodefault* (`boolean`) - if `True`, produced nodes will be ignored + from default target `'.'` + - *alias* (`string`) - if provided, produced nodes will be automatically + added to this alias, and alias will be set as `AlwaysBuild` + - *precious* (`boolean`) - if `True`, the produced nodes will be set as + `Precious`. + - *noclen* (`boolean`) - if `True`, the produced nodes will be excluded + from `Clean`. + """ + self.env = env + self.alias = alias + self.precious = precious + self.noclean = noclean + self.nodefault = nodefault + + def _create_node(self, name, factory, directory=None, create=1): + """ Create node, and set it up to factory settings. """ + import SCons.Util + node = factory(name, directory, create) + node.set_noclean(self.noclean) + node.set_precious(self.precious) + if self.nodefault: + self.env.Ignore('.', node) + if self.alias: + self.env.AlwaysBuild(self.env.Alias(self.alias, node)) + return node + + def Entry(self, name, directory=None, create=1): + """ Create `SCons.Node.FS.Entry` """ + return self._create_node(name, self.env.fs.Entry, directory, create) + + def File(self, name, directory=None, create=1): + """ Create `SCons.Node.FS.File` """ + return self._create_node(name, self.env.fs.File, directory, create) + + ############################################################################# ############################################################################# _re_comment = re.compile(r'(#[^\n\r]+)$', re.M) _re_lang = re.compile(r'([a-zA-Z0-9_]+)', re.M) + + ############################################################################# -def _read_linguas_from_files(env, linguas_files = None): - """ Parse `LINGUAS` file and return list of extracted languages """ - import SCons.Util - import SCons.Environment - global _re_comment - global _re_lang - if not SCons.Util.is_List(linguas_files) \ - and not SCons.Util.is_String(linguas_files) \ - and not isinstance(linguas_files, SCons.Node.FS.Base) \ - and linguas_files: - # If, linguas_files==True or such, then read 'LINGUAS' file. - linguas_files = [ 'LINGUAS' ] - if linguas_files is None: - return [] - fnodes = env.arg2nodes(linguas_files) - linguas = [] - for fnode in fnodes: - contents = _re_comment.sub("", fnode.get_text_contents()) - ls = [ l for l in _re_lang.findall(contents) if l ] - linguas.extend(ls) - return linguas +def _read_linguas_from_files(env, linguas_files=None): + """ Parse `LINGUAS` file and return list of extracted languages """ + import SCons.Util + import SCons.Environment + global _re_comment + global _re_lang + if not SCons.Util.is_List(linguas_files) \ + and not SCons.Util.is_String(linguas_files) \ + and not isinstance(linguas_files, SCons.Node.FS.Base) \ + and linguas_files: + # If, linguas_files==True or such, then read 'LINGUAS' file. + linguas_files = ['LINGUAS'] + if linguas_files is None: + return [] + fnodes = env.arg2nodes(linguas_files) + linguas = [] + for fnode in fnodes: + contents = _re_comment.sub("", fnode.get_text_contents()) + ls = [l for l in _re_lang.findall(contents) if l] + linguas.extend(ls) + return linguas + + ############################################################################# ############################################################################# from SCons.Builder import BuilderBase + + ############################################################################# class _POFileBuilder(BuilderBase): - """ `PO` file builder. - - This is multi-target single-source builder. In typical situation the source - is single `POT` file, e.g. `messages.pot`, and there are multiple `PO` - targets to be updated from this `POT`. We must run - `SCons.Builder.BuilderBase._execute()` separatelly for each target to track - dependencies separatelly for each target file. + """ `PO` file builder. - **NOTE**: if we call `SCons.Builder.BuilderBase._execute(.., target, ...)` - with target being list of all targets, all targets would be rebuilt each time - one of the targets from this list is missing. This would happen, for example, - when new language `ll` enters `LINGUAS_FILE` (at this moment there is no - `ll.po` file yet). To avoid this, we override - `SCons.Builder.BuilerBase._execute()` and call it separatelly for each - target. Here we also append to the target list the languages read from - `LINGUAS_FILE`. - """ - # - #* The argument for overriding _execute(): We must use environment with - # builder overrides applied (see BuilderBase.__init__(). Here it comes for - # free. - #* The argument against using 'emitter': The emitter is called too late - # by BuilderBase._execute(). If user calls, for example: - # - # env.POUpdate(LINGUAS_FILE = 'LINGUAS') - # - # the builder throws error, because it is called with target=None, - # source=None and is trying to "generate" sources or target list first. - # If user calls - # - # env.POUpdate(['foo', 'baz'], LINGUAS_FILE = 'LINGUAS') - # - # the env.BuilderWrapper() calls our builder with target=None, - # source=['foo', 'baz']. The BuilderBase._execute() then splits execution - # and execute iterativelly (recursion) self._execute(None, source[i]). - # After that it calls emitter (which is quite too late). The emitter is - # also called in each iteration, what makes things yet worse. - def __init__(self, env, **kw): - if not 'suffix' in kw: - kw['suffix'] = '$POSUFFIX' - if not 'src_suffix' in kw: - kw['src_suffix'] = '$POTSUFFIX' - if not 'src_builder' in kw: - kw['src_builder'] = '_POTUpdateBuilder' - if not 'single_source' in kw: - kw['single_source'] = True - alias = None - if 'target_alias' in kw: - alias = kw['target_alias'] - del kw['target_alias'] - if not 'target_factory' in kw: - kw['target_factory'] = _POTargetFactory(env, alias=alias).File - BuilderBase.__init__(self, **kw) - - def _execute(self, env, target, source, *args, **kw): - """ Execute builder's actions. + This is multi-target single-source builder. In typical situation the source + is single `POT` file, e.g. `messages.pot`, and there are multiple `PO` + targets to be updated from this `POT`. We must run + `SCons.Builder.BuilderBase._execute()` separatelly for each target to track + dependencies separatelly for each target file. - Here we append to `target` the languages read from `$LINGUAS_FILE` and - apply `SCons.Builder.BuilderBase._execute()` separatelly to each target. - The arguments and return value are same as for - `SCons.Builder.BuilderBase._execute()`. + **NOTE**: if we call `SCons.Builder.BuilderBase._execute(.., target, ...)` + with target being list of all targets, all targets would be rebuilt each time + one of the targets from this list is missing. This would happen, for example, + when new language `ll` enters `LINGUAS_FILE` (at this moment there is no + `ll.po` file yet). To avoid this, we override + `SCons.Builder.BuilerBase._execute()` and call it separatelly for each + target. Here we also append to the target list the languages read from + `LINGUAS_FILE`. """ - import SCons.Util - import SCons.Node - linguas_files = None - if 'LINGUAS_FILE' in env and env['LINGUAS_FILE']: - linguas_files = env['LINGUAS_FILE'] - # This prevents endless recursion loop (we'll be invoked once for - # each target appended here, we must not extend the list again). - env['LINGUAS_FILE'] = None - linguas = _read_linguas_from_files(env,linguas_files) - if SCons.Util.is_List(target): - target.extend(linguas) - elif target is not None: - target = [target] + linguas - else: - target = linguas - if not target: - # Let the SCons.BuilderBase to handle this patologic situation - return BuilderBase._execute( self, env, target, source, *args, **kw) - # The rest is ours - if not SCons.Util.is_List(target): - target = [ target ] - result = [] - for tgt in target: - r = BuilderBase._execute( self, env, [tgt], source, *args, **kw) - result.extend(r) - if linguas_files is not None: - env['LINGUAS_FILE'] = linguas_files - return SCons.Node.NodeList(result) + + # + # * The argument for overriding _execute(): We must use environment with + # builder overrides applied (see BuilderBase.__init__(). Here it comes for + # free. + # * The argument against using 'emitter': The emitter is called too late + # by BuilderBase._execute(). If user calls, for example: + # + # env.POUpdate(LINGUAS_FILE = 'LINGUAS') + # + # the builder throws error, because it is called with target=None, + # source=None and is trying to "generate" sources or target list first. + # If user calls + # + # env.POUpdate(['foo', 'baz'], LINGUAS_FILE = 'LINGUAS') + # + # the env.BuilderWrapper() calls our builder with target=None, + # source=['foo', 'baz']. The BuilderBase._execute() then splits execution + # and execute iterativelly (recursion) self._execute(None, source[i]). + # After that it calls emitter (which is quite too late). The emitter is + # also called in each iteration, what makes things yet worse. + def __init__(self, env, **kw): + if not 'suffix' in kw: + kw['suffix'] = '$POSUFFIX' + if not 'src_suffix' in kw: + kw['src_suffix'] = '$POTSUFFIX' + if not 'src_builder' in kw: + kw['src_builder'] = '_POTUpdateBuilder' + if not 'single_source' in kw: + kw['single_source'] = True + alias = None + if 'target_alias' in kw: + alias = kw['target_alias'] + del kw['target_alias'] + if not 'target_factory' in kw: + kw['target_factory'] = _POTargetFactory(env, alias=alias).File + BuilderBase.__init__(self, **kw) + + def _execute(self, env, target, source, *args, **kw): + """ Execute builder's actions. + + Here we append to `target` the languages read from `$LINGUAS_FILE` and + apply `SCons.Builder.BuilderBase._execute()` separatelly to each target. + The arguments and return value are same as for + `SCons.Builder.BuilderBase._execute()`. + """ + import SCons.Util + import SCons.Node + linguas_files = None + if 'LINGUAS_FILE' in env and env['LINGUAS_FILE']: + linguas_files = env['LINGUAS_FILE'] + # This prevents endless recursion loop (we'll be invoked once for + # each target appended here, we must not extend the list again). + env['LINGUAS_FILE'] = None + linguas = _read_linguas_from_files(env, linguas_files) + if SCons.Util.is_List(target): + target.extend(linguas) + elif target is not None: + target = [target] + linguas + else: + target = linguas + if not target: + # Let the SCons.BuilderBase to handle this patologic situation + return BuilderBase._execute(self, env, target, source, *args, **kw) + # The rest is ours + if not SCons.Util.is_List(target): + target = [target] + result = [] + for tgt in target: + r = BuilderBase._execute(self, env, [tgt], source, *args, **kw) + result.extend(r) + if linguas_files is not None: + env['LINGUAS_FILE'] = linguas_files + return SCons.Node.NodeList(result) + + ############################################################################# import SCons.Environment + + ############################################################################# def _translate(env, target=None, source=SCons.Environment._null, *args, **kw): - """ Function for `Translate()` pseudo-builder """ - if target is None: target = [] - pot = env.POTUpdate(None, source, *args, **kw) - po = env.POUpdate(target, pot, *args, **kw) - return po + """ Function for `Translate()` pseudo-builder """ + if target is None: target = [] + pot = env.POTUpdate(None, source, *args, **kw) + po = env.POUpdate(target, pot, *args, **kw) + return po + + ############################################################################# ############################################################################# class RPaths(object): - """ Callable object, which returns pathnames relative to SCons current - working directory. - - It seems like `SCons.Node.FS.Base.get_path()` returns absolute paths - for nodes that are outside of current working directory (`env.fs.getcwd()`). - Here, we often have `SConscript`, `POT` and `PO` files within `po/` - directory and source files (e.g. `*.c`) outside of it. When generating `POT` - template file, references to source files are written to `POT` template, so - a translator may later quickly jump to appropriate source file and line from - its `PO` editor (e.g. `poedit`). Relative paths in `PO` file are usually - interpreted by `PO` editor as paths relative to the place, where `PO` file - lives. The absolute paths would make resultant `POT` file nonportable, as - the references would be correct only on the machine, where `POT` file was - recently re-created. For such reason, we need a function, which always - returns relative paths. This is the purpose of `RPaths` callable object. - - The `__call__` method returns paths relative to current working directory, but - we assume, that *xgettext(1)* is run from the directory, where target file is - going to be created. - - Note, that this may not work for files distributed over several hosts or - across different drives on windows. We assume here, that single local - filesystem holds both source files and target `POT` templates. - - Intended use of `RPaths` - in `xgettext.py`:: - - def generate(env): - from GettextCommon import RPaths - ... - sources = '$( ${_concat( "", SOURCES, "", __env__, XgettextRPaths, TARGET, SOURCES)} $)' - env.Append( - ... - XGETTEXTCOM = 'XGETTEXT ... ' + sources, - ... - XgettextRPaths = RPaths(env) - ) - """ - # NOTE: This callable object returns pathnames of dirs/files relative to - # current working directory. The pathname remains relative also for entries - # that are outside of current working directory (node, that - # SCons.Node.FS.File and siblings return absolute path in such case). For - # simplicity we compute path relative to current working directory, this - # seems be enough for our purposes (don't need TARGET variable and - # SCons.Defaults.Variable_Caller stuff). + """ Callable object, which returns pathnames relative to SCons current + working directory. - def __init__(self, env): - """ Initialize `RPaths` callable object. - - **Arguments**: - - - *env* - a `SCons.Environment.Environment` object, defines *current - working dir*. + It seems like `SCons.Node.FS.Base.get_path()` returns absolute paths + for nodes that are outside of current working directory (`env.fs.getcwd()`). + Here, we often have `SConscript`, `POT` and `PO` files within `po/` + directory and source files (e.g. `*.c`) outside of it. When generating `POT` + template file, references to source files are written to `POT` template, so + a translator may later quickly jump to appropriate source file and line from + its `PO` editor (e.g. `poedit`). Relative paths in `PO` file are usually + interpreted by `PO` editor as paths relative to the place, where `PO` file + lives. The absolute paths would make resultant `POT` file nonportable, as + the references would be correct only on the machine, where `POT` file was + recently re-created. For such reason, we need a function, which always + returns relative paths. This is the purpose of `RPaths` callable object. + + The `__call__` method returns paths relative to current working directory, but + we assume, that *xgettext(1)* is run from the directory, where target file is + going to be created. + + Note, that this may not work for files distributed over several hosts or + across different drives on windows. We assume here, that single local + filesystem holds both source files and target `POT` templates. + + Intended use of `RPaths` - in `xgettext.py`:: + + def generate(env): + from GettextCommon import RPaths + ... + sources = '$( ${_concat( "", SOURCES, "", __env__, XgettextRPaths, TARGET, SOURCES)} $)' + env.Append( + ... + XGETTEXTCOM = 'XGETTEXT ... ' + sources, + ... + XgettextRPaths = RPaths(env) + ) """ - self.env = env - # FIXME: I'm not sure, how it should be implemented (what the *args are in - # general, what is **kw). - def __call__(self, nodes, *args, **kw): - """ Return nodes' paths (strings) relative to current working directory. - - **Arguments**: + # NOTE: This callable object returns pathnames of dirs/files relative to + # current working directory. The pathname remains relative also for entries + # that are outside of current working directory (node, that + # SCons.Node.FS.File and siblings return absolute path in such case). For + # simplicity we compute path relative to current working directory, this + # seems be enough for our purposes (don't need TARGET variable and + # SCons.Defaults.Variable_Caller stuff). - - *nodes* ([`SCons.Node.FS.Base`]) - list of nodes. - - *args* - currently unused. - - *kw* - currently unused. + def __init__(self, env): + """ Initialize `RPaths` callable object. + + **Arguments**: + + - *env* - a `SCons.Environment.Environment` object, defines *current + working dir*. + """ + self.env = env + + # FIXME: I'm not sure, how it should be implemented (what the *args are in + # general, what is **kw). + def __call__(self, nodes, *args, **kw): + """ Return nodes' paths (strings) relative to current working directory. + + **Arguments**: + + - *nodes* ([`SCons.Node.FS.Base`]) - list of nodes. + - *args* - currently unused. + - *kw* - currently unused. + + **Returns**: + + - Tuple of strings, which represent paths relative to current working + directory (for given environment). + """ + import os + import SCons.Node.FS + rpaths = () + cwd = self.env.fs.getcwd().get_abspath() + for node in nodes: + rpath = None + if isinstance(node, SCons.Node.FS.Base): + rpath = os.path.relpath(node.get_abspath(), cwd) + # FIXME: Other types possible here? + if rpath is not None: + rpaths += (rpath,) + return rpaths - **Returns**: - - Tuple of strings, which represent paths relative to current working - directory (for given environment). - """ - import os - import SCons.Node.FS - rpaths = () - cwd = self.env.fs.getcwd().get_abspath() - for node in nodes: - rpath = None - if isinstance(node, SCons.Node.FS.Base): - rpath = os.path.relpath(node.get_abspath(), cwd) - # FIXME: Other types possible here? - if rpath is not None: - rpaths += (rpath,) - return rpaths ############################################################################# - + ############################################################################# def _init_po_files(target, source, env): - """ Action function for `POInit` builder. """ - nop = lambda target, source, env : 0 - if 'POAUTOINIT' in env: - autoinit = env['POAUTOINIT'] - else: - autoinit = False - # Well, if everything outside works well, this loop should do single - # iteration. Otherwise we are rebuilding all the targets even, if just - # one has changed (but is this our fault?). - for tgt in target: - if not tgt.exists(): - if autoinit: - action = SCons.Action.Action('$MSGINITCOM', '$MSGINITCOMSTR') - else: - msg = 'File ' + repr(str(tgt)) + ' does not exist. ' \ - + 'If you are a translator, you can create it through: \n' \ - + '$MSGINITCOM' - action = SCons.Action.Action(nop, msg) - status = action([tgt], source, env) - if status: return status - return 0 + """ Action function for `POInit` builder. """ + nop = lambda target, source, env: 0 + if 'POAUTOINIT' in env: + autoinit = env['POAUTOINIT'] + else: + autoinit = False + # Well, if everything outside works well, this loop should do single + # iteration. Otherwise we are rebuilding all the targets even, if just + # one has changed (but is this our fault?). + for tgt in target: + if not tgt.exists(): + if autoinit: + action = SCons.Action.Action('$MSGINITCOM', '$MSGINITCOMSTR') + else: + msg = 'File ' + repr(str(tgt)) + ' does not exist. ' \ + + 'If you are a translator, you can create it through: \n' \ + + '$MSGINITCOM' + action = SCons.Action.Action(nop, msg) + status = action([tgt], source, env) + if status: return status + return 0 + + ############################################################################# ############################################################################# def _detect_xgettext(env): - """ Detects *xgettext(1)* binary """ - if 'XGETTEXT' in env: - return env['XGETTEXT'] - xgettext = env.Detect('xgettext'); - if xgettext: - return xgettext - raise SCons.Errors.StopError(XgettextNotFound,"Could not detect xgettext") - return None + """ Detects *xgettext(1)* binary """ + if 'XGETTEXT' in env: + return env['XGETTEXT'] + xgettext = env.Detect('xgettext'); + if xgettext: + return xgettext + raise SCons.Errors.StopError(XgettextNotFound, "Could not detect xgettext") + return None + + ############################################################################# def _xgettext_exists(env): - return _detect_xgettext(env) + return _detect_xgettext(env) + + ############################################################################# ############################################################################# def _detect_msginit(env): - """ Detects *msginit(1)* program. """ - if 'MSGINIT' in env: - return env['MSGINIT'] - msginit = env.Detect('msginit'); - if msginit: - return msginit - raise SCons.Errors.StopError(MsginitNotFound, "Could not detect msginit") - return None + """ Detects *msginit(1)* program. """ + if 'MSGINIT' in env: + return env['MSGINIT'] + msginit = env.Detect('msginit'); + if msginit: + return msginit + raise SCons.Errors.StopError(MsginitNotFound, "Could not detect msginit") + return None + + ############################################################################# def _msginit_exists(env): - return _detect_msginit(env) + return _detect_msginit(env) + + ############################################################################# ############################################################################# def _detect_msgmerge(env): - """ Detects *msgmerge(1)* program. """ - if 'MSGMERGE' in env: - return env['MSGMERGE'] - msgmerge = env.Detect('msgmerge'); - if msgmerge: - return msgmerge - raise SCons.Errors.StopError(MsgmergeNotFound, "Could not detect msgmerge") - return None + """ Detects *msgmerge(1)* program. """ + if 'MSGMERGE' in env: + return env['MSGMERGE'] + msgmerge = env.Detect('msgmerge'); + if msgmerge: + return msgmerge + raise SCons.Errors.StopError(MsgmergeNotFound, "Could not detect msgmerge") + return None + + ############################################################################# def _msgmerge_exists(env): - return _detect_msgmerge(env) + return _detect_msgmerge(env) + + ############################################################################# ############################################################################# def _detect_msgfmt(env): - """ Detects *msgmfmt(1)* program. """ - if 'MSGFMT' in env: - return env['MSGFMT'] - msgfmt = env.Detect('msgfmt'); - if msgfmt: - return msgfmt - raise SCons.Errors.StopError(MsgfmtNotFound, "Could not detect msgfmt") - return None + """ Detects *msgmfmt(1)* program. """ + if 'MSGFMT' in env: + return env['MSGFMT'] + msgfmt = env.Detect('msgfmt'); + if msgfmt: + return msgfmt + raise SCons.Errors.StopError(MsgfmtNotFound, "Could not detect msgfmt") + return None + + ############################################################################# def _msgfmt_exists(env): - return _detect_msgfmt(env) + return _detect_msgfmt(env) + + ############################################################################# ############################################################################# def tool_list(platform, env): - """ List tools that shall be generated by top-level `gettext` tool """ - return [ 'xgettext', 'msginit', 'msgmerge', 'msgfmt' ] -############################################################################# + """ List tools that shall be generated by top-level `gettext` tool """ + return ['xgettext', 'msginit', 'msgmerge', 'msgfmt'] +############################################################################# -- cgit v0.12 From ab8f8b9186dbc9dc14580b00789a7c2aea0f1df9 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 6 Apr 2017 09:33:54 -0700 Subject: pep8 --- src/engine/SCons/Tool/xgettext.py | 544 ++++++++++++++++++++------------------ 1 file changed, 283 insertions(+), 261 deletions(-) diff --git a/src/engine/SCons/Tool/xgettext.py b/src/engine/SCons/Tool/xgettext.py index e9b49b7..2c0ce40 100644 --- a/src/engine/SCons/Tool/xgettext.py +++ b/src/engine/SCons/Tool/xgettext.py @@ -26,311 +26,333 @@ Tool specific initialization of `xgettext` tool. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + ############################################################################# class _CmdRunner(object): - """ Callabe object, which runs shell command storing its stdout and stderr to - variables. It also provides `strfunction()` method, which shall be used by - scons Action objects to print command string. """ - - def __init__(self, command, commandstr = None): - self.out = None - self.err = None - self.status = None - self.command = command - self.commandstr = commandstr - - def __call__(self, target, source, env): - import SCons.Action - import subprocess - import os - import sys - kw = { - 'stdin' : 'devnull', - 'stdout' : subprocess.PIPE, - 'stderr' : subprocess.PIPE, - 'universal_newlines' : True, - 'shell' : True - } - command = env.subst(self.command, target = target, source = source) - proc = SCons.Action._subproc(env, command, **kw) - self.out, self.err = proc.communicate() - self.status = proc.wait() - if self.err: - sys.stderr.write(unicode(self.err)) - return self.status - - def strfunction(self, target, source, env): - import os - comstr = self.commandstr - if env.subst(comstr, target = target, source = source) == "": - comstr = self.command - s = env.subst(comstr, target = target, source = source) - return s + """ Callable object, which runs shell command storing its stdout and stderr to + variables. It also provides `strfunction()` method, which shall be used by + scons Action objects to print command string. """ + + def __init__(self, command, commandstr=None): + self.out = None + self.err = None + self.status = None + self.command = command + self.commandstr = commandstr + + def __call__(self, target, source, env): + import SCons.Action + import subprocess + import os + import sys + kw = { + 'stdin': 'devnull', + 'stdout': subprocess.PIPE, + 'stderr': subprocess.PIPE, + 'universal_newlines': True, + 'shell': True + } + command = env.subst(self.command, target=target, source=source) + proc = SCons.Action._subproc(env, command, **kw) + self.out, self.err = proc.communicate() + self.status = proc.wait() + if self.err: + sys.stderr.write(unicode(self.err)) + return self.status + + def strfunction(self, target, source, env): + import os + comstr = self.commandstr + if env.subst(comstr, target=target, source=source) == "": + comstr = self.command + s = env.subst(comstr, target=target, source=source) + return s + + ############################################################################# ############################################################################# def _update_pot_file(target, source, env): - """ Action function for `POTUpdate` builder """ - import re - import os - import SCons.Action - nop = lambda target, source, env : 0 - - # Save scons cwd and os cwd (NOTE: they may be different. After the job, we - # revert each one to its original state). - save_cwd = env.fs.getcwd() - save_os_cwd = os.getcwd() - chdir = target[0].dir - chdir_str = repr(chdir.get_abspath()) - # Print chdir message (employ SCons.Action.Action for that. It knows better - # than me how to to this correctly). - env.Execute(SCons.Action.Action(nop, "Entering " + chdir_str)) - # Go to target's directory and do our job - env.fs.chdir(chdir, 1) # Go into target's directory - try: - cmd = _CmdRunner('$XGETTEXTCOM', '$XGETTEXTCOMSTR') - action = SCons.Action.Action(cmd, strfunction=cmd.strfunction) - status = action([ target[0] ], source, env) - except: - # Something went wrong. + """ Action function for `POTUpdate` builder """ + import re + import os + import SCons.Action + nop = lambda target, source, env: 0 + + # Save scons cwd and os cwd (NOTE: they may be different. After the job, we + # revert each one to its original state). + save_cwd = env.fs.getcwd() + save_os_cwd = os.getcwd() + chdir = target[0].dir + chdir_str = repr(chdir.get_abspath()) + # Print chdir message (employ SCons.Action.Action for that. It knows better + # than me how to to this correctly). + env.Execute(SCons.Action.Action(nop, "Entering " + chdir_str)) + # Go to target's directory and do our job + env.fs.chdir(chdir, 1) # Go into target's directory + try: + cmd = _CmdRunner('$XGETTEXTCOM', '$XGETTEXTCOMSTR') + action = SCons.Action.Action(cmd, strfunction=cmd.strfunction) + status = action([target[0]], source, env) + except: + # Something went wrong. + env.Execute(SCons.Action.Action(nop, "Leaving " + chdir_str)) + # Revert working dirs to previous state and re-throw exception. + env.fs.chdir(save_cwd, 0) + os.chdir(save_os_cwd) + raise + # Print chdir message. env.Execute(SCons.Action.Action(nop, "Leaving " + chdir_str)) - # Revert working dirs to previous state and re-throw exception. + # Revert working dirs to previous state. env.fs.chdir(save_cwd, 0) os.chdir(save_os_cwd) - raise - # Print chdir message. - env.Execute(SCons.Action.Action(nop, "Leaving " + chdir_str)) - # Revert working dirs to previous state. - env.fs.chdir(save_cwd, 0) - os.chdir(save_os_cwd) - # If the command was not successfull, return error code. - if status: return status - - new_content = cmd.out - - if not new_content: - # When xgettext finds no internationalized messages, no *.pot is created - # (because we don't want to bother translators with empty POT files). - needs_update = False - explain = "no internationalized messages encountered" - else: - if target[0].exists(): - # If the file already exists, it's left unaltered unless its messages - # are outdated (w.r.t. to these recovered by xgettext from sources). - old_content = target[0].get_text_contents() - re_cdate = re.compile(r'^"POT-Creation-Date: .*"$[\r\n]?', re.M) - old_content_nocdate = re.sub(re_cdate,"",old_content) - new_content_nocdate = re.sub(re_cdate,"",new_content) - if(old_content_nocdate == new_content_nocdate): - # Messages are up-to-date + # If the command was not successfull, return error code. + if status: return status + + new_content = cmd.out + + if not new_content: + # When xgettext finds no internationalized messages, no *.pot is created + # (because we don't want to bother translators with empty POT files). needs_update = False - explain = "messages in file found to be up-to-date" - else: - # Messages are outdated - needs_update = True - explain = "messages in file were outdated" + explain = "no internationalized messages encountered" else: - # No POT file found, create new one - needs_update = True - explain = "new file" - if needs_update: - # Print message employing SCons.Action.Action for that. - msg = "Writing " + repr(str(target[0])) + " (" + explain + ")" - env.Execute(SCons.Action.Action(nop, msg)) - f = open(str(target[0]),"w") - f.write(new_content) - f.close() - return 0 - else: - # Print message employing SCons.Action.Action for that. - msg = "Not writing " + repr(str(target[0])) + " (" + explain + ")" - env.Execute(SCons.Action.Action(nop, msg)) - return 0 + if target[0].exists(): + # If the file already exists, it's left unaltered unless its messages + # are outdated (w.r.t. to these recovered by xgettext from sources). + old_content = target[0].get_text_contents() + re_cdate = re.compile(r'^"POT-Creation-Date: .*"$[\r\n]?', re.M) + old_content_nocdate = re.sub(re_cdate, "", old_content) + new_content_nocdate = re.sub(re_cdate, "", new_content) + if (old_content_nocdate == new_content_nocdate): + # Messages are up-to-date + needs_update = False + explain = "messages in file found to be up-to-date" + else: + # Messages are outdated + needs_update = True + explain = "messages in file were outdated" + else: + # No POT file found, create new one + needs_update = True + explain = "new file" + if needs_update: + # Print message employing SCons.Action.Action for that. + msg = "Writing " + repr(str(target[0])) + " (" + explain + ")" + env.Execute(SCons.Action.Action(nop, msg)) + f = open(str(target[0]), "w") + f.write(new_content) + f.close() + return 0 + else: + # Print message employing SCons.Action.Action for that. + msg = "Not writing " + repr(str(target[0])) + " (" + explain + ")" + env.Execute(SCons.Action.Action(nop, msg)) + return 0 + + ############################################################################# ############################################################################# from SCons.Builder import BuilderBase + + ############################################################################# class _POTBuilder(BuilderBase): - def _execute(self, env, target, source, *args): - if not target: - if 'POTDOMAIN' in env and env['POTDOMAIN']: - domain = env['POTDOMAIN'] - else: - domain = 'messages' - target = [ domain ] - return BuilderBase._execute(self, env, target, source, *args) + def _execute(self, env, target, source, *args): + if not target: + if 'POTDOMAIN' in env and env['POTDOMAIN']: + domain = env['POTDOMAIN'] + else: + domain = 'messages' + target = [domain] + return BuilderBase._execute(self, env, target, source, *args) + + ############################################################################# ############################################################################# -def _scan_xgettext_from_files(target, source, env, files = None, path = None): - """ Parses `POTFILES.in`-like file and returns list of extracted file names. - """ - import re - import SCons.Util - import SCons.Node.FS - - if files is None: +def _scan_xgettext_from_files(target, source, env, files=None, path=None): + """ Parses `POTFILES.in`-like file and returns list of extracted file names. + """ + import re + import SCons.Util + import SCons.Node.FS + + if files is None: + return 0 + if not SCons.Util.is_List(files): + files = [files] + + if path is None: + if 'XGETTEXTPATH' in env: + path = env['XGETTEXTPATH'] + else: + path = [] + if not SCons.Util.is_List(path): + path = [path] + + path = SCons.Util.flatten(path) + + dirs = () + for p in path: + if not isinstance(p, SCons.Node.FS.Base): + if SCons.Util.is_String(p): + p = env.subst(p, source=source, target=target) + p = env.arg2nodes(p, env.fs.Dir) + dirs += tuple(p) + # cwd is the default search path (when no path is defined by user) + if not dirs: + dirs = (env.fs.getcwd(),) + + # Parse 'POTFILE.in' files. + re_comment = re.compile(r'^#[^\n\r]*$\r?\n?', re.M) + re_emptyln = re.compile(r'^[ \t\r]*$\r?\n?', re.M) + re_trailws = re.compile(r'[ \t\r]+$') + for f in files: + # Find files in search path $XGETTEXTPATH + if isinstance(f, SCons.Node.FS.Base) and f.rexists(): + contents = f.get_text_contents() + contents = re_comment.sub("", contents) + contents = re_emptyln.sub("", contents) + contents = re_trailws.sub("", contents) + depnames = contents.splitlines() + for depname in depnames: + depfile = SCons.Node.FS.find_file(depname, dirs) + if not depfile: + depfile = env.arg2nodes(depname, dirs[0].File) + env.Depends(target, depfile) return 0 - if not SCons.Util.is_List(files): - files = [ files ] - if path is None: - if 'XGETTEXTPATH' in env: - path = env['XGETTEXTPATH'] - else: - path = [] - if not SCons.Util.is_List(path): - path = [ path ] - - path = SCons.Util.flatten(path) - - dirs = () - for p in path: - if not isinstance(p, SCons.Node.FS.Base): - if SCons.Util.is_String(p): - p = env.subst(p, source = source, target = target) - p = env.arg2nodes(p, env.fs.Dir) - dirs += tuple(p) - # cwd is the default search path (when no path is defined by user) - if not dirs: - dirs = (env.fs.getcwd(),) - - # Parse 'POTFILE.in' files. - re_comment = re.compile(r'^#[^\n\r]*$\r?\n?', re.M) - re_emptyln = re.compile(r'^[ \t\r]*$\r?\n?', re.M) - re_trailws = re.compile(r'[ \t\r]+$') - for f in files: - # Find files in search path $XGETTEXTPATH - if isinstance(f, SCons.Node.FS.Base) and f.rexists(): - contents = f.get_text_contents() - contents = re_comment.sub("", contents) - contents = re_emptyln.sub("", contents) - contents = re_trailws.sub("", contents) - depnames = contents.splitlines() - for depname in depnames: - depfile = SCons.Node.FS.find_file(depname, dirs) - if not depfile: - depfile = env.arg2nodes(depname, dirs[0].File) - env.Depends(target, depfile) - return 0 + ############################################################################# ############################################################################# def _pot_update_emitter(target, source, env): - """ Emitter function for `POTUpdate` builder """ - from SCons.Tool.GettextCommon import _POTargetFactory - import SCons.Util - import SCons.Node.FS - - if 'XGETTEXTFROM' in env: - xfrom = env['XGETTEXTFROM'] - else: + """ Emitter function for `POTUpdate` builder """ + from SCons.Tool.GettextCommon import _POTargetFactory + import SCons.Util + import SCons.Node.FS + + if 'XGETTEXTFROM' in env: + xfrom = env['XGETTEXTFROM'] + else: + return target, source + if not SCons.Util.is_List(xfrom): + xfrom = [xfrom] + + xfrom = SCons.Util.flatten(xfrom) + + # Prepare list of 'POTFILE.in' files. + files = [] + for xf in xfrom: + if not isinstance(xf, SCons.Node.FS.Base): + if SCons.Util.is_String(xf): + # Interpolate variables in strings + xf = env.subst(xf, source=source, target=target) + xf = env.arg2nodes(xf) + files.extend(xf) + if files: + env.Depends(target, files) + _scan_xgettext_from_files(target, source, env, files) return target, source - if not SCons.Util.is_List(xfrom): - xfrom = [ xfrom ] - - xfrom = SCons.Util.flatten(xfrom) - - # Prepare list of 'POTFILE.in' files. - files = [] - for xf in xfrom: - if not isinstance(xf, SCons.Node.FS.Base): - if SCons.Util.is_String(xf): - # Interpolate variables in strings - xf = env.subst(xf, source = source, target = target) - xf = env.arg2nodes(xf) - files.extend(xf) - if files: - env.Depends(target, files) - _scan_xgettext_from_files(target, source, env, files) - return target, source + + ############################################################################# ############################################################################# from SCons.Environment import _null + + ############################################################################# def _POTUpdateBuilderWrapper(env, target=None, source=_null, **kw): - return env._POTUpdateBuilder(target, source, **kw) + return env._POTUpdateBuilder(target, source, **kw) + + ############################################################################# ############################################################################# def _POTUpdateBuilder(env, **kw): - """ Creates `POTUpdate` builder object """ - import SCons.Action - from SCons.Tool.GettextCommon import _POTargetFactory - kw['action'] = SCons.Action.Action(_update_pot_file, None) - kw['suffix'] = '$POTSUFFIX' - kw['target_factory'] = _POTargetFactory(env, alias='$POTUPDATE_ALIAS').File - kw['emitter'] = _pot_update_emitter - return _POTBuilder(**kw) + """ Creates `POTUpdate` builder object """ + import SCons.Action + from SCons.Tool.GettextCommon import _POTargetFactory + kw['action'] = SCons.Action.Action(_update_pot_file, None) + kw['suffix'] = '$POTSUFFIX' + kw['target_factory'] = _POTargetFactory(env, alias='$POTUPDATE_ALIAS').File + kw['emitter'] = _pot_update_emitter + return _POTBuilder(**kw) + + ############################################################################# ############################################################################# -def generate(env,**kw): - """ Generate `xgettext` tool """ - import SCons.Util - from SCons.Tool.GettextCommon import RPaths, _detect_xgettext - - try: - env['XGETTEXT'] = _detect_xgettext(env) - except: - env['XGETTEXT'] = 'xgettext' - # NOTE: sources="$SOURCES" would work as well. However, we use following - # construction to convert absolute paths provided by scons onto paths - # relative to current working dir. Note, that scons expands $SOURCE(S) to - # absolute paths for sources $SOURCE(s) outside of current subtree (e.g. in - # "../"). With source=$SOURCE these absolute paths would be written to the - # resultant *.pot file (and its derived *.po files) as references to lines in - # source code (e.g. referring lines in *.c files). Such references would be - # correct (e.g. in poedit) only on machine on which *.pot was generated and - # would be of no use on other hosts (having a copy of source code located - # in different place in filesystem). - sources = '$( ${_concat( "", SOURCES, "", __env__, XgettextRPaths, TARGET' \ - + ', SOURCES)} $)' - - # NOTE: the output from $XGETTEXTCOM command must go to stdout, not to a file. - # This is required by the POTUpdate builder's action. - xgettextcom = '$XGETTEXT $XGETTEXTFLAGS $_XGETTEXTPATHFLAGS' \ - + ' $_XGETTEXTFROMFLAGS -o - ' + sources - - xgettextpathflags = '$( ${_concat( XGETTEXTPATHPREFIX, XGETTEXTPATH' \ - + ', XGETTEXTPATHSUFFIX, __env__, RDirs, TARGET, SOURCES)} $)' - xgettextfromflags = '$( ${_concat( XGETTEXTFROMPREFIX, XGETTEXTFROM' \ - + ', XGETTEXTFROMSUFFIX, __env__, target=TARGET, source=SOURCES)} $)' - - env.SetDefault( - _XGETTEXTDOMAIN = '${TARGET.filebase}', - XGETTEXTFLAGS = [ ], - XGETTEXTCOM = xgettextcom, - XGETTEXTCOMSTR = '', - XGETTEXTPATH = [ ], - XGETTEXTPATHPREFIX = '-D', - XGETTEXTPATHSUFFIX = '', - XGETTEXTFROM = None, - XGETTEXTFROMPREFIX = '-f', - XGETTEXTFROMSUFFIX = '', - _XGETTEXTPATHFLAGS = xgettextpathflags, - _XGETTEXTFROMFLAGS = xgettextfromflags, - POTSUFFIX = ['.pot'], - POTUPDATE_ALIAS = 'pot-update', - XgettextRPaths = RPaths(env) - ) - env.Append( BUILDERS = { - '_POTUpdateBuilder' : _POTUpdateBuilder(env) - } ) - env.AddMethod(_POTUpdateBuilderWrapper, 'POTUpdate') - env.AlwaysBuild(env.Alias('$POTUPDATE_ALIAS')) +def generate(env, **kw): + """ Generate `xgettext` tool """ + import SCons.Util + from SCons.Tool.GettextCommon import RPaths, _detect_xgettext + + try: + env['XGETTEXT'] = _detect_xgettext(env) + except: + env['XGETTEXT'] = 'xgettext' + # NOTE: sources="$SOURCES" would work as well. However, we use following + # construction to convert absolute paths provided by scons onto paths + # relative to current working dir. Note, that scons expands $SOURCE(S) to + # absolute paths for sources $SOURCE(s) outside of current subtree (e.g. in + # "../"). With source=$SOURCE these absolute paths would be written to the + # resultant *.pot file (and its derived *.po files) as references to lines in + # source code (e.g. referring lines in *.c files). Such references would be + # correct (e.g. in poedit) only on machine on which *.pot was generated and + # would be of no use on other hosts (having a copy of source code located + # in different place in filesystem). + sources = '$( ${_concat( "", SOURCES, "", __env__, XgettextRPaths, TARGET' \ + + ', SOURCES)} $)' + + # NOTE: the output from $XGETTEXTCOM command must go to stdout, not to a file. + # This is required by the POTUpdate builder's action. + xgettextcom = '$XGETTEXT $XGETTEXTFLAGS $_XGETTEXTPATHFLAGS' \ + + ' $_XGETTEXTFROMFLAGS -o - ' + sources + + xgettextpathflags = '$( ${_concat( XGETTEXTPATHPREFIX, XGETTEXTPATH' \ + + ', XGETTEXTPATHSUFFIX, __env__, RDirs, TARGET, SOURCES)} $)' + xgettextfromflags = '$( ${_concat( XGETTEXTFROMPREFIX, XGETTEXTFROM' \ + + ', XGETTEXTFROMSUFFIX, __env__, target=TARGET, source=SOURCES)} $)' + + env.SetDefault( + _XGETTEXTDOMAIN='${TARGET.filebase}', + XGETTEXTFLAGS=[], + XGETTEXTCOM=xgettextcom, + XGETTEXTCOMSTR='', + XGETTEXTPATH=[], + XGETTEXTPATHPREFIX='-D', + XGETTEXTPATHSUFFIX='', + XGETTEXTFROM=None, + XGETTEXTFROMPREFIX='-f', + XGETTEXTFROMSUFFIX='', + _XGETTEXTPATHFLAGS=xgettextpathflags, + _XGETTEXTFROMFLAGS=xgettextfromflags, + POTSUFFIX=['.pot'], + POTUPDATE_ALIAS='pot-update', + XgettextRPaths=RPaths(env) + ) + env.Append(BUILDERS={ + '_POTUpdateBuilder': _POTUpdateBuilder(env) + }) + env.AddMethod(_POTUpdateBuilderWrapper, 'POTUpdate') + env.AlwaysBuild(env.Alias('$POTUPDATE_ALIAS')) + + ############################################################################# ############################################################################# def exists(env): - """ Check, whether the tool exists """ - from SCons.Tool.GettextCommon import _xgettext_exists - try: - return _xgettext_exists(env) - except: - return False + """ Check, whether the tool exists """ + from SCons.Tool.GettextCommon import _xgettext_exists + try: + return _xgettext_exists(env) + except: + return False + ############################################################################# # Local Variables: -- cgit v0.12 From 12826a83362d0da1abd16cb29edb38be48e8f172 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 6 Apr 2017 09:34:44 -0700 Subject: py2/3 Need to add __hash__ function to EntryProxy as with py3 __hash__ function is removed when a class provides __eq__ --- src/engine/SCons/Node/FS.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 33e4a2d..8f26777 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -477,6 +477,11 @@ class EntryProxy(SCons.Util.Proxy): __str__ = SCons.Util.Delegate('__str__') + # In PY3 if a class defines __eq__, then it must explicitly provide + # __hash__. Since SCons.Util.Proxy provides __eq__ we need the following + # see: https://docs.python.org/3.1/reference/datamodel.html#object.__hash__ + __hash__ = SCons.Util.Delegate('__hash__') + def __get_abspath(self): entry = self.get() return SCons.Subst.SpecialAttrWrapper(entry.get_abspath(), @@ -574,6 +579,7 @@ class EntryProxy(SCons.Util.Proxy): else: return attr_function(self) + class Base(SCons.Node.Node): """A generic class for file system entries. This class is for when we don't know yet whether the entry being looked up is a file -- cgit v0.12 From e25264ce5094f6d288cdf780bb99e4bdb605c706 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 6 Apr 2017 09:35:05 -0700 Subject: py2/3 fix mode='r' --- test/gettext/POTUpdate/UserExamples.py | 40 +++++++++++++++++----------------- test/gettext/POUpdate/UserExamples.py | 36 +++++++++++++++--------------- test/gettext/Translate/UserExamples.py | 28 ++++++++++++------------ 3 files changed, 52 insertions(+), 52 deletions(-) diff --git a/test/gettext/POTUpdate/UserExamples.py b/test/gettext/POTUpdate/UserExamples.py index 6269081..06203fa 100644 --- a/test/gettext/POTUpdate/UserExamples.py +++ b/test/gettext/POTUpdate/UserExamples.py @@ -62,19 +62,19 @@ test.must_not_exist( ['ex1', 'po', 'bar.pot'] ) test.run(arguments = 'foo.pot', chdir = path.join('ex1', 'po')) test.must_exist( ['ex1', 'po', 'foo.pot'] ) test.must_not_exist( ['ex1', 'po', 'bar.pot'] ) -test.must_contain( ['ex1', 'po', 'foo.pot'], "Hello from a.cpp" ) -test.must_contain( ['ex1', 'po', 'foo.pot'], "Hello from b.cpp" ) -test.must_not_contain( ['ex1', 'po', 'foo.pot'], "Hello from c.cpp" ) -test.must_not_contain( ['ex1', 'po', 'foo.pot'], "Hello from d.cpp" ) +test.must_contain( ['ex1', 'po', 'foo.pot'], "Hello from a.cpp", mode='r') +test.must_contain( ['ex1', 'po', 'foo.pot'], "Hello from b.cpp", mode='r') +test.must_not_contain( ['ex1', 'po', 'foo.pot'], "Hello from c.cpp", mode='r') +test.must_not_contain( ['ex1', 'po', 'foo.pot'], "Hello from d.cpp", mode='r') # scons 'pot-update' creates foo.pot and bar.pot test.run(arguments = 'pot-update', chdir = path.join('ex1', 'po')) test.must_exist( ['ex1', 'po', 'foo.pot'] ) test.must_exist( ['ex1', 'po', 'bar.pot'] ) -test.must_not_contain( ['ex1', 'po', 'bar.pot'], "Hello from a.cpp" ) -test.must_not_contain( ['ex1', 'po', 'bar.pot'], "Hello from b.cpp" ) -test.must_contain( ['ex1', 'po', 'bar.pot'], "Hello from c.cpp" ) -test.must_contain( ['ex1', 'po', 'bar.pot'], "Hello from d.cpp" ) +test.must_not_contain( ['ex1', 'po', 'bar.pot'], "Hello from a.cpp", mode='r') +test.must_not_contain( ['ex1', 'po', 'bar.pot'], "Hello from b.cpp", mode='r') +test.must_contain( ['ex1', 'po', 'bar.pot'], "Hello from c.cpp", mode='r') +test.must_contain( ['ex1', 'po', 'bar.pot'], "Hello from d.cpp", mode='r') # scons -c does not clean anything test.run(arguments = '-c', chdir = path.join('ex1', 'po')) @@ -101,16 +101,16 @@ test.write(['ex2', 'd.cpp'], """ gettext("Hello from d.cpp") """) test.run(arguments = 'pot-update', chdir = path.join('ex2')) test.must_exist( ['ex2', 'foo.pot']) -test.must_contain( ['ex2', 'foo.pot'], "Hello from a.cpp" ) -test.must_contain( ['ex2', 'foo.pot'], "Hello from b.cpp" ) -test.must_not_contain( ['ex2', 'foo.pot'], "Hello from c.cpp" ) -test.must_not_contain( ['ex2', 'foo.pot'], "Hello from d.cpp" ) +test.must_contain( ['ex2', 'foo.pot'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex2', 'foo.pot'], "Hello from b.cpp", mode='r' ) +test.must_not_contain( ['ex2', 'foo.pot'], "Hello from c.cpp", mode='r' ) +test.must_not_contain( ['ex2', 'foo.pot'], "Hello from d.cpp", mode='r' ) test.must_exist( ['ex2', 'bar.pot']) -test.must_not_contain( ['ex2', 'bar.pot'], "Hello from a.cpp" ) -test.must_not_contain( ['ex2', 'bar.pot'], "Hello from b.cpp" ) -test.must_contain( ['ex2', 'bar.pot'], "Hello from c.cpp" ) -test.must_contain( ['ex2', 'bar.pot'], "Hello from d.cpp" ) +test.must_not_contain( ['ex2', 'bar.pot'], "Hello from a.cpp", mode='r' ) +test.must_not_contain( ['ex2', 'bar.pot'], "Hello from b.cpp", mode='r' ) +test.must_contain( ['ex2', 'bar.pot'], "Hello from c.cpp", mode='r' ) +test.must_contain( ['ex2', 'bar.pot'], "Hello from d.cpp", mode='r' ) ############################################################################# @@ -192,9 +192,9 @@ test.write(['ex5', '0', '1', 'a.cpp'], """ gettext("Hello from ../a.cpp") """) test.run(arguments = 'pot-update', chdir = path.join('ex5', '0', '1', 'po')) test.must_exist( ['ex5', '0', '1', 'po', 'messages.pot']) test.must_contain( ['ex5', '0', '1', 'po', 'messages.pot'], - 'Hello from ../a.cpp' ) + 'Hello from ../a.cpp', mode='r' ) test.must_not_contain( ['ex5', '0', '1', 'po', 'messages.pot'], - 'Hello from ../../a.cpp' ) + 'Hello from ../../a.cpp', mode='r' ) test.write(['ex5', '0', '1', 'po', 'SConstruct'], """ @@ -204,9 +204,9 @@ env.POTUpdate(XGETTEXTFROM = 'POTFILES.in', XGETTEXTPATH=['../../', '../']) """) test.run(arguments = 'pot-update', chdir = path.join('ex5', '0', '1', 'po')) test.must_contain( ['ex5', '0', '1', 'po', 'messages.pot'], - 'Hello from ../../a.cpp' ) + 'Hello from ../../a.cpp', mode='r' ) test.must_not_contain( ['ex5', '0', '1', 'po', 'messages.pot'], - 'Hello from ../a.cpp') + 'Hello from ../a.cpp', mode='r') test.pass_test() diff --git a/test/gettext/POUpdate/UserExamples.py b/test/gettext/POUpdate/UserExamples.py index 01d3706..5f3e6c7 100644 --- a/test/gettext/POUpdate/UserExamples.py +++ b/test/gettext/POUpdate/UserExamples.py @@ -182,8 +182,8 @@ test.write(['ex1', 'pl.po'], pl_po_contents) test.run(arguments = 'po-update', chdir = 'ex1', stderr = None) test.must_exist( ['ex1', 'en.po'] ) test.must_exist( ['ex1', 'pl.po'] ) -test.must_contain( ['ex1', 'en.po'], "Hello from a.cpp" ) -test.must_contain( ['ex1', 'pl.po'], "Hello from a.cpp" ) +test.must_contain( ['ex1', 'en.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex1', 'pl.po'], "Hello from a.cpp", mode='r' ) ############################################################################# # POUpdate: Example 2 @@ -205,8 +205,8 @@ test.write(['ex2', 'pl.po'], pl_po_contents) test.run(arguments = 'po-update', chdir = 'ex2', stderr = None) test.must_exist( ['ex2', 'en.po'] ) test.must_exist( ['ex2', 'pl.po'] ) -test.must_contain( ['ex2', 'en.po'], "Hello from a.cpp" ) -test.must_contain( ['ex2', 'pl.po'], "Hello from a.cpp" ) +test.must_contain( ['ex2', 'en.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex2', 'pl.po'], "Hello from a.cpp", mode='r' ) ############################################################################# # POUpdate: Example 3 @@ -228,8 +228,8 @@ test.write(['ex3', 'pl.po'], pl_po_contents) test.run(arguments = 'po-update', chdir = 'ex3', stderr = None) test.must_exist( ['ex3', 'en.po'] ) test.must_exist( ['ex3', 'pl.po'] ) -test.must_contain( ['ex3', 'en.po'], "Hello from a.cpp" ) -test.must_contain( ['ex3', 'pl.po'], "Hello from a.cpp" ) +test.must_contain( ['ex3', 'en.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex3', 'pl.po'], "Hello from a.cpp", mode='r' ) ############################################################################# # POUpdate: Example 4 @@ -258,8 +258,8 @@ test.run(arguments = 'po-update', chdir = 'ex4', stderr = None) test.must_exist( ['ex4', 'messages.pot'] ) test.must_exist( ['ex4', 'en.po'] ) test.must_exist( ['ex4', 'pl.po'] ) -test.must_contain( ['ex4', 'en.po'], "Hello from a.cpp" ) -test.must_contain( ['ex4', 'pl.po'], "Hello from a.cpp" ) +test.must_contain( ['ex4', 'en.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex4', 'pl.po'], "Hello from a.cpp", mode='r' ) ############################################################################# # POUpdate: Example 5 @@ -286,8 +286,8 @@ test.write(['ex5', 'pl.po'], pl_po_contents) test.run(arguments = 'po-update', chdir= 'ex5', stderr = None) test.must_exist( ['ex5', 'en.po'] ) test.must_exist( ['ex5', 'pl.po'] ) -test.must_contain( ['ex5', 'en.po'], "Hello from a.cpp" ) -test.must_contain( ['ex5', 'pl.po'], "Hello from a.cpp" ) +test.must_contain( ['ex5', 'en.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex5', 'pl.po'], "Hello from a.cpp", mode='r' ) ############################################################################# # POUpdate: Example 6 @@ -317,10 +317,10 @@ test.must_exist( ['ex6', 'en.po'] ) test.must_exist( ['ex6', 'pl.po'] ) test.must_exist( ['ex6', 'de.po'] ) test.must_exist( ['ex6', 'fr.po'] ) -test.must_contain( ['ex6', 'en.po'], "Hello from a.cpp" ) -test.must_contain( ['ex6', 'pl.po'], "Hello from a.cpp" ) -test.must_contain( ['ex6', 'de.po'], "Hello from a.cpp" ) -test.must_contain( ['ex6', 'fr.po'], "Hello from a.cpp" ) +test.must_contain( ['ex6', 'en.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex6', 'pl.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex6', 'de.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex6', 'fr.po'], "Hello from a.cpp", mode='r' ) ############################################################################# # POUpdate: Example 7 @@ -351,8 +351,8 @@ test.write(['ex7', 'messages.pot'], pot_contents) test.run(arguments = 'po-update', chdir= 'ex7', stderr = None) test.must_exist( ['ex7', 'en.po'] ) test.must_exist( ['ex7', 'pl.po'] ) -test.must_contain( ['ex7', 'en.po'], "Hello from a.cpp" ) -test.must_contain( ['ex7', 'pl.po'], "Hello from a.cpp" ) +test.must_contain( ['ex7', 'en.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex7', 'pl.po'], "Hello from a.cpp", mode='r' ) ############################################################################# # POUpdate: Example 8 @@ -389,8 +389,8 @@ test.run(arguments = 'po-update', chdir = 'ex8', stderr = None) test.must_exist( ['ex8', 'foo.pot'] ) test.must_exist( ['ex8', 'en.po'] ) test.must_exist( ['ex8', 'pl.po'] ) -test.must_contain( ['ex8', 'en.po'], "Hello from a.cpp" ) -test.must_contain( ['ex8', 'pl.po'], "Hello from a.cpp" ) +test.must_contain( ['ex8', 'en.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex8', 'pl.po'], "Hello from a.cpp", mode='r' ) test.pass_test() diff --git a/test/gettext/Translate/UserExamples.py b/test/gettext/Translate/UserExamples.py index 384b96d..d7220a3 100644 --- a/test/gettext/Translate/UserExamples.py +++ b/test/gettext/Translate/UserExamples.py @@ -65,10 +65,10 @@ test.write(['ex1', 'b.cpp'], """ gettext("Hello from b.cpp") """) test.run(arguments = 'po-update', chdir = path.join('ex1','po'), stderr = None) test.must_exist( ['ex1', 'po', 'en.po'] ) test.must_exist( ['ex1', 'po', 'pl.po'] ) -test.must_contain( ['ex1', 'po', 'en.po'], "Hello from a.cpp" ) -test.must_contain( ['ex1', 'po', 'en.po'], "Hello from b.cpp" ) -test.must_contain( ['ex1', 'po', 'pl.po'], "Hello from a.cpp" ) -test.must_contain( ['ex1', 'po', 'pl.po'], "Hello from b.cpp" ) +test.must_contain( ['ex1', 'po', 'en.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex1', 'po', 'en.po'], "Hello from b.cpp", mode='r' ) +test.must_contain( ['ex1', 'po', 'pl.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex1', 'po', 'pl.po'], "Hello from b.cpp", mode='r' ) ############################################################################# # Translate: Example 2 @@ -100,10 +100,10 @@ test.write(['ex2', 'b.cpp'], """ gettext("Hello from b.cpp") """) test.run(arguments = 'po-update', chdir = path.join('ex2','po'), stderr = None) test.must_exist( ['ex2', 'po', 'en.po'] ) test.must_exist( ['ex2', 'po', 'pl.po'] ) -test.must_contain( ['ex2', 'po', 'en.po'], "Hello from a.cpp" ) -test.must_contain( ['ex2', 'po', 'en.po'], "Hello from b.cpp" ) -test.must_contain( ['ex2', 'po', 'pl.po'], "Hello from a.cpp" ) -test.must_contain( ['ex2', 'po', 'pl.po'], "Hello from b.cpp" ) +test.must_contain( ['ex2', 'po', 'en.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex2', 'po', 'en.po'], "Hello from b.cpp", mode='r' ) +test.must_contain( ['ex2', 'po', 'pl.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex2', 'po', 'pl.po'], "Hello from b.cpp", mode='r' ) ############################################################################# # Translate: Example 3 @@ -157,12 +157,12 @@ test.must_not_exist( ['ex3', 'build', 'po', 'messages.pot'] ) test.must_not_exist( ['ex3', 'build', 'po', 'en.po'] ) test.must_not_exist( ['ex3', 'build', 'po', 'pl.po'] ) # -test.must_contain( ['ex3', 'src', 'po', 'messages.pot'], "Hello from a.cpp" ) -test.must_contain( ['ex3', 'src', 'po', 'messages.pot'], "Hello from b.cpp" ) -test.must_contain( ['ex3', 'src', 'po', 'en.po'], "Hello from a.cpp" ) -test.must_contain( ['ex3', 'src', 'po', 'en.po'], "Hello from b.cpp" ) -test.must_contain( ['ex3', 'src', 'po', 'pl.po'], "Hello from a.cpp" ) -test.must_contain( ['ex3', 'src', 'po', 'pl.po'], "Hello from b.cpp" ) +test.must_contain( ['ex3', 'src', 'po', 'messages.pot'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex3', 'src', 'po', 'messages.pot'], "Hello from b.cpp", mode='r' ) +test.must_contain( ['ex3', 'src', 'po', 'en.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex3', 'src', 'po', 'en.po'], "Hello from b.cpp", mode='r' ) +test.must_contain( ['ex3', 'src', 'po', 'pl.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex3', 'src', 'po', 'pl.po'], "Hello from b.cpp", mode='r' ) test.run(arguments = '.', chdir = 'ex3', stderr = None) test.must_exist( ['ex3', 'build', 'po', 'en.mo'] ) -- cgit v0.12 From 8b4b7860340e1348ec00587a0c79007531e361d5 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 6 Apr 2017 15:36:31 -0700 Subject: py2/3 don't try to force import threading failure on py3. threading is imported too many places and this form of checking for python being built with thread is no the best way. Use sysconfig.get_config_var('WITH_THREAD') instead --- test/option-j.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/option-j.py b/test/option-j.py index 3dbedc0..278fd30 100644 --- a/test/option-j.py +++ b/test/option-j.py @@ -122,7 +122,7 @@ test.fail_test(start2 < finish1) # succeeds. test.run(arguments='-j 2 out') -if sys.platform != 'win32': +if sys.platform != 'win32' and sys.version_info[0] == 2: # Test breaks on win32 when using real subprocess is not the only # package to import threading # -- cgit v0.12 From 9b49fabea61340c856b18151224603e3162c84d3 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 6 Apr 2017 16:13:36 -0700 Subject: py2/3 fix test logic to handle bytes vs strings when matching --- QMTest/TestCmd.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index 07a3905..3b745f8 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -453,13 +453,17 @@ def pass_test(self = None, condition = 1, function = None): sys.exit(0) -def match_exact(lines = None, matches = None): +def match_exact(lines = None, matches = None, newline = '\n'): """ """ + + if isinstance(lines, bytes) or bytes is str: + newline = to_bytes('\n') + if not is_List(lines): - lines = lines.split("\n") + lines = lines.split(newline) if not is_List(matches): - matches = matches.split("\n") + matches = matches.split(newline) if len(lines) != len(matches): return for i in range(len(lines)): -- cgit v0.12 From 2361be4acf8e9d2ac91a63ea3ba36a03527a726e Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 6 Apr 2017 16:15:21 -0700 Subject: py2/3 swap to bytes for comparison --- test/Progress/spinner.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/Progress/spinner.py b/test/Progress/spinner.py index 85ca32f..59c0a89 100644 --- a/test/Progress/spinner.py +++ b/test/Progress/spinner.py @@ -33,6 +33,7 @@ import os import TestSCons + test = TestSCons.TestSCons(universal_newlines=None) test.write('SConstruct', r""" @@ -50,12 +51,12 @@ test.write('S2.in', "S2.in\n") test.write('S3.in', "S3.in\n") test.write('S4.in', "S4.in\n") -expect = """\ +expect = bytearray("""\ \\\r|\rCopy("S1.out", "S1.in") /\r-\rCopy("S2.out", "S2.in") \\\r|\rCopy("S3.out", "S3.in") /\r-\rCopy("S4.out", "S4.in") -\\\r|\r""" +\\\r|\r""",'utf-8') if os.linesep != '\n': expect = expect.replace('\n', os.linesep) -- cgit v0.12 From 072369e0cf1c10f5b88ebd21487f169eb189cf25 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 6 Apr 2017 16:15:36 -0700 Subject: py2/3 swap to bytes for comparison --- test/Progress/TARGET.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Progress/TARGET.py b/test/Progress/TARGET.py index d7ff3c9..9af5565 100644 --- a/test/Progress/TARGET.py +++ b/test/Progress/TARGET.py @@ -50,12 +50,12 @@ test.write('S2.in', "S2.in\n") test.write('S3.in', "S3.in\n") test.write('S4.in', "S4.in\n") -expect = """\ +expect = bytearray("""\ S1.in\r \rS1.out\rCopy("S1.out", "S1.in") \rS2.in\r \rS2.out\rCopy("S2.out", "S2.in") \rS3.in\r \rS3.out\rCopy("S3.out", "S3.in") \rS4.in\r \rS4.out\rCopy("S4.out", "S4.in") - \rSConstruct\r \r.\r""" + \rSConstruct\r \r.\r""",'utf-8') if os.linesep != '\n': expect = expect.replace('\n', os.linesep) -- cgit v0.12 From cce4024322a5433d441a0d9058c9a1950590ae0c Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 6 Apr 2017 16:16:05 -0700 Subject: py2/3 use sysconfig.get_config_var('WITH_THREAD') to determine if python has threads --- src/engine/SCons/Script/Main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py index f9df813..b7ce466 100644 --- a/src/engine/SCons/Script/Main.py +++ b/src/engine/SCons/Script/Main.py @@ -47,6 +47,7 @@ import os import sys import time import traceback +import sysconfig import SCons.CacheDir import SCons.Debug @@ -1251,12 +1252,15 @@ def _build_targets(fs, options, targets, target_top): # various print_* settings, tree_printer list, etc. BuildTask.options = options + + python_has_threads = sysconfig.get_config_var('WITH_THREAD') + # to check if python configured with threads. global num_jobs num_jobs = options.num_jobs jobs = SCons.Job.Jobs(num_jobs, taskmaster) if num_jobs > 1: msg = None - if jobs.num_jobs == 1: + if jobs.num_jobs == 1 or not python_has_threads: msg = "parallel builds are unsupported by this version of Python;\n" + \ "\tignoring -j or num_jobs option.\n" elif sys.platform == 'win32': -- cgit v0.12 From ec5cfb99fa60afc33a52bf231f16d44d1f9a0074 Mon Sep 17 00:00:00 2001 From: Gaurav Juvekar Date: Fri, 7 Apr 2017 13:39:33 +0530 Subject: py2/3 fixes for CPPDEFINES/append.py test case --- test/CPPDEFINES/append.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/test/CPPDEFINES/append.py b/test/CPPDEFINES/append.py index 14ea7b3..04a2d7b 100644 --- a/test/CPPDEFINES/append.py +++ b/test/CPPDEFINES/append.py @@ -52,12 +52,28 @@ env_2300_2 = Environment(CPPDEFINES = ['foo'], CPPDEFPREFIX='-D') # note the lis env_2300_2.Append(CPPDEFINES='bar') print(env_2300_2.subst('$_CPPDEFFLAGS')) + +# Python3 dicts dont preserve order. Hence we supply subclass of OrderedDict +# whose __str__ and __repr__ act like a normal dict. +from collections import OrderedDict +class OrderedPrintingDict(OrderedDict): + def __str__(self): + return '{' + ', '.join(['%r: %r'%(k, v) for (k, v) in self.items()]) + '}' + + def __repr__(self): + return '{' + ', '.join(['%r: %r'%(k, v) for (k, v) in self.items()]) + '}' + + def __semi_deepcopy__(self): + # Because a dict subclass is not deep copied directly when constructing + # Environment(CPPDEFINES = OrderedPrintingDict(...)) + return self.copy() + # http://scons.tigris.org/issues/show_bug.cgi?id=1152 # http://scons.tigris.org/issues/show_bug.cgi?id=2900 cases=[('string', 'FOO'), ('list', ['NAME1', 'NAME2']), ('list-of-2lists', [('NAME1','VAL1'), ['NAME2','VAL2']]), - ('dict', {'NAME1' : 'VAL1', 'NAME2' : 'VAL2', 'NAME3' : None}) + ('dict', OrderedPrintingDict([('NAME2', 'VAL2'), ('NAME3', None), ('NAME1', 'VAL1')])) ] for (t1, c1) in cases: @@ -180,7 +196,7 @@ AppendUnique: ==== Testing CPPDEFINES, appending a string to a dict orig = {'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'}, append = FOO Append: - result={'FOO': None, 'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'} + result={'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1', 'FOO': None} final=-DFOO -DNAME1=VAL1 -DNAME2=VAL2 -DNAME3 AppendUnique: result=[('NAME2', 'VAL2'), ('NAME3',), ('NAME1', 'VAL1'), 'FOO'] -- cgit v0.12 From 16891265ea2e81e03b8bb3d6e30bbc2a2a642ebe Mon Sep 17 00:00:00 2001 From: Gaurav Juvekar Date: Fri, 7 Apr 2017 13:52:06 +0530 Subject: Make __str__ and __repr__ same --- test/CPPDEFINES/append.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/test/CPPDEFINES/append.py b/test/CPPDEFINES/append.py index 04a2d7b..7973f22 100644 --- a/test/CPPDEFINES/append.py +++ b/test/CPPDEFINES/append.py @@ -52,24 +52,22 @@ env_2300_2 = Environment(CPPDEFINES = ['foo'], CPPDEFPREFIX='-D') # note the lis env_2300_2.Append(CPPDEFINES='bar') print(env_2300_2.subst('$_CPPDEFFLAGS')) - +# http://scons.tigris.org/issues/show_bug.cgi?id=1152 +# http://scons.tigris.org/issues/show_bug.cgi?id=2900 # Python3 dicts dont preserve order. Hence we supply subclass of OrderedDict # whose __str__ and __repr__ act like a normal dict. from collections import OrderedDict class OrderedPrintingDict(OrderedDict): - def __str__(self): - return '{' + ', '.join(['%r: %r'%(k, v) for (k, v) in self.items()]) + '}' - def __repr__(self): return '{' + ', '.join(['%r: %r'%(k, v) for (k, v) in self.items()]) + '}' + __str__ = __repr__ + + # Because dict-like objects (except dict and UserDict) are not deep copied + # directly when constructing Environment(CPPDEFINES = OrderedPrintingDict(...)) def __semi_deepcopy__(self): - # Because a dict subclass is not deep copied directly when constructing - # Environment(CPPDEFINES = OrderedPrintingDict(...)) return self.copy() -# http://scons.tigris.org/issues/show_bug.cgi?id=1152 -# http://scons.tigris.org/issues/show_bug.cgi?id=2900 cases=[('string', 'FOO'), ('list', ['NAME1', 'NAME2']), ('list-of-2lists', [('NAME1','VAL1'), ['NAME2','VAL2']]), -- cgit v0.12 From 8e6b5fc8645b39234367d95590fabf91329c248f Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 7 Apr 2017 09:20:41 -0700 Subject: fix breaking windows check for functional parallel builds --- src/engine/SCons/Script/Main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py index b7ce466..c810634 100644 --- a/src/engine/SCons/Script/Main.py +++ b/src/engine/SCons/Script/Main.py @@ -1260,11 +1260,11 @@ def _build_targets(fs, options, targets, target_top): jobs = SCons.Job.Jobs(num_jobs, taskmaster) if num_jobs > 1: msg = None - if jobs.num_jobs == 1 or not python_has_threads: + if sys.platform == 'win32': + msg = fetch_win32_parallel_msg() + elif jobs.num_jobs == 1 or not python_has_threads: msg = "parallel builds are unsupported by this version of Python;\n" + \ "\tignoring -j or num_jobs option.\n" - elif sys.platform == 'win32': - msg = fetch_win32_parallel_msg() if msg: SCons.Warnings.warn(SCons.Warnings.NoParallelSupportWarning, msg) -- cgit v0.12 From 77d00668798f7be8ea2355a64ba5cb1b667e20a5 Mon Sep 17 00:00:00 2001 From: Gaurav Juvekar Date: Sat, 8 Apr 2017 14:06:30 +0530 Subject: py2/3 fixes for CPPDEFINES/pkg-config.py Use a dict which preserves its order so that output matches --- test/CPPDEFINES/pkg-config.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/test/CPPDEFINES/pkg-config.py b/test/CPPDEFINES/pkg-config.py index 4e81dec..42f38b6 100644 --- a/test/CPPDEFINES/pkg-config.py +++ b/test/CPPDEFINES/pkg-config.py @@ -56,6 +56,20 @@ int main(int argc, char *argv[]) """) test.write('SConstruct', """\ +# Python3 dicts dont preserve order. Hence we supply subclass of OrderedDict +# whose __str__ and __repr__ act like a normal dict. +from collections import OrderedDict +class OrderedPrintingDict(OrderedDict): + def __repr__(self): + return '{' + ', '.join(['%r: %r'%(k, v) for (k, v) in self.items()]) + '}' + + __str__ = __repr__ + + # Because dict-like objects (except dict and UserDict) are not deep copied + # directly when constructing Environment(CPPDEFINES = OrderedPrintingDict(...)) + def __semi_deepcopy__(self): + return self.copy() +""" + """ # http://scons.tigris.org/issues/show_bug.cgi?id=2671 # Passing test cases env_1 = Environment(CPPDEFINES=[('DEBUG','1'), 'TEST']) @@ -67,11 +81,11 @@ env_2.MergeFlags('-DSOMETHING -DVARIABLE=2') print(env_2.subst('$_CPPDEFFLAGS')) # Failing test cases -env_3 = Environment(CPPDEFINES={'DEBUG':1, 'TEST':None}) +env_3 = Environment(CPPDEFINES=OrderedPrintingDict([('DEBUG', 1), ('TEST', None)])) env_3.ParseConfig('PKG_CONFIG_PATH=. %(pkg_config_path)s --cflags bug') print(env_3.subst('$_CPPDEFFLAGS')) -env_4 = Environment(CPPDEFINES={'DEBUG':1, 'TEST':None}) +env_4 = Environment(CPPDEFINES=OrderedPrintingDict([('DEBUG', 1), ('TEST', None)])) env_4.MergeFlags('-DSOMETHING -DVARIABLE=2') print(env_4.subst('$_CPPDEFFLAGS')) -- cgit v0.12 From 5a9dc6249678cc9987cb75dd9b26b9eddd895883 Mon Sep 17 00:00:00 2001 From: Gaurav Juvekar Date: Sat, 8 Apr 2017 20:43:29 +0530 Subject: Fix the Copy-Action test case for py2/3 --- src/engine/SCons/Defaults.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py index ded9539..69d5c94 100644 --- a/src/engine/SCons/Defaults.py +++ b/src/engine/SCons/Defaults.py @@ -264,7 +264,10 @@ def copy_func(dest, src, symlinks=True): shutil.copy2(src, dest) return 0 else: - return shutil.copytree(src, dest, symlinks) + shutil.copytree(src, dest, symlinks) + # copytree returns None in python2 and destination string in python3 + # A error is raised in both cases, so we can just return 0 for success + return 0 Copy = ActionFactory( copy_func, -- cgit v0.12 From 841c3b0c2960822c4cc02235b104d5487316ac30 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 8 Apr 2017 18:21:10 -0700 Subject: Fix issue where a blank line would lead to runtest.py dropping user into a python shell --- runtest.py | 1 + 1 file changed, 1 insertion(+) diff --git a/runtest.py b/runtest.py index 0d9bbaf..18d4121 100755 --- a/runtest.py +++ b/runtest.py @@ -686,6 +686,7 @@ if testlistfile: tests = [x for x in tests if x[0] != '#'] tests = [x[:-1] for x in tests] tests = [x.strip() for x in tests] + tests = [x for x in tests if len(x) > 0] else: testpaths = [] -- cgit v0.12 From 1d60cfed5451fabf22ec48256248b6d3ad57b594 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 8 Apr 2017 18:22:54 -0700 Subject: OSX: if user has SCONS_USE_MAC_PATHS environment variable set, then PATHOSX created from paths in /etc/paths and /etc/paths.d/* will be appended to the Environment's PATH. This allows tests (and builds) to work on (at least) on mac systems using macports --- src/engine/SCons/Platform/darwin.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/engine/SCons/Platform/darwin.py b/src/engine/SCons/Platform/darwin.py index 1cf4aeb..c85b75b 100644 --- a/src/engine/SCons/Platform/darwin.py +++ b/src/engine/SCons/Platform/darwin.py @@ -63,6 +63,10 @@ def generate(env): env.AppendENVPath('PATHOSX', line.strip('\n')) f.close() + # Not sure why this wasn't the case all along? + if env['ENV'].get('PATHOSX', False) and os.environ.get('SCONS_USE_MAC_PATHS', False): + env.AppendENVPath('PATH',env['ENV']['PATHOSX']) + # Local Variables: # tab-width:4 # indent-tabs-mode:nil -- cgit v0.12 From 937b081a09617398ceb0a8bcea6d09ccda3cbad4 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 8 Apr 2017 18:23:41 -0700 Subject: OSX: for now don't run versioned lib tests on mac. The logic to generate the versioned libraries has the wrong format for osx/darwin --- test/LINK/VersionedLib-VariantDir.py | 10 +++++++++- test/LINK/VersionedLib-j2.py | 5 +++++ test/LINK/VersionedLib-subdir.py | 5 +++++ test/LINK/VersionedLib.py | 6 ++++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/test/LINK/VersionedLib-VariantDir.py b/test/LINK/VersionedLib-VariantDir.py index 0a631b0..0350c6e 100644 --- a/test/LINK/VersionedLib-VariantDir.py +++ b/test/LINK/VersionedLib-VariantDir.py @@ -35,11 +35,19 @@ import sys import SCons.Platform import SCons.Defaults +test = TestSCons.TestSCons() + +import sys +if sys.platform == 'darwin': + # Skipping until logic is fixed for macosx + test.skip_test("Not working on darwin yet\n") + + env = SCons.Defaults.DefaultEnvironment() platform = SCons.Platform.platform_default() tool_list = SCons.Platform.DefaultToolList(platform, env) -test = TestSCons.TestSCons() + test.subdir(['src']) test.subdir(['src','lib']) diff --git a/test/LINK/VersionedLib-j2.py b/test/LINK/VersionedLib-j2.py index 249b54f..4646a37 100644 --- a/test/LINK/VersionedLib-j2.py +++ b/test/LINK/VersionedLib-j2.py @@ -39,6 +39,11 @@ import SCons.Defaults test = TestSCons.TestSCons() +if sys.platform == 'darwin': + # Skipping until logic is fixed for macosx + test.skip_test("Not working on darwin yet\n") + + test.write('foo.c', """ #if _WIN32 __declspec(dllexport) diff --git a/test/LINK/VersionedLib-subdir.py b/test/LINK/VersionedLib-subdir.py index a2e141b..91f3011 100644 --- a/test/LINK/VersionedLib-subdir.py +++ b/test/LINK/VersionedLib-subdir.py @@ -41,6 +41,11 @@ import SCons.Defaults test = TestSCons.TestSCons() +if sys.platform == 'darwin': + # Skipping until logic is fixed for macosx + test.skip_test("Not working on darwin yet\n") + + test.write('foo.c', """ #if _WIN32 __declspec(dllexport) diff --git a/test/LINK/VersionedLib.py b/test/LINK/VersionedLib.py index 468e3e5..c05c159 100644 --- a/test/LINK/VersionedLib.py +++ b/test/LINK/VersionedLib.py @@ -33,6 +33,12 @@ import TestSCons import SCons.Platform import SCons.Defaults +import sys +if sys.platform == 'darwin': + # Skipping until logic is fixed for macosx + test = TestSCons.TestSCons() + test.skip_test("Not working on darwin yet\n") + env = SCons.Defaults.DefaultEnvironment() platform = SCons.Platform.platform_default() tool_list = SCons.Platform.DefaultToolList(platform, env) -- cgit v0.12 From b5c465f6f0874bd27a85891536ac157b6dcbadbe Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 8 Apr 2017 18:23:56 -0700 Subject: add docstring --- src/engine/SCons/Tool/link.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/engine/SCons/Tool/link.py b/src/engine/SCons/Tool/link.py index b7db947..07e9250 100644 --- a/src/engine/SCons/Tool/link.py +++ b/src/engine/SCons/Tool/link.py @@ -243,8 +243,10 @@ def _versioned_lib_callbacks(): 'VersionedLdModSoname' : _versioned_ldmod_soname, }.copy() -# Setup all variables required by the versioning machinery def _setup_versioned_lib_variables(env, **kw): + """ + Setup all variables required by the versioning machinery + """ tool = None try: tool = kw['tool'] -- cgit v0.12 From f24bc75523ba61b32c67ab6f5ad701b7a4023614 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 8 Apr 2017 18:24:21 -0700 Subject: osx: add logic to enable versioned shared libraries on osx/darwin. For now it's commented out --- src/engine/SCons/Tool/applelink.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/engine/SCons/Tool/applelink.py b/src/engine/SCons/Tool/applelink.py index ba955a4..c5f4376 100644 --- a/src/engine/SCons/Tool/applelink.py +++ b/src/engine/SCons/Tool/applelink.py @@ -51,6 +51,14 @@ def generate(env): env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -dynamiclib') env['SHLINKCOM'] = env['SHLINKCOM'] + ' $_FRAMEWORKPATH $_FRAMEWORKS $FRAMEWORKSFLAGS' + + # TODO: Work needed to generate versioned shared libraries + # Leaving this commented out, and also going to disable versioned library checking for now + # see: http://docstore.mik.ua/orelly/unix3/mac/ch05_04.htm for proper naming + #link._setup_versioned_lib_variables(env, tool = 'applelink')#, use_soname = use_soname) + #env['LINKCALLBACKS'] = link._versioned_lib_callbacks() + + # override the default for loadable modules, which are different # on OS X than dynamic shared libs. echoing what XCode does for # pre/suffixes: -- cgit v0.12 From 8e6c6ad7f23cf988376d313cdbc510e4ad2c0f86 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 8 Apr 2017 18:24:35 -0700 Subject: pep8 --- src/engine/SCons/Tool/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index 99e0770..61b7788 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -761,6 +761,7 @@ def LibSymlinksStrFun(target, source, env, *args): LibSymlinksAction = SCons.Action.Action(LibSymlinksActionFunction, LibSymlinksStrFun) + def createSharedLibBuilder(env): """This is a utility function that creates the SharedLibrary Builder in an Environment if it is not there already. -- cgit v0.12 From c6281db8311345dbae895a498bd44b73600d4c0c Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 8 Apr 2017 18:26:06 -0700 Subject: osx: fix get_platform_python_info() to work on mac. --- QMTest/TestSCons.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index 5a9d21f..9c89249 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -1246,7 +1246,10 @@ try: import distutils.sysconfig exec_prefix = distutils.sysconfig.EXEC_PREFIX print(distutils.sysconfig.get_python_inc()) - print(os.path.join(exec_prefix, 'libs')) + lib_path = os.path.join(exec_prefix, 'libs') + if not os.path.exists(lib_path): + lib_path = os.path.join(exec_prefix, 'lib') + print(lib_path) except: print(os.path.join(sys.prefix, 'include', py_ver)) print(os.path.join(sys.prefix, 'lib', py_ver, 'config')) -- cgit v0.12 From 35e2fb999be90a3d6619fc404910567822993e1f Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 9 Apr 2017 15:10:45 -0700 Subject: For docbook, stop looking after you find the first tool. It looks like saxon-xslt causes the tests to fail. Dirk? --- src/engine/SCons/Tool/docbook/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/SCons/Tool/docbook/__init__.py b/src/engine/SCons/Tool/docbook/__init__.py index 8a7b2e7..89afe5d 100644 --- a/src/engine/SCons/Tool/docbook/__init__.py +++ b/src/engine/SCons/Tool/docbook/__init__.py @@ -179,6 +179,7 @@ def __detect_cl_tool(env, chainkey, cdict): env[chainkey] = clpath if not env[chainkey + 'COM']: env[chainkey + 'COM'] = cdict[cltool] + break def _detect(env): """ -- cgit v0.12 From 9001886a331f96450bad7c39a6b756ad62242b49 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 9 Apr 2017 18:13:02 -0700 Subject: py2/3 initial changes to try and get SCons build working with py3 --- SConstruct | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/SConstruct b/SConstruct index 08f7da5..57f2fc1 100644 --- a/SConstruct +++ b/SConstruct @@ -162,6 +162,15 @@ import distutils.command no_winpack_templates = not os.path.exists(os.path.join(os.path.split(distutils.command.__file__)[0],'wininst-9.0.exe')) skip_win_packages = ARGUMENTS.get('SKIP_WIN_PACKAGES',False) or no_winpack_templates + +if sys.version_info[0] > 2: + # TODO: Resolve this issue. Currently fails when run on windows with + # File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/command/bdist_wininst.py", line 262, in create_exe + # cfgdata = cfgdata.encode("mbcs") + # LookupError: unknown encoding: mbcs + print("Temporary PY3: Skipping windows package builds") + skip_win_packages = True + if skip_win_packages: print("Skipping the build of Windows packages...") @@ -327,17 +336,20 @@ try: def zipit(env, target, source): print("Zipping %s:" % str(target[0])) - def visit(arg, dirname, names): - for name in names: - path = os.path.join(dirname, name) + def visit(arg, dirname, filenames): + for filename in filenames: + path = os.path.join(dirname, filename) if os.path.isfile(path): arg.write(path) # default ZipFile compression is ZIP_STORED zf = zipfile.ZipFile(str(target[0]), 'w', compression=zipfile.ZIP_DEFLATED) olddir = os.getcwd() os.chdir(env['CD']) - try: os.path.walk(env['PSV'], visit, zf) - finally: os.chdir(olddir) + try: + for dirname, dirnames, filenames in os.walk(env['PSV']): + visit(zf, dirname, filenames) + finally: + os.chdir(olddir) zf.close() def unzipit(env, target, source): @@ -364,6 +376,7 @@ except ImportError: zipit = "cd $CD && $ZIP $ZIPFLAGS $( ${TARGET.abspath} $) $PSV" unzipit = "$UNZIP $UNZIPFLAGS $SOURCES" + def SCons_revision(target, source, env): """Interpolate specific values from the environment into a file. @@ -372,7 +385,7 @@ def SCons_revision(target, source, env): """ t = str(target[0]) s = source[0].rstr() - with open(s, 'rb') as fp: + with open(s, 'r') as fp: contents = fp.read() # Note: We construct the __*__ substitution strings here # so that they don't get replaced when this file gets @@ -387,9 +400,10 @@ def SCons_revision(target, source, env): contents = contents.replace('__REVISION' + '__', env['REVISION']) contents = contents.replace('__VERSION' + '__', env['VERSION']) contents = contents.replace('__NULL' + '__', '') - open(t, 'wb').write(contents) + open(t, 'w').write(contents) os.chmod(t, os.stat(s)[0]) + revaction = SCons_revision revbuilder = Builder(action = Action(SCons_revision, varlist=['COPYRIGHT', 'VERSION'])) @@ -819,6 +833,7 @@ for p in [ scons ]: s = p['filemap'].get(b, b) if not s[0] == '$' and not os.path.isabs(s): s = os.path.join(src, s) + builder = p['buildermap'].get(b, env.SCons_revision) x = builder(os.path.join(build, b), s) Local(x) @@ -835,7 +850,7 @@ for p in [ scons ]: def write_src_files(target, source, **kw): global src_files src_files.sort() - f = open(str(target[0]), 'wb') + f = open(str(target[0]), 'w') for file in src_files: f.write(file + "\n") f.close() @@ -1017,10 +1032,10 @@ for p in [ scons ]: list generated from our MANIFEST(s), so we don't have to maintain multiple lists. """ - c = open(str(source[0]), 'rb').read() + c = open(str(source[0]), 'r').read() c = c.replace('__VERSION' + '__', env['VERSION']) c = c.replace('__RPM_FILES' + '__', env['RPM_FILES']) - open(str(target[0]), 'wb').write(c) + open(str(target[0]), 'w').write(c) rpm_files.sort() rpm_files_str = "\n".join(rpm_files) + "\n" -- cgit v0.12 From a66460a28e7672071cbb5c003332cfdc96669563 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 10 Apr 2017 11:14:23 -0700 Subject: switch to os.system as in py3 os.popen() seemed to not have completed untar before the test checked for files --- test/packaging/use-builddir.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/packaging/use-builddir.py b/test/packaging/use-builddir.py index 76b9737..9ad7aa4 100644 --- a/test/packaging/use-builddir.py +++ b/test/packaging/use-builddir.py @@ -85,7 +85,7 @@ test.run(stderr = None) test.must_exist( 'libfoo-1.2.3.tar.gz' ) -os.popen( 'tar -C temp -xzf %s'%test.workpath('libfoo-1.2.3.tar.gz') ) +os.system('tar -C temp -xzf %s'%test.workpath('libfoo-1.2.3.tar.gz') ) test.must_exist( 'temp/libfoo-1.2.3/src/main.c' ) test.must_exist( 'temp/libfoo-1.2.3/SConstruct' ) -- cgit v0.12 From 31383c850bc278c11c6020ce3f0704a402584a2d Mon Sep 17 00:00:00 2001 From: Gaurav Juvekar Date: Tue, 11 Apr 2017 00:01:37 +0530 Subject: py2/3 fix for test/Value.py --- src/engine/SCons/Node/Python.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/engine/SCons/Node/Python.py b/src/engine/SCons/Node/Python.py index f151fc5..2a3ce98 100644 --- a/src/engine/SCons/Node/Python.py +++ b/src/engine/SCons/Node/Python.py @@ -58,7 +58,7 @@ class ValueNodeInfo(SCons.Node.NodeInfoBase): del state['__weakref__'] except KeyError: pass - + return state def __setstate__(self, state): @@ -77,7 +77,7 @@ class ValueBuildInfo(SCons.Node.BuildInfoBase): current_version_id = 2 class Value(SCons.Node.Node): - """A class for Python variables, typically passed on the command line + """A class for Python variables, typically passed on the command line or generated by a script, but not from a file or some other source. """ @@ -108,7 +108,7 @@ class Value(SCons.Node.Node): is_up_to_date = SCons.Node.Node.children_are_up_to_date def is_under(self, dir): - # Make Value nodes get built regardless of + # Make Value nodes get built regardless of # what directory scons was run from. Value nodes # are outside the filesystem: return 1 @@ -133,10 +133,11 @@ class Value(SCons.Node.Node): ###TODO: something reasonable about universal newlines contents = str(self.value) for kid in self.children(None): - contents = contents + kid.get_contents() + contents = contents + kid.get_contents().decode() return contents - get_contents = get_text_contents ###TODO should return 'bytes' value + def get_contents(self): + return self.get_text_contents().encode() def changed_since_last_build(self, target, prev_ni): cur_csig = self.get_csig() -- cgit v0.12 From 2c7b4f7cd5a2277208902c3b59c98b8530fd8698 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 10 Apr 2017 11:40:50 -0700 Subject: py2/3 change to read sconscripts as binary file. at least test/packaging/rpm/internationalization.py was failing because an open in py3 without specified encoding with LANG=C was trying to decode the file as ascii and it contained unicode characters and was failing. So far I haven't found any tests failing from this change --- src/engine/SCons/Script/SConscript.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py index 8609892..558e28f 100644 --- a/src/engine/SCons/Script/SConscript.py +++ b/src/engine/SCons/Script/SConscript.py @@ -179,10 +179,10 @@ def _SConscript(fs, *files, **kw): fs.chdir(top, change_os_dir=1) if f.rexists(): actual = f.rfile() - _file_ = open(actual.get_abspath(), "r") + _file_ = open(actual.get_abspath(), "rb") elif f.srcnode().rexists(): actual = f.srcnode().rfile() - _file_ = open(actual.get_abspath(), "r") + _file_ = open(actual.get_abspath(), "rb") elif f.has_src_builder(): # The SConscript file apparently exists in a source # code management system. Build it, but then clear @@ -192,7 +192,7 @@ def _SConscript(fs, *files, **kw): f.built() f.builder_set(None) if f.exists(): - _file_ = open(f.get_abspath(), "r") + _file_ = open(f.get_abspath(), "rb") if _file_: # Chdir to the SConscript directory. Use a path # name relative to the SConstruct file so that if @@ -248,6 +248,7 @@ def _SConscript(fs, *files, **kw): pass try: try: +# _file_ = SCons.Util.to_str(_file_) exec(compile(_file_.read(), _file_.name, 'exec'), call_stack[-1].globals) except SConscriptReturn: -- cgit v0.12 From 550fcc144495dfd8569831e2a0996b4e134549f8 Mon Sep 17 00:00:00 2001 From: Gaurav Juvekar Date: Tue, 11 Apr 2017 00:36:39 +0530 Subject: Fix broken tests --- src/engine/SCons/Node/PythonTests.py | 6 +++--- src/engine/SCons/SConf.py | 8 ++++---- src/engine/SCons/SConfTests.py | 38 ++++++++++++++++++------------------ 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/engine/SCons/Node/PythonTests.py b/src/engine/SCons/Node/PythonTests.py index e2e36bf..346542b 100644 --- a/src/engine/SCons/Node/PythonTests.py +++ b/src/engine/SCons/Node/PythonTests.py @@ -90,15 +90,15 @@ class ValueTestCase(unittest.TestCase): """ v1 = SCons.Node.Python.Value('aaa') csig = v1.get_csig(None) - assert csig == 'aaa', csig + assert csig.decode() == 'aaa', csig v2 = SCons.Node.Python.Value(7) csig = v2.get_csig(None) - assert csig == '7', csig + assert csig.decode() == '7', csig v3 = SCons.Node.Python.Value(None) csig = v3.get_csig(None) - assert csig == 'None', csig + assert csig.decode() == 'None', csig class ValueNodeInfoTestCase(unittest.TestCase): def test___init__(self): diff --git a/src/engine/SCons/SConf.py b/src/engine/SCons/SConf.py index 31d9402..889af4a 100644 --- a/src/engine/SCons/SConf.py +++ b/src/engine/SCons/SConf.py @@ -110,7 +110,7 @@ def _createConfigH(target, source, env): #define %(DEFNAME)s_SEEN """ % {'DEFNAME' : defname}) - t.write(source[0].get_contents()) + t.write(source[0].get_contents().decode()) t.write(""" #endif /* %(DEFNAME)s_SEEN */ """ % {'DEFNAME' : defname}) @@ -164,11 +164,11 @@ class ConfigureCacheError(SConfError): # define actions for building text files def _createSource( target, source, env ): fd = open(str(target[0]), "w") - fd.write(source[0].get_contents()) + fd.write(source[0].get_contents().decode()) fd.close() def _stringSource( target, source, env ): return (str(target[0]) + ' <-\n |' + - source[0].get_contents().replace( '\n', "\n |" ) ) + source[0].get_contents().decode().replace( '\n', "\n |" ) ) class SConfBuildInfo(SCons.Node.FS.FileBuildInfo): """ @@ -609,7 +609,7 @@ class SConfBase(object): ok = self.TryBuild(self.env.SConfActionBuilder, text, extension) del self.env['BUILDERS']['SConfActionBuilder'] if ok: - outputStr = self.lastTarget.get_contents() + outputStr = self.lastTarget.get_contents().decode() return (1, outputStr) return (0, "") diff --git a/src/engine/SCons/SConfTests.py b/src/engine/SCons/SConfTests.py index b2aa3b4..0daf31c 100644 --- a/src/engine/SCons/SConfTests.py +++ b/src/engine/SCons/SConfTests.py @@ -48,7 +48,7 @@ class SConfTestCase(unittest.TestCase): def setUp(self): # we always want to start with a clean directory self.save_cwd = os.getcwd() - self.test = TestCmd.TestCmd(workdir = '') + self.test = TestCmd.TestCmd(workdir = '') os.chdir(self.test.workpath('')) def tearDown(self): @@ -109,7 +109,7 @@ class SConfTestCase(unittest.TestCase): # TryCompile and TryLink are much the same, so we can test them # in one method, we pass the function as a string ('TryCompile', # 'TryLink'), so we are aware of reloading modules. - + def checks(self, sconf, TryFuncString): TryFunc = self.SConf.SConfBase.__dict__[TryFuncString] res1 = TryFunc( sconf, "int main() { return 0; }\n", ".c" ) @@ -128,7 +128,7 @@ class SConfTestCase(unittest.TestCase): assert res[0] and not res[1], res finally: sconf.Finish() - + # 2.1 test the error caching mechanism (no dependencies have changed) self._resetSConfState() sconf = self.SConf.SConf(self.scons_env, @@ -139,9 +139,9 @@ class SConfTestCase(unittest.TestCase): assert res[0] and not res[1], res finally: sconf.Finish() - # we should have exactly one one error cached + # we should have exactly one one error cached log = str(self.test.read( self.test.workpath('config.log') )) - expr = re.compile( ".*failed in a previous run and all", re.DOTALL ) + expr = re.compile( ".*failed in a previous run and all", re.DOTALL ) firstOcc = expr.match( log ) assert firstOcc is not None, log secondOcc = expr.match( log, firstOcc.end(0) ) @@ -239,11 +239,11 @@ class SConfTestCase(unittest.TestCase): """Test SConf.TryCompile """ self._baseTryXXX( "TryCompile" ) #self.SConf.SConf.TryCompile ) - + def test_TryLink(self): """Test SConf.TryLink """ - self._baseTryXXX( "TryLink" ) #self.SConf.SConf.TryLink ) + self._baseTryXXX( "TryLink" ) #self.SConf.SConf.TryLink ) def test_TryRun(self): """Test SConf.TryRun @@ -256,10 +256,10 @@ int main() { return 0; } """ - res1 = sconf.TryRun( prog, ".c" ) + res1 = sconf.TryRun( prog, ".c" ) res2 = sconf.TryRun( "not a c program\n", ".c" ) return (res1, res2) - + self._resetSConfState() sconf = self.SConf.SConf(self.scons_env, conf_dir=self.test.workpath('config.tests'), @@ -307,7 +307,7 @@ int main() { log_file=self.test.workpath('config.log')) try: (ret, output) = sconf.TryAction(action=actionOK) - assert ret and output == bytearray("RUN OK"+os.linesep,'utf-8'), (ret, output) + assert ret and output.encode('utf-8') == bytearray("RUN OK"+os.linesep,'utf-8'), (ret, output) (ret, output) = sconf.TryAction(action=actionFAIL) assert not ret and output == "", (ret, output) finally: @@ -354,7 +354,7 @@ int main() { try: self._test_check_compilers('CC', sconf.CheckCC, 'CheckCC') except AssertionError: - sys.stderr.write(self.test.read('config.log')) + sys.stderr.write(self.test.read('config.log', mode='r')) raise finally: sconf.Finish() @@ -370,7 +370,7 @@ int main() { try: self._test_check_compilers('SHCC', sconf.CheckSHCC, 'CheckSHCC') except AssertionError: - sys.stderr.write(self.test.read('config.log')) + sys.stderr.write(self.test.read('config.log', mode='r')) raise finally: sconf.Finish() @@ -386,7 +386,7 @@ int main() { try: self._test_check_compilers('CXX', sconf.CheckCXX, 'CheckCXX') except AssertionError: - sys.stderr.write(self.test.read('config.log')) + sys.stderr.write(self.test.read('config.log', mode='r')) raise finally: sconf.Finish() @@ -402,7 +402,7 @@ int main() { try: self._test_check_compilers('SHCXX', sconf.CheckSHCXX, 'CheckSHCXX') except AssertionError: - sys.stderr.write(self.test.read('config.log')) + sys.stderr.write(self.test.read('config.log', mode='r')) raise finally: sconf.Finish() @@ -627,8 +627,8 @@ int main() { else: r = sconf.CheckProg('cmd.exe') self.assertIn('cmd.exe',r) - - + + r = sconf.CheckProg('hopefully-not-a-program') assert r is None @@ -717,7 +717,7 @@ int main() { # In ANSI C, malloc should be available in stdlib r = sconf.CheckDeclaration('malloc', includes = "#include ") assert r, "malloc not declared ??" - # For C++, __cplusplus should be declared + # For C++, __cplusplus should be declared r = sconf.CheckDeclaration('__cplusplus', language = 'C++') assert r, "__cplusplus not declared in C++ ??" r = sconf.CheckDeclaration('__cplusplus', language = 'C') @@ -761,7 +761,7 @@ int main() { test.Result( ret ) assert ret and output == "Hello", (ret, output) return ret - + self._resetSConfState() sconf = self.SConf.SConf(self.scons_env, @@ -773,7 +773,7 @@ int main() { assert ret, ret finally: sconf.Finish() - + if __name__ == "__main__": suite = unittest.makeSuite(SConfTestCase, 'test_') -- cgit v0.12 From 1cae9523c7cb5b241c1b14021e92d6eccceac7ca Mon Sep 17 00:00:00 2001 From: Gaurav Juvekar Date: Fri, 14 Apr 2017 20:18:20 +0530 Subject: Dirty hack for failing test/sconsign/script/Configure.py --- src/script/sconsign.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/script/sconsign.py b/src/script/sconsign.py index 8f1722a..2e7a550 100644 --- a/src/script/sconsign.py +++ b/src/script/sconsign.py @@ -241,6 +241,11 @@ def default_mapper(entry, name): val = eval("entry."+name) except: val = None + if sys.version_info.major >= 3 and isinstance(val, bytes): + # This is a dirty hack for py 2/3 compatibility. csig is a bytes object + # in Python3 while Python2 bytes are str. Hence, we decode the csig to a + # Python3 string + val = val.decode() return str(val) def map_action(entry, name): -- cgit v0.12 From e2644d7ee935b61f3307aafd376a9bca732f50bc Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 15 Apr 2017 17:27:47 -0700 Subject: remove deprecated module SCons.Sig --- src/CHANGES.txt | 1 + src/engine/SCons/Sig.py | 63 --------------------------------------------- test/Deprecated/Sig.py | 68 ------------------------------------------------- 3 files changed, 1 insertion(+), 131 deletions(-) delete mode 100644 src/engine/SCons/Sig.py delete mode 100644 test/Deprecated/Sig.py diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 5127c51..2b0c3cd 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -40,6 +40,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER From William Deegan: - Removed deprecated tools CVS, Perforce, BitKeeper, RCS, SCCS, Subversion. + - Removed deprecated module SCons.Sig From Daniel Moody: - Fixed msvs.py for Visual Studio generated projects which were diff --git a/src/engine/SCons/Sig.py b/src/engine/SCons/Sig.py deleted file mode 100644 index 35fffc1..0000000 --- a/src/engine/SCons/Sig.py +++ /dev/null @@ -1,63 +0,0 @@ -# -# __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__" - -__doc__ = """Place-holder for the old SCons.Sig module hierarchy - -This is no longer used, but code out there (such as the NSIS module on -the SCons wiki) may try to import SCons.Sig. If so, we generate a warning -that points them to the line that caused the import, and don't die. - -If someone actually tried to use the sub-modules or functions within -the package (for example, SCons.Sig.MD5.signature()), then they'll still -get an AttributeError, but at least they'll know where to start looking. -""" - -import SCons.Util -import SCons.Warnings - -msg = 'The SCons.Sig module no longer exists.\n' \ - ' Remove the following "import SCons.Sig" line to eliminate this warning:' - -SCons.Warnings.warn(SCons.Warnings.DeprecatedSigModuleWarning, msg) - -default_calc = None -default_module = None - -class MD5Null(SCons.Util.Null): - def __repr__(self): - return "MD5Null()" - -class TimeStampNull(SCons.Util.Null): - def __repr__(self): - return "TimeStampNull()" - -MD5 = MD5Null() -TimeStamp = TimeStampNull() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Deprecated/Sig.py b/test/Deprecated/Sig.py deleted file mode 100644 index 1ae118b..0000000 --- a/test/Deprecated/Sig.py +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env python -# -# __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__" - -""" -Verify that we generate the proper warning, but don't die, when someone -tries to import the SCons.Sig module (which no longer exists) and -use the things we used to define therein. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -SConstruct = test.workpath('SConstruct') - -test.write(SConstruct, """ -import SCons.Sig -x = SCons.Sig.default_calc -x = SCons.Sig.default_module -x = SCons.Sig.MD5.current() -x = SCons.Sig.MD5.collect() -x = SCons.Sig.MD5.signature() -x = SCons.Sig.MD5.to_string() -x = SCons.Sig.MD5.from_string() -x = SCons.Sig.TimeStamp.current() -x = SCons.Sig.TimeStamp.collect() -x = SCons.Sig.TimeStamp.signature() -x = SCons.Sig.TimeStamp.to_string() -x = SCons.Sig.TimeStamp.from_string() -""") - -expect = """ -scons: warning: The SCons.Sig module no longer exists. - Remove the following "import SCons.Sig" line to eliminate this warning: -""" + test.python_file_line(SConstruct, 2) - -test.run(arguments = '.', stderr=expect) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: -- cgit v0.12 From 9ced8fe7b4e2f878df32ab3f606f851ac4cb6efc Mon Sep 17 00:00:00 2001 From: Gaurav Juvekar Date: Sun, 16 Apr 2017 19:46:47 +0530 Subject: Try to fix some more py2/3 tests becuase of str vs bytearray --- src/engine/SCons/Node/Python.py | 8 +++++++- src/engine/SCons/Tool/textfile.py | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/engine/SCons/Node/Python.py b/src/engine/SCons/Node/Python.py index 2a3ce98..8c47c97 100644 --- a/src/engine/SCons/Node/Python.py +++ b/src/engine/SCons/Node/Python.py @@ -137,7 +137,13 @@ class Value(SCons.Node.Node): return contents def get_contents(self): - return self.get_text_contents().encode() + text_contents = self.get_text_contents() + try: + return text_contents.encode() + except UnicodeDecodeError: + # Already encoded as python2 str are bytes + return text_contents + def changed_since_last_build(self, target, prev_ni): cur_csig = self.get_csig() diff --git a/src/engine/SCons/Tool/textfile.py b/src/engine/SCons/Tool/textfile.py index 0e4d943..42a79cd 100644 --- a/src/engine/SCons/Tool/textfile.py +++ b/src/engine/SCons/Tool/textfile.py @@ -71,7 +71,11 @@ def _do_subst(node, subs): contents = re.sub(k, v, contents) if 'b' in TEXTFILE_FILE_WRITE_MODE: - contents = bytearray(contents, 'utf-8') + try: + contents = bytearray(contents, 'utf-8') + except UnicodeDecodeError: + # contents is already utf-8 encoded python 2 str i.e. a byte array + contents = bytearray(contents) return contents -- cgit v0.12 From 99433738ce86c18b7622d547fa46cee71b06a818 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 17 Apr 2017 08:39:15 -0700 Subject: fix Manifest.in which was causing bootstrap.py to fail due to removal of Sig.py --- src/engine/MANIFEST.in | 1 - 1 file changed, 1 deletion(-) diff --git a/src/engine/MANIFEST.in b/src/engine/MANIFEST.in index c70466d..32f4965 100644 --- a/src/engine/MANIFEST.in +++ b/src/engine/MANIFEST.in @@ -47,7 +47,6 @@ SCons/Script/Interactive.py SCons/Script/Main.py SCons/Script/SConscript.py SCons/Script/SConsOptions.py -SCons/Sig.py SCons/Subst.py SCons/Taskmaster.py SCons/Tool/__init__.py -- cgit v0.12 From a7e0cf73de6da9a5da8acc0302b979e59c07330d Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 17 Apr 2017 15:34:30 -0700 Subject: set priority for finding xsltproc tools --- src/engine/SCons/Tool/docbook/__init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/engine/SCons/Tool/docbook/__init__.py b/src/engine/SCons/Tool/docbook/__init__.py index 89afe5d..e805253 100644 --- a/src/engine/SCons/Tool/docbook/__init__.py +++ b/src/engine/SCons/Tool/docbook/__init__.py @@ -157,6 +157,7 @@ def __create_output_dir(base_dir): # # Supported command line tools and their call "signature" # +xsltproc_com_priority = ['xsltproc', 'saxon', 'saxon-xslt', 'xalan'] xsltproc_com = {'xsltproc' : '$DOCBOOK_XSLTPROC $DOCBOOK_XSLTPROCFLAGS -o $TARGET $DOCBOOK_XSL $SOURCE', 'saxon' : '$DOCBOOK_XSLTPROC $DOCBOOK_XSLTPROCFLAGS -o $TARGET $DOCBOOK_XSL $SOURCE $DOCBOOK_XSLTPROCPARAMS', 'saxon-xslt' : '$DOCBOOK_XSLTPROC $DOCBOOK_XSLTPROCFLAGS -o $TARGET $DOCBOOK_XSL $SOURCE $DOCBOOK_XSLTPROCPARAMS', @@ -166,14 +167,17 @@ fop_com = {'fop' : '$DOCBOOK_FOP $DOCBOOK_FOPFLAGS -fo $SOURCE -pdf $TARGET', 'xep' : '$DOCBOOK_FOP $DOCBOOK_FOPFLAGS -valid -fo $SOURCE -pdf $TARGET', 'jw' : '$DOCBOOK_FOP $DOCBOOK_FOPFLAGS -f docbook -b pdf $SOURCE -o $TARGET'} -def __detect_cl_tool(env, chainkey, cdict): +def __detect_cl_tool(env, chainkey, cdict, cpriority=None): """ Helper function, picks a command line tool from the list and initializes its environment variables. """ if env.get(chainkey,'') == '': clpath = '' - for cltool in cdict: + + if cpriority is None: + cpriority = cdict.keys() + for cltool in cpriority: clpath = env.WhereIs(cltool) if clpath: env[chainkey] = clpath @@ -193,7 +197,7 @@ def _detect(env): if ((not has_libxml2 and not has_lxml) or (prefer_xsltproc)): # Try to find the XSLT processors - __detect_cl_tool(env, 'DOCBOOK_XSLTPROC', xsltproc_com) + __detect_cl_tool(env, 'DOCBOOK_XSLTPROC', xsltproc_com, xsltproc_com_priority) __detect_cl_tool(env, 'DOCBOOK_XMLLINT', xmllint_com) __detect_cl_tool(env, 'DOCBOOK_FOP', fop_com) -- cgit v0.12 From 066340f2d96ddc73e932f69f6f6df73b86eecde3 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 17 Apr 2017 21:29:36 -0700 Subject: add notes to xsltproc logic with future TODO's for future improvements --- src/engine/SCons/Tool/docbook/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/engine/SCons/Tool/docbook/__init__.py b/src/engine/SCons/Tool/docbook/__init__.py index e805253..d3ea8ae 100644 --- a/src/engine/SCons/Tool/docbook/__init__.py +++ b/src/engine/SCons/Tool/docbook/__init__.py @@ -158,6 +158,10 @@ def __create_output_dir(base_dir): # Supported command line tools and their call "signature" # xsltproc_com_priority = ['xsltproc', 'saxon', 'saxon-xslt', 'xalan'] + +# TODO: Set minimum version of saxon-xslt to be 8.x (lower than this only supports xslt 1.0. +# see: http://saxon.sourceforge.net/saxon6.5.5/ +# see: http://saxon.sourceforge.net/ xsltproc_com = {'xsltproc' : '$DOCBOOK_XSLTPROC $DOCBOOK_XSLTPROCFLAGS -o $TARGET $DOCBOOK_XSL $SOURCE', 'saxon' : '$DOCBOOK_XSLTPROC $DOCBOOK_XSLTPROCFLAGS -o $TARGET $DOCBOOK_XSL $SOURCE $DOCBOOK_XSLTPROCPARAMS', 'saxon-xslt' : '$DOCBOOK_XSLTPROC $DOCBOOK_XSLTPROCFLAGS -o $TARGET $DOCBOOK_XSL $SOURCE $DOCBOOK_XSLTPROCPARAMS', -- cgit v0.12 From 03013f4884c9727cf022fb6299ded8bf6f59e79a Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 17 Apr 2017 21:33:14 -0700 Subject: CHANGES for xsltproc choosing logic changes --- src/CHANGES.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 2b0c3cd..2f46d4f 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -41,6 +41,9 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER From William Deegan: - Removed deprecated tools CVS, Perforce, BitKeeper, RCS, SCCS, Subversion. - Removed deprecated module SCons.Sig + - Added prioritized list of xsltproc tools to docbook. The order will now be as + follows: xsltproc, saxon, saxon-xslt, xalan (with first being highest priority, first + tool found is used) From Daniel Moody: - Fixed msvs.py for Visual Studio generated projects which were -- cgit v0.12 From a72dc1246c42d37e35fc7838c4bc22298a5a3c0a Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 17 Apr 2017 21:43:30 -0700 Subject: more removal of sccs and rcs builder logic --- src/engine/SCons/Node/FS.py | 78 ++-------------------------------------- src/engine/SCons/Node/FSTests.py | 33 ----------------- test/diskcheck.py | 24 ------------- 3 files changed, 2 insertions(+), 133 deletions(-) diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 8f26777..64b2e3f 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -351,33 +351,6 @@ class _Null(object): _null = _Null() -DefaultSCCSBuilder = None -DefaultRCSBuilder = None - -def get_DefaultSCCSBuilder(): - global DefaultSCCSBuilder - if DefaultSCCSBuilder is None: - import SCons.Builder - # "env" will get filled in by Executor.get_build_env() - # calling SCons.Defaults.DefaultEnvironment() when necessary. - act = SCons.Action.Action('$SCCSCOM', '$SCCSCOMSTR') - DefaultSCCSBuilder = SCons.Builder.Builder(action = act, - env = None, - name = "DefaultSCCSBuilder") - return DefaultSCCSBuilder - -def get_DefaultRCSBuilder(): - global DefaultRCSBuilder - if DefaultRCSBuilder is None: - import SCons.Builder - # "env" will get filled in by Executor.get_build_env() - # calling SCons.Defaults.DefaultEnvironment() when necessary. - act = SCons.Action.Action('$RCS_COCOM', '$RCS_COCOMSTR') - DefaultRCSBuilder = SCons.Builder.Builder(action = act, - env = None, - name = "DefaultRCSBuilder") - return DefaultRCSBuilder - # Cygwin's os.path.normcase pretends it's on a case-sensitive filesystem. _is_cygwin = sys.platform == "cygwin" if os.path.normcase("TeSt") == os.path.normpath("TeSt") and not _is_cygwin: @@ -422,46 +395,12 @@ def do_diskcheck_match(node, predicate, errorfmt): def ignore_diskcheck_match(node, predicate, errorfmt): pass -def do_diskcheck_rcs(node, name): - try: - rcs_dir = node.rcs_dir - except AttributeError: - if node.entry_exists_on_disk('RCS'): - rcs_dir = node.Dir('RCS') - else: - rcs_dir = None - node.rcs_dir = rcs_dir - if rcs_dir: - return rcs_dir.entry_exists_on_disk(name+',v') - return None - -def ignore_diskcheck_rcs(node, name): - return None - -def do_diskcheck_sccs(node, name): - try: - sccs_dir = node.sccs_dir - except AttributeError: - if node.entry_exists_on_disk('SCCS'): - sccs_dir = node.Dir('SCCS') - else: - sccs_dir = None - node.sccs_dir = sccs_dir - if sccs_dir: - return sccs_dir.entry_exists_on_disk('s.'+name) - return None -def ignore_diskcheck_sccs(node, name): - return None diskcheck_match = DiskChecker('match', do_diskcheck_match, ignore_diskcheck_match) -diskcheck_rcs = DiskChecker('rcs', do_diskcheck_rcs, ignore_diskcheck_rcs) -diskcheck_sccs = DiskChecker('sccs', do_diskcheck_sccs, ignore_diskcheck_sccs) diskcheckers = [ diskcheck_match, - diskcheck_rcs, - diskcheck_sccs, ] def set_diskcheck(list): @@ -982,8 +921,6 @@ class Entry(Base): 'root', 'dirname', 'on_disk_entries', - 'sccs_dir', - 'rcs_dir', 'released_target_info', 'contentsig'] @@ -1529,8 +1466,6 @@ class Dir(Base): 'root', 'dirname', 'on_disk_entries', - 'sccs_dir', - 'rcs_dir', 'released_target_info', 'contentsig'] @@ -2096,9 +2031,7 @@ class Dir(Base): return node def file_on_disk(self, name): - if self.entry_exists_on_disk(name) or \ - diskcheck_rcs(self, name) or \ - diskcheck_sccs(self, name): + if self.entry_exists_on_disk(name): try: return self.File(name) except TypeError: pass node = self.srcdir_duplicate(name) @@ -2595,8 +2528,6 @@ class File(Base): 'root', 'dirname', 'on_disk_entries', - 'sccs_dir', - 'rcs_dir', 'released_target_info', 'contentsig'] @@ -3037,12 +2968,7 @@ class File(Base): return None scb = self.dir.src_builder() if scb is _null: - if diskcheck_sccs(self.dir, self.name): - scb = get_DefaultSCCSBuilder() - elif diskcheck_rcs(self.dir, self.name): - scb = get_DefaultRCSBuilder() - else: - scb = None + scb = None if scb is not None: try: b = self.builder diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index 7366b7b..306f1a2 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -3269,18 +3269,11 @@ class has_src_builderTestCase(unittest.TestCase): fs = SCons.Node.FS.FS(test.workpath('')) os.chdir(test.workpath('')) test.subdir('sub1') - test.subdir('sub2', ['sub2', 'SCCS'], ['sub2', 'RCS']) sub1 = fs.Dir('sub1', '.') f1 = fs.File('f1', sub1) f2 = fs.File('f2', sub1) f3 = fs.File('f3', sub1) - sub2 = fs.Dir('sub2', '.') - f4 = fs.File('f4', sub2) - f5 = fs.File('f5', sub2) - f6 = fs.File('f6', sub2) - f7 = fs.File('f7', sub2) - f8 = fs.File('f8', sub2) h = f1.has_src_builder() assert not h, h @@ -3305,32 +3298,6 @@ class has_src_builderTestCase(unittest.TestCase): assert h, h assert f3.builder is b1, f3.builder - f7.set_src_builder(b1) - f8.builder_set(b1) - - test.write(['sub2', 'SCCS', 's.f5'], "sub2/SCCS/s.f5\n") - test.write(['sub2', 'RCS', 'f6,v'], "sub2/RCS/f6,v\n") - h = f4.has_src_builder() - assert not h, h - h = f4.has_builder() - assert not h, h - h = f5.has_src_builder() - assert h, h - h = f5.has_builder() - assert h, h - h = f6.has_src_builder() - assert h, h - h = f6.has_builder() - assert h, h - h = f7.has_src_builder() - assert h, h - h = f7.has_builder() - assert h, h - h = f8.has_src_builder() - assert not h, h - h = f8.has_builder() - assert h, h - class prepareTestCase(unittest.TestCase): def runTest(self): """Test the prepare() method""" diff --git a/test/diskcheck.py b/test/diskcheck.py index adbeea1..36cfa4e 100644 --- a/test/diskcheck.py +++ b/test/diskcheck.py @@ -52,30 +52,6 @@ test.must_contain_all_lines(test.stderr(), ["found where file expected"]) -test.write('SConstruct', """ -SetOption('diskcheck', ['rcs', 'sccs']) -Dir('file') -""") - -test.run() - -test.run(arguments='--diskcheck=match', status=2, stderr=None) -test.must_contain_all_lines(test.stderr(), ["found where directory expected"]) - - - -test.write('SConstruct', """ -SetOption('diskcheck', 'rcs,sccs') -Dir('file/subdir') -""") - -test.run() - -test.run(arguments='--diskcheck=match', status=2, stderr=None) -test.must_contain_all_lines(test.stderr(), ["found where directory expected"]) - - - test.pass_test() # Local Variables: -- cgit v0.12 From 05fbc42f3380435f378864b5d7d2b69083d7cd8e Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 18 Apr 2017 10:01:47 -0700 Subject: fix test to not run on OSX --- test/leaky-handles.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/leaky-handles.py b/test/leaky-handles.py index 9502d1b..3787ee2 100644 --- a/test/leaky-handles.py +++ b/test/leaky-handles.py @@ -29,12 +29,13 @@ Verify that file handles aren't leaked to child processes """ import os +import sys import TestSCons test = TestSCons.TestSCons() -if os.name != 'posix': +if os.name != 'posix' or sys.platform == 'darwin': msg = "Skipping fork leak test on non-posix platform '%s'\n" % os.name test.skip_test(msg) -- cgit v0.12 From 764801ecaf19fd73e75a90ba26452dd7c86a5138 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 18 Apr 2017 10:26:34 -0700 Subject: fix test for osx (with macports only at this point) --- test/SWIG/recursive-includes-cpp.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/SWIG/recursive-includes-cpp.py b/test/SWIG/recursive-includes-cpp.py index 364bd73..dbcac6d 100644 --- a/test/SWIG/recursive-includes-cpp.py +++ b/test/SWIG/recursive-includes-cpp.py @@ -64,6 +64,7 @@ test.write("mod.i", """\ test.write('SConstruct', """\ import distutils.sysconfig +import sys DefaultEnvironment( tools = [ 'swig' ] ) @@ -77,6 +78,9 @@ env = Environment( SHLIBPREFIX = "" ) +if sys.platform == 'darwin': + env['LIBS']=['python%d.%d'%(sys.version_info[0],sys.version_info[1])] + env.SharedLibrary( 'mod.so', [ -- cgit v0.12 From 0a59346b5443a5b93fa8ada59519de0ccf95081e Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 18 Apr 2017 10:50:03 -0700 Subject: osx: disable mixedDandC test until a good way to specify correct gcc is found --- test/D/MixedDAndC/sconstest-dmd.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/D/MixedDAndC/sconstest-dmd.py b/test/D/MixedDAndC/sconstest-dmd.py index df66255..d96c5c3 100644 --- a/test/D/MixedDAndC/sconstest-dmd.py +++ b/test/D/MixedDAndC/sconstest-dmd.py @@ -27,6 +27,16 @@ Test compiling and executing a project with a C module. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import sys +if sys.platform == 'darwin': + import TestSCons + test = TestSCons.TestSCons() + + msg = "Skipping Mixed dmd test until a good way to ensure proper gcc is called." + "Calling default(system /usr/bin/gcc) gcc yields a surplus of linking errors\n" + test.skip_test(msg) + + from Common.common import testForTool testForTool('dmd') -- cgit v0.12 From 67cbcb1fabc677b2fcbac4187992d43c51cf3874 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 18 Apr 2017 21:11:17 -0700 Subject: py2/3 - syntax for wrong number of arguments to functions changes for py3, added to valid output --- test/Subst/TypeError.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/Subst/TypeError.py b/test/Subst/TypeError.py index 371ceff..628db2f 100644 --- a/test/Subst/TypeError.py +++ b/test/Subst/TypeError.py @@ -58,9 +58,7 @@ expect = expect_build % (r' \[foo\.bar\]', r'\$\{NONE\[0\]\}') test.run(status=2, stderr=expect) - - -expect_build = r"""scons: \*\*\*%s TypeError `(not enough arguments; expected 3, got 1|func\(\) takes exactly 3 arguments \(1 given\))' trying to evaluate `%s' +expect_build = r"""scons: \*\*\*%s TypeError `(not enough arguments; expected 3, got 1|func\(\) takes exactly 3 arguments \(1 given\)|func\(\) missing 2 required positional arguments: 'b' and 'c')' trying to evaluate `%s' """ expect_read = "\n" + expect_build + TestSCons.file_expr -- cgit v0.12 From aae1dc7ebafa24cc9ac6fef7db00dbc6ec7633a1 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 18 Apr 2017 21:16:46 -0700 Subject: py2/3 no auto stringification for None in py3 --- test/GetBuildFailures/parallel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/GetBuildFailures/parallel.py b/test/GetBuildFailures/parallel.py index ee0e831..f9503e0 100644 --- a/test/GetBuildFailures/parallel.py +++ b/test/GetBuildFailures/parallel.py @@ -80,7 +80,7 @@ Command('f6', 'f6.in', r'@%(_python_)s mypass.py f5 - $TARGET $SOURCE') def print_build_failures(): from SCons.Script import GetBuildFailures - for bf in sorted(GetBuildFailures(), key=lambda t: t.filename): + for bf in sorted(GetBuildFailures(), key=lambda t: t.filename or 'None'): print("%%s failed: %%s" %% (bf.node, bf.errstr)) import atexit -- cgit v0.12 From d13cd11ef106fd6fbdbf007257b1da2dacf71d0e Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 18 Apr 2017 21:17:38 -0700 Subject: py2/3 no auto stringification for None in py3 --- test/GetBuildFailures/option-k.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/GetBuildFailures/option-k.py b/test/GetBuildFailures/option-k.py index 0ff22e6..12ae07b 100644 --- a/test/GetBuildFailures/option-k.py +++ b/test/GetBuildFailures/option-k.py @@ -64,7 +64,7 @@ Command('f6', 'f6.in', r'@%(_python_)s mypass.py f5 - $TARGET $SOURCE') def print_build_failures(): from SCons.Script import GetBuildFailures - for bf in sorted(GetBuildFailures(), key=lambda a: a.filename): + for bf in sorted(GetBuildFailures(), key=lambda a: a.filename or 'None'): print("%%s failed: %%s" %% (bf.node, bf.errstr)) import atexit -- cgit v0.12 From d624a087a4ed7768052f0ab1c614ea6864179dd5 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 18 Apr 2017 21:27:50 -0700 Subject: py2/3 swap to use test.must_match with mode='r' --- test/option--max-drift.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/option--max-drift.py b/test/option--max-drift.py index 08fafd1..4e063c9 100644 --- a/test/option--max-drift.py +++ b/test/option--max-drift.py @@ -109,14 +109,14 @@ atime = os.path.getatime(test.workpath('foo.in')) mtime = os.path.getmtime(test.workpath('foo.in')) test.run() -test.fail_test(test.read('foo.out') != 'foo.in\n') +test.must_match('foo.out', 'foo.in\n', mode='r') test.write('foo.in', 'foo.in delta\n') os.utime(test.workpath('foo.in'), (atime,mtime)) test.run() -test.fail_test(test.read('foo.out') != 'foo.in\n') +test.must_match('foo.out', 'foo.in\n', mode='r') test.pass_test() -- cgit v0.12 From 03eb2e5498807786834933b54703b3b9f127e282 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Wed, 19 Apr 2017 08:42:09 -0700 Subject: py2/3 handle differences between py2 and 3 on reading/writing binary data to stdin/stdout --- test/redirection.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/test/redirection.py b/test/redirection.py index ffc76b5..ba35ed0 100644 --- a/test/redirection.py +++ b/test/redirection.py @@ -32,11 +32,22 @@ test = TestSCons.TestSCons() test.write('cat.py', r""" import sys +PY3K = sys.version_info >= (3, 0) + try: - input = open(sys.argv[1], 'r').read() + input = open(sys.argv[1], 'rb').read() except IndexError: - input = sys.stdin.read() -sys.stdout.write(input) + if PY3K: + source = sys.stdin.buffer + else: + source = sys.stdin + input = source.read() + +if PY3K: + sys.stdout.buffer.write(input) +else: + sys.stdout.write(input) + sys.exit(0) """) -- cgit v0.12 From 6d8d3b89fbcb22ca064a9d24f31f9a0b37e1826d Mon Sep 17 00:00:00 2001 From: William Deegan Date: Wed, 19 Apr 2017 09:02:36 -0700 Subject: py2/3 fix logic for reraising exceptions. A taskmaster test was failing because the passed exception value wasn't an exception and thus couldn't be reraised as is. Added logic to create an exception with the value and raise that --- src/engine/SCons/Taskmaster.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/engine/SCons/Taskmaster.py b/src/engine/SCons/Taskmaster.py index cf924e7..9bd9597 100644 --- a/src/engine/SCons/Taskmaster.py +++ b/src/engine/SCons/Taskmaster.py @@ -546,7 +546,13 @@ class Task(object): if sys.version_info[0] == 2: exec("raise exc_type, exc_value, exc_traceback") else: # sys.version_info[0] == 3: - exec("raise exc_value.with_traceback(exc_traceback)") + if isinstance(exc_value, Exception): #hasattr(exc_value, 'with_traceback'): + # If exc_value is an exception, then just reraise + exec("raise exc_value.with_traceback(exc_traceback)") + else: + # else we'll create an exception using the value and raise that + exec("raise exc_type(exc_value).with_traceback(exc_traceback)") + # raise e.__class__, e.__class__(e), sys.exc_info()[2] # exec("raise exc_type(exc_value).with_traceback(exc_traceback)") -- cgit v0.12 From dd4c5225dd12538a58faa2480548eac87d06a9cd Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 21 Apr 2017 09:27:45 -0700 Subject: Fix bug #2979 Example code for MSVSProject had syntax errors. http://scons.tigris.org/issues/show_bug.cgi?id=2979 --- src/CHANGES.txt | 1 + src/engine/SCons/Tool/msvs.xml | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 2f46d4f..0bcf92e 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -44,6 +44,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Added prioritized list of xsltproc tools to docbook. The order will now be as follows: xsltproc, saxon, saxon-xslt, xalan (with first being highest priority, first tool found is used) + - Fixed MSVSProject example code (http://scons.tigris.org/issues/show_bug.cgi?id=2979) From Daniel Moody: - Fixed msvs.py for Visual Studio generated projects which were diff --git a/src/engine/SCons/Tool/msvs.xml b/src/engine/SCons/Tool/msvs.xml index e85b27c..b367e84 100644 --- a/src/engine/SCons/Tool/msvs.xml +++ b/src/engine/SCons/Tool/msvs.xml @@ -127,8 +127,10 @@ compilation error messages displayed in the Visual Studio console output window. This can be remedied by adding the Visual C/C++ /FC compiler option to the &cv-link-CCFLAGS; variable so that the compiler will print the full path name of any files that cause compilation errors. - Example usage: barsrcs = ['bar.cpp'], -barincs = ['bar.h'], + Example usage: + +barsrcs = ['bar.cpp'] +barincs = ['bar.h'] barlocalincs = ['StdAfx.h'] barresources = ['bar.rc','resource.h'] barmisc = ['bar_readme.txt'] -- cgit v0.12 From f67ce4d87c9531675c2e26715e005234fda4386c Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 21 Apr 2017 09:33:08 -0700 Subject: Part 2 of fix for bug # 2979. Fix target to be the .dll target node output from env.SharedLibrary() --- src/engine/SCons/Tool/msvs.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/SCons/Tool/msvs.xml b/src/engine/SCons/Tool/msvs.xml index b367e84..c4701e1 100644 --- a/src/engine/SCons/Tool/msvs.xml +++ b/src/engine/SCons/Tool/msvs.xml @@ -137,14 +137,14 @@ barmisc = ['bar_readme.txt'] dll = env.SharedLibrary(target = 'bar.dll', source = barsrcs) - +buildtarget = [s for s in dll if str(s).endswith('dll')] env.MSVSProject(target = 'Bar' + env['MSVSPROJECTSUFFIX'], srcs = barsrcs, incs = barincs, localincs = barlocalincs, resources = barresources, misc = barmisc, - buildtarget = dll, + buildtarget = buildtarget, variant = 'Release') Starting with version 2.4 of -- cgit v0.12 From d9cc4fd395a610f3eaaee77ae81eb98d2792e3fa Mon Sep 17 00:00:00 2001 From: Jane Doe Date: Fri, 21 Apr 2017 16:31:02 -0700 Subject: kick buildbot --- SConstruct | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SConstruct b/SConstruct index 57f2fc1..d871eda 100644 --- a/SConstruct +++ b/SConstruct @@ -1406,3 +1406,5 @@ for pf, help_text in packaging_flavors: os.path.join(build_dir, 'runtest.py'), ]) + +# test -- cgit v0.12 From bb04d9ccdacdc5f4d7e35d096889dfc23748631e Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Sun, 23 Apr 2017 15:26:25 -0400 Subject: Test is failing on Windows 7 and Linux when PRESERVE is used. dirlist is saved as unicode, so printing it must also be unicode. Tested with py2 and py3. --- QMTest/TestCmd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index 3b745f8..20f1f14 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -987,7 +987,7 @@ class TestCmd(object): condition = self.condition if self._preserve[condition]: for dir in self._dirlist: - print("Preserved directory " + dir + "\n") + print(u"Preserved directory " + dir + "\n") else: list = self._dirlist[:] list.reverse() -- cgit v0.12 From 26ed93ab719b54ec8fcf1bf31c307d3a34c0e403 Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Sun, 23 Apr 2017 15:32:01 -0400 Subject: Updates CHANGES.txt with changes. --- src/CHANGES.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 0bcf92e..5ec4cd5 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -13,6 +13,10 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER RELEASE VERSION/DATE TO BE FILLED IN LATER + From Daniel Moody: + - Updated the src/engine/SCons/SConfTest.py so when using the + preserve option, it will be able to print unicode directories. + From Gaurav Juvekar: - Fix issue #2910: Make --tree=all handle Unicode. (PR #427) - Fix issue #2788: Fix typo in documentation example for sconf. (PR #388) -- cgit v0.12 From 151cbcd4868c42fc8fc102ca17110f424208cdf1 Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Sun, 23 Apr 2017 16:00:43 -0400 Subject: This test is not account for PRESERVE being set. When preserve is set the rm command does not happen, so this output will fail. Tested py2 and py3. --- test/scons-time/run/option/verbose.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/scons-time/run/option/verbose.py b/test/scons-time/run/option/verbose.py index 5fc6d64..0ef2a6c 100644 --- a/test/scons-time/run/option/verbose.py +++ b/test/scons-time/run/option/verbose.py @@ -30,7 +30,7 @@ Verify that the run -v and --verbose options display command output. import sys import re - +import os import TestSCons_time _python_ = re.escape('"' + sys.executable + '"') @@ -112,7 +112,9 @@ scons-time%(time_re)s: %(_python_)s %(scons_py)s %(scons_flags)s --profile=%(pro SCONS_LIB_DIR = %(src_engine)s SConstruct file directory: %(tmp_scons_time_foo)s scons-time%(time_re)s: cd .* -scons-time%(time_re)s: rm -rf %(tmp_scons_time)s +""" +if 'PRESERVE' not in os.environ or not os.environ['PRESERVE']: + expect += """scons-time%(time_re)s: rm -rf %(tmp_scons_time)s """ foo_tar_gz = re.escape(foo_tar_gz) -- cgit v0.12 From f8899e92a97177e794aecadcd1f7fcce88b547d0 Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Sun, 23 Apr 2017 16:02:57 -0400 Subject: Updated CHANGES.txt with some more info because it was related, adn should be in the same pull request. --- src/CHANGES.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 5ec4cd5..766c7d0 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -16,6 +16,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER From Daniel Moody: - Updated the src/engine/SCons/SConfTest.py so when using the preserve option, it will be able to print unicode directories. + - Also updated a few test that were not taking into account PRESERVE From Gaurav Juvekar: - Fix issue #2910: Make --tree=all handle Unicode. (PR #427) -- cgit v0.12 From 0c775f3836a7d9a20956004834c8576defbf532f Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Sun, 23 Apr 2017 16:07:43 -0400 Subject: updated CHANGES.txt so it was more clear --- src/CHANGES.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 766c7d0..9e6151a 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -14,9 +14,10 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER RELEASE VERSION/DATE TO BE FILLED IN LATER From Daniel Moody: - - Updated the src/engine/SCons/SConfTest.py so when using the + - Updated the QMTest/TestCmd.py so when using the preserve option, it will be able to print unicode directories. - - Also updated a few test that were not taking into account PRESERVE + - Also updated test/scons-time/run/option/verbose.py that was + not taking into account the output when PRESERVE was enabled From Gaurav Juvekar: - Fix issue #2910: Make --tree=all handle Unicode. (PR #427) -- cgit v0.12 From 8bf16ddea63ef3405bf00ba1fb26da0cd60b7b08 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 23 Apr 2017 17:01:16 -0700 Subject: py2/3 Allow SConfTests.py to function when pywin32 is not installed. --- src/engine/SCons/SConfTests.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/engine/SCons/SConfTests.py b/src/engine/SCons/SConfTests.py index 0daf31c..f4c6f89 100644 --- a/src/engine/SCons/SConfTests.py +++ b/src/engine/SCons/SConfTests.py @@ -102,8 +102,11 @@ class SConfTestCase(unittest.TestCase): import SCons.Platform.win32 - file = SCons.Platform.win32._builtin_file - open = SCons.Platform.win32._builtin_open + try: + file = SCons.Platform.win32._builtin_file + open = SCons.Platform.win32._builtin_open + except AttributeError: + pass def _baseTryXXX(self, TryFunc): # TryCompile and TryLink are much the same, so we can test them -- cgit v0.12 From c03e43ea38fc2fe24fc40bbf4b45d4d19997c22d Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 23 Apr 2017 20:01:44 -0700 Subject: test --- SConstruct | 1 - 1 file changed, 1 deletion(-) diff --git a/SConstruct b/SConstruct index d871eda..bd43f19 100644 --- a/SConstruct +++ b/SConstruct @@ -1407,4 +1407,3 @@ for pf, help_text in packaging_flavors: ]) -# test -- cgit v0.12