diff options
author | William Deegan <bill@baddogconsulting.com> | 2020-02-21 02:58:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-21 02:58:57 (GMT) |
commit | 431a6523f9895c2bad2c0ad315c8bc77c0a96bbb (patch) | |
tree | 8ff45f6557761716a2ebb3d648479453dcf80a26 | |
parent | c2df72aa0dbfa5f62ba3753e6824fa663604307c (diff) | |
parent | 962736590a7367450460a594ef2cd3f594fe72ec (diff) | |
download | SCons-431a6523f9895c2bad2c0ad315c8bc77c0a96bbb.zip SCons-431a6523f9895c2bad2c0ad315c8bc77c0a96bbb.tar.gz SCons-431a6523f9895c2bad2c0ad315c8bc77c0a96bbb.tar.bz2 |
Merge branch 'master' into substfilesuffix
129 files changed, 831 insertions, 1057 deletions
@@ -3,8 +3,6 @@ # # See the README.rst file for an overview of how SCons is built and tested. -from __future__ import print_function - copyright_years = '2001 - 2019' # This gets inserted into the man pages to reflect the month of release. diff --git a/bin/calibrate.py b/bin/calibrate.py index be06a54..d18cfcd 100644 --- a/bin/calibrate.py +++ b/bin/calibrate.py @@ -20,8 +20,6 @@ # 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 import re @@ -31,6 +29,7 @@ import sys variable_re = re.compile(r'^VARIABLE: (.*)$', re.M) elapsed_re = re.compile(r'^ELAPSED: (.*)$', re.M) + def main(argv=None): if argv is None: argv = sys.argv @@ -84,5 +83,6 @@ def main(argv=None): return 0 + if __name__ == "__main__": sys.exit(main()) diff --git a/bin/import-test.py b/bin/import-test.py index 65b6e79..6a71a37 100644 --- a/bin/import-test.py +++ b/bin/import-test.py @@ -82,7 +82,7 @@ def print_files(dir): for dirpath, dirnames, filenames in os.walk(directory): dir = lookup(dirpath) - for f in fnames: + for f in filenames: dir.entries[f] = None subdir_list = [] diff --git a/bin/install_scons.py b/bin/install_scons.py index ac79fd3..ed919f8 100644 --- a/bin/install_scons.py +++ b/bin/install_scons.py @@ -25,7 +25,7 @@ import os import shutil import sys import tarfile -from urllib import urlretrieve +from urllib.request import urlretrieve from Command import CommandRunner, Usage diff --git a/bootstrap.py b/bootstrap.py index 4ade361..d47c966 100755 --- a/bootstrap.py +++ b/bootstrap.py @@ -20,18 +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 - -import os -import os.path -import sys -import glob -import subprocess -import filecmp -import shutil -__doc__ = """bootstrap.py +"""bootstrap.py Execute SCons from this source tree. It copies Python scripts and modules from src/ subdirectory into a subdirectory named "bootstrap/" (by default), @@ -75,6 +65,14 @@ the following SCons options: "eaten" by the bootstrap.py script. """ +import os +import os.path +import sys +import glob +import subprocess +import filecmp +import shutil + def parseManifestLines(basedir, manifest): """ Scans a MANIFEST file, and returns the list of source files. diff --git a/doc/SConscript b/doc/SConscript index ff29a70..8f6d1cd 100644 --- a/doc/SConscript +++ b/doc/SConscript @@ -24,8 +24,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 - import os.path import re import sys @@ -90,7 +88,8 @@ def writeVersionXml(verfile, date, ver, rev): os.makedirs(dir) except OSError: pass # okay if the directory already exists - open(verfile, "w").write("""<!-- + with open(verfile, "w") as vf: + vf.write("""<!-- THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. --> <!ENTITY builddate "%s"> @@ -105,7 +104,7 @@ man_page_list = ['scons.1','scons-time.1','sconsign.1'] # Template for the MAN page texts when we can't properly # create them because the skip_doc flag is set (required # modules/tools aren't installed in the current system) -man_replace_tpl = """.TH "%(uctitle)s" "1" "%(today)s" "SCons %(version)s" "SCons %(version)s" +man_replace_tpl = r""".TH "%(uctitle)s" "1" "%(today)s" "SCons %(version)s" "SCons %(version)s" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .nh diff --git a/doc/user/parseflags.xml b/doc/user/parseflags.xml index 836b7f2..35c336e 100644 --- a/doc/user/parseflags.xml +++ b/doc/user/parseflags.xml @@ -80,14 +80,13 @@ <scons_example name="parseflags_ex1"> <file name="SConstruct" printme="1"> -from __future__ import print_function env = Environment() d = env.ParseFlags("-I/opt/include -L/opt/lib -lfoo") -for k,v in sorted(d.items()): +for k, v in sorted(d.items()): if v: print(k, v) env.MergeFlags(d) -env.Program('f1.c') +env.Program("f1.c") </file> <file name="f1.c"> int main() { return 0; } @@ -120,14 +119,13 @@ int main() { return 0; } <scons_example name="parseflags_ex2"> <file name="SConstruct" printme="1"> -from __future__ import print_function env = Environment() d = env.ParseFlags("-whatever") -for k,v in sorted(d.items()): +for k, v in sorted(d.items()): if v: print(k, v) env.MergeFlags(d) -env.Program('f1.c') +env.Program("f1.c") </file> <file name="f1.c"> int main() { return 0; } @@ -147,14 +145,13 @@ env.Program('f1.c') <scons_example name="parseflags_ex3"> <file name="SConstruct" printme="1"> -from __future__ import print_function env = Environment() d = env.ParseFlags(["-I/opt/include", ["-L/opt/lib", "-lfoo"]]) -for k,v in sorted(d.items()): +for k, v in sorted(d.items()): if v: print(k, v) env.MergeFlags(d) -env.Program('f1.c') +env.Program("f1.c") </file> <file name="f1.c"> int main() { return 0; } @@ -175,14 +172,13 @@ int main() { return 0; } <scons_example name="parseflags_ex4"> <file name="SConstruct" printme="1"> -from __future__ import print_function env = Environment() d = env.ParseFlags(["!echo -I/opt/include", "!echo -L/opt/lib", "-lfoo"]) -for k,v in sorted(d.items()): +for k, v in sorted(d.items()): if v: print(k, v) env.MergeFlags(d) -env.Program('f1.c') +env.Program("f1.c") </file> <file name="f1.c"> int main() { return 0; } @@ -69,8 +69,6 @@ Environment Variables: TESTCMD_VERBOSE: turn on verbosity in TestCommand\ """ -from __future__ import print_function - import getopt import glob import os @@ -662,7 +660,7 @@ else: # sys.stderr.write("to:%s\n"%tp) for path in glob.glob(tp): if os.path.isdir(path): - if path.startswith('src'): + if path.startswith('src') or path.startswith('testing'): for p in find_Tests_py(path): unittests.append(p) elif path.startswith('test'): diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 4638bd6..574f64b 100755 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -21,11 +21,17 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Fix Github Issue #3550 - When using Substfile() with a value like Z:\mongo\build\install\bin the implementation using re.sub() would end up interpreting the string and finding regex escape characters where it should have been simply replacing existing text. Switched to use string.replace(). + - Fix Github Issue #2904 - Provide useful error message when more than one Configure Contexts are opened. + Only one open is allowed. You must call conf.Finish() to complete the currently open one before creating another From Jeremy Elson: - Updated design doc to use the correct syntax for Depends() From Adam Gross: + - Added support for scanning multiple entries in an action string if + IMPLICIT_COMMAND_DEPENDENCIES is set to 2. This opts into more thorough + action scanning where every string in the command is scanned to determine + if it is a non-source and non-target path. - Added support for taking instances of the Value class as implicit dependencies. - Added new module SCons.Scanner.Python to allow scanning .py files. @@ -68,7 +74,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Add an alternate warning message cl.exe is not found and msvc config cache is in use (SCONS_CACHE_MSVC_CONFIG was given) - config cache may be out of date. - - Fix typo TEXTFILESUFFIX -> SUBSTFILESUFFIX (bug #3540) + - Fixed bug where changing TEXTFILESUFFIX would cause Substfile() to rebuild. (Github Issue #3540) + - Script/Main.py now uses importlib instead of imp module. RELEASE 3.1.2 - Mon, 17 Dec 2019 02:06:27 +0000 diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index c6fc575..8a8cf27 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -628,17 +628,9 @@ class _ActionAction(ActionBase): """ 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. + This code assumes s is a regular string. """ - try: - sys.stdout.write(s + u"\n") - except UnicodeDecodeError: - sys.stdout.write(s + "\n") + sys.stdout.write(s + "\n") def __call__(self, target, source, env, exitstatfunc=_null, @@ -677,7 +669,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: @@ -976,11 +968,33 @@ class CommandAction(_ActionAction): return env.subst_target_source(cmd, SUBST_SIG, target, source) def get_implicit_deps(self, target, source, env, executor=None): + """Return the implicit dependencies of this action's command line.""" icd = env.get('IMPLICIT_COMMAND_DEPENDENCIES', True) if is_String(icd) and icd[:1] == '$': icd = env.subst(icd) + if not icd or icd in ('0', 'None'): return [] + + try: + icd_int = int(icd) + except ValueError: + icd_int = None + + if (icd_int and icd_int > 1) or icd == 'all': + # An integer value greater than 1 specifies the number of entries + # to scan. "all" means to scan all. + return self._get_implicit_deps_heavyweight(target, source, env, executor, icd_int) + else: + # Everything else (usually 1 or True) means that we want + # lightweight dependency scanning. + return self._get_implicit_deps_lightweight(target, source, env, executor) + + def _get_implicit_deps_lightweight(self, target, source, env, executor): + """ + Lightweight dependency scanning involves only scanning the first entry + in an action string, even if it contains &&. + """ from SCons.Subst import SUBST_SIG if executor: cmd_list = env.subst_list(self.cmd_list, SUBST_SIG, executor=executor) @@ -998,6 +1012,65 @@ class CommandAction(_ActionAction): res.append(env.fs.File(d)) return res + def _get_implicit_deps_heavyweight(self, target, source, env, executor, + icd_int): + """ + Heavyweight dependency scanning involves scanning more than just the + first entry in an action string. The exact behavior depends on the + value of icd_int. Only files are taken as implicit dependencies; + directories are ignored. + + If icd_int is an integer value, it specifies the number of entries to + scan for implicit dependencies. Action strings are also scanned after + a &&. So for example, if icd_int=2 and the action string is + "cd <some_dir> && $PYTHON $SCRIPT_PATH <another_path>", the implicit + dependencies would be the path to the python binary and the path to the + script. + + If icd_int is None, all entries are scanned for implicit dependencies. + """ + + # Avoid circular and duplicate dependencies by not providing source, + # target, or executor to subst_list. This causes references to + # $SOURCES, $TARGETS, and all related variables to disappear. + from SCons.Subst import SUBST_SIG + cmd_list = env.subst_list(self.cmd_list, SUBST_SIG, conv=lambda x: x) + res = [] + + for cmd_line in cmd_list: + if cmd_line: + entry_count = 0 + for entry in cmd_line: + d = str(entry) + if ((icd_int is None or entry_count < icd_int) and + not d.startswith(('&', '-', '/') if os.name == 'nt' + else ('&', '-'))): + m = strip_quotes.match(d) + if m: + d = m.group(1) + + if d: + # Resolve the first entry in the command string using + # PATH, which env.WhereIs() looks in. + # For now, only match files, not directories. + p = os.path.abspath(d) if os.path.isfile(d) else None + if not p and entry_count == 0: + p = env.WhereIs(d) + + if p: + res.append(env.fs.File(p)) + + entry_count = entry_count + 1 + else: + entry_count = 0 if d == '&&' else entry_count + 1 + + # Despite not providing source and target to env.subst() above, we + # can still end up with sources in this list. For example, files in + # LIBS will still resolve in env.subst(). This won't result in + # circular dependencies, but it causes problems with cache signatures + # changing between full and incremental builds. + return [r for r in res if r not in target and r not in source] + class CommandGeneratorAction(ActionBase): """Class for command-generator actions.""" diff --git a/src/engine/SCons/Action.xml b/src/engine/SCons/Action.xml index 7a8194e..d85af3b 100644 --- a/src/engine/SCons/Action.xml +++ b/src/engine/SCons/Action.xml @@ -58,6 +58,45 @@ not be added to the targets built with that construction environment. </para> +<para> +If the construction variable +&cv-IMPLICIT_COMMAND_DEPENDENCIES; +is set to <literal>2</literal> or higher, +then that number of entries in the command +string will be scanned for relative or absolute +paths. The count will reset after any +<literal>&&</literal> entries are found. +The first command in the action string and +the first after any <literal>&&</literal> +entries will be found by searching the +<varname>PATH</varname> variable in the +<varname>ENV</varname> environment used to +execute the command. All other commands will +only be found if they are absolute paths or +valid paths relative to the working directory. +</para> + +<para> +If the construction variable +&cv-IMPLICIT_COMMAND_DEPENDENCIES; +is set to <literal>all</literal>, then +all entries in all command strings will be +scanned for relative or absolute paths. If +any are present, they will be added as +implicit dependencies to the targets built +with that construction environment. +not be added to the targets built with that +construction environment. The first command +in the action string and the first after any +<literal>&&</literal> entries will be found +by searching the <varname>PATH</varname> +variable in the <varname>ENV</varname> +environment used to execute the command. +All other commands will only be found if they +are absolute paths or valid paths relative +to the working directory. +</para> + <example_commands> env = Environment(IMPLICIT_COMMAND_DEPENDENCIES = 0) </example_commands> diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py index 3303750..4784abf 100644 --- a/src/engine/SCons/ActionTests.py +++ b/src/engine/SCons/ActionTests.py @@ -37,10 +37,8 @@ class GlobalActFunc(object): pass -import collections import io import os -import re import sys import types import unittest @@ -339,14 +337,6 @@ class ActionTestCase(unittest.TestCase): # a singleton list returns the contained action test_positional_args(cmd_action, ["string"]) - try: - unicode - except NameError: - pass - else: - a2 = eval("SCons.Action.Action(u'string')") - assert isinstance(a2, SCons.Action.CommandAction), a2 - def line_action(a): assert isinstance(a, SCons.Action.CommandAction), a assert a.cmd_list == ["explicit", "command", "line"], a.cmd_list diff --git a/src/engine/SCons/Builder.py b/src/engine/SCons/Builder.py index 13949e5..3f0be63 100644 --- a/src/engine/SCons/Builder.py +++ b/src/engine/SCons/Builder.py @@ -100,7 +100,7 @@ There are the following methods for internal use within this module: __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import collections +from collections import UserDict, UserList import SCons.Action import SCons.Debug @@ -197,7 +197,7 @@ class DictEmitter(SCons.Util.Selector): target, source = emitter(target, source, env) return (target, source) -class ListEmitter(collections.UserList): +class ListEmitter(UserList): """A callable list of emitters that calls each in sequence, returning the result. """ @@ -215,7 +215,7 @@ misleading_keywords = { 'sources' : 'source', } -class OverrideWarner(collections.UserDict): +class OverrideWarner(UserDict): """A class for warning about keyword arguments that we use as overrides in a Builder call. @@ -224,7 +224,7 @@ class OverrideWarner(collections.UserDict): warnings once, no matter how many Builders are invoked. """ def __init__(self, dict): - collections.UserDict.__init__(self, dict) + UserDict.__init__(self, dict) if SCons.Debug.track_instances: logInstanceCreation(self, 'Builder.OverrideWarner') self.already_warned = None def warn(self): diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py index b4286fd..d509219 100644 --- a/src/engine/SCons/BuilderTests.py +++ b/src/engine/SCons/BuilderTests.py @@ -20,8 +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 __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.compat @@ -33,7 +31,7 @@ import SCons.compat def Func(): pass -import collections +from collections import UserList import io import os.path import re @@ -256,7 +254,7 @@ class BuilderTestCase(unittest.TestCase): assert not hasattr(n2, 'env') l = [1] - ul = collections.UserList([2]) + ul = UserList([2]) try: l.extend(ul) except TypeError: @@ -308,22 +306,6 @@ class BuilderTestCase(unittest.TestCase): #be = target.get_build_env() #assert be['VAR'] == 'foo', be['VAR'] - try: unicode - except NameError: - uni = str - else: - uni = unicode - - target = builder(env, target = uni('n12 n13'), - source = [uni('n14 n15')])[0] - assert target.name == uni('n12 n13') - assert target.sources[0].name == uni('n14 n15') - - target = builder(env, target = [uni('n16 n17')], - source = uni('n18 n19'))[0] - assert target.name == uni('n16 n17') - assert target.sources[0].name == uni('n18 n19') - n20 = MyNode_without_target_from_source('n20') flag = 0 try: diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py index a69d8b0..2bac41e 100644 --- a/src/engine/SCons/Defaults.py +++ b/src/engine/SCons/Defaults.py @@ -31,8 +31,6 @@ 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__" diff --git a/src/engine/SCons/DefaultsTests.py b/src/engine/SCons/DefaultsTests.py index 2cbad70..34941bc 100644 --- a/src/engine/SCons/DefaultsTests.py +++ b/src/engine/SCons/DefaultsTests.py @@ -29,8 +29,6 @@ import os import sys import unittest -from collections import UserDict - import TestCmd import SCons.Errors diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index 5e76e35..00379e1 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -584,7 +584,7 @@ class SubstitutionEnvironment(object): out,err = p.communicate() status = p.wait() if err: - sys.stderr.write(u"" + err) + sys.stderr.write("" + err) if status: raise OSError("'%s' exited %d" % (command, status)) return out diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index 01baba3..a9ec674 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -20,9 +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 __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.compat @@ -265,11 +262,6 @@ class SubstitutionTestCase(unittest.TestCase): assert isinstance(nodes[0], X) assert nodes[0].name == "Util.py UtilTests.py", nodes[0].name - 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[0].name - nodes = env.arg2nodes(["Util.py", "UtilTests.py"], Factory) assert len(nodes) == 2, nodes assert isinstance(nodes[0], X) diff --git a/src/engine/SCons/Executor.py b/src/engine/SCons/Executor.py index 28bb6ad..fb2224f 100644 --- a/src/engine/SCons/Executor.py +++ b/src/engine/SCons/Executor.py @@ -26,8 +26,6 @@ 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__" import collections diff --git a/src/engine/SCons/JobTests.py b/src/engine/SCons/JobTests.py index 2e3af4f..9c9bb41 100644 --- a/src/engine/SCons/JobTests.py +++ b/src/engine/SCons/JobTests.py @@ -42,8 +42,8 @@ def get_cpu_nums(): ncpus = os.sysconf( "SC_NPROCESSORS_ONLN" ) if isinstance(ncpus, int) and ncpus > 0: return ncpus - else: # OSX: - return int( os.popen2( "sysctl -n hw.ncpu")[1].read() ) + else: # OSX: + return int(os.popen2("sysctl -n hw.ncpu")[1].read() ) # Windows: if "NUMBER_OF_PROCESSORS" in os.environ: ncpus = int(os.environ["NUMBER_OF_PROCESSORS"]) diff --git a/src/engine/SCons/Memoize.py b/src/engine/SCons/Memoize.py index 5bdcf42..0595fdf 100644 --- a/src/engine/SCons/Memoize.py +++ b/src/engine/SCons/Memoize.py @@ -20,8 +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 __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" __doc__ = """Memoizer diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 6f16256..bb965db 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -31,8 +31,6 @@ 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__" import fnmatch @@ -44,6 +42,7 @@ import sys import time import codecs from itertools import chain +import importlib.util import SCons.Action import SCons.Debug @@ -1427,22 +1426,10 @@ class FS(LocalFS): This can be useful when we want to determine a toolpath based on a python module name""" dirpath = '' - if sys.version_info[0] < 3 or (sys.version_info[0] == 3 and sys.version_info[1] in (0,1,2,3,4)): - # Python2 Code - import imp - splitname = modulename.split('.') - srchpths = sys.path - for item in splitname: - file, path, desc = imp.find_module(item, srchpths) - if file is not None: - path = os.path.dirname(path) - srchpths = [path] - dirpath = path - else: - # Python3 Code - import importlib.util - modspec = importlib.util.find_spec(modulename) - dirpath = os.path.dirname(modspec.origin) + + # Python3 Code + modspec = importlib.util.find_spec(modulename) + dirpath = os.path.dirname(modspec.origin) return self._lookup(dirpath, None, Dir, True) @@ -1549,9 +1536,7 @@ class Dir(Base): self.repositories = [] self.srcdir = None - self.entries = {} - self.entries['.'] = self - self.entries['..'] = self.dir + self.entries = {'.': self, '..': self.dir} self.cwd = self self.searched = 0 self._sconsign = None @@ -2306,10 +2291,8 @@ class RootDir(Dir): self._morph() self.duplicate = 0 - self._lookupDict = {} + self._lookupDict = {'': self, '/': self} - self._lookupDict[''] = self - self._lookupDict['/'] = self self.root = self # The // entry is necessary because os.path.normpath() # preserves double slashes at the beginning of a path on Posix @@ -2329,9 +2312,7 @@ class RootDir(Dir): self.repositories = [] self.srcdir = None - self.entries = {} - self.entries['.'] = self - self.entries['..'] = self.dir + self.entries = {'.': self, '..': self.dir} self.cwd = self self.searched = 0 self._sconsign = None @@ -3746,7 +3727,7 @@ class FileFinder(object): if verbose and not callable(verbose): 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 bbfdd1b..3f2cb0e 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -20,8 +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 __future__ import division, print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.compat @@ -465,10 +463,7 @@ class VariantDirTestCase(unittest.TestCase): def __init__(self, duplicate, link, symlink, copy): self.duplicate = duplicate - self.have = {} - self.have['hard'] = link - self.have['soft'] = symlink - self.have['copy'] = copy + self.have = {'hard': link, 'soft': symlink, 'copy': copy} self.links_to_be_called = [] for link in self.duplicate.split('-'): @@ -1347,11 +1342,10 @@ class FSTestCase(_tempdirTestCase): 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" + 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"'), \ - f1.get_text_contents() + f1.get_text_contents() == "Foo\x1aBar", f1.get_text_contents() # Check for string which doesn't have BOM and isn't valid # ASCII @@ -1449,7 +1443,7 @@ class FSTestCase(_tempdirTestCase): c = e.get_text_contents() try: - eval('assert c == u"", c') + eval('assert c == "", c') except SyntaxError: assert c == "" @@ -1460,10 +1454,7 @@ class FSTestCase(_tempdirTestCase): assert e.__class__ == SCons.Node.FS.Entry, e.__class__ assert c == "", c c = e.get_text_contents() - try: - eval('assert c == u"", c') - except SyntaxError: - assert c == "", c + assert c == "", c test.write("tstamp", "tstamp\n") try: @@ -3316,15 +3307,7 @@ class RepositoryTestCase(_tempdirTestCase): # Use a test string that has a file terminator in it to make # sure we read the entire file, regardless of its contents. - try: - eval('test_string = u"Con\x1aTents\n"') - except SyntaxError: - import collections - class FakeUnicodeString(collections.UserString): - def encode(self, encoding): - return str(self) - - test_string = FakeUnicodeString("Con\x1aTents\n") + test_string = "Con\x1aTents\n" # Test with ASCII. test.write(["rep3", "contents"], test_string.encode('ascii')) diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 0b58282..c3565bf 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -19,8 +19,6 @@ be able to depend on any other type of "thing." """ -from __future__ import print_function - # # __COPYRIGHT__ # diff --git a/src/engine/SCons/Platform/__init__.py b/src/engine/SCons/Platform/__init__.py index 5e9a358..21e63b4 100644 --- a/src/engine/SCons/Platform/__init__.py +++ b/src/engine/SCons/Platform/__init__.py @@ -41,8 +41,6 @@ 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__" import SCons.compat diff --git a/src/engine/SCons/Platform/win32.py b/src/engine/SCons/Platform/win32.py index bb1b46d..afe2df9 100644 --- a/src/engine/SCons/Platform/win32.py +++ b/src/engine/SCons/Platform/win32.py @@ -62,46 +62,6 @@ except AttributeError: else: parallel_msg = None - if sys.version_info.major == 2: - import __builtin__ - - _builtin_file = __builtin__.file - _builtin_open = __builtin__.open - - def _scons_fixup_mode(mode): - """Adjust 'mode' to mark handle as non-inheritable. - - SCons is multithreaded, so allowing handles to be inherited by - children opens us up to races, where (e.g.) processes spawned by - the Taskmaster may inherit and retain references to files opened - by other threads. This may lead to sharing violations and, - ultimately, build failures. - - By including 'N' as part of fopen's 'mode' parameter, all file - handles returned from these functions are atomically marked as - non-inheritable. - """ - if not mode: - # Python's default is 'r'. - # https://docs.python.org/2/library/functions.html#open - mode = 'rN' - elif 'N' not in mode: - mode += 'N' - return mode - - class _scons_file(_builtin_file): - def __init__(self, name, mode=None, *args, **kwargs): - _builtin_file.__init__(self, name, _scons_fixup_mode(mode), - *args, **kwargs) - - def _scons_open(name, mode=None, *args, **kwargs): - return _builtin_open(name, _scons_fixup_mode(mode), - *args, **kwargs) - - __builtin__.file = _scons_file - __builtin__.open = _scons_open - - if False: # Now swap out shutil.filecopy and filecopy2 for win32 api native CopyFile @@ -307,9 +267,6 @@ def get_system_root(): except: pass - # Ensure system root is a string and not unicode - # (This only matters for py27 were unicode in env passed to POpen fails) - val = str(val) _system_root = val return val diff --git a/src/engine/SCons/SConf.py b/src/engine/SCons/SConf.py index 50a1329..e0e492b 100644 --- a/src/engine/SCons/SConf.py +++ b/src/engine/SCons/SConf.py @@ -33,8 +33,6 @@ libraries are installed, if some command line options are supported etc. # 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 SCons.compat @@ -430,7 +428,8 @@ class SConfBase(object): SConfFS = SCons.Node.FS.default_fs or \ SCons.Node.FS.FS(env.fs.pathTop) if sconf_global is not None: - raise SCons.Errors.UserError + raise SCons.Errors.UserError("""Configure() called while another Configure() exists. + Please call .Finish() before creating and second Configure() context""") if log_file is not None: log_file = SConfFS.File(env.subst(log_file)) diff --git a/src/engine/SCons/SConfTests.py b/src/engine/SCons/SConfTests.py index 40cd69d..e2b9133 100644 --- a/src/engine/SCons/SConfTests.py +++ b/src/engine/SCons/SConfTests.py @@ -56,18 +56,6 @@ class SConfTestCase(unittest.TestCase): os.chdir(self.save_cwd) def _resetSConfState(self): - if sys.platform in ['cygwin', 'win32'] and sys.version_info.major == 2: - # On Windows with Python2, SCons.Platform.win32 redefines the - # built-in file() and open() functions to disable handle - # inheritance. Because we are unloading all SCons modules other - # than SCons.Compat, SCons.Platform.win32 will lose the variables - # it needs. As a result, we should reset the file() and open() - # functions to their original built-in versions. - import __builtin__ - import SCons.Platform.win32 - __builtin__.file = SCons.Platform.win32._builtin_file - __builtin__.open = SCons.Platform.win32._builtin_open - # Ok, this is tricky, and i do not know, if everything is sane. # We try to reset scons' state (including all global variables) import SCons.SConsign @@ -307,10 +295,6 @@ int main(void) { return None def actionFAIL(target, source, env): return 1 - def actionUnicode(target, source, env): - with open(str(target[0]), "wb") as f: - f.write('2\302\242\n') - return None self._resetSConfState() @@ -319,14 +303,10 @@ int main(void) { log_file=self.test.workpath('config.log')) try: (ret, output) = sconf.TryAction(action=actionOK) - assert ret and output.encode('utf-8') == 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) - if not TestCmd.IS_PY3: - # GH Issue #3141 - unicode text and py2.7 crashes. - (ret, output) = sconf.TryAction(action=actionUnicode) - assert ret and output == u'2\xa2\n', (ret, output) finally: sconf.Finish() diff --git a/src/engine/SCons/SConsign.py b/src/engine/SCons/SConsign.py index 1115f2a..a516e1f 100644 --- a/src/engine/SCons/SConsign.py +++ b/src/engine/SCons/SConsign.py @@ -26,9 +26,6 @@ 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__" import SCons.compat diff --git a/src/engine/SCons/Scanner/ProgTests.py b/src/engine/SCons/Scanner/ProgTests.py index 45fdcb2..8981fd4 100644 --- a/src/engine/SCons/Scanner/ProgTests.py +++ b/src/engine/SCons/Scanner/ProgTests.py @@ -43,6 +43,7 @@ libs = [ 'l1.lib', 'd1/l2.lib', 'd1/d2/l3.lib', for h in libs: test.write(h, "\n") + # define some helpers: class DummyEnvironment(object): @@ -254,22 +255,6 @@ def suite(): suite.addTest(ProgramScannerTestCase8()) suite.addTest(ProgramScannerTestCase9()) suite.addTest(ProgramScannerTestCase10()) - try: unicode - except NameError: pass - else: - code = """if 1: - class ProgramScannerTestCase4(unittest.TestCase): - def runTest(self): - env = DummyEnvironment(LIBPATH=[test.workpath("d1/d2"), - test.workpath("d1")], - LIBS=u'l2 l3'.split()) - s = SCons.Scanner.Prog.ProgramScanner() - path = s.path(env) - deps = s(DummyNode('dummy'), env, path) - assert deps_match(deps, ['d1/l2.lib', 'd1/d2/l3.lib']), map(str, deps) - suite.addTest(ProgramScannerTestCase4()) - \n""" - exec(code) return suite if __name__ == "__main__": diff --git a/src/engine/SCons/Scanner/ScannerTests.py b/src/engine/SCons/Scanner/ScannerTests.py index abe4042..6206af9 100644 --- a/src/engine/SCons/Scanner/ScannerTests.py +++ b/src/engine/SCons/Scanner/ScannerTests.py @@ -599,7 +599,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/Script/Interactive.py b/src/engine/SCons/Script/Interactive.py index 59299f1..a414b4e 100644 --- a/src/engine/SCons/Script/Interactive.py +++ b/src/engine/SCons/Script/Interactive.py @@ -19,8 +19,6 @@ # 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__" __doc__ = """ diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py index a0d7f4c..ce948a0 100644 --- a/src/engine/SCons/Script/Main.py +++ b/src/engine/SCons/Script/Main.py @@ -10,9 +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) @@ -43,7 +40,9 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.compat +import importlib.util import os +import re import sys import time import traceback @@ -65,7 +64,6 @@ import SCons.Script import SCons.Taskmaster import SCons.Util import SCons.Warnings - import SCons.Script.Interactive # Global variables @@ -698,80 +696,87 @@ def _create_path(plist): return path def _load_site_scons_dir(topdir, site_dir_name=None): - """Load the site_scons dir under topdir. - Prepends site_scons to sys.path, imports site_scons/site_init.py, - and prepends site_scons/site_tools to default toolpath.""" + """Load the site directory under topdir. + + If a site dir name is supplied use it, else use default "site_scons" + Prepend site dir to sys.path. + If a "site_tools" subdir exists, prepend to toolpath. + Import "site_init.py" from site dir if it exists. + """ if site_dir_name: err_if_not_found = True # user specified: err if missing else: site_dir_name = "site_scons" - err_if_not_found = False - + err_if_not_found = False # scons default: okay to be missing site_dir = os.path.join(topdir, site_dir_name) + if not os.path.exists(site_dir): if err_if_not_found: - raise SCons.Errors.UserError("site dir %s not found."%site_dir) + raise SCons.Errors.UserError("site dir %s not found." % site_dir) return + sys.path.insert(0, os.path.abspath(site_dir)) site_init_filename = "site_init.py" site_init_modname = "site_init" site_tools_dirname = "site_tools" - # prepend to sys.path - sys.path = [os.path.abspath(site_dir)] + sys.path site_init_file = os.path.join(site_dir, site_init_filename) site_tools_dir = os.path.join(site_dir, site_tools_dirname) - if os.path.exists(site_init_file): - import imp, re - try: - try: - fp, pathname, description = imp.find_module(site_init_modname, - [site_dir]) - # Load the file into SCons.Script namespace. This is - # opaque and clever; m is the module object for the - # SCons.Script module, and the exec ... in call executes a - # file (or string containing code) in the context of the - # module's dictionary, so anything that code defines ends - # up adding to that module. This is really short, but all - # the error checking makes it longer. - try: - m = sys.modules['SCons.Script'] - except Exception as e: - fmt = 'cannot import site_init.py: missing SCons.Script module %s' - raise SCons.Errors.InternalError(fmt % repr(e)) - try: - sfx = description[0] - modname = os.path.basename(pathname)[:-len(sfx)] - site_m = {"__file__": pathname, "__name__": modname, "__doc__": None} - re_special = re.compile("__[^_]+__") - for k, v in m.__dict__.items(): - if not re_special.match(k): - site_m[k] = v - - # This is the magic. - exec(compile(fp.read(), fp.name, 'exec'), site_m) - except KeyboardInterrupt: - raise - except Exception as e: - fmt = '*** Error loading site_init file %s:\n' - sys.stderr.write(fmt % repr(site_init_file)) - raise - else: - for k in site_m: - if not re_special.match(k): - m.__dict__[k] = site_m[k] - except KeyboardInterrupt: - raise - except ImportError as e: - fmt = '*** cannot import site init file %s:\n' - sys.stderr.write(fmt % repr(site_init_file)) - raise - finally: - if fp: - fp.close() + if os.path.exists(site_tools_dir): - # prepend to DefaultToolpath SCons.Tool.DefaultToolpath.insert(0, os.path.abspath(site_tools_dir)) + if not os.path.exists(site_init_file): + return + + # "import" the site_init.py file into the SCons.Script namespace. + # This is a variant on the basic Python import flow in that the globals + # dict for the compile step is prepopulated from the SCons.Script + # module object; on success the SCons.Script globals are refilled + # from the site_init globals so it all appears in SCons.Script + # instead of as a separate module. + try: + try: + m = sys.modules['SCons.Script'] + except KeyError: + fmt = 'cannot import {}: missing SCons.Script module' + raise SCons.Errors.InternalError(fmt.format(site_init_file)) + + spec = importlib.util.spec_from_file_location(site_init_modname, site_init_file) + site_m = { + "__file__": spec.origin, + "__name__": spec.name, + "__doc__": None, + } + re_dunder = re.compile(r"__[^_]+__") + # update site dict with all but magic (dunder) methods + for k, v in m.__dict__.items(): + if not re_dunder.match(k): + site_m[k] = v + + with open(spec.origin, 'r') as f: + code = f.read() + try: + codeobj = compile(code, spec.name, "exec") + exec(codeobj, site_m) + except KeyboardInterrupt: + raise + except Exception: + fmt = "*** Error loading site_init file {}:\n" + sys.stderr.write(fmt.format(site_init_file)) + raise + else: + # now refill globals with site_init's symbols + for k, v in site_m.items(): + if not re_dunder.match(k): + m.__dict__[k] = v + except KeyboardInterrupt: + raise + except Exception: + fmt = "*** cannot import site init file {}:\n" + sys.stderr.write(fmt.format(site_init_file)) + raise + + def _load_all_site_scons_dirs(topdir, verbose=None): """Load all of the predefined site_scons dir. Order is significant; we load them in order from most generic @@ -810,7 +815,7 @@ def _load_all_site_scons_dirs(topdir, verbose=None): sysdirs=['/usr/share/scons', homedir('.scons')] - dirs=sysdirs + [topdir] + dirs = sysdirs + [topdir] for d in dirs: if verbose: # this is used by unit tests. print("Loading site dir ", d) diff --git a/src/engine/SCons/SubstTests.py b/src/engine/SCons/SubstTests.py index c25b377..574e714 100644 --- a/src/engine/SCons/SubstTests.py +++ b/src/engine/SCons/SubstTests.py @@ -20,8 +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 __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.compat diff --git a/src/engine/SCons/Taskmaster.py b/src/engine/SCons/Taskmaster.py index 1e5776c..6ca0e03 100644 --- a/src/engine/SCons/Taskmaster.py +++ b/src/engine/SCons/Taskmaster.py @@ -20,8 +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 __future__ import print_function - import sys __doc__ = """ @@ -171,7 +169,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 @@ -233,7 +231,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 = [] @@ -399,7 +397,7 @@ class Task(object): """ global print_prepare 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 = [] @@ -447,7 +445,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 @@ -464,7 +462,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) @@ -493,7 +491,7 @@ class Task(object): for p, subtract in 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: @@ -555,15 +553,12 @@ class Task(object): 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: - 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)") + if isinstance(exc_value, Exception): #hasattr(exc_value, 'with_traceback'): + # If exc_value is an exception, then just reraise + raise exc_value.with_traceback(exc_traceback) + else: + # else we'll create an exception using the value and raise that + raise exc_type(exc_value).with_traceback(exc_traceback) # raise e.__class__, e.__class__(e), sys.exc_info()[2] @@ -797,7 +792,7 @@ class Taskmaster(object): 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() @@ -820,7 +815,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: @@ -828,7 +823,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() @@ -859,7 +854,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) @@ -920,7 +915,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: @@ -946,7 +941,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 1a47230..58a31aa 100644 --- a/src/engine/SCons/TaskmasterTests.py +++ b/src/engine/SCons/TaskmasterTests.py @@ -20,8 +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 __future__ import division - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.compat diff --git a/src/engine/SCons/Tool/DCommon.py b/src/engine/SCons/Tool/DCommon.py index 71c4d8d..d29db3a 100644 --- a/src/engine/SCons/Tool/DCommon.py +++ b/src/engine/SCons/Tool/DCommon.py @@ -1,5 +1,3 @@ -from __future__ import print_function - """SCons.Tool.DCommon Common code for the various D tools. diff --git a/src/engine/SCons/Tool/FortranCommon.py b/src/engine/SCons/Tool/FortranCommon.py index cbb9a03..bfa1c1c 100644 --- a/src/engine/SCons/Tool/FortranCommon.py +++ b/src/engine/SCons/Tool/FortranCommon.py @@ -26,8 +26,6 @@ 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__" import re diff --git a/src/engine/SCons/Tool/MSCommon/common.py b/src/engine/SCons/Tool/MSCommon/common.py index 4ce605b..505136e 100644 --- a/src/engine/SCons/Tool/MSCommon/common.py +++ b/src/engine/SCons/Tool/MSCommon/common.py @@ -23,8 +23,6 @@ Common helper functions for working with the Microsoft tool chain. # 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 copy diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py index ed713d0..82fb6b9 100644 --- a/src/engine/SCons/Tool/MSCommon/vc.py +++ b/src/engine/SCons/Tool/MSCommon/vc.py @@ -46,9 +46,6 @@ import platform import sys from string import digits as string_digits from subprocess import PIPE -#TODO: Python 2 cleanup -if sys.version_info[0] == 2: - import collections import SCons.Warnings from SCons.Tool import find_program_path @@ -697,22 +694,6 @@ def script_env(script, args=None): script_env_cache[cache_key] = cache_data # once we updated cache, give a chance to write out if user wanted common.write_script_env_cache(script_env_cache) - else: - #TODO: Python 2 cleanup - # If we "hit" data from the json file, we have a Py2 problem: - # keys & values will be unicode. don't detect, just convert. - if sys.version_info[0] == 2: - def convert(data): - if isinstance(data, basestring): - return str(data) - elif isinstance(data, collections.Mapping): - return dict(map(convert, data.iteritems())) - elif isinstance(data, collections.Iterable): - return type(data)(map(convert, data)) - else: - return data - - cache_data = convert(cache_data) return cache_data diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index 76a0913..4cb77c0 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -38,9 +38,9 @@ tool definition. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import sys -import re import os -import shutil +from collections.abc import Callable +import importlib.util import SCons.Builder import SCons.Errors @@ -51,12 +51,6 @@ import SCons.Scanner.D import SCons.Scanner.LaTeX import SCons.Scanner.Prog import SCons.Scanner.SWIG -try: - # Python 3 - from collections.abc import Callable -except ImportError: - # Python 2.7 - from collections import Callable DefaultToolpath = [] @@ -142,112 +136,81 @@ class Tool(object): sys.path = self.toolpath + sys.path # sys.stderr.write("Tool:%s\nPATH:%s\n"%(self.name,sys.path)) - 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: - file = None - try: - mod, file = self._load_dotted_module_py2(self.name, self.name, self.toolpath) - return mod - finally: - if file: - file.close() - except ImportError as e: - splitname = self.name.split('.') - if str(e) != "No module named %s" % splitname[0]: - raise SCons.Errors.SConsEnvironmentError(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 - 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 - - # import pdb; pdb.set_trace() - 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 - found_name = self.name - add_to_scons_tools_namespace = False - for path in self.toolpath: - sepname = self.name.replace('.', os.path.sep) - file_path = os.path.join(path, "%s.py" % sepname) - file_package = os.path.join(path, sepname) - - 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): - file_package = os.path.join(file_package, '__init__.py') - 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 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: - error_string = "No module named %s" % self.name - raise SCons.Errors.SConsEnvironmentError(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.SConsEnvironmentError(error_string) - - # Don't reload a tool we already loaded. - sys_modules_value = sys.modules.get(found_name, False) - - found_module = None - if sys_modules_value and sys_modules_value.__file__ == spec.origin: - found_module = sys.modules[found_name] + # 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 + + + # 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 + found_name = self.name + add_to_scons_tools_namespace = False + for path in self.toolpath: + sepname = self.name.replace('.', os.path.sep) + file_path = os.path.join(path, "%s.py" % sepname) + file_package = os.path.join(path, sepname) + + 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): + file_package = os.path.join(file_package, '__init__.py') + spec = importlib.util.spec_from_file_location(self.name, file_package) + if debug: print("PACKAGE:%s Found" % file_package) + break + else: - # Not sure what to do in the case that there already - # exists sys.modules[self.name] but the source file is - # different.. ? - module = spec.loader.load_module(spec.name) - - 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) + 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 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: + error_string = "No module named %s" % self.name + raise SCons.Errors.SConsEnvironmentError(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.SConsEnvironmentError(error_string) + + # Don't reload a tool we already loaded. + sys_modules_value = sys.modules.get(found_name, False) + + found_module = None + if sys_modules_value and sys_modules_value.__file__ == spec.origin: + found_module = 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.. ? + module = spec.loader.load_module(spec.name) + + 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) - found_module = module + found_module = module - if found_module is not None: - sys.path = oldpythonpath - return found_module + if found_module is not None: + sys.path = oldpythonpath + return found_module sys.path = oldpythonpath diff --git a/src/engine/SCons/Tool/cyglink.py b/src/engine/SCons/Tool/cyglink.py index c3d78de..fbb6d24 100644 --- a/src/engine/SCons/Tool/cyglink.py +++ b/src/engine/SCons/Tool/cyglink.py @@ -8,8 +8,6 @@ selection method. """ -from __future__ import absolute_import, print_function - import re import os diff --git a/src/engine/SCons/Tool/dmd.py b/src/engine/SCons/Tool/dmd.py index 6a64a72..3cc4ed0 100644 --- a/src/engine/SCons/Tool/dmd.py +++ b/src/engine/SCons/Tool/dmd.py @@ -1,5 +1,3 @@ -from __future__ import print_function - """SCons.Tool.dmd Tool-specific initialization for the Digital Mars D compiler. 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 de1375d..3d53bf7 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,7 +1,5 @@ # docbook.py: extension module # $Id: docbook.py 8353 2009-03-17 16:57:50Z mzjn $ -from __future__ import print_function - import sys import string import libxml2 @@ -69,9 +67,9 @@ def adjustColumnWidths(ctx, nodeset): relPart = 0.0 absPart = 0.0 - starPos = string.find(width, "*") + starPos = width.find("*") if starPos >= 0: - relPart, absPart = string.split(width, "*", 2) + relPart, absPart = width.split("*", 2) relPart = float(relPart) relTotal = relTotal + float(relPart) else: @@ -113,7 +111,7 @@ def adjustColumnWidths(ctx, nodeset): widths = correctRoundingError(widths) else: pixelWidth = nominalWidth - if string.find(tableWidth, "%") < 0: + if '%' not in tableWidth: pixelWidth = convertLength(tableWidth) if pixelWidth <= absTotal: @@ -127,7 +125,7 @@ def adjustColumnWidths(ctx, nodeset): relParts[count] = rel + absParts[count] absTotal = absTotal + rel + absParts[count] - if string.find(tableWidth, "%") < 0: + if '%' not in tableWidth: for count in range(len(relParts)): if foStylesheet: pixels = relParts[count] 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 d5529b8..0a4ff92 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,7 +1,5 @@ #!/usr/bin/python -u # $Id: xslt.py 8353 2009-03-17 16:57:50Z mzjn $ -from __future__ import print_function - import sys import libxml2 import libxslt diff --git a/src/engine/SCons/Tool/f08.py b/src/engine/SCons/Tool/f08.py index 7fa5872..64bac8e 100644 --- a/src/engine/SCons/Tool/f08.py +++ b/src/engine/SCons/Tool/f08.py @@ -8,8 +8,6 @@ selection method. """ -from __future__ import absolute_import - # # __COPYRIGHT__ # diff --git a/src/engine/SCons/Tool/gdc.py b/src/engine/SCons/Tool/gdc.py index 0c6a8ab..ecf4f3a 100644 --- a/src/engine/SCons/Tool/gdc.py +++ b/src/engine/SCons/Tool/gdc.py @@ -1,5 +1,3 @@ -from __future__ import print_function - """SCons.Tool.gdc Tool-specific initialization for the GDC compiler. diff --git a/src/engine/SCons/Tool/install.py b/src/engine/SCons/Tool/install.py index dcb3581..06f7902 100644 --- a/src/engine/SCons/Tool/install.py +++ b/src/engine/SCons/Tool/install.py @@ -29,8 +29,6 @@ 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__" import os diff --git a/src/engine/SCons/Tool/intelc.py b/src/engine/SCons/Tool/intelc.py index 778cba1..0880976 100644 --- a/src/engine/SCons/Tool/intelc.py +++ b/src/engine/SCons/Tool/intelc.py @@ -30,8 +30,6 @@ 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__" import math, sys, os.path, glob, string, re diff --git a/src/engine/SCons/Tool/ldc.py b/src/engine/SCons/Tool/ldc.py index 3e12199..f915569 100644 --- a/src/engine/SCons/Tool/ldc.py +++ b/src/engine/SCons/Tool/ldc.py @@ -1,5 +1,3 @@ -from __future__ import print_function - """SCons.Tool.ldc Tool-specific initialization for the LDC compiler. diff --git a/src/engine/SCons/Tool/link.py b/src/engine/SCons/Tool/link.py index 5d920fb..d52c90d 100644 --- a/src/engine/SCons/Tool/link.py +++ b/src/engine/SCons/Tool/link.py @@ -30,8 +30,6 @@ 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__" import sys diff --git a/src/engine/SCons/Tool/mslink.py b/src/engine/SCons/Tool/mslink.py index fc5f009..bab78d8 100644 --- a/src/engine/SCons/Tool/mslink.py +++ b/src/engine/SCons/Tool/mslink.py @@ -30,8 +30,6 @@ 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__" import os diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py index 9952ccc..7332b49 100644 --- a/src/engine/SCons/Tool/msvs.py +++ b/src/engine/SCons/Tool/msvs.py @@ -29,9 +29,6 @@ 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__" import SCons.compat diff --git a/src/engine/SCons/Tool/msvsTests.py b/src/engine/SCons/Tool/msvsTests.py index 38a100f..b3373ea 100644 --- a/src/engine/SCons/Tool/msvsTests.py +++ b/src/engine/SCons/Tool/msvsTests.py @@ -20,8 +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 __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os diff --git a/src/engine/SCons/Tool/qt.py b/src/engine/SCons/Tool/qt.py index 0c471f9..3dc87c0 100644 --- a/src/engine/SCons/Tool/qt.py +++ b/src/engine/SCons/Tool/qt.py @@ -31,8 +31,6 @@ 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__" import os.path diff --git a/src/engine/SCons/Tool/rpmutils.py b/src/engine/SCons/Tool/rpmutils.py index 566f8e1..2c4fb32 100644 --- a/src/engine/SCons/Tool/rpmutils.py +++ b/src/engine/SCons/Tool/rpmutils.py @@ -34,8 +34,6 @@ 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/swig.py b/src/engine/SCons/Tool/swig.py index f139a09..4d98494 100644 --- a/src/engine/SCons/Tool/swig.py +++ b/src/engine/SCons/Tool/swig.py @@ -7,8 +7,6 @@ It will usually be imported through the generic SCons.Tool.Tool() selection method. """ -from __future__ import print_function - # # __COPYRIGHT__ # diff --git a/src/engine/SCons/Tool/tex.py b/src/engine/SCons/Tool/tex.py index fa18cf9..1d61e2d 100644 --- a/src/engine/SCons/Tool/tex.py +++ b/src/engine/SCons/Tool/tex.py @@ -31,8 +31,6 @@ 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__" import os.path diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 130cc5e..22df6fa 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -34,18 +34,11 @@ import types import codecs import pprint import hashlib +from collections import UserDict, UserList, UserString, OrderedDict +from collections.abc import MappingView -PY3 = sys.version_info[0] == 3 PYPY = hasattr(sys, 'pypy_translation_info') - -from collections import UserDict, UserList, UserString -from collections.abc import Iterable, MappingView -from collections import OrderedDict - -# Don't "from types import ..." these because we need to get at the -# types module later to look for UnicodeType. - # Below not used? # InstanceType = types.InstanceType @@ -359,27 +352,17 @@ def print_tree(root, child_func, prune=0, showtags=0, margin=[0], visited=None): DictTypes = (dict, UserDict) ListTypes = (list, UserList) -try: - # Handle getting dictionary views. - SequenceTypes = (list, tuple, UserList, MappingView) -except NameError: - SequenceTypes = (list, tuple, UserList) - +# Handle getting dictionary views. +SequenceTypes = (list, tuple, UserList, MappingView) +# TODO: PY3 check this benchmarking is still correct. # Note that profiling data shows a speed-up when comparing -# explicitly with str and unicode instead of simply comparing +# explicitly with str instead of simply comparing # with basestring. (at least on Python 2.5.1) -try: - StringTypes = (str, unicode, UserString) -except NameError: - StringTypes = (str, UserString) +StringTypes = (str, UserString) -# Empirically, it is faster to check explicitly for str and -# unicode than for basestring. -try: - BaseStringTypes = (str, unicode) -except NameError: - BaseStringTypes = str +# Empirically, it is faster to check explicitly for str than for basestring. +BaseStringTypes = str def is_Dict(obj, isinstance=isinstance, DictTypes=DictTypes): return isinstance(obj, DictTypes) @@ -447,24 +430,25 @@ def flatten_sequence(sequence, isinstance=isinstance, StringTypes=StringTypes, do_flatten(item, result) return result -# Generic convert-to-string functions that abstract away whether or -# not the Python we're executing has Unicode support. The wrapper +# Generic convert-to-string functions. The wrapper # to_String_for_signature() will use a for_signature() method if the # specified object has one. # + + def to_String(s, isinstance=isinstance, str=str, UserString=UserString, BaseStringTypes=BaseStringTypes): - if isinstance(s,BaseStringTypes): + if isinstance(s, BaseStringTypes): # Early out when already a string! return s elif isinstance(s, UserString): - # s.data can only be either a unicode or a regular - # string. Please see the UserString initializer. + # s.data can only be a regular string. Please see the UserString initializer. return s.data else: return str(s) + def to_String_for_subst(s, isinstance=isinstance, str=str, to_String=to_String, BaseStringTypes=BaseStringTypes, SequenceTypes=SequenceTypes, @@ -476,12 +460,12 @@ def to_String_for_subst(s, elif isinstance(s, SequenceTypes): return ' '.join([to_String_for_subst(e) for e in s]) elif isinstance(s, UserString): - # s.data can only be either a unicode or a regular - # string. Please see the UserString initializer. + # s.data can only a regular string. Please see the UserString initializer. return s.data else: return str(s) + def to_String_for_signature(obj, to_String_for_subst=to_String_for_subst, AttributeError=AttributeError): try: @@ -491,6 +475,7 @@ def to_String_for_signature(obj, to_String_for_subst=to_String_for_subst, # pprint will output dictionary in key sorted order # with py3.5 the order was randomized. In general depending on dictionary order # which was undefined until py3.6 (where it's by insertion order) was not wise. + # TODO: Change code when floor is raised to PY36 return pprint.pformat(obj, width=1000000) else: return to_String_for_subst(obj) @@ -1508,7 +1493,7 @@ def MD5collect(signatures): def silent_intern(x): """ Perform sys.intern() on the passed argument and return the result. - If the input is ineligible (e.g. a unicode string) the original argument is + If the input is ineligible the original argument is returned and no exception is thrown. """ try: diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py index ee07e61..d96b63f 100644 --- a/src/engine/SCons/UtilTests.py +++ b/src/engine/SCons/UtilTests.py @@ -313,7 +313,7 @@ class UtilTestCase(unittest.TestCase): """ Test the to_Bytes method""" self.assertEqual(to_bytes('Hello'), bytearray('Hello', 'utf-8'), - "Check that to_bytes creates byte array when presented with unicode string.") + "Check that to_bytes creates byte array when presented with non byte string.") def test_to_String(self): """Test the to_String() method.""" @@ -740,7 +740,7 @@ class UtilTestCase(unittest.TestCase): def test_LogicalLines(self): """Test the LogicalLines class""" - content = u""" + content = """ foo \\ bar \\ baz @@ -761,9 +761,6 @@ bling def test_intern(self): s1 = silent_intern("spam") - # TODO: Python 3.x does not have a unicode() global function - if sys.version[0] == '2': - 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/cppTests.py b/src/engine/SCons/cppTests.py index eff7715..eb9189d 100644 --- a/src/engine/SCons/cppTests.py +++ b/src/engine/SCons/cppTests.py @@ -20,9 +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 __future__ import absolute_import - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import atexit diff --git a/src/engine/SCons/dblite.py b/src/engine/SCons/dblite.py index 55254b3..765516c 100644 --- a/src/engine/SCons/dblite.py +++ b/src/engine/SCons/dblite.py @@ -1,6 +1,7 @@ -# dblite.py module contributed by Ralf W. Grosse-Kunstleve. -# Extended for Unicode by Steven Knight. -from __future__ import print_function +""" +dblite.py module contributed by Ralf W. Grosse-Kunstleve. +Extended for Unicode by Steven Knight. +""" import os import pickle @@ -17,26 +18,6 @@ def corruption_warning(filename): print("Warning: Discarding corrupt database:", filename) -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: - unicode('a') -except NameError: - def unicode(s): - return s - dblite_suffix = '.dblite' # TODO: Does commenting this out break switching from py2/3? @@ -181,10 +162,13 @@ class dblite(object): def __setitem__(self, key, value): self._check_writable() - if not is_string(key): + + if not isinstance(key, str): raise TypeError("key `%s' must be a string but is %s" % (key, type(key))) - if not is_bytes(value): + + if not isinstance(value, bytes): raise TypeError("value `%s' must be a bytes but is %s" % (value, type(value))) + self._dict[key] = value self._needs_sync = 0o001 @@ -214,25 +198,21 @@ def open(file, flag=None, mode=0o666): 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["foo"] = b"bar" + assert db["foo"] == b"bar" 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") + assert len(db) == 1, len(db) + assert db["foo"] == b"bar" + db["bar"] = b"foo" + assert db["bar"] == b"foo" 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 len(db) == 2, len(db) + assert db["foo"] == b"bar" + assert db["bar"] == b"foo" try: db.sync() except IOError as e: @@ -240,26 +220,31 @@ def _exercise(): else: raise RuntimeError("IOError expected.") db = open("tmp", "w") - assert len(db) == 4 - db["ping"] = "pong" + assert len(db) == 2, len(db) + db["ping"] = b"pong" db.sync() + try: db[(1, 2)] = "tuple" except TypeError as e: - assert str(e) == "key `(1, 2)' must be a string but is <type 'tuple'>", str(e) + assert str(e) == "key `(1, 2)' must be a string but is <class 'tuple'>", 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 <type 'list'>", str(e) + assert str(e) == "value `[1, 2]' must be a bytes but is <class 'list'>", str(e) else: raise RuntimeError("TypeError exception expected") + db = open("tmp", "r") - assert len(db) == 5 + assert len(db) == 3, len(db) + db = open("tmp", "n") - assert len(db) == 0 + assert len(db) == 0, len(db) dblite._open("tmp.dblite", "w") + db = open("tmp", "r") dblite._open("tmp.dblite", "w").write("x") try: @@ -268,10 +253,11 @@ def _exercise(): pass else: raise RuntimeError("pickle exception expected.") + global ignore_corrupt_dbfiles ignore_corrupt_dbfiles = 2 db = open("tmp", "r") - assert len(db) == 0 + assert len(db) == 0, len(db) os.unlink("tmp.dblite") try: db = open("tmp", "w") @@ -280,6 +266,8 @@ def _exercise(): else: raise RuntimeError("IOError expected.") + print("Completed _exercise()") + if __name__ == "__main__": _exercise() diff --git a/src/script/scons-configure-cache.py b/src/script/scons-configure-cache.py index a687c9c..716315c 100644 --- a/src/script/scons-configure-cache.py +++ b/src/script/scons-configure-cache.py @@ -31,7 +31,6 @@ digits of the signature. The prefix length used for directory names can be changed by this script. """ -from __future__ import print_function import argparse import glob import json diff --git a/src/script/scons-time.py b/src/script/scons-time.py index 91a105b..e4dd863 100644 --- a/src/script/scons-time.py +++ b/src/script/scons-time.py @@ -29,7 +29,6 @@ # 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/src/script/scons.py b/src/script/scons.py index 2e76365..1e12898 100755 --- a/src/script/scons.py +++ b/src/script/scons.py @@ -23,8 +23,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__" __version__ = "__VERSION__" diff --git a/src/script/sconsign.py b/src/script/sconsign.py index 5ea5ea5..726838c 100644 --- a/src/script/sconsign.py +++ b/src/script/sconsign.py @@ -23,8 +23,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__" __version__ = "__VERSION__" diff --git a/src/setup.py b/src/setup.py index 0f9a672..261e2a4 100755 --- a/src/setup.py +++ b/src/setup.py @@ -20,9 +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 __future__ import print_function - - import distutils.command.build_scripts import distutils.command.install_scripts import distutils.command.install_lib diff --git a/src/test_files.py b/src/test_files.py index 1eee11d..fcb2b4c 100644 --- a/src/test_files.py +++ b/src/test_files.py @@ -21,8 +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__" """ diff --git a/src/test_interrupts.py b/src/test_interrupts.py index 8e1b379..1cac046 100644 --- a/src/test_interrupts.py +++ b/src/test_interrupts.py @@ -21,8 +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__" """ diff --git a/src/test_pychecker.py b/src/test_pychecker.py index 56233c2..fdc8d20 100644 --- a/src/test_pychecker.py +++ b/src/test_pychecker.py @@ -20,8 +20,6 @@ # 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 d9fa5b5..8410be3 100644 --- a/src/test_setup.py +++ b/src/test_setup.py @@ -21,8 +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__" """ diff --git a/src/test_strings.py b/src/test_strings.py index a8a5000..b43340f 100644 --- a/src/test_strings.py +++ b/src/test_strings.py @@ -21,8 +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__" """ diff --git a/test/AddOption/help.py b/test/AddOption/help.py index 7b886cb..23e5bd1 100644 --- a/test/AddOption/help.py +++ b/test/AddOption/help.py @@ -20,15 +20,14 @@ # 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__" """ Verify the help text when the AddOption() function is used (and when it's not). """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import TestSCons test = TestSCons.TestSCons() diff --git a/test/Batch/action-changed.py b/test/Batch/action-changed.py index b2b1673..da5115e 100644 --- a/test/Batch/action-changed.py +++ b/test/Batch/action-changed.py @@ -33,7 +33,11 @@ import os 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() @@ -53,17 +57,21 @@ sys.exit(0) test.write('build.py', build_py_contents % (python, 'one')) os.chmod(test.workpath('build.py'), 0o755) +build_py_workpath = test.workpath('build.py') + +# Provide IMPLICIT_COMMAND_DEPENDENCIES=2 so we take a dependency on build.py. +# Without that, we only scan the first entry in the action string. test.write('SConstruct', """ -env = Environment() +env = Environment(IMPLICIT_COMMAND_DEPENDENCIES=2) env.PrependENVPath('PATHEXT', '.PY') -bb = Action(r'"%s" $CHANGED_TARGETS -- $CHANGED_SOURCES', +bb = Action(r'%(_python_)s "%(build_py_workpath)s" $CHANGED_TARGETS -- $CHANGED_SOURCES', batch_key=True, targets='CHANGED_TARGETS') env['BUILDERS']['Batch'] = Builder(action=bb) env.Batch('f1.out', 'f1.in') env.Batch('f2.out', 'f2.in') env.Batch('f3.out', 'f3.in') -""" % test.workpath('build.py')) +""" % locals()) test.write('f1.in', "f1.in\n") test.write('f2.in', "f2.in\n") diff --git a/test/Command.py b/test/Command.py index d8ca86d..5abdf16 100644 --- a/test/Command.py +++ b/test/Command.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. -# + __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons @@ -42,7 +42,6 @@ test.write('build.py', build_py) test.write(['expand_chdir_sub', 'subbuild.py'], build_py) test.write('SConstruct', """ -from __future__ import print_function import os import sys diff --git a/test/Configure/ConfigureDryRunError.py b/test/Configure/ConfigureDryRunError.py index ad40ea4..3648518 100644 --- a/test/Configure/ConfigureDryRunError.py +++ b/test/Configure/ConfigureDryRunError.py @@ -20,15 +20,13 @@ # 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__" """ Verify the ConfigureDryRunError. """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import os import TestSCons diff --git a/test/Configure/config-h.py b/test/Configure/config-h.py index 405f259..0331b24 100644 --- a/test/Configure/config-h.py +++ b/test/Configure/config-h.py @@ -20,15 +20,13 @@ # 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__" """ Verify creation of a config.h file from a Configure context. """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import os import re diff --git a/test/Configure/custom-tests.py b/test/Configure/custom-tests.py index 1c6eac8..47b344a 100644 --- a/test/Configure/custom-tests.py +++ b/test/Configure/custom-tests.py @@ -20,14 +20,13 @@ # 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 execution of custom test cases. """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import TestSCons _exe = TestSCons._exe @@ -49,8 +48,6 @@ runOK = compileOK runFAIL = "int main(void) { return 1; }" test.write('pyAct.py', """\ -from __future__ import print_function - import sys print(sys.argv[1]) sys.exit(int(sys.argv[1])) diff --git a/test/Configure/fixture/SConstruct.issue-2906 b/test/Configure/fixture/SConstruct.issue-2906 new file mode 100644 index 0000000..7763653 --- /dev/null +++ b/test/Configure/fixture/SConstruct.issue-2906 @@ -0,0 +1,5 @@ +env = Environment() +conf1 = Configure(env) +env2 = Environment() +# Error right here. You can't have two configure contexts in flight at the same time. +conf2 = Configure(env2)
\ No newline at end of file diff --git a/test/Configure/implicit-cache.py b/test/Configure/implicit-cache.py index 20bdebb..f4f3e94 100644 --- a/test/Configure/implicit-cache.py +++ b/test/Configure/implicit-cache.py @@ -20,10 +20,6 @@ # 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__" """ Verify that use of --implicit-cache with the Python Value Nodes @@ -56,6 +52,8 @@ something else changed in the .sconf_temp directory), the string would get longer and longer until it blew out the users's memory. """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import TestSConsign test = TestSConsign.TestSConsign() diff --git a/test/Configure/issue-2906-useful-duplicate-configure-message.py b/test/Configure/issue-2906-useful-duplicate-configure-message.py new file mode 100644 index 0000000..c980bd3 --- /dev/null +++ b/test/Configure/issue-2906-useful-duplicate-configure-message.py @@ -0,0 +1,57 @@ +#!/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 useful error message when you create a second Configure context without +finalizing the previous one via conf.Finish() +This addresses Issue 2906: +https://github.com/SCons/scons/issues/2906 +""" + +import TestSCons + +test = TestSCons.TestSCons() +test.verbose_set(1) + +test.file_fixture('./fixture/SConstruct.issue-2906', 'SConstruct') + +test_SConstruct_path = test.workpath('SConstruct') + +expected_stdout = "scons: Reading SConscript files ...\n" + +expected_stderr = """ +scons: *** Configure() called while another Configure() exists. + Please call .Finish() before creating and second Configure() context +File "%s", line 5, in <module>\n"""%test_SConstruct_path +test.run(stderr=expected_stderr, stdout=expected_stdout, status=2) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/ENV.py b/test/ENV.py index 0866cf5..0fc3f09 100644 --- a/test/ENV.py +++ b/test/ENV.py @@ -20,7 +20,6 @@ # 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__" @@ -70,9 +69,7 @@ env['ENV']['LIST'] = [foo, 'bar'] env['ENV']['FOO'] = foo """ % locals()) -test.write('build.py', -r""" -from __future__ import print_function +test.write('build.py', r""" import os print('LIST:', os.environ['LIST']) print('FOO:', os.environ['FOO']) diff --git a/test/GetBuildFailures/parallel.py b/test/GetBuildFailures/parallel.py index 63125ad..9b162d8 100644 --- a/test/GetBuildFailures/parallel.py +++ b/test/GetBuildFailures/parallel.py @@ -20,8 +20,6 @@ # 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 """ 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 0878090..b688b7e 100644 --- a/test/Glob/glob-libpath.py +++ b/test/Glob/glob-libpath.py @@ -20,10 +20,6 @@ # 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__" """ Verify that Glob() in a subdir doesn't corrupt LIBPATH. @@ -31,6 +27,8 @@ See bug #2184, "Glob pollutes LIBPATH" from Ian P. Cardenas. Test output should not contain -Lsrc/util. """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import TestSCons test = TestSCons.TestSCons() diff --git a/test/Interactive/shell.py b/test/Interactive/shell.py index dd13504..e839d6d 100644 --- a/test/Interactive/shell.py +++ b/test/Interactive/shell.py @@ -20,14 +20,14 @@ # 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 the ability of the "shell" command (and its "sh" and "!" aliases) to shell out of interactive mode. """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import sys import TestSCons @@ -40,8 +40,6 @@ shell_command_py = test.workpath('shell_command.py') _shell_command_py_ = '"%s"' % shell_command_py.replace('\\', '\\\\') test.write(shell_command_py, """\ -from __future__ import print_function - print('hello from shell_command.py') """) diff --git a/test/Interactive/version.py b/test/Interactive/version.py index 88416ad..6609ad7 100644 --- a/test/Interactive/version.py +++ b/test/Interactive/version.py @@ -20,14 +20,13 @@ # 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__" """ Verify the behavior of the "version" subcommand. """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import TestCmd import TestSCons diff --git a/test/Java/multi-step.py b/test/Java/multi-step.py index f5ee257..d0b3450 100644 --- a/test/Java/multi-step.py +++ b/test/Java/multi-step.py @@ -20,16 +20,14 @@ # 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__" """ Real-world test (courtesy Leanid Nazdrynau) of the multi-step capabilities of the various Java Builders. """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import os import TestSCons diff --git a/test/LINK/VersionedLib.py b/test/LINK/VersionedLib.py index 64f9b90..104f696 100644 --- a/test/LINK/VersionedLib.py +++ b/test/LINK/VersionedLib.py @@ -20,9 +20,6 @@ # 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/MSVC/mssdk.py b/test/MSVC/mssdk.py index ba45346..8d1bb5c 100644 --- a/test/MSVC/mssdk.py +++ b/test/MSVC/mssdk.py @@ -20,15 +20,13 @@ # 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__" """ Simple test to make sure mssdk works. """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import time import TestSCons diff --git a/test/MSVC/msvc.py b/test/MSVC/msvc.py index 838922c..b92cf3a 100644 --- a/test/MSVC/msvc.py +++ b/test/MSVC/msvc.py @@ -20,16 +20,14 @@ # 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__" """ Verify basic invocation of Microsoft Visual C/C++, including use of a precompiled header with the $CCFLAGS variable. """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import time import TestSCons diff --git a/test/QT/Tool.py b/test/QT/Tool.py index 9e4a277..f684e91 100644 --- a/test/QT/Tool.py +++ b/test/QT/Tool.py @@ -20,11 +20,6 @@ # 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__" """ Verify that applying env.Tool('qt') after running Configure checks @@ -36,6 +31,8 @@ not completely minimal, but we're leaving it as-is since it represents a good real-world sanity check on the interaction of some key subsystems. """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import os import TestSCons diff --git a/test/QT/copied-env.py b/test/QT/copied-env.py index 3989143..be9f599 100644 --- a/test/QT/copied-env.py +++ b/test/QT/copied-env.py @@ -20,14 +20,13 @@ # 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 Qt with a copied construction environment. """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import TestSCons test = TestSCons.TestSCons() diff --git a/test/QT/qt_warnings.py b/test/QT/qt_warnings.py index 020333e..2aa7940 100644 --- a/test/QT/qt_warnings.py +++ b/test/QT/qt_warnings.py @@ -20,15 +20,13 @@ # 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. """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import os import re diff --git a/test/Repository/Program.py b/test/Repository/Program.py index 1eb18d8..9e8af77 100644 --- a/test/Repository/Program.py +++ b/test/Repository/Program.py @@ -32,25 +32,22 @@ if sys.platform == 'win32': else: _exe = '' -test = TestSCons.TestSCons() - - - -# First, test a single repository. -test.subdir('repository', 'work1') - -repository = test.workpath('repository') -repository_foo_c = test.workpath('repository', 'foo.c') -work1_foo = test.workpath('work1', 'foo' + _exe) -work1_foo_c = test.workpath('work1', 'foo.c') - -test.write(['work1', 'SConstruct'], r""" +for implicit_deps in ['0', '1', '2', 'all']: + # First, test a single repository. + test = TestSCons.TestSCons() + test.subdir('repository', 'work1') + repository = test.workpath('repository') + repository_foo_c = test.workpath('repository', 'foo.c') + work1_foo = test.workpath('work1', 'foo' + _exe) + work1_foo_c = test.workpath('work1', 'foo.c') + + test.write(['work1', 'SConstruct'], r""" Repository(r'%s') -env = Environment() +env = Environment(IMPLICIT_COMMAND_DEPENDENCIES=%s) env.Program(target= 'foo', source = Split('aaa.c bbb.c foo.c')) -""" % repository) +""" % (repository, implicit_deps)) -test.write(['repository', 'aaa.c'], r""" + test.write(['repository', 'aaa.c'], r""" #include <stdio.h> void aaa(void) @@ -59,7 +56,7 @@ aaa(void) } """) -test.write(['repository', 'bbb.c'], r""" + test.write(['repository', 'bbb.c'], r""" #include <stdio.h> void bbb(void) @@ -68,7 +65,7 @@ bbb(void) } """) -test.write(['repository', 'foo.c'], r""" + test.write(['repository', 'foo.c'], r""" #include <stdio.h> #include <stdlib.h> @@ -85,21 +82,21 @@ main(int argc, char *argv[]) } """) -# Make the entire repository non-writable, so we'll detect -# if we try to write into it accidentally. -test.writable('repository', 0) + # Make the entire repository non-writable, so we'll detect + # if we try to write into it accidentally. + test.writable('repository', 0) -test.run(chdir = 'work1', arguments = '.') + test.run(chdir = 'work1', arguments = '.') -test.run(program = work1_foo, stdout = """repository/aaa.c + test.run(program = work1_foo, stdout = """repository/aaa.c repository/bbb.c repository/foo.c """) -test.up_to_date(chdir = 'work1', arguments = '.') + test.up_to_date(chdir = 'work1', arguments = '.') -# -test.write(['work1', 'bbb.c'], r""" + # + test.write(['work1', 'bbb.c'], r""" #include <stdio.h> void bbb(void) @@ -108,17 +105,17 @@ bbb(void) } """) -test.run(chdir = 'work1', arguments = '.') + test.run(chdir = 'work1', arguments = '.') -test.run(program = work1_foo, stdout = """repository/aaa.c + test.run(program = work1_foo, stdout = """repository/aaa.c work1/bbb.c repository/foo.c """) -test.up_to_date(chdir = 'work1', arguments = '.') + test.up_to_date(chdir = 'work1', arguments = '.') -# -test.write(['work1', 'aaa.c'], r""" + # + test.write(['work1', 'aaa.c'], r""" #include <stdio.h> void aaa(void) @@ -127,7 +124,7 @@ aaa(void) } """) -test.write(['work1', 'foo.c'], r""" + test.write(['work1', 'foo.c'], r""" #include <stdio.h> #include <stdlib.h> extern void aaa(void); @@ -143,57 +140,57 @@ main(int argc, char *argv[]) } """) -test.run(chdir = 'work1', arguments = '.') + test.run(chdir = 'work1', arguments = '.') -test.run(program = work1_foo, stdout = """work1/aaa.c + test.run(program = work1_foo, stdout = """work1/aaa.c work1/bbb.c work1/foo.c """) -test.up_to_date(chdir = 'work1', arguments = '.') + test.up_to_date(chdir = 'work1', arguments = '.') -# -test.unlink(['work1', 'aaa.c']) + # + test.unlink(['work1', 'aaa.c']) -test.run(chdir = 'work1', arguments = '.') + test.run(chdir = 'work1', arguments = '.') -test.run(program = work1_foo, stdout = """repository/aaa.c + test.run(program = work1_foo, stdout = """repository/aaa.c work1/bbb.c work1/foo.c """) -test.up_to_date(chdir = 'work1', arguments = '.') + test.up_to_date(chdir = 'work1', arguments = '.') -# -test.unlink(['work1', 'bbb.c']) -test.unlink(['work1', 'foo.c']) + # + test.unlink(['work1', 'bbb.c']) + test.unlink(['work1', 'foo.c']) -test.run(chdir = 'work1', arguments = '.') + test.run(chdir = 'work1', arguments = '.') -test.run(program = work1_foo, stdout = """repository/aaa.c + test.run(program = work1_foo, stdout = """repository/aaa.c repository/bbb.c repository/foo.c """) -test.up_to_date(chdir = 'work1', arguments = '.') + test.up_to_date(chdir = 'work1', arguments = '.') -# Now, test multiple repositories. -test.subdir('repository.new', 'repository.old', 'work2') + # Now, test multiple repositories. + test.subdir('repository.new', 'repository.old', 'work2') -repository_new = test.workpath('repository.new') -repository_old = test.workpath('repository.old') -work2_foo = test.workpath('work2', 'foo' + _exe) + repository_new = test.workpath('repository.new') + repository_old = test.workpath('repository.old') + work2_foo = test.workpath('work2', 'foo' + _exe) -test.write(['work2', 'SConstruct'], r""" + test.write(['work2', 'SConstruct'], r""" Repository(r'%s') Repository(r'%s') env = Environment() env.Program(target= 'foo', source = Split('aaa.c bbb.c foo.c')) """ % (repository_new, repository_old)) -test.write(['repository.old', 'aaa.c'], r""" + test.write(['repository.old', 'aaa.c'], r""" #include <stdio.h> void aaa(void) @@ -202,7 +199,7 @@ aaa(void) } """) -test.write(['repository.old', 'bbb.c'], r""" + test.write(['repository.old', 'bbb.c'], r""" #include <stdio.h> void bbb(void) @@ -211,7 +208,7 @@ bbb(void) } """) -test.write(['repository.old', 'foo.c'], r""" + test.write(['repository.old', 'foo.c'], r""" #include <stdio.h> #include <stdlib.h> extern void aaa(void); @@ -227,24 +224,24 @@ main(int argc, char *argv[]) } """) -# Make both repositories non-writable, so we'll detect -# if we try to write into it accidentally. -test.writable('repository.new', 0) -test.writable('repository.old', 0) + # Make both repositories non-writable, so we'll detect + # if we try to write into it accidentally. + test.writable('repository.new', 0) + test.writable('repository.old', 0) -test.run(chdir = 'work2', arguments = '.') + test.run(chdir = 'work2', arguments = '.') -test.run(program = work2_foo, stdout = """repository.old/aaa.c + test.run(program = work2_foo, stdout = """repository.old/aaa.c repository.old/bbb.c repository.old/foo.c """) -test.up_to_date(chdir = 'work2', arguments = '.') + test.up_to_date(chdir = 'work2', arguments = '.') -# -test.writable('repository.new', 1) + # + test.writable('repository.new', 1) -test.write(['repository.new', 'aaa.c'], r""" + test.write(['repository.new', 'aaa.c'], r""" #include <stdio.h> #include <stdlib.h> void @@ -254,7 +251,7 @@ aaa(void) } """) -test.write(['work2', 'bbb.c'], r""" + test.write(['work2', 'bbb.c'], r""" #include <stdio.h> #include <stdlib.h> void @@ -264,20 +261,20 @@ bbb(void) } """) -# -test.writable('repository.new', 0) + # + test.writable('repository.new', 0) -test.run(chdir = 'work2', arguments = '.') + test.run(chdir = 'work2', arguments = '.') -test.run(program = work2_foo, stdout = """repository.new/aaa.c + test.run(program = work2_foo, stdout = """repository.new/aaa.c work2/bbb.c repository.old/foo.c """) -test.up_to_date(chdir = 'work2', arguments = '.') + test.up_to_date(chdir = 'work2', arguments = '.') -# -test.write(['work2', 'aaa.c'], r""" + # + test.write(['work2', 'aaa.c'], r""" #include <stdio.h> #include <stdlib.h> void @@ -287,7 +284,7 @@ aaa(void) } """) -test.write(['work2', 'foo.c'], r""" + test.write(['work2', 'foo.c'], r""" #include <stdio.h> #include <stdlib.h> extern void aaa(void); @@ -303,59 +300,59 @@ main(int argc, char *argv[]) } """) -# -test.run(chdir = 'work2', arguments = '.') + # + test.run(chdir = 'work2', arguments = '.') -test.run(program = work2_foo, stdout = """work2/aaa.c + test.run(program = work2_foo, stdout = """work2/aaa.c work2/bbb.c work2/foo.c """) -test.up_to_date(chdir = 'work2', arguments = '.') + test.up_to_date(chdir = 'work2', arguments = '.') -# -test.unlink(['work2', 'aaa.c']) -test.unlink(['work2', 'bbb.c']) + # + test.unlink(['work2', 'aaa.c']) + test.unlink(['work2', 'bbb.c']) -# -test.run(chdir = 'work2', arguments = '.') + # + test.run(chdir = 'work2', arguments = '.') -test.run(program = work2_foo, stdout = """repository.new/aaa.c + test.run(program = work2_foo, stdout = """repository.new/aaa.c repository.old/bbb.c work2/foo.c """) -test.up_to_date(chdir = 'work2', arguments = '.') + test.up_to_date(chdir = 'work2', arguments = '.') -# -test.unlink(['work2', 'foo.c']) + # + test.unlink(['work2', 'foo.c']) -# -test.run(chdir = 'work2', arguments = '.') + # + test.run(chdir = 'work2', arguments = '.') -test.run(program = work2_foo, stdout = """repository.new/aaa.c + test.run(program = work2_foo, stdout = """repository.new/aaa.c repository.old/bbb.c repository.old/foo.c """) -test.up_to_date(chdir = 'work2', arguments = '.') + test.up_to_date(chdir = 'work2', arguments = '.') -# -test.writable('repository.new', 1) + # + test.writable('repository.new', 1) -test.unlink(['repository.new', 'aaa.c']) + test.unlink(['repository.new', 'aaa.c']) -test.writable('repository.new', 0) + test.writable('repository.new', 0) -# -test.run(chdir = 'work2', arguments = '.') + # + test.run(chdir = 'work2', arguments = '.') -test.run(program = work2_foo, stdout = """repository.old/aaa.c + test.run(program = work2_foo, stdout = """repository.old/aaa.c repository.old/bbb.c repository.old/foo.c """) -test.up_to_date(chdir = 'work2', arguments = '.') + test.up_to_date(chdir = 'work2', arguments = '.') # diff --git a/test/Repository/StaticLibrary.py b/test/Repository/StaticLibrary.py index 4f8160c..acd4b83 100644 --- a/test/Repository/StaticLibrary.py +++ b/test/Repository/StaticLibrary.py @@ -30,35 +30,37 @@ import TestSCons _obj = TestSCons._obj _exe = TestSCons._exe -test = TestSCons.TestSCons() - -# -test.subdir('repository', 'work1', 'work2', 'work3') - -# -workpath_repository = test.workpath('repository') -repository_aaa_obj = test.workpath('repository', 'aaa' + _obj) -repository_bbb_obj = test.workpath('repository', 'bbb' + _obj) -repository_foo_obj = test.workpath('repository', 'foo' + _obj) -repository_foo = test.workpath('repository', 'foo' + _exe) -work1_foo = test.workpath('work1', 'foo' + _exe) -work2_aaa_obj = test.workpath('work2', 'aaa' + _obj) -work2_foo_obj = test.workpath('work2', 'foo' + _obj) -work2_foo = test.workpath('work2', 'foo' + _exe) -work3_aaa_obj = test.workpath('work3', 'aaa' + _obj) -work3_bbb_obj = test.workpath('work3', 'bbb' + _obj) -work3_foo = test.workpath('work3', 'foo' + _exe) - -opts = '-Y ' + workpath_repository - -# -test.write(['repository', 'SConstruct'], """ -env = Environment(LIBS = ['xxx'], LIBPATH = '.') +for implicit_deps in ['0', '1', '2', 'all']: + test = TestSCons.TestSCons() + + # + test.subdir('repository', 'work1', 'work2', 'work3') + + # + workpath_repository = test.workpath('repository') + repository_aaa_obj = test.workpath('repository', 'aaa' + _obj) + repository_bbb_obj = test.workpath('repository', 'bbb' + _obj) + repository_foo_obj = test.workpath('repository', 'foo' + _obj) + repository_foo = test.workpath('repository', 'foo' + _exe) + work1_foo = test.workpath('work1', 'foo' + _exe) + work2_aaa_obj = test.workpath('work2', 'aaa' + _obj) + work2_foo_obj = test.workpath('work2', 'foo' + _obj) + work2_foo = test.workpath('work2', 'foo' + _exe) + work3_aaa_obj = test.workpath('work3', 'aaa' + _obj) + work3_bbb_obj = test.workpath('work3', 'bbb' + _obj) + work3_foo = test.workpath('work3', 'foo' + _exe) + + opts = '-Y ' + workpath_repository + + # + test.write(['repository', 'SConstruct'], """ +env = Environment(LIBS = ['xxx'], LIBPATH = '.', + IMPLICIT_COMMAND_DEPENDENCIES=%s) env.Library(target = 'xxx', source = ['aaa.c', 'bbb.c']) env.Program(target = 'foo', source = 'foo.c') -""") +""" % implicit_deps) -test.write(['repository', 'aaa.c'], r""" + test.write(['repository', 'aaa.c'], r""" #include <stdio.h> #include <stdlib.h> void @@ -68,7 +70,7 @@ aaa(void) } """) -test.write(['repository', 'bbb.c'], r""" + test.write(['repository', 'bbb.c'], r""" #include <stdio.h> #include <stdlib.h> void @@ -78,7 +80,7 @@ bbb(void) } """) -test.write(['repository', 'foo.c'], r""" + test.write(['repository', 'foo.c'], r""" #include <stdio.h> #include <stdlib.h> extern void aaa(void); @@ -94,29 +96,29 @@ main(int argc, char *argv[]) } """) -# Make the repository non-writable, -# so we'll detect if we try to write into it accidentally. -test.writable('repository', 0) + # Make the repository non-writable, + # so we'll detect if we try to write into it accidentally. + test.writable('repository', 0) -# -test.run(chdir = 'work1', options = opts, arguments = ".", - stderr=TestSCons.noisy_ar, - match=TestSCons.match_re_dotall) + # + test.run(chdir = 'work1', options = opts, arguments = ".", + stderr=TestSCons.noisy_ar, + match=TestSCons.match_re_dotall) -test.run(program = work1_foo, stdout = + test.run(program = work1_foo, stdout = """repository/aaa.c repository/bbb.c repository/foo.c """) -test.fail_test(os.path.exists(repository_aaa_obj)) -test.fail_test(os.path.exists(repository_bbb_obj)) -test.fail_test(os.path.exists(repository_foo_obj)) -test.fail_test(os.path.exists(repository_foo)) + test.fail_test(os.path.exists(repository_aaa_obj)) + test.fail_test(os.path.exists(repository_bbb_obj)) + test.fail_test(os.path.exists(repository_foo_obj)) + test.fail_test(os.path.exists(repository_foo)) -test.up_to_date(chdir = 'work1', options = opts, arguments = ".") + test.up_to_date(chdir = 'work1', options = opts, arguments = ".") -test.write(['work1', 'bbb.c'], r""" + test.write(['work1', 'bbb.c'], r""" #include <stdio.h> #include <stdlib.h> void @@ -126,49 +128,49 @@ bbb(void) } """) -test.run(chdir = 'work1', options = opts, arguments = ".", - stderr=TestSCons.noisy_ar, - match=TestSCons.match_re_dotall) + test.run(chdir = 'work1', options = opts, arguments = ".", + stderr=TestSCons.noisy_ar, + match=TestSCons.match_re_dotall) -test.run(program = work1_foo, stdout = + test.run(program = work1_foo, stdout = """repository/aaa.c work1/bbb.c repository/foo.c """) -test.fail_test(os.path.exists(repository_aaa_obj)) -test.fail_test(os.path.exists(repository_bbb_obj)) -test.fail_test(os.path.exists(repository_foo_obj)) -test.fail_test(os.path.exists(repository_foo)) + test.fail_test(os.path.exists(repository_aaa_obj)) + test.fail_test(os.path.exists(repository_bbb_obj)) + test.fail_test(os.path.exists(repository_foo_obj)) + test.fail_test(os.path.exists(repository_foo)) -test.up_to_date(chdir = 'work1', options = opts, arguments = ".") + test.up_to_date(chdir = 'work1', options = opts, arguments = ".") -# -test.writable('repository', 1) + # + test.writable('repository', 1) -test.run(chdir = 'repository', options = opts, arguments = ".", - stderr=TestSCons.noisy_ar, - match=TestSCons.match_re_dotall) + test.run(chdir = 'repository', options = opts, arguments = ".", + stderr=TestSCons.noisy_ar, + match=TestSCons.match_re_dotall) -test.run(program = repository_foo, stdout = + test.run(program = repository_foo, stdout = """repository/aaa.c repository/bbb.c repository/foo.c """) -test.fail_test(not os.path.exists(repository_aaa_obj)) -test.fail_test(not os.path.exists(repository_bbb_obj)) -test.fail_test(not os.path.exists(repository_foo_obj)) + test.fail_test(not os.path.exists(repository_aaa_obj)) + test.fail_test(not os.path.exists(repository_bbb_obj)) + test.fail_test(not os.path.exists(repository_foo_obj)) -test.up_to_date(chdir = 'repository', options = opts, arguments = ".") + test.up_to_date(chdir = 'repository', options = opts, arguments = ".") -# -test.writable('repository', 0) + # + test.writable('repository', 0) -# -test.up_to_date(chdir = 'work2', options = opts, arguments = ".") + # + test.up_to_date(chdir = 'work2', options = opts, arguments = ".") -test.write(['work2', 'bbb.c'], r""" + test.write(['work2', 'bbb.c'], r""" #include <stdio.h> #include <stdlib.h> void @@ -178,25 +180,25 @@ bbb(void) } """) -test.run(chdir = 'work2', options = opts, arguments = ".", - stderr=TestSCons.noisy_ar, - match=TestSCons.match_re_dotall) + test.run(chdir = 'work2', options = opts, arguments = ".", + stderr=TestSCons.noisy_ar, + match=TestSCons.match_re_dotall) -test.run(program = work2_foo, stdout = + test.run(program = work2_foo, stdout = """repository/aaa.c work2/bbb.c repository/foo.c """) -test.fail_test(os.path.exists(work2_aaa_obj)) -test.fail_test(os.path.exists(work2_foo_obj)) + test.fail_test(os.path.exists(work2_aaa_obj)) + test.fail_test(os.path.exists(work2_foo_obj)) -test.up_to_date(chdir = 'work2', options = opts, arguments = ".") + test.up_to_date(chdir = 'work2', options = opts, arguments = ".") -# -test.up_to_date(chdir = 'work3', options = opts, arguments = ".") + # + test.up_to_date(chdir = 'work3', options = opts, arguments = ".") -test.write(['work3', 'foo.c'], r""" + test.write(['work3', 'foo.c'], r""" #include <stdio.h> #include <stdlib.h> extern void aaa(void); @@ -212,18 +214,19 @@ main(int argc, char *argv[]) } """) -test.run(chdir = 'work3', options = opts, arguments = ".") + test.run(chdir = 'work3', options = opts, arguments = ".") -test.run(program = work3_foo, stdout = + test.run(program = work3_foo, stdout = """repository/aaa.c repository/bbb.c work3/foo.c """) -test.fail_test(os.path.exists(work3_aaa_obj)) -test.fail_test(os.path.exists(work3_bbb_obj)) + test.fail_test(os.path.exists(work3_aaa_obj)) + test.fail_test(os.path.exists(work3_bbb_obj)) + + test.up_to_date(chdir = 'work3', options = opts, arguments = ".") -test.up_to_date(chdir = 'work3', options = opts, arguments = ".") # test.pass_test() diff --git a/test/SCONS_LIB_DIR.py b/test/SCONS_LIB_DIR.py index 65ec3de..5691f61 100644 --- a/test/SCONS_LIB_DIR.py +++ b/test/SCONS_LIB_DIR.py @@ -20,7 +20,6 @@ # 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__" @@ -31,8 +30,6 @@ test = TestSCons.TestSCons() test.subdir('SCons') test.write(['SCons','Script.py'], """ -from __future__ import print_function - def main (): print("SCons.Script") """) diff --git a/test/SWIG/build-dir.py b/test/SWIG/build-dir.py index f70e6e1..372b052 100644 --- a/test/SWIG/build-dir.py +++ b/test/SWIG/build-dir.py @@ -21,14 +21,14 @@ # 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__" - """ Make sure SWIG works when a VariantDir (or variant_dir) is used. Test case courtesy Joe Maruszewski. """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import sys import TestSCons @@ -143,8 +143,6 @@ public: ## XXX: @ptomulik: looks like it was unused? ## test.write(['source', 'test.py'], """\ ## #!%(_python_)s -## from __future__ import print_function -## ## import linalg ## ## diff --git a/test/SWIG/live.py b/test/SWIG/live.py index e01597d..e7b2602 100644 --- a/test/SWIG/live.py +++ b/test/SWIG/live.py @@ -20,14 +20,13 @@ # 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 SWIG behavior with a live, installed SWIG. """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import os import sys @@ -134,7 +133,6 @@ 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()) """, stdout="""\ @@ -148,7 +146,6 @@ 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()) diff --git a/test/TEMPFILEPREFIX.py b/test/TEMPFILEPREFIX.py index f5093e1..4ccfd7d 100644 --- a/test/TEMPFILEPREFIX.py +++ b/test/TEMPFILEPREFIX.py @@ -20,9 +20,6 @@ # 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 setting the $TEMPFILEPREFIX variable will cause @@ -30,6 +27,8 @@ it to appear at the front of name of the generated tempfile used for long command lines. """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import os import stat @@ -38,7 +37,6 @@ import TestSCons test = TestSCons.TestSCons(match = TestSCons.match_re) test.write('echo.py', """\ -from __future__ import print_function import sys print(sys.argv) """) diff --git a/test/TEMPFILESUFFIX.py b/test/TEMPFILESUFFIX.py index aee1e2d..df546ac 100644 --- a/test/TEMPFILESUFFIX.py +++ b/test/TEMPFILESUFFIX.py @@ -20,9 +20,6 @@ # 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 setting the $TEMPFILESUFFIX variable will cause @@ -30,6 +27,8 @@ it to appear at the end of name of the generated tempfile used for long command lines. """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import os import stat @@ -38,7 +37,6 @@ import TestSCons test = TestSCons.TestSCons(match=TestSCons.match_re) test.write('echo.py', """\ -from __future__ import print_function import sys print(sys.argv) """) diff --git a/test/TEX/TEX.py b/test/TEX/TEX.py index f0d4043..4c4bd87 100644 --- a/test/TEX/TEX.py +++ b/test/TEX/TEX.py @@ -20,9 +20,6 @@ # 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__" r""" Validate that we can set the TEX string to our own utility, that @@ -30,6 +27,8 @@ the produced .dvi, .aux and .log files get removed by the -c option, and that we can use this to wrap calls to the real latex utility. """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import TestSCons _python_ = TestSCons._python_ diff --git a/test/Value.py b/test/Value.py index 8f6c7fe..eb04eb0 100644 --- a/test/Value.py +++ b/test/Value.py @@ -20,8 +20,6 @@ # 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/VariantDir/reflect.py b/test/VariantDir/reflect.py index 72f3af7..56b0c18 100644 --- a/test/VariantDir/reflect.py +++ b/test/VariantDir/reflect.py @@ -20,9 +20,6 @@ # 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 test validates the correct operation of a VariantDir specification @@ -33,6 +30,8 @@ in the variant_dir as sources for that same build dir. Test based on bug #1055521 filed by Gary Oberbrunner. """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import os.path import re @@ -44,14 +43,11 @@ _python_ = TestSCons._python_ re_python = re.escape(TestSCons._python_) test.write("mycc.py", """ -from __future__ import print_function print('Compile') """) test.write("mylink.py", """ -from __future__ import print_function - print('Link') """) diff --git a/test/Win32/bad-drive.py b/test/Win32/bad-drive.py index 28d926b..cca5462 100644 --- a/test/Win32/bad-drive.py +++ b/test/Win32/bad-drive.py @@ -20,8 +20,6 @@ # 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 """ 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 78db4be..7d19c57 100644 --- a/test/Win32/default-drive.py +++ b/test/Win32/default-drive.py @@ -20,8 +20,6 @@ # 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 """ This test verifies (on Windows systems) that specifying an diff --git a/test/builderrors.py b/test/builderrors.py index f5cbccf..635f448 100644 --- a/test/builderrors.py +++ b/test/builderrors.py @@ -20,7 +20,6 @@ # 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__" @@ -169,7 +168,6 @@ 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() diff --git a/test/explain/basic.py b/test/explain/basic.py index 46ce6bc..6d41496 100644 --- a/test/explain/basic.py +++ b/test/explain/basic.py @@ -20,14 +20,13 @@ # 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 a lot of the basic operation of the --debug=explain option. """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import os import TestSCons @@ -52,7 +51,6 @@ inc_bbb_k = test.workpath('inc', 'bbb.k') test.write(cat_py, r""" -from __future__ import print_function import sys diff --git a/test/explain/save-info.py b/test/explain/save-info.py index 24ebb88..500bb55 100644 --- a/test/explain/save-info.py +++ b/test/explain/save-info.py @@ -20,14 +20,13 @@ # 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 the --debug=explain information gets saved by default. """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import TestSCons _python_ = TestSCons._python_ @@ -42,8 +41,6 @@ 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): diff --git a/test/gnutools.py b/test/gnutools.py index 040de2a..eb0d847 100644 --- a/test/gnutools.py +++ b/test/gnutools.py @@ -20,15 +20,13 @@ # 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__" """ Testing the gnu tool chain, i.e. the tools 'gcc', 'g++' and 'gnulink'. """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import TestSCons import sys diff --git a/test/implicit/IMPLICIT_COMMAND_DEPENDENCIES.py b/test/implicit/IMPLICIT_COMMAND_DEPENDENCIES.py index 2431a61..bec2255 100644 --- a/test/implicit/IMPLICIT_COMMAND_DEPENDENCIES.py +++ b/test/implicit/IMPLICIT_COMMAND_DEPENDENCIES.py @@ -40,6 +40,8 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() +test.write('file.in', "file.in\n") + generate_build_py_py_contents = """\ #!%(python)s import os @@ -61,17 +63,17 @@ os.chmod(sys.argv[1], 0o755) """ -extra = '' -test.write('generate_build_py.py', generate_build_py_py_contents % locals()) - +workpath = test.workpath() test.write('SConstruct', """ DefaultEnvironment(tools=[]) generate = Builder(action = r'%(_python_)s $GENERATE $TARGET') -build = Builder(action = r'$BUILD_PY $TARGET $SOURCES') +build = Builder(action = r'%(_python_)s $BUILD_PY $TARGET $SOURCES') +cd_and_build = Builder(action = r'cd %(workpath)s && %(_python_)s $BUILD_PY $TARGET $SOURCES') env = Environment(tools=[], BUILDERS = { 'GenerateBuild' : generate, 'BuildFile' : build, + 'CdAndBuildFile': cd_and_build, }, GENERATE = 'generate_build_py.py', BUILD_PY = 'build.py', @@ -80,6 +82,8 @@ env.PrependENVPath('PATH', '.') env.PrependENVPath('PATHEXT', '.PY') env0 = env.Clone(IMPLICIT_COMMAND_DEPENDENCIES = 0) env1 = env.Clone(IMPLICIT_COMMAND_DEPENDENCIES = 1) +env2 = env.Clone(IMPLICIT_COMMAND_DEPENDENCIES = 2) +envAll = env.Clone(IMPLICIT_COMMAND_DEPENDENCIES = 'all') envNone = env.Clone(IMPLICIT_COMMAND_DEPENDENCIES = None) envFalse = env.Clone(IMPLICIT_COMMAND_DEPENDENCIES = False) envTrue = env.Clone(IMPLICIT_COMMAND_DEPENDENCIES = True) @@ -90,44 +94,59 @@ AlwaysBuild(build_py) env.BuildFile('file.out', 'file.in') env0.BuildFile('file0.out', 'file.in') env1.BuildFile('file1.out', 'file.in') +env2.BuildFile('file2.out', 'file.in') +envAll.BuildFile('fileall.out', 'file.in') envNone.BuildFile('fileNone.out', 'file.in') envFalse.BuildFile('fileFalse.out', 'file.in') envTrue.BuildFile('fileTrue.out', 'file.in') envTrue.BuildFile('fileQuote.out', 'file.in', BUILD_PY='"build.py"') -""" % locals()) - +env1.CdAndBuildFile('cd_file1.out', 'file.in') +env2.CdAndBuildFile('cd_file2.out', 'file.in') +envAll.CdAndBuildFile('cd_fileall.out', 'file.in') +""" % locals()) -test.write('file.in', "file.in\n") -test.run(arguments = '--tree=all .') -expect_none = 'build.py %s file.in\nfile.in\n' +def run_test(extra, python, _python_): + # Write the generate_build_py.py file. This uses the contents of the + # variable "extra" while writing build.py. + test.write('generate_build_py.py', + generate_build_py_py_contents % locals()) -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') + # Run the SConscript file. + test.run(arguments = '--tree=all .') + # Generate some expected data of actions involving build.py. This expected + # data depends on the value of "extra". + build_none = 'build.py %s file.in\nfile.in\n' + build_extra = (build_none if not extra else + 'build.py %s file.in\n{}file.in\n'.format( + extra.replace('\\\\n', '\n'))) + build_extra_abs = '{} %s file.in\n{}file.in\n'.format( + test.workpath('build.py'), + extra.replace('\\\\n', '\n')) + empty_none = 'empty.py %s file.in\nfile.in\n' -extra = 'xyzzy\\\\n' -test.write('generate_build_py.py', generate_build_py_py_contents % locals()) + # Verify that the output matches what is expected. + test.must_match('file.out', build_none % 'file.out', mode='r') + test.must_match('file0.out', build_none % 'file0.out', mode='r') + test.must_match('file1.out', build_none % 'file1.out', mode='r') + test.must_match('file2.out', build_extra % 'file2.out', mode='r') + test.must_match('fileall.out', build_extra % 'fileall.out', mode='r') + test.must_match('fileNone.out', build_none % 'fileNone.out', mode='r') + test.must_match('fileFalse.out', build_none % 'fileFalse.out', mode='r') + test.must_match('fileTrue.out', build_none % 'fileTrue.out', mode='r') + test.must_match('fileQuote.out', build_none % 'fileQuote.out', mode='r') + test.must_match('cd_file1.out', build_none % 'cd_file1.out', mode='r') + test.must_match('cd_file2.out', build_extra % 'cd_file2.out', mode='r') + test.must_match('cd_fileall.out', build_extra % 'cd_fileall.out', mode='r') -test.run(arguments = '--tree=all .') -expect_extra = 'build.py %s file.in\nxyzzy\nfile.in\n' +run_test('', python, _python_) +run_test('xyzzy\\\\n', python, _python_) -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() diff --git a/test/option--random.py b/test/option--random.py index 2944ad8..c25ec12 100644 --- a/test/option--random.py +++ b/test/option--random.py @@ -20,15 +20,13 @@ # 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__" """ Verify that we build correctly using the --random option. """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import os.path import TestSCons diff --git a/test/option-v.py b/test/option-v.py index ed8c4e5..ec20b20 100644 --- a/test/option-v.py +++ b/test/option-v.py @@ -20,8 +20,6 @@ # 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-action-timestamps.py b/test/option/debug-action-timestamps.py index 059cfdf..747d880 100644 --- a/test/option/debug-action-timestamps.py +++ b/test/option/debug-action-timestamps.py @@ -20,7 +20,6 @@ # 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/debug-count.py b/test/option/debug-count.py index 0234bfa..f2fceb4 100644 --- a/test/option/debug-count.py +++ b/test/option/debug-count.py @@ -20,14 +20,13 @@ # 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 that the --debug=count option works. """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import re import sys diff --git a/test/option/debug-multiple.py b/test/option/debug-multiple.py index 020aa85..124e033 100644 --- a/test/option/debug-multiple.py +++ b/test/option/debug-multiple.py @@ -21,14 +21,12 @@ # 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 that --debug can take multiple options """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import re import TestSCons diff --git a/test/option/debug-time.py b/test/option/debug-time.py index 3ed7555..7e95af3 100644 --- a/test/option/debug-time.py +++ b/test/option/debug-time.py @@ -20,7 +20,6 @@ # 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 1835a62..2dac532 100644 --- a/test/option/help-options.py +++ b/test/option/help-options.py @@ -20,14 +20,13 @@ # 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__" """ Verify behavior of the -H and --help-options options. """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import re import TestSCons diff --git a/test/packaging/convenience-functions/image/SConstruct b/test/packaging/convenience-functions/image/SConstruct index f35c3e3..a424fd9 100644 --- a/test/packaging/convenience-functions/image/SConstruct +++ b/test/packaging/convenience-functions/image/SConstruct @@ -1,5 +1,3 @@ -from __future__ import print_function - env = Environment(tools=['default', 'packaging']) prog = env.Install( 'bin/', ["f1", "f2"] ) env.File( "f3" ) diff --git a/test/scons-time/run/config/python.py b/test/scons-time/run/config/python.py index c8842c1..bf873fa 100644 --- a/test/scons-time/run/config/python.py +++ b/test/scons-time/run/config/python.py @@ -20,14 +20,13 @@ # 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 specifying an alternate Python executable in a config file. """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import os import TestSCons_time @@ -46,7 +45,6 @@ python = r'%(my_python_py)s' test.write(my_python_py, """\ #!%(_python_)s -from __future__ import print_function import sys profile = '' for arg in sys.argv[1:]: diff --git a/test/scons-time/run/config/scons.py b/test/scons-time/run/config/scons.py index b782e83..168ee7a 100644 --- a/test/scons-time/run/config/scons.py +++ b/test/scons-time/run/config/scons.py @@ -20,14 +20,12 @@ # 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 specifying an alternate SCons through a config file. """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons_time @@ -42,7 +40,6 @@ 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:]: diff --git a/test/site_scons/sysdirs.py b/test/site_scons/sysdirs.py index 36a581e..61f9c02 100644 --- a/test/site_scons/sysdirs.py +++ b/test/site_scons/sysdirs.py @@ -20,13 +20,6 @@ # 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 TestSCons """ Verify site_scons system dirs are getting loaded. @@ -37,6 +30,10 @@ 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). """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import TestSCons + test = TestSCons.TestSCons() test.write('SConstruct', """ diff --git a/test/srcchange.py b/test/srcchange.py index 3c23737..30f6f20 100644 --- a/test/srcchange.py +++ b/test/srcchange.py @@ -20,9 +20,6 @@ # 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 changing the C source files based on an always-executed revision @@ -33,6 +30,8 @@ expected. This relies on the default behavior being the equivalent of Decider('content'). """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import os.path import TestSCons @@ -42,7 +41,6 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() test.write('getrevision', r""" -from __future__ import print_function with open('revnum.in', 'r') as f: print(f.read().strip(), end='') """) diff --git a/testing/framework/TestCmd.py b/testing/framework/TestCmd.py index 6beed24..ed8b4b4 100644 --- a/testing/framework/TestCmd.py +++ b/testing/framework/TestCmd.py @@ -285,7 +285,6 @@ 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 <knight at baldmt dot com>" __revision__ = "TestCmd.py 1.3.D001 2010/06/03 12:58:27 knight" @@ -358,14 +357,8 @@ def to_str(s): return str(s, 'utf-8') -try: - eval('unicode') -except NameError: - def is_String(e): - return isinstance(e, (str, UserString)) -else: - def is_String(e): - return isinstance(e, (str, unicode, UserString)) +def is_String(e): + return isinstance(e, (str, UserString)) testprefix = 'testcmd.' if os.name in ('posix', 'nt'): @@ -498,11 +491,9 @@ def match_caseinsensitive(lines=None, matches=None): """ Match function using case-insensitive matching. - Only a simplistic comparison is done, based on lowercasing the - strings. This has plenty of holes for unicode data using - non-English languages. - - TODO: casefold() is better than lower() if we don't need Py2 support. + Only a simplistic comparison is done, based on casefolding + the strings. This may still fail but is the suggestion of + the Unicode Standard. :param lines: data lines :type lines: str or list[str] @@ -518,7 +509,7 @@ def match_caseinsensitive(lines=None, matches=None): if len(lines) != len(matches): return None for line, match in zip(lines, matches): - if line.lower() != match.lower(): + if line.casefold() != match.casefold(): return None return 1 @@ -706,7 +697,7 @@ if sys.platform == 'win32': if is_String(pathext): pathext = pathext.split(os.pathsep) for ext in pathext: - if ext.lower() == file[-len(ext):].lower(): + if ext.casefold() == file[-len(ext):].casefold(): pathext = [''] break for dir in path: @@ -1094,7 +1085,7 @@ class TestCmd(object): condition = self.condition if self._preserve[condition]: for dir in self._dirlist: - print(u"Preserved directory " + dir) + print("Preserved directory " + dir) else: list = self._dirlist[:] list.reverse() @@ -1510,13 +1501,13 @@ class TestCmd(object): @staticmethod def fix_binary_stream(stream): """ - Handle stdout/stderr from popen when we specify universal_newlines = False. + Handle stdout/stderr from popen when we specify not universal_newlines - This will read from the pipes in binary mode, not decode the output, - and not convert line endings to \n. + This will read from the pipes in binary mode, will not decode the + output, and will not convert line endings to \n. We do this because in py3 (3.5) with universal_newlines=True, it will choose the default system locale to decode the output, and this breaks unicode - output. Specifically breaking test/option--tree.py which outputs a unicode char. + output. Specifically test/option--tree.py which outputs a unicode char. py 3.6 allows us to pass an encoding param to popen thus not requiring the decode nor end of line handling, because we propagate universal_newlines as specified. @@ -1536,7 +1527,6 @@ class TestCmd(object): return stream - def finish(self, popen=None, **kw): """ Finishes and waits for the process being run under control of @@ -1975,13 +1965,20 @@ class TestCmd(object): do_chmod(top) 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 - os.path.join() method. The file is created under the temporary - working directory. Any subdirectories in the path must already - exist. The I/O mode for the file may be specified; it must - begin with a 'w'. The default is 'wb' (binary write). + """Write data to file + + The file is created under the temporary working directory. + Any subdirectories in the path must already exist. The + write is converted to the required type rather than failing + if there is a str/bytes mistmatch. + + :param file: name of file to write to. If a list, treated + as components of a path and concatenated into a path. + :type file: str or list(str) + :param content: data to write. + :type content: str or bytes + :param mode: file mode, default is binary. + :type mode: str """ file = self.canonicalize(file) if mode[0] != 'w': @@ -1990,7 +1987,6 @@ class TestCmd(object): 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: diff --git a/testing/framework/TestCmdTests.py b/testing/framework/TestCmdTests.py index 48eba1e..e8c2744 100644 --- a/testing/framework/TestCmdTests.py +++ b/testing/framework/TestCmdTests.py @@ -254,7 +254,7 @@ class cleanup_TestCase(TestCmdTestCase): def test_atexit(self): """Test cleanup() when atexit is used""" - self.popen_python("""from __future__ import print_function + self.popen_python("""\ import sys sys.path = ['%s'] + sys.path import atexit @@ -269,7 +269,7 @@ sys.exit(0) @unittest.skipIf(TestCmd.IS_PY3, "No sys.exitfunc in Python 3") def test_exitfunc(self): """Test cleanup() when sys.exitfunc is set""" - self.popen_python("""from __future__ import print_function + self.popen_python("""\ import sys sys.path = ['%s'] + sys.path def my_exitfunc(): @@ -609,7 +609,7 @@ sys.exit(0) def test_diff_stderr_not_affecting_diff_stdout(self): """Test diff_stderr() not affecting diff_stdout() behavior""" - self.popen_python(r"""from __future__ import print_function + self.popen_python(r""" import sys sys.path = ['%s'] + sys.path import TestCmd @@ -716,7 +716,7 @@ sys.exit(0) def test_diff_stdout_not_affecting_diff_stderr(self): """Test diff_stdout() not affecting diff_stderr() behavior""" - self.popen_python(r"""from __future__ import print_function + self.popen_python(r""" import sys sys.path = ['%s'] + sys.path import TestCmd @@ -2089,7 +2089,7 @@ sys.exit(0) def test_set_diff_function_stdout(self): """Test set_diff_function(): stdout""" - self.popen_python("""from __future__ import print_function + self.popen_python("""\ import sys sys.path = ['%s'] + sys.path import TestCmd @@ -2118,7 +2118,7 @@ diff_stdout: def test_set_diff_function_stderr(self): """Test set_diff_function(): stderr """ - self.popen_python("""from __future__ import print_function + self.popen_python("""\ import sys sys.path = ['%s'] + sys.path import TestCmd @@ -2693,7 +2693,7 @@ class stdin_TestCase(TestCmdTestCase): def test_stdin(self): """Test stdin()""" run_env = TestCmd.TestCmd(workdir = '') - run_env.write('run', """from __future__ import print_function + run_env.write('run', """\ import fileinput for line in fileinput.input(): print('Y'.join(line[:-1].split('X'))) @@ -3332,15 +3332,13 @@ class variables_TestCase(TestCmdTestCase): 'TestCmd', ] - script = "from __future__ import print_function\n" + \ - "import TestCmd\n" + \ + script = "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 __future__ import print_function\n" + \ - "from TestCmd import *\n" + \ + script = "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() diff --git a/testing/framework/TestCommon.py b/testing/framework/TestCommon.py index 8e6cc8e..1bd9f6b 100644 --- a/testing/framework/TestCommon.py +++ b/testing/framework/TestCommon.py @@ -93,8 +93,6 @@ The TestCommon module also provides the following variables # AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. -from __future__ import print_function - __author__ = "Steven Knight <knight at baldmt dot com>" __revision__ = "TestCommon.py 1.3.D001 2010/06/03 12:58:27 knight" __version__ = "1.3" diff --git a/testing/framework/TestCommonTests.py b/testing/framework/TestCommonTests.py index c54f33f..01e9fe1 100644 --- a/testing/framework/TestCommonTests.py +++ b/testing/framework/TestCommonTests.py @@ -45,10 +45,9 @@ def lstrip(s): lines = [ l[spaces:] for l in lines ] return '\n'.join(lines) -if sys.version[:3] == '1.5': - expected_newline = '\\012' -else: - expected_newline = '\\n' + +expected_newline = '\\n' + def assert_display(expect, result, error=None): try: @@ -57,9 +56,9 @@ def assert_display(expect, result, error=None): pass result = [ '\n', - ('*'*80) + '\n', + 'EXPECTED'+('*'*80) + '\n', expect, - ('*'*80) + '\n', + 'GOT'+('*'*80) + '\n', result, ('*'*80) + '\n', ] @@ -168,7 +167,6 @@ 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 @@ -353,14 +351,13 @@ class must_contain_TestCase(TestCommonTestCase): expect = lstrip("""\ File `file1' does not contain required string. Required string ================================================================ - 1 c + b'1 c' file1 contents ================================================================= - file1 does not match - + b'file1 does not match\\n' """) run_env.run(program=sys.executable, stdin=script) stdout = run_env.stdout() - assert stdout == expect, repr(stdout) + assert stdout == expect, "got:\n%s\nexpected:\n%s"%(stdout, expect) stderr = run_env.stderr() assert stderr.find("FAILED") != -1, stderr @@ -1294,7 +1291,7 @@ class must_not_contain_TestCase(TestCommonTestCase): from TestCommon import TestCommon tc = TestCommon(workdir='') tc.write('file1', "file1 contents\\n") - tc.must_not_contain('file1', "1 does not contain c") + tc.must_not_contain('file1', b"1 does not contain c") tc.pass_test() """) run_env.run(program=sys.executable, stdin=script) @@ -1327,20 +1324,20 @@ class must_not_contain_TestCase(TestCommonTestCase): from TestCommon import TestCommon tc = TestCommon(workdir='') tc.write('file1', "file1 does contain contents\\n") - tc.must_not_contain('file1', "1 does contain c") + tc.must_not_contain('file1', b"1 does contain c") tc.run() """) expect = lstrip("""\ File `file1' contains banned string. Banned string ================================================================== - 1 does contain c + b'1 does contain c' file1 contents ================================================================= - file1 does contain contents - + b'file1 does contain contents\\n' """) run_env.run(program=sys.executable, stdin=script) stdout = run_env.stdout() - assert stdout == expect, repr(stdout) + assert stdout == expect, "\ngot:\n%s\nexpected:\n%s" % (stdout, expect) + stderr = run_env.stderr() assert stderr.find("FAILED") != -1, stderr @@ -1352,20 +1349,20 @@ class must_not_contain_TestCase(TestCommonTestCase): from TestCommon import TestCommon tc = TestCommon(workdir='') tc.write('file1', "file1 does contain contents\\n") - tc.must_not_contain('file1', "file1 does") + tc.must_not_contain('file1', b"file1 does") tc.run() """) expect = lstrip("""\ File `file1' contains banned string. Banned string ================================================================== - file1 does + b'file1 does' file1 contents ================================================================= - file1 does contain contents - + b'file1 does contain contents\\n' """) run_env.run(program=sys.executable, stdin=script) stdout = run_env.stdout() - assert stdout == expect, repr(stdout) + assert stdout == expect, "\ngot:\n%s\nexpected:\n%s" % (stdout, expect) + stderr = run_env.stderr() assert stderr.find("FAILED") != -1, stderr @@ -1379,7 +1376,7 @@ class must_not_contain_TestCase(TestCommonTestCase): tc.write('file1', "file1 contents\\n", mode='w') tc.must_not_contain('file1', "1 does not contain c", mode='r') tc.write('file2', "file2 contents\\n", mode='wb') - tc.must_not_contain('file2', "2 does not contain c", mode='rb') + tc.must_not_contain('file2', b"2 does not contain c", mode='rb') tc.pass_test() """) run_env.run(program=sys.executable, stdin=script) @@ -1891,6 +1888,7 @@ class run_TestCase(TestCommonTestCase): expect_stdout = lstrip("""\ STDOUT ========================================================================= + None STDERR ========================================================================= """) @@ -1904,6 +1902,9 @@ class run_TestCase(TestCommonTestCase): .* File "[^"]+TestCommon.py", line \\d+, in start raise e + File "[^"]+TestCommon.py", line \\d+, in start + return TestCmd.start\\(self, program, interpreter, arguments, + File "<stdin>", line \\d+, in raise_exception TypeError: forced TypeError """ % re.escape(repr(sys.executable))) expect_stderr = re.compile(expect_stderr, re.M) @@ -2172,7 +2173,7 @@ class run_TestCase(TestCommonTestCase): tc.run() """) - self.SIGTERM = signal.SIGTERM + self.SIGTERM = int(signal.SIGTERM) # Script returns the signal value as a negative number. expect_stdout = lstrip("""\ @@ -2338,15 +2339,13 @@ class variables_TestCase(TestCommonTestCase): 'dll_suffix', ] - script = "from __future__ import print_function\n" + \ - "import TestCommon\n" + \ + script = "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 __future__ import print_function\n" + \ - "from TestCommon import *\n" + \ + script = "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() diff --git a/testing/framework/TestSCons.py b/testing/framework/TestSCons.py index 2f20950..8800c1b 100644 --- a/testing/framework/TestSCons.py +++ b/testing/framework/TestSCons.py @@ -13,7 +13,6 @@ attributes defined in this subclass. """ # __COPYRIGHT__ -from __future__ import division, print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/testing/framework/TestSCons_time.py b/testing/framework/TestSCons_time.py index f27e0e3..6f46e26 100644 --- a/testing/framework/TestSCons_time.py +++ b/testing/framework/TestSCons_time.py @@ -27,7 +27,6 @@ from TestSCons import search_re, search_re_in_list __all__.extend(['TestSCons_time',]) SConstruct = """\ -from __future__ import print_function import os print("SConstruct file directory:", os.getcwd()) """ diff --git a/testing/framework/TestSConsign.py b/testing/framework/TestSConsign.py index a48b648..665059c 100644 --- a/testing/framework/TestSConsign.py +++ b/testing/framework/TestSConsign.py @@ -1,5 +1,4 @@ # __COPYRIGHT__ -from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" |