From bb22e5738126566b9e3ca826dfa2042e37ba59bd Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 16 Oct 2018 16:11:56 -0700 Subject: Fix logic which populates JAVAINCLUDES when javac is not found. Restore checks in some java tests to skip test if no javac and/or jar found --- src/engine/SCons/Tool/JavaCommon.py | 5 ++++- test/Java/JAR.py | 4 ++++ test/Java/JARCHDIR.py | 3 +++ test/Java/JARFLAGS.py | 4 ++++ test/Java/source-files.py | 4 ++++ 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/engine/SCons/Tool/JavaCommon.py b/src/engine/SCons/Tool/JavaCommon.py index 3a472a9..ba74386 100644 --- a/src/engine/SCons/Tool/JavaCommon.py +++ b/src/engine/SCons/Tool/JavaCommon.py @@ -437,7 +437,10 @@ def get_java_include_paths(env, javac, version): :return: """ paths = [] - if env['PLATFORM'] == 'win32': + if not javac: + # there are no paths if we've not detected javac. + pass + elif env['PLATFORM'] == 'win32': javac_bin_dir = os.path.dirname(javac) java_inc_dir = os.path.normpath(os.path.join(javac_bin_dir, '..', 'include')) paths = [java_inc_dir, os.path.join(java_inc_dir, 'win32')] diff --git a/test/Java/JAR.py b/test/Java/JAR.py index 1eae9eb..d5425af 100644 --- a/test/Java/JAR.py +++ b/test/Java/JAR.py @@ -32,6 +32,10 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() +# Keep this logic because it skips the test if javac or jar not found. +where_javac, java_version = test.java_where_javac() +where_jar = test.java_where_jar() + test.write('myjar.py', r""" import sys args = sys.argv[1:] diff --git a/test/Java/JARCHDIR.py b/test/Java/JARCHDIR.py index e602fad..59bf082 100644 --- a/test/Java/JARCHDIR.py +++ b/test/Java/JARCHDIR.py @@ -38,6 +38,9 @@ import os import TestSCons test = TestSCons.TestSCons() +# Keep this logic because it skips the test if javac or jar not found. +where_javac, java_version = test.java_where_javac() +where_jar = test.java_where_jar() test.write('SConstruct', """ DefaultEnvironment(tools=[]) diff --git a/test/Java/JARFLAGS.py b/test/Java/JARFLAGS.py index e89d02b..39a0a6c 100644 --- a/test/Java/JARFLAGS.py +++ b/test/Java/JARFLAGS.py @@ -30,6 +30,10 @@ import TestSCons test = TestSCons.TestSCons() +# Keep this logic because it skips the test if javac or jar not found. +where_javac, java_version = test.java_where_javac() +where_jar = test.java_where_jar() + test.subdir('src') test.write('SConstruct', """ diff --git a/test/Java/source-files.py b/test/Java/source-files.py index ab395a0..e5cb8b6 100644 --- a/test/Java/source-files.py +++ b/test/Java/source-files.py @@ -35,6 +35,10 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() +# Keep this logic because it skips the test if javac or jar not found. +where_javac, java_version = test.java_where_javac() +where_jar = test.java_where_jar() + test.write('SConstruct', """ env = Environment(tools = ['javac', 'javah']) env.Java(target = 'class1', source = 'com/Example1.java') -- cgit v0.12 From 2888f3ae53a54b57a0b21dd46020a63b48cb505d Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 16 Oct 2018 16:13:34 -0700 Subject: Update CHANGES.txt --- src/CHANGES.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index d5b9251..0f13ef5 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -51,6 +51,7 @@ RELEASE 3.1.0.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE - Fix Java tools to search reasonable default paths for Win32, Linux, macOS. Add required paths for swig and java native interface to JAVAINCLUDES. You should add these to your CPPPATH if you need to compile with them. This handles spaces in paths in default Java paths on windows. + - Fix new logic which populates JAVAINCLUDES to handle the case where javac is not found. From Andrew Featherstone - Removed unused --warn options from the man page and source code. -- cgit v0.12 From a6561696dbb32cad18386cee6601cbc0624cc043 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Wed, 17 Oct 2018 10:30:18 -0400 Subject: PEP8 --- src/engine/SCons/UtilTests.py | 186 ++++++++++++++++++++++++------------------ 1 file changed, 106 insertions(+), 80 deletions(-) diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py index 81ec09d..bee7d6e 100644 --- a/src/engine/SCons/UtilTests.py +++ b/src/engine/SCons/UtilTests.py @@ -37,9 +37,13 @@ import SCons.Errors from SCons.Util import * -try: eval('unicode') -except NameError: HasUnicode = False -else: HasUnicode = True +try: + eval('unicode') +except NameError: + HasUnicode = False +else: + HasUnicode = True + class OutBuffer(object): def __init__(self): @@ -48,47 +52,59 @@ class OutBuffer(object): def write(self, str): self.buffer = self.buffer + str + class dictifyTestCase(unittest.TestCase): def test_dictify(self): """Test the dictify() function""" r = SCons.Util.dictify(['a', 'b', 'c'], [1, 2, 3]) - assert r == {'a':1, 'b':2, 'c':3}, r + assert r == {'a': 1, 'b': 2, 'c': 3}, r r = {} SCons.Util.dictify(['a'], [1], r) SCons.Util.dictify(['b'], [2], r) SCons.Util.dictify(['c'], [3], r) - assert r == {'a':1, 'b':2, 'c':3}, r + assert r == {'a': 1, 'b': 2, 'c': 3}, r + class UtilTestCase(unittest.TestCase): def test_splitext(self): - assert splitext('foo') == ('foo','') - assert splitext('foo.bar') == ('foo','.bar') - assert splitext(os.path.join('foo.bar', 'blat')) == (os.path.join('foo.bar', 'blat'),'') + assert splitext('foo') == ('foo', '') + assert splitext('foo.bar') == ('foo', '.bar') + assert splitext(os.path.join('foo.bar', 'blat')) == (os.path.join('foo.bar', 'blat'), '') class Node(object): def __init__(self, name, children=[]): self.children = children self.name = name self.nocache = None + def __str__(self): return self.name + def exists(self): return 1 + def rexists(self): return 1 + def has_builder(self): return 1 + def has_explicit_builder(self): return 1 + def side_effect(self): return 1 + def precious(self): return 1 + def always_build(self): return 1 + def is_up_to_date(self): return 1 + def noclean(self): return 1 @@ -115,7 +131,7 @@ class UtilTestCase(unittest.TestCase): """ lines = expect.split('\n')[:-1] - lines = ['[E BSPACN ]'+l for l in lines] + lines = ['[E BSPACN ]' + l for l in lines] withtags = '\n'.join(lines) + '\n' return foo, expect, withtags @@ -150,13 +166,14 @@ class UtilTestCase(unittest.TestCase): """ lines = expect.split('\n')[:-1] - lines = ['[E BSPACN ]'+l for l in lines] + lines = ['[E BSPACN ]' + l for l in lines] withtags = '\n'.join(lines) + '\n' return blat_o, expect, withtags def test_render_tree(self): """Test the render_tree() function""" + def get_children(node): return node.children @@ -177,6 +194,7 @@ class UtilTestCase(unittest.TestCase): def test_print_tree(self): """Test the print_tree() function""" + def get_children(node): return node.children @@ -243,7 +261,7 @@ class UtilTestCase(unittest.TestCase): assert is_Dict(UserDict()) # os.environ is not a dictionary in python 3 - if sys.version_info < (3,0): + if sys.version_info < (3, 0): assert is_Dict(os.environ) try: @@ -313,42 +331,42 @@ class UtilTestCase(unittest.TestCase): bytearray(u'Hello', 'utf-8'), "Check that to_bytes creates byte array when presented with unicode string. PY2 only") - def test_to_String(self): """Test the to_String() method.""" assert to_String(1) == "1", to_String(1) - assert to_String([ 1, 2, 3]) == str([1, 2, 3]), to_String([1,2,3]) + assert to_String([1, 2, 3]) == str([1, 2, 3]), to_String([1, 2, 3]) assert to_String("foo") == "foo", to_String("foo") assert to_String(None) == 'None' # test low level string converters too assert to_str(None) == 'None' assert to_bytes(None) == b'None' - s1=UserString('blah') + s1 = UserString('blah') assert to_String(s1) == s1, s1 assert to_String(s1) == 'blah', s1 class Derived(UserString): pass + s2 = Derived('foo') assert to_String(s2) == s2, s2 assert to_String(s2) == 'foo', s2 if HasUnicode: - s3=UserString(unicode('bar')) + s3 = UserString(unicode('bar')) assert to_String(s3) == s3, s3 assert to_String(s3) == unicode('bar'), s3 assert isinstance(to_String(s3), unicode), \ - type(to_String(s3)) + type(to_String(s3)) if HasUnicode: s4 = unicode('baz') assert to_String(s4) == unicode('baz'), to_String(s4) assert isinstance(to_String(s4), unicode), \ - type(to_String(s4)) + type(to_String(s4)) def test_WhereIs(self): - test = TestCmd.TestCmd(workdir = '') + test = TestCmd.TestCmd(workdir='') sub1_xxx_exe = test.workpath('sub1', 'xxx.exe') sub2_xxx_exe = test.workpath('sub2', 'xxx.exe') @@ -371,17 +389,17 @@ class UtilTestCase(unittest.TestCase): env_path = os.environ['PATH'] try: - pathdirs_1234 = [ test.workpath('sub1'), - test.workpath('sub2'), - test.workpath('sub3'), - test.workpath('sub4'), - ] + env_path.split(os.pathsep) - - pathdirs_1243 = [ test.workpath('sub1'), - test.workpath('sub2'), - test.workpath('sub4'), - test.workpath('sub3'), - ] + env_path.split(os.pathsep) + pathdirs_1234 = [test.workpath('sub1'), + test.workpath('sub2'), + test.workpath('sub3'), + test.workpath('sub4'), + ] + env_path.split(os.pathsep) + + pathdirs_1243 = [test.workpath('sub1'), + test.workpath('sub2'), + test.workpath('sub4'), + test.workpath('sub3'), + ] + env_path.split(os.pathsep) os.environ['PATH'] = os.pathsep.join(pathdirs_1234) wi = WhereIs('xxx.exe') @@ -391,9 +409,9 @@ class UtilTestCase(unittest.TestCase): wi = WhereIs('xxx.exe', os.pathsep.join(pathdirs_1243)) assert wi == test.workpath(sub4_xxx_exe), wi - wi = WhereIs('xxx.exe',reject = sub3_xxx_exe) + wi = WhereIs('xxx.exe', reject=sub3_xxx_exe) assert wi == test.workpath(sub4_xxx_exe), wi - wi = WhereIs('xxx.exe', pathdirs_1243, reject = sub3_xxx_exe) + wi = WhereIs('xxx.exe', pathdirs_1243, reject=sub3_xxx_exe) assert wi == test.workpath(sub4_xxx_exe), wi os.environ['PATH'] = os.pathsep.join(pathdirs_1243) @@ -405,19 +423,19 @@ class UtilTestCase(unittest.TestCase): assert wi == test.workpath(sub3_xxx_exe), wi if sys.platform == 'win32': - wi = WhereIs('xxx', pathext = '') + wi = WhereIs('xxx', pathext='') assert wi is None, wi - wi = WhereIs('xxx', pathext = '.exe') + wi = WhereIs('xxx', pathext='.exe') assert wi == test.workpath(sub4_xxx_exe), wi - wi = WhereIs('xxx', path = pathdirs_1234, pathext = '.BAT;.EXE') + wi = WhereIs('xxx', path=pathdirs_1234, pathext='.BAT;.EXE') assert wi.lower() == test.workpath(sub3_xxx_exe).lower(), wi # Test that we return a normalized path even when # the path contains forward slashes. forward_slash = test.workpath('') + '/sub3' - wi = WhereIs('xxx', path = forward_slash, pathext = '.EXE') + wi = WhereIs('xxx', path=forward_slash, pathext='.EXE') assert wi.lower() == test.workpath(sub3_xxx_exe).lower(), wi del os.environ['PATH'] @@ -437,24 +455,27 @@ class UtilTestCase(unittest.TestCase): assert get_environment_var("$BAR ") == None, get_environment_var("$BAR ") assert get_environment_var("FOO$BAR") == None, get_environment_var("FOO$BAR") assert get_environment_var("$FOO[0]") == None, get_environment_var("$FOO[0]") - assert get_environment_var("${some('complex expression')}") == None, get_environment_var("${some('complex expression')}") + assert get_environment_var("${some('complex expression')}") == None, get_environment_var( + "${some('complex expression')}") def test_Proxy(self): """Test generic Proxy class.""" + class Subject(object): def foo(self): return 1 + def bar(self): return 2 - s=Subject() + s = Subject() s.baz = 3 class ProxyTest(Proxy): def bar(self): return 4 - p=ProxyTest(s) + p = ProxyTest(s) assert p.foo() == 1, p.foo() assert p.bar() == 4, p.bar() @@ -503,49 +524,49 @@ class UtilTestCase(unittest.TestCase): p1 = r'C:\dir\num\one;C:\dir\num\two' p2 = r'C:\mydir\num\one;C:\mydir\num\two' # have to include the pathsep here so that the test will work on UNIX too. - p1 = PrependPath(p1,r'C:\dir\num\two',sep = ';') - p1 = PrependPath(p1,r'C:\dir\num\three',sep = ';') - p2 = PrependPath(p2,r'C:\mydir\num\three',sep = ';') - p2 = PrependPath(p2,r'C:\mydir\num\one',sep = ';') - assert(p1 == r'C:\dir\num\three;C:\dir\num\two;C:\dir\num\one') - assert(p2 == r'C:\mydir\num\one;C:\mydir\num\three;C:\mydir\num\two') + p1 = PrependPath(p1, r'C:\dir\num\two', sep=';') + p1 = PrependPath(p1, r'C:\dir\num\three', sep=';') + p2 = PrependPath(p2, r'C:\mydir\num\three', sep=';') + p2 = PrependPath(p2, r'C:\mydir\num\one', sep=';') + assert (p1 == r'C:\dir\num\three;C:\dir\num\two;C:\dir\num\one') + assert (p2 == r'C:\mydir\num\one;C:\mydir\num\three;C:\mydir\num\two') def test_AppendPath(self): """Test appending to a path.""" p1 = r'C:\dir\num\one;C:\dir\num\two' p2 = r'C:\mydir\num\one;C:\mydir\num\two' # have to include the pathsep here so that the test will work on UNIX too. - p1 = AppendPath(p1,r'C:\dir\num\two',sep = ';') - p1 = AppendPath(p1,r'C:\dir\num\three',sep = ';') - p2 = AppendPath(p2,r'C:\mydir\num\three',sep = ';') - p2 = AppendPath(p2,r'C:\mydir\num\one',sep = ';') - assert(p1 == r'C:\dir\num\one;C:\dir\num\two;C:\dir\num\three') - assert(p2 == r'C:\mydir\num\two;C:\mydir\num\three;C:\mydir\num\one') + p1 = AppendPath(p1, r'C:\dir\num\two', sep=';') + p1 = AppendPath(p1, r'C:\dir\num\three', sep=';') + p2 = AppendPath(p2, r'C:\mydir\num\three', sep=';') + p2 = AppendPath(p2, r'C:\mydir\num\one', sep=';') + assert (p1 == r'C:\dir\num\one;C:\dir\num\two;C:\dir\num\three') + assert (p2 == r'C:\mydir\num\two;C:\mydir\num\three;C:\mydir\num\one') def test_PrependPathPreserveOld(self): """Test prepending to a path while preserving old paths""" p1 = r'C:\dir\num\one;C:\dir\num\two' # have to include the pathsep here so that the test will work on UNIX too. - p1 = PrependPath(p1,r'C:\dir\num\two',sep = ';', delete_existing=0) - p1 = PrependPath(p1,r'C:\dir\num\three',sep = ';') - assert(p1 == r'C:\dir\num\three;C:\dir\num\one;C:\dir\num\two') + p1 = PrependPath(p1, r'C:\dir\num\two', sep=';', delete_existing=0) + p1 = PrependPath(p1, r'C:\dir\num\three', sep=';') + assert (p1 == r'C:\dir\num\three;C:\dir\num\one;C:\dir\num\two') def test_AppendPathPreserveOld(self): """Test appending to a path while preserving old paths""" p1 = r'C:\dir\num\one;C:\dir\num\two' # have to include the pathsep here so that the test will work on UNIX too. - p1 = AppendPath(p1,r'C:\dir\num\one',sep = ';', delete_existing=0) - p1 = AppendPath(p1,r'C:\dir\num\three',sep = ';') - assert(p1 == r'C:\dir\num\one;C:\dir\num\two;C:\dir\num\three') + p1 = AppendPath(p1, r'C:\dir\num\one', sep=';', delete_existing=0) + p1 = AppendPath(p1, r'C:\dir\num\three', sep=';') + assert (p1 == r'C:\dir\num\one;C:\dir\num\two;C:\dir\num\three') def test_addPathIfNotExists(self): """Test the AddPathIfNotExists() function""" - env_dict = { 'FOO' : os.path.normpath('/foo/bar') + os.pathsep + \ - os.path.normpath('/baz/blat'), - 'BAR' : os.path.normpath('/foo/bar') + os.pathsep + \ - os.path.normpath('/baz/blat'), - 'BLAT' : [ os.path.normpath('/foo/bar'), - os.path.normpath('/baz/blat') ] } + env_dict = {'FOO': os.path.normpath('/foo/bar') + os.pathsep + \ + os.path.normpath('/baz/blat'), + 'BAR': os.path.normpath('/foo/bar') + os.pathsep + \ + os.path.normpath('/baz/blat'), + 'BLAT': [os.path.normpath('/foo/bar'), + os.path.normpath('/baz/blat')]} AddPathIfNotExists(env_dict, 'FOO', os.path.normpath('/foo/bar')) AddPathIfNotExists(env_dict, 'BAR', os.path.normpath('/bar/foo')) AddPathIfNotExists(env_dict, 'BAZ', os.path.normpath('/foo/baz')) @@ -558,9 +579,9 @@ class UtilTestCase(unittest.TestCase): os.path.normpath('/foo/bar') + os.pathsep + \ os.path.normpath('/baz/blat'), env_dict['BAR'] assert env_dict['BAZ'] == os.path.normpath('/foo/baz'), env_dict['BAZ'] - assert env_dict['BLAT'] == [ os.path.normpath('/baz/foo'), - os.path.normpath('/foo/bar'), - os.path.normpath('/baz/blat') ], env_dict['BLAT' ] + assert env_dict['BLAT'] == [os.path.normpath('/baz/foo'), + os.path.normpath('/foo/bar'), + os.path.normpath('/baz/blat')], env_dict['BLAT'] def test_CLVar(self): """Test the command-line construction variable class""" @@ -669,10 +690,11 @@ class UtilTestCase(unittest.TestCase): def __str__(self): return self.name + def get_suffix(self): return os.path.splitext(self.name)[1] - s = Selector({'a' : 'AAA', 'b' : 'BBB'}) + s = Selector({'a': 'AAA', 'b': 'BBB'}) assert s['a'] == 'AAA', s['a'] assert s['b'] == 'BBB', s['b'] exc_caught = None @@ -692,7 +714,7 @@ class UtilTestCase(unittest.TestCase): env = DummyEnv() - s = Selector({'.d' : 'DDD', '.e' : 'EEE'}) + s = Selector({'.d': 'DDD', '.e': 'EEE'}) ret = s(env, []) assert ret is None, ret ret = s(env, [MyNode('foo.d')]) @@ -705,9 +727,9 @@ class UtilTestCase(unittest.TestCase): ret = s(env, [MyNode('bar.x')]) assert ret == 'XXX', ret - env = DummyEnv({'FSUFF' : '.f', 'GSUFF' : '.g'}) + env = DummyEnv({'FSUFF': '.f', 'GSUFF': '.g'}) - s = Selector({'$FSUFF' : 'FFF', '$GSUFF' : 'GGG'}) + s = Selector({'$FSUFF': 'FFF', '$GSUFF': 'GGG'}) ret = s(env, [MyNode('foo.f')]) assert ret == 'FFF', ret ret = s(env, [MyNode('bar.g')]) @@ -793,9 +815,11 @@ class MD5TestCase(unittest.TestCase): s = MD5signature('222') assert 'bcbe3365e6ac95ea2c0343a2395834dd' == s, s + class NodeListTestCase(unittest.TestCase): def test_simple_attributes(self): """Test simple attributes of a NodeList class""" + class TestClass(object): def __init__(self, name, child=None): self.child = child @@ -806,18 +830,21 @@ class NodeListTestCase(unittest.TestCase): t3 = TestClass('t3') nl = NodeList([t1, t2, t3]) - assert nl.bar == [ 't1', 't2', 't3' ], nl.bar - assert nl[0:2].child.bar == [ 't1child', 't2child' ], \ - nl[0:2].child.bar + assert nl.bar == ['t1', 't2', 't3'], nl.bar + assert nl[0:2].child.bar == ['t1child', 't2child'], \ + nl[0:2].child.bar def test_callable_attributes(self): """Test callable attributes of a NodeList class""" + class TestClass(object): def __init__(self, name, child=None): self.child = child self.bar = name + def foo(self): return self.bar + "foo" + def getself(self): return self @@ -826,13 +853,13 @@ class NodeListTestCase(unittest.TestCase): t3 = TestClass('t3') nl = NodeList([t1, t2, t3]) - assert nl.foo() == [ 't1foo', 't2foo', 't3foo' ], nl.foo() - assert nl.bar == [ 't1', 't2', 't3' ], nl.bar - assert nl.getself().bar == [ 't1', 't2', 't3' ], nl.getself().bar - assert nl[0:2].child.foo() == [ 't1childfoo', 't2childfoo' ], \ - nl[0:2].child.foo() - assert nl[0:2].child.bar == [ 't1child', 't2child' ], \ - nl[0:2].child.bar + assert nl.foo() == ['t1foo', 't2foo', 't3foo'], nl.foo() + assert nl.bar == ['t1', 't2', 't3'], nl.bar + assert nl.getself().bar == ['t1', 't2', 't3'], nl.getself().bar + assert nl[0:2].child.foo() == ['t1childfoo', 't2childfoo'], \ + nl[0:2].child.foo() + assert nl[0:2].child.bar == ['t1child', 't2child'], \ + nl[0:2].child.bar def test_null(self): """Test a null NodeList""" @@ -854,7 +881,6 @@ class flattenTestCase(unittest.TestCase): if __name__ == "__main__": unittest.main() - # Local Variables: # tab-width:4 # indent-tabs-mode:nil -- cgit v0.12 From 15e71f0e56dd21dad0babb09b4e2fe5cbb090be4 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Wed, 17 Oct 2018 10:38:53 -0400 Subject: Add testcase to demonstrate specifying dict.values() on py3 fails. as it returns a dict_values object and not a list --- src/engine/SCons/UtilTests.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py index bee7d6e..7ff509e 100644 --- a/src/engine/SCons/UtilTests.py +++ b/src/engine/SCons/UtilTests.py @@ -877,6 +877,12 @@ class flattenTestCase(unittest.TestCase): result = flatten('xyz') assert result == ['xyz'], result + def test_dictionary_values(self): + """Test flattening the dictionary values""" + items = {"a": 1, "b": 2, "c": 3} + result = flatten(items.values()) + self.assertEquals(sorted(result),[1,2,3]) + if __name__ == "__main__": unittest.main() -- cgit v0.12 From 9c06f18f8b5da659d95f5bb1d7e86c9f82a790ac Mon Sep 17 00:00:00 2001 From: William Deegan Date: Wed, 17 Oct 2018 10:57:56 -0400 Subject: Fix GH Issue #3225 Flatten() doesn't handle dictionary views produces by py3 dict().{items(), values(), keys()} --- src/engine/SCons/Util.py | 10 ++++++++-- src/engine/SCons/UtilTests.py | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index b568ce5..6643b72 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -44,7 +44,7 @@ except ImportError: from UserString import UserString try: - from collections.abc import Iterable + from collections.abc import Iterable, MappingView except ImportError: from collections import Iterable @@ -368,7 +368,13 @@ def print_tree(root, child_func, prune=0, showtags=0, margin=[0], visited=None): DictTypes = (dict, UserDict) ListTypes = (list, UserList) -SequenceTypes = (list, tuple, UserList) + +try: + # Handle getting dictionary views. + SequenceTypes = (list, tuple, UserList, MappingView) +except NameError: + SequenceTypes = (list, tuple, UserList) + # Note that profiling data shows a speed-up when comparing # explicitly with str and unicode instead of simply comparing diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py index 7ff509e..209c60f 100644 --- a/src/engine/SCons/UtilTests.py +++ b/src/engine/SCons/UtilTests.py @@ -875,13 +875,13 @@ class flattenTestCase(unittest.TestCase): def test_scalar(self): """Test flattening a scalar""" result = flatten('xyz') - assert result == ['xyz'], result + self.assertEqual(result,['xyz'], result) def test_dictionary_values(self): """Test flattening the dictionary values""" items = {"a": 1, "b": 2, "c": 3} result = flatten(items.values()) - self.assertEquals(sorted(result),[1,2,3]) + self.assertEqual(sorted(result),[1,2,3]) if __name__ == "__main__": -- cgit v0.12 From fc51dd74d89ec1a4b5704b52d34fe4ef1c6e1982 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Wed, 17 Oct 2018 11:00:51 -0400 Subject: Update CHANGES.txt --- src/CHANGES.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index b413ac3..62e0cea 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -51,6 +51,8 @@ RELEASE 3.1.0.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE - Fix Java tools to search reasonable default paths for Win32, Linux, macOS. Add required paths for swig and java native interface to JAVAINCLUDES. You should add these to your CPPPATH if you need to compile with them. This handles spaces in paths in default Java paths on windows. + - Fix GH Issue #3225 SCons.Util.Flatten() doesn't handle MappingView's produced by dictionary as return + values from dict().{items(), keys(), values()}. From Andrew Featherstone - Removed unused --warn options from the man page and source code. -- cgit v0.12 From 19b57d5bc728c391adceee5a57d4ae7fb6120d7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Tomulik?= Date: Sat, 13 Oct 2018 02:22:40 +0200 Subject: Correct sheabangs in code snippets under test/ --- test/Builder/multi/different-environments.py | 6 +++--- test/Builder/multi/same-overrides.py | 7 ++++--- test/ENV.py | 8 ++++---- test/SWIG/build-dir.py | 6 +++--- test/Scanner/generated.py | 5 +++-- test/TEMPFILEPREFIX.py | 5 +++-- test/TEX/biber_biblatex.py | 5 +++-- test/TEX/biber_biblatex2.py | 5 +++-- test/TEX/biblatex.py | 5 +++-- test/TEX/biblatex_plain.py | 5 +++-- test/explain/basic.py | 6 +++--- test/long-lines/signature.py | 10 +++++----- test/scons-time/run/config/python.py | 7 ++++--- test/scons-time/run/option/python.py | 7 ++++--- test/sconsign/script/SConsignFile.py | 14 +++++++------- test/sconsign/script/Signatures.py | 13 +++++++------ test/sconsign/script/no-SConsignFile.py | 13 +++++++------ test/srcchange.py | 5 +++-- test/subdivide.py | 14 +++++++------- 19 files changed, 79 insertions(+), 67 deletions(-) diff --git a/test/Builder/multi/different-environments.py b/test/Builder/multi/different-environments.py index 686e15c..2de2313 100644 --- a/test/Builder/multi/different-environments.py +++ b/test/Builder/multi/different-environments.py @@ -36,15 +36,15 @@ test = TestSCons.TestSCons(match=TestSCons.match_re) _python_ = TestSCons._python_ -test.write('build.py', r"""#!/usr/bin/env python +test.write('build.py', r"""#!/usr/bin/env python%s import sys def build(num, target, source): file = open(str(target), 'wb') - file.write('%s\n'%num) + file.write('%%s\n' %% num) for s in source: file.write(open(str(s), 'rb').read()) build(sys.argv[1],sys.argv[2],sys.argv[3:]) -""") +""" % sys.version_info[0]) test.write('SConstruct', """\ DefaultEnvironment(tools=[]) diff --git a/test/Builder/multi/same-overrides.py b/test/Builder/multi/same-overrides.py index e51b2ef..0635bed 100644 --- a/test/Builder/multi/same-overrides.py +++ b/test/Builder/multi/same-overrides.py @@ -29,20 +29,21 @@ Verify that everything works if two multi calls have the same overrides. """ import TestSCons +import sys test = TestSCons.TestSCons(match=TestSCons.match_re) _python_ = TestSCons._python_ -test.write('build.py', r"""#!/usr/bin/env python +test.write('build.py', r"""#!/usr/bin/env python%s import sys def build(num, target, source): file = open(str(target), 'wb') - file.write(bytearray('%s\n'%num,'utf-8')) + file.write(bytearray('%%s\n'%% num,'utf-8')) for s in source: file.write(open(str(s), 'rb').read()) build(sys.argv[1],sys.argv[2],sys.argv[3:]) -""") +""" % sys.version_info[0]) test.write('SConstruct', """\ DefaultEnvironment(tools=[]) diff --git a/test/ENV.py b/test/ENV.py index 59b1cdb..4729789 100644 --- a/test/ENV.py +++ b/test/ENV.py @@ -25,7 +25,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os - +import sys import TestSCons _python_ = TestSCons._python_ @@ -47,12 +47,12 @@ env2.Bld(target = 'env2.out', source = 'input') """ % locals()) test.write('build.py', -r"""#!/usr/bin/env python +r"""#!/usr/bin/env python%s import os import sys contents = open(sys.argv[2], 'r').read() -open(sys.argv[1], 'w').write("build.py %s\n%s" % (os.environ['X'], contents)) -""") +open(sys.argv[1], 'w').write("build.py %%s\n%%s" %% (os.environ['X'], contents)) +""" % sys.version_info[0]) test.write('input', "input file\n") diff --git a/test/SWIG/build-dir.py b/test/SWIG/build-dir.py index d268c87..307d6eb 100644 --- a/test/SWIG/build-dir.py +++ b/test/SWIG/build-dir.py @@ -140,7 +140,7 @@ public: """) test.write(['source', 'test.py'], """\ -#!/usr/bin/env python +#!/usr/bin/env python%s from __future__ import print_function import linalg @@ -155,9 +155,9 @@ x[4] = 11.1 for i, v in enumerate(x): - print("\tx[%d] = %g" % (i, v)) + print("\tx[%%d] = %%g" %% (i, v)) -""") +""" % sys.version_info[0]) test.run(arguments = '.') diff --git a/test/Scanner/generated.py b/test/Scanner/generated.py index 4a368b4..8c995be 100644 --- a/test/Scanner/generated.py +++ b/test/Scanner/generated.py @@ -34,6 +34,7 @@ factors triggered the bug Scott saw, and partly because the real-world complexity is valuable in its own right. """ +import sys import TestSCons test = TestSCons.TestSCons() @@ -282,7 +283,7 @@ recurse_env.Command([lib_fullname] + lib_objs, """) test.write(['src', 'lib_geng', 'MAKE-HEADER.py'], """\ -#!/usr/bin/env python +#!/usr/bin/env python%s import os import os.path @@ -293,7 +294,7 @@ os.chdir(os.path.split(sys.argv[0])[0]) for h in ['libg_gx.h', 'libg_gy.h', 'libg_gz.h']: open(h, 'w').write('') -""") +""" % sys.version_info[0]) test.write(['src', 'lib_geng', 'SConstruct'], """\ import os diff --git a/test/TEMPFILEPREFIX.py b/test/TEMPFILEPREFIX.py index f0743e6..a4b25d1 100644 --- a/test/TEMPFILEPREFIX.py +++ b/test/TEMPFILEPREFIX.py @@ -30,6 +30,7 @@ beginning of the TEMPFILE invocation of a long command line. """ import os +import sys import stat import TestSCons @@ -37,11 +38,11 @@ import TestSCons test = TestSCons.TestSCons(match = TestSCons.match_re) test.write('echo.py', """\ -#!/usr/bin/env python +#!/usr/bin/env python%s from __future__ import print_function import sys print(sys.argv) -""") +""" % sys.version_info[0]) echo_py = test.workpath('echo.py') diff --git a/test/TEX/biber_biblatex.py b/test/TEX/biber_biblatex.py index a63fb3f..42a2add 100755 --- a/test/TEX/biber_biblatex.py +++ b/test/TEX/biber_biblatex.py @@ -32,6 +32,7 @@ Test courtesy Rob Managan. import TestSCons import os +import sys test = TestSCons.TestSCons() @@ -49,13 +50,13 @@ if not gloss==0: test.write(['SConstruct'], """\ -#!/usr/bin/env python +#!/usr/bin/env python%s import os env = Environment(ENV=os.environ) env['BIBTEX'] = 'biber' main_output = env.PDF('bibertest.tex') -""") +""" % sys.version_info[0]) sources_bib_content = r""" diff --git a/test/TEX/biber_biblatex2.py b/test/TEX/biber_biblatex2.py index 95b5617..85a833c 100644 --- a/test/TEX/biber_biblatex2.py +++ b/test/TEX/biber_biblatex2.py @@ -34,6 +34,7 @@ Test courtesy Rob Managan. import TestSCons import os +import sys test = TestSCons.TestSCons() @@ -55,12 +56,12 @@ if not biblatex==0: test.write(['SConstruct'], """\ -#!/usr/bin/env python +#!/usr/bin/env python%s import os env = Environment(ENV=os.environ) main_output = env.PDF('bibertest.tex') -""") +""" % sys.version_info[0]) sources_bib_content = r""" diff --git a/test/TEX/biblatex.py b/test/TEX/biblatex.py index a6fbd48..7b0176e 100755 --- a/test/TEX/biblatex.py +++ b/test/TEX/biblatex.py @@ -31,6 +31,7 @@ Test courtesy Rob Managan. """ import TestSCons +import sys import os test = TestSCons.TestSCons() @@ -45,12 +46,12 @@ if not biblatex==0: test.write(['SConstruct'], """\ -#!/usr/bin/env python +#!/usr/bin/env python%s import os env = Environment(ENV=os.environ) main_output = env.PDF(target='biblatextest.pdf', source='biblatextest.tex') -""") +""" % sys.version_info[0]) sources_bib_content = r""" diff --git a/test/TEX/biblatex_plain.py b/test/TEX/biblatex_plain.py index 68f7cc3..6a20761 100644 --- a/test/TEX/biblatex_plain.py +++ b/test/TEX/biblatex_plain.py @@ -32,6 +32,7 @@ Test courtesy Rob Managan. import TestSCons import os +import sys test = TestSCons.TestSCons() @@ -45,12 +46,12 @@ if not biblatex==0: test.write(['SConstruct'], """\ -#!/usr/bin/env python +#!/usr/bin/env python%s import os env = Environment(ENV=os.environ) main_output = env.PDF(target='biblatextest.pdf', source='biblatextest.tex') -""") +""" % sys.version_info[0]) test.write(['biblatextest.tex'],r""" \documentclass{article} diff --git a/test/explain/basic.py b/test/explain/basic.py index 19fc328..ce7c817 100644 --- a/test/explain/basic.py +++ b/test/explain/basic.py @@ -29,7 +29,7 @@ Verify a lot of the basic operation of the --debug=explain option. """ import os - +import sys import TestSCons test = TestSCons.TestSCons() @@ -52,7 +52,7 @@ inc_bbb_k = test.workpath('inc', 'bbb.k') -test.write(cat_py, r"""#!/usr/bin/env python +test.write(cat_py, r"""#!/usr/bin/env python%s from __future__ import print_function import sys @@ -77,7 +77,7 @@ for f in sys.argv[2:]: process(outfp, open(f, 'r')) sys.exit(0) -""") +""" % sys.version_info[0]) SConstruct_contents = """\ diff --git a/test/long-lines/signature.py b/test/long-lines/signature.py index af234a3..480a27c 100644 --- a/test/long-lines/signature.py +++ b/test/long-lines/signature.py @@ -30,7 +30,7 @@ surrounded by $( $) from the signature calculation. """ import os - +import sys import TestSCons test = TestSCons.TestSCons() @@ -38,7 +38,7 @@ test = TestSCons.TestSCons() build_py = test.workpath('build.py') test.write(build_py, """\ -#!/usr/bin/env python +#!/usr/bin/env python%s import sys if sys.argv[1][0] == '@': args = open(sys.argv[1][1:], 'rb').read() @@ -47,9 +47,9 @@ else: args = sys.argv[1:] fp = open(args[0], 'wb') fp.write(open(args[1], 'rb').read()) -fp.write('FILEFLAG=%s\\n' % args[2]) -fp.write('TIMESTAMP=%s\\n' % args[3]) -""") +fp.write('FILEFLAG=%%s\\n' %% args[2]) +fp.write('TIMESTAMP=%%s\\n' %% args[3]) +""" % sys.version_info[0]) os.chmod(build_py, 0o755) diff --git a/test/scons-time/run/config/python.py b/test/scons-time/run/config/python.py index 0734730..92d1600 100644 --- a/test/scons-time/run/config/python.py +++ b/test/scons-time/run/config/python.py @@ -29,6 +29,7 @@ Verify specifying an alternate Python executable in a config file. """ import os +import sys import TestSCons_time @@ -43,7 +44,7 @@ python = r'%(my_python_py)s' """ % locals()) test.write(my_python_py, """\ -#!/usr/bin/env python +#!/usr/bin/env python%s from __future__ import print_function import sys profile = '' @@ -51,8 +52,8 @@ for arg in sys.argv[1:]: if arg.startswith('--profile='): profile = arg[10:] break -print('my_python.py: %s' % profile) -""") +print('my_python.py: %%s' %% profile) +""" % sys.version_info[0]) os.chmod(my_python_py, 0o755) diff --git a/test/scons-time/run/option/python.py b/test/scons-time/run/option/python.py index d0592b6..e508e11 100644 --- a/test/scons-time/run/option/python.py +++ b/test/scons-time/run/option/python.py @@ -29,6 +29,7 @@ Verify the run --python option to specify an alternatie Python executable. """ import os +import sys import TestSCons_time @@ -39,15 +40,15 @@ test.write_sample_project('foo.tar.gz') my_python_py = test.workpath('my_python.py') test.write(my_python_py, """\ -#!/usr/bin/env python +#!/usr/bin/env python%s import sys profile = '' for arg in sys.argv[1:]: if arg.startswith('--profile='): profile = arg[10:] break -sys.stdout.write('my_python.py: %s\\n' % profile) -""") +sys.stdout.write('my_python.py: %%s\\n' %% profile) +""" % sys.version_info[0]) os.chmod(my_python_py, 0o755) diff --git a/test/sconsign/script/SConsignFile.py b/test/sconsign/script/SConsignFile.py index dc45cc1..4adf43d 100644 --- a/test/sconsign/script/SConsignFile.py +++ b/test/sconsign/script/SConsignFile.py @@ -30,7 +30,7 @@ using the signatures in an SConsignFile(). """ import re - +import sys import TestSCons import TestSConsign @@ -41,7 +41,7 @@ test.subdir('sub1', 'sub2') fake_cc_py = test.workpath('fake_cc.py') fake_link_py = test.workpath('fake_link.py') -test.write(fake_cc_py, r"""#!/usr/bin/env python +test.write(fake_cc_py, r"""#!/usr/bin/env python%s import os import re import sys @@ -50,7 +50,7 @@ path = sys.argv[1].split() output = open(sys.argv[2], 'wb') input = open(sys.argv[3], 'rb') -output.write('fake_cc.py: %s\n' % sys.argv) +output.write('fake_cc.py: %%s\n' %% sys.argv) def find_file(f): for dir in path: @@ -71,20 +71,20 @@ def process(infp, outfp): process(input, output) sys.exit(0) -""") +""" % sys.version_info[0]) -test.write(fake_link_py, r"""#!/usr/bin/env python +test.write(fake_link_py, r"""#!/usr/bin/env python%s import sys output = open(sys.argv[1], 'wb') input = open(sys.argv[2], 'rb') -output.write('fake_link.py: %s\n' % sys.argv) +output.write('fake_link.py: %%s\n' %% sys.argv) output.write(input.read()) sys.exit(0) -""") +""" % sys.version_info[0]) test.chmod(fake_cc_py, 0o755) test.chmod(fake_link_py, 0o755) diff --git a/test/sconsign/script/Signatures.py b/test/sconsign/script/Signatures.py index 5babe67..9504ce4 100644 --- a/test/sconsign/script/Signatures.py +++ b/test/sconsign/script/Signatures.py @@ -35,6 +35,7 @@ SourceSignatures('timestamp') with TargetSignatures('content'). import TestSCons import TestSConsign +import sys test = TestSConsign.TestSConsign(match = TestSConsign.match_re) @@ -60,7 +61,7 @@ test.subdir('sub1', 'sub2') fake_cc_py = test.workpath('fake_cc.py') fake_link_py = test.workpath('fake_link.py') -test.write(fake_cc_py, r"""#!/usr/bin/env python +test.write(fake_cc_py, r"""#!/usr/bin/env python%s import os import re import sys @@ -69,7 +70,7 @@ path = sys.argv[1].split() output = open(sys.argv[2], 'wb') input = open(sys.argv[3], 'rb') -output.write('fake_cc.py: %s\n' % sys.argv) +output.write('fake_cc.py: %%s\n' %% sys.argv) def find_file(f): for dir in path: @@ -90,20 +91,20 @@ def process(infp, outfp): process(input, output) sys.exit(0) -""") +""" % sys.version_info[0]) -test.write(fake_link_py, r"""#!/usr/bin/env python +test.write(fake_link_py, r"""#!/usr/bin/env python%s import sys output = open(sys.argv[1], 'wb') input = open(sys.argv[2], 'rb') -output.write('fake_link.py: %s\n' % sys.argv) +output.write('fake_link.py: %%s\n' %% sys.argv) output.write(input.read()) sys.exit(0) -""") +""" % sys.version_info[0]) test.chmod(fake_cc_py, 0o755) test.chmod(fake_link_py, 0o755) diff --git a/test/sconsign/script/no-SConsignFile.py b/test/sconsign/script/no-SConsignFile.py index 4e9915b..3973fc3 100644 --- a/test/sconsign/script/no-SConsignFile.py +++ b/test/sconsign/script/no-SConsignFile.py @@ -31,6 +31,7 @@ Verify that the sconsign script works when using an individual import TestSCons import TestSConsign +import sys test = TestSConsign.TestSConsign(match = TestSConsign.match_re) @@ -49,7 +50,7 @@ test.subdir('sub1', 'sub2') fake_cc_py = test.workpath('fake_cc.py') fake_link_py = test.workpath('fake_link.py') -test.write(fake_cc_py, r"""#!/usr/bin/env python +test.write(fake_cc_py, r"""#!/usr/bin/env python%s import os import re import sys @@ -58,7 +59,7 @@ path = sys.argv[1].split() output = open(sys.argv[2], 'wb') input = open(sys.argv[3], 'rb') -output.write('fake_cc.py: %s\n' % sys.argv) +output.write('fake_cc.py: %%s\n' %% sys.argv) def find_file(f): for dir in path: @@ -79,20 +80,20 @@ def process(infp, outfp): process(input, output) sys.exit(0) -""") +""" % sys.version_info[0]) -test.write(fake_link_py, r"""#!/usr/bin/env python +test.write(fake_link_py, r"""#!/usr/bin/env python%s import sys output = open(sys.argv[1], 'wb') input = open(sys.argv[2], 'rb') -output.write('fake_link.py: %s\n' % sys.argv) +output.write('fake_link.py: %%s\n' %% sys.argv) output.write(input.read()) sys.exit(0) -""") +""" % sys.version_info[0]) test.chmod(fake_cc_py, 0o755) test.chmod(fake_link_py, 0o755) diff --git a/test/srcchange.py b/test/srcchange.py index a156d9b..af153db 100644 --- a/test/srcchange.py +++ b/test/srcchange.py @@ -34,6 +34,7 @@ TargetSignatures('content') but we now rely on the default behavior being the equivalent of Decider('content'). """ +import sys import os.path import TestSCons @@ -43,10 +44,10 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() test.write('getrevision', """ -#!/usr/bin/env python +#!/usr/bin/env python%s from __future__ import print_function print(open('revnum.in','r').read().strip(), end='') -""") +""" % sys.version_info[0]) test.write('SConstruct', """ import re diff --git a/test/subdivide.py b/test/subdivide.py index 8c8eff0..49e5e5d 100644 --- a/test/subdivide.py +++ b/test/subdivide.py @@ -36,7 +36,7 @@ being the equivalent of Decider('content'). """ import os - +import sys import TestSCons test = TestSCons.TestSCons() @@ -59,22 +59,22 @@ fake_cc_py = test.workpath('fake_cc.py') fake_link_py = test.workpath('fake_link.py') test.write(fake_cc_py, """\ -#!/usr/bin/env python +#!/usr/bin/env python%s import sys ofp = open(sys.argv[1], 'w') -ofp.write('fake_cc.py: %s\\n' % sys.argv) +ofp.write('fake_cc.py: %%s\\n' %% sys.argv) for s in sys.argv[2:]: ofp.write(open(s, 'r').read()) -""") +""" % sys.version_info[0]) test.write(fake_link_py, """\ -#!/usr/bin/env python +#!/usr/bin/env python%s import sys ofp = open(sys.argv[1], 'w') -ofp.write('fake_link.py: %s\\n' % sys.argv) +ofp.write('fake_link.py: %%s\\n' %% sys.argv) for s in sys.argv[2:]: ofp.write(open(s, 'r').read()) -""") +""" % sys.version_info[0]) test.chmod(fake_cc_py, 0o755) test.chmod(fake_link_py, 0o755) -- cgit v0.12 From acd60358a5f20a6d82dab42c00ad16a5e07e6428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Tomulik?= Date: Sat, 13 Oct 2018 21:06:58 +0200 Subject: remove unnecessary sheabangs from scripts generated by end-to-end tests --- test/Builder/multi/different-environments.py | 6 ++--- test/Builder/multi/same-overrides.py | 7 +++-- test/ENV.py | 6 ++--- test/SWIG/build-dir.py | 39 ++++++++++++++-------------- test/TEMPFILEPREFIX.py | 4 +-- test/TEX/biber_biblatex.py | 5 +--- test/TEX/biber_biblatex2.py | 5 +--- test/TEX/biblatex.py | 5 +--- test/TEX/biblatex_plain.py | 4 +-- test/explain/basic.py | 5 ++-- test/srcchange.py | 4 +-- test/subdivide.py | 11 +++----- 12 files changed, 41 insertions(+), 60 deletions(-) diff --git a/test/Builder/multi/different-environments.py b/test/Builder/multi/different-environments.py index 2de2313..9ce09b9 100644 --- a/test/Builder/multi/different-environments.py +++ b/test/Builder/multi/different-environments.py @@ -36,15 +36,15 @@ test = TestSCons.TestSCons(match=TestSCons.match_re) _python_ = TestSCons._python_ -test.write('build.py', r"""#!/usr/bin/env python%s +test.write('build.py', r"""\ import sys def build(num, target, source): file = open(str(target), 'wb') - file.write('%%s\n' %% num) + file.write('%s\n' % num) for s in source: file.write(open(str(s), 'rb').read()) build(sys.argv[1],sys.argv[2],sys.argv[3:]) -""" % sys.version_info[0]) +""") test.write('SConstruct', """\ DefaultEnvironment(tools=[]) diff --git a/test/Builder/multi/same-overrides.py b/test/Builder/multi/same-overrides.py index 0635bed..c4c1893 100644 --- a/test/Builder/multi/same-overrides.py +++ b/test/Builder/multi/same-overrides.py @@ -29,21 +29,20 @@ Verify that everything works if two multi calls have the same overrides. """ import TestSCons -import sys test = TestSCons.TestSCons(match=TestSCons.match_re) _python_ = TestSCons._python_ -test.write('build.py', r"""#!/usr/bin/env python%s +test.write('build.py', r"""\ import sys def build(num, target, source): file = open(str(target), 'wb') - file.write(bytearray('%%s\n'%% num,'utf-8')) + file.write(bytearray('%s\n'% num,'utf-8')) for s in source: file.write(open(str(s), 'rb').read()) build(sys.argv[1],sys.argv[2],sys.argv[3:]) -""" % sys.version_info[0]) +""") test.write('SConstruct', """\ DefaultEnvironment(tools=[]) diff --git a/test/ENV.py b/test/ENV.py index 4729789..5972175 100644 --- a/test/ENV.py +++ b/test/ENV.py @@ -47,12 +47,12 @@ env2.Bld(target = 'env2.out', source = 'input') """ % locals()) test.write('build.py', -r"""#!/usr/bin/env python%s +r"""\ import os import sys contents = open(sys.argv[2], 'r').read() -open(sys.argv[1], 'w').write("build.py %%s\n%%s" %% (os.environ['X'], contents)) -""" % sys.version_info[0]) +open(sys.argv[1], 'w').write("build.py %s\n%s" % (os.environ['X'], contents)) +""") test.write('input', "input file\n") diff --git a/test/SWIG/build-dir.py b/test/SWIG/build-dir.py index 307d6eb..946c65c 100644 --- a/test/SWIG/build-dir.py +++ b/test/SWIG/build-dir.py @@ -139,25 +139,26 @@ public: }; """) -test.write(['source', 'test.py'], """\ -#!/usr/bin/env python%s -from __future__ import print_function - -import linalg - - -x = linalg.Vector(5) -print(x) - -x[1] = 99.5 -x[3] = 8.3 -x[4] = 11.1 - - -for i, v in enumerate(x): - print("\tx[%%d] = %%g" %% (i, v)) - -""" % sys.version_info[0]) +## XXX: @ptomulik: looks like it was unused? +## test.write(['source', 'test.py'], """\ +## #!/usr/bin/env python%s +## from __future__ import print_function +## +## import linalg +## +## +## x = linalg.Vector(5) +## print(x) +## +## x[1] = 99.5 +## x[3] = 8.3 +## x[4] = 11.1 +## +## +## for i, v in enumerate(x): +## print("\tx[%%d] = %%g" %% (i, v)) +## +## """ % sys.version_info[0]) test.run(arguments = '.') diff --git a/test/TEMPFILEPREFIX.py b/test/TEMPFILEPREFIX.py index a4b25d1..c47ebc4 100644 --- a/test/TEMPFILEPREFIX.py +++ b/test/TEMPFILEPREFIX.py @@ -30,7 +30,6 @@ beginning of the TEMPFILE invocation of a long command line. """ import os -import sys import stat import TestSCons @@ -38,11 +37,10 @@ import TestSCons test = TestSCons.TestSCons(match = TestSCons.match_re) test.write('echo.py', """\ -#!/usr/bin/env python%s from __future__ import print_function import sys print(sys.argv) -""" % sys.version_info[0]) +""") echo_py = test.workpath('echo.py') diff --git a/test/TEX/biber_biblatex.py b/test/TEX/biber_biblatex.py index 42a2add..b4a4969 100755 --- a/test/TEX/biber_biblatex.py +++ b/test/TEX/biber_biblatex.py @@ -32,7 +32,6 @@ Test courtesy Rob Managan. import TestSCons import os -import sys test = TestSCons.TestSCons() @@ -50,13 +49,11 @@ if not gloss==0: test.write(['SConstruct'], """\ -#!/usr/bin/env python%s - import os env = Environment(ENV=os.environ) env['BIBTEX'] = 'biber' main_output = env.PDF('bibertest.tex') -""" % sys.version_info[0]) +""") sources_bib_content = r""" diff --git a/test/TEX/biber_biblatex2.py b/test/TEX/biber_biblatex2.py index 85a833c..e9893ee 100644 --- a/test/TEX/biber_biblatex2.py +++ b/test/TEX/biber_biblatex2.py @@ -34,7 +34,6 @@ Test courtesy Rob Managan. import TestSCons import os -import sys test = TestSCons.TestSCons() @@ -56,12 +55,10 @@ if not biblatex==0: test.write(['SConstruct'], """\ -#!/usr/bin/env python%s - import os env = Environment(ENV=os.environ) main_output = env.PDF('bibertest.tex') -""" % sys.version_info[0]) +""") sources_bib_content = r""" diff --git a/test/TEX/biblatex.py b/test/TEX/biblatex.py index 7b0176e..21e1a93 100755 --- a/test/TEX/biblatex.py +++ b/test/TEX/biblatex.py @@ -31,7 +31,6 @@ Test courtesy Rob Managan. """ import TestSCons -import sys import os test = TestSCons.TestSCons() @@ -46,12 +45,10 @@ if not biblatex==0: test.write(['SConstruct'], """\ -#!/usr/bin/env python%s - import os env = Environment(ENV=os.environ) main_output = env.PDF(target='biblatextest.pdf', source='biblatextest.tex') -""" % sys.version_info[0]) +""") sources_bib_content = r""" diff --git a/test/TEX/biblatex_plain.py b/test/TEX/biblatex_plain.py index 6a20761..96a8476 100644 --- a/test/TEX/biblatex_plain.py +++ b/test/TEX/biblatex_plain.py @@ -46,12 +46,10 @@ if not biblatex==0: test.write(['SConstruct'], """\ -#!/usr/bin/env python%s - import os env = Environment(ENV=os.environ) main_output = env.PDF(target='biblatextest.pdf', source='biblatextest.tex') -""" % sys.version_info[0]) +""") test.write(['biblatextest.tex'],r""" \documentclass{article} diff --git a/test/explain/basic.py b/test/explain/basic.py index ce7c817..4dfe47b 100644 --- a/test/explain/basic.py +++ b/test/explain/basic.py @@ -29,7 +29,6 @@ Verify a lot of the basic operation of the --debug=explain option. """ import os -import sys import TestSCons test = TestSCons.TestSCons() @@ -52,7 +51,7 @@ inc_bbb_k = test.workpath('inc', 'bbb.k') -test.write(cat_py, r"""#!/usr/bin/env python%s +test.write(cat_py, r""" from __future__ import print_function import sys @@ -77,7 +76,7 @@ for f in sys.argv[2:]: process(outfp, open(f, 'r')) sys.exit(0) -""" % sys.version_info[0]) +""") SConstruct_contents = """\ diff --git a/test/srcchange.py b/test/srcchange.py index af153db..6916d50 100644 --- a/test/srcchange.py +++ b/test/srcchange.py @@ -34,7 +34,6 @@ TargetSignatures('content') but we now rely on the default behavior being the equivalent of Decider('content'). """ -import sys import os.path import TestSCons @@ -44,10 +43,9 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() test.write('getrevision', """ -#!/usr/bin/env python%s from __future__ import print_function print(open('revnum.in','r').read().strip(), end='') -""" % sys.version_info[0]) +""") test.write('SConstruct', """ import re diff --git a/test/subdivide.py b/test/subdivide.py index 49e5e5d..7ddc2e9 100644 --- a/test/subdivide.py +++ b/test/subdivide.py @@ -36,7 +36,6 @@ being the equivalent of Decider('content'). """ import os -import sys import TestSCons test = TestSCons.TestSCons() @@ -59,22 +58,20 @@ fake_cc_py = test.workpath('fake_cc.py') fake_link_py = test.workpath('fake_link.py') test.write(fake_cc_py, """\ -#!/usr/bin/env python%s import sys ofp = open(sys.argv[1], 'w') -ofp.write('fake_cc.py: %%s\\n' %% sys.argv) +ofp.write('fake_cc.py: %s\\n' % sys.argv) for s in sys.argv[2:]: ofp.write(open(s, 'r').read()) -""" % sys.version_info[0]) +""") test.write(fake_link_py, """\ -#!/usr/bin/env python%s import sys ofp = open(sys.argv[1], 'w') -ofp.write('fake_link.py: %%s\\n' %% sys.argv) +ofp.write('fake_link.py: %s\\n' % sys.argv) for s in sys.argv[2:]: ofp.write(open(s, 'r').read()) -""" % sys.version_info[0]) +""") test.chmod(fake_cc_py, 0o755) test.chmod(fake_link_py, 0o755) -- cgit v0.12 From 76ff51ee816e39f98ee26393ac530e9d44a8c9bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Tomulik?= Date: Mon, 22 Oct 2018 21:26:30 +0200 Subject: use absolute python path in sheabangs --- test/ENV.py | 1 - test/SWIG/build-dir.py | 5 +++-- test/Scanner/generated.py | 7 ++++--- test/TEX/biblatex_plain.py | 1 - test/explain/basic.py | 2 +- test/long-lines/signature.py | 7 ++++--- test/scons-time/run/config/python.py | 7 ++++--- test/scons-time/run/option/python.py | 7 ++++--- test/sconsign/script/SConsignFile.py | 11 ++++++----- test/sconsign/script/Signatures.py | 11 ++++++----- test/sconsign/script/no-SConsignFile.py | 11 ++++++----- 11 files changed, 38 insertions(+), 32 deletions(-) diff --git a/test/ENV.py b/test/ENV.py index 5972175..36ad844 100644 --- a/test/ENV.py +++ b/test/ENV.py @@ -25,7 +25,6 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os -import sys import TestSCons _python_ = TestSCons._python_ diff --git a/test/SWIG/build-dir.py b/test/SWIG/build-dir.py index 946c65c..bc105a5 100644 --- a/test/SWIG/build-dir.py +++ b/test/SWIG/build-dir.py @@ -139,9 +139,10 @@ public: }; """) +## _python_ = TestSCons._python_ ## XXX: @ptomulik: looks like it was unused? ## test.write(['source', 'test.py'], """\ -## #!/usr/bin/env python%s +## #!%(_python_)s ## from __future__ import print_function ## ## import linalg @@ -158,7 +159,7 @@ public: ## for i, v in enumerate(x): ## print("\tx[%%d] = %%g" %% (i, v)) ## -## """ % sys.version_info[0]) +## """ % locals()) test.run(arguments = '.') diff --git a/test/Scanner/generated.py b/test/Scanner/generated.py index 8c995be..3e08549 100644 --- a/test/Scanner/generated.py +++ b/test/Scanner/generated.py @@ -34,9 +34,10 @@ factors triggered the bug Scott saw, and partly because the real-world complexity is valuable in its own right. """ -import sys import TestSCons +_python_ = TestSCons._python_ + test = TestSCons.TestSCons() test.subdir('reftree', @@ -283,7 +284,7 @@ recurse_env.Command([lib_fullname] + lib_objs, """) test.write(['src', 'lib_geng', 'MAKE-HEADER.py'], """\ -#!/usr/bin/env python%s +#!%(_python_)s import os import os.path @@ -294,7 +295,7 @@ os.chdir(os.path.split(sys.argv[0])[0]) for h in ['libg_gx.h', 'libg_gy.h', 'libg_gz.h']: open(h, 'w').write('') -""" % sys.version_info[0]) +""" % locals()) test.write(['src', 'lib_geng', 'SConstruct'], """\ import os diff --git a/test/TEX/biblatex_plain.py b/test/TEX/biblatex_plain.py index 96a8476..06b3cc6 100644 --- a/test/TEX/biblatex_plain.py +++ b/test/TEX/biblatex_plain.py @@ -32,7 +32,6 @@ Test courtesy Rob Managan. import TestSCons import os -import sys test = TestSCons.TestSCons() diff --git a/test/explain/basic.py b/test/explain/basic.py index 4dfe47b..99942cd 100644 --- a/test/explain/basic.py +++ b/test/explain/basic.py @@ -51,7 +51,7 @@ inc_bbb_k = test.workpath('inc', 'bbb.k') -test.write(cat_py, r""" +test.write(cat_py, r"""\ from __future__ import print_function import sys diff --git a/test/long-lines/signature.py b/test/long-lines/signature.py index 480a27c..8330fef 100644 --- a/test/long-lines/signature.py +++ b/test/long-lines/signature.py @@ -30,15 +30,16 @@ surrounded by $( $) from the signature calculation. """ import os -import sys import TestSCons +_python_ = TestSCons._python_ + test = TestSCons.TestSCons() build_py = test.workpath('build.py') test.write(build_py, """\ -#!/usr/bin/env python%s +#!%(_python_)s import sys if sys.argv[1][0] == '@': args = open(sys.argv[1][1:], 'rb').read() @@ -49,7 +50,7 @@ fp = open(args[0], 'wb') fp.write(open(args[1], 'rb').read()) fp.write('FILEFLAG=%%s\\n' %% args[2]) fp.write('TIMESTAMP=%%s\\n' %% args[3]) -""" % sys.version_info[0]) +""" % locals()) os.chmod(build_py, 0o755) diff --git a/test/scons-time/run/config/python.py b/test/scons-time/run/config/python.py index 92d1600..c8842c1 100644 --- a/test/scons-time/run/config/python.py +++ b/test/scons-time/run/config/python.py @@ -29,10 +29,11 @@ Verify specifying an alternate Python executable in a config file. """ import os -import sys import TestSCons_time +_python_ = TestSCons_time._python_ + test = TestSCons_time.TestSCons_time() test.write_sample_project('foo.tar.gz') @@ -44,7 +45,7 @@ python = r'%(my_python_py)s' """ % locals()) test.write(my_python_py, """\ -#!/usr/bin/env python%s +#!%(_python_)s from __future__ import print_function import sys profile = '' @@ -53,7 +54,7 @@ for arg in sys.argv[1:]: profile = arg[10:] break print('my_python.py: %%s' %% profile) -""" % sys.version_info[0]) +""" % locals()) os.chmod(my_python_py, 0o755) diff --git a/test/scons-time/run/option/python.py b/test/scons-time/run/option/python.py index e508e11..27ca072 100644 --- a/test/scons-time/run/option/python.py +++ b/test/scons-time/run/option/python.py @@ -29,10 +29,11 @@ Verify the run --python option to specify an alternatie Python executable. """ import os -import sys import TestSCons_time +_python_ = TestSCons_time._python_ + test = TestSCons_time.TestSCons_time() test.write_sample_project('foo.tar.gz') @@ -40,7 +41,7 @@ test.write_sample_project('foo.tar.gz') my_python_py = test.workpath('my_python.py') test.write(my_python_py, """\ -#!/usr/bin/env python%s +#!%(_python_)s import sys profile = '' for arg in sys.argv[1:]: @@ -48,7 +49,7 @@ for arg in sys.argv[1:]: profile = arg[10:] break sys.stdout.write('my_python.py: %%s\\n' %% profile) -""" % sys.version_info[0]) +""" % locals()) os.chmod(my_python_py, 0o755) diff --git a/test/sconsign/script/SConsignFile.py b/test/sconsign/script/SConsignFile.py index 4adf43d..e9eba66 100644 --- a/test/sconsign/script/SConsignFile.py +++ b/test/sconsign/script/SConsignFile.py @@ -30,10 +30,11 @@ using the signatures in an SConsignFile(). """ import re -import sys import TestSCons import TestSConsign +_python_ = TestSCons._python_ + test = TestSConsign.TestSConsign(match = TestSConsign.match_re) test.subdir('sub1', 'sub2') @@ -41,7 +42,7 @@ test.subdir('sub1', 'sub2') fake_cc_py = test.workpath('fake_cc.py') fake_link_py = test.workpath('fake_link.py') -test.write(fake_cc_py, r"""#!/usr/bin/env python%s +test.write(fake_cc_py, r"""#!%(_python_)s import os import re import sys @@ -71,9 +72,9 @@ def process(infp, outfp): process(input, output) sys.exit(0) -""" % sys.version_info[0]) +""" % locals()) -test.write(fake_link_py, r"""#!/usr/bin/env python%s +test.write(fake_link_py, r"""#!%(_python_)s import sys output = open(sys.argv[1], 'wb') @@ -84,7 +85,7 @@ output.write('fake_link.py: %%s\n' %% sys.argv) output.write(input.read()) sys.exit(0) -""" % sys.version_info[0]) +""" % locals()) test.chmod(fake_cc_py, 0o755) test.chmod(fake_link_py, 0o755) diff --git a/test/sconsign/script/Signatures.py b/test/sconsign/script/Signatures.py index 9504ce4..0c6dfb5 100644 --- a/test/sconsign/script/Signatures.py +++ b/test/sconsign/script/Signatures.py @@ -35,7 +35,8 @@ SourceSignatures('timestamp') with TargetSignatures('content'). import TestSCons import TestSConsign -import sys + +_python_ = TestSCons._python_ test = TestSConsign.TestSConsign(match = TestSConsign.match_re) @@ -61,7 +62,7 @@ test.subdir('sub1', 'sub2') fake_cc_py = test.workpath('fake_cc.py') fake_link_py = test.workpath('fake_link.py') -test.write(fake_cc_py, r"""#!/usr/bin/env python%s +test.write(fake_cc_py, r"""#!%(_python_)s import os import re import sys @@ -91,9 +92,9 @@ def process(infp, outfp): process(input, output) sys.exit(0) -""" % sys.version_info[0]) +""" % locals()) -test.write(fake_link_py, r"""#!/usr/bin/env python%s +test.write(fake_link_py, r"""#!%(_python_)s import sys output = open(sys.argv[1], 'wb') @@ -104,7 +105,7 @@ output.write('fake_link.py: %%s\n' %% sys.argv) output.write(input.read()) sys.exit(0) -""" % sys.version_info[0]) +""" % locals()) test.chmod(fake_cc_py, 0o755) test.chmod(fake_link_py, 0o755) diff --git a/test/sconsign/script/no-SConsignFile.py b/test/sconsign/script/no-SConsignFile.py index 3973fc3..6c892e1 100644 --- a/test/sconsign/script/no-SConsignFile.py +++ b/test/sconsign/script/no-SConsignFile.py @@ -31,7 +31,8 @@ Verify that the sconsign script works when using an individual import TestSCons import TestSConsign -import sys + +_python_ = TestSCons._python_ test = TestSConsign.TestSConsign(match = TestSConsign.match_re) @@ -50,7 +51,7 @@ test.subdir('sub1', 'sub2') fake_cc_py = test.workpath('fake_cc.py') fake_link_py = test.workpath('fake_link.py') -test.write(fake_cc_py, r"""#!/usr/bin/env python%s +test.write(fake_cc_py, r"""#!%(_python_)s import os import re import sys @@ -80,9 +81,9 @@ def process(infp, outfp): process(input, output) sys.exit(0) -""" % sys.version_info[0]) +""" % locals()) -test.write(fake_link_py, r"""#!/usr/bin/env python%s +test.write(fake_link_py, r"""#!%(_python_)s import sys output = open(sys.argv[1], 'wb') @@ -93,7 +94,7 @@ output.write('fake_link.py: %%s\n' %% sys.argv) output.write(input.read()) sys.exit(0) -""" % sys.version_info[0]) +""" % locals()) test.chmod(fake_cc_py, 0o755) test.chmod(fake_link_py, 0o755) -- cgit v0.12 From a011d2aa0e21d1dc6ab6b11251a671b7152319fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Tomulik?= Date: Sat, 13 Oct 2018 10:14:34 +0200 Subject: attempt fixing tests failing due to binary mode --- test/long-lines/signature.py | 12 ++++++------ test/sconsign/script/SConsignFile.py | 10 +++++----- test/sconsign/script/Signatures.py | 10 +++++----- test/sconsign/script/no-SConsignFile.py | 10 +++++----- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/test/long-lines/signature.py b/test/long-lines/signature.py index 8330fef..64214b4 100644 --- a/test/long-lines/signature.py +++ b/test/long-lines/signature.py @@ -42,12 +42,12 @@ test.write(build_py, """\ #!%(_python_)s import sys if sys.argv[1][0] == '@': - args = open(sys.argv[1][1:], 'rb').read() + args = open(sys.argv[1][1:], 'r').read() args = args.split() else: args = sys.argv[1:] -fp = open(args[0], 'wb') -fp.write(open(args[1], 'rb').read()) +fp = open(args[0], 'w') +fp.write(open(args[1], 'r').read()) fp.write('FILEFLAG=%%s\\n' %% args[2]) fp.write('TIMESTAMP=%%s\\n' %% args[3]) """ % locals()) @@ -75,17 +75,17 @@ env.Command('file.out', 'file.in', '${TEMPFILE(FILECOM)}') """ % locals()) -test.write('file.in', "file.in\n") +test.write('file.in', "file.in\n", mode='w') test.run(arguments='FILEFLAG=first TIMESTAMP=20090207 .') -test.must_match('file.out', "file.in\nFILEFLAG=first\nTIMESTAMP=20090207\n") +test.must_match('file.out', "file.in\nFILEFLAG=first\nTIMESTAMP=20090207\n", mode='r') test.up_to_date(options='FILEFLAG=first TIMESTAMP=20090208', arguments = '.') test.run(arguments='FILEFLAG=second TIMESTAMP=20090208 .') -test.must_match('file.out', "file.in\nFILEFLAG=second\nTIMESTAMP=20090208\n") +test.must_match('file.out', "file.in\nFILEFLAG=second\nTIMESTAMP=20090208\n", mode='r') test.up_to_date(options='FILEFLAG=second TIMESTAMP=20090209', arguments = '.') diff --git a/test/sconsign/script/SConsignFile.py b/test/sconsign/script/SConsignFile.py index e9eba66..5e56624 100644 --- a/test/sconsign/script/SConsignFile.py +++ b/test/sconsign/script/SConsignFile.py @@ -48,8 +48,8 @@ import re import sys path = sys.argv[1].split() -output = open(sys.argv[2], 'wb') -input = open(sys.argv[3], 'rb') +output = open(sys.argv[2], 'w') +input = open(sys.argv[3], 'r') output.write('fake_cc.py: %%s\n' %% sys.argv) @@ -57,7 +57,7 @@ def find_file(f): for dir in path: p = dir + os.sep + f if os.path.exists(p): - return open(p, 'rb') + return open(p, 'r') return None def process(infp, outfp): @@ -77,8 +77,8 @@ sys.exit(0) test.write(fake_link_py, r"""#!%(_python_)s import sys -output = open(sys.argv[1], 'wb') -input = open(sys.argv[2], 'rb') +output = open(sys.argv[1], 'w') +input = open(sys.argv[2], 'r') output.write('fake_link.py: %%s\n' %% sys.argv) diff --git a/test/sconsign/script/Signatures.py b/test/sconsign/script/Signatures.py index 0c6dfb5..7797bce 100644 --- a/test/sconsign/script/Signatures.py +++ b/test/sconsign/script/Signatures.py @@ -68,8 +68,8 @@ import re import sys path = sys.argv[1].split() -output = open(sys.argv[2], 'wb') -input = open(sys.argv[3], 'rb') +output = open(sys.argv[2], 'w') +input = open(sys.argv[3], 'r') output.write('fake_cc.py: %%s\n' %% sys.argv) @@ -77,7 +77,7 @@ def find_file(f): for dir in path: p = dir + os.sep + f if os.path.exists(p): - return open(p, 'rb') + return open(p, 'r') return None def process(infp, outfp): @@ -97,8 +97,8 @@ sys.exit(0) test.write(fake_link_py, r"""#!%(_python_)s import sys -output = open(sys.argv[1], 'wb') -input = open(sys.argv[2], 'rb') +output = open(sys.argv[1], 'w') +input = open(sys.argv[2], 'r') output.write('fake_link.py: %%s\n' %% sys.argv) diff --git a/test/sconsign/script/no-SConsignFile.py b/test/sconsign/script/no-SConsignFile.py index 6c892e1..d9ab51f 100644 --- a/test/sconsign/script/no-SConsignFile.py +++ b/test/sconsign/script/no-SConsignFile.py @@ -57,8 +57,8 @@ import re import sys path = sys.argv[1].split() -output = open(sys.argv[2], 'wb') -input = open(sys.argv[3], 'rb') +output = open(sys.argv[2], 'w') +input = open(sys.argv[3], 'r') output.write('fake_cc.py: %%s\n' %% sys.argv) @@ -66,7 +66,7 @@ def find_file(f): for dir in path: p = dir + os.sep + f if os.path.exists(p): - return open(p, 'rb') + return open(p, 'r') return None def process(infp, outfp): @@ -86,8 +86,8 @@ sys.exit(0) test.write(fake_link_py, r"""#!%(_python_)s import sys -output = open(sys.argv[1], 'wb') -input = open(sys.argv[2], 'rb') +output = open(sys.argv[1], 'w') +input = open(sys.argv[2], 'r') output.write('fake_link.py: %%s\n' %% sys.argv) -- cgit v0.12 From 4a94e4265d7951bcb10cf2b345fa36d3ddc0432e Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Mon, 29 Oct 2018 10:17:44 -0600 Subject: Update and add show option to cache config scons-configure-cache.py can now show the cache configuration, and some statistics (currently only a file count). Script passes pep8 now. Signed-off-by: Mats Wichmann --- src/CHANGES.txt | 1 + src/script/scons-configure-cache.py | 129 +++++++++++++++++++++++------------- 2 files changed, 84 insertions(+), 46 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 162de48..ddc7e60 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -164,6 +164,7 @@ RELEASE 3.1.0.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE - Syntax cleanups - trailing blanks, use "is" to compare with None, etc. Three uses of variables not defined are changed. - Some script changes in trying to find scons engine + - Update (pep8) configure-cache script, add a --show option. From Bernhard M. Wiedemann: - Update SCons' internal scons build logic to allow overriding build date diff --git a/src/script/scons-configure-cache.py b/src/script/scons-configure-cache.py index 0fc7b48..3c096e1 100644 --- a/src/script/scons-configure-cache.py +++ b/src/script/scons-configure-cache.py @@ -23,7 +23,19 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +'''Show or convert the configuration of an SCons cache directory. + +A cache of derived files is stored by file signature. +The files are split into directories named by the first few +digits of the signature. The prefix length used for directory +names can be changed by this script. +''' + from __future__ import print_function +import argparse +import glob +import json +import os __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -37,88 +49,113 @@ __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) + '''Move cache files if prefix length changed. + + Move the existing cache files to new directories of the + appropriate name length and clean up the old directories. + ''' + 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)) + dname = name[:current_prefix_len].upper() + if dname not in old_dirs: + print('Migrating', dname) + old_dirs.add(dname) + dname = name[:new_prefix_len].upper() + if dname not in dirs: + os.mkdir(dname) + dirs.add(dname) + os.rename(file, os.path.join(dname, name)) # Now delete the original directories - for dir in old_dirs: - os.rmdir(dir) + for dname in old_dirs: + os.rmdir(dname) + -# This dictionary should have one entry per entry in the cache config -# Each entry should have the following: +# The configuration dictionary should have one entry per entry in the +# cache config. The value of each entry should include 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. +# 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 +# converter - (optional) Function to call if conversion is required # 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 + '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). - ''' - ) + description='Modify the configuration of an scons cache directory', + epilog=''' + Unspecified options will not be changed unless they are not + set at all, in which case they are set to an appropriate default. + ''') parser.add_argument('cache-dir', help='Path to scons cache directory') for param in config_entries: - parser.add_argument('--' + param.replace('_', '-'), + parser.add_argument('--' + param.replace('_', '-'), **config_entries[param]['command-line']) -parser.add_argument('--version', action='version', version='%(prog)s 1.0') +parser.add_argument('--version', + action='version', + version='%(prog)s 1.0') +parser.add_argument('--show', + action="store_true", + help="show current configuration") # Get the command line as a dict without any of the unspecified entries. args = dict([x for x in vars(parser.parse_args()).items() if x[1]]) # It seems somewhat strange to me, but positional arguments don't get the - # in the name changed to _, whereas optional arguments do... -os.chdir(args['cache-dir']) +cache = args['cache-dir'] +if not os.path.isdir(cache): + raise RuntimeError("There is no cache directory named %s" % cache) +os.chdir(cache) del args['cache-dir'] if not os.path.exists('config'): + # old config dirs did not have a 'config' file. Try to update. # Validate the only files in the directory are directories 0-9, a-f - expected = [ '{:X}'.format(x) for x in range(0, 16) ] + 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") + raise RuntimeError( + "%s does not look like a valid version 1 cache directory" % cache) config = dict() else: with open('config') as conf: config = json.load(conf) -# Find any keys that aren't currently set but should be +if args.get('show', None): + print("Current configuration in '%s':" % cache) + print(json.dumps(config, sort_keys=True, + indent=4, separators=(',', ': '))) + # in case of the show argument, emit some stats as well + file_count = 0 + for _, _, files in os.walk('.'): + file_count += len(files) + if file_count: # skip config file if it exists + file_count -= 1 + print("Cache contains %s files" % file_count) + del args['show'] + +# Find any keys that are not currently set but should be for key in config_entries: if key not in config: if 'implicit' in config_entries[key]: @@ -128,10 +165,10 @@ for key in config_entries: 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. +# Now 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 args[key] != config[key]: if 'converter' in config_entries[key]: config_entries[key]['converter'](config[key], args[key]) config[key] = args[key] -- cgit v0.12 From ede687eacbe877947ea43305a7fe32c551a75088 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Wed, 31 Oct 2018 23:36:20 -0400 Subject: Update python versions SCons runs with as well as URL to documentation --- src/README.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/README.txt b/src/README.txt index d80460a..ce65b8d 100644 --- a/src/README.txt +++ b/src/README.txt @@ -28,8 +28,7 @@ the latest version by checking the SCons download page at: EXECUTION REQUIREMENTS ====================== -Running SCons requires Python version 2.7.*. Currently it does not -run on the Python 3.x release. There should be +Running SCons requires Python version 2.7.* or 3.5.* and above. There should be no other dependencies or requirements to run SCons. (There is, however, an additional requirement to *install* SCons from this particular package; see the next section.) @@ -146,7 +145,7 @@ of small examples for getting started using SCons. Additional documentation for SCons is available at: - http://www.scons.org/doc.html + https://scons.org/documentation.html LICENSING -- cgit v0.12 From 477a8702b95c8bd2a9099c440e3d9e9c6f7cd068 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Wed, 31 Oct 2018 23:37:03 -0400 Subject: Add caching to appveyor config --- .appveyor.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.appveyor.yml b/.appveyor.yml index edc8e55..eb8f827 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,6 +1,12 @@ image: Visual Studio 2017 shallow_clone: true +cache: + - downloads -> appveyor.yml + - '%LOCALAPPDATA%\pip\Cache' + - C:\ProgramData\chocolatey\bin -> appveyor.yml + - C:\ProgramData\chocolatey\lib -> appveyor.yml + install: - "set PATH=%PYTHON%;%PYTHON%\\Scripts;C:\\cygwin64\\bin;C:\\msys64;%PATH%" - python --version -- cgit v0.12 From 03be89c25fd6e6b4e8f9cddd41e8b5fbc3ed7c1f Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 1 Nov 2018 17:53:34 -0400 Subject: add appveyor build id to appveyor.xml --- .appveyor.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.appveyor.yml b/.appveyor.yml index eb8f827..dad0abf 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,3 +1,5 @@ +version: '3.0.1.{build}' + image: Visual Studio 2017 shallow_clone: true -- cgit v0.12