Skip to content

Commit d52dccb

Browse files
authored
Merge pull request #2075 from ldrumm/print-cts-invokes
Print CTS invocation to stderr to ease reproduction
2 parents ed5a20e + df6422e commit d52dccb

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

test/conformance/cts_exe.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,43 @@
1010
# Printing conformance test output from gtest and checking failed tests with match files.
1111
# The match files contain tests that are expected to fail.
1212

13+
import os
14+
import shlex
1315
import sys
1416
from argparse import ArgumentParser
1517
import subprocess # nosec B404
1618
import signal
1719
import re
1820
from collections import OrderedDict
1921

20-
if __name__ == '__main__':
22+
23+
def _print_cmdline(cmd_args, env, cwd, file=sys.stderr):
24+
cwd = shlex.quote(cwd)
25+
env_args = " ".join(
26+
"%s=%s" % (shlex.quote(k), shlex.quote(v)) for k, v in env.items()
27+
)
28+
cmd_str = " ".join(map(shlex.quote, cmd_args))
29+
print(f"### env -C {cwd} -i {env_args} {cmd_str}", file=file)
30+
31+
32+
if __name__ == "__main__":
2133

2234
parser = ArgumentParser()
2335
parser.add_argument("--test_command", help="Ctest test case")
2436
parser.add_argument("--devices_count", type=str, help="Number of devices on which tests will be run")
2537
parser.add_argument("--platforms_count", type=str, help="Number of platforms on which tests will be run")
2638
args = parser.parse_args()
39+
invocation = [
40+
args.test_command,
41+
"--gtest_brief=1",
42+
f"--devices_count={args.devices_count}",
43+
f"--platforms_count={args.platforms_count}",
44+
]
45+
_print_cmdline(invocation, os.environ, os.getcwd())
2746

28-
result = subprocess.Popen([args.test_command, '--gtest_brief=1', # nosec B603
29-
f'--devices_count={args.devices_count}',
30-
f'--platforms_count={args.platforms_count}'],
31-
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
47+
result = subprocess.Popen( # nosec B603
48+
invocation, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True
49+
)
3250

3351
pat = re.compile(r'\[( )*FAILED( )*\]')
3452
output_list = []

0 commit comments

Comments
 (0)