[PATCH] D115486: [lit] Support relative path arguments

Geoffrey Martin-Noble via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 9 17:24:53 PST 2021


GMNGeoffrey created this revision.
Herald added a subscriber: delcypher.
GMNGeoffrey requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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 other potential edge cases from the
latter, also modified `which` to return absolute paths.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115486

Files:
  llvm/utils/lit/lit/cl_arguments.py


Index: llvm/utils/lit/lit/cl_arguments.py
===================================================================
--- llvm/utils/lit/lit/cl_arguments.py
+++ llvm/utils/lit/lit/cl_arguments.py
@@ -237,6 +237,10 @@
 
     opts.reports = filter(None, [opts.output, opts.xunit_xml_output, opts.resultdb_output, opts.time_trace_output])
 
+    # Convert path arguments to absolute paths, so they can be referenced
+    # anywhere.
+    opts.path = [os.path.abspath(p) for p in opts.path]
+
     return opts
 
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115486.393345.patch
Type: text/x-patch
Size: 502 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211210/37b0b47c/attachment.bin>


More information about the llvm-commits mailing list