mirror of
https://github.com/rust-lang/cargo
synced 2024-10-05 23:39:47 +00:00
Auto merge of #14171 - heisen-li:dir_doc, r=weihanglo
test:migrate `doc/directory/docscrape` to snapbox ### What does this PR try to resolve? Complete the following file migration: ``` tests/testsuite/directory.rs tests/testsuite/doc.rs tests/testsuite/docscrape.rs ``` part of #14039
This commit is contained in:
commit
a0b280398c
|
@ -279,6 +279,7 @@ static E2E_LITERAL_REDACTIONS: &[(&str, &str)] = &[
|
|||
("[PUBLISHED]", " Published"),
|
||||
("[BLOCKING]", " Blocking"),
|
||||
("[GENERATED]", " Generated"),
|
||||
("[OPENING]", " Opening"),
|
||||
];
|
||||
|
||||
/// Normalizes the output so that it can be compared against the expected value.
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
//! Tests for directory sources.
|
||||
|
||||
#![allow(deprecated)]
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::fs;
|
||||
use std::str;
|
||||
|
@ -12,6 +10,7 @@ use cargo_test_support::cargo_process;
|
|||
use cargo_test_support::git;
|
||||
use cargo_test_support::paths;
|
||||
use cargo_test_support::registry::{cksum, Package};
|
||||
use cargo_test_support::str;
|
||||
use cargo_test_support::{basic_manifest, project, t, ProjectBuilder};
|
||||
|
||||
fn setup() {
|
||||
|
@ -107,14 +106,13 @@ fn simple() {
|
|||
.build();
|
||||
|
||||
p.cargo("check")
|
||||
.with_stderr(
|
||||
"\
|
||||
.with_stderr_data(str![[r#"
|
||||
[LOCKING] 2 packages to latest compatible versions
|
||||
[CHECKING] bar v0.1.0
|
||||
[CHECKING] foo v0.1.0 ([CWD])
|
||||
[FINISHED] [..]
|
||||
",
|
||||
)
|
||||
[CHECKING] foo v0.1.0 ([ROOT]/foo)
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
|
@ -147,18 +145,17 @@ fn simple_install() {
|
|||
.build();
|
||||
|
||||
cargo_process("install bar")
|
||||
.with_stderr(
|
||||
"\
|
||||
.with_stderr_data(str![[r#"
|
||||
[INSTALLING] bar v0.1.0
|
||||
[LOCKING] 2 packages to latest compatible versions
|
||||
[COMPILING] foo v0.0.1
|
||||
[COMPILING] bar v0.1.0
|
||||
[FINISHED] `release` profile [optimized] target(s) in [..]s
|
||||
[FINISHED] `release` profile [optimized] target(s) in [ELAPSED]s
|
||||
[INSTALLING] [..]bar[..]
|
||||
[INSTALLED] package `bar v0.1.0` (executable `bar[EXE]`)
|
||||
[WARNING] be sure to add `[..]` to your PATH to be able to run the installed binaries
|
||||
",
|
||||
)
|
||||
[WARNING] be sure to add `[ROOT]/home/.cargo/bin` to your PATH to be able to run the installed binaries
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
|
@ -193,11 +190,10 @@ fn simple_install_fail() {
|
|||
|
||||
cargo_process("install bar")
|
||||
.with_status(101)
|
||||
.with_stderr(
|
||||
" Installing bar v0.1.0
|
||||
error: failed to compile `bar v0.1.0`, intermediate artifacts can be found at `[..]`.
|
||||
To reuse those artifacts with a future compilation, set the environment variable \
|
||||
`CARGO_TARGET_DIR` to that path.
|
||||
.with_stderr_data(str![[r#"
|
||||
[INSTALLING] bar v0.1.0
|
||||
[ERROR] failed to compile `bar v0.1.0`, intermediate artifacts can be found at `[..]`.
|
||||
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
|
||||
|
||||
Caused by:
|
||||
no matching package found
|
||||
|
@ -205,8 +201,8 @@ Caused by:
|
|||
perhaps you meant: bar or foo
|
||||
location searched: registry `crates-io`
|
||||
required by package `bar v0.1.0`
|
||||
",
|
||||
)
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
|
@ -243,18 +239,17 @@ fn install_without_feature_dep() {
|
|||
.build();
|
||||
|
||||
cargo_process("install bar")
|
||||
.with_stderr(
|
||||
"\
|
||||
.with_stderr_data(str![[r#"
|
||||
[INSTALLING] bar v0.1.0
|
||||
[LOCKING] 2 packages to latest compatible versions
|
||||
[COMPILING] foo v0.0.1
|
||||
[COMPILING] bar v0.1.0
|
||||
[FINISHED] `release` profile [optimized] target(s) in [..]s
|
||||
[FINISHED] `release` profile [optimized] target(s) in [ELAPSED]s
|
||||
[INSTALLING] [..]bar[..]
|
||||
[INSTALLED] package `bar v0.1.0` (executable `bar[EXE]`)
|
||||
[WARNING] be sure to add `[..]` to your PATH to be able to run the installed binaries
|
||||
",
|
||||
)
|
||||
[WARNING] be sure to add `[ROOT]/home/.cargo/bin` to your PATH to be able to run the installed binaries
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
|
@ -286,13 +281,12 @@ fn not_there() {
|
|||
|
||||
p.cargo("check")
|
||||
.with_status(101)
|
||||
.with_stderr(
|
||||
"\
|
||||
error: no matching package named `bar` found
|
||||
location searched: [..]
|
||||
required by package `foo v0.1.0 ([..])`
|
||||
",
|
||||
)
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] no matching package named `bar` found
|
||||
location searched: registry `crates-io`
|
||||
required by package `foo v0.1.0 ([ROOT]/foo)`
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
|
@ -333,15 +327,14 @@ fn multiple() {
|
|||
.build();
|
||||
|
||||
p.cargo("check")
|
||||
.with_stderr(
|
||||
"\
|
||||
.with_stderr_data(str![[r#"
|
||||
[LOCKING] 2 packages to latest compatible versions
|
||||
[ADDING] bar v0.1.0 (latest: v0.2.0)
|
||||
[CHECKING] bar v0.1.0
|
||||
[CHECKING] foo v0.1.0 ([CWD])
|
||||
[FINISHED] [..]
|
||||
",
|
||||
)
|
||||
[CHECKING] foo v0.1.0 ([ROOT]/foo)
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
|
@ -372,17 +365,16 @@ fn crates_io_then_directory() {
|
|||
.publish();
|
||||
|
||||
p.cargo("check")
|
||||
.with_stderr(
|
||||
"\
|
||||
[UPDATING] `[..]` index
|
||||
.with_stderr_data(str![[r#"
|
||||
[UPDATING] `dummy-registry` index
|
||||
[LOCKING] 2 packages to latest compatible versions
|
||||
[DOWNLOADING] crates ...
|
||||
[DOWNLOADED] bar v0.1.0 ([..])
|
||||
[DOWNLOADED] bar v0.1.0 (registry `dummy-registry`)
|
||||
[CHECKING] bar v0.1.0
|
||||
[CHECKING] foo v0.1.0 ([CWD])
|
||||
[FINISHED] [..]
|
||||
",
|
||||
)
|
||||
[CHECKING] foo v0.1.0 ([ROOT]/foo)
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
|
||||
setup();
|
||||
|
@ -394,13 +386,12 @@ fn crates_io_then_directory() {
|
|||
v.build();
|
||||
|
||||
p.cargo("check")
|
||||
.with_stderr(
|
||||
"\
|
||||
.with_stderr_data(str![[r#"
|
||||
[CHECKING] bar v0.1.0
|
||||
[CHECKING] foo v0.1.0 ([CWD])
|
||||
[FINISHED] [..]
|
||||
",
|
||||
)
|
||||
[CHECKING] foo v0.1.0 ([ROOT]/foo)
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
|
@ -435,9 +426,8 @@ fn crates_io_then_bad_checksum() {
|
|||
|
||||
p.cargo("check")
|
||||
.with_status(101)
|
||||
.with_stderr(
|
||||
"\
|
||||
error: checksum for `bar v0.1.0` changed between lock files
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] checksum for `bar v0.1.0` changed between lock files
|
||||
|
||||
this could be indicative of a few possible errors:
|
||||
|
||||
|
@ -447,8 +437,8 @@ this could be indicative of a few possible errors:
|
|||
|
||||
unable to verify that `bar v0.1.0` is the same as when the lockfile was generated
|
||||
|
||||
",
|
||||
)
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
|
@ -485,18 +475,15 @@ fn bad_file_checksum() {
|
|||
|
||||
p.cargo("check")
|
||||
.with_status(101)
|
||||
.with_stderr(
|
||||
"\
|
||||
.with_stderr_data(str![[r#"
|
||||
[LOCKING] 2 packages to latest compatible versions
|
||||
error: the listed checksum of `[..]lib.rs` has changed:
|
||||
[ERROR] the listed checksum of `[ROOT]/index/bar/src/lib.rs` has changed:
|
||||
expected: [..]
|
||||
actual: [..]
|
||||
|
||||
directory sources are not intended to be edited, if modifications are \
|
||||
required then it is recommended that `[patch]` is used with a forked copy of \
|
||||
the source
|
||||
",
|
||||
)
|
||||
directory sources are not intended to be edited, if modifications are required then it is recommended that `[patch]` is used with a forked copy of the source
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
|
@ -622,13 +609,12 @@ fn git_lock_file_doesnt_change() {
|
|||
));
|
||||
|
||||
p.cargo("check")
|
||||
.with_stderr(
|
||||
"\
|
||||
[CHECKING] [..]
|
||||
[CHECKING] [..]
|
||||
[FINISHED] [..]
|
||||
",
|
||||
)
|
||||
.with_stderr_data(str![[r#"
|
||||
[CHECKING] git v0.5.0 ([..])
|
||||
[CHECKING] foo v0.0.1 ([ROOT]/foo)
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
|
||||
let lock2 = p.read_lockfile();
|
||||
|
@ -676,9 +662,8 @@ fn git_override_requires_lockfile() {
|
|||
|
||||
p.cargo("check")
|
||||
.with_status(101)
|
||||
.with_stderr(
|
||||
"\
|
||||
[ERROR] failed to get `git` as a dependency of package `foo v0.0.1 ([..])`
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] failed to get `git` as a dependency of package `foo v0.0.1 ([ROOT]/foo)`
|
||||
|
||||
Caused by:
|
||||
failed to load source for dependency `git`
|
||||
|
@ -692,8 +677,8 @@ Caused by:
|
|||
|
||||
remove the source replacement configuration, generate a lock file, and then
|
||||
restore the source replacement configuration to continue the build
|
||||
",
|
||||
)
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
|
@ -748,13 +733,12 @@ fn workspace_different_locations() {
|
|||
p.cargo("check").cwd("foo").run();
|
||||
p.cargo("check")
|
||||
.cwd("bar")
|
||||
.with_stderr(
|
||||
"\
|
||||
.with_stderr_data(str![[r#"
|
||||
[LOCKING] 2 packages to latest compatible versions
|
||||
[CHECKING] bar [..]
|
||||
[FINISHED] [..]
|
||||
",
|
||||
)
|
||||
[CHECKING] bar v0.1.0 ([ROOT]/foo/bar)
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
|
@ -784,21 +768,19 @@ fn version_missing() {
|
|||
.build();
|
||||
|
||||
cargo_process("install bar")
|
||||
.with_stderr(
|
||||
"\
|
||||
.with_stderr_data(str![[r#"
|
||||
[INSTALLING] bar v0.1.0
|
||||
error: failed to compile [..], intermediate artifacts can be found at `[..]`.
|
||||
To reuse those artifacts with a future compilation, set the environment variable \
|
||||
`CARGO_TARGET_DIR` to that path.
|
||||
[ERROR] failed to compile [..], intermediate artifacts can be found at `[..]`.
|
||||
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
|
||||
|
||||
Caused by:
|
||||
failed to select a version for the requirement `foo = \"^2\"`
|
||||
failed to select a version for the requirement `foo = "^2"`
|
||||
candidate versions found which didn't match: 0.0.1
|
||||
location searched: directory source `[..] (which is replacing registry `[..]`)
|
||||
required by package `bar v0.1.0`
|
||||
perhaps a crate was updated and forgotten to be re-vendored?
|
||||
",
|
||||
)
|
||||
|
||||
"#]])
|
||||
.with_status(101)
|
||||
.run();
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,8 +1,8 @@
|
|||
//! Tests for the `cargo doc` command with `-Zrustdoc-scrape-examples`.
|
||||
|
||||
#![allow(deprecated)]
|
||||
|
||||
use cargo_test_support::prelude::*;
|
||||
use cargo_test_support::project;
|
||||
use cargo_test_support::str;
|
||||
|
||||
#[cargo_test(nightly, reason = "rustdoc scrape examples flags are unstable")]
|
||||
fn basic() {
|
||||
|
@ -23,24 +23,23 @@ fn basic() {
|
|||
|
||||
p.cargo("doc -Zunstable-options -Zrustdoc-scrape-examples")
|
||||
.masquerade_as_nightly_cargo(&["rustdoc-scrape-examples"])
|
||||
.with_stderr(
|
||||
"\
|
||||
[CHECKING] foo v0.0.1 ([CWD])
|
||||
[SCRAPING] foo v0.0.1 ([CWD])
|
||||
[DOCUMENTING] foo v0.0.1 ([CWD])
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
[GENERATED] [CWD]/target/doc/foo/index.html
|
||||
",
|
||||
)
|
||||
.with_stderr_data(str![[r#"
|
||||
[CHECKING] foo v0.0.1 ([ROOT]/foo)
|
||||
[SCRAPING] foo v0.0.1 ([ROOT]/foo)
|
||||
[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
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
|
||||
p.cargo("doc -Zunstable-options -Z rustdoc-scrape-examples")
|
||||
.masquerade_as_nightly_cargo(&["rustdoc-scrape-examples"])
|
||||
.with_stderr(
|
||||
"[FINISHED] [..]
|
||||
[GENERATED] [CWD]/target/doc/foo/index.html
|
||||
",
|
||||
)
|
||||
.with_stderr_data(str![[r#"
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
[GENERATED] [ROOT]/foo/target/doc/foo/index.html
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
|
||||
let doc_html = p.read_file("target/doc/foo/fn.foo.html");
|
||||
|
@ -115,15 +114,18 @@ impl Foo {
|
|||
|
||||
p.cargo("doc -Zunstable-options -Zrustdoc-scrape-examples --no-deps")
|
||||
.masquerade_as_nightly_cargo(&["rustdoc-scrape-examples"])
|
||||
.with_stderr_unordered(
|
||||
"\
|
||||
.with_stderr_data(
|
||||
str![[r#"
|
||||
[LOCKING] 2 packages to latest compatible versions
|
||||
[CHECKING] a v0.0.1 ([CWD]/crates/a)
|
||||
[CHECKING] foo v0.0.1 ([CWD])
|
||||
[SCRAPING] foo v0.0.1 ([CWD])
|
||||
[DOCUMENTING] foo v0.0.1 ([CWD])
|
||||
[FINISHED] [..]
|
||||
[GENERATED] [CWD]/target/doc/foo/index.html",
|
||||
[CHECKING] a v0.0.1 ([ROOT]/foo/crates/a)
|
||||
[CHECKING] foo v0.0.1 ([ROOT]/foo)
|
||||
[SCRAPING] foo v0.0.1 ([ROOT]/foo)
|
||||
[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();
|
||||
|
||||
|
@ -402,25 +404,23 @@ fn cache() {
|
|||
|
||||
p.cargo("doc -Zunstable-options -Zrustdoc-scrape-examples")
|
||||
.masquerade_as_nightly_cargo(&["rustdoc-scrape-examples"])
|
||||
.with_stderr(
|
||||
"\
|
||||
[CHECKING] foo v0.0.1 ([CWD])
|
||||
[SCRAPING] foo v0.0.1 ([CWD])
|
||||
[DOCUMENTING] foo v0.0.1 ([CWD])
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
[GENERATED] [CWD]/target/doc/foo/index.html
|
||||
",
|
||||
)
|
||||
.with_stderr_data(str![[r#"
|
||||
[CHECKING] foo v0.0.1 ([ROOT]/foo)
|
||||
[SCRAPING] foo v0.0.1 ([ROOT]/foo)
|
||||
[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
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
|
||||
p.cargo("doc -Zunstable-options -Zrustdoc-scrape-examples")
|
||||
.masquerade_as_nightly_cargo(&["rustdoc-scrape-examples"])
|
||||
.with_stderr(
|
||||
"\
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
[GENERATED] [CWD]/target/doc/foo/index.html
|
||||
",
|
||||
)
|
||||
.with_stderr_data(str![[r#"
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
[GENERATED] [ROOT]/foo/target/doc/foo/index.html
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
|
@ -444,27 +444,26 @@ fn no_fail_bad_lib() {
|
|||
|
||||
p.cargo("doc -Zunstable-options -Z rustdoc-scrape-examples")
|
||||
.masquerade_as_nightly_cargo(&["rustdoc-scrape-examples"])
|
||||
.with_stderr_unordered(
|
||||
"\
|
||||
[CHECKING] foo v0.0.1 ([CWD])
|
||||
[SCRAPING] foo v0.0.1 ([CWD])
|
||||
warning: failed to check lib in package `foo` as a prerequisite for scraping examples from: example \"ex\", example \"ex2\"
|
||||
.with_stderr_data(str![[r#"
|
||||
[CHECKING] foo v0.0.1 ([ROOT]/foo)
|
||||
[SCRAPING] foo v0.0.1 ([ROOT]/foo)
|
||||
[WARNING] failed to check lib in package `foo` as a prerequisite for scraping examples from: example "ex", example "ex2"
|
||||
Try running with `--verbose` to see the error message.
|
||||
If an example should not be scanned, then consider adding `doc-scrape-examples = false` to its `[[example]]` definition in Cargo.toml
|
||||
warning: `foo` (lib) generated 1 warning
|
||||
warning: failed to scan example \"ex\" in package `foo` for example code usage
|
||||
[WARNING] `foo` (lib) generated 1 warning
|
||||
[WARNING] failed to scan example "ex" in package `foo` for example code usage
|
||||
Try running with `--verbose` to see the error message.
|
||||
If an example should not be scanned, then consider adding `doc-scrape-examples = false` to its `[[example]]` definition in Cargo.toml
|
||||
warning: `foo` (example \"ex\") generated 1 warning
|
||||
warning: failed to scan example \"ex2\" in package `foo` for example code usage
|
||||
[WARNING] `foo` (example "ex") generated 1 warning
|
||||
[WARNING] failed to scan example "ex2" in package `foo` for example code usage
|
||||
Try running with `--verbose` to see the error message.
|
||||
If an example should not be scanned, then consider adding `doc-scrape-examples = false` to its `[[example]]` definition in Cargo.toml
|
||||
warning: `foo` (example \"ex2\") generated 1 warning
|
||||
[DOCUMENTING] foo v0.0.1 ([CWD])
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
[GENERATED] [CWD]/target/doc/foo/index.html
|
||||
",
|
||||
)
|
||||
[WARNING] `foo` (example "ex2") generated 1 warning
|
||||
[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();
|
||||
}
|
||||
|
||||
|
@ -489,14 +488,22 @@ fn fail_bad_build_script() {
|
|||
// `cargo doc` fails
|
||||
p.cargo("doc")
|
||||
.with_status(101)
|
||||
.with_stderr_contains("[..]You shall not pass[..]")
|
||||
.with_stderr_data(str![[r#"
|
||||
...
|
||||
[..]You shall not pass[..]
|
||||
...
|
||||
"#]])
|
||||
.run();
|
||||
|
||||
// scrape examples should fail whenever `cargo doc` fails.
|
||||
p.cargo("doc -Zunstable-options -Z rustdoc-scrape-examples")
|
||||
.masquerade_as_nightly_cargo(&["rustdoc-scrape-examples"])
|
||||
.with_status(101)
|
||||
.with_stderr_contains("[..]You shall not pass[..]")
|
||||
.with_stderr_data(str![[r#"
|
||||
...
|
||||
[..]You shall not pass[..]
|
||||
...
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
|
@ -520,43 +527,44 @@ fn no_fail_bad_example() {
|
|||
|
||||
p.cargo("doc -Zunstable-options -Z rustdoc-scrape-examples")
|
||||
.masquerade_as_nightly_cargo(&["rustdoc-scrape-examples"])
|
||||
.with_stderr(
|
||||
"\
|
||||
[CHECKING] foo v0.0.1 ([CWD])
|
||||
[SCRAPING] foo v0.0.1 ([CWD])
|
||||
warning: failed to scan example \"ex1\" in package `foo` for example code usage
|
||||
.with_stderr_data(str![[r#"
|
||||
[CHECKING] foo v0.0.1 ([ROOT]/foo)
|
||||
[SCRAPING] foo v0.0.1 ([ROOT]/foo)
|
||||
[WARNING] failed to scan example "ex1" in package `foo` for example code usage
|
||||
Try running with `--verbose` to see the error message.
|
||||
If an example should not be scanned, then consider adding `doc-scrape-examples = false` to its `[[example]]` definition in Cargo.toml
|
||||
warning: `foo` (example \"ex1\") generated 1 warning
|
||||
[DOCUMENTING] foo v0.0.1 ([CWD])
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
[GENERATED] [CWD]/target/doc/foo/index.html
|
||||
",
|
||||
)
|
||||
[WARNING] `foo` (example "ex1") generated 1 warning
|
||||
[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
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
|
||||
p.cargo("clean").run();
|
||||
|
||||
p.cargo("doc -v -Zunstable-options -Z rustdoc-scrape-examples")
|
||||
.masquerade_as_nightly_cargo(&["rustdoc-scrape-examples"])
|
||||
.with_stderr_unordered(
|
||||
"\
|
||||
[CHECKING] foo v0.0.1 ([CWD])
|
||||
.with_stderr_data(
|
||||
str![[r#"
|
||||
[CHECKING] foo v0.0.1 ([ROOT]/foo)
|
||||
[RUNNING] `rustc --crate-name foo[..]
|
||||
[SCRAPING] foo v0.0.1 ([CWD])
|
||||
[SCRAPING] foo v0.0.1 ([ROOT]/foo)
|
||||
[RUNNING] `rustdoc[..] --crate-name ex1[..]
|
||||
[RUNNING] `rustdoc[..] --crate-name ex2[..]
|
||||
[RUNNING] `rustdoc[..] --crate-name foo[..]
|
||||
error: expected one of `!` or `::`, found `NOT`
|
||||
[ERROR] expected one of `!` or `::`, found `NOT`
|
||||
--> examples/ex1.rs:1:6
|
||||
|
|
||||
1 | DOES NOT COMPILE
|
||||
| ^^^ expected one of `!` or `::`
|
||||
|
||||
[DOCUMENTING] foo v0.0.1 ([CWD])
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
[GENERATED] [CWD]/target/doc/foo/index.html
|
||||
",
|
||||
[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();
|
||||
|
||||
|
@ -603,32 +611,33 @@ fn no_scrape_with_dev_deps() {
|
|||
// should be raised.
|
||||
p.cargo("doc -Zunstable-options -Z rustdoc-scrape-examples")
|
||||
.masquerade_as_nightly_cargo(&["rustdoc-scrape-examples"])
|
||||
.with_stderr(
|
||||
"\
|
||||
.with_stderr_data(str![[r#"
|
||||
[LOCKING] 2 packages to latest compatible versions
|
||||
warning: Rustdoc did not scrape the following examples because they require dev-dependencies: ex
|
||||
[WARNING] Rustdoc did not scrape the following examples because they require dev-dependencies: ex
|
||||
If you want Rustdoc to scrape these examples, then add `doc-scrape-examples = true`
|
||||
to the [[example]] target configuration of at least one example.
|
||||
[DOCUMENTING] foo v0.0.1 ([CWD])
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
[GENERATED] [CWD]/target/doc/foo/index.html
|
||||
",
|
||||
)
|
||||
[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
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
|
||||
// If --examples is provided, then the example is scanned.
|
||||
p.cargo("doc --examples -Zunstable-options -Z rustdoc-scrape-examples")
|
||||
.masquerade_as_nightly_cargo(&["rustdoc-scrape-examples"])
|
||||
.with_stderr_unordered(
|
||||
"\
|
||||
[CHECKING] a v0.0.1 ([CWD]/a)
|
||||
[CHECKING] foo v0.0.1 ([CWD])
|
||||
[DOCUMENTING] a v0.0.1 ([CWD]/a)
|
||||
[SCRAPING] foo v0.0.1 ([CWD])
|
||||
[DOCUMENTING] foo v0.0.1 ([CWD])
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
[GENERATED] [CWD]/target/doc/ex/index.html
|
||||
",
|
||||
.with_stderr_data(
|
||||
str![[r#"
|
||||
[CHECKING] a v0.0.1 ([ROOT]/foo/a)
|
||||
[CHECKING] foo v0.0.1 ([ROOT]/foo)
|
||||
[DOCUMENTING] a v0.0.1 ([ROOT]/foo/a)
|
||||
[SCRAPING] foo v0.0.1 ([ROOT]/foo)
|
||||
[DOCUMENTING] foo v0.0.1 ([ROOT]/foo)
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
[GENERATED] [ROOT]/foo/target/doc/ex/index.html
|
||||
|
||||
"#]]
|
||||
.unordered(),
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
@ -671,16 +680,18 @@ fn use_dev_deps_if_explicitly_enabled() {
|
|||
// If --examples is not provided, then the example is never scanned.
|
||||
p.cargo("doc -Zunstable-options -Z rustdoc-scrape-examples")
|
||||
.masquerade_as_nightly_cargo(&["rustdoc-scrape-examples"])
|
||||
.with_stderr_unordered(
|
||||
"\
|
||||
.with_stderr_data(
|
||||
str![[r#"
|
||||
[LOCKING] 2 packages to latest compatible versions
|
||||
[CHECKING] foo v0.0.1 ([CWD])
|
||||
[CHECKING] a v0.0.1 ([CWD]/a)
|
||||
[SCRAPING] foo v0.0.1 ([CWD])
|
||||
[DOCUMENTING] foo v0.0.1 ([CWD])
|
||||
[CHECKING] a v0.0.1 ([ROOT]/foo/a)
|
||||
[CHECKING] foo v0.0.1 ([ROOT]/foo)
|
||||
[SCRAPING] foo v0.0.1 ([ROOT]/foo)
|
||||
[DOCUMENTING] foo v0.0.1 ([ROOT]/foo)
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
[GENERATED] [CWD]/target/doc/foo/index.html
|
||||
",
|
||||
[GENERATED] [ROOT]/foo/target/doc/foo/index.html
|
||||
|
||||
"#]]
|
||||
.unordered(),
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue