diff options
author | William Deegan <bill@baddogconsulting.com> | 2017-05-08 19:43:25 (GMT) |
---|---|---|
committer | William Deegan <bill@baddogconsulting.com> | 2017-05-08 19:43:25 (GMT) |
commit | 1976be7b15db2b89bf7c6361ea28806824c9c399 (patch) | |
tree | 0c8c5591ff3c06456615358417a9688dc6231699 /test | |
parent | 8c13f3194dc2e59c0322021630032441793b6d94 (diff) | |
parent | 6b86f7db0794b07ad5023fa96b041590a89a8d77 (diff) | |
download | SCons-1976be7b15db2b89bf7c6361ea28806824c9c399.zip SCons-1976be7b15db2b89bf7c6361ea28806824c9c399.tar.gz SCons-1976be7b15db2b89bf7c6361ea28806824c9c399.tar.bz2 |
merge
Diffstat (limited to 'test')
35 files changed, 205 insertions, 188 deletions
diff --git a/test/CPPDEFINES/append.py b/test/CPPDEFINES/append.py index 14ea7b3..7973f22 100644 --- a/test/CPPDEFINES/append.py +++ b/test/CPPDEFINES/append.py @@ -54,10 +54,24 @@ print(env_2300_2.subst('$_CPPDEFFLAGS')) # http://scons.tigris.org/issues/show_bug.cgi?id=1152 # http://scons.tigris.org/issues/show_bug.cgi?id=2900 +# Python3 dicts dont preserve order. Hence we supply subclass of OrderedDict +# whose __str__ and __repr__ act like a normal dict. +from collections import OrderedDict +class OrderedPrintingDict(OrderedDict): + def __repr__(self): + return '{' + ', '.join(['%r: %r'%(k, v) for (k, v) in self.items()]) + '}' + + __str__ = __repr__ + + # Because dict-like objects (except dict and UserDict) are not deep copied + # directly when constructing Environment(CPPDEFINES = OrderedPrintingDict(...)) + def __semi_deepcopy__(self): + return self.copy() + cases=[('string', 'FOO'), ('list', ['NAME1', 'NAME2']), ('list-of-2lists', [('NAME1','VAL1'), ['NAME2','VAL2']]), - ('dict', {'NAME1' : 'VAL1', 'NAME2' : 'VAL2', 'NAME3' : None}) + ('dict', OrderedPrintingDict([('NAME2', 'VAL2'), ('NAME3', None), ('NAME1', 'VAL1')])) ] for (t1, c1) in cases: @@ -180,7 +194,7 @@ AppendUnique: ==== Testing CPPDEFINES, appending a string to a dict orig = {'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'}, append = FOO Append: - result={'FOO': None, 'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'} + result={'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1', 'FOO': None} final=-DFOO -DNAME1=VAL1 -DNAME2=VAL2 -DNAME3 AppendUnique: result=[('NAME2', 'VAL2'), ('NAME3',), ('NAME1', 'VAL1'), 'FOO'] diff --git a/test/CPPDEFINES/pkg-config.py b/test/CPPDEFINES/pkg-config.py index 4e81dec..42f38b6 100644 --- a/test/CPPDEFINES/pkg-config.py +++ b/test/CPPDEFINES/pkg-config.py @@ -56,6 +56,20 @@ int main(int argc, char *argv[]) """) test.write('SConstruct', """\ +# Python3 dicts dont preserve order. Hence we supply subclass of OrderedDict +# whose __str__ and __repr__ act like a normal dict. +from collections import OrderedDict +class OrderedPrintingDict(OrderedDict): + def __repr__(self): + return '{' + ', '.join(['%r: %r'%(k, v) for (k, v) in self.items()]) + '}' + + __str__ = __repr__ + + # Because dict-like objects (except dict and UserDict) are not deep copied + # directly when constructing Environment(CPPDEFINES = OrderedPrintingDict(...)) + def __semi_deepcopy__(self): + return self.copy() +""" + """ # http://scons.tigris.org/issues/show_bug.cgi?id=2671 # Passing test cases env_1 = Environment(CPPDEFINES=[('DEBUG','1'), 'TEST']) @@ -67,11 +81,11 @@ env_2.MergeFlags('-DSOMETHING -DVARIABLE=2') print(env_2.subst('$_CPPDEFFLAGS')) # Failing test cases -env_3 = Environment(CPPDEFINES={'DEBUG':1, 'TEST':None}) +env_3 = Environment(CPPDEFINES=OrderedPrintingDict([('DEBUG', 1), ('TEST', None)])) env_3.ParseConfig('PKG_CONFIG_PATH=. %(pkg_config_path)s --cflags bug') print(env_3.subst('$_CPPDEFFLAGS')) -env_4 = Environment(CPPDEFINES={'DEBUG':1, 'TEST':None}) +env_4 = Environment(CPPDEFINES=OrderedPrintingDict([('DEBUG', 1), ('TEST', None)])) env_4.MergeFlags('-DSOMETHING -DVARIABLE=2') print(env_4.subst('$_CPPDEFFLAGS')) diff --git a/test/D/MixedDAndC/sconstest-dmd.py b/test/D/MixedDAndC/sconstest-dmd.py index df66255..d96c5c3 100644 --- a/test/D/MixedDAndC/sconstest-dmd.py +++ b/test/D/MixedDAndC/sconstest-dmd.py @@ -27,6 +27,16 @@ Test compiling and executing a project with a C module. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import sys +if sys.platform == 'darwin': + import TestSCons + test = TestSCons.TestSCons() + + msg = "Skipping Mixed dmd test until a good way to ensure proper gcc is called." + "Calling default(system /usr/bin/gcc) gcc yields a surplus of linking errors\n" + test.skip_test(msg) + + from Common.common import testForTool testForTool('dmd') diff --git a/test/Deprecated/Sig.py b/test/Deprecated/Sig.py deleted file mode 100644 index 1ae118b..0000000 --- a/test/Deprecated/Sig.py +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -""" -Verify that we generate the proper warning, but don't die, when someone -tries to import the SCons.Sig module (which no longer exists) and -use the things we used to define therein. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -SConstruct = test.workpath('SConstruct') - -test.write(SConstruct, """ -import SCons.Sig -x = SCons.Sig.default_calc -x = SCons.Sig.default_module -x = SCons.Sig.MD5.current() -x = SCons.Sig.MD5.collect() -x = SCons.Sig.MD5.signature() -x = SCons.Sig.MD5.to_string() -x = SCons.Sig.MD5.from_string() -x = SCons.Sig.TimeStamp.current() -x = SCons.Sig.TimeStamp.collect() -x = SCons.Sig.TimeStamp.signature() -x = SCons.Sig.TimeStamp.to_string() -x = SCons.Sig.TimeStamp.from_string() -""") - -expect = """ -scons: warning: The SCons.Sig module no longer exists. - Remove the following "import SCons.Sig" line to eliminate this warning: -""" + test.python_file_line(SConstruct, 2) - -test.run(arguments = '.', stderr=expect) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Errors/InternalError.py b/test/Errors/InternalError.py index 8ed6da1..a709597 100644 --- a/test/Errors/InternalError.py +++ b/test/Errors/InternalError.py @@ -47,7 +47,7 @@ test.run(stdout = "scons: Reading SConscript files ...\ninternal error\n", File ".+", line \d+, in .+ File ".+SConstruct", line \d+, in .+ raise InternalError\('error inside'\) -InternalError: error inside +(SCons\.Errors\.|)InternalError: error inside """, status=2) test.pass_test() diff --git a/test/GetBuildFailures/option-k.py b/test/GetBuildFailures/option-k.py index 0ff22e6..12ae07b 100644 --- a/test/GetBuildFailures/option-k.py +++ b/test/GetBuildFailures/option-k.py @@ -64,7 +64,7 @@ Command('f6', 'f6.in', r'@%(_python_)s mypass.py f5 - $TARGET $SOURCE') def print_build_failures(): from SCons.Script import GetBuildFailures - for bf in sorted(GetBuildFailures(), key=lambda a: a.filename): + for bf in sorted(GetBuildFailures(), key=lambda a: a.filename or 'None'): print("%%s failed: %%s" %% (bf.node, bf.errstr)) import atexit diff --git a/test/GetBuildFailures/parallel.py b/test/GetBuildFailures/parallel.py index ee0e831..f9503e0 100644 --- a/test/GetBuildFailures/parallel.py +++ b/test/GetBuildFailures/parallel.py @@ -80,7 +80,7 @@ Command('f6', 'f6.in', r'@%(_python_)s mypass.py f5 - $TARGET $SOURCE') def print_build_failures(): from SCons.Script import GetBuildFailures - for bf in sorted(GetBuildFailures(), key=lambda t: t.filename): + for bf in sorted(GetBuildFailures(), key=lambda t: t.filename or 'None'): print("%%s failed: %%s" %% (bf.node, bf.errstr)) import atexit diff --git a/test/LINK/VersionedLib-VariantDir.py b/test/LINK/VersionedLib-VariantDir.py index 0a631b0..0350c6e 100644 --- a/test/LINK/VersionedLib-VariantDir.py +++ b/test/LINK/VersionedLib-VariantDir.py @@ -35,11 +35,19 @@ import sys import SCons.Platform import SCons.Defaults +test = TestSCons.TestSCons() + +import sys +if sys.platform == 'darwin': + # Skipping until logic is fixed for macosx + test.skip_test("Not working on darwin yet\n") + + env = SCons.Defaults.DefaultEnvironment() platform = SCons.Platform.platform_default() tool_list = SCons.Platform.DefaultToolList(platform, env) -test = TestSCons.TestSCons() + test.subdir(['src']) test.subdir(['src','lib']) diff --git a/test/LINK/VersionedLib-j2.py b/test/LINK/VersionedLib-j2.py index 249b54f..4646a37 100644 --- a/test/LINK/VersionedLib-j2.py +++ b/test/LINK/VersionedLib-j2.py @@ -39,6 +39,11 @@ import SCons.Defaults test = TestSCons.TestSCons() +if sys.platform == 'darwin': + # Skipping until logic is fixed for macosx + test.skip_test("Not working on darwin yet\n") + + test.write('foo.c', """ #if _WIN32 __declspec(dllexport) diff --git a/test/LINK/VersionedLib-subdir.py b/test/LINK/VersionedLib-subdir.py index a2e141b..91f3011 100644 --- a/test/LINK/VersionedLib-subdir.py +++ b/test/LINK/VersionedLib-subdir.py @@ -41,6 +41,11 @@ import SCons.Defaults test = TestSCons.TestSCons() +if sys.platform == 'darwin': + # Skipping until logic is fixed for macosx + test.skip_test("Not working on darwin yet\n") + + test.write('foo.c', """ #if _WIN32 __declspec(dllexport) diff --git a/test/LINK/VersionedLib.py b/test/LINK/VersionedLib.py index 468e3e5..c05c159 100644 --- a/test/LINK/VersionedLib.py +++ b/test/LINK/VersionedLib.py @@ -33,6 +33,12 @@ import TestSCons import SCons.Platform import SCons.Defaults +import sys +if sys.platform == 'darwin': + # Skipping until logic is fixed for macosx + test = TestSCons.TestSCons() + test.skip_test("Not working on darwin yet\n") + env = SCons.Defaults.DefaultEnvironment() platform = SCons.Platform.platform_default() tool_list = SCons.Platform.DefaultToolList(platform, env) diff --git a/test/MSVS/vs-10.0-scc-files.py b/test/MSVS/vs-10.0-scc-files.py index 32dd9ef..0b8bd76 100644 --- a/test/MSVS/vs-10.0-scc-files.py +++ b/test/MSVS/vs-10.0-scc-files.py @@ -69,9 +69,9 @@ env.MSVSProject(target = 'Test.vcxproj', expected_sln_sccinfo = """\ \tGlobalSection(SourceCodeControl) = preSolution \t\tSccNumberOfProjects = 2 -\t\tSccProjectName0 = Perforce\u0020Project +\t\tSccProjectName0 = Perforce\\u0020Project \t\tSccLocalPath0 = . -\t\tSccProvider0 = MSSCCI:Perforce\u0020SCM +\t\tSccProvider0 = MSSCCI:Perforce\\u0020SCM \t\tCanCheckoutShared = true \t\tSccProjectUniqueName1 = Test.vcxproj \t\tSccLocalPath1 = . diff --git a/test/MSVS/vs-11.0-scc-files.py b/test/MSVS/vs-11.0-scc-files.py index 6d12c79..a25b954 100644 --- a/test/MSVS/vs-11.0-scc-files.py +++ b/test/MSVS/vs-11.0-scc-files.py @@ -69,9 +69,9 @@ env.MSVSProject(target = 'Test.vcxproj', expected_sln_sccinfo = """\ \tGlobalSection(SourceCodeControl) = preSolution \t\tSccNumberOfProjects = 2 -\t\tSccProjectName0 = Perforce\u0020Project +\t\tSccProjectName0 = Perforce\\u0020Project \t\tSccLocalPath0 = . -\t\tSccProvider0 = MSSCCI:Perforce\u0020SCM +\t\tSccProvider0 = MSSCCI:Perforce\\u0020SCM \t\tCanCheckoutShared = true \t\tSccProjectUniqueName1 = Test.vcxproj \t\tSccLocalPath1 = . diff --git a/test/MSVS/vs-14.0-scc-files.py b/test/MSVS/vs-14.0-scc-files.py index c934ac9..b6db6d5 100644 --- a/test/MSVS/vs-14.0-scc-files.py +++ b/test/MSVS/vs-14.0-scc-files.py @@ -69,9 +69,9 @@ env.MSVSProject(target = 'Test.vcxproj', expected_sln_sccinfo = """\ \tGlobalSection(SourceCodeControl) = preSolution \t\tSccNumberOfProjects = 2 -\t\tSccProjectName0 = Perforce\u0020Project +\t\tSccProjectName0 = Perforce\\u0020Project \t\tSccLocalPath0 = . -\t\tSccProvider0 = MSSCCI:Perforce\u0020SCM +\t\tSccProvider0 = MSSCCI:Perforce\\u0020SCM \t\tCanCheckoutShared = true \t\tSccProjectUniqueName1 = Test.vcxproj \t\tSccLocalPath1 = . diff --git a/test/MSVS/vs-7.0-scc-files.py b/test/MSVS/vs-7.0-scc-files.py index 76b4380..8586060 100644 --- a/test/MSVS/vs-7.0-scc-files.py +++ b/test/MSVS/vs-7.0-scc-files.py @@ -71,9 +71,9 @@ env.MSVSProject(target = 'Test.vcproj', expected_sln_sccinfo = """\ \tGlobalSection(SourceCodeControl) = preSolution \t\tSccNumberOfProjects = 2 -\t\tSccProjectName0 = Perforce\u0020Project +\t\tSccProjectName0 = Perforce\\u0020Project \t\tSccLocalPath0 = . -\t\tSccProvider0 = MSSCCI:Perforce\u0020SCM +\t\tSccProvider0 = MSSCCI:Perforce\\u0020SCM \t\tCanCheckoutShared = true \t\tSolutionUniqueID = {SLNGUID} \t\tSccProjectUniqueName1 = Test.vcproj diff --git a/test/MSVS/vs-7.1-scc-files.py b/test/MSVS/vs-7.1-scc-files.py index 219bd0a..8404422 100644 --- a/test/MSVS/vs-7.1-scc-files.py +++ b/test/MSVS/vs-7.1-scc-files.py @@ -71,9 +71,9 @@ env.MSVSProject(target = 'Test.vcproj', expected_sln_sccinfo = """\ \tGlobalSection(SourceCodeControl) = preSolution \t\tSccNumberOfProjects = 2 -\t\tSccProjectName0 = Perforce\u0020Project +\t\tSccProjectName0 = Perforce\\u0020Project \t\tSccLocalPath0 = . -\t\tSccProvider0 = MSSCCI:Perforce\u0020SCM +\t\tSccProvider0 = MSSCCI:Perforce\\u0020SCM \t\tCanCheckoutShared = true \t\tSolutionUniqueID = {SLNGUID} \t\tSccProjectUniqueName1 = Test.vcproj diff --git a/test/MSVS/vs-8.0-scc-files.py b/test/MSVS/vs-8.0-scc-files.py index 1baa407..05a8a5f 100644 --- a/test/MSVS/vs-8.0-scc-files.py +++ b/test/MSVS/vs-8.0-scc-files.py @@ -69,9 +69,9 @@ env.MSVSProject(target = 'Test.vcproj', expected_sln_sccinfo = """\ \tGlobalSection(SourceCodeControl) = preSolution \t\tSccNumberOfProjects = 2 -\t\tSccProjectName0 = Perforce\u0020Project +\t\tSccProjectName0 = Perforce\\u0020Project \t\tSccLocalPath0 = . -\t\tSccProvider0 = MSSCCI:Perforce\u0020SCM +\t\tSccProvider0 = MSSCCI:Perforce\\u0020SCM \t\tCanCheckoutShared = true \t\tSccProjectUniqueName1 = Test.vcproj \t\tSccLocalPath1 = . diff --git a/test/MSVS/vs-9.0-scc-files.py b/test/MSVS/vs-9.0-scc-files.py index e3d37c0..c270010 100644 --- a/test/MSVS/vs-9.0-scc-files.py +++ b/test/MSVS/vs-9.0-scc-files.py @@ -69,9 +69,9 @@ env.MSVSProject(target = 'Test.vcproj', expected_sln_sccinfo = """\ \tGlobalSection(SourceCodeControl) = preSolution \t\tSccNumberOfProjects = 2 -\t\tSccProjectName0 = Perforce\u0020Project +\t\tSccProjectName0 = Perforce\\u0020Project \t\tSccLocalPath0 = . -\t\tSccProvider0 = MSSCCI:Perforce\u0020SCM +\t\tSccProvider0 = MSSCCI:Perforce\\u0020SCM \t\tCanCheckoutShared = true \t\tSccProjectUniqueName1 = Test.vcproj \t\tSccLocalPath1 = . diff --git a/test/Progress/TARGET.py b/test/Progress/TARGET.py index d7ff3c9..9af5565 100644 --- a/test/Progress/TARGET.py +++ b/test/Progress/TARGET.py @@ -50,12 +50,12 @@ test.write('S2.in', "S2.in\n") test.write('S3.in', "S3.in\n") test.write('S4.in', "S4.in\n") -expect = """\ +expect = bytearray("""\ S1.in\r \rS1.out\rCopy("S1.out", "S1.in") \rS2.in\r \rS2.out\rCopy("S2.out", "S2.in") \rS3.in\r \rS3.out\rCopy("S3.out", "S3.in") \rS4.in\r \rS4.out\rCopy("S4.out", "S4.in") - \rSConstruct\r \r.\r""" + \rSConstruct\r \r.\r""",'utf-8') if os.linesep != '\n': expect = expect.replace('\n', os.linesep) diff --git a/test/Progress/spinner.py b/test/Progress/spinner.py index 85ca32f..59c0a89 100644 --- a/test/Progress/spinner.py +++ b/test/Progress/spinner.py @@ -33,6 +33,7 @@ import os import TestSCons + test = TestSCons.TestSCons(universal_newlines=None) test.write('SConstruct', r""" @@ -50,12 +51,12 @@ test.write('S2.in', "S2.in\n") test.write('S3.in', "S3.in\n") test.write('S4.in', "S4.in\n") -expect = """\ +expect = bytearray("""\ \\\r|\rCopy("S1.out", "S1.in") /\r-\rCopy("S2.out", "S2.in") \\\r|\rCopy("S3.out", "S3.in") /\r-\rCopy("S4.out", "S4.in") -\\\r|\r""" +\\\r|\r""",'utf-8') if os.linesep != '\n': expect = expect.replace('\n', os.linesep) diff --git a/test/SConsignFile/use-dbm.py b/test/SConsignFile/use-dbm.py index 90983b3..129d5b6 100644 --- a/test/SConsignFile/use-dbm.py +++ b/test/SConsignFile/use-dbm.py @@ -34,10 +34,16 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() + try: import dbm.ndbm + use_db = 'dbm.ndbm' except ImportError: - test.skip_test('No dbm in this version of Python; skipping test.\n') + try: + import dbm + use_db = 'dbm' + except ImportError: + test.skip_test('No dbm.ndbm in this version of Python; skipping test.\n') test.subdir('subdir') @@ -53,8 +59,8 @@ sys.exit(0) # test.write('SConstruct', """ import sys -import dbm -SConsignFile('.sconsign', dbm) +import %(use_db)s +SConsignFile('.sconsign', %(use_db)s) B = Builder(action = '%(_python_)s build.py $TARGETS $SOURCES') env = Environment(BUILDERS = { 'B' : B }) env.B(target = 'f1.out', source = 'f1.in') diff --git a/test/SWIG/recursive-includes-cpp.py b/test/SWIG/recursive-includes-cpp.py index 364bd73..dbcac6d 100644 --- a/test/SWIG/recursive-includes-cpp.py +++ b/test/SWIG/recursive-includes-cpp.py @@ -64,6 +64,7 @@ test.write("mod.i", """\ test.write('SConstruct', """\ import distutils.sysconfig +import sys DefaultEnvironment( tools = [ 'swig' ] ) @@ -77,6 +78,9 @@ env = Environment( SHLIBPREFIX = "" ) +if sys.platform == 'darwin': + env['LIBS']=['python%d.%d'%(sys.version_info[0],sys.version_info[1])] + env.SharedLibrary( 'mod.so', [ diff --git a/test/Subst/TypeError.py b/test/Subst/TypeError.py index 371ceff..628db2f 100644 --- a/test/Subst/TypeError.py +++ b/test/Subst/TypeError.py @@ -58,9 +58,7 @@ expect = expect_build % (r' \[foo\.bar\]', r'\$\{NONE\[0\]\}') test.run(status=2, stderr=expect) - - -expect_build = r"""scons: \*\*\*%s TypeError `(not enough arguments; expected 3, got 1|func\(\) takes exactly 3 arguments \(1 given\))' trying to evaluate `%s' +expect_build = r"""scons: \*\*\*%s TypeError `(not enough arguments; expected 3, got 1|func\(\) takes exactly 3 arguments \(1 given\)|func\(\) missing 2 required positional arguments: 'b' and 'c')' trying to evaluate `%s' """ expect_read = "\n" + expect_build + TestSCons.file_expr diff --git a/test/TEX/auxiliaries.py b/test/TEX/auxiliaries.py index 98cbf41..8d220c5 100644 --- a/test/TEX/auxiliaries.py +++ b/test/TEX/auxiliaries.py @@ -120,7 +120,7 @@ test.write(['docs', 'test.tex'], tex_input) test.run(stderr=None) pdf_output_1 = test.read(['build', 'docs', 'test.pdf']) -ps_output_1 = test.read(['build', 'docs', 'test.ps']) +ps_output_1 = test.read(['build', 'docs', 'test.ps'], mode='r') # Adding blank lines will cause SCons to re-run the builds, but the # actual contents of the output files should be the same modulo @@ -130,7 +130,7 @@ test.write(['docs', 'test.tex'], tex_input + "\n\n\n") test.run(stderr=None) pdf_output_2 = test.read(['build', 'docs', 'test.pdf']) -ps_output_2 = test.read(['build', 'docs', 'test.ps']) +ps_output_2 = test.read(['build', 'docs', 'test.ps'], mode='r') diff --git a/test/diskcheck.py b/test/diskcheck.py index adbeea1..36cfa4e 100644 --- a/test/diskcheck.py +++ b/test/diskcheck.py @@ -52,30 +52,6 @@ test.must_contain_all_lines(test.stderr(), ["found where file expected"]) -test.write('SConstruct', """ -SetOption('diskcheck', ['rcs', 'sccs']) -Dir('file') -""") - -test.run() - -test.run(arguments='--diskcheck=match', status=2, stderr=None) -test.must_contain_all_lines(test.stderr(), ["found where directory expected"]) - - - -test.write('SConstruct', """ -SetOption('diskcheck', 'rcs,sccs') -Dir('file/subdir') -""") - -test.run() - -test.run(arguments='--diskcheck=match', status=2, stderr=None) -test.must_contain_all_lines(test.stderr(), ["found where directory expected"]) - - - test.pass_test() # Local Variables: diff --git a/test/gettext/POTUpdate/UserExamples.py b/test/gettext/POTUpdate/UserExamples.py index 6269081..06203fa 100644 --- a/test/gettext/POTUpdate/UserExamples.py +++ b/test/gettext/POTUpdate/UserExamples.py @@ -62,19 +62,19 @@ test.must_not_exist( ['ex1', 'po', 'bar.pot'] ) test.run(arguments = 'foo.pot', chdir = path.join('ex1', 'po')) test.must_exist( ['ex1', 'po', 'foo.pot'] ) test.must_not_exist( ['ex1', 'po', 'bar.pot'] ) -test.must_contain( ['ex1', 'po', 'foo.pot'], "Hello from a.cpp" ) -test.must_contain( ['ex1', 'po', 'foo.pot'], "Hello from b.cpp" ) -test.must_not_contain( ['ex1', 'po', 'foo.pot'], "Hello from c.cpp" ) -test.must_not_contain( ['ex1', 'po', 'foo.pot'], "Hello from d.cpp" ) +test.must_contain( ['ex1', 'po', 'foo.pot'], "Hello from a.cpp", mode='r') +test.must_contain( ['ex1', 'po', 'foo.pot'], "Hello from b.cpp", mode='r') +test.must_not_contain( ['ex1', 'po', 'foo.pot'], "Hello from c.cpp", mode='r') +test.must_not_contain( ['ex1', 'po', 'foo.pot'], "Hello from d.cpp", mode='r') # scons 'pot-update' creates foo.pot and bar.pot test.run(arguments = 'pot-update', chdir = path.join('ex1', 'po')) test.must_exist( ['ex1', 'po', 'foo.pot'] ) test.must_exist( ['ex1', 'po', 'bar.pot'] ) -test.must_not_contain( ['ex1', 'po', 'bar.pot'], "Hello from a.cpp" ) -test.must_not_contain( ['ex1', 'po', 'bar.pot'], "Hello from b.cpp" ) -test.must_contain( ['ex1', 'po', 'bar.pot'], "Hello from c.cpp" ) -test.must_contain( ['ex1', 'po', 'bar.pot'], "Hello from d.cpp" ) +test.must_not_contain( ['ex1', 'po', 'bar.pot'], "Hello from a.cpp", mode='r') +test.must_not_contain( ['ex1', 'po', 'bar.pot'], "Hello from b.cpp", mode='r') +test.must_contain( ['ex1', 'po', 'bar.pot'], "Hello from c.cpp", mode='r') +test.must_contain( ['ex1', 'po', 'bar.pot'], "Hello from d.cpp", mode='r') # scons -c does not clean anything test.run(arguments = '-c', chdir = path.join('ex1', 'po')) @@ -101,16 +101,16 @@ test.write(['ex2', 'd.cpp'], """ gettext("Hello from d.cpp") """) test.run(arguments = 'pot-update', chdir = path.join('ex2')) test.must_exist( ['ex2', 'foo.pot']) -test.must_contain( ['ex2', 'foo.pot'], "Hello from a.cpp" ) -test.must_contain( ['ex2', 'foo.pot'], "Hello from b.cpp" ) -test.must_not_contain( ['ex2', 'foo.pot'], "Hello from c.cpp" ) -test.must_not_contain( ['ex2', 'foo.pot'], "Hello from d.cpp" ) +test.must_contain( ['ex2', 'foo.pot'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex2', 'foo.pot'], "Hello from b.cpp", mode='r' ) +test.must_not_contain( ['ex2', 'foo.pot'], "Hello from c.cpp", mode='r' ) +test.must_not_contain( ['ex2', 'foo.pot'], "Hello from d.cpp", mode='r' ) test.must_exist( ['ex2', 'bar.pot']) -test.must_not_contain( ['ex2', 'bar.pot'], "Hello from a.cpp" ) -test.must_not_contain( ['ex2', 'bar.pot'], "Hello from b.cpp" ) -test.must_contain( ['ex2', 'bar.pot'], "Hello from c.cpp" ) -test.must_contain( ['ex2', 'bar.pot'], "Hello from d.cpp" ) +test.must_not_contain( ['ex2', 'bar.pot'], "Hello from a.cpp", mode='r' ) +test.must_not_contain( ['ex2', 'bar.pot'], "Hello from b.cpp", mode='r' ) +test.must_contain( ['ex2', 'bar.pot'], "Hello from c.cpp", mode='r' ) +test.must_contain( ['ex2', 'bar.pot'], "Hello from d.cpp", mode='r' ) ############################################################################# @@ -192,9 +192,9 @@ test.write(['ex5', '0', '1', 'a.cpp'], """ gettext("Hello from ../a.cpp") """) test.run(arguments = 'pot-update', chdir = path.join('ex5', '0', '1', 'po')) test.must_exist( ['ex5', '0', '1', 'po', 'messages.pot']) test.must_contain( ['ex5', '0', '1', 'po', 'messages.pot'], - 'Hello from ../a.cpp' ) + 'Hello from ../a.cpp', mode='r' ) test.must_not_contain( ['ex5', '0', '1', 'po', 'messages.pot'], - 'Hello from ../../a.cpp' ) + 'Hello from ../../a.cpp', mode='r' ) test.write(['ex5', '0', '1', 'po', 'SConstruct'], """ @@ -204,9 +204,9 @@ env.POTUpdate(XGETTEXTFROM = 'POTFILES.in', XGETTEXTPATH=['../../', '../']) """) test.run(arguments = 'pot-update', chdir = path.join('ex5', '0', '1', 'po')) test.must_contain( ['ex5', '0', '1', 'po', 'messages.pot'], - 'Hello from ../../a.cpp' ) + 'Hello from ../../a.cpp', mode='r' ) test.must_not_contain( ['ex5', '0', '1', 'po', 'messages.pot'], - 'Hello from ../a.cpp') + 'Hello from ../a.cpp', mode='r') test.pass_test() diff --git a/test/gettext/POUpdate/UserExamples.py b/test/gettext/POUpdate/UserExamples.py index 01d3706..5f3e6c7 100644 --- a/test/gettext/POUpdate/UserExamples.py +++ b/test/gettext/POUpdate/UserExamples.py @@ -182,8 +182,8 @@ test.write(['ex1', 'pl.po'], pl_po_contents) test.run(arguments = 'po-update', chdir = 'ex1', stderr = None) test.must_exist( ['ex1', 'en.po'] ) test.must_exist( ['ex1', 'pl.po'] ) -test.must_contain( ['ex1', 'en.po'], "Hello from a.cpp" ) -test.must_contain( ['ex1', 'pl.po'], "Hello from a.cpp" ) +test.must_contain( ['ex1', 'en.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex1', 'pl.po'], "Hello from a.cpp", mode='r' ) ############################################################################# # POUpdate: Example 2 @@ -205,8 +205,8 @@ test.write(['ex2', 'pl.po'], pl_po_contents) test.run(arguments = 'po-update', chdir = 'ex2', stderr = None) test.must_exist( ['ex2', 'en.po'] ) test.must_exist( ['ex2', 'pl.po'] ) -test.must_contain( ['ex2', 'en.po'], "Hello from a.cpp" ) -test.must_contain( ['ex2', 'pl.po'], "Hello from a.cpp" ) +test.must_contain( ['ex2', 'en.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex2', 'pl.po'], "Hello from a.cpp", mode='r' ) ############################################################################# # POUpdate: Example 3 @@ -228,8 +228,8 @@ test.write(['ex3', 'pl.po'], pl_po_contents) test.run(arguments = 'po-update', chdir = 'ex3', stderr = None) test.must_exist( ['ex3', 'en.po'] ) test.must_exist( ['ex3', 'pl.po'] ) -test.must_contain( ['ex3', 'en.po'], "Hello from a.cpp" ) -test.must_contain( ['ex3', 'pl.po'], "Hello from a.cpp" ) +test.must_contain( ['ex3', 'en.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex3', 'pl.po'], "Hello from a.cpp", mode='r' ) ############################################################################# # POUpdate: Example 4 @@ -258,8 +258,8 @@ test.run(arguments = 'po-update', chdir = 'ex4', stderr = None) test.must_exist( ['ex4', 'messages.pot'] ) test.must_exist( ['ex4', 'en.po'] ) test.must_exist( ['ex4', 'pl.po'] ) -test.must_contain( ['ex4', 'en.po'], "Hello from a.cpp" ) -test.must_contain( ['ex4', 'pl.po'], "Hello from a.cpp" ) +test.must_contain( ['ex4', 'en.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex4', 'pl.po'], "Hello from a.cpp", mode='r' ) ############################################################################# # POUpdate: Example 5 @@ -286,8 +286,8 @@ test.write(['ex5', 'pl.po'], pl_po_contents) test.run(arguments = 'po-update', chdir= 'ex5', stderr = None) test.must_exist( ['ex5', 'en.po'] ) test.must_exist( ['ex5', 'pl.po'] ) -test.must_contain( ['ex5', 'en.po'], "Hello from a.cpp" ) -test.must_contain( ['ex5', 'pl.po'], "Hello from a.cpp" ) +test.must_contain( ['ex5', 'en.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex5', 'pl.po'], "Hello from a.cpp", mode='r' ) ############################################################################# # POUpdate: Example 6 @@ -317,10 +317,10 @@ test.must_exist( ['ex6', 'en.po'] ) test.must_exist( ['ex6', 'pl.po'] ) test.must_exist( ['ex6', 'de.po'] ) test.must_exist( ['ex6', 'fr.po'] ) -test.must_contain( ['ex6', 'en.po'], "Hello from a.cpp" ) -test.must_contain( ['ex6', 'pl.po'], "Hello from a.cpp" ) -test.must_contain( ['ex6', 'de.po'], "Hello from a.cpp" ) -test.must_contain( ['ex6', 'fr.po'], "Hello from a.cpp" ) +test.must_contain( ['ex6', 'en.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex6', 'pl.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex6', 'de.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex6', 'fr.po'], "Hello from a.cpp", mode='r' ) ############################################################################# # POUpdate: Example 7 @@ -351,8 +351,8 @@ test.write(['ex7', 'messages.pot'], pot_contents) test.run(arguments = 'po-update', chdir= 'ex7', stderr = None) test.must_exist( ['ex7', 'en.po'] ) test.must_exist( ['ex7', 'pl.po'] ) -test.must_contain( ['ex7', 'en.po'], "Hello from a.cpp" ) -test.must_contain( ['ex7', 'pl.po'], "Hello from a.cpp" ) +test.must_contain( ['ex7', 'en.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex7', 'pl.po'], "Hello from a.cpp", mode='r' ) ############################################################################# # POUpdate: Example 8 @@ -389,8 +389,8 @@ test.run(arguments = 'po-update', chdir = 'ex8', stderr = None) test.must_exist( ['ex8', 'foo.pot'] ) test.must_exist( ['ex8', 'en.po'] ) test.must_exist( ['ex8', 'pl.po'] ) -test.must_contain( ['ex8', 'en.po'], "Hello from a.cpp" ) -test.must_contain( ['ex8', 'pl.po'], "Hello from a.cpp" ) +test.must_contain( ['ex8', 'en.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex8', 'pl.po'], "Hello from a.cpp", mode='r' ) test.pass_test() diff --git a/test/gettext/Translate/UserExamples.py b/test/gettext/Translate/UserExamples.py index 384b96d..d7220a3 100644 --- a/test/gettext/Translate/UserExamples.py +++ b/test/gettext/Translate/UserExamples.py @@ -65,10 +65,10 @@ test.write(['ex1', 'b.cpp'], """ gettext("Hello from b.cpp") """) test.run(arguments = 'po-update', chdir = path.join('ex1','po'), stderr = None) test.must_exist( ['ex1', 'po', 'en.po'] ) test.must_exist( ['ex1', 'po', 'pl.po'] ) -test.must_contain( ['ex1', 'po', 'en.po'], "Hello from a.cpp" ) -test.must_contain( ['ex1', 'po', 'en.po'], "Hello from b.cpp" ) -test.must_contain( ['ex1', 'po', 'pl.po'], "Hello from a.cpp" ) -test.must_contain( ['ex1', 'po', 'pl.po'], "Hello from b.cpp" ) +test.must_contain( ['ex1', 'po', 'en.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex1', 'po', 'en.po'], "Hello from b.cpp", mode='r' ) +test.must_contain( ['ex1', 'po', 'pl.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex1', 'po', 'pl.po'], "Hello from b.cpp", mode='r' ) ############################################################################# # Translate: Example 2 @@ -100,10 +100,10 @@ test.write(['ex2', 'b.cpp'], """ gettext("Hello from b.cpp") """) test.run(arguments = 'po-update', chdir = path.join('ex2','po'), stderr = None) test.must_exist( ['ex2', 'po', 'en.po'] ) test.must_exist( ['ex2', 'po', 'pl.po'] ) -test.must_contain( ['ex2', 'po', 'en.po'], "Hello from a.cpp" ) -test.must_contain( ['ex2', 'po', 'en.po'], "Hello from b.cpp" ) -test.must_contain( ['ex2', 'po', 'pl.po'], "Hello from a.cpp" ) -test.must_contain( ['ex2', 'po', 'pl.po'], "Hello from b.cpp" ) +test.must_contain( ['ex2', 'po', 'en.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex2', 'po', 'en.po'], "Hello from b.cpp", mode='r' ) +test.must_contain( ['ex2', 'po', 'pl.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex2', 'po', 'pl.po'], "Hello from b.cpp", mode='r' ) ############################################################################# # Translate: Example 3 @@ -157,12 +157,12 @@ test.must_not_exist( ['ex3', 'build', 'po', 'messages.pot'] ) test.must_not_exist( ['ex3', 'build', 'po', 'en.po'] ) test.must_not_exist( ['ex3', 'build', 'po', 'pl.po'] ) # -test.must_contain( ['ex3', 'src', 'po', 'messages.pot'], "Hello from a.cpp" ) -test.must_contain( ['ex3', 'src', 'po', 'messages.pot'], "Hello from b.cpp" ) -test.must_contain( ['ex3', 'src', 'po', 'en.po'], "Hello from a.cpp" ) -test.must_contain( ['ex3', 'src', 'po', 'en.po'], "Hello from b.cpp" ) -test.must_contain( ['ex3', 'src', 'po', 'pl.po'], "Hello from a.cpp" ) -test.must_contain( ['ex3', 'src', 'po', 'pl.po'], "Hello from b.cpp" ) +test.must_contain( ['ex3', 'src', 'po', 'messages.pot'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex3', 'src', 'po', 'messages.pot'], "Hello from b.cpp", mode='r' ) +test.must_contain( ['ex3', 'src', 'po', 'en.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex3', 'src', 'po', 'en.po'], "Hello from b.cpp", mode='r' ) +test.must_contain( ['ex3', 'src', 'po', 'pl.po'], "Hello from a.cpp", mode='r' ) +test.must_contain( ['ex3', 'src', 'po', 'pl.po'], "Hello from b.cpp", mode='r' ) test.run(arguments = '.', chdir = 'ex3', stderr = None) test.must_exist( ['ex3', 'build', 'po', 'en.mo'] ) diff --git a/test/leaky-handles.py b/test/leaky-handles.py index 9502d1b..3787ee2 100644 --- a/test/leaky-handles.py +++ b/test/leaky-handles.py @@ -29,12 +29,13 @@ Verify that file handles aren't leaked to child processes """ import os +import sys import TestSCons test = TestSCons.TestSCons() -if os.name != 'posix': +if os.name != 'posix' or sys.platform == 'darwin': msg = "Skipping fork leak test on non-posix platform '%s'\n" % os.name test.skip_test(msg) diff --git a/test/option--max-drift.py b/test/option--max-drift.py index 08fafd1..4e063c9 100644 --- a/test/option--max-drift.py +++ b/test/option--max-drift.py @@ -109,14 +109,14 @@ atime = os.path.getatime(test.workpath('foo.in')) mtime = os.path.getmtime(test.workpath('foo.in')) test.run() -test.fail_test(test.read('foo.out') != 'foo.in\n') +test.must_match('foo.out', 'foo.in\n', mode='r') test.write('foo.in', 'foo.in delta\n') os.utime(test.workpath('foo.in'), (atime,mtime)) test.run() -test.fail_test(test.read('foo.out') != 'foo.in\n') +test.must_match('foo.out', 'foo.in\n', mode='r') test.pass_test() diff --git a/test/option--tree.py b/test/option--tree.py index a50433c..a9618d8 100644 --- a/test/option--tree.py +++ b/test/option--tree.py @@ -51,6 +51,30 @@ scons: warning: The --debug=tree option is deprecated; please use --tree=all ins """, status = 0, match=TestSCons.match_re_dotall) + +# Test that unicode characters can be printed (escaped) with the --tree option +test.write('SConstruct', +""" +env = Environment() +env.Tool("textfile") +try: + # Python 2 + write = unichr(0xe7).encode('utf-8') +except NameError: + # Python 3 + # str is utf-8 by default + write = chr(0xe7) +env.Textfile("Foo", write) +""") + +test.run(arguments = '-Q --tree=all', + stdout = """Creating 'Foo.txt' ++-. + +-Foo.txt + | +-\\xc3\\xa7 + +-SConstruct +""", + status = 0) test.pass_test() # Local Variables: diff --git a/test/option-j.py b/test/option-j.py index 3dbedc0..278fd30 100644 --- a/test/option-j.py +++ b/test/option-j.py @@ -122,7 +122,7 @@ test.fail_test(start2 < finish1) # succeeds. test.run(arguments='-j 2 out') -if sys.platform != 'win32': +if sys.platform != 'win32' and sys.version_info[0] == 2: # Test breaks on win32 when using real subprocess is not the only # package to import threading # diff --git a/test/packaging/use-builddir.py b/test/packaging/use-builddir.py index 76b9737..9ad7aa4 100644 --- a/test/packaging/use-builddir.py +++ b/test/packaging/use-builddir.py @@ -85,7 +85,7 @@ test.run(stderr = None) test.must_exist( 'libfoo-1.2.3.tar.gz' ) -os.popen( 'tar -C temp -xzf %s'%test.workpath('libfoo-1.2.3.tar.gz') ) +os.system('tar -C temp -xzf %s'%test.workpath('libfoo-1.2.3.tar.gz') ) test.must_exist( 'temp/libfoo-1.2.3/src/main.c' ) test.must_exist( 'temp/libfoo-1.2.3/SConstruct' ) diff --git a/test/redirection.py b/test/redirection.py index ffc76b5..ba35ed0 100644 --- a/test/redirection.py +++ b/test/redirection.py @@ -32,11 +32,22 @@ test = TestSCons.TestSCons() test.write('cat.py', r""" import sys +PY3K = sys.version_info >= (3, 0) + try: - input = open(sys.argv[1], 'r').read() + input = open(sys.argv[1], 'rb').read() except IndexError: - input = sys.stdin.read() -sys.stdout.write(input) + if PY3K: + source = sys.stdin.buffer + else: + source = sys.stdin + input = source.read() + +if PY3K: + sys.stdout.buffer.write(input) +else: + sys.stdout.write(input) + sys.exit(0) """) diff --git a/test/scons-time/run/option/verbose.py b/test/scons-time/run/option/verbose.py index 5fc6d64..0ef2a6c 100644 --- a/test/scons-time/run/option/verbose.py +++ b/test/scons-time/run/option/verbose.py @@ -30,7 +30,7 @@ Verify that the run -v and --verbose options display command output. import sys import re - +import os import TestSCons_time _python_ = re.escape('"' + sys.executable + '"') @@ -112,7 +112,9 @@ scons-time%(time_re)s: %(_python_)s %(scons_py)s %(scons_flags)s --profile=%(pro SCONS_LIB_DIR = %(src_engine)s SConstruct file directory: %(tmp_scons_time_foo)s scons-time%(time_re)s: cd .* -scons-time%(time_re)s: rm -rf %(tmp_scons_time)s +""" +if 'PRESERVE' not in os.environ or not os.environ['PRESERVE']: + expect += """scons-time%(time_re)s: rm -rf %(tmp_scons_time)s """ foo_tar_gz = re.escape(foo_tar_gz) |