[llvm] [lit] Fix to make "RUN: env PATH=..." work as intended (PR #165308)
Björn Pettersson via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 27 12:56:05 PDT 2025
https://github.com/bjope created https://github.com/llvm/llvm-project/pull/165308
There was a bug in llvm-lit related to setting PATH using env in the internal shell.
The new PATH wasn't used when looking up the command to be executed. So when doing things like this in a test case
RUN: mkdir %t
RUN: env PATH=%t program ...
the internal shell would search for "program" using the orignal PATH and not the PATH set by env when preceeding the command.
It seems like this was a simple mistake in commit 57782eff31e9d454, since the logic to pick a PATH from the cmd_shenv instead of shenv actually was added in that patch, but the resulting path wasn't used.
>From 45ff976775473c85e51de0d3eccaed8619014838 Mon Sep 17 00:00:00 2001
From: Bjorn Pettersson <bjorn.a.pettersson at ericsson.com>
Date: Mon, 27 Oct 2025 16:20:17 +0100
Subject: [PATCH] [lit] Fix to make "RUN: env PATH=..." work as intended
There was a bug in llvm-lit related to setting PATH using env
in the internal shell.
The new PATH wasn't used when looking up the command to be executed.
So when doing things like this in a test case
RUN: mkdir %t
RUN: env PATH=%t program ...
the internal shell would search for "program" using the orignal PATH
and not the PATH set by env when preceeding the command.
It seems like this was a simple mistake in commit 57782eff31e9d454,
since the logic to pick a PATH from the cmd_shenv instead of shenv
actually was added in that patch, but the resulting path wasn't used.
---
llvm/utils/lit/lit/TestRunner.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index f88314547bb3f..9fba96a1471a0 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -945,7 +945,7 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
path = (
cmd_shenv.env["PATH"] if "PATH" in cmd_shenv.env else shenv.env["PATH"]
)
- executable = lit.util.which(args[0], shenv.env["PATH"])
+ executable = lit.util.which(args[0], path)
if not executable:
raise InternalShellError(j, "%r: command not found" % args[0])
More information about the llvm-commits
mailing list