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

Change PantsIntegrationTest to be hermetic by default #10672

Merged
merged 4 commits into from Aug 23, 2020

Conversation

Eric-Arellano
Copy link
Contributor

@Eric-Arellano Eric-Arellano commented Aug 22, 2020

Several refactors:

  • Make hermetic a class property rather than classmethod. Default to True.
  • Rename use_pantsd_env_var to a class property use_pantsd. Removes the env var mechanism as we no longer use that. Defaults to pantsd being used.
  • Rename hermetic_env_whitelist to hermetic_env_allowlist, and make it a class property.
  • Add type hints.
  • Enforce kwargs.
  • Remove do_command() in favor of self.run_pants(). It does the same thing. We want to simplify.
  • Remove the unused file_renamed. We generally are moving in the direction of our integration tests creating their own environment, rather than mutating the build root (e.g. testprojects). This wasn't being used.

A followup will make it more convenient to create temporary content, which is a common pattern for newly written integration tests.

[ci skip-rust]
[ci skip-build-wheels]

# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
@Eric-Arellano Eric-Arellano changed the title WIP: Refactor PantsIntegrationTest Refactor PantsIntegrationTest Aug 22, 2020
@Eric-Arellano Eric-Arellano marked this pull request as ready for review August 22, 2020 23:42
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
Comment on lines -173 to -174
class InvalidTestEnvironmentError(Exception):
"""Raised when the external environment is not set up properly to run integration tests."""
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was unused, so deleted.

Comment on lines -216 to -219
def setUp(self):
super().setUp()
# Some integration tests rely on clean subsystem state (e.g., to set up a DistributionLocator).
Subsystem.reset()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deleted. No need for this.

Comment on lines -221 to -228
def temporary_workdir(self, cleanup=True):
# We can hard-code '.pants.d' here because we know that will always be its value
# in the pantsbuild/pants repo (e.g., that's what we .gitignore in that repo).
# Grabbing the pants_workdir config would require this pants's config object,
# which we don't have a reference to here.
root = os.path.join(get_buildroot(), ".pants.d", "tmp")
safe_mkdir(root)
return temporary_dir(root_dir=root, cleanup=cleanup, suffix=".pants.d")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Kept, but moved down in the file near the other "temporary" methods.

@Eric-Arellano Eric-Arellano changed the title Refactor PantsIntegrationTest Change PantsIntegrationTest to be hermetic by default Aug 23, 2020
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
@Eric-Arellano Eric-Arellano merged commit 496a680 into pantsbuild:master Aug 23, 2020
@Eric-Arellano Eric-Arellano deleted the refactor-it branch August 23, 2020 05:35
@coveralls
Copy link

Coverage Status

Coverage remained the same at 0.0% when pulling c180bf6 on Eric-Arellano:refactor-it into ff2bec3 on pantsbuild:master.

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.

None yet

3 participants