hatch icon indicating copy to clipboard operation
hatch copied to clipboard

Add coverage options for hatch-test scripts

Open jborbely opened this issue 1 year ago • 1 comments

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.

jborbely avatar May 10 '24 02:05 jborbely

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

ofek avatar May 10 '24 19:05 ofek