forked from python/cpython
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…1710) Now all results from worker processes are aggregated and displayed together as a summary at the end of a regrtest run. The traditional trace is left in place for use with sequential in-process test runs but now raises a warning that those numbers are not precise. `-T -j` requires `--with-pydebug` as it relies on `-Xpresite=`.
- Loading branch information
Showing
13 changed files
with
166 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
"""A minimal hook for gathering line coverage of the standard library. | ||
Designed to be used with -Xpresite= which means: | ||
* it installs itself on import | ||
* it's not imported as `__main__` so can't use the ifmain idiom | ||
* it can't import anything besides `sys` to avoid tainting gathered coverage | ||
* filenames are not normalized | ||
To get gathered coverage back, look for 'test.cov' in `sys.modules` | ||
instead of importing directly. That way you can determine if the module | ||
was already in use. | ||
If you need to disable the hook, call the `disable()` function. | ||
""" | ||
|
||
import sys | ||
|
||
mon = sys.monitoring | ||
|
||
FileName = str | ||
LineNo = int | ||
Location = tuple[FileName, LineNo] | ||
|
||
coverage: set[Location] = set() | ||
|
||
|
||
# `types` and `typing` aren't imported to avoid invalid coverage | ||
def add_line( | ||
code: "types.CodeType", | ||
lineno: int, | ||
) -> "typing.Literal[sys.monitoring.DISABLE]": | ||
coverage.add((code.co_filename, lineno)) | ||
return mon.DISABLE | ||
|
||
|
||
def enable(): | ||
mon.use_tool_id(mon.COVERAGE_ID, "regrtest coverage") | ||
mon.register_callback(mon.COVERAGE_ID, mon.events.LINE, add_line) | ||
mon.set_events(mon.COVERAGE_ID, mon.events.LINE) | ||
|
||
|
||
def disable(): | ||
mon.set_events(mon.COVERAGE_ID, 0) | ||
mon.register_callback(mon.COVERAGE_ID, mon.events.LINE, None) | ||
mon.free_tool_id(mon.COVERAGE_ID) | ||
|
||
|
||
enable() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.