This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Use shutil.which in Shell tests find_executable
ClosedPublic

Authored by DavidSpickett on Apr 28 2022, 3:30 AM.

Details

Summary

In build.py we have our own find_executable that looks
a lot like the distutils one that I switched to shutil.which.

This find_executable isn't quite the same as shutil.which
so I've refactored it to call that in the correct way.

Note that the path passed to shutil.which is in the form that
PATH would be, meaning separators are allowed.

>>> shutil.which("gcc", path="/home/david.spickett:/bin")
'/bin/gcc'

We just need to make sure it doesn't ignore the existing PATH
and normalise the result if it does find the binary.

The .exe extension is automatically added to the binary name
if we are on Windows.

Depends on D124601

Diff Detail

Event Timeline

DavidSpickett created this revision.Apr 28 2022, 3:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 28 2022, 3:30 AM
DavidSpickett requested review of this revision.Apr 28 2022, 3:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 28 2022, 3:30 AM
DavidSpickett edited the summary of this revision. (Show Details)Apr 28 2022, 3:30 AM
This revision is now accepted and ready to land.Apr 28 2022, 10:07 AM