Skip to content

Commit 4b6cc0c

Browse files
committed
Add support for compile-flags in coverage tests
1 parent ad8f9af commit 4b6cc0c

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

src/test/run-make-fulldeps/coverage-reports/Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ endif
8282
%: $(SOURCEDIR)/lib/%.rs
8383
# Compile the test library with coverage instrumentation
8484
$(RUSTC) $(SOURCEDIR)/lib/$@.rs \
85-
$$( grep -q '^\/\/ require-rust-edition-2018' $(SOURCEDIR)/lib/$@.rs && echo "--edition=2018" ) \
85+
$$( sed -nE 's#^// compile-flags:(.*)#\1# p' $(SOURCEDIR)/lib/$@.rs) \
8686
--crate-type rlib -Zinstrument-coverage
8787

8888
%: $(SOURCEDIR)/%.rs
8989
# Compile the test program with coverage instrumentation
9090
$(RUSTC) $(SOURCEDIR)/$@.rs \
91-
$$( grep -q '^\/\/ require-rust-edition-2018' $(SOURCEDIR)/$@.rs && echo "--edition=2018" ) \
91+
$$( sed -nE 's#^// compile-flags:(.*)#\1# p' $(SOURCEDIR)/$@.rs) \
9292
-L "$(TMPDIR)" -Zinstrument-coverage
9393

9494
# Run it in order to generate some profiling data,
@@ -107,7 +107,7 @@ endif
107107
# Run it through rustdoc as well to cover doctests
108108
LLVM_PROFILE_FILE="$(TMPDIR)"/$@-%p.profraw \
109109
$(RUSTDOC) --crate-name workaround_for_79771 --test $(SOURCEDIR)/$@.rs \
110-
$$( grep -q '^\/\/ require-rust-edition-2018' $(SOURCEDIR)/$@.rs && echo "--edition=2018" ) \
110+
$$( sed -nE 's#^// compile-flags:(.*)#\1# p' $(SOURCEDIR)/$@.rs) \
111111
-L "$(TMPDIR)" -Zinstrument-coverage \
112112
-Z unstable-options --persist-doctests=$(TMPDIR)/rustdoc-$@
113113

src/test/run-make-fulldeps/coverage-spanview/Makefile

+2-6
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ endif
3838
%: $(SOURCEDIR)/lib/%.rs
3939
# Compile the test library with coverage instrumentation
4040
$(RUSTC) $(SOURCEDIR)/lib/$@.rs \
41-
$$( grep -q '^\/\/ require-rust-edition-2018' $(SOURCEDIR)/lib/$@.rs && \
42-
echo "--edition=2018" \
43-
) \
41+
$$( sed -nE 's#^// compile-flags:(.*)#\1# p' $(SOURCEDIR)/lib/$@.rs) \
4442
--crate-type rlib \
4543
-Ztrim-diagnostic-paths=no \
4644
-Zinstrument-coverage \
@@ -70,9 +68,7 @@ endif
7068
%: $(SOURCEDIR)/%.rs
7169
# Compile the test program with coverage instrumentation
7270
$(RUSTC) $(SOURCEDIR)/$@.rs \
73-
$$( grep -q '^\/\/ require-rust-edition-2018' $(SOURCEDIR)/$@.rs && \
74-
echo "--edition=2018" \
75-
) \
71+
$$( sed -nE 's#^// compile-flags:(.*)#\1# p' $(SOURCEDIR)/$@.rs) \
7672
-L "$(TMPDIR)" \
7773
-Ztrim-diagnostic-paths=no \
7874
-Zinstrument-coverage \

src/test/run-make-fulldeps/coverage/async.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![allow(unused_assignments, dead_code)]
22

3-
// require-rust-edition-2018
3+
// compile-flags: --edition=2018
44

55
async fn c(x: u8) -> u8 {
66
if x == 8 {

0 commit comments

Comments
 (0)