about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2025-02-26 17:14:10 +0100
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2025-02-26 20:36:23 +0100
commitb97310c4491c989e74d42b48483626b988d1f5a6 (patch)
tree5456df3071a76b4fddf53ae92fe10fa5db8e9382
parent46a39f0b27f20848757b60e6d8caf274de7aefaa (diff)
downloadrust-b97310c4491c989e74d42b48483626b988d1f5a6.tar.gz
rust-b97310c4491c989e74d42b48483626b988d1f5a6.zip
Add run-make test for rustdoc `--emit=dep-info` option
-rw-r--r--tests/run-make/rustdoc-default-output/output-default.stdout2
-rw-r--r--tests/run-make/rustdoc-dep-info/bar.rs1
-rw-r--r--tests/run-make/rustdoc-dep-info/doc.md1
-rw-r--r--tests/run-make/rustdoc-dep-info/foo.rs1
-rw-r--r--tests/run-make/rustdoc-dep-info/lib.rs6
-rw-r--r--tests/run-make/rustdoc-dep-info/rmake.rs21
6 files changed, 31 insertions, 1 deletions
diff --git a/tests/run-make/rustdoc-default-output/output-default.stdout b/tests/run-make/rustdoc-default-output/output-default.stdout
index c1b246e849c..01f470f6e16 100644
--- a/tests/run-make/rustdoc-default-output/output-default.stdout
+++ b/tests/run-make/rustdoc-default-output/output-default.stdout
@@ -153,7 +153,7 @@ Options:
         --generate-redirect-map 
                         Generate JSON file at the top level instead of
                         generating HTML redirection files
-        --emit [unversioned-shared-resources,toolchain-shared-resources,invocation-specific]
+        --emit [unversioned-shared-resources,toolchain-shared-resources,invocation-specific,dep-info]
                         Comma separated list of types of output for rustdoc to
                         emit
         --no-run        Compile doctests without running them
diff --git a/tests/run-make/rustdoc-dep-info/bar.rs b/tests/run-make/rustdoc-dep-info/bar.rs
new file mode 100644
index 00000000000..76b8dcd05c8
--- /dev/null
+++ b/tests/run-make/rustdoc-dep-info/bar.rs
@@ -0,0 +1 @@
+include!("foo.rs");
diff --git a/tests/run-make/rustdoc-dep-info/doc.md b/tests/run-make/rustdoc-dep-info/doc.md
new file mode 100644
index 00000000000..6a4238fc8b6
--- /dev/null
+++ b/tests/run-make/rustdoc-dep-info/doc.md
@@ -0,0 +1 @@
+blablabla
diff --git a/tests/run-make/rustdoc-dep-info/foo.rs b/tests/run-make/rustdoc-dep-info/foo.rs
new file mode 100644
index 00000000000..b76b4321d62
--- /dev/null
+++ b/tests/run-make/rustdoc-dep-info/foo.rs
@@ -0,0 +1 @@
+pub fn foo() {}
diff --git a/tests/run-make/rustdoc-dep-info/lib.rs b/tests/run-make/rustdoc-dep-info/lib.rs
new file mode 100644
index 00000000000..1f003f79b1f
--- /dev/null
+++ b/tests/run-make/rustdoc-dep-info/lib.rs
@@ -0,0 +1,6 @@
+#![crate_name = "foo"]
+
+#[cfg_attr(doc, doc = include_str!("doc.md"))]
+pub struct Bar;
+
+mod bar;
diff --git a/tests/run-make/rustdoc-dep-info/rmake.rs b/tests/run-make/rustdoc-dep-info/rmake.rs
new file mode 100644
index 00000000000..6902bfc21ca
--- /dev/null
+++ b/tests/run-make/rustdoc-dep-info/rmake.rs
@@ -0,0 +1,21 @@
+// This is a simple smoke test for rustdoc's `--emit dep-info` feature. It prints out
+// information about dependencies in a Makefile-compatible format, as a `.d` file.
+
+use run_make_support::assertion_helpers::assert_contains;
+use run_make_support::{path, rfs, rustdoc};
+
+fn main() {
+    // We're only emitting dep info, so we shouldn't be running static analysis to
+    // figure out that this program is erroneous.
+    rustdoc().input("lib.rs").arg("-Zunstable-options").emit("dep-info").run();
+
+    let content = rfs::read_to_string("foo.d");
+    assert_contains(&content, "lib.rs:");
+    assert_contains(&content, "foo.rs:");
+    assert_contains(&content, "bar.rs:");
+    assert_contains(&content, "doc.md:");
+
+    // Now we check that we can provide a file name to the `dep-info` argument.
+    rustdoc().input("lib.rs").arg("-Zunstable-options").emit("dep-info=bla.d").run();
+    assert!(path("bla.d").exists());
+}