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

Refactor `pants_run_integration_test.py` and `pex_build_util.py` #8180

Merged

Conversation

@Eric-Arellano
Copy link
Contributor

commented Aug 17, 2019

Both these files are very important to understanding how Pytest works with V1 and how we run integration tests. While reading them to understand what's going on, I made these changes:

  • Replace lambdas with full def so that we can use intermediate variables and type hints
  • Use pathlib.Path
  • Use f-strings
  • Replace datatype() with dataclasses
  • Fix BUILD entries
  • Add type hints (can't be type checked yet)

@Eric-Arellano Eric-Arellano requested review from stuhood and blorente Aug 17, 2019

@Eric-Arellano Eric-Arellano changed the title Refactor pants_run_integration_test.py Refactor `pants_run_integration_test.py` and `pex_build_util.py` Aug 18, 2019

@Eric-Arellano Eric-Arellano force-pushed the Eric-Arellano:refactor-integration-tests branch from d6b8211 to d048fd2 Aug 18, 2019

# these `Files` can still be accessed in the context of a built pex distribution.
builder.info.zip_safe = False
return relpath
return str(Path(relpath).relative_to(tgt.target_base))

This comment has been minimized.

Copy link
@Eric-Arellano

Eric-Arellano Aug 18, 2019

Author Contributor

This line is the answer to one of my biggest questions the past two months! I had been confused this whole time how we go from full paths to source-root stripped paths, like src/python/pants -> pants.

I'm going to revisit V2 source root and resource handling yet again now that I see what's going on.


def dump_sources(builder, tgt, log):

This comment has been minimized.

Copy link
@Eric-Arellano

Eric-Arellano Aug 18, 2019

Author Contributor

I deleted this because there were no usages and it's not a public API. It's highly similar to add_sources_from(), which we do use a lot of.

@Eric-Arellano Eric-Arellano requested a review from jsirois Aug 18, 2019

tests/python/pants_test/BUILD Outdated Show resolved Hide resolved

@Eric-Arellano Eric-Arellano merged commit fb3ba3f into pantsbuild:master Aug 20, 2019

1 check passed

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

@Eric-Arellano Eric-Arellano deleted the Eric-Arellano:refactor-integration-tests branch Aug 20, 2019

patliu85 added a commit to twitter/pants that referenced this pull request Aug 20, 2019
Refactor `pants_run_integration_test.py` and `pex_build_util.py` (pan…
…tsbuild#8180)

Both these files are very important to understanding how Pytest works with V1 and how we run integration tests. While reading them to understand what's going on, I made these changes:

* Replace lambdas with full `def` so that we can use intermediate variables and type hints
* Use `pathlib.Path`
* Use f-strings
* Replace datatype() with dataclasses
* Fix `BUILD` entries
* Add type hints (can't be type checked yet)
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.