diff --git a/Cargo.lock b/Cargo.lock index e87d1eafb..d865676be 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -312,6 +312,7 @@ dependencies = [ "csv 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "ctrlc 3.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "docsrs-metadata 0.1.0 (git+https://github.com/rust-lang/docs.rs/)", "dotenv 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -506,6 +507,16 @@ dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "docsrs-metadata" +version = "0.1.0" +source = "git+https://github.com/rust-lang/docs.rs/#bfa6adaabd3081be8e5d0f93d498b93d167469b9" +dependencies = [ + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.20 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "dotenv" version = "0.13.0" @@ -3136,6 +3147,7 @@ dependencies = [ "checksum digest 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "03b072242a8cbaf9c145665af9d250c59af3b958f83ed6824e13533cf76d5b90" "checksum digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05f47366984d3ad862010e22c7ce81a7dbcaebbdfb37241a620f8b6596ee135c" "checksum dirs 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "88972de891f6118092b643d85a0b28e0678e0f948d7f879aa32f2d5aafe97d2a" +"checksum docsrs-metadata 0.1.0 (git+https://github.com/rust-lang/docs.rs/)" = "" "checksum dotenv 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0d0a1279c96732bc6800ce6337b6a614697b0e74ae058dc03c62ebeb78b4d86" "checksum dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6d301140eb411af13d3115f9a562c85cc6b541ade9dfa314132244aaee7489dd" "checksum encoding_rs 0.8.10 (registry+https://github.com/rust-lang/crates.io-index)" = "065f4d0c826fdaef059ac45487169d918558e3cf86c9d89f6e81cf52369126e5" diff --git a/Cargo.toml b/Cargo.toml index 35fa752c5..b46178cbf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,7 @@ chrono-humanize = "0.0.11" crates-index = "0.12" crossbeam-utils = "0.5" csv = "1.0.2" +docsrs-metadata = { git = "https://github.com/rust-lang/docs.rs/" } dotenv = "0.13" error-chain = "0.12" failure = "0.1.3" diff --git a/local-crates/docs-rs-features/Cargo.toml b/local-crates/docs-rs-features/Cargo.toml new file mode 100644 index 000000000..b9ff60158 --- /dev/null +++ b/local-crates/docs-rs-features/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "docs-rs-features" +version = "0.1.0" +authors = ["Joshua Nelson "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] + +[package.metadata.docs.rs] +features = ["docs_rs_feature"] + +[features] +docs_rs_feature = [] diff --git a/local-crates/docs-rs-features/src/main.rs b/local-crates/docs-rs-features/src/main.rs new file mode 100644 index 000000000..74d165969 --- /dev/null +++ b/local-crates/docs-rs-features/src/main.rs @@ -0,0 +1,6 @@ +#[cfg(feature = "docs_rs_feature")] +compile_error!("oh no, a hidden regression!"); + +fn main() { + println!("Hello, world!"); +} diff --git a/src/runner/test.rs b/src/runner/test.rs index 7bfac40db..9160fa71e 100644 --- a/src/runner/test.rs +++ b/src/runner/test.rs @@ -6,11 +6,12 @@ use crate::runner::tasks::TaskCtx; use crate::runner::OverrideResult; use cargo_metadata::diagnostic::DiagnosticLevel; use cargo_metadata::{Message, Metadata, PackageId}; +use docsrs_metadata::Metadata as DocsrsMetadata; use failure::Error; use remove_dir_all::remove_dir_all; use rustwide::cmd::{CommandError, ProcessLinesActions, SandboxBuilder}; use rustwide::{Build, PrepareError}; -use std::collections::{BTreeSet, HashSet}; +use std::collections::{BTreeSet, HashMap, HashSet}; use std::convert::TryFrom; fn failure_reason(err: &Error) -> FailureReason { @@ -80,8 +81,9 @@ fn run_cargo( args: &[&str], check_errors: bool, local_packages_id: &HashSet, + mut env: HashMap<&'static str, String>, ) -> Fallible<()> { - let mut rustflags = format!("--cap-lints={}", ctx.experiment.cap_lints.to_str()); + let mut rustflags = format!(" --cap-lints={}", ctx.experiment.cap_lints.to_str()); if let Some(ref tc_rustflags) = ctx.toolchain.rustflags { rustflags.push(' '); rustflags.push_str(tc_rustflags); @@ -92,6 +94,7 @@ fn run_cargo( } else { "RUSTFLAGS" }; + env.entry(rustflags_env).or_default().push_str(&rustflags); let mut did_ice = false; let mut error_codes = BTreeSet::new(); @@ -146,8 +149,10 @@ fn run_cargo( .cargo() .args(args) .env("CARGO_INCREMENTAL", "0") - .env("RUST_BACKTRACE", "full") - .env(rustflags_env, rustflags); + .env("RUST_BACKTRACE", "full"); + for (var, data) in env { + command = command.env(var, data); + } if check_errors { command = command.process_lines(&mut detect_error); @@ -238,6 +243,7 @@ fn build( &["build", "--frozen", "--message-format=json"], true, local_packages_id, + HashMap::default(), )?; run_cargo( ctx, @@ -245,6 +251,7 @@ fn build( &["test", "--frozen", "--no-run", "--message-format=json"], true, local_packages_id, + HashMap::default(), )?; Ok(()) } @@ -256,6 +263,7 @@ fn test(ctx: &TaskCtx, build_env: &Build) -> Fallible<()> &["test", "--frozen"], false, &HashSet::new(), + HashMap::default(), ) } @@ -308,6 +316,7 @@ pub(super) fn test_check_only( ], true, local_packages_id, + HashMap::default(), ) { Ok(TestResult::BuildFail(failure_reason(&err))) } else { @@ -332,6 +341,7 @@ pub(super) fn test_clippy_only( ], true, local_packages_id, + HashMap::default(), ) { Ok(TestResult::BuildFail(failure_reason(&err))) } else { @@ -344,18 +354,21 @@ pub(super) fn test_rustdoc( build_env: &Build, local_packages_id: &HashSet, ) -> Fallible { + let src = build_env.host_source_dir(); + let metadata = DocsrsMetadata::from_crate_root(src)?; + let cargo_args = metadata.cargo_args(); + assert_eq!(cargo_args[0], "doc"); + let mut cargo_args: Vec<_> = cargo_args.iter().map(|s| s.as_str()).collect(); + cargo_args.push("--frozen"); + cargo_args.push("--message-format=json"); + let res = run_cargo( ctx, build_env, - &[ - "doc", - "--frozen", - "--no-deps", - "--document-private-items", - "--message-format=json", - ], + &cargo_args, true, local_packages_id, + metadata.environment_variables(), ); // Make sure to remove the built documentation diff --git a/tests/minicrater/doc/config.toml b/tests/minicrater/doc/config.toml new file mode 100644 index 000000000..efe718c91 --- /dev/null +++ b/tests/minicrater/doc/config.toml @@ -0,0 +1,27 @@ +[server.bot-acl] +rust-teams = true +github = ["pietroalbini"] + +[server.labels] +remove = "^S-" +experiment-queued = "S-waiting-on-crater" +experiment-completed = "S-waiting-on-review" + +[server.distributed] +chunk-size = 32 + +[demo-crates] +crates = [] +github-repos = [] +local-crates = ["build-pass", "docs-rs-features"] + +[sandbox] +memory-limit = "512M" +build-log-max-size = "2M" +build-log-max-lines = 1000 + +[crates] + +[github-repos] + +[local-crates] diff --git a/tests/minicrater/doc/downloads.html.context.expected.json b/tests/minicrater/doc/downloads.html.context.expected.json new file mode 100644 index 000000000..298e097d7 --- /dev/null +++ b/tests/minicrater/doc/downloads.html.context.expected.json @@ -0,0 +1,30 @@ +{ + "available_archives": [ + { + "name": "All the crates", + "path": "logs-archives/all.tar.gz" + }, + { + "name": "error crates", + "path": "logs-archives/error.tar.gz" + } + ], + "crates_count": 2, + "nav": [ + { + "active": false, + "label": "Summary", + "url": "index.html" + }, + { + "active": false, + "label": "Full report", + "url": "full.html" + }, + { + "active": true, + "label": "Downloads", + "url": "downloads.html" + } + ] +} diff --git a/tests/minicrater/doc/full.html.context.expected.json b/tests/minicrater/doc/full.html.context.expected.json new file mode 100644 index 000000000..5f6fef49a --- /dev/null +++ b/tests/minicrater/doc/full.html.context.expected.json @@ -0,0 +1,76 @@ +{ + "categories": [ + [ + "error", + { + "Plain": [ + { + "name": "build-pass (local)", + "res": "error", + "runs": [ + { + "log": "stable/local/build-pass", + "res": 0 + }, + { + "log": "beta/local/build-pass", + "res": 0 + } + ], + "url": "https://github.com/rust-lang/crater/tree/master/local-crates/build-pass" + }, + { + "name": "docs-rs-features (local)", + "res": "error", + "runs": [ + { + "log": "stable/local/docs-rs-features", + "res": 0 + }, + { + "log": "beta/local/docs-rs-features", + "res": 0 + } + ], + "url": "https://github.com/rust-lang/crater/tree/master/local-crates/docs-rs-features" + } + ] + } + ] + ], + "comparison_colors": { + "error": { + "Single": "#d77026" + } + }, + "crates_count": 2, + "full": true, + "info": { + "error": 2 + }, + "nav": [ + { + "active": false, + "label": "Summary", + "url": "index.html" + }, + { + "active": true, + "label": "Full report", + "url": "full.html" + }, + { + "active": false, + "label": "Downloads", + "url": "downloads.html" + } + ], + "result_colors": [ + { + "Single": "#d77026" + } + ], + "result_names": [ + "error" + ] +} diff --git a/tests/minicrater/doc/index.html.context.expected.json b/tests/minicrater/doc/index.html.context.expected.json new file mode 100644 index 000000000..d89b74bb4 --- /dev/null +++ b/tests/minicrater/doc/index.html.context.expected.json @@ -0,0 +1,76 @@ +{ + "categories": [ + [ + "error", + { + "Plain": [ + { + "name": "build-pass (local)", + "res": "error", + "runs": [ + { + "log": "stable/local/build-pass", + "res": 0 + }, + { + "log": "beta/local/build-pass", + "res": 0 + } + ], + "url": "https://github.com/rust-lang/crater/tree/master/local-crates/build-pass" + }, + { + "name": "docs-rs-features (local)", + "res": "error", + "runs": [ + { + "log": "stable/local/docs-rs-features", + "res": 0 + }, + { + "log": "beta/local/docs-rs-features", + "res": 0 + } + ], + "url": "https://github.com/rust-lang/crater/tree/master/local-crates/docs-rs-features" + } + ] + } + ] + ], + "comparison_colors": { + "error": { + "Single": "#d77026" + } + }, + "crates_count": 2, + "full": false, + "info": { + "error": 2 + }, + "nav": [ + { + "active": true, + "label": "Summary", + "url": "index.html" + }, + { + "active": false, + "label": "Full report", + "url": "full.html" + }, + { + "active": false, + "label": "Downloads", + "url": "downloads.html" + } + ], + "result_colors": [ + { + "Single": "#d77026" + } + ], + "result_names": [ + "error" + ] +} diff --git a/tests/minicrater/doc/markdown.md.context.expected.json b/tests/minicrater/doc/markdown.md.context.expected.json new file mode 100644 index 000000000..3497771b3 --- /dev/null +++ b/tests/minicrater/doc/markdown.md.context.expected.json @@ -0,0 +1,52 @@ +{ + "categories": [ + [ + "error", + { + "Plain": [ + { + "krate": { + "Local": "build-pass" + }, + "name": "build-pass (local)", + "res": "error", + "runs": [ + { + "log": "stable/local/build-pass", + "res": "error" + }, + { + "log": "beta/local/build-pass", + "res": "error" + } + ], + "url": "https://github.com/rust-lang/crater/tree/master/local-crates/build-pass" + }, + { + "krate": { + "Local": "docs-rs-features" + }, + "name": "docs-rs-features (local)", + "res": "error", + "runs": [ + { + "log": "stable/local/docs-rs-features", + "res": "error" + }, + { + "log": "beta/local/docs-rs-features", + "res": "error" + } + ], + "url": "https://github.com/rust-lang/crater/tree/master/local-crates/docs-rs-features" + } + ] + } + ] + ], + "crates_count": 2, + "full": false, + "info": { + "error": 2 + } +} diff --git a/tests/minicrater/doc/results.expected.json b/tests/minicrater/doc/results.expected.json new file mode 100644 index 000000000..26c3976d0 --- /dev/null +++ b/tests/minicrater/doc/results.expected.json @@ -0,0 +1,40 @@ +{ + "crates": [ + { + "krate": { + "Local": "build-pass" + }, + "name": "build-pass (local)", + "res": "error", + "runs": [ + { + "log": "stable/local/build-pass", + "res": "error" + }, + { + "log": "beta/local/build-pass", + "res": "error" + } + ], + "url": "https://github.com/rust-lang/crater/tree/master/local-crates/build-pass" + }, + { + "krate": { + "Local": "docs-rs-features" + }, + "name": "docs-rs-features (local)", + "res": "error", + "runs": [ + { + "log": "stable/local/docs-rs-features", + "res": "error" + }, + { + "log": "beta/local/docs-rs-features", + "res": "error" + } + ], + "url": "https://github.com/rust-lang/crater/tree/master/local-crates/docs-rs-features" + } + ] +} diff --git a/tests/minicrater/full/downloads.html.context.expected.json b/tests/minicrater/full/downloads.html.context.expected.json index 9ade340bb..cebdf81b2 100644 --- a/tests/minicrater/full/downloads.html.context.expected.json +++ b/tests/minicrater/full/downloads.html.context.expected.json @@ -29,7 +29,7 @@ "path": "logs-archives/test-fail.tar.gz" } ], - "crates_count": 16, + "crates_count": 17, "nav": [ { "active": false, diff --git a/tests/minicrater/full/full.html.context.expected.json b/tests/minicrater/full/full.html.context.expected.json index 25336c300..ca7a514a8 100644 --- a/tests/minicrater/full/full.html.context.expected.json +++ b/tests/minicrater/full/full.html.context.expected.json @@ -264,6 +264,21 @@ ], "url": "https://github.com/rust-lang/crater/tree/master/local-crates/clippy-warn" }, + { + "name": "docs-rs-features (local)", + "res": "test-pass", + "runs": [ + { + "log": "stable/local/docs-rs-features", + "res": 0 + }, + { + "log": "beta/local/docs-rs-features", + "res": 0 + } + ], + "url": "https://github.com/rust-lang/crater/tree/master/local-crates/docs-rs-features" + }, { "name": "missing-examples (local)", "res": "test-pass", @@ -362,7 +377,7 @@ "Single": "#72a156" } }, - "crates_count": 16, + "crates_count": 17, "full": true, "info": { "broken": 2, @@ -371,7 +386,7 @@ "regressed": 4, "skipped": 1, "test-fail": 1, - "test-pass": 4 + "test-pass": 5 }, "nav": [ { diff --git a/tests/minicrater/full/index.html.context.expected.json b/tests/minicrater/full/index.html.context.expected.json index 3654e1b07..7763beb80 100644 --- a/tests/minicrater/full/index.html.context.expected.json +++ b/tests/minicrater/full/index.html.context.expected.json @@ -165,7 +165,7 @@ "Single": "#db3026" } }, - "crates_count": 16, + "crates_count": 17, "full": false, "info": { "broken": 2, @@ -174,7 +174,7 @@ "regressed": 4, "skipped": 1, "test-fail": 1, - "test-pass": 4 + "test-pass": 5 }, "nav": [ { diff --git a/tests/minicrater/full/markdown.md.context.expected.json b/tests/minicrater/full/markdown.md.context.expected.json index 977808596..41d2366cd 100644 --- a/tests/minicrater/full/markdown.md.context.expected.json +++ b/tests/minicrater/full/markdown.md.context.expected.json @@ -156,7 +156,7 @@ } ] ], - "crates_count": 16, + "crates_count": 17, "full": false, "info": { "broken": 2, @@ -165,6 +165,6 @@ "regressed": 4, "skipped": 1, "test-fail": 1, - "test-pass": 4 + "test-pass": 5 } } diff --git a/tests/minicrater/full/results.expected.json b/tests/minicrater/full/results.expected.json index 3a3058db0..cd4be6d4c 100644 --- a/tests/minicrater/full/results.expected.json +++ b/tests/minicrater/full/results.expected.json @@ -126,6 +126,24 @@ ], "url": "https://github.com/rust-lang/crater/tree/master/local-crates/clippy-warn" }, + { + "krate": { + "Local": "docs-rs-features" + }, + "name": "docs-rs-features (local)", + "res": "test-pass", + "runs": [ + { + "log": "stable/local/docs-rs-features", + "res": "test-pass" + }, + { + "log": "beta/local/docs-rs-features", + "res": "test-pass" + } + ], + "url": "https://github.com/rust-lang/crater/tree/master/local-crates/docs-rs-features" + }, { "krate": { "Local": "error-code" diff --git a/tests/minicrater/mod.rs b/tests/minicrater/mod.rs index dd387d937..6f1f8f06b 100644 --- a/tests/minicrater/mod.rs +++ b/tests/minicrater/mod.rs @@ -42,6 +42,13 @@ minicrater! { ..Default::default() }, + doc_small { + ex: "doc", + crate_select: "demo", + mode: "rustdoc", + ..Default::default() + }, + single_thread_missing_repo { ex: "missing-repo", crate_select: "dummy", diff --git a/tests/minicrater/resource-exhaustion/downloads.html.context.expected.json b/tests/minicrater/resource-exhaustion/downloads.html.context.expected.json index fa45379ac..4ae5deb1e 100644 --- a/tests/minicrater/resource-exhaustion/downloads.html.context.expected.json +++ b/tests/minicrater/resource-exhaustion/downloads.html.context.expected.json @@ -7,10 +7,6 @@ { "name": "test-pass crates", "path": "logs-archives/test-pass.tar.gz" - }, - { - "name": "spurious-fixed crates", - "path": "logs-archives/spurious-fixed.tar.gz" } ], "crates_count": 2, diff --git a/tests/minicrater/resource-exhaustion/full.html.context.expected.json b/tests/minicrater/resource-exhaustion/full.html.context.expected.json index c742e6b83..49d8f52c5 100644 --- a/tests/minicrater/resource-exhaustion/full.html.context.expected.json +++ b/tests/minicrater/resource-exhaustion/full.html.context.expected.json @@ -18,25 +18,18 @@ } ], "url": "https://github.com/rust-lang/crater/tree/master/local-crates/build-pass" - } - ] - } - ], - [ - "spurious-fixed", - { - "Plain": [ + }, { "name": "memory-hungry (local)", - "res": "spurious-fixed", + "res": "test-pass", "runs": [ { "log": "stable/local/memory-hungry", - "res": 1 + "res": 0 }, { "log": "beta/local/memory-hungry", - "res": 2 + "res": 0 } ], "url": "https://github.com/rust-lang/crater/tree/master/local-crates/memory-hungry" @@ -46,12 +39,6 @@ ] ], "comparison_colors": { - "spurious-fixed": { - "Striped": [ - "#5630db", - "#5d3dcf" - ] - }, "test-pass": { "Single": "#72a156" } @@ -59,8 +46,7 @@ "crates_count": 2, "full": true, "info": { - "spurious-fixed": 1, - "test-pass": 1 + "test-pass": 2 }, "nav": [ { @@ -82,17 +68,9 @@ "result_colors": [ { "Single": "#62a156" - }, - { - "Single": "#db3026" - }, - { - "Single": "#65461e" } ], "result_names": [ - "test passed", - "build OOM", - "test OOM" + "test passed" ] } diff --git a/tests/minicrater/resource-exhaustion/index.html.context.expected.json b/tests/minicrater/resource-exhaustion/index.html.context.expected.json index 536c6039d..e60091230 100644 --- a/tests/minicrater/resource-exhaustion/index.html.context.expected.json +++ b/tests/minicrater/resource-exhaustion/index.html.context.expected.json @@ -1,41 +1,10 @@ { - "categories": [ - [ - "spurious-fixed", - { - "Plain": [ - { - "name": "memory-hungry (local)", - "res": "spurious-fixed", - "runs": [ - { - "log": "stable/local/memory-hungry", - "res": 0 - }, - { - "log": "beta/local/memory-hungry", - "res": 1 - } - ], - "url": "https://github.com/rust-lang/crater/tree/master/local-crates/memory-hungry" - } - ] - } - ] - ], - "comparison_colors": { - "spurious-fixed": { - "Striped": [ - "#5630db", - "#5d3dcf" - ] - } - }, + "categories": [], + "comparison_colors": {}, "crates_count": 2, "full": false, "info": { - "spurious-fixed": 1, - "test-pass": 1 + "test-pass": 2 }, "nav": [ { @@ -54,16 +23,6 @@ "url": "downloads.html" } ], - "result_colors": [ - { - "Single": "#db3026" - }, - { - "Single": "#65461e" - } - ], - "result_names": [ - "build OOM", - "test OOM" - ] + "result_colors": [], + "result_names": [] } diff --git a/tests/minicrater/resource-exhaustion/markdown.md.context.expected.json b/tests/minicrater/resource-exhaustion/markdown.md.context.expected.json index edf5221c6..cd86aa113 100644 --- a/tests/minicrater/resource-exhaustion/markdown.md.context.expected.json +++ b/tests/minicrater/resource-exhaustion/markdown.md.context.expected.json @@ -1,35 +1,8 @@ { - "categories": [ - [ - "spurious-fixed", - { - "Plain": [ - { - "krate": { - "Local": "memory-hungry" - }, - "name": "memory-hungry (local)", - "res": "spurious-fixed", - "runs": [ - { - "log": "stable/local/memory-hungry", - "res": "build-fail:oom" - }, - { - "log": "beta/local/memory-hungry", - "res": "test-fail:oom" - } - ], - "url": "https://github.com/rust-lang/crater/tree/master/local-crates/memory-hungry" - } - ] - } - ] - ], + "categories": [], "crates_count": 2, "full": false, "info": { - "spurious-fixed": 1, - "test-pass": 1 + "test-pass": 2 } }