RFC: Support relative `--path` arguments to lit

I noticed that the lit --path argument currently accepts relative paths, but the way it operates with them 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 file path
to binaries looked up with the which method is returned relative to the directory from which lit is executed, but then executed from the test execution directory. That means that relative --path arguments when using the internal shell result in a [Errno 2] No such file or directory error instead of the expected command not found.

I propose that --path arguments be resolved as absolute paths as part of command line argument parsing. So relative paths passed to --path would be consistently interpreted as relative to the directory from which lit was invoked, which seems the least surprising behavior. To address other potential edge cases from the which method returning relative paths, I also propose modifying it to return absolute paths, which matches the behavior of the unix function from which it gets its name.

https://reviews.llvm.org/D115486 is a patch making this change.


FWIW that makes sense to me!

Thanks for the clear explanation :slight_smile:

Any objections? I’ve sent the patch for review and will land next week if it’s accepted and there isn’t any other discussion.

Ship it!

Landed: https://reviews.llvm.org/rGe8b5b7218263e7b1c0b0466cc3c71ff88748935d