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 %: $(SOURCEDIR)/lib/%.rs
# Compile the test library with coverage instrumentation # Compile the test library with coverage instrumentation
$(RUSTC) $(SOURCEDIR)/lib/$@.rs \ $(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 --crate-type rlib -Zinstrument-coverage
%: $(SOURCEDIR)/%.rs %: $(SOURCEDIR)/%.rs
# Compile the test program with coverage instrumentation # Compile the test program with coverage instrumentation
$(RUSTC) $(SOURCEDIR)/$@.rs \ $(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 -L "$(TMPDIR)" -Zinstrument-coverage
# Run it in order to generate some profiling data, # Run it in order to generate some profiling data,
@ -107,7 +107,7 @@ endif
# Run it through rustdoc as well to cover doctests # Run it through rustdoc as well to cover doctests
LLVM_PROFILE_FILE="$(TMPDIR)"/$@-%p.profraw \ LLVM_PROFILE_FILE="$(TMPDIR)"/$@-%p.profraw \
$(RUSTDOC) --crate-name workaround_for_79771 --test $(SOURCEDIR)/$@.rs \ $(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 \ -L "$(TMPDIR)" -Zinstrument-coverage \
-Z unstable-options --persist-doctests=$(TMPDIR)/rustdoc-$@ -Z unstable-options --persist-doctests=$(TMPDIR)/rustdoc-$@

View File

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

View File

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