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

feat(toolchain): Extend Python Testing Toolchain with COVERAGE_RC Support #2246

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ewianda
Copy link
Contributor

@ewianda ewianda commented Sep 24, 2024

This PR enhances the Test Runner environment to support custom coverage configuration via the COVERAGE_RC environment variable. Inspired by this approach, this feature allows users to specify a .coveragerc file in any compatible format to customize coverage reporting.

Key Changes
Adds support for the COVERAGE_RC environment variable in the Test Runner environment.
Enables users to define and pass their own .coveragerc configurations, enhancing flexibility for various testing and reporting requirements.

close #1434

@ewianda ewianda force-pushed the feat-configure-coverage-rc-env-variable branch from c7a142b to 173853e Compare September 24, 2024 21:20
@ewianda ewianda force-pushed the feat-configure-coverage-rc-env-variable branch 4 times, most recently from 4c0451e to 5a16df4 Compare October 22, 2024 19:02
@ewianda ewianda force-pushed the feat-configure-coverage-rc-env-variable branch from 5a16df4 to 039012f Compare October 22, 2024 19:11
Copy link
Collaborator

@aignas aignas left a comment

Choose a reason for hiding this comment

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

This is certainly interesting. It seems that there are //tests/python/python_tests.bzl failing due to the mock module_ctx not being updated.

Shall we mark this as Ready for review and ask others to also have a look? Before doing that could you please update the PR description?

examples/bzlmod/BUILD.bazel Show resolved Hide resolved
examples/bzlmod/MODULE.bazel Outdated Show resolved Hide resolved
@ewianda
Copy link
Contributor Author

ewianda commented Oct 26, 2024

This is certainly interesting. It seems that there are //tests/python/python_tests.bzl failing due to the mock module_ctx not being updated.

Shall we mark this as Ready for review and ask others to also have a look? Before doing that could you please update the PR description?

I am going to work on the description and get the tests to pass, then we can open it up for review.

Copy link
Collaborator

@aignas aignas left a comment

Choose a reason for hiding this comment

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

Added some extra thoughts about the API design

python/private/py_test_toolchain.bzl Outdated Show resolved Hide resolved
python/private/python.bzl Outdated Show resolved Hide resolved
@ewianda ewianda force-pushed the feat-configure-coverage-rc-env-variable branch from 039012f to 0d3a405 Compare October 30, 2024 06:19
@ewianda ewianda changed the title Feat configure coverage rc env variable feat(toolchain): Extend Python Testing Toolchain with COVERAGE_RC Support Oct 30, 2024
@ewianda ewianda force-pushed the feat-configure-coverage-rc-env-variable branch 2 times, most recently from f256992 to 9ebd564 Compare October 30, 2024 13:35
python/private/py_test_toolchain.bzl Outdated Show resolved Hide resolved
python/private/python_test.bzl Show resolved Hide resolved
examples/bzlmod/tests/BUILD.bazel Show resolved Hide resolved
@ewianda
Copy link
Contributor Author

ewianda commented Oct 31, 2024

The test under Bazel 6.4.0 test is failing. My guess is because this native java py_test, If that is the case is the a mechanism to run the test conditionally

Inspired by https://github.com/trybka/scraps/blob/master/cc_test.md

This PR extends Test Runner enviroment to provide a coveragerc
enviroment variable COVERAGE_RC, allowing user to provide
coverage resource in what ever format
@ewianda ewianda force-pushed the feat-configure-coverage-rc-env-variable branch from 02d40e0 to 9e4665c Compare October 31, 2024 15:56
@aignas
Copy link
Collaborator

aignas commented Nov 1, 2024

Ah, this is because bazel 6.4 is not using the starlark implementation of the rules, so it is expected to not work for now.

@ewianda ewianda force-pushed the feat-configure-coverage-rc-env-variable branch from 9e4665c to 0371be3 Compare November 1, 2024 21:03
@ewianda ewianda force-pushed the feat-configure-coverage-rc-env-variable branch from 0371be3 to 3060b83 Compare November 1, 2024 21:16
@aignas
Copy link
Collaborator

aignas commented Nov 4, 2024

Idea for why the Windows build is failing - it is using a very different bootstrap mechanism and it could be that the coveragerc is not wired properly. I am not 100% sure how we should do this. @rickeylev, any thoughts here?

@ewianda
Copy link
Contributor Author

ewianda commented Nov 5, 2024

@rickeylev @aignas I have tried to figure out the issue with windows with no success. I noticed that C:\Users\ELVISW~1\AppData\Local\Temp\Bazel.runfiles__dysvgw6\runfiles\_main\.coveragerc is missing C:\Users\ElvisWianda\Documents\rules_python\examples\bzlmod\bazel-bin\tests\coverage_rc_is_set_test.exe.runfiles\_main/.coveragerc
exists

Figured out the issue

@ewianda ewianda force-pushed the feat-configure-coverage-rc-env-variable branch from de0204d to d7181bc Compare November 5, 2024 18:44
@ewianda ewianda marked this pull request as ready for review November 5, 2024 18:53
@ewianda ewianda force-pushed the feat-configure-coverage-rc-env-variable branch from d7181bc to 2270aa0 Compare November 5, 2024 20:03
@ewianda ewianda requested a review from aignas November 5, 2024 20:03
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.

Allow customized coveragerc for Python coverage
2 participants