[llvm] e8b5b72 - [lit] Support relative path arguments
Geoffrey Martin-Noble via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 20 11:49:50 PST 2021
Author: Geoffrey Martin-Noble
Date: 2021-12-20T11:49:42-08:00
New Revision: e8b5b7218263e7b1c0b0466cc3c71ff88748935d
URL: https://github.com/llvm/llvm-project/commit/e8b5b7218263e7b1c0b0466cc3c71ff88748935d
DIFF: https://github.com/llvm/llvm-project/commit/e8b5b7218263e7b1c0b0466cc3c71ff88748935d.diff
LOG: [lit] Support relative path arguments
Currently the behavior with relative paths is pretty broken. It differs
between external shell and internal shell because the path resolution
is done with a different working directory. With the internal shell,
it's resolved relative to the directory from which lit is executed,
whereas with the external shell it's resolved relative to where the
test case is executed. To make matters worse, using the internal shell
the filepath to binaries looked up with `which` is returned relative
to the directory from which lit is executed, but then executed from
the test execution directory. That means that relative paths with the
internal shell give a `[Errno 2] No such file or directory` error
instead of the expected `command not found`.
To address these issues this patch makes lit interpret relative paths
as relative to the directory from which lit was invoked and modifies
`which` to return absolute paths, matching the behavior of its
namesake unix function.
See https://groups.google.com/g/llvm-dev/c/KzMWlOXR98Y/m/QJoqn0U5HAAJ
Reviewed By: yln
Differential Revision: https://reviews.llvm.org/D115486
Added:
Modified:
llvm/utils/lit/lit/cl_arguments.py
llvm/utils/lit/lit/util.py
Removed:
################################################################################
diff --git a/llvm/utils/lit/lit/cl_arguments.py b/llvm/utils/lit/lit/cl_arguments.py
index 41e63622b0657..a7488774802fd 100644
--- a/llvm/utils/lit/lit/cl_arguments.py
+++ b/llvm/utils/lit/lit/cl_arguments.py
@@ -92,7 +92,8 @@ def parse_args():
execution_group.add_argument("--path",
help="Additional paths to add to testing environment",
action="append",
- default=[])
+ default=[],
+ type=os.path.abspath)
execution_group.add_argument("--vg",
dest="useValgrind",
help="Run tests under valgrind",
diff --git a/llvm/utils/lit/lit/util.py b/llvm/utils/lit/lit/util.py
index b02cf2815a795..41bf89d399ceb 100644
--- a/llvm/utils/lit/lit/util.py
+++ b/llvm/utils/lit/lit/util.py
@@ -232,7 +232,7 @@ def which(command, paths=None):
for ext in pathext:
p = os.path.join(path, command + ext)
if os.path.exists(p) and not os.path.isdir(p):
- return os.path.normcase(os.path.normpath(p))
+ return os.path.normcase(os.path.abspath(p))
return None
More information about the llvm-commits
mailing list