mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Auto merge of #11694 - weihanglo:issue-11623, r=epage
`-Zrustdoc-scrape-example` must fail with bad build script
This commit is contained in:
commit
a49049817d
@ -211,16 +211,24 @@ impl RustdocScrapeExamples {
|
||||
}
|
||||
|
||||
impl BuildContext<'_, '_> {
|
||||
/// Returns the set of Docscrape units that have a direct dependency on `unit`
|
||||
/// Returns the set of [`Docscrape`] units that have a direct dependency on `unit`.
|
||||
///
|
||||
/// [`RunCustomBuild`] units are excluded because we allow failures
|
||||
/// from type checks but not build script executions.
|
||||
/// A plain old `cargo doc` would just die if a build script execution fails,
|
||||
/// there is no reason for `-Zrustdoc-scrape-examples` to keep going.
|
||||
///
|
||||
/// [`Docscrape`]: crate::core::compiler::CompileMode::Docscrape
|
||||
/// [`RunCustomBuild`]: crate::core::compiler::CompileMode::Docscrape
|
||||
pub fn scrape_units_have_dep_on<'a>(&'a self, unit: &'a Unit) -> Vec<&'a Unit> {
|
||||
self.scrape_units
|
||||
.iter()
|
||||
.filter(|scrape_unit| {
|
||||
self.unit_graph[scrape_unit]
|
||||
.iter()
|
||||
.any(|dep| &dep.unit == unit)
|
||||
.any(|dep| &dep.unit == unit && !dep.unit.mode.is_run_custom_build())
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Returns true if this unit is needed for doing doc-scraping and is also
|
||||
|
@ -366,6 +366,37 @@ warning: `foo` (example \"ex2\") generated 1 warning
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test(nightly, reason = "rustdoc scrape examples flags are unstable")]
|
||||
fn fail_bad_build_script() {
|
||||
// See rust-lang/cargo#11623
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.file("build.rs", "fn main() { panic!(\"You shall not pass\")}")
|
||||
.file("examples/ex.rs", "fn main() {}")
|
||||
.build();
|
||||
|
||||
// `cargo doc` fails
|
||||
p.cargo("doc")
|
||||
.with_status(101)
|
||||
.with_stderr_contains("[..]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[..]")
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test(nightly, reason = "rustdoc scrape examples flags are unstable")]
|
||||
fn no_fail_bad_example() {
|
||||
let p = project()
|
||||
|
Loading…
x
Reference in New Issue
Block a user