jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1175537?usp=email )
Change subject: Tests: Enable coverage measurement in subprocesses started by
execute_pwb()
......................................................................
Tests: Enable coverage measurement in subprocesses started by execute_pwb()
- Detect if tests are running via PYWIKIBOT_TEST_RUNNING environment variable
- Attempt to import coverage module and activate coverage run for subprocess
- Prepend 'python -m coverage run' to the command when coverage is available
- Ensures coverage data includes code executed in pwb.py subprocesses
- Gracefully handles missing coverage module by skipping coverage injection
- use coverage combine in github action
Bug: T401124
Change-Id: Ib81936c68fcf7e54e9db0375fafd40f7ca45eabc
---
M .github/workflows/doctest.yml
M .github/workflows/login_tests-ci.yml
M .github/workflows/oauth_tests-ci.yml
M .github/workflows/pywikibot-ci.yml
M .github/workflows/sysop_write_tests-ci.yml
M .github/workflows/windows_tests.yml
M tests/utils.py
7 files changed, 12 insertions(+), 0 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/.github/workflows/doctest.yml b/.github/workflows/doctest.yml
index dee414e..6c9b8b5 100644
--- a/.github/workflows/doctest.yml
+++ b/.github/workflows/doctest.yml
@@ -68,6 +68,7 @@
coverage run -m pytest pywikibot --doctest-modules
--ignore-glob="*gui.py" --ignore-glob="*memento.py"
- name: Show coverage statistics
run: |
+ coverage combine
coverage report
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
diff --git a/.github/workflows/login_tests-ci.yml
b/.github/workflows/login_tests-ci.yml
index a8e35f1..fe66042 100644
--- a/.github/workflows/login_tests-ci.yml
+++ b/.github/workflows/login_tests-ci.yml
@@ -124,6 +124,7 @@
coverage run -m unittest -vv tests/site_login_logout_tests.py
- name: Show coverage statistics
run: |
+ coverage combine
coverage report
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
diff --git a/.github/workflows/oauth_tests-ci.yml
b/.github/workflows/oauth_tests-ci.yml
index 0aa7e33..008124b 100644
--- a/.github/workflows/oauth_tests-ci.yml
+++ b/.github/workflows/oauth_tests-ci.yml
@@ -102,6 +102,7 @@
coverage run -m unittest -vv
- name: Show coverage statistics
run: |
+ coverage combine
coverage report
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
diff --git a/.github/workflows/pywikibot-ci.yml
b/.github/workflows/pywikibot-ci.yml
index 114fb7b..dea4499 100644
--- a/.github/workflows/pywikibot-ci.yml
+++ b/.github/workflows/pywikibot-ci.yml
@@ -140,6 +140,7 @@
fi
- name: Show coverage statistics
run: |
+ coverage combine
coverage report
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
diff --git a/.github/workflows/sysop_write_tests-ci.yml
b/.github/workflows/sysop_write_tests-ci.yml
index a08b124..917ba22 100644
--- a/.github/workflows/sysop_write_tests-ci.yml
+++ b/.github/workflows/sysop_write_tests-ci.yml
@@ -62,6 +62,7 @@
coverage run -m pytest -s -r A -a "${{ matrix.attr }}"
- name: Show coverage statistics
run: |
+ coverage combine
coverage report
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
diff --git a/.github/workflows/windows_tests.yml
b/.github/workflows/windows_tests.yml
index 13a2405..579d45a 100644
--- a/.github/workflows/windows_tests.yml
+++ b/.github/workflows/windows_tests.yml
@@ -75,6 +75,7 @@
coverage run -m unittest discover -vv -p \"*_tests.py\";
- name: Show coverage statistics
run: |
+ coverage combine
coverage report
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
diff --git a/tests/utils.py b/tests/utils.py
index 8f5d342..1c69793 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -530,6 +530,12 @@
else:
command.append(_pwb_py)
+ # Test is running; activate coverage if present
+ if os.environ.get('PYWIKIBOT_TEST_RUNNING', '0') == '1':
+ with suppress(ModuleNotFoundError):
+ import coverage # noqa: F401
+ command = [command[0], '-m', 'coverage', 'run'] + command[1:]
+
return execute(command=command + args, data_in=data_in, timeout=timeout)
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1175537?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ib81936c68fcf7e54e9db0375fafd40f7ca45eabc
Gerrit-Change-Number: 1175537
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]