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

Add engine_error() context manager for testing plugin exceptions #13108

Merged
merged 5 commits into from
Oct 5, 2021

Conversation

Eric-Arellano
Copy link
Contributor

This makes it much easier to test that we raise the appropriate exceptions in rule code.

Thanks to @chrisjrn for co-developing this.

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

Co-authored-by: Christopher Neugebauer <_@chrisjrn.com>

[ci skip-rust]

[ci skip-build-wheels]
Copy link
Member

@kaos kaos left a comment

Choose a reason for hiding this comment

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

Nice :)

src/python/pants/testutil/rule_runner.py Outdated Show resolved Hide resolved
src/python/pants/testutil/rule_runner.py Outdated Show resolved Hide resolved
# 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]
# Conflicts:
#	src/python/pants/testutil/rule_runner.py

# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]
@Eric-Arellano Eric-Arellano enabled auto-merge (squash) October 5, 2021 08:25
Copy link
Member

@kaos kaos left a comment

Choose a reason for hiding this comment

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

Love it :)

@Eric-Arellano
Copy link
Contributor Author

Oh hm! @kaos your suggestion means we can make this a lot simpler. Do we really need to allow inspecting trap.e after the context manager? Instead, I think it's enough to rely on the expected_exception_type and contains args. That allows us to switch to a function-based context manager.

@kaos
Copy link
Member

kaos commented Oct 5, 2021

I think it's enough to rely on the expected_exception_type and contains args. That allows us to switch to a function-based context manager.

Hah, true! :)

# 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 Add EngineErrorTrap for testing plugin exceptions Add engine_error() context manager for testing plugin exceptions Oct 5, 2021
Copy link
Member

@kaos kaos left a comment

Choose a reason for hiding this comment

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

Cool.

# 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 45d376b into pantsbuild:main Oct 5, 2021
@Eric-Arellano Eric-Arellano deleted the engine-error branch October 5, 2021 14:45
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.

2 participants