Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions tests/testsuite/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1062,55 +1062,56 @@ fn features() {
bar = []
"#,
)
.file(
"bar/build.rs",
r#"
fn main() {
println!("cargo::rustc-cfg=bar");
}
"#,
)
.file(
"bar/src/lib.rs",
r#"#[cfg(feature = "bar")] pub fn bar() {}"#,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Looking at #2050, I'm wondering if this was just a mistake in the original test where this should have been:

Suggested change
r#"#[cfg(feature = "bar")] pub fn bar() {}"#,
r#"#[cfg(bar)] pub fn bar() {}"#,

Since the thing that PR was introducing was the ability for rustc-cfg directives to propagate to rustdoc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard to tell because there are other tests that do use rustc-cfg in the build script tests which we still have today. The name of this one is focused on features so I would assume that is what it is for.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to say, it also has the appearance of being a copy/paste bug from the build script tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yea, I see. Yea, hard to tell, but this seems right.

)
.build();
p.cargo("doc --features foo")
.with_stderr_data(str![[r#"
.with_stderr_data(
str![[r#"
[LOCKING] 1 package to latest compatible version
[COMPILING] bar v0.0.1 ([ROOT]/foo/bar)
[CHECKING] bar v0.0.1 ([ROOT]/foo/bar)
[DOCUMENTING] bar v0.0.1 ([ROOT]/foo/bar)
[DOCUMENTING] foo v0.0.1 ([ROOT]/foo)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
[GENERATED] [ROOT]/foo/target/doc/foo/index.html

"#]])
"#]]
.unordered(),
)
.run();
assert!(p.root().join("target/doc").is_dir());
assert!(p.root().join("target/doc/foo/fn.foo.html").is_file());
assert!(p.root().join("target/doc/bar/fn.bar.html").is_file());
// Check that turning the feature off will remove the files.
p.cargo("doc")
.with_stderr_data(str![[r#"
[COMPILING] bar v0.0.1 ([ROOT]/foo/bar)
.with_stderr_data(
str![[r#"
[CHECKING] bar v0.0.1 ([ROOT]/foo/bar)
[DOCUMENTING] bar v0.0.1 ([ROOT]/foo/bar)
[DOCUMENTING] foo v0.0.1 ([ROOT]/foo)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
[GENERATED] [ROOT]/foo/target/doc/foo/index.html

"#]])
"#]]
.unordered(),
)
.run();
assert!(!p.root().join("target/doc/foo/fn.foo.html").is_file());
assert!(!p.root().join("target/doc/bar/fn.bar.html").is_file());
// And switching back will rebuild and bring them back.
p.cargo("doc --features foo")
.with_stderr_data(str![[r#"
.with_stderr_data(
str![[r#"
[DOCUMENTING] bar v0.0.1 ([ROOT]/foo/bar)
[DOCUMENTING] foo v0.0.1 ([ROOT]/foo)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
[GENERATED] [ROOT]/foo/target/doc/foo/index.html

"#]])
"#]]
.unordered(),
)
.run();
assert!(p.root().join("target/doc/foo/fn.foo.html").is_file());
assert!(p.root().join("target/doc/bar/fn.bar.html").is_file());
Expand Down