Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove tests from V2 unit test blacklist that were already passing #8060

Merged
merged 1 commit into from
Aug 13, 2019

Conversation

Eric-Arellano
Copy link
Contributor

@Eric-Arellano Eric-Arellano commented Jul 17, 2019

Several of the tests work now without any changes, very likely thanks to #7866. These not only pass with V2, but also pass with remote execution.

Copy link
Member

@stuhood stuhood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect that a lot of it was due to #7866 and the prework that John did. Thanks @jsirois!

@Eric-Arellano Eric-Arellano changed the title Remove several tests from V2 unit test blacklist Remove tests from V2 unit test blacklist that were already passing Jul 17, 2019
stuhood pushed a commit that referenced this pull request Jul 24, 2019
### Problem
While #7696 added support for source roots, its implementation of stripping the actual prefix from the file broke use of resources, specifically when referring to their path in source code, e.g. calling `open('tests/python/pants_test/backend/jvm/tasks/ivy_utils.py')`. This is because we physically stripped the name, so the hardcoded file path would need to be updated to `'pants_test/backend/jvm/tasks/ivy_utils.py'`. Per #8060 (comment), this is not acceptable because it changes a public API.

We must have a way to relativize Python files so that their import statements work, but to also keep the full path.

### Solution
By populating the `PYTHONPATH` env var for the Pex that runs Pytest with the unique source root paths, Python absolute imports work without actually having to strip any prefix. This appears similar to what [Pycharm and IntelliJ do](https://stackoverflow.com/questions/21199382/why-does-pycharm-always-add-contents-root-to-my-pythonpath-and-what-pythonpat).

#### Alternative attempted: use `PEX`'s `--source-directory`
PEX is able to understand source roots via its `--source-directory` and `--resource-directory` args. The idea was to create two pexes: a requirements PEX and a sources PEX, then to merge the two via `PEX_PATH`. They would stay separate to increase the likelihood of cache hits.

This solution failed, however, due to Pytest failing to discover any tests. See #8063 (comment) and the comment below it.

#### Alternative attempted: only strip `PythonTarget`s
The first idea was to only strip any subclass of `PythonTarget` and keep the full path for other target types like `files` (2b68ebd). This failed quickly, though, because the `VERSION` file is not able to correctly imported in this case.

### Result
Two tests can be removed from the V2 blacklist without any changes to them required.
@Eric-Arellano Eric-Arellano merged commit 17c2dee into pantsbuild:master Aug 13, 2019
@Eric-Arellano Eric-Arellano deleted the v2-blacklist branch August 13, 2019 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants