diff --git a/crates/cargo-test-support/src/compare.rs b/crates/cargo-test-support/src/compare.rs index 154938ad57bb..d9e8d5454d0d 100644 --- a/crates/cargo-test-support/src/compare.rs +++ b/crates/cargo-test-support/src/compare.rs @@ -237,6 +237,7 @@ fn substitute_macros(input: &str) -> String { ("[WAITING]", " Waiting"), ("[PUBLISHED]", " Published"), ("[BLOCKING]", " Blocking"), + ("[GENERATED]", " Generated"), ]; let mut result = input.to_owned(); for &(pat, subst) in ¯os { diff --git a/src/cargo/ops/cargo_doc.rs b/src/cargo/ops/cargo_doc.rs index afa6ac327d85..0eda728ab836 100644 --- a/src/cargo/ops/cargo_doc.rs +++ b/src/cargo/ops/cargo_doc.rs @@ -19,12 +19,9 @@ pub struct DocOptions { pub fn doc(ws: &Workspace<'_>, options: &DocOptions) -> CargoResult<()> { let compilation = ops::compile(ws, &options.compile_opts)?; - if options.open_result { - let name = &compilation - .root_crate_names - .get(0) - .ok_or_else(|| anyhow::anyhow!("no crates with documentation"))?; - let kind = options.compile_opts.build_config.single_requested_kind()?; + let kind = options.compile_opts.build_config.single_requested_kind()?; + let mut opened = false; + for name in &compilation.root_crate_names { let path = compilation.root_output[&kind] .with_file_name("doc") .join(&name) @@ -36,10 +33,20 @@ pub fn doc(ws: &Workspace<'_>, options: &DocOptions) -> CargoResult<()> { }; let mut shell = ws.config().shell(); - shell.status("Opening", path.display())?; - open_docs(&path, &mut shell, config_browser, ws.config())?; + if options.open_result { + shell.status("Opening", path.display())?; + open_docs(&path, &mut shell, config_browser, ws.config())?; + opened = true; + // User can navigate to the other crates + break; + } else { + shell.status("Generated", path.display())?; + } } } + if options.open_result && !opened { + anyhow::bail!("no crates with documentation"); + } Ok(()) } diff --git a/tests/testsuite/artifact_dep.rs b/tests/testsuite/artifact_dep.rs index 64aa9d8afbc2..c512987358cd 100644 --- a/tests/testsuite/artifact_dep.rs +++ b/tests/testsuite/artifact_dep.rs @@ -2152,6 +2152,7 @@ fn doc_lib_true() { [DOCUMENTING] bar v0.0.1 ([CWD]/bar) [DOCUMENTING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/foo/index.html ", ) .run(); @@ -2227,6 +2228,7 @@ fn rustdoc_works_on_libs_with_artifacts_and_lib_false() { [COMPILING] bar v0.5.0 ([CWD]/bar) [DOCUMENTING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/foo/index.html ", ) .run(); diff --git a/tests/testsuite/build_script.rs b/tests/testsuite/build_script.rs index 72a5fb648aa5..408ce6457ade 100644 --- a/tests/testsuite/build_script.rs +++ b/tests/testsuite/build_script.rs @@ -1471,6 +1471,7 @@ fn testing_and_such() { [DOCUMENTING] foo v0.5.0 ([CWD]) [RUNNING] `rustdoc [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/foo/index.html ", ) .run(); diff --git a/tests/testsuite/collisions.rs b/tests/testsuite/collisions.rs index 77e05dd9c6d6..ce54ebc8e46e 100644 --- a/tests/testsuite/collisions.rs +++ b/tests/testsuite/collisions.rs @@ -202,6 +202,7 @@ fn collision_doc_multiple_versions() { [DOCUMENTING] bar v2.0.0 [FINISHED] [..] [DOCUMENTING] foo v0.1.0 [..] +[GENERATED] [CWD]/target/doc/foo/index.html ", ) .run(); @@ -384,6 +385,7 @@ fn collision_doc_profile_split() { [DOCUMENTING] pm v0.1.0 [..] [DOCUMENTING] foo v0.1.0 [..] [FINISHED] [..] +[GENERATED] [CWD]/target/doc/foo/index.html ", ) .run(); @@ -430,6 +432,7 @@ the same path; see . [CHECKING] bar v1.0.0 [DOCUMENTING] foo v0.1.0 [..] [FINISHED] [..] +[GENERATED] [CWD]/target/doc/foo/index.html ", ) .run(); @@ -545,6 +548,8 @@ the same path; see . [DOCUMENTING] foo-macro v1.0.0 [..] [DOCUMENTING] abc v1.0.0 [..] [FINISHED] [..] +[GENERATED] [CWD]/target/doc/abc/index.html +[GENERATED] [CWD]/target/doc/foo_macro/index.html ") .run(); } diff --git a/tests/testsuite/doc.rs b/tests/testsuite/doc.rs index a16980912460..65169d214049 100644 --- a/tests/testsuite/doc.rs +++ b/tests/testsuite/doc.rs @@ -31,6 +31,7 @@ fn simple() { [..] foo v0.0.1 ([CWD]) [..] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/foo/index.html ", ) .run(); @@ -69,6 +70,7 @@ fn doc_twice() { "\ [DOCUMENTING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/foo/index.html ", ) .run(); @@ -103,6 +105,7 @@ fn doc_deps() { [..] bar v0.0.1 ([CWD]/bar) [DOCUMENTING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/foo/index.html ", ) .run(); @@ -151,6 +154,7 @@ fn doc_no_deps() { [CHECKING] bar v0.0.1 ([CWD]/bar) [DOCUMENTING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/foo/index.html ", ) .run(); @@ -284,6 +288,8 @@ the same path; see . [DOCUMENTING] bar v0.1.0 ([ROOT]/foo/bar) [DOCUMENTING] foo v0.1.0 ([ROOT]/foo/foo) [FINISHED] [..] +[GENERATED] [CWD]/target/doc/foo_lib/index.html +[GENERATED] [CWD]/target/doc/foo_lib/index.html ", ) .run(); @@ -398,6 +404,7 @@ fn doc_lib_bin_same_name_documents_lib() { "\ [DOCUMENTING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/foo/index.html ", ) .run(); @@ -433,6 +440,7 @@ fn doc_lib_bin_same_name_documents_lib_when_requested() { "\ [DOCUMENTING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/foo/index.html ", ) .run(); @@ -478,6 +486,7 @@ the same path; see . [CHECKING] foo v0.0.1 ([CWD]) [DOCUMENTING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/foo/index.html ", ) .run(); @@ -523,6 +532,7 @@ the same path; see . [CHECKING] foo v0.0.1 ([CWD]) [DOCUMENTING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/foo/index.html ", ) .run(); @@ -567,7 +577,9 @@ fn doc_lib_bin_example_same_name_documents_named_example_when_requested() { "\ [CHECKING] foo v0.0.1 ([CWD]) [DOCUMENTING] foo v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]", +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/ex1/index.html +", ) .run(); @@ -620,7 +632,10 @@ fn doc_lib_bin_example_same_name_documents_examples_when_requested() { "\ [CHECKING] foo v0.0.1 ([CWD]) [DOCUMENTING] foo v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]", +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/ex1/index.html +[GENERATED] [CWD]/target/doc/ex2/index.html +", ) .run(); @@ -677,6 +692,7 @@ fn doc_dash_p() { [..] b v0.0.1 ([CWD]/b) [DOCUMENTING] a v0.0.1 ([CWD]/a) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/a/index.html ", ) .run(); @@ -704,6 +720,7 @@ fn doc_all_exclude() { "\ [DOCUMENTING] bar v0.1.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/bar/index.html ", ) .run(); @@ -731,6 +748,7 @@ fn doc_all_exclude_glob() { "\ [DOCUMENTING] bar v0.1.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/bar/index.html ", ) .run(); @@ -918,6 +936,7 @@ fn doc_release() { [DOCUMENTING] foo v0.0.1 ([..]) [RUNNING] `rustdoc [..] src/lib.rs [..]` [FINISHED] release [optimized] target(s) in [..] +[GENERATED] [CWD]/target/doc/foo/index.html ", ) .run(); @@ -1006,6 +1025,7 @@ fn features() { [DOCUMENTING] bar v0.0.1 [..] [DOCUMENTING] foo v0.0.1 [..] [FINISHED] [..] +[GENERATED] [CWD]/target/doc/foo/index.html ", ) .run(); @@ -1020,6 +1040,7 @@ fn features() { [DOCUMENTING] bar v0.0.1 [..] [DOCUMENTING] foo v0.0.1 [..] [FINISHED] [..] +[GENERATED] [CWD]/target/doc/foo/index.html ", ) .run(); @@ -1032,6 +1053,7 @@ fn features() { [DOCUMENTING] bar v0.0.1 [..] [DOCUMENTING] foo v0.0.1 [..] [FINISHED] [..] +[GENERATED] [CWD]/target/doc/foo/index.html ", ) .run(); @@ -1202,6 +1224,7 @@ fn doc_virtual_manifest_one_project() { "\ [DOCUMENTING] bar v0.1.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/bar/index.html ", ) .run(); @@ -1229,6 +1252,7 @@ fn doc_virtual_manifest_glob() { "\ [DOCUMENTING] baz v0.1.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/baz/index.html ", ) .run(); @@ -1277,6 +1301,7 @@ the same path; see . [CHECKING] bar v0.1.0 [DOCUMENTING] bar v0.1.0 [..] [FINISHED] [..] +[GENERATED] [CWD]/target/doc/bar/index.html ", ) .run(); @@ -1639,6 +1664,7 @@ fn doc_cap_lints() { [CHECKING] a v0.5.0 ([..]) [DOCUMENTING] foo v0.0.1 ([..]) [FINISHED] dev [..] +[GENERATED] [CWD]/target/doc/foo/index.html ", ) .run(); @@ -1903,6 +1929,7 @@ fn bin_private_items() { "\ [DOCUMENTING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/foo/index.html ", ) .run(); @@ -1963,6 +1990,7 @@ fn bin_private_items_deps() { [CHECKING] bar v0.0.1 ([..]) [DOCUMENTING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/foo/index.html ", ) .run(); @@ -1997,6 +2025,7 @@ fn crate_versions() { [DOCUMENTING] foo v1.2.4 [..] [RUNNING] `rustdoc --crate-type lib --crate-name foo src/lib.rs [..]--crate-version 1.2.4` [FINISHED] [..] +[GENERATED] [CWD]/target/doc/foo/index.html ", ) .run(); @@ -2406,7 +2435,8 @@ fn doc_fingerprint_unusual_behavior() { p.cargo("doc") .with_stderr( "[DOCUMENTING] foo [..]\n\ - [FINISHED] [..]", + [FINISHED] [..]\n\ + [GENERATED] [CWD]/target/doc/foo/index.html", ) .run(); // This will delete somefile, but not .hidden. @@ -2425,7 +2455,8 @@ fn doc_fingerprint_unusual_behavior() { .masquerade_as_nightly_cargo(&["skip-rustdoc-fingerprint"]) .with_stderr( "[DOCUMENTING] foo [..]\n\ - [FINISHED] [..]", + [FINISHED] [..]\n\ + [GENERATED] [CWD]/target/doc/foo/index.html", ) .run(); // Should not have deleted anything. @@ -2467,6 +2498,8 @@ fn lib_before_bin() { [RUNNING] `rustdoc --crate-type lib --crate-name foo src/lib.rs [..] [RUNNING] `rustdoc --crate-type bin --crate-name somebin src/bin/somebin.rs [..] [FINISHED] [..] +[GENERATED] [CWD]/target/doc/foo/index.html +[GENERATED] [CWD]/target/doc/somebin/index.html ", ) .run(); @@ -2517,6 +2550,7 @@ fn doc_lib_false() { [CHECKING] foo v0.1.0 [..] [DOCUMENTING] foo v0.1.0 [..] [FINISHED] [..] +[GENERATED] [CWD]/target/doc/some_bin/index.html ", ) .run(); @@ -2563,6 +2597,7 @@ fn doc_lib_false_dep() { [CHECKING] bar v0.1.0 [..] [DOCUMENTING] foo v0.1.0 [..] [FINISHED] [..] +[GENERATED] [CWD]/target/doc/foo/index.html ", ) .run(); @@ -2587,7 +2622,8 @@ fn link_to_private_item() { p.cargo("doc") .with_stderr( "[DOCUMENTING] foo [..]\n\ - [FINISHED] [..]", + [FINISHED] [..]\n\ + [GENERATED] [CWD]/target/doc/foo/index.html", ) .run(); } diff --git a/tests/testsuite/features2.rs b/tests/testsuite/features2.rs index d4c32cc2f2fc..125a293a0040 100644 --- a/tests/testsuite/features2.rs +++ b/tests/testsuite/features2.rs @@ -1955,6 +1955,7 @@ fn doc_optional() { [CHECKING] bar v1.0.0 [DOCUMENTING] foo v0.1.0 [..] [FINISHED] [..] +[GENERATED] [CWD]/target/doc/foo/index.html ", ) .run(); diff --git a/tests/testsuite/glob_targets.rs b/tests/testsuite/glob_targets.rs index 8021dffa9b20..1eed4b1fae3b 100644 --- a/tests/testsuite/glob_targets.rs +++ b/tests/testsuite/glob_targets.rs @@ -137,6 +137,7 @@ fn doc_bin() { [DOCUMENTING] foo v0.0.1 ([CWD]) [RUNNING] `rustdoc --crate-type bin --crate-name bin1 [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/bin1/index.html ", ) .run(); @@ -407,6 +408,7 @@ fn rustdoc_example() { [DOCUMENTING] foo v0.0.1 ([CWD]) [RUNNING] `rustdoc --crate-type bin --crate-name example1 [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/example1/index.html ", ) .run(); @@ -421,6 +423,7 @@ fn rustdoc_bin() { [DOCUMENTING] foo v0.0.1 ([CWD]) [RUNNING] `rustdoc --crate-type bin --crate-name bin1 [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/bin1/index.html ", ) .run(); @@ -435,6 +438,7 @@ fn rustdoc_bench() { [DOCUMENTING] foo v0.0.1 ([CWD]) [RUNNING] `rustdoc --crate-type bin --crate-name bench1 [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/bench1/index.html ", ) .run(); @@ -449,6 +453,7 @@ fn rustdoc_test() { [DOCUMENTING] foo v0.0.1 ([CWD]) [RUNNING] `rustdoc --crate-type bin --crate-name test1 [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/test1/index.html ", ) .run(); diff --git a/tests/testsuite/profile_targets.rs b/tests/testsuite/profile_targets.rs index f2de169b9f1f..9f00b73f3a5a 100644 --- a/tests/testsuite/profile_targets.rs +++ b/tests/testsuite/profile_targets.rs @@ -667,5 +667,6 @@ fn profile_selection_doc() { [DOCUMENTING] foo [..] [RUNNING] `rustdoc [..]--crate-name foo src/lib.rs [..] [FINISHED] dev [unoptimized + debuginfo] [..] +[GENERATED] [CWD]/target/doc/foo/index.html ").run(); } diff --git a/tests/testsuite/rustdoc.rs b/tests/testsuite/rustdoc.rs index 5650f3e0a5bf..d5a55e84402a 100644 --- a/tests/testsuite/rustdoc.rs +++ b/tests/testsuite/rustdoc.rs @@ -15,6 +15,7 @@ fn rustdoc_simple() { [..] \ -L dependency=[CWD]/target/debug/deps [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/foo/index.html ", ) .run(); @@ -35,6 +36,7 @@ fn rustdoc_args() { -C metadata=[..] \ -L dependency=[CWD]/target/debug/deps [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/foo/index.html ", ) .run(); @@ -88,6 +90,7 @@ fn rustdoc_foo_with_bar_dependency() { -L dependency=[CWD]/target/debug/deps \ --extern [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/foo/index.html ", ) .run(); @@ -127,6 +130,7 @@ fn rustdoc_only_bar_dependency() { -C metadata=[..] \ -L dependency=[CWD]/target/debug/deps [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/bar/index.html ", ) .run(); @@ -150,6 +154,7 @@ fn rustdoc_same_name_documents_lib() { -C metadata=[..] \ -L dependency=[CWD]/target/debug/deps [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/foo/index.html ", ) .run(); diff --git a/tests/testsuite/rustdocflags.rs b/tests/testsuite/rustdocflags.rs index c37d5a8266bc..e7c2aa263225 100644 --- a/tests/testsuite/rustdocflags.rs +++ b/tests/testsuite/rustdocflags.rs @@ -48,7 +48,10 @@ fn rerun() { p.cargo("doc").env("RUSTDOCFLAGS", "--cfg=foo").run(); p.cargo("doc") .env("RUSTDOCFLAGS", "--cfg=foo") - .with_stderr("[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]") + .with_stderr( + "[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/foo/index.html", + ) .run(); p.cargo("doc") .env("RUSTDOCFLAGS", "--cfg=bar") @@ -56,6 +59,7 @@ fn rerun() { "\ [DOCUMENTING] foo v0.0.1 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[GENERATED] [CWD]/target/doc/foo/index.html ", ) .run();