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

pytest: Collect code coverage in multiple workers too #243

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ omit =
${INITIAL_PWD-.}/.github/*
${INITIAL_PWD-.}/bin.*/*
${INITIAL_PWD-.}/dist.*/*
**/gui/wxpython/*/**
**/OBJ.*/*
source =
.
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,25 @@ jobs:
run: |
export PYTHONPATH=`grass --config python_path`:$PYTHONPATH
export LD_LIBRARY_PATH=$(grass --config path)/lib:$LD_LIBRARY_PATH
export INITIAL_GISBASE="$(grass --config path)"
export INITIAL_PWD="${PWD}"
pytest --verbose --color=yes --durations=0 --durations-min=0.5 \
--numprocesses auto -ra . \
--numprocesses auto \
--cov \
--cov-context=test \
-ra . \
-m 'not needs_solo_run'

- name: Run pytest with a single worker (for tests marked with needs_solo_run)
run: |
export PYTHONPATH=`grass --config python_path`:$PYTHONPATH
export LD_LIBRARY_PATH=$(grass --config path)/lib:$LD_LIBRARY_PATH
export INITIAL_GISBASE="$(grass --config path)"
INITIAL_PWD="${PWD}" pytest --verbose --color=yes --durations=0 --durations-min=0.5 \
export INITIAL_PWD="${PWD}"
pytest --verbose --color=yes --durations=0 --durations-min=0.5 \
--cov \
--cov-context=test \
--cov-append \
-ra . \
-m 'needs_solo_run'
- name: Fix non-standard installed script paths in coverage data
Expand Down
6 changes: 4 additions & 2 deletions utils/coverage_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ def map_scripts_paths(old_path):
if INITIAL_GISBASE is None or INITIAL_PWD is None:
return old_path
p = Path(old_path)
extension = ".py"
p_name = p.stem if p.suffix == extension else p.name
temporal_base = Path(INITIAL_GISBASE) / "scripts" / "t.*"
base = Path(INITIAL_GISBASE) / "scripts" / "*"
if p.match(str(temporal_base)):
return str(Path(INITIAL_PWD) / "temporal" / (p.name) / (p.name)) + ".py"
return str(Path(INITIAL_PWD) / "temporal" / (p_name) / (p_name)) + extension
if p.match(str(base)):
return str(Path(INITIAL_PWD) / "scripts" / (p.name) / (p.name)) + ".py"
return str(Path(INITIAL_PWD) / "scripts" / (p_name) / (p_name)) + extension

return old_path

Expand Down
Loading