-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-110722: Make -m test -T -j
use sys.monitoring
#111710
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9611b56
Make `-m test -T -j` use sys.monitoring
ambv bf65fbe
Only run -T -j test when Python is built --with-pydebug
ambv 1adbf57
Simplify `get_coverage_results`
ambv d4f5b6b
Turn off sys.monitoring hooks for tests marked with `@no_tracing`
ambv 84263a3
Merge branch 'main' into gh-110722-regrtest
ambv 3a0688b
Make patchcheck happy
ambv aa31295
Add improvements after review by Victor and Serhiy
ambv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 | ||
ambv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
mon = sys.monitoring | ||
ambv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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]": | ||
ambv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.