diff --git a/tests/littlecheck.py b/tests/littlecheck.py index d07c134f9..e3d843826 100755 --- a/tests/littlecheck.py +++ b/tests/littlecheck.py @@ -367,7 +367,10 @@ def perform_substitution(input_str, subs): text = m.group(1) for key, replacement in subs_ordered: if text.startswith(key): - return replacement + text[len(key) :] + # shell-quote the replacement, so it's usable in #RUN lines. + # We could loosen this and only do it for #RUN/#REQUIRES, + # but so far we don't need it anywhere. + return shlex.quote(replacement + text[len(key) :]) # No substitution found, so we default to running it as-is, # which will end up running it via $PATH. return text @@ -475,7 +478,7 @@ class TestRun(object): """Decode a string and split it by newlines only, retaining the newlines. """ - return [s + "\n" for s in s.decode("utf-8").split("\n")] + return [s + "\n" for s in s.decode("utf-8", errors="backslashreplace").split("\n")] if self.config.verbose: print(self.subbed_command)