summaryrefslogtreecommitdiffstats
path: root/test/VariantDir
diff options
context:
space:
mode:
authorMats Wichmann <mats@linux.com>2019-03-31 13:01:00 (GMT)
committerMats Wichmann <mats@linux.com>2019-04-25 15:37:04 (GMT)
commitf61d3bcd112285644c1a6ce253b267ef690a7e06 (patch)
tree2e489e238c11697f602cb9a7cbeb43afed088734 /test/VariantDir
parentb0c3385604ebc1d7d552472f1cc6d0910aafa32a (diff)
downloadSCons-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/VariantDir')
-rw-r--r--test/VariantDir/Clean.py6
-rw-r--r--test/VariantDir/SConscript-variant_dir.py18
2 files changed, 13 insertions, 11 deletions
diff --git a/test/VariantDir/Clean.py b/test/VariantDir/Clean.py
index 1287034..2e0d4c6 100644
--- a/test/VariantDir/Clean.py
+++ b/test/VariantDir/Clean.py
@@ -43,8 +43,10 @@ VariantDir('build1', '.', duplicate=1)
def build_sample(target, source, env):
targetdir = str(target[0].dir)
target = str(target[0])
- open(target, 'w').write(open(str(source[0]), 'r').read())
- open(targetdir+'/sample.junk', 'w').write('Side effect!\\n')
+ with open(target, 'w') as ofd, open(str(source[0]), 'r') as ifd:
+ ofd.write(ifd.read())
+ with open(targetdir+'/sample.junk', 'w') as f:
+ f.write('Side effect!\\n')
t0 = Command("build0/sample.out", "sample.in", build_sample)
t1 = Command("build1/sample.out", "sample.in", build_sample)
diff --git a/test/VariantDir/SConscript-variant_dir.py b/test/VariantDir/SConscript-variant_dir.py
index 068c312..1e28c47 100644
--- a/test/VariantDir/SConscript-variant_dir.py
+++ b/test/VariantDir/SConscript-variant_dir.py
@@ -59,10 +59,10 @@ var9 = Dir('../build/var9')
def cat(env, source, target):
target = str(target[0])
- f = open(target, "wb")
- for src in source:
- f.write(open(str(src), "rb").read())
- f.close()
+ with open(target, "wb") as ofp:
+ for src in source:
+ with open(str(src), "rb") as ifp:
+ ofp.write(ifp.read())
env = Environment(BUILDERS={'Cat':Builder(action=cat)},
BUILD='build')
@@ -94,7 +94,7 @@ env.SConscript('src/SConscript', variant_dir='../$BUILD/var8', duplicate=0)
# VariantDir('build/var9', '.')
# SConscript('build/var9/src/SConscript')
SConscript('src/SConscript', variant_dir='build/var9', src_dir='.')
-""")
+""")
test.subdir(['test', 'src'], ['test', 'alt'])
@@ -154,12 +154,12 @@ for file in ['aaa.in', 'bbb.in', 'ccc.in']:
test.must_exist(test.workpath('test', 'build', 'var2', file))
test.fail_test(not equal_stats(test.workpath('test', 'build', 'var2', file),
test.workpath('test', 'src', file)))
-
+
# Make sure we didn't duplicate the source files in build/var3.
test.must_not_exist(test.workpath('test', 'build', 'var3', 'aaa.in'))
test.must_not_exist(test.workpath('test', 'build', 'var3', 'bbb.in'))
test.must_not_exist(test.workpath('test', 'build', 'var3', 'ccc.in'))
-
+
#XXX We can't support var4 and var5 yet, because our VariantDir linkage
#XXX is to an entire source directory. We haven't yet generalized our
#XXX infrastructure to be able to take the SConscript file from one source
@@ -186,12 +186,12 @@ for file in ['aaa.in', 'bbb.in', 'ccc.in']:
test.must_exist(test.workpath('build', 'var6', file))
test.fail_test(not equal_stats(test.workpath('build', 'var6', file),
test.workpath('test', 'src', file)))
-
+
# Make sure we didn't duplicate the source files in build/var7.
test.must_not_exist(test.workpath('build', 'var7', 'aaa.in'))
test.must_not_exist(test.workpath('build', 'var7', 'bbb.in'))
test.must_not_exist(test.workpath('build', 'var7', 'ccc.in'))
-
+
# Make sure we didn't duplicate the source files in build/var8.
test.must_not_exist(test.workpath('build', 'var8', 'aaa.in'))
test.must_not_exist(test.workpath('build', 'var8', 'bbb.in'))