hatch icon indicating copy to clipboard operation
hatch copied to clipboard

Make `hatch -e hatch-test.py3.11 test …` work as expected

Open flying-sheep opened this issue 3 months ago • 2 comments

Hatch’s global env selection via -e shouldn’t be ignored by hatch test.

This is useful because hatch env show -i --json only outputs env names and not the necessary hatch test env selection syntax. So to derive e.g. a GitHub test matrix fully from Hatch’s CLI, currently only hatch run syntax can be used, which leads to ugly workflows:

- name: Run tests with coverage
  env:
    COVERAGE_PROCESS_START: ${{ github.workspace }}/pyproject.toml
  run: |
    uvx hatch run ${{ matrix.env.name }}:run-cov -v --color=yes -n auto
    uvx hatch run ${{ matrix.env.name }}:cov-combine
    uvx hatch run ${{ matrix.env.name }}:coverage xml

cc @ilan-gold @grst

flying-sheep avatar Sep 16 '25 13:09 flying-sheep

Oooh, actually since coverage 7.10, the new [run] patch config makes this pretty easy, we should switch to that instead! See https://github.com/nedbat/coveragepy/commit/6d2e56209ebe3bb2595e8b180c99845c25576d53

flying-sheep avatar Sep 25 '25 09:09 flying-sheep

Oh, that's awesome!

ofek avatar Sep 26 '25 04:09 ofek