diff options
author | William Deegan <bill@baddogconsulting.com> | 2019-04-28 19:43:43 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-28 19:43:43 (GMT) |
commit | 35e6bbe16a859b42efca4592b435695a530f0717 (patch) | |
tree | 5a298b113bb1899e91583866b41eb9c337c0857e /testing | |
parent | 44c7b81e1a47ff5d4439740b1e929ea723ee1f18 (diff) | |
parent | 4ecdcf07580b1bfcd03f7886b6ab9256ee825175 (diff) | |
download | SCons-35e6bbe16a859b42efca4592b435695a530f0717.zip SCons-35e6bbe16a859b42efca4592b435695a530f0717.tar.gz SCons-35e6bbe16a859b42efca4592b435695a530f0717.tar.bz2 |
Merge pull request #3345 from mwichmann/py38warns4-tests
[wip] Py38warns4 tests
Diffstat (limited to 'testing')
-rw-r--r-- | testing/framework/SConscript | 13 | ||||
-rw-r--r-- | testing/framework/TestSCons.py | 62 | ||||
-rw-r--r-- | testing/framework/TestSConsMSVS.py | 8 |
3 files changed, 42 insertions, 41 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..907eac7 100644 --- a/testing/framework/TestSCons.py +++ b/testing/framework/TestSCons.py @@ -949,7 +949,7 @@ class TestSCons(TestCommon): def Qt_dummy_installation(self, dir='qt'): # create a dummy qt installation - self.subdir( dir, [dir, 'bin'], [dir, 'include'], [dir, 'lib'] ) + self.subdir(dir, [dir, 'bin'], [dir, 'include'], [dir, 'lib']) self.write([dir, 'bin', 'mymoc.py'], """\ import getopt @@ -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': outfile = 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(outfile, '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') + outfile = 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(outfile, '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) """ ) @@ -1027,7 +1027,7 @@ void my_qt_symbol(const char *arg); #include "../include/my_qobject.h" #include <stdio.h> void my_qt_symbol(const char *arg) { - fputs( arg, stdout ); + fputs(arg, stdout); } """) @@ -1035,9 +1035,9 @@ void my_qt_symbol(const char *arg) { env = Environment() import sys if sys.platform == 'win32': - env.StaticLibrary( 'myqt', 'my_qobject.cpp' ) + env.StaticLibrary('myqt', 'my_qobject.cpp') else: - env.SharedLibrary( 'myqt', 'my_qobject.cpp' ) + env.SharedLibrary('myqt', 'my_qobject.cpp') """) self.run(chdir = self.workpath(dir, 'lib'), @@ -1080,7 +1080,7 @@ if ARGUMENTS.get('variant_dir', 0): else: sconscript = File('SConscript') Export("env dup") -SConscript( sconscript ) +SConscript(sconscript) """ % (self.QT, self.QT_LIB, self.QT_MOC, self.QT_UIC)) diff --git a/testing/framework/TestSConsMSVS.py b/testing/framework/TestSConsMSVS.py index 4c853dc..348d7ed 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'] |