summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMats Wichmann <mats@linux.com>2019-04-01 23:40:42 (GMT)
committerMats Wichmann <mats@linux.com>2019-04-01 23:40:42 (GMT)
commit11355c20e8779a644f6eb51a9cbf80557c3e905c (patch)
treedc1002c9363c98fb174c5853df2962f033f62a18
parentc7fedae70b112c03f8898e4b3091770a07b46f2c (diff)
downloadSCons-11355c20e8779a644f6eb51a9cbf80557c3e905c.zip
SCons-11355c20e8779a644f6eb51a9cbf80557c3e905c.tar.gz
SCons-11355c20e8779a644f6eb51a9cbf80557c3e905c.tar.bz2
[PR #3339] Updates for that failed
Since the build with everything-CI-j2 triggered a couple of test fails, include the patches for open-file warnings in those test areas in the hopes it will help. Signed-off-by: Mats Wichmann <mats@linux.com>
-rw-r--r--test/Interactive/configure.py7
-rw-r--r--test/Interactive/option-j.py16
-rw-r--r--test/Parallel/duplicate-children.py8
-rw-r--r--test/Parallel/duplicate-target.py9
-rw-r--r--test/Parallel/failed-build.py3
-rw-r--r--test/Parallel/multiple-parents.py4
-rw-r--r--test/Parallel/ref_count.py10
7 files changed, 30 insertions, 27 deletions
diff --git a/test/Interactive/configure.py b/test/Interactive/configure.py
index 906a7e9..a7f0735 100644
--- a/test/Interactive/configure.py
+++ b/test/Interactive/configure.py
@@ -38,10 +38,9 @@ test = TestSCons.TestSCons()
test.write('mycc.py', r"""
import sys
-outfile = open(sys.argv[1], 'wb')
-infile = open(sys.argv[2], 'rb')
-for l in [l for l in infile.readlines() if l[:7] != '/*c++*/']:
- outfile.write(l)
+with open(sys.argv[1], 'wb') as ofp, open(sys.argv[2], 'rb') as ifp:
+ for l in [l for l in ifp.readlines() if l[:7] != '/*c++*/']:
+ ofp.write(l)
sys.exit(0)
""")
diff --git a/test/Interactive/option-j.py b/test/Interactive/option-j.py
index 279fc51..356a067 100644
--- a/test/Interactive/option-j.py
+++ b/test/Interactive/option-j.py
@@ -39,10 +39,10 @@ from SCons.Script import *
def cat(target, source, env):
t = str(target[0])
os.mkdir(t + '.started')
- fp = open(t, 'wb')
- for s in source:
- fp.write(open(str(s), 'rb').read())
- fp.close()
+ with open(t, 'wb') as ofp:
+ for s in source:
+ with open(str(s), 'rb') as ifp:
+ ofp.write(ifp.read())
os.mkdir(t + '.finished')
def must_be_finished(target, source, env, dir):
@@ -63,10 +63,10 @@ def must_wait_for_f2_b_out(target, source, env):
f2_b_started = 'f2-b.out.started'
while not os.path.exists(f2_b_started):
time.sleep(1)
- fp = open(t, 'wb')
- for s in source:
- fp.write(open(str(s), 'rb').read())
- fp.close()
+ with open(t, 'wb') as ofp:
+ for s in source:
+ with open(str(s), 'rb') as ifp:
+ ofp.write(ifp.read())
os.mkdir(t + '.finished')
def _f2_a_out_must_not_be_finished(target, source, env):
diff --git a/test/Parallel/duplicate-children.py b/test/Parallel/duplicate-children.py
index 8b8f4cd..fab1e58 100644
--- a/test/Parallel/duplicate-children.py
+++ b/test/Parallel/duplicate-children.py
@@ -37,10 +37,10 @@ test = TestSCons.TestSCons()
test.write('cat.py', """\
import sys
-fp = open(sys.argv[1], 'wb')
-for fname in sys.argv[2:]:
- fp.write(open(fname, 'rb').read())
-fp.close()
+with open(sys.argv[1], 'wb') as ofp:
+ for fname in sys.argv[2:]:
+ with open(fname, 'rb') as ifp:
+ ofp.write(ifp.read())
""")
test.write('sleep.py', """\
diff --git a/test/Parallel/duplicate-target.py b/test/Parallel/duplicate-target.py
index efe20d9..e947edc 100644
--- a/test/Parallel/duplicate-target.py
+++ b/test/Parallel/duplicate-target.py
@@ -49,14 +49,15 @@ test.write(['work', 'mycopy.py'], """\
import sys
import time
time.sleep(int(sys.argv[1]))
-open(sys.argv[2], 'wb').write(open(sys.argv[3], 'rb').read())
+with open(sys.argv[2], 'wb') as ofp, open(sys.argv[3], 'rb') as ifp:
+ ofp.write(ifp.read())
""")
test.write(['work', 'mytar.py'], """\
import sys
import os.path
-fp = open(sys.argv[1], 'wb')
+ofp = open(sys.argv[1], 'wb')
def visit(dirname):
names = os.listdir(dirname)
@@ -66,10 +67,12 @@ def visit(dirname):
if os.path.isdir(p):
visit(p)
elif os.path.isfile(p):
- fp.write(open(p, 'rb').read())
+ with open(p, 'rb') as ifp:
+ ofp.write(ifp.read())
for s in sys.argv[2:]:
visit(s)
+ofp.close()
""")
test.write(['work', 'SConstruct'], """\
diff --git a/test/Parallel/failed-build.py b/test/Parallel/failed-build.py
index 2360679..bfdc01d 100644
--- a/test/Parallel/failed-build.py
+++ b/test/Parallel/failed-build.py
@@ -78,7 +78,8 @@ import os
import sys
import time
os.mkdir('mycopy.started')
-open(sys.argv[1], 'wb').write(open(sys.argv[2], 'rb').read())
+with open(sys.argv[1], 'wb') as ofp, open(sys.argv[2], 'rb') as ifp:
+ ofp.write(ifp.read())
for i in [1, 2, 3, 4, 5]:
time.sleep(2)
if os.path.exists('myfail.exiting'):
diff --git a/test/Parallel/multiple-parents.py b/test/Parallel/multiple-parents.py
index 7fbcb00..5a52f28 100644
--- a/test/Parallel/multiple-parents.py
+++ b/test/Parallel/multiple-parents.py
@@ -147,8 +147,8 @@ Default(all)
re_error = """\
(scons: \\*\\*\\* \\[failed\\d+] Error 2\\n)|\
(scons: \\*\\*\\* \\[missing\\d+] Source `MissingSrc' not found, needed by target `missing\\d+'\\.( Stop\\.)?\\n)|\
-(scons: \\*\\*\\* \\[\\w+] Build interrupted\.\\n)|\
-(scons: Build interrupted\.\\n)\
+(scons: \\*\\*\\* \\[\\w+] Build interrupted\\.\\n)|\
+(scons: Build interrupted\\.\\n)\
"""
re_errors = "(" + re_error + ")+"
diff --git a/test/Parallel/ref_count.py b/test/Parallel/ref_count.py
index 7ce5910..8a31bf3 100644
--- a/test/Parallel/ref_count.py
+++ b/test/Parallel/ref_count.py
@@ -74,12 +74,12 @@ while args:
time.sleep(int(args.pop(0)))
contents = ''
for ifile in args:
- contents = contents + open(ifile, 'r').read()
+ with open(ifile, 'r') as ifp:
+ contents = contents + ifp.read()
for ofile in outputs:
- ofp = open(ofile, 'w')
- ofp.write('%s: building from %s\\n' % (ofile, " ".join(args)))
- ofp.write(contents)
- ofp.close()
+ with open(ofile, 'w') as ofp:
+ ofp.write('%s: building from %s\\n' % (ofile, " ".join(args)))
+ ofp.write(contents)
""")
#