This is an archive of the discontinued LLVM Phabricator instance.

[lldb/Reproducers] Add test-specific API to set the test CWD
ClosedPublic

Authored by JDevlieghere on May 12 2020, 4:24 PM.

Details

Summary

The reproducers' working directory is set to the current working directory when
they are initialized. While this is not optimal, as the cwd can change during a
debug session, it has been sufficient so far.

The current approach doesn't work for the API test suite however because dotest
temporarily changes the directory to where the test's Python file lives.

This patch adds an API to tell the reproducers what to set the CWD to. This is
a NO-OP in every mode but capture.

Diff Detail

Event Timeline

JDevlieghere created this revision.May 12 2020, 4:24 PM
labath accepted this revision.May 13 2020, 2:06 AM

It's definitely a hack, but it seems to be fairly well contained.

As an aside, I've always wondered, how much we really need to switch the cwd. Now that we build tests out-of-tree, I would expect most of the file references to be cwd-independent (getBuildArtifact). The only remaining references are probably the ones where we work with source files, which shouldn't be too hard to fix, and also those where we still accidentally create files in the source tree (which this would help eliminate).

This revision is now accepted and ready to land.May 13 2020, 2:06 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMay 13 2020, 9:12 AM

It's definitely a hack, but it seems to be fairly well contained.

As an aside, I've always wondered, how much we really need to switch the cwd. Now that we build tests out-of-tree, I would expect most of the file references to be cwd-independent (getBuildArtifact). The only remaining references are probably the ones where we work with source files, which shouldn't be too hard to fix, and also those where we still accidentally create files in the source tree (which this would help eliminate).

Sounds good. About half the API tests are failing without changing the working directory, though I suspect it's mostly the same issue. I've added it to my list of nice-to-haves.