-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for documenting all members of the workspace with "doc --all" #3515
Changes from 2 commits
067eb28
01e930f
9576b31
b850c25
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ use std::fs; | |
|
||
use cargotest::{is_nightly, rustc_host}; | ||
use cargotest::support::{project, execs, path2url}; | ||
use cargotest::support::registry::Package; | ||
use hamcrest::{assert_that, existing_file, existing_dir, is_not}; | ||
|
||
#[test] | ||
|
@@ -612,3 +613,97 @@ fn plugins_no_use_target() { | |
.arg("-v"), | ||
execs().with_status(0)); | ||
} | ||
|
||
#[test] | ||
fn doc_all_workspace() { | ||
let p = project("foo") | ||
.file("Cargo.toml", r#" | ||
[project] | ||
name = "foo" | ||
version = "0.1.0" | ||
|
||
[dependencies] | ||
bar = { path = "bar" } | ||
|
||
[workspace] | ||
"#) | ||
.file("src/main.rs", r#" | ||
fn main() {} | ||
"#) | ||
.file("bar/Cargo.toml", r#" | ||
[project] | ||
name = "bar" | ||
version = "0.1.0" | ||
"#) | ||
.file("bar/src/lib.rs", r#" | ||
pub fn bar() {} | ||
"#); | ||
p.build(); | ||
|
||
// The order in which bar is compiled or documented is not deterministic | ||
assert_that(p.cargo_process("doc") | ||
.arg("--all"), | ||
execs().with_stderr_contains("[..] Documenting bar v0.1.0 ([..])") | ||
.with_stderr_contains("[..] Compiling bar v0.1.0 ([..])") | ||
.with_stderr_contains("[..] Documenting foo v0.1.0 ([..])")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, but shouldn't this also be added to the "build --all" test? I'll send another pull request for the change of the other test then There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess it would be "nice" but not necessary, as for building the test checks for the "finished successfully" line in the output There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yeah it's true I should have caught it on that PR! Want to send another PR for that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, will send something for that tomorrow :) |
||
} | ||
|
||
#[test] | ||
fn doc_all_virtual_manifest() { | ||
let p = project("workspace") | ||
.file("Cargo.toml", r#" | ||
[workspace] | ||
members = ["foo", "bar"] | ||
"#) | ||
.file("foo/Cargo.toml", r#" | ||
[project] | ||
name = "foo" | ||
version = "0.1.0" | ||
"#) | ||
.file("foo/src/lib.rs", r#" | ||
pub fn foo() {} | ||
"#) | ||
.file("bar/Cargo.toml", r#" | ||
[project] | ||
name = "bar" | ||
version = "0.1.0" | ||
"#) | ||
.file("bar/src/lib.rs", r#" | ||
pub fn bar() {} | ||
"#); | ||
p.build(); | ||
|
||
// The order in which foo and bar are documented is not guaranteed | ||
assert_that(p.cargo_process("doc") | ||
.arg("--all"), | ||
execs().with_stderr_contains("[..] Documenting bar v0.1.0 ([..])") | ||
.with_stderr_contains("[..] Documenting foo v0.1.0 ([..])")); | ||
} | ||
|
||
#[test] | ||
fn doc_all_member_dependency_same_name() { | ||
let p = project("workspace") | ||
.file("Cargo.toml", r#" | ||
[workspace] | ||
members = ["a"] | ||
"#) | ||
.file("a/Cargo.toml", r#" | ||
[project] | ||
name = "a" | ||
version = "0.1.0" | ||
|
||
[dependencies] | ||
a = "0.1.0" | ||
"#) | ||
.file("a/src/lib.rs", r#" | ||
pub fn a() {} | ||
"#); | ||
p.build(); | ||
|
||
Package::new("a", "0.1.0").publish(); | ||
|
||
assert_that(p.cargo_process("doc") | ||
.arg("--all"), | ||
execs().with_stderr_contains("[..] Updating registry `[..]`") | ||
.with_stderr_contains("[..] Documenting a v0.1.0 ([..])")); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this may actually work best if we remove this condition. I don't quite recall why it exists, but I think it's best if we execute the below logic for all packages, not just the root package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I only kept it because I thought someone probably had a reason for having done that and I just don't understand the reason :)