about summary refs log tree commit diff
path: root/tests/run-make/rustdoc-scrape-examples-macros
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume.gomez@huawei.com>2024-05-22 11:47:32 +0200
committerGuillaume Gomez <guillaume.gomez@huawei.com>2024-05-22 11:49:21 +0200
commitfc76015dcb77ce86aa2df98c33a8e9cf36c16352 (patch)
tree37cda3fbd49cf352cfcc79bfdd90d8321da7e398 /tests/run-make/rustdoc-scrape-examples-macros
parentb54dd08a84f3c07efbc2aaf63c3df219ae680a03 (diff)
downloadrust-fc76015dcb77ce86aa2df98c33a8e9cf36c16352.tar.gz
rust-fc76015dcb77ce86aa2df98c33a8e9cf36c16352.zip
Migrate `run-make/rustdoc-scrape-examples-macros` to `rmake.rs`
Diffstat (limited to 'tests/run-make/rustdoc-scrape-examples-macros')
-rw-r--r--tests/run-make/rustdoc-scrape-examples-macros/Makefile19
-rw-r--r--tests/run-make/rustdoc-scrape-examples-macros/rmake.rs64
2 files changed, 64 insertions, 19 deletions
diff --git a/tests/run-make/rustdoc-scrape-examples-macros/Makefile b/tests/run-make/rustdoc-scrape-examples-macros/Makefile
deleted file mode 100644
index edc19d8cb5d..00000000000
--- a/tests/run-make/rustdoc-scrape-examples-macros/Makefile
+++ /dev/null
@@ -1,19 +0,0 @@
-# ignore-cross-compile
-include ../../run-make/tools.mk
-
-OUTPUT_DIR := "$(TMPDIR)/rustdoc"
-DYLIB_NAME := $(shell echo | $(RUSTC) --crate-name foobar_macro --crate-type dylib --print file-names -)
-
-all:
-	$(RUSTC) src/proc.rs --crate-name foobar_macro --edition=2021 --crate-type proc-macro --emit=dep-info,link
-
-	$(RUSTC) src/lib.rs --crate-name foobar --edition=2021 --crate-type lib --emit=dep-info,link
-
-	$(RUSTDOC) examples/ex.rs --crate-name ex --crate-type bin --output $(OUTPUT_DIR) \
-		--extern foobar=$(TMPDIR)/libfoobar.rlib --extern foobar_macro=$(TMPDIR)/$(DYLIB_NAME) \
-		-Z unstable-options --scrape-examples-output-path $(TMPDIR)/ex.calls --scrape-examples-target-crate foobar
-
-	$(RUSTDOC) src/lib.rs --crate-name foobar --crate-type lib --output $(OUTPUT_DIR) \
-		-Z unstable-options --with-examples $(TMPDIR)/ex.calls
-
-	$(HTMLDOCCK) $(OUTPUT_DIR) src/lib.rs
diff --git a/tests/run-make/rustdoc-scrape-examples-macros/rmake.rs b/tests/run-make/rustdoc-scrape-examples-macros/rmake.rs
new file mode 100644
index 00000000000..81b7defafc6
--- /dev/null
+++ b/tests/run-make/rustdoc-scrape-examples-macros/rmake.rs
@@ -0,0 +1,64 @@
+//@ ignore-cross-compile
+
+use run_make_support::{htmldocck, rustc, rustdoc, tmp_dir};
+
+fn main() {
+    let tmp_dir = tmp_dir();
+    let out_dir = tmp_dir.join("rustdoc");
+    let ex_dir = tmp_dir.join("ex.calls");
+    let proc_crate_name = "foobar_macro";
+    let crate_name = "foobar";
+
+    let dylib_name = String::from_utf8(
+        rustc()
+            .crate_name(proc_crate_name)
+            .crate_type("dylib")
+            .arg("--print")
+            .arg("file-names")
+            .arg("-")
+            .command_output()
+            .stdout,
+    )
+    .unwrap();
+
+    rustc()
+        .input("src/proc.rs")
+        .crate_name(proc_crate_name)
+        .edition("2021")
+        .crate_type("proc-macro")
+        .emit("dep-info,link")
+        .run();
+    rustc()
+        .input("src/lib.rs")
+        .crate_name(crate_name)
+        .edition("2021")
+        .crate_type("lib")
+        .emit("dep-info,link")
+        .run();
+
+    rustdoc()
+        .input("examples/ex.rs")
+        .crate_name("ex")
+        .crate_type("bin")
+        .output(&out_dir)
+        .extern_(crate_name, tmp_dir.join(format!("lib{crate_name}.rlib")))
+        .extern_(proc_crate_name, tmp_dir.join(dylib_name.trim()))
+        .arg("-Zunstable-options")
+        .arg("--scrape-examples-output-path")
+        .arg(&ex_dir)
+        .arg("--scrape-examples-target-crate")
+        .arg(crate_name)
+        .run();
+
+    rustdoc()
+        .input("src/lib.rs")
+        .crate_name(crate_name)
+        .crate_type("lib")
+        .output(&out_dir)
+        .arg("-Zunstable-options")
+        .arg("--with-examples")
+        .arg(&ex_dir)
+        .run();
+
+    assert!(htmldocck().arg(out_dir).arg("src/lib.rs").status().unwrap().success());
+}