From ccf62abac7be516e2947f5badb6bc86021159772 Mon Sep 17 00:00:00 2001 From: Daniel Holth Date: Mon, 20 Jun 2016 19:40:16 -0400 Subject: centralize the preferred pickle protocol; use highest protocol. --- src/engine/SCons/SConsign.py | 6 ++++-- src/engine/SCons/Tool/msvs.py | 15 ++++++++------- src/engine/SCons/compat/__init__.py | 5 +++++ src/engine/SCons/dblite.py | 4 +++- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/engine/SCons/SConsign.py b/src/engine/SCons/SConsign.py index cb089aa..3a5e5c0 100644 --- a/src/engine/SCons/SConsign.py +++ b/src/engine/SCons/SConsign.py @@ -39,6 +39,8 @@ import pickle import SCons.dblite import SCons.Warnings +from SCons.compat import PICKLE_PROTOCOL + def corrupt_dblite_warning(filename): SCons.Warnings.warn(SCons.Warnings.CorruptSConsignWarning, "Ignoring corrupt .sconsign file: %s"%filename) @@ -272,7 +274,7 @@ class DB(Base): path = normcase(self.dir.get_internal_path()) for key, entry in self.entries.items(): entry.convert_to_sconsign() - db[path] = pickle.dumps(self.entries, 1) + db[path] = pickle.dumps(self.entries, PICKLE_PROTOCOL) if sync: try: @@ -360,7 +362,7 @@ class DirFile(Dir): return for key, entry in self.entries.items(): entry.convert_to_sconsign() - pickle.dump(self.entries, file, 1) + pickle.dump(self.entries, file, PICKLE_PROTOCOL) file.close() if fname != self.sconsign: try: diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py index 6df4928..02b9a34 100644 --- a/src/engine/SCons/Tool/msvs.py +++ b/src/engine/SCons/Tool/msvs.py @@ -54,6 +54,7 @@ import SCons.Warnings from .MSCommon import msvc_exists, msvc_setup_env_once from SCons.Defaults import processDefines +from SCons.compat import PICKLE_PROTOCOL ############################################################################## # Below here are the classes and functions for generation of @@ -641,10 +642,10 @@ class _GenerateV6DSP(_DSPGenerator): if self.nokeep == 0: # now we pickle some data and add it to the file -- MSDEV will ignore it. - pdata = pickle.dumps(self.configs,1) + pdata = pickle.dumps(self.configs,PICKLE_PROTOCOL) pdata = base64.encodestring(pdata) self.file.write(pdata + '\n') - pdata = pickle.dumps(self.sources,1) + pdata = pickle.dumps(self.sources,PICKLE_PROTOCOL) pdata = base64.encodestring(pdata) self.file.write(pdata + '\n') @@ -913,10 +914,10 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User): if self.nokeep == 0: # now we pickle some data and add it to the file -- MSDEV will ignore it. - pdata = pickle.dumps(self.configs,1) + pdata = pickle.dumps(self.configs,PICKLE_PROTOCOL) pdata = base64.encodestring(pdata) self.file.write('\n') @@ -1232,10 +1233,10 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): if self.nokeep == 0: # now we pickle some data and add it to the file -- MSDEV will ignore it. - pdata = pickle.dumps(self.configs,1) + pdata = pickle.dumps(self.configs,PICKLE_PROTOCOL) pdata = base64.encodestring(pdata) self.file.write('\n') @@ -1606,7 +1607,7 @@ class _GenerateV7DSW(_DSWGenerator): '\tEndGlobalSection\n') self.file.write('EndGlobal\n') if self.nokeep == 0: - pdata = pickle.dumps(self.configs,1) + pdata = pickle.dumps(self.configs,PICKLE_PROTOCOL) pdata = base64.encodestring(pdata) self.file.write(pdata + '\n') diff --git a/src/engine/SCons/compat/__init__.py b/src/engine/SCons/compat/__init__.py index 6f20b73..9a911f7 100644 --- a/src/engine/SCons/compat/__init__.py +++ b/src/engine/SCons/compat/__init__.py @@ -88,6 +88,11 @@ def rename_module(new, old): # In 3.x, 'pickle' automatically loads the fast version if available. rename_module('pickle', 'cPickle') +# Default pickle protocol. Higher protocols are more efficient/featureful +# but incompatible with older Python versions. On Python 2.7 this is 2. +# Negative numbers choose the highest available protocol. +PICKLE_PROTOCOL=-1 + # TODO: FIXME # In 3.x, 'profile' automatically loads the fast version if available. rename_module('profile', 'cProfile') diff --git a/src/engine/SCons/dblite.py b/src/engine/SCons/dblite.py index b12d320..c32f494 100644 --- a/src/engine/SCons/dblite.py +++ b/src/engine/SCons/dblite.py @@ -4,6 +4,8 @@ from __future__ import print_function import SCons.compat +from SCons.compat import PICKLE_PROTOCOL + import os import pickle import shutil @@ -119,7 +121,7 @@ class dblite(object): def sync(self): self._check_writable() f = self._open(self._tmp_name, "wb", self._mode) - self._pickle_dump(self._dict, f, 1) + self._pickle_dump(self._dict, f, PICKLE_PROTOCOL) f.close() # Windows doesn't allow renaming if the file exists, so unlink # it first, chmod'ing it to make sure we can do so. On UNIX, we -- cgit v0.12 From b10a8e66e04ed191b27c8d7d33040deabe255714 Mon Sep 17 00:00:00 2001 From: Daniel Holth Date: Tue, 21 Jun 2016 01:06:22 +0000 Subject: CHANGES.txt edited --- src/CHANGES.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index db52cf0..4cf2100 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -15,7 +15,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER metaclass on PyPy); wrap most-used open() calls in 'with' statements to avoid too many open files. - Add __main__.py for `python -m SCons` in case it is on PYTHONPATH. - +  - Always use highest available pickle protocol for efficiency. + From Paweł Tomulik: - Fixed the issue with LDMODULEVERSIONFLAGS reported by Tim Jennes (https://pairlist4.pair.net/pipermail/scons-users/2016-May/004893.html). -- cgit v0.12 From d8f891005dc3edc527e62fd06fa92feab94db61d Mon Sep 17 00:00:00 2001 From: Daniel Holth Date: Tue, 21 Jun 2016 12:24:43 +0000 Subject: use pickle.HIGHEST_PROTOCOL instead of -1 --- src/engine/SCons/compat/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/SCons/compat/__init__.py b/src/engine/SCons/compat/__init__.py index 9a911f7..c6c7214 100644 --- a/src/engine/SCons/compat/__init__.py +++ b/src/engine/SCons/compat/__init__.py @@ -91,7 +91,8 @@ rename_module('pickle', 'cPickle') # Default pickle protocol. Higher protocols are more efficient/featureful # but incompatible with older Python versions. On Python 2.7 this is 2. # Negative numbers choose the highest available protocol. -PICKLE_PROTOCOL=-1 +import pickle +PICKLE_PROTOCOL=pickle.HIGHEST_PROTOCOL # TODO: FIXME # In 3.x, 'profile' automatically loads the fast version if available. -- cgit v0.12 From 5a7b42144f99ff62bd4f2b81b47a038c415d61cf Mon Sep 17 00:00:00 2001 From: William Blevins Date: Wed, 10 Aug 2016 01:10:09 +0100 Subject: Updated QMTest fortran lib setup for versions GCC 5/6 (and higher*). --- QMTest/TestSCons.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index a515684..2d4df3a 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -977,7 +977,9 @@ SConscript( sconscript ) m = re.search('(gcc\s+version|gcc-Version)\s+(\d\.\d)', stderr) if m: gcc_version = m.group(2) - if re.match('4.[^0]', gcc_version): + if re.match('[5-9].\d', gcc_version): + libs = ['gfortran'] + elif re.match('4.[^0]', gcc_version): libs = ['gfortranbegin'] elif gcc_version in ('3.1', '4.0'): libs = ['frtbegin'] + libs -- cgit v0.12 From 2f3daaaff1ad6d5252e1583fd65b2a5fd4a95ca7 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Wed, 10 Aug 2016 01:19:17 +0100 Subject: Updated CHANGES.txt. --- src/CHANGES.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index db52cf0..3d86359 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -25,6 +25,9 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Added LoadableModule to the list of global functions (DefaultEnvironment builders). + From William Blevins: + - Updated Fortran-related tests to pass under GCC 5/6. + RELEASE 2.5.0 - Mon, 09 Apr 2016 11:27:42 -0700 From Dirk Baechle: -- cgit v0.12 From 5f7882c1ff04fdd3ef3cc44654a2a69911cb73f0 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Wed, 10 Aug 2016 12:42:01 +0100 Subject: Removed deprecate fortran lib handling. --- QMTest/TestSCons.py | 28 ---------------------------- test/Fortran/FORTRAN.py | 1 - test/VariantDir/VariantDir.py | 7 +++---- 3 files changed, 3 insertions(+), 33 deletions(-) diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index 2d4df3a..98b2f00 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -958,34 +958,6 @@ SConscript( sconscript ) # to use cygwin compilers on cmd.exe -> uncomment following line #Configure_lib = 'm' - def gccFortranLibs(self): - """Test which gcc Fortran startup libraries are required. - This should probably move into SCons itself, but is kind of hacky. - """ - if sys.platform.find('irix') != -1: - return ['ftn'] - - libs = ['g2c'] - cmd = ['gcc','-v'] - - try: - p = Popen(cmd, stdout=PIPE, stderr=PIPE) - stdout, stderr = p.communicate() - except: - return libs - - m = re.search('(gcc\s+version|gcc-Version)\s+(\d\.\d)', stderr) - if m: - gcc_version = m.group(2) - if re.match('[5-9].\d', gcc_version): - libs = ['gfortran'] - elif re.match('4.[^0]', gcc_version): - libs = ['gfortranbegin'] - elif gcc_version in ('3.1', '4.0'): - libs = ['frtbegin'] + libs - - return libs - def skip_if_not_msvc(self, check_platform=True): """ Check whether we are on a Windows platform and skip the test if not. This check can be omitted by setting diff --git a/test/Fortran/FORTRAN.py b/test/Fortran/FORTRAN.py index 4a2529c..9a01fa6 100644 --- a/test/Fortran/FORTRAN.py +++ b/test/Fortran/FORTRAN.py @@ -87,7 +87,6 @@ test.must_match('test08' + _exe, "This is a .FPP file.\n") fc = 'f77' f77 = test.detect_tool(fc) -FTN_LIB = test.gccFortranLibs() if f77: diff --git a/test/VariantDir/VariantDir.py b/test/VariantDir/VariantDir.py index 0092692..1b620bb 100644 --- a/test/VariantDir/VariantDir.py +++ b/test/VariantDir/VariantDir.py @@ -28,7 +28,6 @@ import TestSCons _exe = TestSCons._exe test = TestSCons.TestSCons() -fortran_runtime = test.gccFortranLibs() fortran = test.detect('FORTRAN') @@ -118,9 +117,9 @@ except: if fortran and env.Detect(fortran): env.Command(target='b2.f', source='b2.in', action=buildIt) - env.Clone(LIBS = %s).Program(target='bar2', source='b2.f') - env.Clone(LIBS = %s).Program(target='bar1', source='b1.f') -""" % (fortran_runtime, fortran_runtime)) + env.Clone().Program(target='bar2', source='b2.f') + env.Clone().Program(target='bar1', source='b1.f') +""") test.write(['work1', 'src', 'f1.c'], r""" #include -- cgit v0.12 From d5d59de27b9d27649694e3fdca2737ca923550be Mon Sep 17 00:00:00 2001 From: William Blevins Date: Thu, 11 Aug 2016 18:02:10 +0100 Subject: Issue 1924: Updated D Language scanner support. Meets DLang specification 2.071.1 accessed 11 August 2016. URL: https://dlang.org/spec/module.html ImportDeclaration: import ImportList ; static import ImportList ; ImportList: Import ImportBindings Import , ImportList Import: ModuleFullyQualifiedName ModuleAliasIdentifier = ModuleFullyQualifiedName ImportBindings: Import : ImportBindList ImportBindList: ImportBind ImportBind , ImportBindList ImportBind: Identifier Identifier = Identifier ModuleAliasIdentifier: Identifier --- src/engine/SCons/Scanner/D.py | 16 +-- src/engine/SCons/Scanner/DTests.py | 271 +++++++++++++++++++++++++++++++++++++ 2 files changed, 279 insertions(+), 8 deletions(-) create mode 100644 src/engine/SCons/Scanner/DTests.py diff --git a/src/engine/SCons/Scanner/D.py b/src/engine/SCons/Scanner/D.py index 9402ed1..95496d5 100644 --- a/src/engine/SCons/Scanner/D.py +++ b/src/engine/SCons/Scanner/D.py @@ -32,8 +32,6 @@ Coded by Andy Friesen __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import re - import SCons.Scanner def DScanner(): @@ -43,13 +41,13 @@ def DScanner(): class D(SCons.Scanner.Classic): def __init__ (self): - SCons.Scanner.Classic.__init__ (self, + SCons.Scanner.Classic.__init__ ( + self, name = "DScanner", suffixes = '$DSUFFIXES', path_variable = 'DPATH', - regex = 'import\s+(?:[a-zA-Z0-9_.]+)\s*(?:,\s*(?:[a-zA-Z0-9_.]+)\s*)*;') - - self.cre2 = re.compile ('(?:import\s)?\s*([a-zA-Z0-9_.]+)\s*(?:,|;)', re.M) + regex = '(?:import\s+)([\w\s=,.]+)(?:\s*:[\s\w,=]+)?(?:;)' + ) def find_include(self, include, source_dir, path): # translate dots (package separators) to slashes @@ -62,8 +60,10 @@ class D(SCons.Scanner.Classic): def find_include_names(self, node): includes = [] - for i in self.cre.findall(node.get_text_contents()): - includes = includes + self.cre2.findall(i) + for iii in self.cre.findall(node.get_text_contents()): + for jjj in iii.split(','): + kkk = jjj.split('=')[-1] + includes.append(kkk.strip()) return includes # Local Variables: diff --git a/src/engine/SCons/Scanner/DTests.py b/src/engine/SCons/Scanner/DTests.py new file mode 100644 index 0000000..c644e95 --- /dev/null +++ b/src/engine/SCons/Scanner/DTests.py @@ -0,0 +1,271 @@ +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import unittest + +import TestCmd +import TestUnit + +import SCons.Scanner.D + +test = TestCmd.TestCmd(workdir = '') + +import collections +import os + +class DummyEnvironment(collections.UserDict): + def __init__(self, **kw): + collections.UserDict.__init__(self) + self.data.update(kw) + self.fs = SCons.Node.FS.FS(test.workpath('')) + + def Dictionary(self, *args): + return self.data + + def subst(self, strSubst, target=None, source=None, conv=None): + if strSubst[0] == '$': + return self.data[strSubst[1:]] + return strSubst + + def subst_list(self, strSubst, target=None, source=None, conv=None): + if strSubst[0] == '$': + return [self.data[strSubst[1:]]] + return [[strSubst]] + + def subst_path(self, path, target=None, source=None, conv=None): + if not isinstance(path, list): + path = [path] + return list(map(self.subst, path)) + + def get_calculator(self): + return None + + def get_factory(self, factory): + return factory or self.fs.File + + def Dir(self, filename): + return self.fs.Dir(filename) + + def File(self, filename): + return self.fs.File(filename) + +if os.path.normcase('foo') == os.path.normcase('FOO'): + my_normpath = os.path.normcase +else: + my_normpath = os.path.normpath + +def deps_match(self, deps, headers): + global my_normpath + scanned = list(map(my_normpath, list(map(str, deps)))) + expect = list(map(my_normpath, headers)) + self.failUnless(scanned == expect, "expect %s != scanned %s" % (expect, scanned)) + +""" +Examples from https://dlang.org/spec/module.html + +D Language: 2.071.1 +Accessed: 11 August 2016 +""" + +# Regular import +test.write('basic.d',""" +import A; + +void main() {} +""") + +# Static import +test.write('static.d',""" +static import A; + +void main() +{ + std.stdio.writeln("hello!"); // ok, writeln is fully qualified +} +""") + +# Public import +test.write('public.d',""" +public import A; + +void main() {} +""") + +# Renamed import +test.write('rename.d',""" +import B = A; + +void main() +{ + io.writeln("hello!"); // ok, calls std.stdio.writeln +} +""") + +# Selective import +test.write('selective.d',""" +import A : B, C = D; + +void main() +{ + writeln("hello!"); // ok, writeln bound into current namespace + foo("world"); // ok, calls std.stdio.write() +} +""") + +# Renamed and Selective import +test.write('renameAndSelective.d',""" +import B = A : C = D; + +void main() +{ +} +""") + +# Scoped import +test.write('scoped.d',""" +void main() +{ + import A; +} +""") + +# Combinatorial import +test.write('combinatorial.d',""" +import A, B, CCC = C, DDD = D : EEE = FFF; + +void main() +{ +} +""") + +# Subdirs import +test.write('subdirs.d',""" +import X.Y, X.Z, X.X.X; + +void main() {} +""") + +# Multiple import +test.write('multiple.d',""" +public import B; +static import C; + +import X = X.Y : Q, R, S, T = U; +void main() +{ + import A; +} +""") + +test.write('A.d',""" +module A; +void main() {} +""") + +test.write('B.d',""" +module B; +void main() {} +""") + +test.write('C.d',""" +module C; +void main() {} +""") + +test.write('D.d',""" +module D; +void main() {} +""") + +test.subdir('X', os.path.join('X','X')) + +test.write(os.path.join('X','Y.d'),""" +module Y; +void main() {} +""") + +test.write(os.path.join('X','Z.d'),""" +module Z; +void main() {} +""") + +test.write(os.path.join('X','X','X.d'),""" +module X; +void main() {} +""") + +class DScannerTestCase(unittest.TestCase): + def helper(self, filename, headers): + env = DummyEnvironment() + s = SCons.Scanner.D.DScanner() + path = s.path(env) + deps = s(env.File(filename), env, path) + deps_match(self, deps, headers) + + def test_BasicImport(self): + self.helper('basic.d', ['A.d']) + + def test_StaticImport(self): + self.helper('static.d', ['A.d']) + + def test_publicImport(self): + self.helper('public.d', ['A.d']) + + def test_RenameImport(self): + self.helper('rename.d', ['A.d']) + + def test_SelectiveImport(self): + self.helper('selective.d', ['A.d']) + + def test_RenameAndSelectiveImport(self): + self.helper('renameAndSelective.d', ['A.d']) + + def test_ScopedImport(self): + self.helper('scoped.d', ['A.d']) + + def test_CombinatorialImport(self): + self.helper('combinatorial.d', ['A.d', 'B.d', 'C.d', 'D.d']) + + def test_SubdirsImport(self): + self.helper('subdirs.d', [os.path.join('X','X','X.d'), os.path.join('X','Y.d'), os.path.join('X','Z.d')]) + + def test_MultipleImport(self): + self.helper('multiple.d', ['A.d', 'B.d', 'C.d', os.path.join('X','Y.d')]) + +if __name__ == "__main__": + suite = unittest.TestSuite() + tclasses = [ + DScannerTestCase, + ] + for tclass in tclasses: + names = unittest.getTestCaseNames(tclass, 'test_') + suite.addTests(list(map(tclass, names))) + TestUnit.run(suite) + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: -- cgit v0.12 From 4daf33934df9ae29e01037ab4646bcbae80a5e2d Mon Sep 17 00:00:00 2001 From: William Blevins Date: Thu, 11 Aug 2016 18:29:45 +0100 Subject: Updated CHANGES.txt --- src/CHANGES.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index db52cf0..28343a6 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -25,6 +25,10 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Added LoadableModule to the list of global functions (DefaultEnvironment builders). + From William Blevins: + - Updated D language scanner support to latest: 2.071.1. (PR #1924) + https://dlang.org/spec/module.html accessed 11 August 2016 + RELEASE 2.5.0 - Mon, 09 Apr 2016 11:27:42 -0700 From Dirk Baechle: -- cgit v0.12 From 65ff75bf1a44beaa4961af9ef6379c84aeb63a62 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Fri, 12 Aug 2016 16:05:28 +0100 Subject: Added multiline support test. --- src/engine/SCons/Scanner/DTests.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/engine/SCons/Scanner/DTests.py b/src/engine/SCons/Scanner/DTests.py index c644e95..805508d 100644 --- a/src/engine/SCons/Scanner/DTests.py +++ b/src/engine/SCons/Scanner/DTests.py @@ -179,6 +179,14 @@ void main() } """) +# Multiline import +test.write('multiline.d',""" +import +A; + +void main() {} +""") + test.write('A.d',""" module A; void main() {} @@ -254,6 +262,9 @@ class DScannerTestCase(unittest.TestCase): def test_MultipleImport(self): self.helper('multiple.d', ['A.d', 'B.d', 'C.d', os.path.join('X','Y.d')]) + def test_MultilineImport(self): + self.helper('multiline.d', ['A.d']) + if __name__ == "__main__": suite = unittest.TestSuite() tclasses = [ -- cgit v0.12 From 05f53e20938706a5bfbff65c82d4820374daa829 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Fri, 12 Aug 2016 16:10:40 +0100 Subject: Updated change notes to be explicit with regards to selective and renamed imports support. --- src/CHANGES.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 28343a6..09271f5 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -28,6 +28,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER From William Blevins: - Updated D language scanner support to latest: 2.071.1. (PR #1924) https://dlang.org/spec/module.html accessed 11 August 2016 + - Added support for selective imports. + - Added support for renamed imports. RELEASE 2.5.0 - Mon, 09 Apr 2016 11:27:42 -0700 -- cgit v0.12 From 70fd8bc246d6453d3da36cbd69f563a59b63c487 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Fri, 12 Aug 2016 16:25:46 +0100 Subject: Added change disclaimer of possible rebuild in Dlang projects after upgrade. --- src/CHANGES.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 09271f5..80ffc6b 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -28,8 +28,12 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER From William Blevins: - Updated D language scanner support to latest: 2.071.1. (PR #1924) https://dlang.org/spec/module.html accessed 11 August 2016 - - Added support for selective imports. - - Added support for renamed imports. + - Enhancements: + - Added support for selective imports. + - Added support for renamed imports. + - Notes: + - May find new (previously missed) Dlang dependencies. + - May cause rebuild after upgrade due to dependency changes. RELEASE 2.5.0 - Mon, 09 Apr 2016 11:27:42 -0700 -- cgit v0.12 From 944226d3beb4b158e4e55b577f46d99e63ca41f8 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Fri, 12 Aug 2016 16:35:48 +0100 Subject: Updated selective test to remove impurity from a selection rename. --- src/engine/SCons/Scanner/DTests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/Scanner/DTests.py b/src/engine/SCons/Scanner/DTests.py index 805508d..51e527a 100644 --- a/src/engine/SCons/Scanner/DTests.py +++ b/src/engine/SCons/Scanner/DTests.py @@ -125,7 +125,7 @@ void main() # Selective import test.write('selective.d',""" -import A : B, C = D; +import A : B, C; void main() { -- cgit v0.12 From 59d3af904b80f672a3719653e30cff72f1a7a44c Mon Sep 17 00:00:00 2001 From: William Blevins Date: Sat, 13 Aug 2016 20:48:31 +0100 Subject: Added additional support examples to the changes.txt. --- src/CHANGES.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 80ffc6b..648027b 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -29,8 +29,9 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Updated D language scanner support to latest: 2.071.1. (PR #1924) https://dlang.org/spec/module.html accessed 11 August 2016 - Enhancements: - - Added support for selective imports. - - Added support for renamed imports. + - Added support for selective imports: "import A : B, C;" -> A + - Added support for renamed imports. "import B = A;" -> A + - Supports valid combinations: "A, B, CCC = C, DDD = D : EEE = FFF;" -> A, B, C, D - Notes: - May find new (previously missed) Dlang dependencies. - May cause rebuild after upgrade due to dependency changes. -- cgit v0.12 From 52815bb68d058b12288a4f05fc3b7051d520a89c Mon Sep 17 00:00:00 2001 From: William Blevins Date: Sat, 13 Aug 2016 20:58:53 +0100 Subject: Updated example text for clarity. --- src/CHANGES.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 648027b..f032d93 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -31,7 +31,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Enhancements: - Added support for selective imports: "import A : B, C;" -> A - Added support for renamed imports. "import B = A;" -> A - - Supports valid combinations: "A, B, CCC = C, DDD = D : EEE = FFF;" -> A, B, C, D + - Supports valid combinations: "import A, B, CCC = C, DDD = D : EEE = FFF;" -> A, B, C, D - Notes: - May find new (previously missed) Dlang dependencies. - May cause rebuild after upgrade due to dependency changes. -- cgit v0.12 From c9a335d6bed101757540429c314e227c9d119486 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 18 Aug 2016 16:30:22 -0700 Subject: fix typo in Decider documentation. --- src/engine/SCons/Environment.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/SCons/Environment.xml b/src/engine/SCons/Environment.xml index b90f1d8..65d71ff 100644 --- a/src/engine/SCons/Environment.xml +++ b/src/engine/SCons/Environment.xml @@ -1100,7 +1100,7 @@ timestamp, such as can happen when restoring files from backup archives. Specifies that a target shall be considered out of date and rebuilt -if the dependency's content has changed sine the last time +if the dependency's content has changed since the last time the target was built, as determined be performing an MD5 checksum on the dependency's contents @@ -1117,7 +1117,7 @@ can be used as a synonym for Specifies that a target shall be considered out of date and rebuilt -if the dependency's content has changed sine the last time +if the dependency's content has changed since the last time the target was built, except that dependencies with a timestamp that matches the last time the target was rebuilt will be -- cgit v0.12 From 8df60cf25428207781fda6ad66c06325556a09a0 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Sun, 18 Sep 2016 00:19:52 -0400 Subject: Sorting RPM tarball sources to correct nondeterminism in ordering. --- src/engine/SCons/Tool/packaging/rpm.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/engine/SCons/Tool/packaging/rpm.py b/src/engine/SCons/Tool/packaging/rpm.py index a132555..99124ed 100644 --- a/src/engine/SCons/Tool/packaging/rpm.py +++ b/src/engine/SCons/Tool/packaging/rpm.py @@ -95,6 +95,8 @@ def collectintargz(target, source, env): # find the .spec file for rpm and add it since it is not necessarily found # by the FindSourceFiles function. sources.extend( [s for s in source if str(s).rfind('.spec')!=-1] ) + # sort to keep sources from changing order across builds + sources.sort() # as the source contains the url of the source package this rpm package # is built from, we extract the target name -- cgit v0.12 From 43448eba072c9638416004986a10836df4d70d90 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Sun, 18 Sep 2016 16:20:21 -0400 Subject: Updated CHANGES.TXT. --- src/CHANGES.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 69fb621..4ae9cb2 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -43,6 +43,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - May find new (previously missed) Dlang dependencies. - May cause rebuild after upgrade due to dependency changes. - Updated Fortran-related tests to pass under GCC 5/6. + - Fixed SCons.Tool.Packaging.rpm.package source nondeterminism across builds. RELEASE 2.5.0 - Mon, 09 Apr 2016 11:27:42 -0700 -- cgit v0.12 From 804fc90e41588c3cbb2eadb58c3120dbcdf0c7b1 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Mon, 19 Sep 2016 22:33:12 -0400 Subject: Caching a pickle protocol in the dblite class. Access to SCons.compat is not available. --- src/engine/SCons/dblite.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/engine/SCons/dblite.py b/src/engine/SCons/dblite.py index c32f494..9ece011 100644 --- a/src/engine/SCons/dblite.py +++ b/src/engine/SCons/dblite.py @@ -2,10 +2,6 @@ # Extended for Unicode by Steven Knight. from __future__ import print_function -import SCons.compat - -from SCons.compat import PICKLE_PROTOCOL - import os import pickle import shutil @@ -50,6 +46,7 @@ class dblite(object): _open = open _pickle_dump = staticmethod(pickle.dump) + _pickle_protocol = pickle.HIGHEST_PROTOCOL _os_chmod = os.chmod try: _os_chown = os.chown @@ -121,7 +118,7 @@ class dblite(object): def sync(self): self._check_writable() f = self._open(self._tmp_name, "wb", self._mode) - self._pickle_dump(self._dict, f, PICKLE_PROTOCOL) + self._pickle_dump(self._dict, f, self._pickle_protocol) f.close() # Windows doesn't allow renaming if the file exists, so unlink # it first, chmod'ing it to make sure we can do so. On UNIX, we -- cgit v0.12 From 2e74f8c28a15f64bad8429ebece227db285f07dc Mon Sep 17 00:00:00 2001 From: William Blevins Date: Mon, 19 Sep 2016 22:52:01 -0400 Subject: Work around src/engine/SCons/SConfTests.py failing without decentralizing pickle protocal variable. --- src/engine/SCons/dblite.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/engine/SCons/dblite.py b/src/engine/SCons/dblite.py index 9ece011..588a7ab 100644 --- a/src/engine/SCons/dblite.py +++ b/src/engine/SCons/dblite.py @@ -7,6 +7,8 @@ import pickle import shutil import time +from SCons.compat import PICKLE_PROTOCOL + keep_all_files = 00000 ignore_corrupt_dbfiles = 0 @@ -46,7 +48,7 @@ class dblite(object): _open = open _pickle_dump = staticmethod(pickle.dump) - _pickle_protocol = pickle.HIGHEST_PROTOCOL + _pickle_protocol = PICKLE_PROTOCOL _os_chmod = os.chmod try: _os_chown = os.chown -- cgit v0.12 From 226c34a47471c5c27bc9a0c262edd62d713acc81 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Tue, 20 Sep 2016 15:05:06 -0400 Subject: Futurize stage 2 2to3 fixes only. --- QMTest/TestSCons.py | 6 +- QMTest/scons_tdb.py | 2 +- bench/bench.py | 2 +- bin/SConsDoc.py | 2 +- bin/SConsExamples.py | 4 +- bin/caller-tree.py | 2 +- bin/memoicmp.py | 8 +- bin/objcounts.py | 4 +- bin/scons-diff.py | 2 +- bin/scons-proc.py | 2 +- src/engine/SCons/Action.py | 6 +- src/engine/SCons/ActionTests.py | 6 +- src/engine/SCons/Builder.py | 2 +- src/engine/SCons/BuilderTests.py | 4 +- src/engine/SCons/Debug.py | 4 +- src/engine/SCons/Defaults.py | 2 +- src/engine/SCons/Environment.py | 34 +-- src/engine/SCons/EnvironmentTests.py | 2 +- src/engine/SCons/Node/Alias.py | 2 +- src/engine/SCons/Node/FS.py | 8 +- src/engine/SCons/Node/Python.py | 2 +- src/engine/SCons/Node/__init__.py | 16 +- src/engine/SCons/SConf.py | 4 +- src/engine/SCons/SConsign.py | 10 +- src/engine/SCons/Scanner/LaTeX.py | 4 +- src/engine/SCons/Script/Interactive.py | 4 +- src/engine/SCons/Script/Main.py | 2 +- src/engine/SCons/Script/SConsOptions.py | 2 +- src/engine/SCons/Script/SConscript.py | 2 +- src/engine/SCons/Taskmaster.py | 2 +- src/engine/SCons/Tool/MSCommon/common.py | 4 +- src/engine/SCons/Tool/MSCommon/vc.py | 2 +- src/engine/SCons/Tool/MSCommon/vs.py | 2 +- src/engine/SCons/Tool/aixlink.py | 2 +- src/engine/SCons/Tool/docbook/__init__.py | 2 +- src/engine/SCons/Tool/gnulink.py | 2 +- src/engine/SCons/Tool/install.py | 2 +- src/engine/SCons/Tool/intelc.py | 4 +- src/engine/SCons/Tool/msvs.py | 26 +-- src/engine/SCons/Tool/msvsTests.py | 10 +- src/engine/SCons/Tool/packaging/__init__.py | 2 +- src/engine/SCons/Tool/packaging/ipk.py | 2 +- src/engine/SCons/Tool/packaging/msi.py | 6 +- src/engine/SCons/Tool/packaging/rpm.py | 4 +- src/engine/SCons/Tool/rpmutils.py | 2 +- src/engine/SCons/Util.py | 6 +- src/engine/SCons/Variables/EnumVariableTests.py | 4 +- src/engine/SCons/Variables/__init__.py | 2 +- src/engine/SCons/cpp.py | 8 +- src/script/scons-configure-cache.py | 276 ++++++++++++------------ src/script/scons-time.py | 4 +- src/test_files.py | 2 +- src/test_interrupts.py | 2 +- test/AS/nasm.py | 2 +- test/QT/QTFLAGS.py | 2 +- 55 files changed, 266 insertions(+), 266 deletions(-) diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index 98b2f00..0d5dc90 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -1233,7 +1233,7 @@ class TimeSCons(TestSCons): self.variables = kw.get('variables') default_calibrate_variables = [] if self.variables is not None: - for variable, value in self.variables.items(): + for variable, value in list(self.variables.items()): value = os.environ.get(variable, value) try: value = int(value) @@ -1289,7 +1289,7 @@ class TimeSCons(TestSCons): """ if 'options' not in kw and self.variables: options = [] - for variable, value in self.variables.items(): + for variable, value in list(self.variables.items()): options.append('%s=%s' % (variable, value)) kw['options'] = ' '.join(options) if self.calibrate: @@ -1315,7 +1315,7 @@ class TimeSCons(TestSCons): self.elapsed_time(), "seconds", sort=0) - for name, args in stats.items(): + for name, args in list(stats.items()): self.trace(name, trace, **args) def uptime(self): diff --git a/QMTest/scons_tdb.py b/QMTest/scons_tdb.py index 76c7fe1..f5c0ae5 100644 --- a/QMTest/scons_tdb.py +++ b/QMTest/scons_tdb.py @@ -92,7 +92,7 @@ def get_explicit_arguments(e): # Determine which subset of the 'arguments' have been set # explicitly. explicit_arguments = {} - for name, field in arguments.items(): + for name, field in list(arguments.items()): # Do not record computed fields. if field.IsComputed(): continue diff --git a/bench/bench.py b/bench/bench.py index f1d18c6..cfdac2d 100644 --- a/bench/bench.py +++ b/bench/bench.py @@ -94,7 +94,7 @@ exec(open(args[0], 'rU').read()) try: FunctionList except NameError: - function_names = sorted([x for x in locals().keys() if x[:4] == FunctionPrefix]) + function_names = sorted([x for x in list(locals().keys()) if x[:4] == FunctionPrefix]) l = [locals()[f] for f in function_names] FunctionList = [f for f in l if isinstance(f, types.FunctionType)] diff --git a/bin/SConsDoc.py b/bin/SConsDoc.py index d566644..2fe4f73 100644 --- a/bin/SConsDoc.py +++ b/bin/SConsDoc.py @@ -598,7 +598,7 @@ class SConsDocTree: # Create xpath context self.xpath_context = self.doc.xpathNewContext() # Register namespaces - for key, val in self.nsmap.items(): + for key, val in list(self.nsmap.items()): self.xpath_context.xpathRegisterNs(key, val) def __del__(self): diff --git a/bin/SConsExamples.py b/bin/SConsExamples.py index dd9bfaf..a86968d 100644 --- a/bin/SConsExamples.py +++ b/bin/SConsExamples.py @@ -267,7 +267,7 @@ def ensureExampleOutputsExist(dpath): os.mkdir(generated_examples) examples = readAllExampleInfos(dpath) - for key, value in examples.items(): + for key, value in list(examples.items()): # Process all scons_output tags for o in value.outputs: cpath = os.path.join(generated_examples, @@ -305,7 +305,7 @@ def createAllExampleOutputs(dpath): examples = readAllExampleInfos(dpath) total = len(examples) idx = 0 - for key, value in examples.items(): + for key, value in list(examples.items()): # Process all scons_output tags print("%.2f%s (%d/%d) %s" % (float(idx + 1) * 100.0 / float(total), perc, idx + 1, total, key)) diff --git a/bin/caller-tree.py b/bin/caller-tree.py index 21cda4b..18cd9e1 100644 --- a/bin/caller-tree.py +++ b/bin/caller-tree.py @@ -87,7 +87,7 @@ def print_entry(e, level, calls): else: print() -for e in [ e for e in AllCalls.values() if not e.calls ]: +for e in [ e for e in list(AllCalls.values()) if not e.calls ]: print_entry(e, 0, '') # Local Variables: diff --git a/bin/memoicmp.py b/bin/memoicmp.py index 7f0369e..63f6538 100644 --- a/bin/memoicmp.py +++ b/bin/memoicmp.py @@ -31,14 +31,14 @@ def memoize_cmp(filea, fileb): ma_o = [] mb_o = [] mab = [] - for k in ma.keys(): - if k in mb.keys(): + for k in list(ma.keys()): + if k in list(mb.keys()): if k not in mab: mab.append(k) else: ma_o.append(k) - for k in mb.keys(): - if k in ma.keys(): + for k in list(mb.keys()): + if k in list(ma.keys()): if k not in mab: mab.append(k) else: diff --git a/bin/objcounts.py b/bin/objcounts.py index 2bd8923..8b550d1 100644 --- a/bin/objcounts.py +++ b/bin/objcounts.py @@ -48,7 +48,7 @@ c1 = fetch_counts(sys.argv[1]) c2 = fetch_counts(sys.argv[2]) common = {} -for k in c1.keys(): +for k in list(c1.keys()): try: common[k] = (c1[k], c2[k]) except KeyError: @@ -59,7 +59,7 @@ for k in c1.keys(): if not '.' in k: s = '.'+k l = len(s) - for k2 in c2.keys(): + for k2 in list(c2.keys()): if k2[-l:] == s: common[k2] = (c1[k], c2[k2]) del c1[k] diff --git a/bin/scons-diff.py b/bin/scons-diff.py index 8597501..687e7fa 100644 --- a/bin/scons-diff.py +++ b/bin/scons-diff.py @@ -174,7 +174,7 @@ def diff_dir(left, right): u[l] = 1 for r in rlist: u[r] = 1 - for x in sorted([ x for x in u.keys() if x[-4:] != '.pyc' ]): + for x in sorted([ x for x in list(u.keys()) if x[-4:] != '.pyc' ]): if x in llist: if x in rlist: do_diff(os.path.join(left, x), diff --git a/bin/scons-proc.py b/bin/scons-proc.py index e09c853..0747b2c 100644 --- a/bin/scons-proc.py +++ b/bin/scons-proc.py @@ -104,7 +104,7 @@ Link_Entities_Header = """\ class SCons_XML(object): def __init__(self, entries, **kw): self.values = entries - for k, v in kw.items(): + for k, v in list(kw.items()): setattr(self, k, v) def fopen(self, name): diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index 7e1f8f1..de9bf5c 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -645,7 +645,7 @@ def _subproc(scons_env, cmd, error = 'ignore', **kw): # Ensure that the ENV values are all strings: new_env = {} - for key, value in ENV.items(): + for key, value in list(ENV.items()): if is_List(value): # If the value is a list, then we assume it is a path list, # because that's a pretty common list-like value to stick @@ -772,7 +772,7 @@ class CommandAction(_ActionAction): ENV = get_default_ENV(env) # Ensure that the ENV values are all strings: - for key, value in ENV.items(): + for key, value in list(ENV.items()): if not is_String(value): if is_List(value): # If the value is a list, then we assume it is a @@ -1206,7 +1206,7 @@ class ActionCaller(object): def subst_kw(self, target, source, env): kw = {} - for key in self.kw.keys(): + for key in list(self.kw.keys()): kw[key] = self.subst(self.kw[key], target, source, env) return kw diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py index 9007183..b790ccc 100644 --- a/src/engine/SCons/ActionTests.py +++ b/src/engine/SCons/ActionTests.py @@ -132,7 +132,7 @@ class Environment(object): self.d['SPAWN'] = scons_env['SPAWN'] self.d['PSPAWN'] = scons_env['PSPAWN'] self.d['ESCAPE'] = scons_env['ESCAPE'] - for k, v in kw.items(): + for k, v in list(kw.items()): self.d[k] = v # Just use the underlying scons_subst*() utility methods. def subst(self, strSubst, raw=0, target=[], source=[], conv=None): @@ -157,12 +157,12 @@ class Environment(object): def Clone(self, **kw): res = Environment() res.d = SCons.Util.semi_deepcopy(self.d) - for k, v in kw.items(): + for k, v in list(kw.items()): res.d[k] = v return res def sig_dict(self): d = {} - for k,v in self.items(): d[k] = v + for k,v in list(self.items()): d[k] = v d['TARGETS'] = ['__t1__', '__t2__', '__t3__', '__t4__', '__t5__', '__t6__'] d['TARGET'] = d['TARGETS'][0] d['SOURCES'] = ['__s1__', '__s2__', '__s3__', '__s4__', '__s5__', '__s6__'] diff --git a/src/engine/SCons/Builder.py b/src/engine/SCons/Builder.py index 50e85ec..c7bce3a 100644 --- a/src/engine/SCons/Builder.py +++ b/src/engine/SCons/Builder.py @@ -229,7 +229,7 @@ class OverrideWarner(collections.UserDict): def warn(self): if self.already_warned: return - for k in self.keys(): + for k in list(self.keys()): if k in misleading_keywords: alt = misleading_keywords[k] msg = "Did you mean to use `%s' instead of `%s'?" % (alt, k) diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py index 1e544a1..ca35abc 100644 --- a/src/engine/SCons/BuilderTests.py +++ b/src/engine/SCons/BuilderTests.py @@ -79,7 +79,7 @@ class Environment(object): self.d['SHELL'] = scons_env['SHELL'] self.d['SPAWN'] = scons_env['SPAWN'] self.d['ESCAPE'] = scons_env['ESCAPE'] - for k, v in kw.items(): + for k, v in list(kw.items()): self.d[k] = v global env_arg2nodes_called env_arg2nodes_called = None @@ -140,7 +140,7 @@ class Environment(object): return list(self.d.items()) def sig_dict(self): d = {} - for k,v in self.items(): d[k] = v + for k,v in list(self.items()): d[k] = v d['TARGETS'] = ['__t1__', '__t2__', '__t3__', '__t4__', '__t5__', '__t6__'] d['TARGET'] = d['TARGETS'][0] d['SOURCES'] = ['__s1__', '__s2__', '__s3__', '__s4__', '__s5__', '__s6__'] diff --git a/src/engine/SCons/Debug.py b/src/engine/SCons/Debug.py index 9e520ff..6ac5f27 100644 --- a/src/engine/SCons/Debug.py +++ b/src/engine/SCons/Debug.py @@ -89,7 +89,7 @@ def dumpLoggedInstances(classes, file=sys.stdout): obj = ref() if obj is not None: file.write(' %s:\n' % obj) - for key, value in obj.__dict__.items(): + for key, value in list(obj.__dict__.items()): file.write(' %20s : %s\n' % (key, value)) @@ -163,7 +163,7 @@ def caller_trace(back=0): # print a single caller and its callers, if any def _dump_one_caller(key, file, level=0): leader = ' '*level - for v,c in sorted([(-v,c) for c,v in caller_dicts[key].items()]): + for v,c in sorted([(-v,c) for c,v in list(caller_dicts[key].items())]): file.write("%s %6d %s:%d(%s)\n" % ((leader,-v) + func_shorten(c[-3:]))) if c in caller_dicts: _dump_one_caller(c, file, level+1) diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py index f1d5bca..f095982 100644 --- a/src/engine/SCons/Defaults.py +++ b/src/engine/SCons/Defaults.py @@ -459,7 +459,7 @@ def processDefines(defs): else: l.append(str(d[0])) elif SCons.Util.is_Dict(d): - for macro,value in d.items(): + for macro,value in list(d.items()): if value is not None: l.append(str(macro) + '=' + str(value)) else: diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index d979005..ed8ef78 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -152,7 +152,7 @@ def _set_BUILDERS(env, key, value): except KeyError: bd = BuilderDict(kwbd, env) env._dict[key] = bd - for k, v in value.items(): + for k, v in list(value.items()): if not SCons.Builder.is_a_Builder(v): raise SCons.Errors.UserError('%s is not a Builder.' % repr(v)) bd.update(value) @@ -324,7 +324,7 @@ class BuilderDict(UserDict): delattr(self.env, item) def update(self, dict): - for i, v in dict.items(): + for i, v in list(dict.items()): self.__setitem__(i, v) @@ -515,7 +515,7 @@ class SubstitutionEnvironment(object): def subst_kw(self, kw, raw=0, target=None, source=None): nkw = {} - for k, v in kw.items(): + for k, v in list(kw.items()): k = self.subst(k, raw, target, source) if SCons.Util.is_String(v): v = self.subst(v, raw, target, source) @@ -627,7 +627,7 @@ class SubstitutionEnvironment(object): if not o: return self overrides = {} merges = None - for key, value in o.items(): + for key, value in list(o.items()): if key == 'parse_flags': merges = value else: @@ -815,7 +815,7 @@ class SubstitutionEnvironment(object): if not unique: self.Append(**args) return self - for key, value in args.items(): + for key, value in list(args.items()): if not value: continue try: @@ -984,7 +984,7 @@ class Base(SubstitutionEnvironment): # Now restore the passed-in and customized variables # to the environment, since the values the user set explicitly # should override any values set by the tools. - for key, val in save.items(): + for key, val in list(save.items()): self._dict[key] = val # Finally, apply any flags to be merged in @@ -1185,7 +1185,7 @@ class Base(SubstitutionEnvironment): if SCons.Util.is_List(val): if key == 'CPPDEFINES': tmp = [] - for (k, v) in orig.iteritems(): + for (k, v) in orig.items(): if v is not None: tmp.append((k, v)) else: @@ -1247,7 +1247,7 @@ class Base(SubstitutionEnvironment): values move to end. """ kw = copy_non_reserved_keywords(kw) - for key, val in kw.items(): + for key, val in list(kw.items()): if SCons.Util.is_List(val): val = _delete_duplicates(val, delete_existing) if key not in self._dict or self._dict[key] in ('', None): @@ -1273,7 +1273,7 @@ class Base(SubstitutionEnvironment): # Construct a list of (key, value) tuples. if SCons.Util.is_Dict(dk): tmp = [] - for (k, v) in dk.iteritems(): + for (k, v) in dk.items(): if v is not None: tmp.append((k, v)) else: @@ -1321,7 +1321,7 @@ class Base(SubstitutionEnvironment): # Construct a list of (key, value) tuples. if SCons.Util.is_Dict(val): tmp = [] - for (k, v) in val.iteritems(): + for (k, v) in val.items(): if v is not None: tmp.append((k, v)) else: @@ -1350,7 +1350,7 @@ class Base(SubstitutionEnvironment): dk = [dk] elif SCons.Util.is_Dict(dk): tmp = [] - for (k, v) in dk.iteritems(): + for (k, v) in dk.items(): if v is not None: tmp.append((k, v)) else: @@ -1363,7 +1363,7 @@ class Base(SubstitutionEnvironment): val = [val] elif SCons.Util.is_Dict(val): tmp = [] - for i,j in val.items(): + for i,j in list(val.items()): if j is not None: tmp.append((i,j)) else: @@ -1405,7 +1405,7 @@ class Base(SubstitutionEnvironment): # so the tools can use the new variables kw = copy_non_reserved_keywords(kw) new = {} - for key, value in kw.items(): + for key, value in list(kw.items()): new[key] = SCons.Subst.scons_subst_once(value, self, key) clone.Replace(**new) @@ -1605,7 +1605,7 @@ class Base(SubstitutionEnvironment): in an Environment. """ kw = copy_non_reserved_keywords(kw) - for key, val in kw.items(): + for key, val in list(kw.items()): # It would be easier on the eyes to write this using # "continue" statements whenever we finish processing an item, # but Python 1.5.2 apparently doesn't let you use "continue" @@ -1696,7 +1696,7 @@ class Base(SubstitutionEnvironment): values move to front. """ kw = copy_non_reserved_keywords(kw) - for key, val in kw.items(): + for key, val in list(kw.items()): if SCons.Util.is_List(val): val = _delete_duplicates(val, not delete_existing) if key not in self._dict or self._dict[key] in ('', None): @@ -1833,7 +1833,7 @@ class Base(SubstitutionEnvironment): uniq = {} for executor in [n.get_executor() for n in nodes]: uniq[executor] = 1 - for executor in uniq.keys(): + for executor in list(uniq.keys()): executor.add_pre_action(action) return nodes @@ -1843,7 +1843,7 @@ class Base(SubstitutionEnvironment): uniq = {} for executor in [n.get_executor() for n in nodes]: uniq[executor] = 1 - for executor in uniq.keys(): + for executor in list(uniq.keys()): executor.add_post_action(action) return nodes diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index 4b57763..e3259d4 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -164,7 +164,7 @@ class TestEnvironmentFixture(object): default_keys = { 'CC' : 'cc', 'CCFLAGS' : '-DNDEBUG', 'ENV' : { 'TMP' : '/tmp' } } - for key, value in default_keys.items(): + for key, value in list(default_keys.items()): if key not in kw: kw[key] = value if 'BUILDERS' not in kw: diff --git a/src/engine/SCons/Node/Alias.py b/src/engine/SCons/Node/Alias.py index a035816..f229a9f 100644 --- a/src/engine/SCons/Node/Alias.py +++ b/src/engine/SCons/Node/Alias.py @@ -89,7 +89,7 @@ class AliasNodeInfo(SCons.Node.NodeInfoBase): """ # TODO check or discard version del state['_version_id'] - for key, value in state.items(): + for key, value in list(state.items()): if key not in ('__weakref__',): setattr(self, key, value) diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 71511b5..9b7e105 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -1607,7 +1607,7 @@ class Dir(Base): This clears any cached information that is invalidated by changing the repository.""" - for node in self.entries.values(): + for node in list(self.entries.values()): if node != self.dir: if node != self and isinstance(node, Dir): node.__clearRepositoryCache(duplicate) @@ -2179,7 +2179,7 @@ class Dir(Base): for x in excludeList: r = self.glob(x, ondisk, source, strings) excludes.extend(r) - result = filter(lambda x: not any(fnmatch.fnmatch(str(x), str(e)) for e in SCons.Util.flatten(excludes)), result) + result = [x for x in result if not any(fnmatch.fnmatch(str(x), str(e)) for e in SCons.Util.flatten(excludes))] return sorted(result, key=lambda a: str(a)) def _glob1(self, pattern, ondisk=True, source=False, strings=False): @@ -2203,7 +2203,7 @@ class Dir(Base): # We use the .name attribute from the Node because the keys of # the dir.entries dictionary are normalized (that is, all upper # case) on case-insensitive systems like Windows. - node_names = [ v.name for k, v in dir.entries.items() + node_names = [ v.name for k, v in list(dir.entries.items()) if k not in ('.', '..') ] names.extend(node_names) if not strings: @@ -2481,7 +2481,7 @@ class FileNodeInfo(SCons.Node.NodeInfoBase): """ # TODO check or discard version del state['_version_id'] - for key, value in state.items(): + for key, value in list(state.items()): if key not in ('__weakref__',): setattr(self, key, value) diff --git a/src/engine/SCons/Node/Python.py b/src/engine/SCons/Node/Python.py index f151fc5..92cc320 100644 --- a/src/engine/SCons/Node/Python.py +++ b/src/engine/SCons/Node/Python.py @@ -67,7 +67,7 @@ class ValueNodeInfo(SCons.Node.NodeInfoBase): """ # TODO check or discard version del state['_version_id'] - for key, value in state.items(): + for key, value in list(state.items()): if key not in ('__weakref__',): setattr(self, key, value) diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 00ddf2f..2bf38c2 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -382,7 +382,7 @@ class NodeInfoBase(object): try: field_list = self.field_list except AttributeError: - field_list = getattr(self, '__dict__', {}).keys() + field_list = list(getattr(self, '__dict__', {}).keys()) for obj in type(self).mro(): for slot in getattr(obj, '__slots__', ()): if slot not in ('__weakref__', '__dict__'): @@ -427,7 +427,7 @@ class NodeInfoBase(object): # TODO check or discard version del state['_version_id'] - for key, value in state.items(): + for key, value in list(state.items()): if key not in ('__weakref__',): setattr(self, key, value) @@ -488,7 +488,7 @@ class BuildInfoBase(object): """ # TODO check or discard version del state['_version_id'] - for key, value in state.items(): + for key, value in list(state.items()): if key not in ('__weakref__',): setattr(self, key, value) @@ -1338,7 +1338,7 @@ class Node(object, with_metaclass(NoSlotsPyPy)): # dictionary patterns I found all ended up using "not in" # internally anyway...) if self.ignore_set: - iter = chain.from_iterable(filter(None, [self.sources, self.depends, self.implicit])) + iter = chain.from_iterable([_f for _f in [self.sources, self.depends, self.implicit] if _f]) children = [] for i in iter: @@ -1372,7 +1372,7 @@ class Node(object, with_metaclass(NoSlotsPyPy)): # using dictionary keys, lose the order, and the only ordered # dictionary patterns I found all ended up using "not in" # internally anyway...) - return list(chain.from_iterable(filter(None, [self.sources, self.depends, self.implicit]))) + return list(chain.from_iterable([_f for _f in [self.sources, self.depends, self.implicit] if _f])) def children(self, scan=1): """Return a list of the node's direct children, minus those @@ -1396,7 +1396,7 @@ class Node(object, with_metaclass(NoSlotsPyPy)): def Decider(self, function): foundkey = None - for k, v in _decider_map.iteritems(): + for k, v in _decider_map.items(): if v == function: foundkey = k break @@ -1609,8 +1609,8 @@ class Node(object, with_metaclass(NoSlotsPyPy)): new_bkids = new.bsources + new.bdepends + new.bimplicit new_bkidsigs = new.bsourcesigs + new.bdependsigs + new.bimplicitsigs - osig = dict(zip(old_bkids, old_bkidsigs)) - nsig = dict(zip(new_bkids, new_bkidsigs)) + osig = dict(list(zip(old_bkids, old_bkidsigs))) + nsig = dict(list(zip(new_bkids, new_bkidsigs))) # The sources and dependencies we'll want to report are all stored # as relative paths to this target's directory, but we want to diff --git a/src/engine/SCons/SConf.py b/src/engine/SCons/SConf.py index d56b333..c68d1c6 100644 --- a/src/engine/SCons/SConf.py +++ b/src/engine/SCons/SConf.py @@ -132,7 +132,7 @@ def CreateConfigHBuilder(env): _stringConfigH) sconfigHBld = SCons.Builder.Builder(action=action) env.Append( BUILDERS={'SConfigHBuilder':sconfigHBld} ) - for k in _ac_config_hs.keys(): + for k in list(_ac_config_hs.keys()): env.SConfigHBuilder(k, env.Value(_ac_config_hs[k])) @@ -671,7 +671,7 @@ class SConfBase(object): """Adds all the tests given in the tests dictionary to this SConf instance """ - for name in tests.keys(): + for name in list(tests.keys()): self.AddTest(name, tests[name]) def _createDir( self, node ): diff --git a/src/engine/SCons/SConsign.py b/src/engine/SCons/SConsign.py index 3a5e5c0..75d2c41 100644 --- a/src/engine/SCons/SConsign.py +++ b/src/engine/SCons/SConsign.py @@ -155,7 +155,7 @@ class SConsignEntry(object): return state def __setstate__(self, state): - for key, value in state.items(): + for key, value in list(state.items()): if key not in ('_version_id','__weakref__'): setattr(self, key, value) @@ -199,7 +199,7 @@ class Base(object): pass def merge(self): - for key, node in self.to_be_merged.items(): + for key, node in list(self.to_be_merged.items()): entry = node.get_stored_info() try: ninfo = entry.ninfo @@ -245,7 +245,7 @@ class DB(Base): except Exception as e: SCons.Warnings.warn(SCons.Warnings.CorruptSConsignWarning, "Ignoring corrupt sconsign entry : %s (%s)\n"%(self.dir.get_tpath(), e)) - for key, entry in self.entries.items(): + for key, entry in list(self.entries.items()): entry.convert_from_sconsign(dir, key) if mode == "r": @@ -272,7 +272,7 @@ class DB(Base): # the Repository; we only write to our own .sconsign file, # not to .sconsign files in Repositories. path = normcase(self.dir.get_internal_path()) - for key, entry in self.entries.items(): + for key, entry in list(self.entries.items()): entry.convert_to_sconsign() db[path] = pickle.dumps(self.entries, PICKLE_PROTOCOL) @@ -360,7 +360,7 @@ class DirFile(Dir): fname = self.sconsign except IOError: return - for key, entry in self.entries.items(): + for key, entry in list(self.entries.items()): entry.convert_to_sconsign() pickle.dump(self.entries, file, PICKLE_PROTOCOL) file.close() diff --git a/src/engine/SCons/Scanner/LaTeX.py b/src/engine/SCons/Scanner/LaTeX.py index 2cb1ed5..1e0fea1 100644 --- a/src/engine/SCons/Scanner/LaTeX.py +++ b/src/engine/SCons/Scanner/LaTeX.py @@ -200,14 +200,14 @@ class LaTeX(SCons.Scanner.Base): """ def __init__(self, dictionary): self.dictionary = {} - for k,n in dictionary.items(): + for k,n in list(dictionary.items()): self.dictionary[k] = ( SCons.Scanner.FindPathDirs(n), FindENVPathDirs(n) ) def __call__(self, env, dir=None, target=None, source=None, argument=None): di = {} - for k,(c,cENV) in self.dictionary.items(): + for k,(c,cENV) in list(self.dictionary.items()): di[k] = ( c(env, dir=None, target=None, source=None, argument=None) , cENV(env, dir=None, target=None, source=None, diff --git a/src/engine/SCons/Script/Interactive.py b/src/engine/SCons/Script/Interactive.py index e7a0658..3c3d23a 100644 --- a/src/engine/SCons/Script/Interactive.py +++ b/src/engine/SCons/Script/Interactive.py @@ -121,7 +121,7 @@ class SConsInteractiveCmd(cmd.Cmd): def __init__(self, **kw): cmd.Cmd.__init__(self) - for key, val in kw.items(): + for key, val in list(kw.items()): setattr(self, key, val) if sys.platform == 'win32': @@ -250,7 +250,7 @@ class SConsInteractiveCmd(cmd.Cmd): while n: n = walker.get_next() - for node in seen_nodes.keys(): + for node in list(seen_nodes.keys()): # Call node.clear() to clear most of the state node.clear() # node.clear() doesn't reset node.state, so call diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py index c0b22a7..f8cb24c 100644 --- a/src/engine/SCons/Script/Main.py +++ b/src/engine/SCons/Script/Main.py @@ -727,7 +727,7 @@ def _load_site_scons_dir(topdir, site_dir_name=None): modname = os.path.basename(pathname)[:-len(sfx)] site_m = {"__file__": pathname, "__name__": modname, "__doc__": None} re_special = re.compile("__[^_]+__") - for k in m.__dict__.keys(): + for k in list(m.__dict__.keys()): if not re_special.match(k): site_m[k] = m.__dict__[k] diff --git a/src/engine/SCons/Script/SConsOptions.py b/src/engine/SCons/Script/SConsOptions.py index b2f2858..501e4ce 100644 --- a/src/engine/SCons/Script/SConsOptions.py +++ b/src/engine/SCons/Script/SConsOptions.py @@ -638,7 +638,7 @@ def Parser(version): for value in value__.split(','): if value in debug_options: parser.values.debug.append(value) - elif value in deprecated_debug_options.keys(): + elif value in list(deprecated_debug_options.keys()): parser.values.debug.append(value) try: parser.values.delayed_warnings diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py index 6480ace..a7c8a37 100644 --- a/src/engine/SCons/Script/SConscript.py +++ b/src/engine/SCons/Script/SConscript.py @@ -526,7 +526,7 @@ class SConsEnvironment(SCons.Environment.Base): return x ls = list(map(subst_element, ls)) subst_kw = {} - for key, val in kw.items(): + for key, val in list(kw.items()): if SCons.Util.is_String(val): val = self.subst(val) elif SCons.Util.is_List(val): diff --git a/src/engine/SCons/Taskmaster.py b/src/engine/SCons/Taskmaster.py index 0f4fd21..461a556 100644 --- a/src/engine/SCons/Taskmaster.py +++ b/src/engine/SCons/Taskmaster.py @@ -479,7 +479,7 @@ class Task(object): if p.ref_count == 0: self.tm.candidates.append(p) - for p, subtract in parents.items(): + for p, subtract in list(parents.items()): p.ref_count = p.ref_count - subtract if T: T.write(self.trace_message(u'Task.postprocess()', p, diff --git a/src/engine/SCons/Tool/MSCommon/common.py b/src/engine/SCons/Tool/MSCommon/common.py index bcfee2b..b14eba1 100644 --- a/src/engine/SCons/Tool/MSCommon/common.py +++ b/src/engine/SCons/Tool/MSCommon/common.py @@ -114,7 +114,7 @@ def normalize_env(env, keys, force=False): Note: the environment is copied.""" normenv = {} if env: - for k in env.keys(): + for k in list(env.keys()): normenv[k] = copy.deepcopy(env[k]) for k in keys: @@ -219,7 +219,7 @@ def parse_output(output, keep = ("INCLUDE", "LIB", "LIBPATH", "PATH")): dkeep[key].append(p) for line in output.splitlines(): - for k,v in rdk.items(): + for k,v in list(rdk.items()): m = v.match(line) if m: add_env(m, k) diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py index f96b8ca..baa4025 100644 --- a/src/engine/SCons/Tool/MSCommon/vc.py +++ b/src/engine/SCons/Tool/MSCommon/vc.py @@ -514,7 +514,7 @@ def msvc_setup_env(env): SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning, warn_msg) return None - for k, v in d.items(): + for k, v in list(d.items()): debug('vc.py:msvc_setup_env() env:%s -> %s'%(k,v)) env.PrependENVPath(k, v, delete_existing=True) diff --git a/src/engine/SCons/Tool/MSCommon/vs.py b/src/engine/SCons/Tool/MSCommon/vs.py index 31197ef..4bda406 100644 --- a/src/engine/SCons/Tool/MSCommon/vs.py +++ b/src/engine/SCons/Tool/MSCommon/vs.py @@ -545,7 +545,7 @@ def msvs_setup_env(env): env['ENV'] = save_ENV vars = parse_output(output, vars) - for k, v in vars.items(): + for k, v in list(vars.items()): env.PrependENVPath(k, v, delete_existing=1) def query_versions(): diff --git a/src/engine/SCons/Tool/aixlink.py b/src/engine/SCons/Tool/aixlink.py index bfddf0a..3117c55 100644 --- a/src/engine/SCons/Tool/aixlink.py +++ b/src/engine/SCons/Tool/aixlink.py @@ -65,7 +65,7 @@ def exists(env): # TODO: sync with link.smart_link() to choose a linker linkers = { 'CXX': ['aixc++'], 'CC': ['aixcc'] } alltools = [] - for langvar, linktools in linkers.items(): + for langvar, linktools in list(linkers.items()): if langvar in env: # use CC over CXX when user specified CC but not CXX return SCons.Tool.FindTool(linktools, env) alltools.extend(linktools) diff --git a/src/engine/SCons/Tool/docbook/__init__.py b/src/engine/SCons/Tool/docbook/__init__.py index 2b22e17..8a7b2e7 100644 --- a/src/engine/SCons/Tool/docbook/__init__.py +++ b/src/engine/SCons/Tool/docbook/__init__.py @@ -461,7 +461,7 @@ def DocbookEpub(env, target, source=None, *args, **kw): # Create xpath context xpath_context = doc.xpathNewContext() # Register namespaces - for key, val in nsmap.iteritems(): + for key, val in nsmap.items(): xpath_context.xpathRegisterNs(key, val) if hasattr(opf, 'xpathEval') and xpath_context: diff --git a/src/engine/SCons/Tool/gnulink.py b/src/engine/SCons/Tool/gnulink.py index b1d5088..cf1ce85 100644 --- a/src/engine/SCons/Tool/gnulink.py +++ b/src/engine/SCons/Tool/gnulink.py @@ -67,7 +67,7 @@ def exists(env): # TODO: sync with link.smart_link() to choose a linker linkers = { 'CXX': ['g++'], 'CC': ['gcc'] } alltools = [] - for langvar, linktools in linkers.items(): + for langvar, linktools in list(linkers.items()): if langvar in env: # use CC over CXX when user specified CC but not CXX return SCons.Tool.FindTool(linktools, env) alltools.extend(linktools) diff --git a/src/engine/SCons/Tool/install.py b/src/engine/SCons/Tool/install.py index e16bb5f..ee15753 100644 --- a/src/engine/SCons/Tool/install.py +++ b/src/engine/SCons/Tool/install.py @@ -244,7 +244,7 @@ def add_versioned_targets_to_INSTALLED_FILES(target, source, env): Verbose = False _INSTALLED_FILES.extend(target) if Verbose: - print("add_versioned_targets_to_INSTALLED_FILES: target={:r}".format(map(str, target))) + print("add_versioned_targets_to_INSTALLED_FILES: target={:r}".format(list(map(str, target)))) symlinks = listShlibLinksToInstall(target[0], source, env) if symlinks: SCons.Tool.EmitLibSymlinks(env, symlinks, target[0]) diff --git a/src/engine/SCons/Tool/intelc.py b/src/engine/SCons/Tool/intelc.py index 185db9e..8ae02ef 100644 --- a/src/engine/SCons/Tool/intelc.py +++ b/src/engine/SCons/Tool/intelc.py @@ -500,14 +500,14 @@ def generate(env, version=None, abi=None, topdir=None, verbose=0): 'LIB' : libdir, 'PATH' : bindir, 'LD_LIBRARY_PATH' : libdir} - for p in paths.keys(): + for p in list(paths.keys()): env.PrependENVPath(p, os.path.join(topdir, paths[p])) if is_mac: paths={'INCLUDE' : 'include', 'LIB' : libdir, 'PATH' : bindir, 'LD_LIBRARY_PATH' : libdir} - for p in paths.keys(): + for p in list(paths.keys()): env.PrependENVPath(p, os.path.join(topdir, paths[p])) if is_windows: # env key reg valname default subdir of top diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py index 8166d7d..50f6b27 100644 --- a/src/engine/SCons/Tool/msvs.py +++ b/src/engine/SCons/Tool/msvs.py @@ -210,11 +210,11 @@ class _UserGenerator(object): dbg_settings and bool([ds for ds in dbg_settings if ds]) if self.createfile: - dbg_settings = dict(zip(variants, dbg_settings)) - for var, src in dbg_settings.items(): + dbg_settings = dict(list(zip(variants, dbg_settings))) + for var, src in list(dbg_settings.items()): # Update only expected keys trg = {} - for key in [k for k in self.usrdebg.keys() if k in src]: + for key in [k for k in list(self.usrdebg.keys()) if k in src]: trg[key] = str(src[key]) self.configs[var].debug = trg @@ -301,7 +301,7 @@ class _GenerateV7User(_UserGenerator): debug = self.configs[kind].debug if debug: debug_settings = '\n'.join(['\t\t\t\t%s="%s"' % (key, xmlify(value)) - for key, value in debug.items() + for key, value in list(debug.items()) if value is not None]) self.usrfile.write(self.usrconf % locals()) self.usrfile.write('\t\n') @@ -363,7 +363,7 @@ class _GenerateV10User(_UserGenerator): debug = self.configs[kind].debug if debug: debug_settings = '\n'.join(['\t\t<%s>%s' % (key, xmlify(value), key) - for key, value in debug.items() + for key, value in list(debug.items()) if value is not None]) self.usrfile.write(self.usrconf % locals()) self.usrfile.write('') @@ -533,7 +533,7 @@ class _DSPGenerator(object): AddConfig(self, variants[i], buildtarget[i], outdir[i], runfile[i], cmdargs[i]) self.platforms = [] - for key in self.configs.keys(): + for key in list(self.configs.keys()): platform = self.configs[key].platform if not platform in self.platforms: self.platforms.append(platform) @@ -656,7 +656,7 @@ class _GenerateV6DSP(_DSPGenerator): 'Resource Files': 'r|rc|ico|cur|bmp|dlg|rc2|rct|bin|cnt|rtf|gif|jpg|jpeg|jpe', 'Other Files': ''} - for kind in sorted(categories.keys(), key=lambda a: a.lower()): + for kind in sorted(list(categories.keys()), key=lambda a: a.lower()): if not self.sources[kind]: continue # skip empty groups @@ -922,7 +922,7 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User): self.file.write(pdata + '-->\n') def printSources(self, hierarchy, commonprefix): - sorteditems = sorted(hierarchy.items(), key=lambda a: a[0].lower()) + sorteditems = sorted(list(hierarchy.items()), key=lambda a: a[0].lower()) # First folders, then files for key, value in sorteditems: @@ -952,7 +952,7 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User): self.file.write('\t\n') - cats = sorted([k for k in categories.keys() if self.sources[k]], + cats = sorted([k for k in list(categories.keys()) if self.sources[k]], key=lambda a: a.lower()) for kind in cats: if len(cats) > 1: @@ -1241,7 +1241,7 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): self.file.write(pdata + '-->\n') def printFilters(self, hierarchy, name): - sorteditems = sorted(hierarchy.items(), key = lambda a: a[0].lower()) + sorteditems = sorted(list(hierarchy.items()), key = lambda a: a[0].lower()) for key, value in sorteditems: if SCons.Util.is_Dict(value): @@ -1258,7 +1258,7 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): 'Resource Files': 'None', 'Other Files': 'None'} - sorteditems = sorted(hierarchy.items(), key = lambda a: a[0].lower()) + sorteditems = sorted(list(hierarchy.items()), key = lambda a: a[0].lower()) # First folders, then files for key, value in sorteditems: @@ -1284,7 +1284,7 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): 'Resource Files': 'r;rc;ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe', 'Other Files': ''} - cats = sorted([k for k in categories.keys() if self.sources[k]], + cats = sorted([k for k in list(categories.keys()) if self.sources[k]], key = lambda a: a.lower()) # print vcxproj.filters file first @@ -1442,7 +1442,7 @@ class _GenerateV7DSW(_DSWGenerator): AddConfig(self, variant) self.platforms = [] - for key in self.configs.keys(): + for key in list(self.configs.keys()): platform = self.configs[key].platform if not platform in self.platforms: self.platforms.append(platform) diff --git a/src/engine/SCons/Tool/msvsTests.py b/src/engine/SCons/Tool/msvsTests.py index 2bd640f..bf82114 100644 --- a/src/engine/SCons/Tool/msvsTests.py +++ b/src/engine/SCons/Tool/msvsTests.py @@ -624,7 +624,7 @@ class msvsTestCase(unittest.TestCase): tests_cmdargs = [(None, dict.fromkeys(list_variant, '')), ('', dict.fromkeys(list_variant, '')), (list_cmdargs[0], dict.fromkeys(list_variant, list_cmdargs[0])), - (list_cmdargs, dict(zip(list_variant, list_cmdargs)))] + (list_cmdargs, dict(list(zip(list_variant, list_cmdargs))))] # Run the test for each test case for param_cmdargs, expected_cmdargs in tests_cmdargs: @@ -651,8 +651,8 @@ class msvsTestCase(unittest.TestCase): 'cmdargs': expected_cmdargs[variant_platform]} # Create parameter environment with final parameter dictionary - param_dict = dict(zip(('variant', 'runfile', 'buildtarget', 'outdir'), - [list(l) for l in zip(*param_configs)])) + param_dict = dict(list(zip(('variant', 'runfile', 'buildtarget', 'outdir'), + [list(l) for l in zip(*param_configs)]))) param_dict['cmdargs'] = param_cmdargs # Hack to be able to run the test with a 'DummyEnv' @@ -668,8 +668,8 @@ class msvsTestCase(unittest.TestCase): genDSP = function_test(dspfile, source, env) # Check expected result - self.assertListEqual(genDSP.configs.keys(), expected_configs.keys()) - for key in genDSP.configs.keys(): + self.assertListEqual(list(genDSP.configs.keys()), list(expected_configs.keys())) + for key in list(genDSP.configs.keys()): self.assertDictEqual(genDSP.configs[key].__dict__, expected_configs[key]) class msvs6aTestCase(msvsTestCase): diff --git a/src/engine/SCons/Tool/packaging/__init__.py b/src/engine/SCons/Tool/packaging/__init__.py index 1a95abe..1727938 100644 --- a/src/engine/SCons/Tool/packaging/__init__.py +++ b/src/engine/SCons/Tool/packaging/__init__.py @@ -72,7 +72,7 @@ def Tag(env, target, source, *more_tags, **kw_tags): target=env.Flatten(target) for t in target: - for (k,v) in kw_tags.items(): + for (k,v) in list(kw_tags.items()): # all file tags have to start with PACKAGING_, so we can later # differentiate between "normal" object attributes and the # packaging attributes. As the user should not be bothered with diff --git a/src/engine/SCons/Tool/packaging/ipk.py b/src/engine/SCons/Tool/packaging/ipk.py index c666033..ad4fe0f 100644 --- a/src/engine/SCons/Tool/packaging/ipk.py +++ b/src/engine/SCons/Tool/packaging/ipk.py @@ -169,7 +169,7 @@ Description: $X_IPK_DESCRIPTION # # close all opened files - for f in opened_files.values(): + for f in list(opened_files.values()): f.close() # call a user specified function diff --git a/src/engine/SCons/Tool/packaging/msi.py b/src/engine/SCons/Tool/packaging/msi.py index c25f856..73d3567 100644 --- a/src/engine/SCons/Tool/packaging/msi.py +++ b/src/engine/SCons/Tool/packaging/msi.py @@ -172,7 +172,7 @@ def generate_guids(root): # find all XMl nodes matching the key, retrieve their attribute, hash their # subtree, convert hash to string and add as a attribute to the xml node. - for (key,value) in needs_id.items(): + for (key,value) in list(needs_id.items()): node_list = root.getElementsByTagName(key) attribute = value for node in node_list: @@ -335,7 +335,7 @@ def build_wxsfile_file_section(root, files, NAME, VERSION, VENDOR, filename_set, } # fill in the default tags given above. - for k,v in [ (k, v) for (k,v) in h.items() if not hasattr(file, k) ]: + for k,v in [ (k, v) for (k,v) in list(h.items()) if not hasattr(file, k) ]: setattr( file, k, v ) File = factory.createElement( 'File' ) @@ -382,7 +382,7 @@ def build_wxsfile_features_section(root, files, NAME, VERSION, SUMMARY, id_set): Feature.attributes['Description'] = escape( SUMMARY ) Feature.attributes['Display'] = 'expand' - for (feature, files) in create_feature_dict(files).items(): + for (feature, files) in list(create_feature_dict(files).items()): SubFeature = factory.createElement('Feature') SubFeature.attributes['Level'] = '1' diff --git a/src/engine/SCons/Tool/packaging/rpm.py b/src/engine/SCons/Tool/packaging/rpm.py index a132555..25b5875 100644 --- a/src/engine/SCons/Tool/packaging/rpm.py +++ b/src/engine/SCons/Tool/packaging/rpm.py @@ -270,7 +270,7 @@ def build_specfile_filesection(spec, files): for file in files: # build the tagset tags = {} - for k in supported_tags.keys(): + for k in list(supported_tags.keys()): try: v = file.GetTag(k) if v: @@ -331,7 +331,7 @@ class SimpleTagCompiler(object): international = [t for t in replacements if is_international(t[0])] for key, replacement in international: try: - x = [t for t in values.items() if strip_country_code(t[0]) == key] + x = [t for t in list(values.items()) if strip_country_code(t[0]) == key] int_values_for_key = [(get_country_code(t[0]),t[1]) for t in x] for v in int_values_for_key: str = str + replacement % v diff --git a/src/engine/SCons/Tool/rpmutils.py b/src/engine/SCons/Tool/rpmutils.py index 3eeed1d..d4db417 100644 --- a/src/engine/SCons/Tool/rpmutils.py +++ b/src/engine/SCons/Tool/rpmutils.py @@ -520,7 +520,7 @@ def updateRpmDicts(rpmrc, pyfile): if l.startswith('# Start of rpmrc dictionaries'): pm = 1 # Write data sections to single dictionaries - for key, entries in data.items(): + for key, entries in list(data.items()): out.write("%s = {\n" % key) for arch in sorted(entries.keys()): out.write(" '%s' : ['%s'],\n" % (arch, "','".join(entries[arch]))) diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 0be6196..4f4ac2d 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -477,7 +477,7 @@ _semi_deepcopy_dispatch = d = {} def semi_deepcopy_dict(x, exclude = [] ): copy = {} - for key, val in x.items(): + for key, val in list(x.items()): # The regular Python copy.deepcopy() also deepcopies the key, # as follows: # @@ -1037,7 +1037,7 @@ class OrderedDict(UserDict): if key not in self._keys: self._keys.append(key) def update(self, dict): - for (key, val) in dict.items(): + for (key, val) in list(dict.items()): self.__setitem__(key, val) def values(self): @@ -1059,7 +1059,7 @@ class Selector(OrderedDict): # Try to perform Environment substitution on the keys of # the dictionary before giving up. s_dict = {} - for (k,v) in self.items(): + for (k,v) in list(self.items()): if k is not None: s_k = env.subst(k) if s_k in s_dict: diff --git a/src/engine/SCons/Variables/EnumVariableTests.py b/src/engine/SCons/Variables/EnumVariableTests.py index 931dfe2..edc2973 100644 --- a/src/engine/SCons/Variables/EnumVariableTests.py +++ b/src/engine/SCons/Variables/EnumVariableTests.py @@ -124,7 +124,7 @@ class EnumVariableTestCase(unittest.TestCase): 'C' : ['C', 'three', 'three'], } - for k, l in table.items(): + for k, l in list(table.items()): x = o0.converter(k) assert x == l[0], "o0 got %s, expected %s" % (x, l[0]) x = o1.converter(k) @@ -188,7 +188,7 @@ class EnumVariableTestCase(unittest.TestCase): 'no_v' : [invalid, invalid, invalid], } - for v, l in table.items(): + for v, l in list(table.items()): l[0](o0, v) l[1](o1, v) l[2](o2, v) diff --git a/src/engine/SCons/Variables/__init__.py b/src/engine/SCons/Variables/__init__.py index b03e5b5..ce3541c 100644 --- a/src/engine/SCons/Variables/__init__.py +++ b/src/engine/SCons/Variables/__init__.py @@ -185,7 +185,7 @@ class Variables(object): if args is None: args = self.args - for arg, value in args.items(): + for arg, value in list(args.items()): added = False for option in self.options: if arg in list(option.aliases) + [ option.key ]: diff --git a/src/engine/SCons/cpp.py b/src/engine/SCons/cpp.py index 60cfcea..18f154a 100644 --- a/src/engine/SCons/cpp.py +++ b/src/engine/SCons/cpp.py @@ -72,7 +72,7 @@ cpp_lines_dict = { # the corresponding compiled regular expression that fetches the arguments # we care about. Table = {} -for op_list, expr in cpp_lines_dict.items(): +for op_list, expr in list(cpp_lines_dict.items()): e = re.compile(expr) for op in op_list: Table[op] = e @@ -87,7 +87,7 @@ del op_list override = { 'if' : 'if(?!def)', } -l = [override.get(x, x) for x in Table.keys()] +l = [override.get(x, x) for x in list(Table.keys())] # Turn the list of expressions into one big honkin' regular expression @@ -130,7 +130,7 @@ CPP_to_Python_Ops_Sub = lambda m: CPP_to_Python_Ops_Dict[m.group(0)] # re module, as late as version 2.2.2, empirically matches the # "!" in "!=" first, instead of finding the longest match. # What's up with that? -l = sorted(CPP_to_Python_Ops_Dict.keys(), key=lambda a: len(a), reverse=True) +l = sorted(list(CPP_to_Python_Ops_Dict.keys()), key=lambda a: len(a), reverse=True) # Turn the list of keys into one regular expression that will allow us # to substitute all of the operators at once. @@ -266,7 +266,7 @@ class PreProcessor(object): d = { 'scons_current_file' : self.scons_current_file } - for op in Table.keys(): + for op in list(Table.keys()): d[op] = getattr(self, 'do_' + op) self.default_table = d diff --git a/src/script/scons-configure-cache.py b/src/script/scons-configure-cache.py index c1b7d59..2648acd 100644 --- a/src/script/scons-configure-cache.py +++ b/src/script/scons-configure-cache.py @@ -1,139 +1,139 @@ -#! /usr/bin/env python -# -# SCons - a Software Constructor -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -__version__ = "__VERSION__" - -__build__ = "__BUILD__" - -__buildsys__ = "__BUILDSYS__" - -__date__ = "__DATE__" - -__developer__ = "__DEVELOPER__" - -import argparse -import glob -import json -import os - -def rearrange_cache_entries(current_prefix_len, new_prefix_len): - print 'Changing prefix length from', current_prefix_len, 'to', new_prefix_len - dirs = set() - old_dirs = set() - for file in glob.iglob(os.path.join('*', '*')): - name = os.path.basename(file) - dir = name[:current_prefix_len].upper() - if dir not in old_dirs: - print 'Migrating', dir - old_dirs.add(dir) - dir = name[:new_prefix_len].upper() - if dir not in dirs: - os.mkdir(dir) - dirs.add(dir) - os.rename(file, os.path.join(dir, name)) - - # Now delete the original directories - for dir in old_dirs: - os.rmdir(dir) - -# This dictionary should have one entry per entry in the cache config -# Each entry should have the following: -# implicit - (optional) This is to allow adding a new config entry and also -# changing the behaviour of the system at the same time. This -# indicates the value the config entry would have had if it had been -# specified. -# default - The value the config entry should have if it wasn't previously -# specified -# command-line - parameters to pass to ArgumentParser.add_argument -# converter - (optional) Function to call if it's necessary to do some work -# if this configuration entry changes -config_entries = { - 'prefix_len' : { - 'implicit' : 1, - 'default' : 2 , - 'command-line' : { - 'help' : 'Length of cache file name used as subdirectory prefix', - 'metavar' : '', - 'type' : int - }, - 'converter' : rearrange_cache_entries - } -} -parser = argparse.ArgumentParser( - description = 'Modify the configuration of an scons cache directory', - epilog = ''' - Unless you specify an option, it will not be changed (if it is - already set in the cache config), or changed to an appropriate - default (it it is not set). - ''' - ) - -parser.add_argument('cache-dir', help='Path to scons cache directory') -for param in config_entries: - parser.add_argument('--' + param.replace('_', '-'), - **config_entries[param]['command-line']) -parser.add_argument('--version', action='version', version='%(prog)s 1.0') - -# Get the command line as a dict without any of the unspecified entries. -args = dict(filter(lambda x: x[1], vars(parser.parse_args()).items())) - -# It seems somewhat strange to me, but positional arguments don't get the - -# in the name changed to _, whereas optional arguments do... -os.chdir(args['cache-dir']) -del args['cache-dir'] - -if not os.path.exists('config'): - # Validate the only files in the directory are directories 0-9, a-f - expected = [ '{:X}'.format(x) for x in range(0, 16) ] - if not set(os.listdir('.')).issubset(expected): - raise RuntimeError("This doesn't look like a version 1 cache directory") - config = dict() -else: - with open('config') as conf: - config = json.load(conf) - -# Find any keys that aren't currently set but should be -for key in config_entries: - if key not in config: - if 'implicit' in config_entries[key]: - config[key] = config_entries[key]['implicit'] - else: - config[key] = config_entries[key]['default'] - if key not in args: - args[key] = config_entries[key]['default'] - -#Now we go through each entry in args to see if it changes an existing config -#setting. -for key in args: - if args[key] != config[key]: - if 'converter' in config_entries[key]: - config_entries[key]['converter'](config[key], args[key]) - config[key] = args[key] - -# and write the updated config file -with open('config', 'w') as conf: +#! /usr/bin/env python +# +# SCons - a Software Constructor +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +__version__ = "__VERSION__" + +__build__ = "__BUILD__" + +__buildsys__ = "__BUILDSYS__" + +__date__ = "__DATE__" + +__developer__ = "__DEVELOPER__" + +import argparse +import glob +import json +import os + +def rearrange_cache_entries(current_prefix_len, new_prefix_len): + print 'Changing prefix length from', current_prefix_len, 'to', new_prefix_len + dirs = set() + old_dirs = set() + for file in glob.iglob(os.path.join('*', '*')): + name = os.path.basename(file) + dir = name[:current_prefix_len].upper() + if dir not in old_dirs: + print 'Migrating', dir + old_dirs.add(dir) + dir = name[:new_prefix_len].upper() + if dir not in dirs: + os.mkdir(dir) + dirs.add(dir) + os.rename(file, os.path.join(dir, name)) + + # Now delete the original directories + for dir in old_dirs: + os.rmdir(dir) + +# This dictionary should have one entry per entry in the cache config +# Each entry should have the following: +# implicit - (optional) This is to allow adding a new config entry and also +# changing the behaviour of the system at the same time. This +# indicates the value the config entry would have had if it had been +# specified. +# default - The value the config entry should have if it wasn't previously +# specified +# command-line - parameters to pass to ArgumentParser.add_argument +# converter - (optional) Function to call if it's necessary to do some work +# if this configuration entry changes +config_entries = { + 'prefix_len' : { + 'implicit' : 1, + 'default' : 2 , + 'command-line' : { + 'help' : 'Length of cache file name used as subdirectory prefix', + 'metavar' : '', + 'type' : int + }, + 'converter' : rearrange_cache_entries + } +} +parser = argparse.ArgumentParser( + description = 'Modify the configuration of an scons cache directory', + epilog = ''' + Unless you specify an option, it will not be changed (if it is + already set in the cache config), or changed to an appropriate + default (it it is not set). + ''' + ) + +parser.add_argument('cache-dir', help='Path to scons cache directory') +for param in config_entries: + parser.add_argument('--' + param.replace('_', '-'), + **config_entries[param]['command-line']) +parser.add_argument('--version', action='version', version='%(prog)s 1.0') + +# Get the command line as a dict without any of the unspecified entries. +args = dict([x for x in list(vars(parser.parse_args()).items()) if x[1]]) + +# It seems somewhat strange to me, but positional arguments don't get the - +# in the name changed to _, whereas optional arguments do... +os.chdir(args['cache-dir']) +del args['cache-dir'] + +if not os.path.exists('config'): + # Validate the only files in the directory are directories 0-9, a-f + expected = [ '{:X}'.format(x) for x in range(0, 16) ] + if not set(os.listdir('.')).issubset(expected): + raise RuntimeError("This doesn't look like a version 1 cache directory") + config = dict() +else: + with open('config') as conf: + config = json.load(conf) + +# Find any keys that aren't currently set but should be +for key in config_entries: + if key not in config: + if 'implicit' in config_entries[key]: + config[key] = config_entries[key]['implicit'] + else: + config[key] = config_entries[key]['default'] + if key not in args: + args[key] = config_entries[key]['default'] + +#Now we go through each entry in args to see if it changes an existing config +#setting. +for key in args: + if args[key] != config[key]: + if 'converter' in config_entries[key]: + config_entries[key]['converter'](config[key], args[key]) + config[key] = args[key] + +# and write the updated config file +with open('config', 'w') as conf: json.dump(config, conf) \ No newline at end of file diff --git a/src/script/scons-time.py b/src/script/scons-time.py index ebdaf08..edb9dad 100644 --- a/src/script/scons-time.py +++ b/src/script/scons-time.py @@ -652,7 +652,7 @@ class SConsTimer(object): sys.stderr.write('%s Cannot use the "func" subcommand.\n' % self.name_spaces) sys.exit(1) statistics = pstats.Stats(file).stats - matches = [ e for e in statistics.items() if e[0][2] == function ] + matches = [ e for e in list(statistics.items()) if e[0][2] == function ] r = matches[0] return r[0][0], r[0][1], r[0][2], r[1][3] @@ -1422,7 +1422,7 @@ class SConsTimer(object): elif o in ('--title',): self.title = a elif o in ('--which',): - if not a in self.time_strings.keys(): + if not a in list(self.time_strings.keys()): sys.stderr.write('%s: time: Unrecognized timer "%s".\n' % (self.name, a)) sys.stderr.write('%s Type "%s help time" for help.\n' % (self.name_spaces, self.name)) sys.exit(1) diff --git a/src/test_files.py b/src/test_files.py index 1eee11d..ef27606 100644 --- a/src/test_files.py +++ b/src/test_files.py @@ -78,7 +78,7 @@ check = { missing = [] no_result = [] -for directory, check_list in check.items(): +for directory, check_list in list(check.items()): if os.path.exists(directory): for c in check_list: f = os.path.join(directory, c) diff --git a/src/test_interrupts.py b/src/test_interrupts.py index b81ef3f..0fd8ba7 100644 --- a/src/test_interrupts.py +++ b/src/test_interrupts.py @@ -104,7 +104,7 @@ for f in files: indent_list.append( (line_num, match.group('try_or_except') ) ) try_except_lines[match.group('indent')] = indent_list uncaught_this_file = [] - for indent in try_except_lines.keys(): + for indent in list(try_except_lines.keys()): exc_keyboardint_seen = 0 exc_all_seen = 0 for (l,statement) in try_except_lines[indent] + [(-1,indent + 'try')]: diff --git a/test/AS/nasm.py b/test/AS/nasm.py index be7db3e..551a5ab 100644 --- a/test/AS/nasm.py +++ b/test/AS/nasm.py @@ -69,7 +69,7 @@ else: # anyway...). nasm_format = 'elf' format_map = {} -for k, v in format_map.items(): +for k, v in list(format_map.items()): if sys.platform.find(k) != -1: nasm_format = v break diff --git a/test/QT/QTFLAGS.py b/test/QT/QTFLAGS.py index f6aa00f..e29ee80 100644 --- a/test/QT/QTFLAGS.py +++ b/test/QT/QTFLAGS.py @@ -147,7 +147,7 @@ test.must_exist(['work1', 'mmmmocFromH.cxx'], ['work1', 'mmmanother_ui_file.cxx']) def _flagTest(test,fileToContentsStart): - for f,c in fileToContentsStart.items(): + for f,c in list(fileToContentsStart.items()): if test.read(test.workpath('work1', f)).find(c) != 0: return 1 return 0 -- cgit v0.12 From 0e2a4161264e7bac8368b8132b368796c880e30e Mon Sep 17 00:00:00 2001 From: William Blevins Date: Tue, 20 Sep 2016 16:07:30 -0400 Subject: Fixing QMTest str and bytes issues. --- QMTest/TestCmd.py | 19 ++++++++++++++++++- QMTest/TestCommon.py | 2 +- src/engine/SCons/Tool/swig.py | 2 +- test/AR/AR.py | 4 ++-- test/AR/ARCOM.py | 2 +- test/AR/ARCOMSTR.py | 2 +- test/AR/ARFLAGS.py | 4 ++-- 7 files changed, 26 insertions(+), 9 deletions(-) diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index b0a456b..d7b8d94 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -328,12 +328,27 @@ __all__ = [ 'match_re_dotall', 'python', '_python_', - 'TestCmd' + 'TestCmd', + 'to_bytes', + 'to_str', ] def is_List(e): return isinstance(e, (list, UserList)) +def to_bytes (s): + if isinstance (s, bytes) or bytes is str: + return s + else: + return bytes (s, 'utf-8') + +def to_str (s): + if bytes is str: + return s + elif not is_String(s): + return str (s, 'utf-8') + return s + try: eval('unicode') except NameError: @@ -513,6 +528,8 @@ def simple_diff(a, b, fromfile='', tofile='', (diff -c) and difflib.unified_diff (diff -u) but which prints output like the simple, unadorned 'diff" command. """ + a = [to_str(q) for q in a] + b = [to_str(q) for q in b] sm = difflib.SequenceMatcher(None, a, b) def comma(x1, x2): return x1+1 == x2 and str(x2) or '%s,%s' % (x1+1, x2) diff --git a/QMTest/TestCommon.py b/QMTest/TestCommon.py index f878636..9093cc9 100644 --- a/QMTest/TestCommon.py +++ b/QMTest/TestCommon.py @@ -479,7 +479,7 @@ class TestCommon(TestCmd): if not match: match = self.match try: - self.fail_test(not match(file_contents, expect)) + self.fail_test(not match(to_str(file_contents), to_str(expect))) except KeyboardInterrupt: raise except: diff --git a/src/engine/SCons/Tool/swig.py b/src/engine/SCons/Tool/swig.py index fa86174..9935de8 100644 --- a/src/engine/SCons/Tool/swig.py +++ b/src/engine/SCons/Tool/swig.py @@ -143,7 +143,7 @@ def _get_swig_version(env, swig): # MAYBE: out = SCons.Util.to_str (pipe.stdout.read()) out = pipe.stdout.read() - match = re.search(r'SWIG Version\s+(\S+).*', out, re.MULTILINE) + match = re.search(b'SWIG Version\s+(\S+).*', out, re.MULTILINE) if match: if verbose: print("Version is:%s"%match.group(1)) return match.group(1) diff --git a/test/AR/AR.py b/test/AR/AR.py index 8fb8073..573f2d9 100644 --- a/test/AR/AR.py +++ b/test/AR/AR.py @@ -36,7 +36,7 @@ test = TestSCons.TestSCons() test.write("wrapper.py", """import os import sys -open('%s', 'wb').write("wrapper.py\\n") +open('%s', 'wb').write(b"wrapper.py\\n") os.system(" ".join(sys.argv[1:])) """ % test.workpath('wrapper.out').replace('\\', '\\\\')) @@ -100,7 +100,7 @@ test.run(arguments = 'b' + _exe, stderr=TestSCons.noisy_ar, match=TestSCons.match_re_dotall) -test.fail_test(test.read('wrapper.out') != "wrapper.py\n") +test.fail_test(test.read('wrapper.out') != b"wrapper.py\n") test.pass_test() diff --git a/test/AR/ARCOM.py b/test/AR/ARCOM.py index f26ced6..bf2830e 100644 --- a/test/AR/ARCOM.py +++ b/test/AR/ARCOM.py @@ -41,7 +41,7 @@ import sys outfile = open(sys.argv[1], 'wb') for f in sys.argv[2:]: infile = open(f, 'rb') - for l in [l for l in infile.readlines() if l != '/*ar*/\\n']: + for l in [l for l in infile.readlines() if l != b'/*ar*/\\n']: outfile.write(l) sys.exit(0) """) diff --git a/test/AR/ARCOMSTR.py b/test/AR/ARCOMSTR.py index 4c0bb85..1b1a9fb 100644 --- a/test/AR/ARCOMSTR.py +++ b/test/AR/ARCOMSTR.py @@ -42,7 +42,7 @@ import sys outfile = open(sys.argv[1], 'wb') for f in sys.argv[2:]: infile = open(f, 'rb') - for l in [l for l in infile.readlines() if l != '/*ar*/\\n']: + for l in [l for l in infile.readlines() if l != b'/*ar*/\\n']: outfile.write(l) sys.exit(0) """) diff --git a/test/AR/ARFLAGS.py b/test/AR/ARFLAGS.py index be4e8bd..fad9c19 100644 --- a/test/AR/ARFLAGS.py +++ b/test/AR/ARFLAGS.py @@ -36,7 +36,7 @@ test = TestSCons.TestSCons() test.write("wrapper.py", """import os import sys -open('%s', 'wb').write("wrapper.py\\n") +open('%s', 'wb').write(b"wrapper.py\\n") os.system(" ".join(sys.argv[1:])) """ % test.workpath('wrapper.out').replace('\\', '\\\\')) @@ -99,7 +99,7 @@ test.run(arguments = 'b' + _exe, stderr=TestSCons.noisy_ar, match=TestSCons.match_re_dotall) -test.fail_test(test.read('wrapper.out') != "wrapper.py\n") +test.fail_test(test.read('wrapper.out') != b"wrapper.py\n") test.pass_test() -- cgit v0.12 From 191d1f1a9937ecdf16e12ad5610586c3ba7c50fd Mon Sep 17 00:00:00 2001 From: William Blevins Date: Tue, 20 Sep 2016 22:11:33 -0400 Subject: Updates to test/AR and test/Actions. -Moved some string files to fixture. --- test/AR/AR.py | 4 +- test/AR/ARFLAGS.py | 4 +- test/Actions/actions.py | 10 +-- test/Actions/addpost-link-fixture/.exclude_tests | 1 + test/Actions/addpost-link-fixture/strip.py | 2 + test/Actions/addpost-link-fixture/test1.c | 5 ++ test/Actions/addpost-link-fixture/test_lib.c | 5 ++ test/Actions/addpost-link.py | 21 +---- test/Actions/append-fixture/foo.c | 7 ++ test/Actions/append.py | 21 ++--- test/Actions/pre-post-fixture/work1/bar.c | 7 ++ test/Actions/pre-post-fixture/work1/foo.c | 7 ++ test/Actions/pre-post-fixture/work2/SConstruct | 26 ++++++ test/Actions/pre-post-fixture/work3/SConstruct | 10 +++ test/Actions/pre-post-fixture/work4/.exclude_tests | 1 + test/Actions/pre-post-fixture/work4/file.in | 1 + test/Actions/pre-post.py | 98 ++-------------------- test/Actions/unicode-signature-fixture/SConstruct | 11 +++ test/Actions/unicode-signature.py | 14 +--- 19 files changed, 107 insertions(+), 148 deletions(-) create mode 100644 test/Actions/addpost-link-fixture/.exclude_tests create mode 100644 test/Actions/addpost-link-fixture/strip.py create mode 100644 test/Actions/addpost-link-fixture/test1.c create mode 100644 test/Actions/addpost-link-fixture/test_lib.c create mode 100644 test/Actions/append-fixture/foo.c create mode 100644 test/Actions/pre-post-fixture/work1/bar.c create mode 100644 test/Actions/pre-post-fixture/work1/foo.c create mode 100644 test/Actions/pre-post-fixture/work2/SConstruct create mode 100644 test/Actions/pre-post-fixture/work3/SConstruct create mode 100644 test/Actions/pre-post-fixture/work4/.exclude_tests create mode 100644 test/Actions/pre-post-fixture/work4/file.in create mode 100644 test/Actions/unicode-signature-fixture/SConstruct diff --git a/test/AR/AR.py b/test/AR/AR.py index 573f2d9..eb4c507 100644 --- a/test/AR/AR.py +++ b/test/AR/AR.py @@ -94,13 +94,13 @@ test.run(arguments = 'f' + _exe, stderr=TestSCons.noisy_ar, match=TestSCons.match_re_dotall) -test.fail_test(os.path.exists(test.workpath('wrapper.out'))) +test.must_not_exist(test.workpath('wrapper.out')) test.run(arguments = 'b' + _exe, stderr=TestSCons.noisy_ar, match=TestSCons.match_re_dotall) -test.fail_test(test.read('wrapper.out') != b"wrapper.py\n") +test.must_match('wrapper.out', 'wrapper.py\n') test.pass_test() diff --git a/test/AR/ARFLAGS.py b/test/AR/ARFLAGS.py index fad9c19..0a9f36e 100644 --- a/test/AR/ARFLAGS.py +++ b/test/AR/ARFLAGS.py @@ -93,13 +93,13 @@ test.run(arguments = 'f' + _exe, stderr=TestSCons.noisy_ar, match=TestSCons.match_re_dotall) -test.fail_test(os.path.exists(test.workpath('wrapper.out'))) +test.must_not_exist(test.workpath('wrapper.out')) test.run(arguments = 'b' + _exe, stderr=TestSCons.noisy_ar, match=TestSCons.match_re_dotall) -test.fail_test(test.read('wrapper.out') != b"wrapper.py\n") +test.must_match('wrapper.out', 'wrapper.py\n') test.pass_test() diff --git a/test/Actions/actions.py b/test/Actions/actions.py index 785a0cb..e69cdd7 100644 --- a/test/Actions/actions.py +++ b/test/Actions/actions.py @@ -33,7 +33,7 @@ test = TestSCons.TestSCons() test.write('build.py', r""" import sys file = open(sys.argv[1], 'wb') -file.write(sys.argv[2] + "\n") +file.write((sys.argv[2] + "\n").encode()) file.write(open(sys.argv[3], 'rb').read()) file.close sys.exit(0) @@ -49,7 +49,7 @@ test.write('foo.in', "foo.in\n") test.run(arguments = '.') -test.fail_test(test.read('foo.out') != "1\nfoo.in\n") +test.must_match('foo.out', '1\nfoo.in\n') test.up_to_date(arguments = '.') @@ -61,7 +61,7 @@ env.B(target = 'foo.out', source = 'foo.in') test.run(arguments = '.') -test.fail_test(test.read('foo.out') != "2\nfoo.in\n") +test.must_match('foo.out', '2\nfoo.in\n') test.up_to_date(arguments = '.') @@ -79,7 +79,7 @@ env.B(target = 'foo.out', source = 'foo.in') test.run(arguments = '.', stderr = None) -test.fail_test(test.read('foo.out') != "3\nfoo.in\n") +test.must_match('foo.out', '3\nfoo.in\n') test.up_to_date(arguments = '.') @@ -103,7 +103,7 @@ env.B(target = 'foo.out', source = 'foo.in') test.run(arguments = '.') -test.fail_test(test.read('foo.out') != "4\nfoo.in\n") +test.must_match('foo.out', '4\nfoo.in\n') test.up_to_date(arguments = '.') diff --git a/test/Actions/addpost-link-fixture/.exclude_tests b/test/Actions/addpost-link-fixture/.exclude_tests new file mode 100644 index 0000000..03cc8e0 --- /dev/null +++ b/test/Actions/addpost-link-fixture/.exclude_tests @@ -0,0 +1 @@ +strip.py diff --git a/test/Actions/addpost-link-fixture/strip.py b/test/Actions/addpost-link-fixture/strip.py new file mode 100644 index 0000000..88242f2 --- /dev/null +++ b/test/Actions/addpost-link-fixture/strip.py @@ -0,0 +1,2 @@ +import sys +print("strip.py: %s" % " ".join(sys.argv[1:])) diff --git a/test/Actions/addpost-link-fixture/test1.c b/test/Actions/addpost-link-fixture/test1.c new file mode 100644 index 0000000..333f5c7 --- /dev/null +++ b/test/Actions/addpost-link-fixture/test1.c @@ -0,0 +1,5 @@ +extern void test_lib_fn(); +int main(int argc, char **argv) { + test_lib_fn(); + return 0; +} diff --git a/test/Actions/addpost-link-fixture/test_lib.c b/test/Actions/addpost-link-fixture/test_lib.c new file mode 100644 index 0000000..0ac1076 --- /dev/null +++ b/test/Actions/addpost-link-fixture/test_lib.c @@ -0,0 +1,5 @@ +#include + +void test_lib_fn() { + printf("Hello world\n"); +} diff --git a/test/Actions/addpost-link.py b/test/Actions/addpost-link.py index 04cd68d..0a238e1 100644 --- a/test/Actions/addpost-link.py +++ b/test/Actions/addpost-link.py @@ -38,10 +38,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() -test.write('strip.py', """\ -import sys -print "strip.py: %s" % " ".join(sys.argv[1:]) -""") +test.dir_fixture('addpost-link-fixture') test.write('SConstruct', """\ env = Environment() @@ -57,22 +54,6 @@ if ARGUMENTS['case']=='2': AddPostAction(myprog, Action(r'%(_python_)s strip.py ' + myprog[0].get_abspath())) """ % locals()) -test.write('test1.c', """\ -extern void test_lib_fn(); -int main(int argc, char **argv) { - test_lib_fn(); - return 0; -} -""") - -test.write('test_lib.c', r"""\ -#include - -void test_lib_fn() { - printf("Hello world\n"); -} -""") - test.run(arguments="-Q case=1", stderr=None) test.run(arguments="-Q -c case=1") diff --git a/test/Actions/append-fixture/foo.c b/test/Actions/append-fixture/foo.c new file mode 100644 index 0000000..e6428b5 --- /dev/null +++ b/test/Actions/append-fixture/foo.c @@ -0,0 +1,7 @@ +#include + +int main(void) +{ + printf("Foo\n"); + return 0; +} diff --git a/test/Actions/append.py b/test/Actions/append.py index f617280..68646b3 100644 --- a/test/Actions/append.py +++ b/test/Actions/append.py @@ -33,22 +33,11 @@ import stat import sys import TestSCons -if sys.platform == 'win32': - _exe = '.exe' -else: - _exe = '' +_exe = TestSCons._exe test = TestSCons.TestSCons() -test.write('foo.c', r""" -#include - -int main(void) -{ - printf("Foo\n"); - return 0; -} -""") +test.dir_fixture('append-fixture') test.write('SConstruct', """ @@ -56,10 +45,10 @@ env=Environment() def before(env, target, source): f=open(str(target[0]), "wb") - f.write("Foo\\n") + f.write(b"Foo\\n") f.close() f=open("before.txt", "wb") - f.write("Bar\\n") + f.write(b"Bar\\n") f.close() def after(env, target, source): @@ -77,7 +66,7 @@ env.Program(source='foo.c', target='foo') after_exe = test.workpath('after' + _exe) test.run(arguments='.') -test.fail_test(open('before.txt', 'rb').read() != "Bar\n") +test.must_match('before.txt', 'Bar\n') os.chmod(after_exe, os.stat(after_exe)[stat.ST_MODE] | stat.S_IXUSR) test.run(program=after_exe, stdout="Foo\n") test.pass_test() diff --git a/test/Actions/pre-post-fixture/work1/bar.c b/test/Actions/pre-post-fixture/work1/bar.c new file mode 100644 index 0000000..eb3fd78 --- /dev/null +++ b/test/Actions/pre-post-fixture/work1/bar.c @@ -0,0 +1,7 @@ +#include + +int main(void) +{ + printf("bar.c\n"); + return 0; +} diff --git a/test/Actions/pre-post-fixture/work1/foo.c b/test/Actions/pre-post-fixture/work1/foo.c new file mode 100644 index 0000000..32f2a3e --- /dev/null +++ b/test/Actions/pre-post-fixture/work1/foo.c @@ -0,0 +1,7 @@ +#include + +int main(void) +{ + printf("foo.c\n"); + return 0; +} diff --git a/test/Actions/pre-post-fixture/work2/SConstruct b/test/Actions/pre-post-fixture/work2/SConstruct new file mode 100644 index 0000000..61f739f --- /dev/null +++ b/test/Actions/pre-post-fixture/work2/SConstruct @@ -0,0 +1,26 @@ +def b(target, source, env): + open(str(target[0]), 'wb').write((env['X'] + '\n').encode()) +env1 = Environment(X='111') +env2 = Environment(X='222') +B = Builder(action = b, env = env1, multi=1) +print("B =", B) +print("B.env =", B.env) +env1.Append(BUILDERS = {'B' : B}) +env2.Append(BUILDERS = {'B' : B}) +env3 = env1.Clone(X='333') +print("env1 =", env1) +print("env2 =", env2) +print("env3 =", env3) +f1 = env1.B(File('file1.out'), []) +f2 = env2.B('file2.out', []) +f3 = env3.B('file3.out', []) +def do_nothing(env, target, source): + pass +AddPreAction(f2[0], do_nothing) +AddPostAction(f3[0], do_nothing) +print("f1[0].builder =", f1[0].builder) +print("f2[0].builder =", f2[0].builder) +print("f3[0].builder =", f3[0].builder) +print("f1[0].env =", f1[0].env) +print("f2[0].env =", f2[0].env) +print("f3[0].env =", f3[0].env) diff --git a/test/Actions/pre-post-fixture/work3/SConstruct b/test/Actions/pre-post-fixture/work3/SConstruct new file mode 100644 index 0000000..0e13fa2 --- /dev/null +++ b/test/Actions/pre-post-fixture/work3/SConstruct @@ -0,0 +1,10 @@ +def pre(target, source, env): + pass +def post(target, source, env): + pass +def build(target, source, env): + open(str(target[0]), 'wb').write(b'build()\n') +env = Environment() +AddPreAction('dir', pre) +AddPostAction('dir', post) +env.Command('dir/file', [], build) diff --git a/test/Actions/pre-post-fixture/work4/.exclude_tests b/test/Actions/pre-post-fixture/work4/.exclude_tests new file mode 100644 index 0000000..3fb299e --- /dev/null +++ b/test/Actions/pre-post-fixture/work4/.exclude_tests @@ -0,0 +1 @@ +build.py diff --git a/test/Actions/pre-post-fixture/work4/file.in b/test/Actions/pre-post-fixture/work4/file.in new file mode 100644 index 0000000..1912927 --- /dev/null +++ b/test/Actions/pre-post-fixture/work4/file.in @@ -0,0 +1 @@ +file.in diff --git a/test/Actions/pre-post.py b/test/Actions/pre-post.py index f6997e2..a5acbfb 100644 --- a/test/Actions/pre-post.py +++ b/test/Actions/pre-post.py @@ -37,9 +37,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() -test.subdir('work1', 'work2', 'work3', 'work4') - - +test.dir_fixture('pre-post-fixture') test.write(['work1', 'SConstruct'], """ import os.path @@ -50,11 +48,11 @@ env = Environment(XXX='bar%(_exe)s') def before(env, target, source): a=str(target[0]) f=open(a, "wb") - f.write("Foo\\n") + f.write(b"Foo\\n") f.close() os.chmod(a, os.stat(a)[stat.ST_MODE] | stat.S_IXUSR) f=open("before.txt", "ab") - f.write(os.path.splitext(str(target[0]))[0] + "\\n") + f.write((os.path.splitext(str(target[0]))[0] + "\\n").encode()) f.close() def after(env, target, source): @@ -76,26 +74,6 @@ env.AddPreAction('$XXX', before) env.AddPostAction('$XXX', after) """ % locals()) -test.write(['work1', 'foo.c'], r""" -#include - -int main(void) -{ - printf("foo.c\n"); - return 0; -} -""") - -test.write(['work1', 'bar.c'], r""" -#include - -int main(void) -{ - printf("bar.c\n"); - return 0; -} -""") - test.run(chdir='work1', arguments='.') test.run(program=test.workpath('work1', 'foo'+ _exe), stdout="foo.c\n") @@ -109,59 +87,14 @@ test.run(program=after_foo_exe, stdout="foo.c\n") after_bar_exe = test.workpath('work1', 'after_bar' + _exe) test.run(program=after_bar_exe, stdout="bar.c\n") - - - -test.write(['work2', 'SConstruct'], """\ -def b(target, source, env): - open(str(target[0]), 'wb').write(env['X'] + '\\n') -env1 = Environment(X='111') -env2 = Environment(X='222') -B = Builder(action = b, env = env1, multi=1) -print("B =", B) -print("B.env =", B.env) -env1.Append(BUILDERS = {'B' : B}) -env2.Append(BUILDERS = {'B' : B}) -env3 = env1.Clone(X='333') -print("env1 =", env1) -print("env2 =", env2) -print("env3 =", env3) -f1 = env1.B(File('file1.out'), []) -f2 = env2.B('file2.out', []) -f3 = env3.B('file3.out', []) -def do_nothing(env, target, source): - pass -AddPreAction(f2[0], do_nothing) -AddPostAction(f3[0], do_nothing) -print("f1[0].builder =", f1[0].builder) -print("f2[0].builder =", f2[0].builder) -print("f3[0].builder =", f3[0].builder) -print("f1[0].env =", f1[0].env) -print("f2[0].env =", f2[0].env) -print("f3[0].env =", f3[0].env) -""") - +# work2 start test.run(chdir='work2', arguments = '.') test.must_match(['work2', 'file1.out'], "111\n") test.must_match(['work2', 'file2.out'], "222\n") test.must_match(['work2', 'file3.out'], "333\n") - - -test.write(['work3', 'SConstruct'], """\ -def pre(target, source, env): - pass -def post(target, source, env): - pass -def build(target, source, env): - open(str(target[0]), 'wb').write('build()\\n') -env = Environment() -AddPreAction('dir', pre) -AddPostAction('dir', post) -env.Command('dir/file', [], build) -""") - +# work3 start test.run(chdir = 'work3', arguments = 'dir/file', stdout=test.wrap_stdout("""\ pre(["dir"], []) post(["dir"], []) @@ -170,21 +103,12 @@ build(["%s"], []) test.must_match(['work3', 'dir', 'file'], "build()\n") - - -test.write(['work4', 'build.py'], """\ -import sys -outfp = open(sys.argv[1], 'wb') -for f in sys.argv[2:]: - outfp.write(open(f, 'rb').read()) -outfp.close() -""") - +# work4 start test.write(['work4', 'SConstruct'], """\ def pre_action(target, source, env): - open(str(target[0]), 'ab').write('pre %%s\\n' %% source[0]) + open(str(target[0]), 'ab').write(('pre %%s\\n' %% source[0]).encode()) def post_action(target, source, env): - open(str(target[0]), 'ab').write('post %%s\\n' %% source[0]) + open(str(target[0]), 'ab').write(('post %%s\\n' %% source[0]).encode()) env = Environment() o = env.Command(['pre-post', 'file.out'], 'file.in', @@ -193,8 +117,6 @@ env.AddPreAction(o, pre_action) env.AddPostAction(o, post_action) """ % locals()) -test.write(['work4', 'file.in'], "file.in\n") - test.run(chdir='work4', arguments='.') test.must_match(['work4', 'file.out'], "file.in\n") @@ -202,10 +124,6 @@ test.must_match(['work4', 'pre-post'], "pre file.in\npost file.in\n") test.pass_test() - - -test.pass_test() - # Local Variables: # tab-width:4 # indent-tabs-mode:nil diff --git a/test/Actions/unicode-signature-fixture/SConstruct b/test/Actions/unicode-signature-fixture/SConstruct new file mode 100644 index 0000000..9c0f03d --- /dev/null +++ b/test/Actions/unicode-signature-fixture/SConstruct @@ -0,0 +1,11 @@ +fnode = File(u'foo.txt') + +def funcact(target, source, env): + open(str(target[0]), 'wb').write(b"funcact\n") + for i in range(300): + pass + return 0 + +env = Environment() + +env.Command(fnode, [], ["echo $TARGET", funcact]) diff --git a/test/Actions/unicode-signature.py b/test/Actions/unicode-signature.py index d91bfa8..ef8c888 100644 --- a/test/Actions/unicode-signature.py +++ b/test/Actions/unicode-signature.py @@ -42,19 +42,7 @@ test = TestSCons.TestSCons() ## msg = "Unicode not supported by Python version %s; skipping test\n" ## test.skip_test(msg % sys.version[:3]) -test.write('SConstruct', """ -fnode = File(u'foo.txt') - -def funcact(target, source, env): - open(str(target[0]), 'wb').write("funcact\\n") - for i in range(300): - pass - return 0 - -env = Environment() - -env.Command(fnode, [], ["echo $TARGET", funcact]) -""") +test.dir_fixture('unicode-signature-fixture') test.run(arguments = '.') -- cgit v0.12 From d81a3387f0c6ab528986d25bd57a27f549cd0c91 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Tue, 20 Sep 2016 22:34:39 -0400 Subject: Updating to_str and to_bytes between QMTest and SCons.Util. -Added check to skip decode if already string; otherwise, throws TypeError. --- QMTest/TestCmd.py | 9 +++------ src/engine/SCons/Util.py | 8 +++----- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index d7b8d94..bff0d6a 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -339,15 +339,12 @@ def is_List(e): def to_bytes (s): if isinstance (s, bytes) or bytes is str: return s - else: - return bytes (s, 'utf-8') + return bytes (s, 'utf-8') def to_str (s): - if bytes is str: + if bytes is str or is_String(s): return s - elif not is_String(s): - return str (s, 'utf-8') - return s + return str (s, 'utf-8') try: eval('unicode') diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 4f4ac2d..6a7e4a1 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -1553,14 +1553,12 @@ del __revision__ def to_bytes (s): if isinstance (s, bytes) or bytes is str: return s - else: - return bytes (s, 'utf-8') + return bytes (s, 'utf-8') def to_str (s): - if bytes is str: + if bytes is str or is_String(s): return s - else: - return str (s, 'utf-8') + return str (s, 'utf-8') # Local Variables: # tab-width:4 -- cgit v0.12 From 5f4aa5312e2d37a271233d864573772ae2b512fe Mon Sep 17 00:00:00 2001 From: William Blevins Date: Tue, 20 Sep 2016 23:07:51 -0400 Subject: Fixed test/ZIP tests. --- test/ZIP/ZIP.py | 16 ++++++++-------- test/ZIP/ZIPCOM-fixture/.exclude_tests | 1 + test/ZIP/ZIPCOM-fixture/myzip.py | 6 ++++++ test/ZIP/ZIPCOM-fixture/test1.in | 2 ++ test/ZIP/ZIPCOM.py | 18 +----------------- test/ZIP/ZIPCOMSTR-fixture/.exclude_tests | 1 + test/ZIP/ZIPCOMSTR-fixture/aaa.in | 2 ++ test/ZIP/ZIPCOMSTR-fixture/myzip.py | 7 +++++++ test/ZIP/ZIPCOMSTR.py | 16 +--------------- 9 files changed, 29 insertions(+), 40 deletions(-) create mode 100644 test/ZIP/ZIPCOM-fixture/.exclude_tests create mode 100644 test/ZIP/ZIPCOM-fixture/myzip.py create mode 100644 test/ZIP/ZIPCOM-fixture/test1.in create mode 100644 test/ZIP/ZIPCOMSTR-fixture/.exclude_tests create mode 100644 test/ZIP/ZIPCOMSTR-fixture/aaa.in create mode 100644 test/ZIP/ZIPCOMSTR-fixture/myzip.py diff --git a/test/ZIP/ZIP.py b/test/ZIP/ZIP.py index f2acad8..f842caf 100644 --- a/test/ZIP/ZIP.py +++ b/test/ZIP/ZIP.py @@ -91,7 +91,7 @@ marker_out = test.workpath('marker.out').replace('\\', '\\\\') test.write('SConstruct', """\ def marker(target, source, env): - open(r'%s', 'wb').write("marker\\n") + open(r'%s', 'wb').write(b"marker\\n") f1 = Environment() zipcom = f1.Dictionary('ZIPCOM') if not isinstance(zipcom, list): @@ -117,24 +117,24 @@ f1.Zip(target = 'f4deflated.zip', source = sources, for f in ['file10', 'file11', 'file12', 'file13', 'file14', 'file15', 'file16', 'file17', 'file18']: - test.write(f, f + "\n") + test.write(f, (f + "\n").encode()) test.run(arguments = 'f1.zip', stderr = None) -test.fail_test(os.path.exists(test.workpath('marker.out'))) +test.must_not_exist(test.workpath('marker.out')) -test.fail_test(not os.path.exists(test.workpath('f1.zip'))) +test.must_exist(test.workpath('f1.zip')) test.run(arguments = 'f2.zip', stderr = None) -test.fail_test(test.read('marker.out') != 'marker\n') +test.must_match('marker.out', 'marker\n') -test.fail_test(not os.path.exists(test.workpath('f2.zip'))) +test.must_exist(test.workpath('f2.zip')) test.run(arguments = '.', stderr = None) -test.fail_test(os.path.exists(test.workpath('f3.zip'))) -test.fail_test(not os.path.exists(test.workpath('f3.xyzzy'))) +test.must_not_exist(test.workpath('f3.zip')) +test.must_exist(test.workpath('f3.xyzzy')) test.fail_test(zipfile_files("f1.zip") != ['file10', 'file11', 'file12']) diff --git a/test/ZIP/ZIPCOM-fixture/.exclude_tests b/test/ZIP/ZIPCOM-fixture/.exclude_tests new file mode 100644 index 0000000..dae6f60 --- /dev/null +++ b/test/ZIP/ZIPCOM-fixture/.exclude_tests @@ -0,0 +1 @@ +myzip.py diff --git a/test/ZIP/ZIPCOM-fixture/myzip.py b/test/ZIP/ZIPCOM-fixture/myzip.py new file mode 100644 index 0000000..adbc6ac --- /dev/null +++ b/test/ZIP/ZIPCOM-fixture/myzip.py @@ -0,0 +1,6 @@ +import sys +outfile = open(sys.argv[1], 'wb') +infile = open(sys.argv[2], 'rb') +for l in [l for l in infile.readlines() if l != b'/*zip*/\n']: + outfile.write(l) +sys.exit(0) diff --git a/test/ZIP/ZIPCOM-fixture/test1.in b/test/ZIP/ZIPCOM-fixture/test1.in new file mode 100644 index 0000000..0546626 --- /dev/null +++ b/test/ZIP/ZIPCOM-fixture/test1.in @@ -0,0 +1,2 @@ +test1.in +/*zip*/ diff --git a/test/ZIP/ZIPCOM.py b/test/ZIP/ZIPCOM.py index e982c58..4d84ccf 100644 --- a/test/ZIP/ZIPCOM.py +++ b/test/ZIP/ZIPCOM.py @@ -34,16 +34,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('myzip.py', r""" -import sys -outfile = open(sys.argv[1], 'wb') -infile = open(sys.argv[2], 'rb') -for l in [l for l in infile.readlines() if l != '/*zip*/\n']: - outfile.write(l) -sys.exit(0) -""") +test.dir_fixture('ZIPCOM-fixture') test.write('SConstruct', """ env = Environment(TOOLS = ['zip'], @@ -51,17 +42,10 @@ env = Environment(TOOLS = ['zip'], env.Zip('test1.zip', 'test1.in') """ % locals()) -test.write('test1.in', """\ -test1.in -/*zip*/ -""") - test.run() test.must_match('test1.zip', "test1.in\n") - - test.pass_test() # Local Variables: diff --git a/test/ZIP/ZIPCOMSTR-fixture/.exclude_tests b/test/ZIP/ZIPCOMSTR-fixture/.exclude_tests new file mode 100644 index 0000000..dae6f60 --- /dev/null +++ b/test/ZIP/ZIPCOMSTR-fixture/.exclude_tests @@ -0,0 +1 @@ +myzip.py diff --git a/test/ZIP/ZIPCOMSTR-fixture/aaa.in b/test/ZIP/ZIPCOMSTR-fixture/aaa.in new file mode 100644 index 0000000..8474a29 --- /dev/null +++ b/test/ZIP/ZIPCOMSTR-fixture/aaa.in @@ -0,0 +1,2 @@ +aaa.in +/*zip*/ diff --git a/test/ZIP/ZIPCOMSTR-fixture/myzip.py b/test/ZIP/ZIPCOMSTR-fixture/myzip.py new file mode 100644 index 0000000..f0fcc51 --- /dev/null +++ b/test/ZIP/ZIPCOMSTR-fixture/myzip.py @@ -0,0 +1,7 @@ +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in [l for l in infile.readlines() if l != b'/*zip*/\n']: + outfile.write(l) +sys.exit(0) diff --git a/test/ZIP/ZIPCOMSTR.py b/test/ZIP/ZIPCOMSTR.py index d91a48d..a26ed49 100644 --- a/test/ZIP/ZIPCOMSTR.py +++ b/test/ZIP/ZIPCOMSTR.py @@ -35,17 +35,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('myzip.py', """ -import sys -outfile = open(sys.argv[1], 'wb') -for f in sys.argv[2:]: - infile = open(f, 'rb') - for l in [l for l in infile.readlines() if l != '/*zip*/\\n']: - outfile.write(l) -sys.exit(0) -""") +test.dir_fixture('ZIPCOMSTR-fixture') test.write('SConstruct', """ env = Environment(tools=['zip'], @@ -54,16 +44,12 @@ env = Environment(tools=['zip'], env.Zip('aaa.zip', 'aaa.in') """ % locals()) -test.write('aaa.in', "aaa.in\n/*zip*/\n") - test.run(stdout = test.wrap_stdout("""\ Zipping aaa.zip from aaa.in """)) test.must_match('aaa.zip', "aaa.in\n") - - test.pass_test() # Local Variables: -- cgit v0.12 From f5035c6a61ad10f440a22c14ce22bbb1d6796f62 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Wed, 21 Sep 2016 12:57:57 -0400 Subject: More test fixes. --- test/ARGUMENTS.py | 4 ++-- test/AS/AS.py | 8 ++++---- test/AS/ASCOM.py | 18 +++++++++--------- test/AS/ASCOMSTR.py | 10 +++++----- test/AS/ASPPCOM.py | 10 +++++----- test/AS/ASPPCOMSTR.py | 6 +++--- test/AS/as-live.py | 2 +- test/AS/ml.py | 2 +- test/CC/CCCOM.py | 16 +--------------- test/CC/CCCOMSTR.py | 16 +--------------- test/CC/SHCC.py | 6 +++--- test/CC/SHCCCOM.py | 16 +--------------- test/CC/SHCCCOMSTR.py | 16 +--------------- test/CC/shared-fixture/.exclude_tests | 1 + test/CC/shared-fixture/mycc.py | 6 ++++++ test/CC/shared-fixture/test1.c | 2 ++ test/CFILESUFFIX.py | 2 +- test/SWIG/SWIGCOM.py | 2 +- test/SWIG/SWIGCOMSTR.py | 2 +- test/file-names.py | 6 +++--- 20 files changed, 52 insertions(+), 99 deletions(-) create mode 100644 test/CC/shared-fixture/.exclude_tests create mode 100644 test/CC/shared-fixture/mycc.py create mode 100644 test/CC/shared-fixture/test1.c diff --git a/test/ARGUMENTS.py b/test/ARGUMENTS.py index 4bd2f78..97c97c8 100644 --- a/test/ARGUMENTS.py +++ b/test/ARGUMENTS.py @@ -31,13 +31,13 @@ test = TestSCons.TestSCons() test.write('SConstruct', """ foo = open('foo.out', 'wb') for k in sorted(ARGUMENTS.keys()): - foo.write(k + " = " + ARGUMENTS[k] + "\\n") + foo.write((k + " = " + ARGUMENTS[k] + "\\n").encode()) foo.close() """) test.run(arguments='a=1 bz=3 xx=sd zzz=foo=bar .') -test.fail_test(test.read('foo.out') != """a = 1 +test.must_match('foo.out', """a = 1 bz = 3 xx = sd zzz = foo=bar diff --git a/test/AS/AS.py b/test/AS/AS.py index e0ffbf4..6ccf0cb 100644 --- a/test/AS/AS.py +++ b/test/AS/AS.py @@ -58,7 +58,7 @@ while args: infile = open(args[0], 'rb') outfile = open(out, 'wb') for l in infile.readlines(): - if l[:5] != '#link': + if l[:5] != b'#link': outfile.write(l) sys.exit(0) """) @@ -82,7 +82,7 @@ while args: infile = open(inf, 'rb') outfile = open(out, 'wb') for l in infile.readlines(): - if l[:3] != '#as': + if l[:3] != b'#as': outfile.write(l) sys.exit(0) """) @@ -98,7 +98,7 @@ for opt, arg in opts: infile = open(args[0], 'rb') outfile = open(out, 'wb') for l in infile.readlines(): - if l[:5] != '#link': + if l[:5] != b'#link': outfile.write(l) sys.exit(0) """) @@ -112,7 +112,7 @@ for opt, arg in opts: infile = open(args[0], 'rb') outfile = open(out, 'wb') for l in infile.readlines(): - if l[:3] != '#as': + if l[:3] != b'#as': outfile.write(l) sys.exit(0) """) diff --git a/test/AS/ASCOM.py b/test/AS/ASCOM.py index 568bd00..8f91404 100644 --- a/test/AS/ASCOM.py +++ b/test/AS/ASCOM.py @@ -42,7 +42,7 @@ test.write('myas.py', r""" import sys infile = open(sys.argv[2], 'rb') outfile = open(sys.argv[1], 'wb') -for l in [l for l in infile.readlines() if l != "#as\n"]: +for l in [l for l in infile.readlines() if l != b"#as\n"]: outfile.write(l) sys.exit(0) """) @@ -80,14 +80,14 @@ test.write('test8'+alt_asm_suffix, "test8.ASM\n#as\n") test.run(arguments = '.') -test.fail_test(test.read('test1.obj') != "test1.s\n") -test.fail_test(test.read('test2.obj') != "test2.S\n") -test.fail_test(test.read('test3.obj') != "test3.asm\n") -test.fail_test(test.read('test4.obj') != "test4.ASM\n") -test.fail_test(test.read('test5.shobj') != "test5.s\n") -test.fail_test(test.read('test6.shobj') != "test6.S\n") -test.fail_test(test.read('test7.shobj') != "test7.asm\n") -test.fail_test(test.read('test8.shobj') != "test8.ASM\n") +test.must_match('test1.obj', "test1.s\n") +test.must_match('test2.obj', "test2.S\n") +test.must_match('test3.obj', "test3.asm\n") +test.must_match('test4.obj', "test4.ASM\n") +test.must_match('test5.shobj', "test5.s\n") +test.must_match('test6.shobj', "test6.S\n") +test.must_match('test7.shobj', "test7.asm\n") +test.must_match('test8.shobj', "test8.ASM\n") diff --git a/test/AS/ASCOMSTR.py b/test/AS/ASCOMSTR.py index f7cc34e..39b963f 100644 --- a/test/AS/ASCOMSTR.py +++ b/test/AS/ASCOMSTR.py @@ -43,7 +43,7 @@ test.write('myas.py', r""" import sys infile = open(sys.argv[2], 'rb') outfile = open(sys.argv[1], 'wb') -for l in [l for l in infile.readlines() if l != "#as\n"]: +for l in [l for l in infile.readlines() if l != b"#as\n"]: outfile.write(l) sys.exit(0) """) @@ -77,10 +77,10 @@ Assembling test3.obj from test3.asm Assembling test4.obj from test4%(alt_asm_suffix)s """ % locals())) -test.fail_test(test.read('test1.obj') != "test1.s\n") -test.fail_test(test.read('test2.obj') != "test2.S\n") -test.fail_test(test.read('test3.obj') != "test3.asm\n") -test.fail_test(test.read('test4.obj') != "test4.ASM\n") +test.must_match('test1.obj', "test1.s\n") +test.must_match('test2.obj', "test2.S\n") +test.must_match('test3.obj', "test3.asm\n") +test.must_match('test4.obj', "test4.ASM\n") diff --git a/test/AS/ASPPCOM.py b/test/AS/ASPPCOM.py index f89306e..62f859a 100644 --- a/test/AS/ASPPCOM.py +++ b/test/AS/ASPPCOM.py @@ -40,7 +40,7 @@ test.write('myas.py', r""" import sys infile = open(sys.argv[2], 'rb') outfile = open(sys.argv[1], 'wb') -for l in [l for l in infile.readlines() if l != "#as\n"]: +for l in [l for l in infile.readlines() if l != b"#as\n"]: outfile.write(l) sys.exit(0) """) @@ -63,10 +63,10 @@ test.write('test4.SPP', "test4.SPP\n#as\n") test.run(arguments = '.') -test.fail_test(test.read('test1.obj') != "test1.spp\n") -test.fail_test(test.read('test2.obj') != "test2.SPP\n") -test.fail_test(test.read('test3.shobj') != "test3.spp\n") -test.fail_test(test.read('test4.shobj') != "test4.SPP\n") +test.must_match('test1.obj', "test1.spp\n") +test.must_match('test2.obj', "test2.SPP\n") +test.must_match('test3.shobj', "test3.spp\n") +test.must_match('test4.shobj', "test4.SPP\n") diff --git a/test/AS/ASPPCOMSTR.py b/test/AS/ASPPCOMSTR.py index 7de3b12..0497470 100644 --- a/test/AS/ASPPCOMSTR.py +++ b/test/AS/ASPPCOMSTR.py @@ -41,7 +41,7 @@ test.write('myas.py', r""" import sys infile = open(sys.argv[2], 'rb') outfile = open(sys.argv[1], 'wb') -for l in [l for l in infile.readlines() if l != "#as\n"]: +for l in [l for l in infile.readlines() if l != b"#as\n"]: outfile.write(l) sys.exit(0) """) @@ -62,8 +62,8 @@ Assembling test1.obj from test1.spp Assembling test2.obj from test2.SPP """)) -test.fail_test(test.read('test1.obj') != "test1.spp\n") -test.fail_test(test.read('test2.obj') != "test2.SPP\n") +test.must_match('test1.obj', "test1.spp\n") +test.must_match('test2.obj', "test2.SPP\n") diff --git a/test/AS/as-live.py b/test/AS/as-live.py index 801eeca..879e7b2 100644 --- a/test/AS/as-live.py +++ b/test/AS/as-live.py @@ -58,7 +58,7 @@ if sys.platform == "win32": test.write("wrapper.py", """\ import os import sys -open('%s', 'wb').write("wrapper.py: %%s\\n" %% sys.argv[-1]) +open('%s', 'wb').write(("wrapper.py: %%s\\n" %% sys.argv[-1]).encode()) cmd = " ".join(sys.argv[1:]) os.system(cmd) """ % test.workpath('wrapper.out').replace('\\', '\\\\')) diff --git a/test/AS/ml.py b/test/AS/ml.py index 9491e36..c377172 100644 --- a/test/AS/ml.py +++ b/test/AS/ml.py @@ -48,7 +48,7 @@ if not ml: test.write("wrapper.py", """import os import sys -open('%s', 'wb').write("wrapper.py\\n") +open('%s', 'wb').write(b"wrapper.py\\n") os.system(" ".join(sys.argv[1:])) """ % test.workpath('wrapper.out').replace('\\', '\\\\')) diff --git a/test/CC/CCCOM.py b/test/CC/CCCOM.py index 8d06942..f930ecd 100644 --- a/test/CC/CCCOM.py +++ b/test/CC/CCCOM.py @@ -37,16 +37,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() - - -test.write('mycc.py', r""" -import sys -outfile = open(sys.argv[1], 'wb') -infile = open(sys.argv[2], 'rb') -for l in [l for l in infile.readlines() if l[:6] != '/*cc*/']: - outfile.write(l) -sys.exit(0) -""") +test.dir_fixture('shared-fixture') if os.path.normcase('.c') == os.path.normcase('.C'): alt_c_suffix = '.C' @@ -60,11 +51,6 @@ env.Object(target = 'test1', source = 'test1.c') env.Object(target = 'test2', source = 'test2%(alt_c_suffix)s') """ % locals()) -test.write('test1.c', """\ -test1.c -/*cc*/ -""") - test.write('test2'+alt_c_suffix, """\ test2.C /*cc*/ diff --git a/test/CC/CCCOMSTR.py b/test/CC/CCCOMSTR.py index 6874406..0be9971 100644 --- a/test/CC/CCCOMSTR.py +++ b/test/CC/CCCOMSTR.py @@ -38,16 +38,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() - - -test.write('mycc.py', r""" -import sys -outfile = open(sys.argv[1], 'wb') -infile = open(sys.argv[2], 'rb') -for l in [l for l in infile.readlines() if l[:6] != '/*cc*/']: - outfile.write(l) -sys.exit(0) -""") +test.dir_fixture('shared-fixture') if os.path.normcase('.c') == os.path.normcase('.C'): alt_c_suffix = '.C' @@ -62,11 +53,6 @@ env.Object(target = 'test1', source = 'test1.c') env.Object(target = 'test2', source = 'test2%(alt_c_suffix)s') """ % locals()) -test.write('test1.c', """\ -test1.c -/*cc*/ -""") - test.write('test2'+alt_c_suffix, """\ test2.C /*cc*/ diff --git a/test/CC/SHCC.py b/test/CC/SHCC.py index b624bf2..5f121fc 100644 --- a/test/CC/SHCC.py +++ b/test/CC/SHCC.py @@ -35,7 +35,7 @@ test = TestSCons.TestSCons() test.write("wrapper.py", """import os import sys -open('%s', 'wb').write("wrapper.py\\n") +open('%s', 'wb').write(b"wrapper.py\\n") os.system(" ".join(sys.argv[1:])) """ % test.workpath('wrapper.out').replace('\\', '\\\\')) @@ -76,11 +76,11 @@ main(int argc, char *argv[]) test.run(arguments = 'foo') -test.fail_test(os.path.exists(test.workpath('wrapper.out'))) +test.must_not_exist(test.workpath('wrapper.out')) test.run(arguments = 'bar') -test.fail_test(test.read('wrapper.out') != "wrapper.py\n") +test.must_match('wrapper.out', "wrapper.py\n") test.pass_test() diff --git a/test/CC/SHCCCOM.py b/test/CC/SHCCCOM.py index 006a80e..689b6e7 100644 --- a/test/CC/SHCCCOM.py +++ b/test/CC/SHCCCOM.py @@ -36,16 +36,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('mycc.py', r""" -import sys -outfile = open(sys.argv[1], 'wb') -infile = open(sys.argv[2], 'rb') -for l in [l for l in infile.readlines() if l[:6] != '/*cc*/']: - outfile.write(l) -sys.exit(0) -""") +test.dir_fixture('shared-fixture') if os.path.normcase('.c') == os.path.normcase('.C'): alt_c_suffix = '.C' @@ -60,11 +51,6 @@ env.SharedObject(target = 'test1', source = 'test1.c') env.SharedObject(target = 'test2', source = 'test2%(alt_c_suffix)s') """ % locals()) -test.write('test1.c', """\ -test1.c -/*cc*/ -""") - test.write('test2'+alt_c_suffix, """\ test2.C /*cc*/ diff --git a/test/CC/SHCCCOMSTR.py b/test/CC/SHCCCOMSTR.py index 15bfa85..0983a67 100644 --- a/test/CC/SHCCCOMSTR.py +++ b/test/CC/SHCCCOMSTR.py @@ -38,16 +38,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() - - -test.write('mycc.py', r""" -import sys -outfile = open(sys.argv[1], 'wb') -infile = open(sys.argv[2], 'rb') -for l in [l for l in infile.readlines() if l[:6] != '/*cc*/']: - outfile.write(l) -sys.exit(0) -""") +test.dir_fixture('shared-fixture') if os.path.normcase('.c') == os.path.normcase('.C'): alt_c_suffix = '.C' @@ -63,11 +54,6 @@ env.SharedObject(target = 'test1', source = 'test1.c') env.SharedObject(target = 'test2', source = 'test2%(alt_c_suffix)s') """ % locals()) -test.write('test1.c', """\ -test1.c -/*cc*/ -""") - test.write('test2'+alt_c_suffix, """\ test2.C /*cc*/ diff --git a/test/CC/shared-fixture/.exclude_tests b/test/CC/shared-fixture/.exclude_tests new file mode 100644 index 0000000..3f2bc0f --- /dev/null +++ b/test/CC/shared-fixture/.exclude_tests @@ -0,0 +1 @@ +mycc.py diff --git a/test/CC/shared-fixture/mycc.py b/test/CC/shared-fixture/mycc.py new file mode 100644 index 0000000..b96c31c --- /dev/null +++ b/test/CC/shared-fixture/mycc.py @@ -0,0 +1,6 @@ +import sys +outfile = open(sys.argv[1], 'wb') +infile = open(sys.argv[2], 'rb') +for l in [l for l in infile.readlines() if l[:6] != b'/*cc*/']: + outfile.write(l) +sys.exit(0) diff --git a/test/CC/shared-fixture/test1.c b/test/CC/shared-fixture/test1.c new file mode 100644 index 0000000..9c281d7 --- /dev/null +++ b/test/CC/shared-fixture/test1.c @@ -0,0 +1,2 @@ +test1.c +/*cc*/ diff --git a/test/CFILESUFFIX.py b/test/CFILESUFFIX.py index 1a81240..0a3a81a 100644 --- a/test/CFILESUFFIX.py +++ b/test/CFILESUFFIX.py @@ -42,7 +42,7 @@ import sys cmd_opts, args = getopt.getopt(sys.argv[1:], 't', []) for a in args: contents = open(a, 'rb').read() - sys.stdout.write(contents.replace('LEX', 'mylex.py')) + sys.stdout.write((contents.replace(b'LEX', b'mylex.py')).decode()) sys.exit(0) """) diff --git a/test/SWIG/SWIGCOM.py b/test/SWIG/SWIGCOM.py index 44602fd..ee3ff64 100644 --- a/test/SWIG/SWIGCOM.py +++ b/test/SWIG/SWIGCOM.py @@ -41,7 +41,7 @@ import sys outfile = open(sys.argv[1], 'wb') for f in sys.argv[2:]: infile = open(f, 'rb') - for l in [l for l in infile.readlines() if l != '/*swig*/\\n']: + for l in [l for l in infile.readlines() if l != b'/*swig*/\\n']: outfile.write(l) sys.exit(0) """) diff --git a/test/SWIG/SWIGCOMSTR.py b/test/SWIG/SWIGCOMSTR.py index 1df3499..24db13e 100644 --- a/test/SWIG/SWIGCOMSTR.py +++ b/test/SWIG/SWIGCOMSTR.py @@ -42,7 +42,7 @@ import sys outfile = open(sys.argv[1], 'wb') for f in sys.argv[2:]: infile = open(f, 'rb') - for l in [l for l in infile.readlines() if l != '/*swig*/\\n']: + for l in [l for l in infile.readlines() if l != b'/*swig*/\\n']: outfile.write(l) sys.exit(0) """) diff --git a/test/file-names.py b/test/file-names.py index d9f9c63..4b89126 100644 --- a/test/file-names.py +++ b/test/file-names.py @@ -119,10 +119,10 @@ for c in goodChars: c_str = ("%d"%ord(c[-1]))+c if not invalid_leading_char(c): - test.fail_test(test.read(c_str + "out") != contents(c)) - test.fail_test(test.read("out" + c_str + "out") != contents(c)) + test.must_match(c_str + "out", contents(c)) + test.must_match("out" + c_str + "out", contents(c)) if not invalid_trailing_char(c): - test.fail_test(test.read("out" + c_str) != contents(c)) + test.must_match("out" + c_str, contents(c)) test.pass_test() -- cgit v0.12 From 88eb753eb8e65721368beb2fc1247312e2a5ab4c Mon Sep 17 00:00:00 2001 From: William Blevins Date: Wed, 21 Sep 2016 19:54:23 -0400 Subject: Fixed difference in types MethodType argument list between 2/3 which allowed finishing CC folder. --- src/engine/SCons/Util.py | 16 ++++++--- test/CC/CC-fixture/bar.c | 10 ++++++ test/CC/CC-fixture/foo.c | 10 ++++++ test/CC/CC-fixture/test1.c | 3 ++ test/CC/CC-fixture/test2.C | 3 ++ test/CC/CC.py | 57 +++++--------------------------- test/CC/CCVERSION-fixture/.exclude_tests | 1 + test/CC/CCVERSION-fixture/versioned.py | 12 +++++++ test/CC/CCVERSION.py | 29 ++-------------- 9 files changed, 61 insertions(+), 80 deletions(-) create mode 100644 test/CC/CC-fixture/bar.c create mode 100644 test/CC/CC-fixture/foo.c create mode 100644 test/CC/CC-fixture/test1.c create mode 100644 test/CC/CC-fixture/test2.C create mode 100644 test/CC/CCVERSION-fixture/.exclude_tests create mode 100644 test/CC/CCVERSION-fixture/versioned.py diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 6a7e4a1..7653acd 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -1425,14 +1425,22 @@ def AddMethod(obj, function, name=None): else: function = RenameFunction(function, name) + # Note the Python version checks - WLB + # Python 3.3 dropped the 3rd parameter from types.MethodType if hasattr(obj, '__class__') and obj.__class__ is not type: # "obj" is an instance, so it gets a bound method. - method = MethodType(function, obj, obj.__class__) - setattr(obj, name, method) + if sys.version_info[:2] > (3, 2): + method = MethodType(function, obj) + else: + method = MethodType(function, obj, obj.__class__) else: # "obj" is a class, so it gets an unbound method. - function = MethodType(function, None, obj) - setattr(obj, name, function) + if sys.version_info[:2] > (3, 2): + method = MethodType(function, None) + else: + method = MethodType(function, None, obj) + + setattr(obj, name, method) def RenameFunction(function, name): """ diff --git a/test/CC/CC-fixture/bar.c b/test/CC/CC-fixture/bar.c new file mode 100644 index 0000000..de1e6e5 --- /dev/null +++ b/test/CC/CC-fixture/bar.c @@ -0,0 +1,10 @@ +#include +#include + +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf("foo.c\n"); + exit (0); +} diff --git a/test/CC/CC-fixture/foo.c b/test/CC/CC-fixture/foo.c new file mode 100644 index 0000000..de1e6e5 --- /dev/null +++ b/test/CC/CC-fixture/foo.c @@ -0,0 +1,10 @@ +#include +#include + +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf("foo.c\n"); + exit (0); +} diff --git a/test/CC/CC-fixture/test1.c b/test/CC/CC-fixture/test1.c new file mode 100644 index 0000000..7535b0a --- /dev/null +++ b/test/CC/CC-fixture/test1.c @@ -0,0 +1,3 @@ +This is a .c file. +/*cc*/ +/*link*/ diff --git a/test/CC/CC-fixture/test2.C b/test/CC/CC-fixture/test2.C new file mode 100644 index 0000000..a1ee9e3 --- /dev/null +++ b/test/CC/CC-fixture/test2.C @@ -0,0 +1,3 @@ +This is a .C file. +/*cc*/ +/*link*/ diff --git a/test/CC/CC.py b/test/CC/CC.py index 9500088..7478cbe 100644 --- a/test/CC/CC.py +++ b/test/CC/CC.py @@ -33,7 +33,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() - +test.dir_fixture('CC-fixture') if sys.platform == 'win32': @@ -53,7 +53,7 @@ while args: infile = open(args[0], 'rb') outfile = open(out, 'wb') for l in infile.readlines(): - if l[:8] != '/*link*/': + if l[:8] != b'/*link*/': outfile.write(l) sys.exit(0) """) @@ -77,7 +77,7 @@ while args: infile = open(inf, 'rb') outfile = open(out, 'wb') for l in infile.readlines(): - if l[:6] != '/*cc*/': + if l[:6] != b'/*cc*/': outfile.write(l) sys.exit(0) """) @@ -93,7 +93,7 @@ for opt, arg in opts: infile = open(args[0], 'rb') outfile = open(out, 'wb') for l in infile.readlines(): - if l[:8] != '/*link*/': + if l[:8] != b'/*link*/': outfile.write(l) sys.exit(0) """) @@ -107,7 +107,7 @@ for opt, arg in opts: infile = open(args[0], 'rb') outfile = open(out, 'wb') for l in infile.readlines(): - if l[:6] != '/*cc*/': + if l[:6] != b'/*cc*/': outfile.write(l) sys.exit(0) """) @@ -122,14 +122,9 @@ env = Environment(LINK = r'%(_python_)s mylink.py', env.Program(target = 'test1', source = 'test1.c') """ % locals()) -test.write('test1.c', r"""This is a .c file. -/*cc*/ -/*link*/ -""") - test.run(arguments = '.', stderr = None) -test.fail_test(test.read('test1' + _exe) != "This is a .c file.\n") +test.must_match('test1' + _exe, "This is a .c file.\n") if os.path.normcase('.c') == os.path.normcase('.C'): @@ -141,23 +136,14 @@ env = Environment(LINK = r'%(_python_)s mylink.py', env.Program(target = 'test2', source = 'test2.C') """ % locals()) - test.write('test2.C', r"""This is a .C file. -/*cc*/ -/*link*/ -""") - test.run(arguments = '.', stderr = None) - - test.fail_test(test.read('test2' + _exe) != "This is a .C file.\n") - - - + test.must_match('test2' + _exe, "This is a .C file.\n") test.write("wrapper.py", """import os import sys if '--version' not in sys.argv and '-dumpversion' not in sys.argv: - open('%s', 'wb').write("wrapper.py\\n") + open('%s', 'wb').write(b"wrapper.py\\n") os.system(" ".join(sys.argv[1:])) """ % test.workpath('wrapper.out').replace('\\', '\\\\')) @@ -169,33 +155,6 @@ foo.Program(target = 'foo', source = 'foo.c') bar.Program(target = 'bar', source = 'bar.c') """ % locals()) -test.write('foo.c', r""" -#include -#include - -int -main(int argc, char *argv[]) -{ - argv[argc++] = "--"; - printf("foo.c\n"); - exit (0); -} -""") - -test.write('bar.c', r""" -#include -#include - -int -main(int argc, char *argv[]) -{ - argv[argc++] = "--"; - printf("foo.c\n"); - exit (0); -} -""") - - test.run(arguments = 'foo' + _exe) test.must_not_exist(test.workpath('wrapper.out')) diff --git a/test/CC/CCVERSION-fixture/.exclude_tests b/test/CC/CCVERSION-fixture/.exclude_tests new file mode 100644 index 0000000..775816e --- /dev/null +++ b/test/CC/CCVERSION-fixture/.exclude_tests @@ -0,0 +1 @@ +versioned.py diff --git a/test/CC/CCVERSION-fixture/versioned.py b/test/CC/CCVERSION-fixture/versioned.py new file mode 100644 index 0000000..d6c7ae8 --- /dev/null +++ b/test/CC/CCVERSION-fixture/versioned.py @@ -0,0 +1,12 @@ +import os +import sys +if '-dumpversion' in sys.argv: + print('3.9.9') + sys.exit(0) +if '--version' in sys.argv: + print('this is version 2.9.9 wrapping', sys.argv[2]) + sys.exit(0) +if sys.argv[1] not in [ '2.9.9', '3.9.9' ]: + print('wrong version', sys.argv[1], 'when wrapping', sys.argv[2]) + sys.exit(1) +os.system(" ".join(sys.argv[2:])) diff --git a/test/CC/CCVERSION.py b/test/CC/CCVERSION.py index f785ddc..20d8616 100644 --- a/test/CC/CCVERSION.py +++ b/test/CC/CCVERSION.py @@ -36,20 +36,8 @@ test = TestSCons.TestSCons() if sys.platform == 'win32': test.skip_test('CCVERSION not set with MSVC, skipping test.') -test.write("versioned.py", -"""import os -import sys -if '-dumpversion' in sys.argv: - print '3.9.9' - sys.exit(0) -if '--version' in sys.argv: - print 'this is version 2.9.9 wrapping', sys.argv[2] - sys.exit(0) -if sys.argv[1] not in [ '2.9.9', '3.9.9' ]: - print 'wrong version', sys.argv[1], 'when wrapping', sys.argv[2] - sys.exit(1) -os.system(" ".join(sys.argv[2:])) -""") +test.dir_fixture('CCVERSION-fixture') +test.file_fixture(os.path.join('CC-fixture', 'foo.c')) test.write('SConstruct', """ cc = Environment().Dictionary('CC') @@ -57,19 +45,6 @@ foo = Environment(CC = r'%(_python_)s versioned.py "${CCVERSION}" ' + cc) foo.Program(target = 'foo', source = 'foo.c') """ % locals()) -test.write('foo.c', r""" -#include -#include - -int -main(int argc, char *argv[]) -{ - argv[argc++] = "--"; - printf("foo.c\n"); - exit (0); -} -""") - test.run(arguments = 'foo' + _exe) test.up_to_date(arguments = 'foo' + _exe) -- cgit v0.12 From bea6d372a175aff23d05b6a513c2df53aaa6fa87 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Wed, 21 Sep 2016 20:47:35 -0400 Subject: Fixed the YACC tests. --- test/YACC/YACC-fixture/.exclude_tests | 1 + test/YACC/YACC-fixture/aaa.y | 2 ++ test/YACC/YACC-fixture/bbb.yacc | 2 ++ test/YACC/YACC-fixture/ccc.yy | 2 ++ test/YACC/YACC-fixture/ddd.ym | 2 ++ test/YACC/YACC-fixture/myyacc.py | 13 +++++++++++++ test/YACC/YACC.py | 25 +------------------------ test/YACC/YACCCOM-fixture/.exclude_tests | 1 + test/YACC/YACCCOM-fixture/myyacc.py | 7 +++++++ test/YACC/YACCCOM.py | 16 ++-------------- test/YACC/YACCCOMSTR.py | 16 ++-------------- test/YACC/YACCFLAGS-fixture/.exclude_tests | 1 + test/YACC/YACCFLAGS-fixture/myyacc.py | 17 +++++++++++++++++ test/YACC/YACCFLAGS.py | 22 +--------------------- test/YACC/YACCHFILESUFFIX.py | 4 ++-- test/YACC/YACCHXXFILESUFFIX.py | 4 ++-- test/YACC/YACCVCGFILESUFFIX.py | 4 ++-- test/YACC/shared-fixture/.exclude_tests | 1 + test/YACC/shared-fixture/aaa.y | 2 ++ test/YACC/shared-fixture/bbb.yacc | 2 ++ 20 files changed, 65 insertions(+), 79 deletions(-) create mode 100644 test/YACC/YACC-fixture/.exclude_tests create mode 100644 test/YACC/YACC-fixture/aaa.y create mode 100644 test/YACC/YACC-fixture/bbb.yacc create mode 100644 test/YACC/YACC-fixture/ccc.yy create mode 100644 test/YACC/YACC-fixture/ddd.ym create mode 100644 test/YACC/YACC-fixture/myyacc.py create mode 100644 test/YACC/YACCCOM-fixture/.exclude_tests create mode 100644 test/YACC/YACCCOM-fixture/myyacc.py create mode 100644 test/YACC/YACCFLAGS-fixture/.exclude_tests create mode 100644 test/YACC/YACCFLAGS-fixture/myyacc.py create mode 100644 test/YACC/shared-fixture/.exclude_tests create mode 100644 test/YACC/shared-fixture/aaa.y create mode 100644 test/YACC/shared-fixture/bbb.yacc diff --git a/test/YACC/YACC-fixture/.exclude_tests b/test/YACC/YACC-fixture/.exclude_tests new file mode 100644 index 0000000..f12c4d0 --- /dev/null +++ b/test/YACC/YACC-fixture/.exclude_tests @@ -0,0 +1 @@ +myyacc.py diff --git a/test/YACC/YACC-fixture/aaa.y b/test/YACC/YACC-fixture/aaa.y new file mode 100644 index 0000000..dab6e40 --- /dev/null +++ b/test/YACC/YACC-fixture/aaa.y @@ -0,0 +1,2 @@ +aaa.y +YACC diff --git a/test/YACC/YACC-fixture/bbb.yacc b/test/YACC/YACC-fixture/bbb.yacc new file mode 100644 index 0000000..ca4ab73 --- /dev/null +++ b/test/YACC/YACC-fixture/bbb.yacc @@ -0,0 +1,2 @@ +bbb.yacc +YACC diff --git a/test/YACC/YACC-fixture/ccc.yy b/test/YACC/YACC-fixture/ccc.yy new file mode 100644 index 0000000..c7ec552 --- /dev/null +++ b/test/YACC/YACC-fixture/ccc.yy @@ -0,0 +1,2 @@ +ccc.yacc +YACC diff --git a/test/YACC/YACC-fixture/ddd.ym b/test/YACC/YACC-fixture/ddd.ym new file mode 100644 index 0000000..c8962be --- /dev/null +++ b/test/YACC/YACC-fixture/ddd.ym @@ -0,0 +1,2 @@ +ddd.yacc +YACC diff --git a/test/YACC/YACC-fixture/myyacc.py b/test/YACC/YACC-fixture/myyacc.py new file mode 100644 index 0000000..c2e1abf --- /dev/null +++ b/test/YACC/YACC-fixture/myyacc.py @@ -0,0 +1,13 @@ +import getopt +import sys +cmd_opts, args = getopt.getopt(sys.argv[1:], 'o:', []) +output = None +opt_string = '' +for opt, arg in cmd_opts: + if opt == '-o': output = open(arg, 'wb') + else: opt_string = opt_string + ' ' + opt +for a in args: + contents = open(a, 'rb').read() + output.write(contents.replace(b'YACC', b'myyacc.py')) +output.close() +sys.exit(0) diff --git a/test/YACC/YACC.py b/test/YACC/YACC.py index 59067f3..3fc1f7c 100644 --- a/test/YACC/YACC.py +++ b/test/YACC/YACC.py @@ -41,25 +41,7 @@ else: test = TestSCons.TestSCons() - - -test.write('myyacc.py', """ -import getopt -import sys -cmd_opts, args = getopt.getopt(sys.argv[1:], 'o:', []) -output = None -opt_string = '' -for opt, arg in cmd_opts: - if opt == '-o': output = open(arg, 'wb') - else: opt_string = opt_string + ' ' + opt -for a in args: - contents = open(a, 'rb').read() - output.write(contents.replace('YACC', 'myyacc.py')) -output.close() -sys.exit(0) -""") - - +test.dir_fixture('YACC-fixture') test.write('SConstruct', """ env = Environment(YACC = r'%(_python_)s myyacc.py', tools=['default', 'yacc']) @@ -69,11 +51,6 @@ env.CXXFile(target = 'ccc', source = 'ccc.yy') env.CFile(target = 'ddd', source = 'ddd.ym') """ % locals()) -test.write('aaa.y', "aaa.y\nYACC\n") -test.write('bbb.yacc', "bbb.yacc\nYACC\n") -test.write('ccc.yy', "ccc.yacc\nYACC\n") -test.write('ddd.ym', "ddd.yacc\nYACC\n") - test.run(arguments = '.', stderr = None) test.must_match('aaa.c', "aaa.y\nmyyacc.py\n") diff --git a/test/YACC/YACCCOM-fixture/.exclude_tests b/test/YACC/YACCCOM-fixture/.exclude_tests new file mode 100644 index 0000000..f12c4d0 --- /dev/null +++ b/test/YACC/YACCCOM-fixture/.exclude_tests @@ -0,0 +1 @@ +myyacc.py diff --git a/test/YACC/YACCCOM-fixture/myyacc.py b/test/YACC/YACCCOM-fixture/myyacc.py new file mode 100644 index 0000000..1502800 --- /dev/null +++ b/test/YACC/YACCCOM-fixture/myyacc.py @@ -0,0 +1,7 @@ +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in [l for l in infile.readlines() if l != b'/*yacc*/\n']: + outfile.write(l) +sys.exit(0) diff --git a/test/YACC/YACCCOM.py b/test/YACC/YACCCOM.py index 4e43676..70ffa72 100644 --- a/test/YACC/YACCCOM.py +++ b/test/YACC/YACCCOM.py @@ -34,17 +34,8 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('myyacc.py', """ -import sys -outfile = open(sys.argv[1], 'wb') -for f in sys.argv[2:]: - infile = open(f, 'rb') - for l in [l for l in infile.readlines() if l != '/*yacc*/\\n']: - outfile.write(l) -sys.exit(0) -""") +test.dir_fixture('shared-fixture') +test.dir_fixture('YACCCOM-fixture') test.write('SConstruct', """ env = Environment(tools=['default', 'yacc'], @@ -53,9 +44,6 @@ env.CFile(target = 'aaa', source = 'aaa.y') env.CFile(target = 'bbb', source = 'bbb.yacc') """ % locals()) -test.write('aaa.y', "aaa.y\n/*yacc*/\n") -test.write('bbb.yacc', "bbb.yacc\n/*yacc*/\n") - test.run(arguments = '.') test.must_match('aaa.c', "aaa.y\n") diff --git a/test/YACC/YACCCOMSTR.py b/test/YACC/YACCCOMSTR.py index eaf3fde..344b715 100644 --- a/test/YACC/YACCCOMSTR.py +++ b/test/YACC/YACCCOMSTR.py @@ -35,17 +35,8 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() - - -test.write('myyacc.py', """ -import sys -outfile = open(sys.argv[1], 'wb') -for f in sys.argv[2:]: - infile = open(f, 'rb') - for l in [l for l in infile.readlines() if l != '/*yacc*/\\n']: - outfile.write(l) -sys.exit(0) -""") +test.dir_fixture('shared-fixture') +test.dir_fixture('YACCCOM-fixture') test.write('SConstruct', """ env = Environment(tools=['default', 'yacc'], @@ -55,9 +46,6 @@ env.CFile(target = 'aaa', source = 'aaa.y') env.CFile(target = 'bbb', source = 'bbb.yacc') """ % locals()) -test.write('aaa.y', "aaa.y\n/*yacc*/\n") -test.write('bbb.yacc', "bbb.yacc\n/*yacc*/\n") - test.run(stdout = test.wrap_stdout("""\ Yaccing aaa.c from aaa.y Yaccing bbb.c from bbb.yacc diff --git a/test/YACC/YACCFLAGS-fixture/.exclude_tests b/test/YACC/YACCFLAGS-fixture/.exclude_tests new file mode 100644 index 0000000..f12c4d0 --- /dev/null +++ b/test/YACC/YACCFLAGS-fixture/.exclude_tests @@ -0,0 +1 @@ +myyacc.py diff --git a/test/YACC/YACCFLAGS-fixture/myyacc.py b/test/YACC/YACCFLAGS-fixture/myyacc.py new file mode 100644 index 0000000..ffd9031 --- /dev/null +++ b/test/YACC/YACCFLAGS-fixture/myyacc.py @@ -0,0 +1,17 @@ +import getopt +import sys +cmd_opts, args = getopt.getopt(sys.argv[1:], 'o:I:x', []) +output = None +opt_string = '' +i_arguments = '' +for opt, arg in cmd_opts: + if opt == '-o': output = open(arg, 'wb') + elif opt == '-I': i_arguments = i_arguments + ' ' + arg + else: opt_string = opt_string + ' ' + opt +for a in args: + contents = open(a, 'rb').read() + contents = contents.replace(b'YACCFLAGS', opt_string.encode()) + contents = contents.replace(b'I_ARGS', i_arguments.encode()) + output.write(contents) +output.close() +sys.exit(0) diff --git a/test/YACC/YACCFLAGS.py b/test/YACC/YACCFLAGS.py index f0b698b..b3f86fe 100644 --- a/test/YACC/YACCFLAGS.py +++ b/test/YACC/YACCFLAGS.py @@ -43,27 +43,7 @@ test = TestSCons.TestSCons() test.subdir('in') - - -test.write('myyacc.py', """ -import getopt -import sys -cmd_opts, args = getopt.getopt(sys.argv[1:], 'o:I:x', []) -output = None -opt_string = '' -i_arguments = '' -for opt, arg in cmd_opts: - if opt == '-o': output = open(arg, 'wb') - elif opt == '-I': i_arguments = i_arguments + ' ' + arg - else: opt_string = opt_string + ' ' + opt -for a in args: - contents = open(a, 'rb').read() - contents = contents.replace('YACCFLAGS', opt_string) - contents = contents.replace('I_ARGS', i_arguments) - output.write(contents) -output.close() -sys.exit(0) -""") +test.dir_fixture('YACCFLAGS-fixture') test.write('SConstruct', """ env = Environment(YACC = r'%(_python_)s myyacc.py', diff --git a/test/YACC/YACCHFILESUFFIX.py b/test/YACC/YACCHFILESUFFIX.py index 8801aea..f205473 100644 --- a/test/YACC/YACCHFILESUFFIX.py +++ b/test/YACC/YACCHFILESUFFIX.py @@ -47,11 +47,11 @@ for o, a in opts: outfile = open(a, 'wb') for f in args: infile = open(f, 'rb') - for l in [l for l in infile.readlines() if l != '/*yacc*/\\n']: + for l in [l for l in infile.readlines() if l != b'/*yacc*/\\n']: outfile.write(l) outfile.close() base, ext = os.path.splitext(args[0]) -open(base+'.hsuffix', 'wb').write(" ".join(sys.argv)+'\\n') +open(base+'.hsuffix', 'wb').write((" ".join(sys.argv)+'\\n').encode()) sys.exit(0) """) diff --git a/test/YACC/YACCHXXFILESUFFIX.py b/test/YACC/YACCHXXFILESUFFIX.py index 6664356..6418189 100644 --- a/test/YACC/YACCHXXFILESUFFIX.py +++ b/test/YACC/YACCHXXFILESUFFIX.py @@ -47,11 +47,11 @@ for o, a in opts: outfile = open(a, 'wb') for f in args: infile = open(f, 'rb') - for l in [l for l in infile.readlines() if l != '/*yacc*/\\n']: + for l in [l for l in infile.readlines() if l != b'/*yacc*/\\n']: outfile.write(l) outfile.close() base, ext = os.path.splitext(args[0]) -open(base+'.hxxsuffix', 'wb').write(" ".join(sys.argv)+'\\n') +open(base+'.hxxsuffix', 'wb').write((" ".join(sys.argv)+'\\n').encode()) sys.exit(0) """) diff --git a/test/YACC/YACCVCGFILESUFFIX.py b/test/YACC/YACCVCGFILESUFFIX.py index 0327d8a..5306076 100644 --- a/test/YACC/YACCVCGFILESUFFIX.py +++ b/test/YACC/YACCVCGFILESUFFIX.py @@ -49,12 +49,12 @@ for o, a in opts: outfile = open(a, 'wb') for f in args: infile = open(f, 'rb') - for l in [l for l in infile.readlines() if l != '/*yacc*/\\n']: + for l in [l for l in infile.readlines() if l != b'/*yacc*/\\n']: outfile.write(l) outfile.close() if vcg: base, ext = os.path.splitext(args[0]) - open(base+'.vcgsuffix', 'wb').write(" ".join(sys.argv)+'\\n') + open(base+'.vcgsuffix', 'wb').write((" ".join(sys.argv)+'\\n').encode()) sys.exit(0) """) diff --git a/test/YACC/shared-fixture/.exclude_tests b/test/YACC/shared-fixture/.exclude_tests new file mode 100644 index 0000000..f12c4d0 --- /dev/null +++ b/test/YACC/shared-fixture/.exclude_tests @@ -0,0 +1 @@ +myyacc.py diff --git a/test/YACC/shared-fixture/aaa.y b/test/YACC/shared-fixture/aaa.y new file mode 100644 index 0000000..f7f4cc7 --- /dev/null +++ b/test/YACC/shared-fixture/aaa.y @@ -0,0 +1,2 @@ +aaa.y +/*yacc*/ diff --git a/test/YACC/shared-fixture/bbb.yacc b/test/YACC/shared-fixture/bbb.yacc new file mode 100644 index 0000000..b3c856f --- /dev/null +++ b/test/YACC/shared-fixture/bbb.yacc @@ -0,0 +1,2 @@ +bbb.yacc +/*yacc*/ -- cgit v0.12 From 0f0725d9215ca35e9b9995a9421ef83e35a338d8 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Thu, 22 Sep 2016 17:19:50 -0400 Subject: Yet another batch of test fixes. --- .hgignore | 1 + test/LEX/LEX.py | 2 +- test/LEX/LEXCOM.py | 2 +- test/LEX/LEXCOMSTR.py | 2 +- test/LEX/LEXFLAGS.py | 6 +++--- test/LEX/live.py | 2 +- test/LINK/LINK.py | 6 +++--- test/LINK/LINKCOM.py | 5 +---- test/LINK/LINKCOMSTR.py | 4 ++-- test/LINK/LINKFLAGS.py | 4 ++-- test/LINK/SHLINK.py | 6 +++--- test/LINK/SHLINKCOM.py | 4 ++-- test/LINK/SHLINKCOMSTR.py | 4 ++-- test/LINK/SHLINKFLAGS.py | 4 ++-- test/M4/M4.py | 10 +++++----- test/M4/M4COM.py | 2 +- test/M4/M4COMSTR.py | 2 +- test/YACC/live.py | 2 +- 18 files changed, 33 insertions(+), 35 deletions(-) diff --git a/.hgignore b/.hgignore index 3e16531..15c093f 100644 --- a/.hgignore +++ b/.hgignore @@ -11,6 +11,7 @@ syntax:glob *.orig *.DS_Store *\# +*.swp doc/user/scons-user doc/user/scons_db.xml diff --git a/test/LEX/LEX.py b/test/LEX/LEX.py index 975d4e9..1239c6b 100644 --- a/test/LEX/LEX.py +++ b/test/LEX/LEX.py @@ -41,7 +41,7 @@ import sys cmd_opts, args = getopt.getopt(sys.argv[1:], 't', []) for a in args: contents = open(a, 'rb').read() - sys.stdout.write(contents.replace('LEX', 'mylex.py')) + sys.stdout.write(contents.replace(b'LEX', b'mylex.py').decode()) sys.exit(0) """) diff --git a/test/LEX/LEXCOM.py b/test/LEX/LEXCOM.py index 5fb82fe..6a32388 100644 --- a/test/LEX/LEXCOM.py +++ b/test/LEX/LEXCOM.py @@ -41,7 +41,7 @@ import sys outfile = open(sys.argv[1], 'wb') for f in sys.argv[2:]: infile = open(f, 'rb') - for l in [l for l in infile.readlines() if l != '/*lex*/\\n']: + for l in [l for l in infile.readlines() if l != b'/*lex*/\\n']: outfile.write(l) sys.exit(0) """) diff --git a/test/LEX/LEXCOMSTR.py b/test/LEX/LEXCOMSTR.py index 83b2f9c..07e693c 100644 --- a/test/LEX/LEXCOMSTR.py +++ b/test/LEX/LEXCOMSTR.py @@ -42,7 +42,7 @@ import sys outfile = open(sys.argv[1], 'wb') for f in sys.argv[2:]: infile = open(f, 'rb') - for l in [l for l in infile.readlines() if l != '/*lex*/\\n']: + for l in [l for l in infile.readlines() if l != b'/*lex*/\\n']: outfile.write(l) sys.exit(0) """) diff --git a/test/LEX/LEXFLAGS.py b/test/LEX/LEXFLAGS.py index 82ae586..54df161 100644 --- a/test/LEX/LEXFLAGS.py +++ b/test/LEX/LEXFLAGS.py @@ -48,9 +48,9 @@ for opt, arg in cmd_opts: else: opt_string = opt_string + ' ' + opt for a in args: contents = open(a, 'rb').read() - contents = contents.replace('LEXFLAGS', opt_string) - contents = contents.replace('I_ARGS', i_arguments) - sys.stdout.write(contents) + contents = contents.replace(b'LEXFLAGS', opt_string.encode()) + contents = contents.replace(b'I_ARGS', i_arguments.encode()) + sys.stdout.write(contents.decode()) sys.exit(0) """) diff --git a/test/LEX/live.py b/test/LEX/live.py index e4b4dfb..2abb8ce 100644 --- a/test/LEX/live.py +++ b/test/LEX/live.py @@ -44,7 +44,7 @@ if not lex: test.write("wrapper.py", """import os import sys -open('%s', 'wb').write("wrapper.py\\n") +open('%s', 'wb').write(b"wrapper.py\\n") os.system(" ".join(sys.argv[1:])) """ % test.workpath('wrapper.out').replace('\\', '\\\\')) diff --git a/test/LINK/LINK.py b/test/LINK/LINK.py index 25d9efb..54c75fa 100644 --- a/test/LINK/LINK.py +++ b/test/LINK/LINK.py @@ -36,7 +36,7 @@ test = TestSCons.TestSCons() test.write("wrapper.py", """import os import sys -open('%s', 'wb').write("wrapper.py\\n") +open('%s', 'wb').write(("wrapper.py\\n").encode()) os.system(" ".join(sys.argv[1:])) """ % test.workpath('wrapper.out').replace('\\', '\\\\')) @@ -75,11 +75,11 @@ main(int argc, char *argv[]) test.run(arguments = 'foo' + _exe) -test.fail_test(os.path.exists(test.workpath('wrapper.out'))) +test.must_not_exist(test.workpath('wrapper.out')) test.run(arguments = 'bar' + _exe) -test.fail_test(test.read('wrapper.out') != "wrapper.py\n") +test.must_match('wrapper.out', "wrapper.py\n") test.pass_test() diff --git a/test/LINK/LINKCOM.py b/test/LINK/LINKCOM.py index f09e8f8..996e727 100644 --- a/test/LINK/LINKCOM.py +++ b/test/LINK/LINKCOM.py @@ -31,18 +31,15 @@ Test the ability to configure the $LINKCOM construction variable. import TestSCons _python_ = TestSCons._python_ -_exe = TestSCons._exe test = TestSCons.TestSCons() - - test.write('mylink.py', r""" import sys outfile = open(sys.argv[1], 'wb') for f in sys.argv[2:]: infile = open(f, 'rb') - for l in [l for l in infile.readlines() if l != '/*link*/\n']: + for l in [l for l in infile.readlines() if l != b'/*link*/\n']: outfile.write(l) sys.exit(0) """) diff --git a/test/LINK/LINKCOMSTR.py b/test/LINK/LINKCOMSTR.py index 8fd8adc..8163016 100644 --- a/test/LINK/LINKCOMSTR.py +++ b/test/LINK/LINKCOMSTR.py @@ -32,7 +32,6 @@ the displayed linker string. import TestSCons _python_ = TestSCons._python_ -_exe = TestSCons._exe test = TestSCons.TestSCons() @@ -43,7 +42,7 @@ import sys outfile = open(sys.argv[1], 'wb') for f in sys.argv[2:]: infile = open(f, 'rb') - for l in [l for l in infile.readlines() if l != '/*link*/\n']: + for l in [l for l in infile.readlines() if l != b'/*link*/\n']: outfile.write(l) sys.exit(0) """) @@ -80,6 +79,7 @@ env = Environment(CXXCOMSTR = 'Compiling $TARGET ...', LINKCOMSTR = 'Linking $TARGET ...') env.Program('test', 'test.cpp') """) + test.write('test.cpp', """ int main(int argc, char **argv) {} """) diff --git a/test/LINK/LINKFLAGS.py b/test/LINK/LINKFLAGS.py index 442baf7..f0c7518 100644 --- a/test/LINK/LINKFLAGS.py +++ b/test/LINK/LINKFLAGS.py @@ -36,7 +36,7 @@ test = TestSCons.TestSCons() test.write("wrapper.py", """import os import sys -open('%s', 'wb').write("wrapper.py\\n") +open('%s', 'wb').write(("wrapper.py\\n").encode()) args = [s for s in sys.argv[1:] if s != 'fake_link_flag'] os.system(" ".join(args)) """ % test.workpath('wrapper.out').replace('\\', '\\\\')) @@ -80,7 +80,7 @@ test.must_not_exist(test.workpath('wrapper.out')) test.run(arguments = 'bar' + _exe) -test.fail_test(test.read('wrapper.out') != "wrapper.py\n") +test.must_match('wrapper.out', "wrapper.py\n") test.pass_test() diff --git a/test/LINK/SHLINK.py b/test/LINK/SHLINK.py index bc1239b..7353996 100644 --- a/test/LINK/SHLINK.py +++ b/test/LINK/SHLINK.py @@ -37,7 +37,7 @@ test = TestSCons.TestSCons() test.write("wrapper.py", """import os import sys -open('%s', 'wb').write("wrapper.py\\n") +open('%s', 'wb').write(b"wrapper.py\\n") os.system(" ".join(sys.argv[1:])) """ % test.workpath('wrapper.out').replace('\\', '\\\\')) @@ -73,11 +73,11 @@ test() test.run(arguments = dll_ + 'foo' + _shlib) -test.fail_test(os.path.exists(test.workpath('wrapper.out'))) +test.must_not_exist(test.workpath('wrapper.out')) test.run(arguments = dll_ + 'bar' + _shlib) -test.fail_test(test.read('wrapper.out') != "wrapper.py\n") +test.must_match('wrapper.out', "wrapper.py\n") test.pass_test() diff --git a/test/LINK/SHLINKCOM.py b/test/LINK/SHLINKCOM.py index 8bdb9b5..1204ed1 100644 --- a/test/LINK/SHLINKCOM.py +++ b/test/LINK/SHLINKCOM.py @@ -41,7 +41,7 @@ import sys outfile = open(sys.argv[1], 'wb') for f in sys.argv[2:]: infile = open(f, 'rb') - for l in [l for l in infile.readlines() if l != '/*cc*/\n']: + for l in [l for l in infile.readlines() if l != b'/*cc*/\n']: outfile.write(l) sys.exit(0) @@ -51,7 +51,7 @@ import sys outfile = open(sys.argv[1], 'wb') for f in sys.argv[2:]: infile = open(f, 'rb') - for l in [l for l in infile.readlines() if l != '/*link*/\n']: + for l in [l for l in infile.readlines() if l != b'/*link*/\n']: outfile.write(l) sys.exit(0) """) diff --git a/test/LINK/SHLINKCOMSTR.py b/test/LINK/SHLINKCOMSTR.py index db40732..5663a1e 100644 --- a/test/LINK/SHLINKCOMSTR.py +++ b/test/LINK/SHLINKCOMSTR.py @@ -43,7 +43,7 @@ import sys outfile = open(sys.argv[1], 'wb') for f in sys.argv[2:]: infile = open(f, 'rb') - for l in [l for l in infile.readlines() if l != '/*cc*/\n']: + for l in [l for l in infile.readlines() if l != b'/*cc*/\n']: outfile.write(l) sys.exit(0) @@ -53,7 +53,7 @@ import sys outfile = open(sys.argv[1], 'wb') for f in sys.argv[2:]: infile = open(f, 'rb') - for l in [l for l in infile.readlines() if l != '/*link*/\n']: + for l in [l for l in infile.readlines() if l != b'/*link*/\n']: outfile.write(l) sys.exit(0) """) diff --git a/test/LINK/SHLINKFLAGS.py b/test/LINK/SHLINKFLAGS.py index 57766de..51b6e22 100644 --- a/test/LINK/SHLINKFLAGS.py +++ b/test/LINK/SHLINKFLAGS.py @@ -37,7 +37,7 @@ test = TestSCons.TestSCons() test.write("wrapper.py", """import os import sys -open('%s', 'wb').write("wrapper.py\\n") +open('%s', 'wb').write(("wrapper.py\\n").encode()) args = [s for s in sys.argv[1:] if s != 'fake_shlink_flag'] os.system(" ".join(args)) """ % test.workpath('wrapper.out').replace('\\', '\\\\')) @@ -78,7 +78,7 @@ test.must_not_exist(test.workpath('wrapper.out')) test.run(arguments = lib_ + 'bar' + _shlib) -test.fail_test(test.read('wrapper.out') != "wrapper.py\n") +test.must_match('wrapper.out', "wrapper.py\n") test.pass_test() diff --git a/test/M4/M4.py b/test/M4/M4.py index 6c2de9c..d2b8365 100644 --- a/test/M4/M4.py +++ b/test/M4/M4.py @@ -59,7 +59,7 @@ line 3 test.run() -test.fail_test(test.read(test.workpath('aaa.x'), 'r') != "line 1\nmym4.py\nline 3\n") +test.must_match(test.workpath('aaa.x'), "line 1\nmym4.py\nline 3\n") @@ -70,7 +70,7 @@ if m4: test.write("wrapper.py", """import os import sys -open('%s', 'wb').write("wrapper.py\\n") +open('%s', 'wb').write(b"wrapper.py\\n") os.system(" ".join(sys.argv[1:])) """ % test.workpath('wrapper.out').replace('\\', '\\\\')) @@ -96,11 +96,11 @@ bar.M4(target = 'bar', source = 'bar.m4') test.up_to_date(arguments = '.') - test.fail_test(test.read('wrapper.out') != "wrapper.py\n") + test.must_match('wrapper.out', "wrapper.py\n") - test.fail_test(test.read('foo.x', 'r') != "line 1\nfff\nline 3\n") + test.must_match('foo.x', "line 1\nfff\nline 3\n") - test.fail_test(test.read('bar', 'r') != "line 1\nbbb\nline 3\n") + test.must_match('bar', "line 1\nbbb\nline 3\n") test.pass_test() diff --git a/test/M4/M4COM.py b/test/M4/M4COM.py index ad15172..5a2f076 100644 --- a/test/M4/M4COM.py +++ b/test/M4/M4COM.py @@ -41,7 +41,7 @@ import sys outfile = open(sys.argv[1], 'wb') for f in sys.argv[2:]: infile = open(f, 'rb') - for l in [l for l in infile.readlines() if l != '/*m4*/\\n']: + for l in [l for l in infile.readlines() if l != b'/*m4*/\\n']: outfile.write(l) sys.exit(0) """) diff --git a/test/M4/M4COMSTR.py b/test/M4/M4COMSTR.py index 1b5bd35..da01e6c 100644 --- a/test/M4/M4COMSTR.py +++ b/test/M4/M4COMSTR.py @@ -42,7 +42,7 @@ import sys outfile = open(sys.argv[1], 'wb') for f in sys.argv[2:]: infile = open(f, 'rb') - for l in [l for l in infile.readlines() if l != '/*m4*/\\n']: + for l in [l for l in infile.readlines() if l != b'/*m4*/\\n']: outfile.write(l) sys.exit(0) """) diff --git a/test/YACC/live.py b/test/YACC/live.py index f6733da..e125daa 100644 --- a/test/YACC/live.py +++ b/test/YACC/live.py @@ -43,7 +43,7 @@ if not yacc: test.write("wrapper.py", """import os import sys -open('%s', 'wb').write("wrapper.py\\n") +open('%s', 'wb').write(b"wrapper.py\\n") os.system(" ".join(sys.argv[1:])) """ % test.workpath('wrapper.out').replace('\\', '\\\\')) -- cgit v0.12 From 4fe5ff748a5831be8279c3c9bc1c198fcacc9aca Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 22 Sep 2016 18:15:47 -0400 Subject: fix missing file from test fixture --- test/Actions/pre-post-fixture/work4/build.py | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 test/Actions/pre-post-fixture/work4/build.py diff --git a/test/Actions/pre-post-fixture/work4/build.py b/test/Actions/pre-post-fixture/work4/build.py new file mode 100644 index 0000000..db0572a --- /dev/null +++ b/test/Actions/pre-post-fixture/work4/build.py @@ -0,0 +1,5 @@ +import sys +outfp = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + outfp.write(open(f, 'rb').read()) +outfp.close() -- cgit v0.12 From 2c18000b934722c69e23a2d0ad181767d5266ac9 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Fri, 23 Sep 2016 00:43:00 -0400 Subject: Allowed for multiple fixture dirs and added default global directory. --- QMTest/TestCmd.py | 25 ++++++++++++++++--------- QMTest/TestSCons.py | 2 +- runtest.py | 8 +++++--- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index bff0d6a..109c83a 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -924,7 +924,7 @@ class TestCmd(object): self.condition = 'no_result' self.workdir_set(workdir) self.subdir(subdir) - self.script_srcdir = None + self.fixture_dirs = [] def __del__(self): self.cleanup() @@ -1248,8 +1248,13 @@ class TestCmd(object): assumed to be under the temporary working directory, it gets created automatically, if it does not already exist. """ - if srcdir and self.script_srcdir and not os.path.isabs(srcdir): - spath = os.path.join(self.script_srcdir, srcdir) + + if srcdir and self.fixture_dirs and not os.path.isabs(srcdir): + for dir in self.fixture_dirs: + spath = os.path.join(self.fixture_dirs, srcdir) + if os.path.isdir(spath): + continue + else: spath = srcdir if dstdir: @@ -1285,13 +1290,15 @@ class TestCmd(object): automatically, if it does not already exist. """ srcpath, srctail = os.path.split(srcfile) - if srcpath: - if self.script_srcdir and not os.path.isabs(srcpath): - spath = os.path.join(self.script_srcdir, srcfile) - else: - spath = srcfile + + if srcpath and (not self.fixture_dirs or os.path.isabs(srcpath)): + spath = srcfile else: - spath = os.path.join(self.script_srcdir, srcfile) + for dir in self.fixture_dirs: + spath = os.path.join(self.fixture_dirs, srcfile) + if os.path.isfile(spath): + continue + if not dstfile: if srctail: dpath = os.path.join(self.workdir, srctail) diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index 0d5dc90..f02ddd8 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -268,7 +268,7 @@ class TestSCons(TestCommon): SCons.Node.FS.default_fs = SCons.Node.FS.FS() try: - self.script_srcdir = os.environ['PYTHON_SCRIPT_DIR'] + self.fixture_dirs = os.environ['FIXTURE_DIRS'].split(':') except KeyError: pass diff --git a/runtest.py b/runtest.py index 0950bbe..dec8f9f 100755 --- a/runtest.py +++ b/runtest.py @@ -786,10 +786,12 @@ def run_test(t, io_lock, async=True): if not suppress_stdout and not suppress_stderr: sys.stdout.write(header) head, tail = os.path.split(t.abspath) + fixture_dirs = [] if head: - os.environ['PYTHON_SCRIPT_DIR'] = head - else: - os.environ['PYTHON_SCRIPT_DIR'] = '' + fixture_dirs.append(head) + fixture_dirs.append(os.path.join(os.path.split(os.path.abspath(__file__))[0], 'fixture')) + os.environ['PYTHON_SCRIPT_DIR'] = ':'.join(fixture_dirs) + test_start_time = time_func() if execute_tests: t.execute() -- cgit v0.12 From d2312ff7f05636c425526936d1957464221b26d0 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Fri, 23 Sep 2016 02:13:44 -0400 Subject: Initial python3 cut of test/Fortran. --- QMTest/TestCmd.py | 10 ++--- QMTest/TestSCons.py | 2 +- fixture/mylink.py | 31 ++++++++++++++ fixture/wrapper.py | 5 +++ runtest.py | 4 +- src/engine/SCons/Scanner/Fortran.py | 12 +++--- src/engine/SCons/Tool/FortranCommon.py | 2 +- test/Fortran/F03.py | 14 ++----- test/Fortran/common.py | 75 ---------------------------------- 9 files changed, 54 insertions(+), 101 deletions(-) create mode 100644 fixture/mylink.py create mode 100644 fixture/wrapper.py delete mode 100644 test/Fortran/common.py diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index 109c83a..370101b 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -1251,12 +1251,12 @@ class TestCmd(object): if srcdir and self.fixture_dirs and not os.path.isabs(srcdir): for dir in self.fixture_dirs: - spath = os.path.join(self.fixture_dirs, srcdir) + spath = os.path.join(dir, srcdir) if os.path.isdir(spath): - continue - + break else: spath = srcdir + if dstdir: dstdir = self.canonicalize(dstdir) else: @@ -1295,9 +1295,9 @@ class TestCmd(object): spath = srcfile else: for dir in self.fixture_dirs: - spath = os.path.join(self.fixture_dirs, srcfile) + spath = os.path.join(dir, srcfile) if os.path.isfile(spath): - continue + break if not dstfile: if srctail: diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index f02ddd8..a987c5a 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -268,7 +268,7 @@ class TestSCons(TestCommon): SCons.Node.FS.default_fs = SCons.Node.FS.FS() try: - self.fixture_dirs = os.environ['FIXTURE_DIRS'].split(':') + self.fixture_dirs = (os.environ['FIXTURE_DIRS']).split(':') except KeyError: pass diff --git a/fixture/mylink.py b/fixture/mylink.py new file mode 100644 index 0000000..7c03f00 --- /dev/null +++ b/fixture/mylink.py @@ -0,0 +1,31 @@ +import sys + +if sys.platform == 'win32': + args = sys.argv[1:] + while args: + a = args[0] + if a == '-o': + out = args[1] + args = args[2:] + continue + if not a[0] in '/-': + break + args = args[1:] + if a[:5].lower() == '/out:': out = a[5:] + infile = open(args[0], 'rb') + outfile = open(out, 'wb') + for l in infile.readlines(): + if l[:5] != b'#link': + outfile.write(l) + sys.exit(0) +else: + import getopt + opts, args = getopt.getopt(sys.argv[1:], 'o:') + for opt, arg in opts: + if opt == '-o': out = arg + infile = open(args[0], 'rb') + outfile = open(out, 'wb') + for l in infile.readlines(): + if l[:5] != b'#link': + outfile.write(l) + sys.exit(0) diff --git a/fixture/wrapper.py b/fixture/wrapper.py new file mode 100644 index 0000000..a797434 --- /dev/null +++ b/fixture/wrapper.py @@ -0,0 +1,5 @@ +import os +import sys +path = os.path.join(os.path.abspath(__file__), 'wrapper.out') +open(path, 'wb').write(b"wrapper.py\n") +os.system(" ".join(sys.argv[1:])) diff --git a/runtest.py b/runtest.py index dec8f9f..c856740 100755 --- a/runtest.py +++ b/runtest.py @@ -789,8 +789,8 @@ def run_test(t, io_lock, async=True): fixture_dirs = [] if head: fixture_dirs.append(head) - fixture_dirs.append(os.path.join(os.path.split(os.path.abspath(__file__))[0], 'fixture')) - os.environ['PYTHON_SCRIPT_DIR'] = ':'.join(fixture_dirs) + fixture_dirs.append(os.path.join(scriptpath, 'fixture')) + os.environ['FIXTURE_DIRS'] = ':'.join(fixture_dirs) test_start_time = time_func() if execute_tests: diff --git a/src/engine/SCons/Scanner/Fortran.py b/src/engine/SCons/Scanner/Fortran.py index 1b55130..9082015 100644 --- a/src/engine/SCons/Scanner/Fortran.py +++ b/src/engine/SCons/Scanner/Fortran.py @@ -82,11 +82,11 @@ class F90Scanner(SCons.Scanner.Classic): mods_and_includes = node.includes else: # retrieve all included filenames - includes = self.cre_incl.findall(node.get_text_contents()) + includes = self.cre_incl.findall(node.get_contents()) # retrieve all USE'd module names - modules = self.cre_use.findall(node.get_text_contents()) + modules = self.cre_use.findall(node.get_contents()) # retrieve all defined module names - defmodules = self.cre_def.findall(node.get_text_contents()) + defmodules = self.cre_def.findall(node.get_contents()) # Remove all USE'd module names that are defined in the same file # (case-insensitively) @@ -187,7 +187,7 @@ def FortranScan(path_variable="FORTRANPATH"): # (\w+) : match the module name that is being USE'd # # - use_regex = "(?i)(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)" + use_regex = b"(?i)(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)" # The INCLUDE statement regex matches the following: @@ -275,7 +275,7 @@ def FortranScan(path_variable="FORTRANPATH"): # set of semicolon-separated INCLUDE statements # (as allowed by the F2003 standard) - include_regex = """(?i)(?:^|['">]\s*;)\s*INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])""" + include_regex = b"(?i)(?:^|['\">]\s*;)\s*INCLUDE\s+(?:\w+_)?[<\"'](.+?)(?=[\"'>])" # The MODULE statement regex finds module definitions by matching # the following: @@ -299,7 +299,7 @@ def FortranScan(path_variable="FORTRANPATH"): # that make up the defined module name and # save it in a group - def_regex = """(?i)^\s*MODULE\s+(?!PROCEDURE)(\w+)""" + def_regex = b"(?i)^\s*MODULE\s+(?!PROCEDURE)(\w+)" scanner = F90Scanner("FortranScan", "$FORTRANSUFFIXES", diff --git a/src/engine/SCons/Tool/FortranCommon.py b/src/engine/SCons/Tool/FortranCommon.py index e450730..1503639 100644 --- a/src/engine/SCons/Tool/FortranCommon.py +++ b/src/engine/SCons/Tool/FortranCommon.py @@ -64,7 +64,7 @@ def _fortranEmitter(target, source, env): if not node.exists() and not node.is_derived(): print("Could not locate " + str(node.name)) return ([], []) - mod_regex = """(?i)^\s*MODULE\s+(?!PROCEDURE)(\w+)""" + mod_regex = b"(?i)^\s*MODULE\s+(?!PROCEDURE)(\w+)" cre = re.compile(mod_regex,re.M) # Retrieve all USE'd module names modules = cre.findall(node.get_text_contents()) diff --git a/test/Fortran/F03.py b/test/Fortran/F03.py index ea706a9..3c6bba4 100644 --- a/test/Fortran/F03.py +++ b/test/Fortran/F03.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt @@ -46,7 +44,7 @@ for opt, arg in opts: infile = open(args[0], 'rb') outfile = open(out, 'wb') for l in infile.readlines(): - if l[:length] != comment: + if l[:length] != comment.encode(): outfile.write(l) sys.exit(0) """) @@ -97,13 +95,7 @@ fc = 'f03' g03 = test.detect_tool(fc) if g03: - - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(F03 = '%(fc)s') diff --git a/test/Fortran/common.py b/test/Fortran/common.py deleted file mode 100644 index 6763ef4..0000000 --- a/test/Fortran/common.py +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - - -"""This module implements common code to all fortran tests.""" - -import sys - -def write_fake_link(t): - """Writes a mylink.py script to remove the link step for 'fake' (e.g. - non-compiled) tests.""" - if sys.platform == 'win32': - t.write('mylink.py', r""" -import sys -args = sys.argv[1:] -while args: - a = args[0] - if a == '-o': - out = args[1] - args = args[2:] - continue - if not a[0] in '/-': - break - args = args[1:] - if a[:5].lower() == '/out:': out = a[5:] -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:5] != '#link': - outfile.write(l) -sys.exit(0) - """) - else: - t.write('mylink.py', r""" -import getopt -import sys -opts, args = getopt.getopt(sys.argv[1:], 'o:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:5] != '#link': - outfile.write(l) -sys.exit(0) - """) - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: -- cgit v0.12 From 9e87609dfac0fd6a87d2cdc0a9e4e8b5c0a6a99a Mon Sep 17 00:00:00 2001 From: William Blevins Date: Sat, 24 Sep 2016 02:05:34 -0400 Subject: Updated remaining Fortran tests to use fixture over import. --- test/Fortran/F03COM.py | 4 +--- test/Fortran/F03FILESUFFIXES.py | 4 +--- test/Fortran/F03FILESUFFIXES2.py | 4 +--- test/Fortran/F03FLAGS.py | 4 +--- test/Fortran/F08.py | 4 +--- test/Fortran/F08COM.py | 4 +--- test/Fortran/F08FILESUFFIXES.py | 4 +--- test/Fortran/F08FILESUFFIXES2.py | 4 +--- test/Fortran/F08FLAGS.py | 4 +--- test/Fortran/F77.py | 4 +--- test/Fortran/F77COM.py | 4 +--- test/Fortran/F77FILESUFFIXES.py | 4 +--- test/Fortran/F77FILESUFFIXES2.py | 4 +--- test/Fortran/F77FLAGS.py | 4 +--- test/Fortran/F90.py | 4 +--- test/Fortran/F90COM.py | 4 +--- test/Fortran/F90FILESUFFIXES.py | 4 +--- test/Fortran/F90FILESUFFIXES2.py | 4 +--- test/Fortran/F90FLAGS.py | 4 ++-- test/Fortran/F95.py | 4 ++-- test/Fortran/F95COM.py | 4 ++-- test/Fortran/F95FILESUFFIXES.py | 4 ++-- test/Fortran/F95FILESUFFIXES2.py | 4 ++-- test/Fortran/F95FLAGS.py | 4 ++-- test/Fortran/FORTRAN.py | 4 ++-- test/Fortran/FORTRANCOM.py | 4 ++-- test/Fortran/FORTRANFILESUFFIXES.py | 4 ++-- test/Fortran/FORTRANFILESUFFIXES2.py | 4 ++-- test/Fortran/FORTRANFLAGS.py | 4 ++-- test/Fortran/FORTRANPPFILESUFFIXES.py | 4 ++-- 30 files changed, 42 insertions(+), 78 deletions(-) diff --git a/test/Fortran/F03COM.py b/test/Fortran/F03COM.py index b0d1f79..dc1523e 100644 --- a/test/Fortran/F03COM.py +++ b/test/Fortran/F03COM.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import sys diff --git a/test/Fortran/F03FILESUFFIXES.py b/test/Fortran/F03FILESUFFIXES.py index ffc2169..b1d2b93 100644 --- a/test/Fortran/F03FILESUFFIXES.py +++ b/test/Fortran/F03FILESUFFIXES.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F03FILESUFFIXES2.py b/test/Fortran/F03FILESUFFIXES2.py index 77a601f..44be880 100644 --- a/test/Fortran/F03FILESUFFIXES2.py +++ b/test/Fortran/F03FILESUFFIXES2.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F03FLAGS.py b/test/Fortran/F03FLAGS.py index 0c5bf93..b11b780 100644 --- a/test/Fortran/F03FLAGS.py +++ b/test/Fortran/F03FLAGS.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ test = TestSCons.TestSCons() _exe = TestSCons._exe -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F08.py b/test/Fortran/F08.py index 35df37c..b61b861 100644 --- a/test/Fortran/F08.py +++ b/test/Fortran/F08.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F08COM.py b/test/Fortran/F08COM.py index 783a163..363c2d0 100644 --- a/test/Fortran/F08COM.py +++ b/test/Fortran/F08COM.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import sys diff --git a/test/Fortran/F08FILESUFFIXES.py b/test/Fortran/F08FILESUFFIXES.py index 8463403..41059af 100644 --- a/test/Fortran/F08FILESUFFIXES.py +++ b/test/Fortran/F08FILESUFFIXES.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F08FILESUFFIXES2.py b/test/Fortran/F08FILESUFFIXES2.py index 39bba44..e53cee1 100644 --- a/test/Fortran/F08FILESUFFIXES2.py +++ b/test/Fortran/F08FILESUFFIXES2.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F08FLAGS.py b/test/Fortran/F08FLAGS.py index 866ea2c..34f3d75 100644 --- a/test/Fortran/F08FLAGS.py +++ b/test/Fortran/F08FLAGS.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ test = TestSCons.TestSCons() _exe = TestSCons._exe -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F77.py b/test/Fortran/F77.py index 0ebd7ee..300df85 100644 --- a/test/Fortran/F77.py +++ b/test/Fortran/F77.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F77COM.py b/test/Fortran/F77COM.py index 1efbe05..4e15eea 100644 --- a/test/Fortran/F77COM.py +++ b/test/Fortran/F77COM.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import sys diff --git a/test/Fortran/F77FILESUFFIXES.py b/test/Fortran/F77FILESUFFIXES.py index 2070ff2..1715ce9 100644 --- a/test/Fortran/F77FILESUFFIXES.py +++ b/test/Fortran/F77FILESUFFIXES.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F77FILESUFFIXES2.py b/test/Fortran/F77FILESUFFIXES2.py index 52e4d68..1938af1 100644 --- a/test/Fortran/F77FILESUFFIXES2.py +++ b/test/Fortran/F77FILESUFFIXES2.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F77FLAGS.py b/test/Fortran/F77FLAGS.py index 342adac..8e972ec 100644 --- a/test/Fortran/F77FLAGS.py +++ b/test/Fortran/F77FLAGS.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ test = TestSCons.TestSCons() _exe = TestSCons._exe -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myg77.py', r""" import getopt diff --git a/test/Fortran/F90.py b/test/Fortran/F90.py index d7c73c6..bbceaac 100644 --- a/test/Fortran/F90.py +++ b/test/Fortran/F90.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F90COM.py b/test/Fortran/F90COM.py index 8981bb3..e3be2a1 100644 --- a/test/Fortran/F90COM.py +++ b/test/Fortran/F90COM.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import sys diff --git a/test/Fortran/F90FILESUFFIXES.py b/test/Fortran/F90FILESUFFIXES.py index ae61a84..47da08e 100644 --- a/test/Fortran/F90FILESUFFIXES.py +++ b/test/Fortran/F90FILESUFFIXES.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F90FILESUFFIXES2.py b/test/Fortran/F90FILESUFFIXES2.py index ab62ca7..7039530 100644 --- a/test/Fortran/F90FILESUFFIXES2.py +++ b/test/Fortran/F90FILESUFFIXES2.py @@ -26,14 +26,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F90FLAGS.py b/test/Fortran/F90FLAGS.py index f0b3003..8eaa938 100644 --- a/test/Fortran/F90FLAGS.py +++ b/test/Fortran/F90FLAGS.py @@ -27,14 +27,14 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link + _python_ = TestSCons._python_ test = TestSCons.TestSCons() _exe = TestSCons._exe -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F95.py b/test/Fortran/F95.py index e7745b1..56c6edd 100644 --- a/test/Fortran/F95.py +++ b/test/Fortran/F95.py @@ -26,14 +26,14 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link + _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F95COM.py b/test/Fortran/F95COM.py index 6ef6eb0..4761635 100644 --- a/test/Fortran/F95COM.py +++ b/test/Fortran/F95COM.py @@ -26,14 +26,14 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link + _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import sys diff --git a/test/Fortran/F95FILESUFFIXES.py b/test/Fortran/F95FILESUFFIXES.py index 119629d..8643a24 100644 --- a/test/Fortran/F95FILESUFFIXES.py +++ b/test/Fortran/F95FILESUFFIXES.py @@ -26,14 +26,14 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link + _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F95FILESUFFIXES2.py b/test/Fortran/F95FILESUFFIXES2.py index d89839b..d267a24 100644 --- a/test/Fortran/F95FILESUFFIXES2.py +++ b/test/Fortran/F95FILESUFFIXES2.py @@ -26,14 +26,14 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link + _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/F95FLAGS.py b/test/Fortran/F95FLAGS.py index 8c3ce09..525b8cc 100644 --- a/test/Fortran/F95FLAGS.py +++ b/test/Fortran/F95FLAGS.py @@ -26,14 +26,14 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link + _python_ = TestSCons._python_ test = TestSCons.TestSCons() _exe = TestSCons._exe -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/FORTRAN.py b/test/Fortran/FORTRAN.py index 9a01fa6..c03698f 100644 --- a/test/Fortran/FORTRAN.py +++ b/test/Fortran/FORTRAN.py @@ -26,14 +26,14 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link + _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myg77.py', r""" import getopt diff --git a/test/Fortran/FORTRANCOM.py b/test/Fortran/FORTRANCOM.py index 6948b96..bf84d26 100644 --- a/test/Fortran/FORTRANCOM.py +++ b/test/Fortran/FORTRANCOM.py @@ -26,14 +26,14 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link + _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import sys diff --git a/test/Fortran/FORTRANFILESUFFIXES.py b/test/Fortran/FORTRANFILESUFFIXES.py index 92e30ea..e4b6192 100644 --- a/test/Fortran/FORTRANFILESUFFIXES.py +++ b/test/Fortran/FORTRANFILESUFFIXES.py @@ -26,14 +26,14 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link + _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/FORTRANFILESUFFIXES2.py b/test/Fortran/FORTRANFILESUFFIXES2.py index 8ba0962..79231ac 100644 --- a/test/Fortran/FORTRANFILESUFFIXES2.py +++ b/test/Fortran/FORTRANFILESUFFIXES2.py @@ -26,14 +26,14 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link + _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/FORTRANFLAGS.py b/test/Fortran/FORTRANFLAGS.py index 150000a..7dbc049 100644 --- a/test/Fortran/FORTRANFLAGS.py +++ b/test/Fortran/FORTRANFLAGS.py @@ -26,14 +26,14 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from common import write_fake_link + _python_ = TestSCons._python_ test = TestSCons.TestSCons() _exe = TestSCons._exe -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt diff --git a/test/Fortran/FORTRANPPFILESUFFIXES.py b/test/Fortran/FORTRANPPFILESUFFIXES.py index e0c6974..2791b91 100644 --- a/test/Fortran/FORTRANPPFILESUFFIXES.py +++ b/test/Fortran/FORTRANPPFILESUFFIXES.py @@ -30,14 +30,14 @@ import string import sys import TestSCons -from common import write_fake_link + _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() -write_fake_link(test) +test.file_fixture('mylink.py') test.write('myfortran.py', r""" import getopt -- cgit v0.12 From c4c2ba91c671527828fbc6ffb79421d5e487a398 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Sat, 24 Sep 2016 04:29:36 -0400 Subject: Updating tests to use fixture wrapper.py. --- fixture/wrapper.py | 5 +++-- test/AR/AR.py | 7 +------ test/AR/ARFLAGS.py | 7 +------ test/AS/ml.py | 7 +------ test/AS/nasm.py | 7 +------ test/CC/CC.py | 8 +------- test/CC/SHCC.py | 7 +------ test/CXX/CXX.py | 8 +------- test/CXX/SHCXX.py | 7 +------ test/Fortran/F03FLAGS.py | 7 +------ test/Fortran/F08.py | 7 +------ test/Fortran/F08FLAGS.py | 7 +------ test/Fortran/F77.py | 7 +------ test/Fortran/F77FLAGS.py | 7 +------ test/Fortran/F90.py | 7 +------ test/Fortran/F90FLAGS.py | 7 +------ test/Fortran/F95.py | 7 +------ test/Fortran/F95FLAGS.py | 7 +------ test/Fortran/FORTRAN.py | 7 +------ test/Fortran/FORTRANFLAGS.py | 7 +------ test/Fortran/SHF03.py | 7 +------ test/Fortran/SHF08.py | 7 +------ test/Fortran/SHF77.py | 7 +------ test/Fortran/SHF77FLAGS.py | 7 +------ test/Fortran/SHF90.py | 7 +------ test/Fortran/SHF90FLAGS.py | 7 +------ test/Fortran/SHF95.py | 7 +------ test/Fortran/SHF95FLAGS.py | 7 +------ test/Fortran/SHFORTRAN.py | 7 +------ test/Fortran/SHFORTRANFLAGS.py | 7 +------ test/Ghostscript/GSFLAGS.py | 7 +------ test/Java/JAR.py | 7 +------ test/Java/JAVAH.py | 7 +------ test/Java/RMIC.py | 7 +------ test/LEX/live.py | 6 +----- test/LINK/LINK.py | 7 +------ test/LINK/SHLINK.py | 7 +------ test/M4/M4.py | 7 +------ test/RANLIB/RANLIB.py | 7 +------ test/RANLIB/RANLIBFLAGS.py | 7 +------ test/SWIG/live.py | 7 +------ test/TAR/TAR.py | 6 +----- test/TAR/TARFLAGS.py | 6 +----- test/TEX/LATEX.py | 6 +----- test/TEX/LATEXFLAGS.py | 6 +----- test/TEX/PDFLATEX.py | 6 +----- test/TEX/PDFLATEXFLAGS.py | 6 +----- test/TEX/PDFTEX.py | 6 +----- test/TEX/PDFTEXFLAGS.py | 6 +----- test/TEX/TEX.py | 6 +----- test/TEX/TEXFLAGS.py | 6 +----- test/YACC/live.py | 7 +------ 52 files changed, 54 insertions(+), 299 deletions(-) diff --git a/fixture/wrapper.py b/fixture/wrapper.py index a797434..f02ea03 100644 --- a/fixture/wrapper.py +++ b/fixture/wrapper.py @@ -1,5 +1,6 @@ import os import sys -path = os.path.join(os.path.abspath(__file__), 'wrapper.out') -open(path, 'wb').write(b"wrapper.py\n") +if '--version' not in sys.argv and '-dumpversion' not in sys.argv: + path = os.path.join(os.path.dirname(os.path.relpath(__file__)), 'wrapper.out') + open(path, 'wb').write(b"wrapper.py\n") os.system(" ".join(sys.argv[1:])) diff --git a/test/AR/AR.py b/test/AR/AR.py index eb4c507..11687d9 100644 --- a/test/AR/AR.py +++ b/test/AR/AR.py @@ -33,12 +33,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() -test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write(b"wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(LIBS = ['foo'], LIBPATH = ['.']) diff --git a/test/AR/ARFLAGS.py b/test/AR/ARFLAGS.py index 0a9f36e..2d90752 100644 --- a/test/AR/ARFLAGS.py +++ b/test/AR/ARFLAGS.py @@ -33,12 +33,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() -test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write(b"wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(LIBS = ['foo'], LIBPATH = ['.']) diff --git a/test/AS/ml.py b/test/AS/ml.py index c377172..0506f5f 100644 --- a/test/AS/ml.py +++ b/test/AS/ml.py @@ -45,12 +45,7 @@ ml = test.where_is('ml') if not ml: test.skip_test("ml not found; skipping test\n") -test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write(b"wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ import os diff --git a/test/AS/nasm.py b/test/AS/nasm.py index 551a5ab..b436a75 100644 --- a/test/AS/nasm.py +++ b/test/AS/nasm.py @@ -74,12 +74,7 @@ for k, v in list(format_map.items()): nasm_format = v break -test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ eee = Environment(tools = ['gcc', 'gnulink', 'nasm'], diff --git a/test/CC/CC.py b/test/CC/CC.py index 7478cbe..f6c2954 100644 --- a/test/CC/CC.py +++ b/test/CC/CC.py @@ -139,13 +139,7 @@ env.Program(target = 'test2', source = 'test2.C') test.run(arguments = '.', stderr = None) test.must_match('test2' + _exe, "This is a .C file.\n") -test.write("wrapper.py", -"""import os -import sys -if '--version' not in sys.argv and '-dumpversion' not in sys.argv: - open('%s', 'wb').write(b"wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment() diff --git a/test/CC/SHCC.py b/test/CC/SHCC.py index 5f121fc..beda8e4 100644 --- a/test/CC/SHCC.py +++ b/test/CC/SHCC.py @@ -32,12 +32,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() -test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write(b"wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment() diff --git a/test/CXX/CXX.py b/test/CXX/CXX.py index 79dbde4..c9dbf1c 100644 --- a/test/CXX/CXX.py +++ b/test/CXX/CXX.py @@ -183,13 +183,7 @@ env.Program(target = 'test6', source = 'test6.C') -test.write("wrapper.py", -"""import os -import sys -if '--version' not in sys.argv and '-dumpversion' not in sys.argv: - open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment() diff --git a/test/CXX/SHCXX.py b/test/CXX/SHCXX.py index 9a78881..d6a314e 100644 --- a/test/CXX/SHCXX.py +++ b/test/CXX/SHCXX.py @@ -32,12 +32,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() -test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment() diff --git a/test/Fortran/F03FLAGS.py b/test/Fortran/F03FLAGS.py index b11b780..4e99db8 100644 --- a/test/Fortran/F03FLAGS.py +++ b/test/Fortran/F03FLAGS.py @@ -103,12 +103,7 @@ g03 = test.detect_tool(fc) if g03: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(F03 = '%(fc)s') diff --git a/test/Fortran/F08.py b/test/Fortran/F08.py index b61b861..a28389e 100644 --- a/test/Fortran/F08.py +++ b/test/Fortran/F08.py @@ -96,12 +96,7 @@ g08 = test.detect_tool(fc) if g08: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(F08 = '%(fc)s') diff --git a/test/Fortran/F08FLAGS.py b/test/Fortran/F08FLAGS.py index 34f3d75..c693c82 100644 --- a/test/Fortran/F08FLAGS.py +++ b/test/Fortran/F08FLAGS.py @@ -103,12 +103,7 @@ g08 = test.detect_tool(fc) if g08: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(F08 = '%(fc)s') diff --git a/test/Fortran/F77.py b/test/Fortran/F77.py index 300df85..8fdd391 100644 --- a/test/Fortran/F77.py +++ b/test/Fortran/F77.py @@ -94,12 +94,7 @@ f77 = test.detect_tool(fc) if f77: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(F77 = '%(fc)s', tools = ['default', 'f77'], F77FILESUFFIXES = ['.f']) diff --git a/test/Fortran/F77FLAGS.py b/test/Fortran/F77FLAGS.py index 8e972ec..9b4c56c 100644 --- a/test/Fortran/F77FLAGS.py +++ b/test/Fortran/F77FLAGS.py @@ -78,12 +78,7 @@ if g77: directory = 'x' test.subdir(directory) - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(F77 = '%(fc)s', tools = ['default', 'f77'], F77FILESUFFIXES = [".f"]) diff --git a/test/Fortran/F90.py b/test/Fortran/F90.py index bbceaac..633b174 100644 --- a/test/Fortran/F90.py +++ b/test/Fortran/F90.py @@ -96,12 +96,7 @@ g90 = test.detect_tool(fc) if g90: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(F90 = '%(fc)s') diff --git a/test/Fortran/F90FLAGS.py b/test/Fortran/F90FLAGS.py index 8eaa938..cf2b3b3 100644 --- a/test/Fortran/F90FLAGS.py +++ b/test/Fortran/F90FLAGS.py @@ -105,12 +105,7 @@ g90 = test.detect_tool(fc) if g90: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(F90 = '%(fc)s') diff --git a/test/Fortran/F95.py b/test/Fortran/F95.py index 56c6edd..0912f71 100644 --- a/test/Fortran/F95.py +++ b/test/Fortran/F95.py @@ -98,12 +98,7 @@ g95 = test.detect_tool(fc) if g95: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(F95 = '%(fc)s') diff --git a/test/Fortran/F95FLAGS.py b/test/Fortran/F95FLAGS.py index 525b8cc..cc5a5e3 100644 --- a/test/Fortran/F95FLAGS.py +++ b/test/Fortran/F95FLAGS.py @@ -111,12 +111,7 @@ if g95: # Exists only such that -Ix finds the directory... """) - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(F95 = '%(fc)s') diff --git a/test/Fortran/FORTRAN.py b/test/Fortran/FORTRAN.py index c03698f..577421e 100644 --- a/test/Fortran/FORTRAN.py +++ b/test/Fortran/FORTRAN.py @@ -90,12 +90,7 @@ f77 = test.detect_tool(fc) if f77: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(FORTRAN = '%(fc)s') diff --git a/test/Fortran/FORTRANFLAGS.py b/test/Fortran/FORTRANFLAGS.py index 7dbc049..7b9f7d7 100644 --- a/test/Fortran/FORTRANFLAGS.py +++ b/test/Fortran/FORTRANFLAGS.py @@ -98,12 +98,7 @@ if g77: directory = 'x' test.subdir(directory) - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(FORTRAN = '%(fc)s') diff --git a/test/Fortran/SHF03.py b/test/Fortran/SHF03.py index 6502f49..d514f64 100644 --- a/test/Fortran/SHF03.py +++ b/test/Fortran/SHF03.py @@ -95,12 +95,7 @@ g03 = test.detect_tool(fc) if g03: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(SHF03 = '%(fc)s') diff --git a/test/Fortran/SHF08.py b/test/Fortran/SHF08.py index 85f2bcd..0aed858 100644 --- a/test/Fortran/SHF08.py +++ b/test/Fortran/SHF08.py @@ -95,12 +95,7 @@ g08 = test.detect_tool(fc) if g08: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(SHF08 = '%(fc)s') diff --git a/test/Fortran/SHF77.py b/test/Fortran/SHF77.py index ff2a0ca..3c2565b 100644 --- a/test/Fortran/SHF77.py +++ b/test/Fortran/SHF77.py @@ -94,12 +94,7 @@ f77 = test.detect_tool(fc) if f77: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(SHF77 = '%(fc)s') diff --git a/test/Fortran/SHF77FLAGS.py b/test/Fortran/SHF77FLAGS.py index 79e46f3..1b9628c 100644 --- a/test/Fortran/SHF77FLAGS.py +++ b/test/Fortran/SHF77FLAGS.py @@ -78,12 +78,7 @@ if g77: directory = 'x' test.subdir(directory) - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(SHF77 = '%(fc)s') diff --git a/test/Fortran/SHF90.py b/test/Fortran/SHF90.py index 486b57b..46bf4ae 100644 --- a/test/Fortran/SHF90.py +++ b/test/Fortran/SHF90.py @@ -96,12 +96,7 @@ g90 = test.detect_tool(fc) if g90: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(SHF90 = '%(fc)s') diff --git a/test/Fortran/SHF90FLAGS.py b/test/Fortran/SHF90FLAGS.py index d5066c6..0f9e2ba3 100644 --- a/test/Fortran/SHF90FLAGS.py +++ b/test/Fortran/SHF90FLAGS.py @@ -101,12 +101,7 @@ g90 = test.detect_tool(fc) if g90: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(SHF90 = '%(fc)s') diff --git a/test/Fortran/SHF95.py b/test/Fortran/SHF95.py index 0b64923..6329c9e 100644 --- a/test/Fortran/SHF95.py +++ b/test/Fortran/SHF95.py @@ -95,12 +95,7 @@ g95 = test.detect_tool(fc) if g95: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(SHF95 = '%(fc)s') diff --git a/test/Fortran/SHF95FLAGS.py b/test/Fortran/SHF95FLAGS.py index 8e75878..e573eb4 100644 --- a/test/Fortran/SHF95FLAGS.py +++ b/test/Fortran/SHF95FLAGS.py @@ -110,12 +110,7 @@ if g95: # Exists only such that -Ix finds the directory... """) - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(SHF95 = '%(fc)s') diff --git a/test/Fortran/SHFORTRAN.py b/test/Fortran/SHFORTRAN.py index d9ae55d..fdcba7f 100644 --- a/test/Fortran/SHFORTRAN.py +++ b/test/Fortran/SHFORTRAN.py @@ -89,12 +89,7 @@ fortran = test.detect_tool(fc) if fortran: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(SHFORTRAN = '%(fc)s') diff --git a/test/Fortran/SHFORTRANFLAGS.py b/test/Fortran/SHFORTRANFLAGS.py index 8e6f019..7067c6f 100644 --- a/test/Fortran/SHFORTRANFLAGS.py +++ b/test/Fortran/SHFORTRANFLAGS.py @@ -94,12 +94,7 @@ if fortran: directory = 'x' test.subdir(directory) - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(SHFORTRAN = '%(fc)s') diff --git a/test/Ghostscript/GSFLAGS.py b/test/Ghostscript/GSFLAGS.py index 16ad6c1..c8e0668 100644 --- a/test/Ghostscript/GSFLAGS.py +++ b/test/Ghostscript/GSFLAGS.py @@ -82,12 +82,7 @@ gs = test.where_is(gs_executable) if gs: - test.write("wrapper.py", """import os -import sys -cmd = " ".join(sys.argv[1:]) -open('%s', 'ab').write("%%s\\n" %% cmd) -os.system(cmd) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """\ import os diff --git a/test/Java/JAR.py b/test/Java/JAR.py index 81664dc..98dfa38 100644 --- a/test/Java/JAR.py +++ b/test/Java/JAR.py @@ -124,12 +124,7 @@ where_jar = test.java_where_jar() -test.write("wrapper.py", """\ -import os -import sys -open('%s', 'ab').write("wrapper.py %%s\\n" %% " ".join(sys.argv[1:])) -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(tools = ['javac', 'jar'], diff --git a/test/Java/JAVAH.py b/test/Java/JAVAH.py index 81582d7..f647b03 100644 --- a/test/Java/JAVAH.py +++ b/test/Java/JAVAH.py @@ -105,12 +105,7 @@ if java_version: if test.javac_is_gcj: test.skip_test('Test not valid for gcj (gnu java); skipping test(s).\n') -test.write("wrapper.py", """\ -import os -import sys -open('%s', 'ab').write("wrapper.py %%s\\n" %% " ".join(sys.argv[1:])) -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(tools = ['javac', 'javah', 'install'], diff --git a/test/Java/RMIC.py b/test/Java/RMIC.py index 876ed80..5f5decd 100644 --- a/test/Java/RMIC.py +++ b/test/Java/RMIC.py @@ -111,12 +111,7 @@ if java_version.count('.') == 1: # Note, how we allow simple version strings like "5" and # "6" to successfully pass this test. if curver < (1, 8): - test.write("wrapper.py", """\ -import os -import sys -open('%s', 'ab').write("wrapper.py %%s\\n" %% " ".join(sys.argv[1:])) -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(tools = ['javac', 'rmic'], diff --git a/test/LEX/live.py b/test/LEX/live.py index 2abb8ce..3d697d5 100644 --- a/test/LEX/live.py +++ b/test/LEX/live.py @@ -42,11 +42,7 @@ if not lex: -test.write("wrapper.py", """import os -import sys -open('%s', 'wb').write(b"wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment() diff --git a/test/LINK/LINK.py b/test/LINK/LINK.py index 54c75fa..533163c 100644 --- a/test/LINK/LINK.py +++ b/test/LINK/LINK.py @@ -33,12 +33,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() -test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write(("wrapper.py\\n").encode()) -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment() diff --git a/test/LINK/SHLINK.py b/test/LINK/SHLINK.py index 7353996..9b546c7 100644 --- a/test/LINK/SHLINK.py +++ b/test/LINK/SHLINK.py @@ -34,12 +34,7 @@ _shlib = TestSCons._dll test = TestSCons.TestSCons() -test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write(b"wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment() diff --git a/test/M4/M4.py b/test/M4/M4.py index d2b8365..4306558 100644 --- a/test/M4/M4.py +++ b/test/M4/M4.py @@ -67,12 +67,7 @@ m4 = test.where_is('m4') if m4: - test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write(b"wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(tools=['default', 'm4'], diff --git a/test/RANLIB/RANLIB.py b/test/RANLIB/RANLIB.py index fbfe36c..8d64b36 100644 --- a/test/RANLIB/RANLIB.py +++ b/test/RANLIB/RANLIB.py @@ -39,12 +39,7 @@ ranlib = test.detect('RANLIB', 'ranlib') if not ranlib: test.skip_test("Could not find 'ranlib', skipping test.\n") -test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(LIBS = ['foo'], LIBPATH = ['.']) diff --git a/test/RANLIB/RANLIBFLAGS.py b/test/RANLIB/RANLIBFLAGS.py index 86e5283..0de0cdc 100644 --- a/test/RANLIB/RANLIBFLAGS.py +++ b/test/RANLIB/RANLIBFLAGS.py @@ -38,12 +38,7 @@ ranlib = test.detect('RANLIB', 'ranlib') if not ranlib: test.skip_test("Could not find 'ranlib', skipping test.\n") -test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(LIBS = ['foo'], LIBPATH = ['.']) diff --git a/test/SWIG/live.py b/test/SWIG/live.py index 7d79bae..5e95dc7 100644 --- a/test/SWIG/live.py +++ b/test/SWIG/live.py @@ -61,12 +61,7 @@ if sys.platform == 'win32' and sys.maxsize <= 2**32: else: swig_arch_var="" -test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """\ foo = Environment(SWIGFLAGS='-python', diff --git a/test/TAR/TAR.py b/test/TAR/TAR.py index 93c5cea..8aa2747 100644 --- a/test/TAR/TAR.py +++ b/test/TAR/TAR.py @@ -88,11 +88,7 @@ tar = test.detect('TAR', 'tar') if tar: - test.write("wrapper.py", """import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment() diff --git a/test/TAR/TARFLAGS.py b/test/TAR/TARFLAGS.py index 96d61fe..034539c 100644 --- a/test/TAR/TARFLAGS.py +++ b/test/TAR/TARFLAGS.py @@ -94,11 +94,7 @@ tar = test.detect('TAR', 'tar') if tar: - test.write("wrapper.py", """import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment() diff --git a/test/TEX/LATEX.py b/test/TEX/LATEX.py index 03d3a00..c6f58e6 100644 --- a/test/TEX/LATEX.py +++ b/test/TEX/LATEX.py @@ -96,11 +96,7 @@ latex = test.where_is('latex') if latex: - test.write("wrapper.py", """import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ import os diff --git a/test/TEX/LATEXFLAGS.py b/test/TEX/LATEXFLAGS.py index f693970..46e0479 100644 --- a/test/TEX/LATEXFLAGS.py +++ b/test/TEX/LATEXFLAGS.py @@ -80,11 +80,7 @@ latex = test.where_is('latex') if latex: - test.write("wrapper.py", """import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ import os diff --git a/test/TEX/PDFLATEX.py b/test/TEX/PDFLATEX.py index dbae623..dece385 100644 --- a/test/TEX/PDFLATEX.py +++ b/test/TEX/PDFLATEX.py @@ -96,11 +96,7 @@ pdflatex = test.where_is('pdflatex') if pdflatex: - test.write("wrapper.py", """import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ import os diff --git a/test/TEX/PDFLATEXFLAGS.py b/test/TEX/PDFLATEXFLAGS.py index deee9ed..ffed20b 100644 --- a/test/TEX/PDFLATEXFLAGS.py +++ b/test/TEX/PDFLATEXFLAGS.py @@ -80,11 +80,7 @@ pdflatex = test.where_is('pdflatex') if pdflatex: - test.write("wrapper.py", """import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ import os diff --git a/test/TEX/PDFTEX.py b/test/TEX/PDFTEX.py index 321a58a..5a958d5 100644 --- a/test/TEX/PDFTEX.py +++ b/test/TEX/PDFTEX.py @@ -83,11 +83,7 @@ pdftex = test.where_is('pdftex') if pdftex: - test.write("wrapper.py", """import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ import os diff --git a/test/TEX/PDFTEXFLAGS.py b/test/TEX/PDFTEXFLAGS.py index ce27e82..06dc780 100644 --- a/test/TEX/PDFTEXFLAGS.py +++ b/test/TEX/PDFTEXFLAGS.py @@ -73,11 +73,7 @@ pdftex = test.where_is('pdftex') if pdftex: - test.write("wrapper.py", """import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ import os diff --git a/test/TEX/TEX.py b/test/TEX/TEX.py index e1d634f..3e48419 100644 --- a/test/TEX/TEX.py +++ b/test/TEX/TEX.py @@ -86,11 +86,7 @@ tex = test.where_is('tex') if tex: - test.write("wrapper.py", """import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ import os diff --git a/test/TEX/TEXFLAGS.py b/test/TEX/TEXFLAGS.py index 7ae86ff..e21aaa9 100644 --- a/test/TEX/TEXFLAGS.py +++ b/test/TEX/TEXFLAGS.py @@ -73,11 +73,7 @@ tex = test.where_is('tex') if tex: - test.write("wrapper.py", """import os -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + test.file_fixture('wrapper.py') test.write('SConstruct', """ import os diff --git a/test/YACC/live.py b/test/YACC/live.py index e125daa..253a387 100644 --- a/test/YACC/live.py +++ b/test/YACC/live.py @@ -40,12 +40,7 @@ yacc = test.where_is('yacc') or test.where_is('bison') if not yacc: test.skip_test('No yacc or bison found; skipping test.\n') -test.write("wrapper.py", -"""import os -import sys -open('%s', 'wb').write(b"wrapper.py\\n") -os.system(" ".join(sys.argv[1:])) -""" % test.workpath('wrapper.out').replace('\\', '\\\\')) +test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(YACCFLAGS='-d') -- cgit v0.12 From db1903ca5df83294d9f38f521058b75a7f647c1c Mon Sep 17 00:00:00 2001 From: William Blevins Date: Sat, 24 Sep 2016 06:03:34 -0400 Subject: Ensuring that FS.get_text_contents returns actual text. --- src/engine/SCons/Node/FS.py | 8 ++++++-- src/engine/SCons/Tool/FortranCommon.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 9b7e105..0de3989 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -696,7 +696,7 @@ class Base(SCons.Node.Node): return self._memo['_save_str'] except KeyError: pass - result = sys.intern(self._get_str()) + result = SCons.Util.silent_intern(self._get_str()) self._memo['_save_str'] = result return result @@ -2670,7 +2670,11 @@ class File(Base): return contents[len(codecs.BOM_UTF16_LE):].decode('utf-16-le') if contents.startswith(codecs.BOM_UTF16_BE): return contents[len(codecs.BOM_UTF16_BE):].decode('utf-16-be') - return contents + try: + return contents.decode() + except UnicodeDecodeError: + return contents + def get_content_hash(self): """ diff --git a/src/engine/SCons/Tool/FortranCommon.py b/src/engine/SCons/Tool/FortranCommon.py index 1503639..e450730 100644 --- a/src/engine/SCons/Tool/FortranCommon.py +++ b/src/engine/SCons/Tool/FortranCommon.py @@ -64,7 +64,7 @@ def _fortranEmitter(target, source, env): if not node.exists() and not node.is_derived(): print("Could not locate " + str(node.name)) return ([], []) - mod_regex = b"(?i)^\s*MODULE\s+(?!PROCEDURE)(\w+)" + mod_regex = """(?i)^\s*MODULE\s+(?!PROCEDURE)(\w+)""" cre = re.compile(mod_regex,re.M) # Retrieve all USE'd module names modules = cre.findall(node.get_text_contents()) -- cgit v0.12 From 203e9a690d471e53c88e6fe577188593c98bd9ef Mon Sep 17 00:00:00 2001 From: William Blevins Date: Sat, 24 Sep 2016 06:13:49 -0400 Subject: Revert src/engine/SCons/Scanner/Fortran.py changes. --- src/engine/SCons/Scanner/Fortran.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/engine/SCons/Scanner/Fortran.py b/src/engine/SCons/Scanner/Fortran.py index 9082015..1b55130 100644 --- a/src/engine/SCons/Scanner/Fortran.py +++ b/src/engine/SCons/Scanner/Fortran.py @@ -82,11 +82,11 @@ class F90Scanner(SCons.Scanner.Classic): mods_and_includes = node.includes else: # retrieve all included filenames - includes = self.cre_incl.findall(node.get_contents()) + includes = self.cre_incl.findall(node.get_text_contents()) # retrieve all USE'd module names - modules = self.cre_use.findall(node.get_contents()) + modules = self.cre_use.findall(node.get_text_contents()) # retrieve all defined module names - defmodules = self.cre_def.findall(node.get_contents()) + defmodules = self.cre_def.findall(node.get_text_contents()) # Remove all USE'd module names that are defined in the same file # (case-insensitively) @@ -187,7 +187,7 @@ def FortranScan(path_variable="FORTRANPATH"): # (\w+) : match the module name that is being USE'd # # - use_regex = b"(?i)(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)" + use_regex = "(?i)(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)" # The INCLUDE statement regex matches the following: @@ -275,7 +275,7 @@ def FortranScan(path_variable="FORTRANPATH"): # set of semicolon-separated INCLUDE statements # (as allowed by the F2003 standard) - include_regex = b"(?i)(?:^|['\">]\s*;)\s*INCLUDE\s+(?:\w+_)?[<\"'](.+?)(?=[\"'>])" + include_regex = """(?i)(?:^|['">]\s*;)\s*INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])""" # The MODULE statement regex finds module definitions by matching # the following: @@ -299,7 +299,7 @@ def FortranScan(path_variable="FORTRANPATH"): # that make up the defined module name and # save it in a group - def_regex = b"(?i)^\s*MODULE\s+(?!PROCEDURE)(\w+)" + def_regex = """(?i)^\s*MODULE\s+(?!PROCEDURE)(\w+)""" scanner = F90Scanner("FortranScan", "$FORTRANSUFFIXES", -- cgit v0.12 From 6dd3fd8b838d18d65edd6e7adabf3a363437f8a9 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Sat, 24 Sep 2016 18:36:07 -0400 Subject: Moved fixture directory under #test. --- fixture/mylink.py | 31 ------------------------------- fixture/wrapper.py | 6 ------ runtest.py | 2 +- test/fixture/mylink.py | 31 +++++++++++++++++++++++++++++++ test/fixture/sconstest.skip | 0 test/fixture/wrapper.py | 6 ++++++ 6 files changed, 38 insertions(+), 38 deletions(-) delete mode 100644 fixture/mylink.py delete mode 100644 fixture/wrapper.py create mode 100644 test/fixture/mylink.py create mode 100644 test/fixture/sconstest.skip create mode 100644 test/fixture/wrapper.py diff --git a/fixture/mylink.py b/fixture/mylink.py deleted file mode 100644 index 7c03f00..0000000 --- a/fixture/mylink.py +++ /dev/null @@ -1,31 +0,0 @@ -import sys - -if sys.platform == 'win32': - args = sys.argv[1:] - while args: - a = args[0] - if a == '-o': - out = args[1] - args = args[2:] - continue - if not a[0] in '/-': - break - args = args[1:] - if a[:5].lower() == '/out:': out = a[5:] - infile = open(args[0], 'rb') - outfile = open(out, 'wb') - for l in infile.readlines(): - if l[:5] != b'#link': - outfile.write(l) - sys.exit(0) -else: - import getopt - opts, args = getopt.getopt(sys.argv[1:], 'o:') - for opt, arg in opts: - if opt == '-o': out = arg - infile = open(args[0], 'rb') - outfile = open(out, 'wb') - for l in infile.readlines(): - if l[:5] != b'#link': - outfile.write(l) - sys.exit(0) diff --git a/fixture/wrapper.py b/fixture/wrapper.py deleted file mode 100644 index f02ea03..0000000 --- a/fixture/wrapper.py +++ /dev/null @@ -1,6 +0,0 @@ -import os -import sys -if '--version' not in sys.argv and '-dumpversion' not in sys.argv: - path = os.path.join(os.path.dirname(os.path.relpath(__file__)), 'wrapper.out') - open(path, 'wb').write(b"wrapper.py\n") -os.system(" ".join(sys.argv[1:])) diff --git a/runtest.py b/runtest.py index c856740..d636b73 100755 --- a/runtest.py +++ b/runtest.py @@ -789,7 +789,7 @@ def run_test(t, io_lock, async=True): fixture_dirs = [] if head: fixture_dirs.append(head) - fixture_dirs.append(os.path.join(scriptpath, 'fixture')) + fixture_dirs.append(os.path.join(scriptpath, 'test', 'fixture')) os.environ['FIXTURE_DIRS'] = ':'.join(fixture_dirs) test_start_time = time_func() diff --git a/test/fixture/mylink.py b/test/fixture/mylink.py new file mode 100644 index 0000000..7c03f00 --- /dev/null +++ b/test/fixture/mylink.py @@ -0,0 +1,31 @@ +import sys + +if sys.platform == 'win32': + args = sys.argv[1:] + while args: + a = args[0] + if a == '-o': + out = args[1] + args = args[2:] + continue + if not a[0] in '/-': + break + args = args[1:] + if a[:5].lower() == '/out:': out = a[5:] + infile = open(args[0], 'rb') + outfile = open(out, 'wb') + for l in infile.readlines(): + if l[:5] != b'#link': + outfile.write(l) + sys.exit(0) +else: + import getopt + opts, args = getopt.getopt(sys.argv[1:], 'o:') + for opt, arg in opts: + if opt == '-o': out = arg + infile = open(args[0], 'rb') + outfile = open(out, 'wb') + for l in infile.readlines(): + if l[:5] != b'#link': + outfile.write(l) + sys.exit(0) diff --git a/test/fixture/sconstest.skip b/test/fixture/sconstest.skip new file mode 100644 index 0000000..e69de29 diff --git a/test/fixture/wrapper.py b/test/fixture/wrapper.py new file mode 100644 index 0000000..f02ea03 --- /dev/null +++ b/test/fixture/wrapper.py @@ -0,0 +1,6 @@ +import os +import sys +if '--version' not in sys.argv and '-dumpversion' not in sys.argv: + path = os.path.join(os.path.dirname(os.path.relpath(__file__)), 'wrapper.out') + open(path, 'wb').write(b"wrapper.py\n") +os.system(" ".join(sys.argv[1:])) -- cgit v0.12