about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTomasz Miąsko <tomasz.miasko@gmail.com>2021-03-15 00:00:00 +0000
committerTomasz Miąsko <tomasz.miasko@gmail.com>2021-03-15 23:26:03 +0100
commit4b6cc0c20488a598b97f887cbc747aee61bee7df (patch)
treee6f978b52732510c15e2b55290be5ad716595195
parentad8f9af7cbeae48db0606cb5e39cbc04e5e35789 (diff)
downloadrust-4b6cc0c20488a598b97f887cbc747aee61bee7df.tar.gz
rust-4b6cc0c20488a598b97f887cbc747aee61bee7df.zip
Add support for compile-flags in coverage tests
-rw-r--r--src/test/run-make-fulldeps/coverage-reports/Makefile6
-rw-r--r--src/test/run-make-fulldeps/coverage-spanview/Makefile8
-rw-r--r--src/test/run-make-fulldeps/coverage/async.rs2
3 files changed, 6 insertions, 10 deletions
diff --git a/src/test/run-make-fulldeps/coverage-reports/Makefile b/src/test/run-make-fulldeps/coverage-reports/Makefile
index 31583eaa8fe..af75ec5e24d 100644
--- a/src/test/run-make-fulldeps/coverage-reports/Makefile
+++ b/src/test/run-make-fulldeps/coverage-reports/Makefile
@@ -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-$@
 
diff --git a/src/test/run-make-fulldeps/coverage-spanview/Makefile b/src/test/run-make-fulldeps/coverage-spanview/Makefile
index cd54ac0ed4c..b0bfa7074db 100644
--- a/src/test/run-make-fulldeps/coverage-spanview/Makefile
+++ b/src/test/run-make-fulldeps/coverage-spanview/Makefile
@@ -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 \
diff --git a/src/test/run-make-fulldeps/coverage/async.rs b/src/test/run-make-fulldeps/coverage/async.rs
index 5553af92465..d5ec32deac1 100644
--- a/src/test/run-make-fulldeps/coverage/async.rs
+++ b/src/test/run-make-fulldeps/coverage/async.rs
@@ -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 {