Skip to content

Commit 01e930f

Browse files
committed
Add tests for "doc --all"
These are basically the same as the ones from "test --all" and "build --all"
1 parent 067eb28 commit 01e930f

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed

tests/doc.rs

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::fs;
66

77
use cargotest::{is_nightly, rustc_host};
88
use cargotest::support::{project, execs, path2url};
9+
use cargotest::support::registry::Package;
910
use hamcrest::{assert_that, existing_file, existing_dir, is_not};
1011

1112
#[test]
@@ -612,3 +613,97 @@ fn plugins_no_use_target() {
612613
.arg("-v"),
613614
execs().with_status(0));
614615
}
616+
617+
#[test]
618+
fn doc_all_workspace() {
619+
let p = project("foo")
620+
.file("Cargo.toml", r#"
621+
[project]
622+
name = "foo"
623+
version = "0.1.0"
624+
625+
[dependencies]
626+
bar = { path = "bar" }
627+
628+
[workspace]
629+
"#)
630+
.file("src/main.rs", r#"
631+
fn main() {}
632+
"#)
633+
.file("bar/Cargo.toml", r#"
634+
[project]
635+
name = "bar"
636+
version = "0.1.0"
637+
"#)
638+
.file("bar/src/lib.rs", r#"
639+
pub fn bar() {}
640+
"#);
641+
p.build();
642+
643+
// The order in which bar is compiled or documented is not deterministic
644+
assert_that(p.cargo_process("doc")
645+
.arg("--all"),
646+
execs().with_stderr_contains("[..] Documenting bar v0.1.0 ([..])")
647+
.with_stderr_contains("[..] Compiling bar v0.1.0 ([..])")
648+
.with_stderr_contains("[..] Documenting foo v0.1.0 ([..])"));
649+
}
650+
651+
#[test]
652+
fn doc_all_virtual_manifest() {
653+
let p = project("workspace")
654+
.file("Cargo.toml", r#"
655+
[workspace]
656+
members = ["foo", "bar"]
657+
"#)
658+
.file("foo/Cargo.toml", r#"
659+
[project]
660+
name = "foo"
661+
version = "0.1.0"
662+
"#)
663+
.file("foo/src/lib.rs", r#"
664+
pub fn foo() {}
665+
"#)
666+
.file("bar/Cargo.toml", r#"
667+
[project]
668+
name = "bar"
669+
version = "0.1.0"
670+
"#)
671+
.file("bar/src/lib.rs", r#"
672+
pub fn bar() {}
673+
"#);
674+
p.build();
675+
676+
// The order in which foo and bar are documented is not guaranteed
677+
assert_that(p.cargo_process("doc")
678+
.arg("--all"),
679+
execs().with_stderr_contains("[..] Documenting bar v0.1.0 ([..])")
680+
.with_stderr_contains("[..] Documenting foo v0.1.0 ([..])"));
681+
}
682+
683+
#[test]
684+
fn doc_all_member_dependency_same_name() {
685+
let p = project("workspace")
686+
.file("Cargo.toml", r#"
687+
[workspace]
688+
members = ["a"]
689+
"#)
690+
.file("a/Cargo.toml", r#"
691+
[project]
692+
name = "a"
693+
version = "0.1.0"
694+
695+
[dependencies]
696+
a = "0.1.0"
697+
"#)
698+
.file("a/src/lib.rs", r#"
699+
pub fn a() {}
700+
"#);
701+
p.build();
702+
703+
Package::new("a", "0.1.0").publish();
704+
705+
assert_that(p.cargo_process("doc")
706+
.arg("--all"),
707+
execs().with_stderr_contains("[..] Updating registry `[..]`")
708+
.with_stderr_contains("[..] Documenting a v0.1.0 ([..])"));
709+
}

0 commit comments

Comments
 (0)