Add support for compile-flags in coverage tests

This commit is contained in:
Tomasz Miąsko 2021-03-15 00:00:00 +00:00
parent ad8f9af7cb
commit 4b6cc0c204
3 changed files with 6 additions and 10 deletions

View File

@ -82,13 +82,13 @@ endif
%: $(SOURCEDIR)/lib/%.rs
# Compile the test library with coverage instrumentation
$(RUSTC) $(SOURCEDIR)/lib/$@.rs \
$$( grep -q '^\/\/ require-rust-edition-2018' $(SOURCEDIR)/lib/$@.rs && echo "--edition=2018" ) \
$$( sed -nE 's#^// compile-flags:(.*)#\1# p' $(SOURCEDIR)/lib/$@.rs) \
--crate-type rlib -Zinstrument-coverage
%: $(SOURCEDIR)/%.rs
# Compile the test program with coverage instrumentation
$(RUSTC) $(SOURCEDIR)/$@.rs \
$$( grep -q '^\/\/ require-rust-edition-2018' $(SOURCEDIR)/$@.rs && echo "--edition=2018" ) \
$$( sed -nE 's#^// compile-flags:(.*)#\1# p' $(SOURCEDIR)/$@.rs) \
-L "$(TMPDIR)" -Zinstrument-coverage
# Run it in order to generate some profiling data,
@ -107,7 +107,7 @@ endif
# Run it through rustdoc as well to cover doctests
LLVM_PROFILE_FILE="$(TMPDIR)"/$@-%p.profraw \
$(RUSTDOC) --crate-name workaround_for_79771 --test $(SOURCEDIR)/$@.rs \
$$( grep -q '^\/\/ require-rust-edition-2018' $(SOURCEDIR)/$@.rs && echo "--edition=2018" ) \
$$( sed -nE 's#^// compile-flags:(.*)#\1# p' $(SOURCEDIR)/$@.rs) \
-L "$(TMPDIR)" -Zinstrument-coverage \
-Z unstable-options --persist-doctests=$(TMPDIR)/rustdoc-$@

View File

@ -38,9 +38,7 @@ endif
%: $(SOURCEDIR)/lib/%.rs
# Compile the test library with coverage instrumentation
$(RUSTC) $(SOURCEDIR)/lib/$@.rs \
$$( grep -q '^\/\/ require-rust-edition-2018' $(SOURCEDIR)/lib/$@.rs && \
echo "--edition=2018" \
) \
$$( sed -nE 's#^// compile-flags:(.*)#\1# p' $(SOURCEDIR)/lib/$@.rs) \
--crate-type rlib \
-Ztrim-diagnostic-paths=no \
-Zinstrument-coverage \
@ -70,9 +68,7 @@ endif
%: $(SOURCEDIR)/%.rs
# Compile the test program with coverage instrumentation
$(RUSTC) $(SOURCEDIR)/$@.rs \
$$( grep -q '^\/\/ require-rust-edition-2018' $(SOURCEDIR)/$@.rs && \
echo "--edition=2018" \
) \
$$( sed -nE 's#^// compile-flags:(.*)#\1# p' $(SOURCEDIR)/$@.rs) \
-L "$(TMPDIR)" \
-Ztrim-diagnostic-paths=no \
-Zinstrument-coverage \

View File

@ -1,6 +1,6 @@
#![allow(unused_assignments, dead_code)]
// require-rust-edition-2018
// compile-flags: --edition=2018
async fn c(x: u8) -> u8 {
if x == 8 {