From: Matthew Fernandez Date: Tue, 11 Jan 2022 01:23:49 +0000 (-0800) Subject: shell-quote commands echoed during testing X-Git-Tag: 3.0.0~67^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6cd70a38e88f255a40a233077e1e87ddaaf8336d;p=graphviz shell-quote commands echoed during testing It is not typical that testing paths will contain things like spaces and other characters that require quoting. But this change goes the extra mile to make sure these echoed commands are always copy-pastable to re-execute them. --- diff --git a/rtest/gvtest.py b/rtest/gvtest.py index e91153b11..390ae6b14 100644 --- a/rtest/gvtest.py +++ b/rtest/gvtest.py @@ -3,6 +3,7 @@ import os from pathlib import Path import platform +import shlex import subprocess import sys import sysconfig @@ -46,7 +47,7 @@ def compile_c(src: Path, cflags: List[str] = None, link: List[str] = None, args += [f"-l{l}" for l in link] + ldflags # dump the command being run for the user to observe if the test fails - print(f'+ {" ".join(str(x) for x in args)}') + print(f'+ {" ".join(shlex.quote(str(x)) for x in args)}') # compile the program try: @@ -116,7 +117,7 @@ def run_c(src: Path, args: List[str] = None, input: str = "", # dump the command being run for the user to observe if the test fails argv = [exe] + args - print(f'+ {" ".join(str(x) for x in argv)}') + print(f'+ {" ".join(shlex.quote(str(x)) for x in argv)}') # run it p = subprocess.run(argv, input=input, stdout=subprocess.PIPE,