aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2021-04-06 21:16:26 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2021-04-06 21:29:44 +0300
commit3317c146e3a2eaec192c378a4e04389cf34246f1 (patch)
treecaa7125eb342e6f6515f1b13c51090cd32beb0d7
parentctest-driver.py: MULTILINE regex matching (diff)
downloadcmake-common-3317c146e3a2eaec192c378a4e04389cf34246f1.tar.gz
cmake-common-3317c146e3a2eaec192c378a4e04389cf34246f1.zip
ctest-driver.py: fix --new-window
-rwxr-xr-xtools/ctest-driver.py30
1 files changed, 22 insertions, 8 deletions
diff --git a/tools/ctest-driver.py b/tools/ctest-driver.py
index a3fa3e3..e467bd1 100755
--- a/tools/ctest-driver.py
+++ b/tools/ctest-driver.py
@@ -34,11 +34,11 @@ def read_file(path):
return fd.read()
-def run(cmd_line, **kwargs):
+def run(cmd_line):
try:
result = subprocess.run(cmd_line, check=True, universal_newlines=True,
stderr=subprocess.STDOUT,
- stdout=subprocess.PIPE, **kwargs)
+ stdout=subprocess.PIPE)
assert result.returncode == 0
return result.stdout
except subprocess.CalledProcessError as e:
@@ -46,6 +46,16 @@ def run(cmd_line, **kwargs):
sys.exit(e.returncode)
+def run_new_window(cmd_line):
+ try:
+ result = subprocess.run(cmd_line, check=True,
+ creationflags=subprocess.CREATE_NEW_CONSOLE)
+ assert result.returncode == 0
+ return None
+ except subprocess.CalledProcessError as e:
+ sys.exit(e.returncode)
+
+
def match_any(s, regexes):
if not regexes:
return True
@@ -65,12 +75,16 @@ def match_pass_regexes(output, regexes):
def run_actual_test_driver(args):
- creationflags = 0
- if args.new_window and hasattr(subprocess, 'CREATE_NEW_CONSOLE'):
- creationflags = subprocess.CREATE_NEW_CONSOLE
- output = run([args.exe_path] + args.exe_args, creationflags=creationflags)
- sys.stdout.write(output)
- match_pass_regexes(output, args.pass_regexes)
+ cmd_line = [args.exe_path] + args.exe_args
+ run_func = run
+ if args.new_window:
+ run_func = run_new_window
+ output = run_func(cmd_line)
+ if args.new_window and args.pass_regexes:
+ err("Cannot launch child process in a new window and capture its output")
+ if output is not None:
+ sys.stdout.write(output)
+ match_pass_regexes(output, args.pass_regexes)
def grep_file(args):