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 /test/sconsign | |
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 'test/sconsign')
-rw-r--r-- | test/sconsign/corrupt.py | 11 | ||||
-rw-r--r-- | test/sconsign/ghost-entries.py | 8 | ||||
-rw-r--r-- | test/sconsign/script/SConsignFile.py | 24 | ||||
-rw-r--r-- | test/sconsign/script/Signatures.py | 22 | ||||
-rw-r--r-- | test/sconsign/script/bad.py | 8 | ||||
-rw-r--r-- | test/sconsign/script/dblite.py | 4 | ||||
-rw-r--r-- | test/sconsign/script/no-SConsignFile.py | 24 |
7 files changed, 48 insertions, 53 deletions
diff --git a/test/sconsign/corrupt.py b/test/sconsign/corrupt.py index cab4d75..25b48e2 100644 --- a/test/sconsign/corrupt.py +++ b/test/sconsign/corrupt.py @@ -41,7 +41,8 @@ work2_sub__sconsign = test.workpath('work2', 'sub', '.sconsign') SConstruct_contents = """\ def build1(target, source, env): - open(str(target[0]), 'wb').write(open(str(source[0]), 'rb').read()) + with open(str(target[0]), 'wb') as ofp, open(str(source[0]), 'rb') as ifp: + ofp.write(ifp.read()) return None B1 = Builder(action = build1) @@ -55,12 +56,12 @@ test.write(['work1', 'SConstruct'], SConstruct_contents) test.write(['work1', 'foo.in'], "work1/foo.in\n") -stderr = ''' +stderr = r''' scons: warning: Ignoring corrupt .sconsign file: \.sconsign\.dblite .* ''' -stdout = test.wrap_stdout('build1\(\["sub.foo\.out"\], \["foo\.in"\]\)\n') +stdout = test.wrap_stdout(r'build1\(\["sub.foo\.out"\], \["foo\.in"\]\)' + '\n') test.write(work1__sconsign_dblite, 'not:a:sconsign:file') test.run(chdir='work1', arguments='.', stderr=stderr, stdout=stdout) @@ -80,12 +81,12 @@ test.write(['work2', 'SConstruct'], SConstruct_contents) test.write(['work2', 'foo.in'], "work2/foo.in\n") -stderr = ''' +stderr = r''' scons: warning: Ignoring corrupt .sconsign file: sub.\.sconsign .* ''' -stdout = test.wrap_stdout('build1\(\["sub.foo\.out"\], \["foo\.in"\]\)\n') +stdout = test.wrap_stdout(r'build1\(\["sub.foo\.out"\], \["foo\.in"\]\)' + '\n') test.write(work2_sub__sconsign, 'not:a:sconsign:file') test.run(chdir='work2', arguments='.', stderr=stderr, stdout=stdout) diff --git a/test/sconsign/ghost-entries.py b/test/sconsign/ghost-entries.py index 46916ca..59a1ec2 100644 --- a/test/sconsign/ghost-entries.py +++ b/test/sconsign/ghost-entries.py @@ -51,10 +51,10 @@ test = TestSCons.TestSCons() test.write('SConstruct', """\ def cat(target, source, env): - fp = open(str(target[0]), 'wb') - for s in source: - fp.write(open(str(s), 'rb').read()) - fp.close() + with open(str(target[0]), 'wb') as fp: + for s in source: + with open(str(s), 'rb') as infp: + fp.write(infp.read()) env=Environment() Export('env') env['BUILDERS']['Cat']=Builder(action=cat, multi=1) diff --git a/test/sconsign/script/SConsignFile.py b/test/sconsign/script/SConsignFile.py index 5e56624..8055b68 100644 --- a/test/sconsign/script/SConsignFile.py +++ b/test/sconsign/script/SConsignFile.py @@ -48,10 +48,6 @@ import re import sys path = sys.argv[1].split() -output = open(sys.argv[2], 'w') -input = open(sys.argv[3], 'r') - -output.write('fake_cc.py: %%s\n' %% sys.argv) def find_file(f): for dir in path: @@ -62,14 +58,19 @@ def find_file(f): def process(infp, outfp): for line in infp.readlines(): - m = re.match('#include <(.*)>', line) + m = re.match(r'#include <(.*)>', line) if m: file = m.group(1) - process(find_file(file), outfp) + found = find_file(file) + process(found, outfp) + if found: + found.close() else: outfp.write(line) -process(input, output) +with open(sys.argv[2], 'w') as outf, open(sys.argv[3], 'r') as ifp: + outf.write('fake_cc.py: %%s\n' %% sys.argv) + process(ifp, outf) sys.exit(0) """ % locals()) @@ -77,12 +78,9 @@ sys.exit(0) test.write(fake_link_py, r"""#!%(_python_)s import sys -output = open(sys.argv[1], 'w') -input = open(sys.argv[2], 'r') - -output.write('fake_link.py: %%s\n' %% sys.argv) - -output.write(input.read()) +with open(sys.argv[1], 'w') as outf, open(sys.argv[2], 'r') as ifp: + outf.write('fake_link.py: %%s\n' %% sys.argv) + outf.write(ifp.read()) sys.exit(0) """ % locals()) diff --git a/test/sconsign/script/Signatures.py b/test/sconsign/script/Signatures.py index 7797bce..24ffaf7 100644 --- a/test/sconsign/script/Signatures.py +++ b/test/sconsign/script/Signatures.py @@ -68,10 +68,6 @@ import re import sys path = sys.argv[1].split() -output = open(sys.argv[2], 'w') -input = open(sys.argv[3], 'r') - -output.write('fake_cc.py: %%s\n' %% sys.argv) def find_file(f): for dir in path: @@ -85,11 +81,16 @@ def process(infp, outfp): m = re.match('#include <(.*)>', line) if m: file = m.group(1) - process(find_file(file), outfp) + found = find_file(file) + process(found, outfp) + if found: + found.close() else: outfp.write(line) -process(input, output) +with open(sys.argv[2], 'w') as outf, open(sys.argv[3], 'r') as ifp: + outf.write('fake_cc.py: %%s\n' %% sys.argv) + process(ifp, outf) sys.exit(0) """ % locals()) @@ -97,12 +98,9 @@ sys.exit(0) test.write(fake_link_py, r"""#!%(_python_)s import sys -output = open(sys.argv[1], 'w') -input = open(sys.argv[2], 'r') - -output.write('fake_link.py: %%s\n' %% sys.argv) - -output.write(input.read()) +with open(sys.argv[1], 'w') as outf, open(sys.argv[2], 'r') as ifp: + outf.write('fake_link.py: %%s\n' %% sys.argv) + outf.write(ifp.read()) sys.exit(0) """ % locals()) diff --git a/test/sconsign/script/bad.py b/test/sconsign/script/bad.py index a384748..5be42b9 100644 --- a/test/sconsign/script/bad.py +++ b/test/sconsign/script/bad.py @@ -38,13 +38,13 @@ test.write('bad2.dblite', "bad2.dblite\n") test.write('bad3', "bad3\n") test.run_sconsign(arguments = "-f dblite no_sconsign", - stderr = "sconsign: \[Errno 2\] No such file or directory: 'no_sconsign'\n") + stderr = "sconsign: \\[Errno 2\\] No such file or directory: 'no_sconsign'\n") test.run_sconsign(arguments = "-f dblite bad1", - stderr = "sconsign: \[Errno 2\] No such file or directory: 'bad1.dblite'\n") + stderr = "sconsign: \\[Errno 2\\] No such file or directory: 'bad1.dblite'\n") test.run_sconsign(arguments = "-f dblite bad1.dblite", - stderr = "sconsign: \[Errno 2\] No such file or directory: 'bad1.dblite'\n") + stderr = "sconsign: \\[Errno 2\\] No such file or directory: 'bad1.dblite'\n") test.run_sconsign(arguments = "-f dblite bad2", stderr = "sconsign: ignoring invalid `dblite' file `bad2'.*\n") @@ -53,7 +53,7 @@ test.run_sconsign(arguments = "-f dblite bad2.dblite", stderr = "sconsign: ignoring invalid `dblite' file `bad2.dblite'.*\n") test.run_sconsign(arguments = "-f sconsign no_sconsign", - stderr = "sconsign: \[Errno 2\] No such file or directory: 'no_sconsign'\n") + stderr = "sconsign: \\[Errno 2\\] No such file or directory: 'no_sconsign'\n") test.run_sconsign(arguments = "-f sconsign bad3", stderr = "sconsign: ignoring invalid .sconsign file `bad3'.*\n") diff --git a/test/sconsign/script/dblite.py b/test/sconsign/script/dblite.py index 0daf8bf..41cf7e2 100644 --- a/test/sconsign/script/dblite.py +++ b/test/sconsign/script/dblite.py @@ -43,7 +43,7 @@ LINK = test.detect('LINK', norm=1) if LINK is None: LINK = CC def escape_drive_case(s): - """Turn c\: into [cC]\:""" + r"""Turn c\: into [cC]\:""" if re.match(r'^(.)[\\]?:', s): drive=s[0] return '['+drive.lower()+drive.upper()+']'+s[1:] @@ -133,7 +133,7 @@ hello%(_obj)s: %(sig_re)s \d+ \d+ %(sig_re)s \[.*\] """ % locals() -expect_r = """=== sub1: +expect_r = r"""=== sub1: hello%(_exe)s: %(sig_re)s '%(date_re)s' \d+ %(sub1_hello_obj)s: %(sig_re)s '%(date_re)s' \d+ %(LINK)s: None '%(date_re)s' \d+ diff --git a/test/sconsign/script/no-SConsignFile.py b/test/sconsign/script/no-SConsignFile.py index d9ab51f..cf5bcb2 100644 --- a/test/sconsign/script/no-SConsignFile.py +++ b/test/sconsign/script/no-SConsignFile.py @@ -57,10 +57,6 @@ import re import sys path = sys.argv[1].split() -output = open(sys.argv[2], 'w') -input = open(sys.argv[3], 'r') - -output.write('fake_cc.py: %%s\n' %% sys.argv) def find_file(f): for dir in path: @@ -71,14 +67,19 @@ def find_file(f): def process(infp, outfp): for line in infp.readlines(): - m = re.match('#include <(.*)>', line) + m = re.match(r'#include <(.*)>', line) if m: file = m.group(1) - process(find_file(file), outfp) + found = find_file(file) + process(found, outfp) + if found: + found.close() else: outfp.write(line) -process(input, output) +with open(sys.argv[2], 'w') as outf, open(sys.argv[3], 'r') as ifp: + outf.write('fake_cc.py: %%s\n' %% sys.argv) + process(ifp, outf) sys.exit(0) """ % locals()) @@ -86,12 +87,9 @@ sys.exit(0) test.write(fake_link_py, r"""#!%(_python_)s import sys -output = open(sys.argv[1], 'w') -input = open(sys.argv[2], 'r') - -output.write('fake_link.py: %%s\n' %% sys.argv) - -output.write(input.read()) +with open(sys.argv[1], 'w') as outf, open(sys.argv[2], 'r') as ifp: + outf.write('fake_link.py: %%s\n' %% sys.argv) + outf.write(ifp.read()) sys.exit(0) """ % locals()) |