-
Notifications
You must be signed in to change notification settings - Fork 647
chore: show agents how to view test code coverage #5426
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
wjones127
merged 7 commits into
lance-format:main
from
wjones127:docs-agents-code-coverage
Dec 9, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c54350c
chore: show agents how to view test code coverage
wjones127 6b451e2
add a way to ignore some lines
wjones127 5756051
give it a script for file-level coverage
wjones127 9be974b
fix up script
wjones127 99ef016
fix script
wjones127 3814872
add branch coverage to CI
wjones127 6cbf623
try without branch coverage
wjones127 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
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,38 @@ | ||
| import argparse | ||
| import subprocess | ||
|
|
||
| parser = argparse.ArgumentParser(description="Run code coverage analysis.") | ||
| parser.add_argument("-p", "--package", type=str, help="The Rust crate to analyze.") | ||
| parser.add_argument( | ||
| "-f", "--file", type=str, help="The specific file to show coverage for." | ||
| ) | ||
| args = parser.parse_args() | ||
|
|
||
| cmd = ["cargo", "+nightly", "llvm-cov", "-q", "--branch", "--text", "--color", "always"] | ||
| if args.package: | ||
| cmd += ["-p", args.package] | ||
|
|
||
| result = subprocess.run(cmd, capture_output=True) | ||
| if result.returncode != 0: | ||
| print("Error running coverage analysis:") | ||
| print(result.stderr.decode()) | ||
| elif args.file: | ||
| # Look for the specific file's coverage details | ||
| # Section headers look like: /path/to/file.rs: | ||
| lines = result.stdout.splitlines() | ||
| in_file_section = False | ||
| file_bytes = args.file.encode() | ||
| for line in lines: | ||
| # Check if this is a section header (path ending with colon) | ||
| stripped = line.rstrip() | ||
| is_section_header = stripped.endswith(b":") and b"|" not in line | ||
| if is_section_header: | ||
| if file_bytes in line: | ||
| in_file_section = True | ||
| elif in_file_section: | ||
| # Hit a new section, stop | ||
| break | ||
| if in_file_section: | ||
| print(line.decode()) | ||
| else: | ||
| print(result.stdout.decode()) |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way to just skip code coverage for anything in the test cfg? Or is that already done and this is for test utilities that are in main scope for some reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't seem like there's a particularly easy way. taiki-e/cargo-llvm-cov#123
But most of the time tests have their lines covered. It's just some edge cases like branches that only happen on test failures that get missed. I think that's okay.