Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Gate fallible Docscrape unit feature behind -Z ignore-scrape-failures
Browse files Browse the repository at this point in the history
willcrichton committed Jul 16, 2022

Unverified

The committer email address is not verified.
1 parent a3a4e86 commit decc3f0
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/cargo/core/features.rs
Original file line number Diff line number Diff line change
@@ -663,6 +663,7 @@ unstable_cli_options!(
// TODO(wcrichto): move scrape example configuration into Cargo.toml before stabilization
// See: https://github.com/rust-lang/cargo/pull/9525#discussion_r728470927
rustdoc_scrape_examples: Option<String> = ("Allow rustdoc to scrape examples from reverse-dependencies for documentation"),
ignore_scrape_failures: bool = ("When scraping examples for Rustdoc, don't stop compilation if an example fails"),
skip_rustdoc_fingerprint: bool = (HIDDEN),
);

@@ -936,6 +937,7 @@ impl CliUnstable {
)
}
}
"ignore-scrape-failures" => self.ignore_scrape_failures = parse_empty(k, v)?,
"skip-rustdoc-fingerprint" => self.skip_rustdoc_fingerprint = parse_empty(k, v)?,
"compile-progress" => stabilized_warn(k, "1.30", STABILIZED_COMPILE_PROGRESS),
"offline" => stabilized_err(k, "1.36", STABILIZED_OFFLINE)?,
2 changes: 1 addition & 1 deletion src/cargo/ops/cargo_compile.rs
Original file line number Diff line number Diff line change
@@ -1069,7 +1069,7 @@ fn generate_targets(
/*is_std*/ false,
/*dep_hash*/ 0,
IsArtifact::No,
mode.is_doc_scrape(),
mode.is_doc_scrape() && ws.config().cli_unstable().ignore_scrape_failures,
);
units.insert(unit);
}
16 changes: 9 additions & 7 deletions tests/testsuite/doc.rs
Original file line number Diff line number Diff line change
@@ -2667,10 +2667,12 @@ fn scrape_examples_no_fail_bad_example() {
.file("src/lib.rs", "pub fn foo(){}")
.build();

p.cargo("doc -v -Zunstable-options -Z rustdoc-scrape-examples=examples")
.masquerade_as_nightly_cargo()
.with_stderr_unordered(
"\
p.cargo(
"doc -v -Zunstable-options -Z rustdoc-scrape-examples=examples -Z ignore-scrape-failures",
)
.masquerade_as_nightly_cargo()
.with_stderr_unordered(
"\
[CHECKING] foo v0.0.1 ([CWD])
[RUNNING] `rustc --crate-name foo[..]
[RUNNING] `rustdoc[..] --crate-name ex1[..]
@@ -2684,8 +2686,8 @@ error: expected one of `!` or `::`, found `NOT`
[DOCUMENTING] foo v0.0.1 ([CWD])
[RUNNING] `rustdoc[..] --crate-name foo[..]
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]",
)
.run();
)
.run();

let doc_html = p.read_file("target/doc/foo/fn.foo.html");
assert!(doc_html.contains("Examples found in repository"));
@@ -2728,7 +2730,7 @@ fn scrape_examples_no_fail_bad_dependency() {
.file("dep/src/lib.rs", "DOES NOT COMPILE")
.build();

p.cargo("doc -Zunstable-options -Z rustdoc-scrape-examples=all")
p.cargo("doc -Zunstable-options -Z rustdoc-scrape-examples=all -Z ignore-scrape-failures")
.masquerade_as_nightly_cargo()
.with_stderr_unordered(
"\

0 comments on commit decc3f0

Please sign in to comment.