forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#85283 - Swatinem:ordered-profraw, r=tmandry
Avoid possible filename collision in coverage tests Previously, coverage tests were writing profiler data to files based on their pid. As rustdoc spawns each doctest as its own process, it might be possible in rare cases that a pid is being reused which would cause a file to be overwritten, leading to incorrect coverage results. should help with rust-lang#83262 r? `@tmandry`
- Loading branch information
Showing
1 changed file
with
8 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,7 +87,7 @@ endif | |
# Run it in order to generate some profiling data, | ||
# with `LLVM_PROFILE_FILE=<profdata_file>` environment variable set to | ||
# output the coverage stats for this run. | ||
LLVM_PROFILE_FILE="$(TMPDIR)"/$@-%p.profraw \ | ||
LLVM_PROFILE_FILE="$(TMPDIR)"/[email protected] \ | ||
$(call RUN,$@) || \ | ||
( \ | ||
status=$$?; \ | ||
|
@@ -97,16 +97,19 @@ endif | |
) \ | ||
) | ||
|
||
# Run it through rustdoc as well to cover doctests | ||
LLVM_PROFILE_FILE="$(TMPDIR)"/$@-%p.profraw \ | ||
# Run it through rustdoc as well to cover doctests. | ||
# `%p` is the pid, and `%m` the binary signature. We suspect that the pid alone | ||
# might result in overwritten files and failed tests, as rustdoc spawns each | ||
# doctest as its own process, so make sure the filename is as unique as possible. | ||
LLVM_PROFILE_FILE="$(TMPDIR)"/$@-%p-%m.profraw \ | ||
$(RUSTDOC) --crate-name workaround_for_79771 --test $(SOURCEDIR)/[email protected] \ | ||
$$( sed -n 's/^\/\/ compile-flags: \([^#]*\).*/\1/p' $(SOURCEDIR)/[email protected] ) \ | ||
-L "$(TMPDIR)" -Zinstrument-coverage \ | ||
-Z unstable-options --persist-doctests=$(TMPDIR)/rustdoc-$@ | ||
|
||
# Postprocess the profiling data so it can be used by the llvm-cov tool | ||
"$(LLVM_BIN_DIR)"/llvm-profdata merge --sparse \ | ||
"$(TMPDIR)"/$@-*.profraw \ | ||
"$(TMPDIR)"/$@*.profraw \ | ||
-o "$(TMPDIR)"/[email protected] | ||
|
||
# Generate a coverage report using `llvm-cov show`. | ||
|
@@ -118,8 +121,7 @@ endif | |
--instr-profile="$(TMPDIR)"/[email protected] \ | ||
$(call BIN,"$(TMPDIR)"/$@) \ | ||
$$( \ | ||
for file in $(TMPDIR)/rustdoc-$@/*/rust_out; \ | ||
do \ | ||
for file in $(TMPDIR)/rustdoc-$@/*/rust_out; do \ | ||
[ -x "$$file" ] && printf "%s %s " -object $$file; \ | ||
done \ | ||
) \ | ||
|