This is an archive of the discontinued LLVM Phabricator instance.

[lit] Support relative path arguments
ClosedPublic

Authored by GMNGeoffrey on Dec 9 2021, 5:24 PM.

Details

Summary

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

Diff Detail

Event Timeline

GMNGeoffrey created this revision.Dec 9 2021, 5:24 PM
GMNGeoffrey requested review of this revision.Dec 9 2021, 5:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 9 2021, 5:24 PM

Return absolute paths from which

Pre-merge failures are due to a buildkite outage: https://www.buildkitestatus.com/incidents/5xlht1w0p780

GMNGeoffrey edited the summary of this revision. (Show Details)Dec 15 2021, 12:37 PM
GMNGeoffrey added reviewers: jdenny, yln, mehdi_amini.
yln accepted this revision.Dec 15 2021, 1:57 PM

I haven't been in a situation where I had to (manually) use this option, but your explanation sounds sensible to me.

LGTM with 1 optional nit!

llvm/utils/lit/lit/cl_arguments.py
241–244

Could we replace this block by specifying type=os.path.abspath as the "converter" function where the --path argument is declared?

This revision is now accepted and ready to land.Dec 15 2021, 1:57 PM

Use type=os.path.abspath

GMNGeoffrey added inline comments.Dec 15 2021, 2:35 PM
llvm/utils/lit/lit/cl_arguments.py
241–244

Indeed we can, thanks!

Rebase on head

The only pre-merge failure is LLVM :: Bindings/Go/go.test which is failing for lots of people, as discussed in https://groups.google.com/g/llvm-dev/c/o07dxO7Y-CA. Going to land past that

This revision was landed with ongoing or failed builds.Dec 20 2021, 11:50 AM
This revision was automatically updated to reflect the committed changes.