diff options
author | Mats Wichmann <mats@linux.com> | 2019-03-31 13:01:00 (GMT) |
---|---|---|
committer | Mats Wichmann <mats@linux.com> | 2019-04-25 15:37:04 (GMT) |
commit | f61d3bcd112285644c1a6ce253b267ef690a7e06 (patch) | |
tree | 2e489e238c11697f602cb9a7cbeb43afed088734 /testing | |
parent | b0c3385604ebc1d7d552472f1cc6d0910aafa32a (diff) | |
download | SCons-f61d3bcd112285644c1a6ce253b267ef690a7e06.zip SCons-f61d3bcd112285644c1a6ce253b267ef690a7e06.tar.gz SCons-f61d3bcd112285644c1a6ce253b267ef690a7e06.tar.bz2 |
[PY 3.8] test fixes for file closings, rawstrings
On a linux host (missing some things that may be on the Travis CI
setup), Py3.8a3 now shows 19 fails, 1048 pass, with 84 Warning: messages.
Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'testing')
-rw-r--r-- | testing/framework/SConscript | 13 | ||||
-rw-r--r-- | testing/framework/TestSCons.py | 52 | ||||
-rw-r--r-- | testing/framework/TestSConsMSVS.py | 8 |
3 files changed, 37 insertions, 36 deletions
diff --git a/testing/framework/SConscript b/testing/framework/SConscript index 0d3832e..bb81d8e 100644 --- a/testing/framework/SConscript +++ b/testing/framework/SConscript @@ -41,12 +41,13 @@ files = [ def copy(target, source, env): t = str(target[0]) s = str(source[0]) - c = open(s, 'r').read() - # Note: We construct the __ VERSION __ substitution string at - # run-time so it doesn't get replaced when this file gets copied - # into the tree for packaging. - c = c.replace('__' + 'VERSION' + '__', env['VERSION']) - open(t, 'w').write(c) + with open(s, 'r') as i, open(t, 'w') as o: + c = i.read() + # Note: We construct the __ VERSION __ substitution string at + # run-time so it doesn't get replaced when this file gets copied + # into the tree for packaging. + c = c.replace('__' + 'VERSION' + '__', env['VERSION']) + o.write(c) for file in files: # Guarantee that real copies of these files always exist in diff --git a/testing/framework/TestSCons.py b/testing/framework/TestSCons.py index 23e8753..23b3416 100644 --- a/testing/framework/TestSCons.py +++ b/testing/framework/TestSCons.py @@ -957,23 +957,23 @@ import sys import re # -w and -z are fake options used in test/QT/QTFLAGS.py cmd_opts, args = getopt.getopt(sys.argv[1:], 'io:wz', []) -output = None impl = 0 opt_string = '' for opt, arg in cmd_opts: - if opt == '-o': output = open(arg, 'w') + if opt == '-o': out = arg elif opt == '-i': impl = 1 else: opt_string = opt_string + ' ' + opt -output.write("/* mymoc.py%s */\\n" % opt_string) -for a in args: - with open(a, 'r') as f: - contents = f.read() - a = a.replace('\\\\', '\\\\\\\\') - subst = r'{ my_qt_symbol( "' + a + '\\\\n" ); }' - if impl: - contents = re.sub( r'#include.*', '', contents ) - output.write(contents.replace('Q_OBJECT', subst)) -output.close() + +with open(out, 'w') as ofp: + ofp.write("/* mymoc.py%s */\\n" % opt_string) + for a in args: + with open(a, 'r') as ifp: + contents = ifp.read() + a = a.replace('\\\\', '\\\\\\\\') + subst = r'{ my_qt_symbol( "' + a + '\\\\n" ); }' + if impl: + contents = re.sub( r'#include.*', '', contents ) + ofp.write(contents.replace('Q_OBJECT', subst)) sys.exit(0) """) @@ -988,7 +988,7 @@ source = None opt_string = '' for arg in sys.argv[1:]: if output_arg: - output = open(arg, 'w') + out = arg output_arg = 0 elif impl_arg: impl = arg @@ -1002,19 +1002,19 @@ for arg in sys.argv[1:]: else: if source: sys.exit(1) - source = open(arg, 'r') - sourceFile = arg -output.write("/* myuic.py%s */\\n" % opt_string) -if impl: - output.write( '#include "' + impl + '"\\n' ) - includes = re.findall('<include.*?>(.*?)</include>', source.read()) - for incFile in includes: - # this is valid for ui.h files, at least - if os.path.exists(incFile): - output.write('#include "' + incFile + '"\\n') -else: - output.write( '#include "my_qobject.h"\\n' + source.read() + " Q_OBJECT \\n" ) -output.close() + source = sourceFile = arg + +with open(out, 'w') as ofp, open(source, 'r') as ifp: + ofp.write("/* myuic.py%s */\\n" % opt_string) + if impl: + ofp.write( '#include "' + impl + '"\\n' ) + includes = re.findall('<include.*?>(.*?)</include>', ifp.read()) + for incFile in includes: + # this is valid for ui.h files, at least + if os.path.exists(incFile): + ofp.write('#include "' + incFile + '"\\n') + else: + ofp.write( '#include "my_qobject.h"\\n' + ifp.read() + " Q_OBJECT \\n" ) sys.exit(0) """ ) diff --git a/testing/framework/TestSConsMSVS.py b/testing/framework/TestSConsMSVS.py index 4c99bd4..e7200b6 100644 --- a/testing/framework/TestSConsMSVS.py +++ b/testing/framework/TestSConsMSVS.py @@ -1045,7 +1045,7 @@ env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='10.0', HOST_ARCH='%(HOST_ARCH)s') testsrc = ['test1.cpp', 'test2.cpp'] -testincs = ['sdk_dir\\sdk.h'] +testincs = [r'sdk_dir\\sdk.h'] testlocalincs = ['test.h'] testresources = ['test.rc'] testmisc = ['readme.txt'] @@ -1068,7 +1068,7 @@ env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='11.0', HOST_ARCH='%(HOST_ARCH)s') testsrc = ['test1.cpp', 'test2.cpp'] -testincs = ['sdk_dir\\sdk.h'] +testincs = [r'sdk_dir\\sdk.h'] testlocalincs = ['test.h'] testresources = ['test.rc'] testmisc = ['readme.txt'] @@ -1091,7 +1091,7 @@ env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='14.0', HOST_ARCH='%(HOST_ARCH)s') testsrc = ['test1.cpp', 'test2.cpp'] -testincs = ['sdk_dir\\sdk.h'] +testincs = [r'sdk_dir\\sdk.h'] testlocalincs = ['test.h'] testresources = ['test.rc'] testmisc = ['readme.txt'] @@ -1114,7 +1114,7 @@ env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='14.1', HOST_ARCH='%(HOST_ARCH)s') testsrc = ['test1.cpp', 'test2.cpp'] -testincs = ['sdk_dir\\sdk.h'] +testincs = [r'sdk_dir\\sdk.h'] testlocalincs = ['test.h'] testresources = ['test.rc'] testmisc = ['readme.txt'] |