summaryrefslogtreecommitdiffstats
path: root/test/Parallel
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 /test/Parallel
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>
Diffstat (limited to 'test/Parallel')
-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
5 files changed, 19 insertions, 15 deletions
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)
""")
#