Skip to content

Commit

Permalink
Update tests if scraping is only on nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
willcrichton committed Apr 14, 2022
1 parent 9e7a5ed commit 1daaf68
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 164 deletions.
3 changes: 1 addition & 2 deletions src/cargo/core/compiler/unit_dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -712,15 +712,14 @@ fn compute_deps_doc(
if state.ws.unit_needs_doc_scrape(unit) {
for scrape_unit in state.scrape_units.iter() {
deps_of(scrape_unit, state, unit_for)?;
ret.push(new_unit_dep_with_profile(
ret.push(new_unit_dep(
state,
scrape_unit,
&scrape_unit.pkg,
&scrape_unit.target,
unit_for,
scrape_unit.kind,
scrape_unit.mode,
scrape_unit.profile.clone(),
IS_NO_ARTIFACT_DEP,
)?);
}
Expand Down
13 changes: 7 additions & 6 deletions src/cargo/core/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -808,12 +808,13 @@ impl Target {
self.inner.edition
}
pub fn doc_scrape_examples(&self) -> bool {
self.inner.doc_scrape_examples.unwrap_or_else(|| {
matches!(
self.kind(),
TargetKind::Lib(..) | TargetKind::ExampleBin | TargetKind::ExampleLib(..)
)
})
!self.for_host()
&& self.inner.doc_scrape_examples.unwrap_or_else(|| {
matches!(
self.kind(),
TargetKind::Lib(..) | TargetKind::ExampleBin | TargetKind::ExampleLib(..)
)
})
}
pub fn benched(&self) -> bool {
self.inner.benched
Expand Down
16 changes: 14 additions & 2 deletions tests/testsuite/artifact_dep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
use cargo_test_support::compare::match_exact;
use cargo_test_support::registry::Package;
use cargo_test_support::{
basic_bin_manifest, basic_manifest, cross_compile, project, publish, registry, rustc_host,
Project,
basic_bin_manifest, basic_manifest, cross_compile, is_nightly, project, publish, registry,
rustc_host, Project,
};

#[cargo_test]
Expand Down Expand Up @@ -1991,6 +1991,11 @@ target = "target""#,

#[cargo_test]
fn doc_lib_true() {
if !is_nightly() {
// nightly rustdoc invokes scrape examples, which is not stable
return;
}

let p = project()
.file(
"Cargo.toml",
Expand Down Expand Up @@ -2019,6 +2024,7 @@ fn doc_lib_true() {
"\
[COMPILING] bar v0.0.1 ([CWD]/bar)
[DOCUMENTING] bar v0.0.1 ([CWD]/bar)
[SCRAPING] foo v0.0.1 ([CWD])
[DOCUMENTING] foo v0.0.1 ([CWD])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
",
Expand Down Expand Up @@ -2046,6 +2052,11 @@ fn doc_lib_true() {

#[cargo_test]
fn rustdoc_works_on_libs_with_artifacts_and_lib_false() {
if !is_nightly() {
// nightly rustdoc invokes scrape examples, which is not stable
return;
}

let p = project()
.file(
"Cargo.toml",
Expand Down Expand Up @@ -2094,6 +2105,7 @@ fn rustdoc_works_on_libs_with_artifacts_and_lib_false() {
.with_stderr(
"\
[COMPILING] bar v0.5.0 ([CWD]/bar)
[SCRAPING] foo v0.0.1 ([CWD])
[DOCUMENTING] foo v0.0.1 ([CWD])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
",
Expand Down
2 changes: 0 additions & 2 deletions tests/testsuite/build_script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1317,8 +1317,6 @@ fn testing_and_such() {
p.cargo("doc -v")
.with_stderr(
"\
[SCRAPING] foo v0.5.0 ([CWD])
[RUNNING] `rustdoc [..]`
[DOCUMENTING] foo v0.5.0 ([CWD])
[RUNNING] `rustdoc [..]`
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
Expand Down
4 changes: 0 additions & 4 deletions tests/testsuite/collisions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ fn collision_doc_multiple_versions() {
[CHECKING] bar v1.0.0
[DOCUMENTING] bar v2.0.0
[FINISHED] [..]
[SCRAPING] foo v0.1.0 [..]
[DOCUMENTING] foo v0.1.0 [..]
",
)
Expand Down Expand Up @@ -379,7 +378,6 @@ fn collision_doc_profile_split() {
[CHECKING] common v1.0.0
[DOCUMENTING] common v1.0.0
[DOCUMENTING] pm v0.1.0 [..]
[SCRAPING] foo v0.1.0 [..]
[DOCUMENTING] foo v0.1.0 [..]
[FINISHED] [..]
",
Expand Down Expand Up @@ -426,7 +424,6 @@ the same path; see <https://github.com/rust-lang/cargo/issues/6313>.
[DOCUMENTING] bar v1.0.0 [..]
[DOCUMENTING] bar v1.0.0
[CHECKING] bar v1.0.0
[SCRAPING] foo v0.1.0 [..]
[DOCUMENTING] foo v0.1.0 [..]
[FINISHED] [..]
",
Expand Down Expand Up @@ -541,7 +538,6 @@ the same path; see <https://github.com/rust-lang/cargo/issues/6313>.
[CHECKING] foo-macro v1.0.0
[DOCUMENTING] foo-macro v1.0.0
[CHECKING] abc v1.0.0 [..]
[SCRAPING] foo-macro v1.0.0 [..]
[DOCUMENTING] foo-macro v1.0.0 [..]
[DOCUMENTING] abc v1.0.0 [..]
[FINISHED] [..]
Expand Down
Loading

0 comments on commit 1daaf68

Please sign in to comment.