aboutsummaryrefslogtreecommitdiff
path: root/run_tests.py
diff options
context:
space:
mode:
authorElliott Sales de Andrade <quantum.analyst@gmail.com>2016-08-30 02:31:44 -0400
committerElliott Sales de Andrade <quantum.analyst@gmail.com>2016-08-30 04:17:46 -0400
commitaec1e88c21224691edbe9c2fbba712c267eb917d (patch)
treed6289c8368b90c1c1dd1a717c089c65991e7bf91 /run_tests.py
parent181d9a891d6791125946abe3ff630fba3a34ebbe (diff)
downloadmeson-aec1e88c21224691edbe9c2fbba712c267eb917d.zip
meson-aec1e88c21224691edbe9c2fbba712c267eb917d.tar.gz
meson-aec1e88c21224691edbe9c2fbba712c267eb917d.tar.bz2
Use context manager in test cases.
Diffstat (limited to 'run_tests.py')
-rwxr-xr-xrun_tests.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/run_tests.py b/run_tests.py
index 3e49662..48f1230 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -156,8 +156,9 @@ def validate_install(srcdir, installdir):
if os.path.exists(os.path.join(installdir, noinst_file)):
expected[noinst_file] = False
elif os.path.exists(info_file):
- for line in open(info_file):
- expected[platform_fix_exe_name(line.strip())] = False
+ with open(info_file) as f:
+ for line in f:
+ expected[platform_fix_exe_name(line.strip())] = False
# Check if expected files were found
for fname in expected:
if os.path.exists(os.path.join(installdir, fname)):
@@ -249,7 +250,8 @@ def _run_test(testdir, test_build_dir, install_dir, extra_args, flags, compile_c
(returncode, stdo, stde) = run_configure_inprocess(gen_command)
try:
logfile = os.path.join(test_build_dir, 'meson-logs/meson-log.txt')
- mesonlog = open(logfile, errors='ignore').read()
+ with open(logfile, errors='ignore') as f:
+ mesonlog = f.read()
except Exception:
mesonlog = 'No meson-log.txt found.'
gen_time = time.time() - gen_start
@@ -401,7 +403,9 @@ def run_tests(extra_args):
def check_file(fname):
linenum = 1
- for line in open(fname, 'rb').readlines():
+ with open(fname, 'rb') as f:
+ lines = f.readlines()
+ for line in lines:
if b'\t' in line:
print("File %s contains a literal tab on line %d. Only spaces are permitted." % (fname, linenum))
sys.exit(1)