diff options
author | Robin McCorkell <rmccorkell@karoshi.org.uk> | 2014-11-16 17:11:00 +0000 |
---|---|---|
committer | Robin McCorkell <rmccorkell@karoshi.org.uk> | 2014-11-16 17:11:00 +0000 |
commit | 85586ce1ba3ceaabd160882a922994125efba79b (patch) | |
tree | 026ce8842ec4bc61da8e669e3fc763ff5a5cc7fe /run_tests.py | |
parent | 46773e75a8d546d8b101d2938eff0c4021f93734 (diff) | |
download | meson-85586ce1ba3ceaabd160882a922994125efba79b.zip meson-85586ce1ba3ceaabd160882a922994125efba79b.tar.gz meson-85586ce1ba3ceaabd160882a922994125efba79b.tar.bz2 |
Signal handling for run_tests.py
SIGINT and SIGTERM are handled, causing further test execution to stop and
the results to be printed immediately. Also cleans up prebuilt objects
Diffstat (limited to 'run_tests.py')
-rwxr-xr-x | run_tests.py | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/run_tests.py b/run_tests.py index 8ed0f69..671289b 100755 --- a/run_tests.py +++ b/run_tests.py @@ -15,7 +15,7 @@ # limitations under the License. from glob import glob -import os, subprocess, shutil, sys, platform +import os, subprocess, shutil, sys, platform, signal import environment from environment import is_windows @@ -27,6 +27,17 @@ test_build_dir = 'work area' install_dir = os.path.join(os.path.split(os.path.abspath(__file__))[0], 'install dir') meson_command = './meson.py' +class StopException(Exception): + def __init__(self): + super(Exception, self).__init__('Stopped by user') + +stop = False +def stop_handler(signal, frame): + global stop + stop = True +signal.signal(signal.SIGINT, stop_handler) +signal.signal(signal.SIGTERM, stop_handler) + #unity_flags = ['--unity'] unity_flags = [] msbuild_exe = shutil.which('msbuild') @@ -93,7 +104,7 @@ def validate_install(srcdir, installdir): return '' def run_and_log(logfile, testdir, should_succeed=True): - global passing_tests, failing_tests + global passing_tests, failing_tests, stop (msg, stdo, stde) = run_test(testdir, should_succeed) if msg != '': print('Fail:', msg) @@ -109,6 +120,8 @@ def run_and_log(logfile, testdir, should_succeed=True): if print_debug: print(stdo) print(stde, file=sys.stderr) + if stop: + raise StopException() def run_test(testdir, should_succeed): global compile_commands @@ -309,7 +322,10 @@ if __name__ == '__main__': os.chdir(script_dir) check_format() pbfile = generate_prebuilt_object() - run_tests() + try: + run_tests() + except StopException: + pass os.unlink(pbfile) print('\nTotal passed tests:', passing_tests) print('Total failed tests:', failing_tests) |