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 coverage options for hatch-test scripts #1477

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jborbely
Copy link

It has been a very educational experience following the documentation of hatch to update my setup.py-style projects to follow the latest best-practices. Thank you @ofek for all the time you spend developing helpful tools.

This PR is in regards to the hatch test command that was added in version 1.10.0.

While converting a project that used the coverage html command, I needed to redefine all scripts in the [envs.hatch-test.scripts] table even though I used the default run, run-cov and cov-combine scripts, e.g.,

[envs.hatch-test.scripts]
run = "pytest{env:HATCH_TEST_ARGS:} {args}"   # default
run-cov = "coverage run -m pytest{env:HATCH_TEST_ARGS:} {args}"  # default
cov-combine = "coverage combine"  # default
cov-report = "coverage html"  # replaced 'report' with 'html'

This PR proposes that the following options may be defined in the [envs.hatch-test] table

  • combine-args: array of strings, for the cov-combine script
  • reporting: string, for the cov-report script
  • reporting-args: array of strings, for the cov-report script

so that, for my particular use case, I could now define the [envs.hatch-test] table as

[envs.hatch-test]
reporting = "html"

Another example. Suppose someone wants to silence all messages from coverage combine and show the lines that were excluded in the tests when reporting

[envs.hatch-test]
combine-args = ["--quiet"]
reporting-args = ["--show-missing"]

Thanking you for any comments or suggestions you may have. No worries if this PR does not align with the way you want hatch-test.scripts to be used ‐ feel free to close it.

The following new options may be defined in the [tool.hatch.envs.hatch-test] table
* combine-args: array of strings, for the 'cov-combine' script
* reporting: string, for the 'cov-report' script
* reporting-args: array of strings, for the 'cov-report' script
@ofek
Copy link
Sponsor Collaborator

ofek commented May 10, 2024

I will check this out in the coming weeks, thanks!!!

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

2 participants