From 3e075f2a9a5ddf8aa8b3b082c7c758f5a71c5be5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0ar=C5=ABnas=20Nejus?= Date: Sat, 15 Jun 2024 23:52:18 +0100 Subject: [PATCH 1/2] Add 'test-with-coverage' command And do not measure coverage by default. --- .github/workflows/ci.yaml | 4 ++-- pyproject.toml | 20 +++++++++++++++++++- setup.cfg | 11 ----------- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ebee6add6f..9c3d583054 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -41,14 +41,14 @@ jobs: - if: ${{ env.IS_MAIN_PYTHON != 'true' }} name: Test without coverage - run: poe test --no-cov + run: poe test - if: ${{ env.IS_MAIN_PYTHON == 'true' }} name: Test with coverage uses: liskin/gh-problem-matcher-wrap@v3 with: linters: pytest - run: poe test + run: poe test-with-coverage - if: ${{ env.IS_MAIN_PYTHON == 'true' }} name: Store the coverage report diff --git a/pyproject.toml b/pyproject.toml index 950818ed22..86d5be9e7f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -211,7 +211,25 @@ cmd = "poetry update -vv" [tool.poe.tasks.test] help = "Run tests with pytest" -cmd = "pytest" +cmd = "pytest $OPTS" +env.OPTS.default = "-p no:cov" + +[tool.poe.tasks.test-with-coverage] +help = "Run tests and record coverage" +ref = "test" +# record coverage in beets and beetsplug packages +# save xml for coverage upload to coveralls +# save html report for local dev use +# measure coverage across logical branches +# show which tests cover specific lines in the code (see the HTML report) +env.OPTS = """ +--cov=beets +--cov=beetsplug +--cov-report=xml:.reports/coverage.xml +--cov-report=html:.reports/html +--cov-branch +--cov-context=test +""" [tool.black] line-length = 80 diff --git a/setup.cfg b/setup.cfg index bdf742abdb..8f127e8e43 100644 --- a/setup.cfg +++ b/setup.cfg @@ -7,17 +7,6 @@ addopts = # show all skipped/failed/xfailed tests in the summary except passed -ra --strict-config - # record coverage in these two packages - --cov=beets - --cov=beetsplug - # save xml for coverage upload - --cov-report=xml:.reports/coverage.xml - # save html files for local dev use - --cov-report=html:.reports/html - # record coverage across logical branches - --cov-branch - # show which tests cover specific lines in the code (available in HTML) - --cov-context=test [coverage:run] data_file = .reports/coverage/data From 0e1b5c20eddc75813e1821e7e3c2e321285f5a8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0ar=C5=ABnas=20Nejus?= Date: Sat, 15 Jun 2024 23:52:52 +0100 Subject: [PATCH 2/2] Gitignore the .reports directory --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 4b024e39b9..15f11a433b 100644 --- a/.gitignore +++ b/.gitignore @@ -56,6 +56,7 @@ htmlcov/ coverage.xml *,cover .hypothesis/ +.reports # Flask stuff: instance/