diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2016-04-01 20:20:48 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2016-04-01 20:20:48 +0300 |
commit | ea092fefc26f70066517edb06dec6bd251e59380 (patch) | |
tree | c80edc8bdf81a126204141626742a098774ee98b /run_tests.py | |
parent | 5bb94b901d471fe95460e8976995d017232b6a8e (diff) | |
download | meson-ea092fefc26f70066517edb06dec6bd251e59380.zip meson-ea092fefc26f70066517edb06dec6bd251e59380.tar.gz meson-ea092fefc26f70066517edb06dec6bd251e59380.tar.bz2 |
Use individual tempdirs for building and installing in unit tests.
Diffstat (limited to 'run_tests.py')
-rwxr-xr-x | run_tests.py | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/run_tests.py b/run_tests.py index c4f14ec..9149ea0 100755 --- a/run_tests.py +++ b/run_tests.py @@ -18,7 +18,7 @@ from glob import glob import os, subprocess, shutil, sys, signal from io import StringIO from ast import literal_eval -import sys +import sys, tempfile from mesonbuild import environment from mesonbuild import mesonlib from mesonbuild import mlog @@ -45,8 +45,6 @@ failing_tests = 0 skipped_tests = 0 print_debug = 'MESON_PRINT_TEST_OUTPUT' in os.environ -test_build_dir = 'work area' -install_dir = os.path.join(os.path.split(os.path.abspath(__file__))[0], 'install dir') meson_command = os.path.join(os.getcwd(), 'meson') if not os.path.exists(meson_command): meson_command += '.py' @@ -198,12 +196,13 @@ def parse_test_args(testdir): return args def run_test(testdir, extra_args, should_succeed): + with tempfile.TemporaryDirectory(prefix='b ', dir='.') as build_dir: + with tempfile.TemporaryDirectory(prefix='i ', dir=os.getcwd()) as install_dir: + return _run_test(testdir, build_dir, install_dir, extra_args, should_succeed) + +def _run_test(testdir, test_build_dir, install_dir, extra_args, should_succeed): global compile_commands mlog.shutdown() # Close the log file because otherwise Windows wets itself. - shutil.rmtree(test_build_dir) - shutil.rmtree(install_dir) - os.mkdir(test_build_dir) - os.mkdir(install_dir) print('Running test: ' + testdir) test_args = parse_test_args(testdir) gen_start = time.time() @@ -290,14 +289,6 @@ def run_tests(extra_args): conf_time = 0 build_time = 0 test_time = 0 - try: - os.mkdir(test_build_dir) - except OSError: - pass - try: - os.mkdir(install_dir) - except OSError: - pass for name, test_cases, skipped in all_tests: current_suite = ET.SubElement(junit_root, 'testsuite', {'name' : name, 'tests' : str(len(test_cases))}) |