Update littlecheck to fix spurious "not found" error on exit 127

Commit b6d76ae: we now use lines like "# RUN: fish=%fish %fish".
If a test exits with 127 we try to look up the command but use the
wrong name, which leads to unintelligible errors if the test exits
with 127 for other reasons.
This commit is contained in:
Johannes Altmanninger 2025-01-03 10:26:58 +01:00
parent 834001087d
commit 3405621dee

View file

@ -32,6 +32,8 @@ CHECK_STDOUT_RE = re.compile(COMMENT_RE + r"CHECK:\s+(.*)\n")
# A regex capturing lines that should be checked against stderr.
CHECK_STDERR_RE = re.compile(COMMENT_RE + r"CHECKERR:\s+(.*)\n")
VARIABLE_OVERRIDE_RE = re.compile(r"\w+=.*")
SKIP = object()
def find_command(program):
@ -489,7 +491,7 @@ class TestRun(object):
# most likely when the last command in a shell script doesn't exist.
# So we check if the command *we execute* exists, and complain then.
status = proc.returncode
cmd = shlex.split(self.subbed_command)[0]
cmd = next((word for word in shlex.split(self.subbed_command) if not VARIABLE_OVERRIDE_RE.match(word)))
if status == 127 and not find_command(cmd):
raise CheckerError("Command could not be found: " + cmd)
if status == 126 and not find_command(cmd):