about summary refs log tree commit diff
diff options
context:
space:
mode:
authorWill Crichton <wcrichto@cs.stanford.edu>2021-10-08 20:49:05 -0700
committerWill Crichton <wcrichto@cs.stanford.edu>2021-10-08 20:49:05 -0700
commitb1616f34efc5bc0d0328c1bba94176c62be2b3d0 (patch)
tree159bf117f5a97edb7569c99731b87db3de404e3d
parent9e4958a3e6c48630b777244adad80d1381ada32a (diff)
downloadrust-b1616f34efc5bc0d0328c1bba94176c62be2b3d0.tar.gz
rust-b1616f34efc5bc0d0328c1bba94176c62be2b3d0.zip
Add test for ordering of examples, simplify with single scrape.mk file
-rw-r--r--src/test/run-make/rustdoc-scrape-examples-multiple/Makefile22
-rw-r--r--src/test/run-make/rustdoc-scrape-examples-multiple/scrape.mk20
-rw-r--r--src/test/run-make/rustdoc-scrape-examples-multiple/src/lib.rs2
-rw-r--r--src/test/run-make/rustdoc-scrape-examples-ordering/Makefile5
-rw-r--r--src/test/run-make/rustdoc-scrape-examples-ordering/examples/ex1.rs9
-rw-r--r--src/test/run-make/rustdoc-scrape-examples-ordering/examples/ex2.rs4
-rw-r--r--src/test/run-make/rustdoc-scrape-examples-ordering/src/lib.rs4
-rw-r--r--src/test/run-make/rustdoc-scrape-examples-remap/Makefile23
8 files changed, 49 insertions, 40 deletions
diff --git a/src/test/run-make/rustdoc-scrape-examples-multiple/Makefile b/src/test/run-make/rustdoc-scrape-examples-multiple/Makefile
index 68d78ae3017..897805e4405 100644
--- a/src/test/run-make/rustdoc-scrape-examples-multiple/Makefile
+++ b/src/test/run-make/rustdoc-scrape-examples-multiple/Makefile
@@ -1,21 +1,5 @@
--include ../../run-make-fulldeps/tools.mk
+deps := ex ex2
 
-OUTPUT_DIR := "$(TMPDIR)/rustdoc"
+-include ./scrape.mk
 
-all: $(TMPDIR)/ex.calls $(TMPDIR)/ex2.calls
-	$(RUSTDOC) src/lib.rs --crate-name foobar --crate-type lib --output $(OUTPUT_DIR) \
-		-Z unstable-options \
-		--with-examples $(TMPDIR)/ex.calls \
-		--with-examples $(TMPDIR)/ex2.calls
-
-	$(HTMLDOCCK) $(OUTPUT_DIR) src/lib.rs
-
-$(TMPDIR)/%.calls: $(TMPDIR)/libfoobar.rmeta
-	$(RUSTDOC) examples/$*.rs --crate-name $* --crate-type bin --output $(OUTPUT_DIR) \
-	  --extern foobar=$(TMPDIR)/libfoobar.rmeta \
-		-Z unstable-options \
-		--scrape-examples-output-path $@ \
-		--scrape-examples-target-crate foobar
-
-$(TMPDIR)/lib%.rmeta: src/lib.rs
-	$(RUSTC) src/lib.rs --crate-name $* --crate-type lib --emit=metadata
+all: scrape
diff --git a/src/test/run-make/rustdoc-scrape-examples-multiple/scrape.mk b/src/test/run-make/rustdoc-scrape-examples-multiple/scrape.mk
new file mode 100644
index 00000000000..1fa1fae1a0b
--- /dev/null
+++ b/src/test/run-make/rustdoc-scrape-examples-multiple/scrape.mk
@@ -0,0 +1,20 @@
+-include ../../run-make-fulldeps/tools.mk
+
+OUTPUT_DIR := "$(TMPDIR)/rustdoc"
+
+$(TMPDIR)/%.calls: $(TMPDIR)/libfoobar.rmeta
+	$(RUSTDOC) examples/$*.rs --crate-name $* --crate-type bin --output $(OUTPUT_DIR) \
+	  --extern foobar=$(TMPDIR)/libfoobar.rmeta \
+		-Z unstable-options \
+		--scrape-examples-output-path $@ \
+		--scrape-examples-target-crate foobar
+
+$(TMPDIR)/lib%.rmeta: src/lib.rs
+	$(RUSTC) src/lib.rs --crate-name $* --crate-type lib --emit=metadata
+
+scrape: $(foreach d,$(deps),$(TMPDIR)/$(d).calls)
+	$(RUSTDOC) src/lib.rs --crate-name foobar --crate-type lib --output $(OUTPUT_DIR) \
+		-Z unstable-options \
+		$(foreach d,$(deps),--with-examples $(TMPDIR)/$(d).calls)
+
+	$(HTMLDOCCK) $(OUTPUT_DIR) src/lib.rs
diff --git a/src/test/run-make/rustdoc-scrape-examples-multiple/src/lib.rs b/src/test/run-make/rustdoc-scrape-examples-multiple/src/lib.rs
index b26122a37e2..bd59584bbbf 100644
--- a/src/test/run-make/rustdoc-scrape-examples-multiple/src/lib.rs
+++ b/src/test/run-make/rustdoc-scrape-examples-multiple/src/lib.rs
@@ -1,4 +1,4 @@
-// @has foobar/fn.ok.html '//*[@class="prev"]' ''
+// @has foobar/fn.ok.html '//*[@class="docblock scraped-example-list"]//*[@class="prev"]' ''
 // @has foobar/fn.ok.html '//*[@class="more-scraped-examples"]' ''
 
 pub fn ok() {}
diff --git a/src/test/run-make/rustdoc-scrape-examples-ordering/Makefile b/src/test/run-make/rustdoc-scrape-examples-ordering/Makefile
new file mode 100644
index 00000000000..339d539bfd5
--- /dev/null
+++ b/src/test/run-make/rustdoc-scrape-examples-ordering/Makefile
@@ -0,0 +1,5 @@
+deps := ex1 ex2
+
+-include ../rustdoc-scrape-examples-multiple/scrape.mk
+
+all: scrape
diff --git a/src/test/run-make/rustdoc-scrape-examples-ordering/examples/ex1.rs b/src/test/run-make/rustdoc-scrape-examples-ordering/examples/ex1.rs
new file mode 100644
index 00000000000..d6d59820876
--- /dev/null
+++ b/src/test/run-make/rustdoc-scrape-examples-ordering/examples/ex1.rs
@@ -0,0 +1,9 @@
+fn main() {
+    foobar::ok();
+
+    // this is a
+
+    // BIG
+
+    // item
+}
diff --git a/src/test/run-make/rustdoc-scrape-examples-ordering/examples/ex2.rs b/src/test/run-make/rustdoc-scrape-examples-ordering/examples/ex2.rs
new file mode 100644
index 00000000000..a1133117f86
--- /dev/null
+++ b/src/test/run-make/rustdoc-scrape-examples-ordering/examples/ex2.rs
@@ -0,0 +1,4 @@
+fn main() {
+    foobar::ok();
+    // small item
+}
diff --git a/src/test/run-make/rustdoc-scrape-examples-ordering/src/lib.rs b/src/test/run-make/rustdoc-scrape-examples-ordering/src/lib.rs
new file mode 100644
index 00000000000..f1b7686d368
--- /dev/null
+++ b/src/test/run-make/rustdoc-scrape-examples-ordering/src/lib.rs
@@ -0,0 +1,4 @@
+// @has foobar/fn.ok.html '//*[@class="docblock scraped-example-list"]' 'ex2'
+// @has foobar/fn.ok.html '//*[@class="more-scraped-examples"]' 'ex1'
+
+pub fn ok() {}
diff --git a/src/test/run-make/rustdoc-scrape-examples-remap/Makefile b/src/test/run-make/rustdoc-scrape-examples-remap/Makefile
index 9903c87be23..dce8b83eefe 100644
--- a/src/test/run-make/rustdoc-scrape-examples-remap/Makefile
+++ b/src/test/run-make/rustdoc-scrape-examples-remap/Makefile
@@ -1,22 +1,5 @@
--include ../../run-make-fulldeps/tools.mk
+deps := ex
 
-OUTPUT_DIR := "$(TMPDIR)/rustdoc"
+-include ../rustdoc-scrape-examples-multiple/scrape.mk
 
-all:
-# 1. compile the library crate and emit an rmeta
-	$(RUSTC) src/lib.rs --crate-name foobar --crate-type lib --emit=metadata
-
-# 2. scrape examples from the reverse-dependency into an ex.calls file
-	$(RUSTDOC) examples/ex.rs --crate-name ex --crate-type bin --output $(OUTPUT_DIR) \
-	  --extern foobar=$(TMPDIR)/libfoobar.rmeta \
-		-Z unstable-options \
-		--scrape-examples-output-path $(TMPDIR)/ex.calls \
-		--scrape-examples-target-crate foobar
-
-# 3. pass those examples to rustdoc when documenting the library crate
-	$(RUSTDOC) src/lib.rs --crate-name foobar --crate-type lib --output $(OUTPUT_DIR) \
-		-Z unstable-options \
-		--with-examples $(TMPDIR)/ex.calls
-
-# 4. check that the examples were scraped successfully
-	$(HTMLDOCCK) $(OUTPUT_DIR) src/lib.rs
+all: scrape