Skip to content

Commit 41bfa42

Browse files
authored
Merge pull request diffblue#276 from diffblue/marek/test_driver_copy-paste-able_command
Copy-paste-able dump of executed/failed command of security-scanner pipeline.
2 parents 16f2cd1 + f0eb2c7 commit 41bfa42

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

regression/end_to_end/driver.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def run_security_analyser_pipeline(
7878
"-R", results_dir,
7979
"-T", temporary_dir,
8080
"--name", relative_binary_path,
81-
"--verbosity", "9"]
81+
"--verbosity", "9"] # TODO: we should rather pass the verbosity to this function.
8282
cmdline.extend(extra_args)
8383
if "SECURITY_ANALYSER_END_TO_END_TESTS_EXTRA_ARGS" in os.environ:
8484
cmdline.extend(os.environ["SECURITY_ANALYSER_END_TO_END_TESTS_EXTRA_ARGS"].split(","))
@@ -87,12 +87,24 @@ def run_security_analyser_pipeline(
8787
temp_dir_deleter(results_dir), \
8888
temp_dir_deleter(temporary_dir):
8989

90+
def quote_pathnames_in_command_line(cmdline):
91+
assert isinstance(cmdline, list) and len(cmdline) > 0
92+
result = cmdline[:1]
93+
for idx in range(1, len(cmdline)):
94+
if cmdline[idx - 1] in ["-C", "-I", "-R", "-T"] or \
95+
(cmdline[idx - 1] == "--name" and " " in cmdline[idx]):
96+
result.append("'" + cmdline[idx] + "'")
97+
else:
98+
result.append(cmdline[idx])
99+
return result
100+
90101
executable_runner = ExecutableRunner(cmdline)
91102
(stdout, stderr, ret) = executable_runner.run()
92103
if ret != 0:
93104
raise Exception(
94-
"Failed running %s:\nstdout:\n\n%s\nstderr\n\n%s" % \
95-
(cmdline, stdout, stderr))
105+
"Failed running \"%s\":\nstdout:\n\n%s\nstderr\n\n%s" % \
106+
(" ".join(quote_pathnames_in_command_line(cmdline)),
107+
stdout, stderr))
96108

97109
trace_list = \
98110
os.path.join(
@@ -112,6 +124,8 @@ def run_security_analyser_pipeline(
112124
inline_traces.append(trace_json)
113125

114126
if "SECURITY_ANALYSER_END_TO_END_TESTS_KEEP_RESULTS" in os.environ:
115-
print("Test %s kept results (%s) and temporary directory (%s)" % (cmdline, results_dir, temporary_dir))
127+
print("Test \"%s\" kept results (%s) and temporary directory (%s)" %
128+
(" ".join(quote_pathnames_in_command_line(cmdline)),
129+
results_dir, temporary_dir))
116130

117131
return ErrorTraces(traces)

0 commit comments

Comments
 (0)