hatch icon indicating copy to clipboard operation
hatch copied to clipboard

Running arbitrary scripts as part of hatch test

Open jrs53 opened this issue 1 year ago • 3 comments

Is hatch test limited to running the four documented scripts (run, run-cov, cov-combine, cov-report) or can we run arbitrary scripts? Currently looking to replace our use of tox that calls pytest and some other tests. Thanks

jrs53 avatar Jun 10 '24 17:06 jrs53

You can override the scripts and also define anything else there that you want. You can also define extra scripts if you don't want to modify the default ones.

ofek avatar Jun 10 '24 17:06 ofek

Thanks, skimming over

https://github.com/pypa/hatch/blob/master/src/hatch/cli/test/init.py

hatch test seems mostly syntactic sugar for running some combination of the run/run-cov/cov-combine/cov-report scripts within the hatch-test environment? So I can override the scripts (as long as I call them those names), but I can't use arbitrary names?

Our tox config has a few different environments defined which run tests using pytest, run linters etc similar to https://tox.wiki/en/4.15.1/user_guide.html. All these are run across the environment matrices when I run the single "tox" command. My understanding is that for the same behaviour with hatch test, I'd need to use one of the four names to override scripts in the hatch-test environment. Alternatively, I could use arbitrary script names but would have to invoke them individually with hatch run.

jrs53 avatar Jun 11 '24 06:06 jrs53

The docs should also show, as examples, how exactly one can use these commands after defining them in the manifest file.

jymchng avatar Jul 30 '24 11:07 jymchng