Skip to content

Commit

Permalink
Add tests for "doc --all"
Browse files Browse the repository at this point in the history
These are basically the same as the ones from "test --all" and "build --all"
  • Loading branch information
sdroege committed Jan 8, 2017
1 parent 067eb28 commit 01e930f
Showing 1 changed file with 95 additions and 0 deletions.
95 changes: 95 additions & 0 deletions tests/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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 ([..])"));
}

#[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 ([..])"));
}

0 comments on commit 01e930f

Please sign in to comment.