Skip to content

Commit

Permalink
Add run-make test for rustdoc --emit=dep-info option
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Feb 26, 2025
1 parent 46a39f0 commit b97310c
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/run-make/rustdoc-dep-info/bar.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include!("foo.rs");
1 change: 1 addition & 0 deletions tests/run-make/rustdoc-dep-info/doc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blablabla
1 change: 1 addition & 0 deletions tests/run-make/rustdoc-dep-info/foo.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub fn foo() {}
6 changes: 6 additions & 0 deletions tests/run-make/rustdoc-dep-info/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#![crate_name = "foo"]

#[cfg_attr(doc, doc = include_str!("doc.md"))]
pub struct Bar;

mod bar;
21 changes: 21 additions & 0 deletions tests/run-make/rustdoc-dep-info/rmake.rs
Original file line number Diff line number Diff line change
@@ -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());
}

0 comments on commit b97310c

Please sign in to comment.