-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add a cargo option to generate coverage reports using -Z instrument-coverage
#14987
Comments
Added to the tracking issue (#79121) for |
cargo test -Ztimings is also problematic. It would be nice to shim in a prefix script like /usr/bin/time -v to get memory usage; I'm working on a Rust port of /usr/bin/time -v that emits JSON/CSV/PythonDict for easy parsing. Debug symbols for production call stack profiling is another sore point. https://pyroscope.io/ uses https://github.com/iovisor/bcc/blob/master/tools/profile.py under the hood. This script needs modified to properly annotate Rust call stacks. Is cargo build able to emit debug symbol files as part of the production build? https://wiki.ubuntu.com/Debug%20Symbol%20Packages Ideally one could get a coverage report from the production call stack traces too. |
@rustbot label A-code-coverage C-feature-request T-cargo |
Highly related: |
@rustbot transfer cargo |
This is a dupe of #13040, closing in favor of that |
The Rust unstable book includes some examples of the workflow for generating LLVM coverage reports using
-Z instrument-coverage
.Given the flexibility of this feature, having these detailed examples is useful, but there should be an "easy button" for generating coverage reports for the more common use cases. (I have some personal bash scripts to simplify the process during development, for example.)
cargo
can provide a great foundation for cross platform automation of Rust coverage analysis.Some loose requirements, off the top of my head, include:
cargo run
andcargo test
options. (Enabling the coverage report workflow will, therefore, probably be a flag option to these commands, versus a separate command, I think.)LLVM_PROFILE_FILE
, with the right filename patterns for filename deconfliction, and a path to a coverage-specific subdirectory of the target directory.profraw
,profdata
, and report data, before starting another coverage analysis (unless the user provides a flag option to retain old data).--persist-doctests
, and the workflow should automatically include the right test binaries when running thellvm-cov
command).llvm-cov
options in thecargo
command.llvm-cov
option configuration that generates a coverage report with minimalcargo
flags, and perhaps a few easy flags for other common configurations (for example, generating results as text, with ANSI terminal color highlights or not, or generating HTML, with files saved in the coverage target subdirectory with associatedprofraw
/profdata
files).cargo
Longer term:
profraw
data from multiple executions (being careful not to automatically delete data from prior runs when the user requests this feature).The text was updated successfully, but these errors were encountered: