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

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.

@stuhood
Copy link
Member

left a comment

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

@Eric-Arellano Eric-Arellano force-pushed the Eric-Arellano:v2-blacklist branch from f03ffb6 to e92c438 Jul 17, 2019

stuhood added a commit that referenced this pull request Jul 24, 2019

Properly handle source roots and resources with V2 Pytest runner (#8063)
### 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 force-pushed the Eric-Arellano:v2-blacklist branch from e92c438 to e6db164 Aug 13, 2019

@Eric-Arellano Eric-Arellano force-pushed the Eric-Arellano:v2-blacklist branch from e6db164 to e17b0ad Aug 13, 2019

@Eric-Arellano Eric-Arellano merged commit 17c2dee into pantsbuild:master Aug 13, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@Eric-Arellano Eric-Arellano deleted the Eric-Arellano:v2-blacklist branch Aug 13, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.