Xqt created this task.
Xqt added projects: Pywikibot, Pywikibot-tests.
Restricted Application added subscribers: pywikibot-bugs-list, Aklapper.

TASK DESCRIPTION
  **Description: **
  Currently, tests that spawn subprocesses through the helper functions 
`execute()` and `execute_pwb()` do not have the code executed in these 
subprocesses included in the coverage reports. This is because the subprocesses 
are started directly using `subprocess.Popen` without running under coverage 
measurement.
  
  **Problem: **
  
  - Coverage measurement is only performed in the main test process.
  - Code executed in subprocesses launched by `execute()` and `execute_pwb()` 
is missing from coverage data, resulting in incomplete and inaccurate coverage 
reports.
  
  **Proposed solution: **
  Modify the `execute()` function to detect when the command starts a Python 
interpreter and inject `coverage run` into the command line to ensure coverage 
is enabled in subprocesses.  
  For example, transform commands like:  
  `python pwb.py args...  `
  into:  
  `python -m coverage run pwb.py args...`
  
  **Additional considerations: **
  
  - After tests have run, run `coverage combine` to merge the `.coverage` data 
files generated by the main process and subprocesses.
  - Then generate the coverage reports (`coverage report`, `coverage xml`) as 
usual and upload them to Codecov.
  
  **Benefits:**
  
  - Ensures full coverage tracking including code executed in subprocesses.
  - Improves accuracy and completeness of coverage reports, enabling better 
test quality insights.

TASK DETAIL
  https://phabricator.wikimedia.org/T401124

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

_______________________________________________
pywikibot-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to