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.
import os
from pathlib import Path
import platform
+import shlex
import subprocess
import sys
import sysconfig
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:
# 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,