Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group build script failures separately and extract the build script's crate #672

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions local-crates/build-script-fail/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "build-fail"
version = "0.1.0"
authors = ["Pietro Albini <pietro@pietroalbini.org>"]
build = "build.rs"

[dependencies]
3 changes: 3 additions & 0 deletions local-crates/build-script-fail/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
panic!("kawoom")
}
1 change: 1 addition & 0 deletions local-crates/build-script-fail/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fn main() {}
2 changes: 2 additions & 0 deletions src/report/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ impl ResultName for FailureReason {
FailureReason::OOM => "OOM".into(),
FailureReason::ICE => "ICE".into(),
FailureReason::CompilerError(_) => "compiler error".into(),
FailureReason::BuildScript => "build script failure".into(),
FailureReason::DependsOn(_) => "faulty deps".into(),
}
}
Expand All @@ -26,6 +27,7 @@ impl ResultName for FailureReason {
FailureReason::Unknown
| FailureReason::NetworkAccess
| FailureReason::Timeout
| FailureReason::BuildScript
| FailureReason::OOM
| FailureReason::ICE => self.short_name(),
}
Expand Down
4 changes: 4 additions & 0 deletions src/results/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ pub enum FailureReason {
Timeout,
ICE,
NetworkAccess,
BuildScript,
CompilerError(BTreeSet<DiagnosticCode>),
DependsOn(BTreeSet<Crate>),
}
Expand All @@ -213,6 +214,7 @@ impl ::std::fmt::Display for FailureReason {
FailureReason::Timeout => write!(f, "timeout"),
FailureReason::ICE => write!(f, "ice"),
FailureReason::NetworkAccess => write!(f, "network-access"),
FailureReason::BuildScript => write!(f, "build-script"),
FailureReason::CompilerError(codes) => write!(
f,
"compiler-error({})",
Expand Down Expand Up @@ -261,6 +263,7 @@ impl ::std::str::FromStr for FailureReason {
} else {
match s {
"network-access" => Ok(FailureReason::NetworkAccess),
"build-script" => Ok(FailureReason::BuildScript),
"unknown" => Ok(FailureReason::Unknown),
"oom" => Ok(FailureReason::OOM),
"timeout" => Ok(FailureReason::Timeout),
Expand All @@ -277,6 +280,7 @@ impl FailureReason {
FailureReason::OOM | FailureReason::Timeout | FailureReason::NetworkAccess => true,
FailureReason::CompilerError(_)
| FailureReason::DependsOn(_)
| FailureReason::BuildScript
| FailureReason::Unknown
| FailureReason::ICE => false,
}
Expand Down
15 changes: 14 additions & 1 deletion src/runner/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::results::{BrokenReason, EncodingType, FailureReason, TestResult, Writ
use crate::runner::tasks::TaskCtx;
use crate::runner::OverrideResult;
use cargo_metadata::diagnostic::DiagnosticLevel;
use cargo_metadata::{Message, Metadata, Package, Target};
use cargo_metadata::{Message, Metadata, Package, PackageId, Target};
use docsrs_metadata::Metadata as DocsrsMetadata;
use failure::Error;
use remove_dir_all::remove_dir_all;
Expand Down Expand Up @@ -109,6 +109,7 @@ fn run_cargo<DB: WriteResults>(
}

let mut did_ice = false;
let mut build_script_failure = false;
let mut did_network = false;
let mut error_codes = BTreeSet::new();
let mut deps = BTreeSet::new();
Expand All @@ -123,6 +124,16 @@ fn run_cargo<DB: WriteResults>(
if line.contains("code: 111") && line.contains("Connection refused") {
did_network = true;
}
if let Some(rest) = line.strip_prefix("error: failed to run custom build command for `") {
build_script_failure = true;
let krate = rest.trim_end_matches('`');
let krate = PackageId { repr: krate.into() };
if !local_packages_id.contains(&krate) {
if let Ok(krate) = Crate::try_from(&krate) {
deps.insert(krate);
}
}
}

// Avoid trying to deserialize non JSON output
if !line.starts_with('{') {
Expand Down Expand Up @@ -198,6 +209,8 @@ fn run_cargo<DB: WriteResults>(
Err(e.context(FailureReason::CompilerError(error_codes)).into())
} else if did_network {
Err(e.context(FailureReason::NetworkAccess).into())
} else if build_script_failure {
Err(e.context(FailureReason::BuildScript).into())
} else {
Err(e.into())
}
Expand Down
2 changes: 1 addition & 1 deletion tests/minicrater/full/downloads.html.context.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"path": "logs-archives/test-fail.tar.gz"
}
],
"crates_count": 17,
"crates_count": 18,
"nav": [
{
"active": false,
Expand Down
69 changes: 45 additions & 24 deletions tests/minicrater/full/full.html.context.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,38 +118,40 @@
"fixed",
{
"RootResults": {
"count": 1,
"count": 2,
"results": {
"build failed (unknown)": [
"build build script failure": [
{
"name": "beta-fixed (local)",
"name": "network-access (local)",
"res": "fixed",
"runs": [
{
"log": "stable/local/beta-fixed",
"res": 2
"log": "stable/local/network-access",
"res": 6
},
{
"log": "beta/local/beta-fixed",
"res": 0
"log": "beta/local/network-access",
"res": 7
}
],
"url": "https://github.com/rust-lang/crater/tree/master/local-crates/beta-fixed"
},
"url": "https://github.com/rust-lang/crater/tree/master/local-crates/network-access"
}
],
"build failed (unknown)": [
{
"name": "network-access (local)",
"name": "beta-fixed (local)",
"res": "fixed",
"runs": [
{
"log": "stable/local/network-access",
"log": "stable/local/beta-fixed",
"res": 2
},
{
"log": "beta/local/network-access",
"res": 6
"log": "beta/local/beta-fixed",
"res": 0
}
],
"url": "https://github.com/rust-lang/crater/tree/master/local-crates/network-access"
"url": "https://github.com/rust-lang/crater/tree/master/local-crates/beta-fixed"
}
]
}
Expand All @@ -166,11 +168,11 @@
"runs": [
{
"log": "stable/local/broken-cargotoml",
"res": 7
"res": 8
},
{
"log": "beta/local/broken-cargotoml",
"res": 7
"res": 8
}
],
"url": "https://github.com/rust-lang/crater/tree/master/local-crates/broken-cargotoml"
Expand All @@ -181,11 +183,11 @@
"runs": [
{
"log": "stable/local/yanked-deps",
"res": 8
"res": 9
},
{
"log": "beta/local/yanked-deps",
"res": 8
"res": 9
}
],
"url": "https://github.com/rust-lang/crater/tree/master/local-crates/yanked-deps"
Expand All @@ -212,17 +214,32 @@
],
"url": "https://github.com/rust-lang/crater/tree/master/local-crates/build-fail"
},
{
"name": "build-script-fail (local)",
"res": "build-fail",
"runs": [
{
"log": "stable/local/build-script-fail",
"res": 6
},
{
"log": "beta/local/build-script-fail",
"res": 6
}
],
"url": "https://github.com/rust-lang/crater/tree/master/local-crates/build-script-fail"
},
{
"name": "faulty-deps (local)",
"res": "build-fail",
"runs": [
{
"log": "stable/local/faulty-deps",
"res": 9
"res": 10
},
{
"log": "beta/local/faulty-deps",
"res": 9
"res": 10
}
],
"url": "https://github.com/rust-lang/crater/tree/master/local-crates/faulty-deps"
Expand Down Expand Up @@ -338,11 +355,11 @@
"runs": [
{
"log": "stable/local/test-fail",
"res": 6
"res": 7
},
{
"log": "beta/local/test-fail",
"res": 6
"res": 7
}
],
"url": "https://github.com/rust-lang/crater/tree/master/local-crates/test-fail"
Expand Down Expand Up @@ -377,11 +394,11 @@
"Single": "#72a156"
}
},
"crates_count": 17,
"crates_count": 18,
"full": true,
"info": {
"broken": 2,
"build-fail": 2,
"build-fail": 3,
"fixed": 2,
"regressed": 4,
"skipped": 1,
Expand Down Expand Up @@ -424,6 +441,9 @@
{
"Single": "#db3026"
},
{
"Single": "#db3026"
},
{
"Single": "#65461e"
},
Expand All @@ -444,6 +464,7 @@
"build compiler error",
"build compiler error",
"build ICE",
"build build script failure",
"test failed (unknown)",
"broken Cargo.toml",
"deps yanked",
Expand Down
38 changes: 22 additions & 16 deletions tests/minicrater/full/index.html.context.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,38 +118,40 @@
"fixed",
{
"RootResults": {
"count": 1,
"count": 2,
"results": {
"build failed (unknown)": [
"build build script failure": [
{
"name": "beta-fixed (local)",
"name": "network-access (local)",
"res": "fixed",
"runs": [
{
"log": "stable/local/beta-fixed",
"res": 2
"log": "stable/local/network-access",
"res": 6
},
{
"log": "beta/local/beta-fixed",
"res": 0
"log": "beta/local/network-access",
"res": 7
}
],
"url": "https://github.com/rust-lang/crater/tree/master/local-crates/beta-fixed"
},
"url": "https://github.com/rust-lang/crater/tree/master/local-crates/network-access"
}
],
"build failed (unknown)": [
{
"name": "network-access (local)",
"name": "beta-fixed (local)",
"res": "fixed",
"runs": [
{
"log": "stable/local/network-access",
"log": "stable/local/beta-fixed",
"res": 2
},
{
"log": "beta/local/network-access",
"res": 6
"log": "beta/local/beta-fixed",
"res": 0
}
],
"url": "https://github.com/rust-lang/crater/tree/master/local-crates/network-access"
"url": "https://github.com/rust-lang/crater/tree/master/local-crates/beta-fixed"
}
]
}
Expand All @@ -165,11 +167,11 @@
"Single": "#db3026"
}
},
"crates_count": 17,
"crates_count": 18,
"full": false,
"info": {
"broken": 2,
"build-fail": 2,
"build-fail": 3,
"fixed": 2,
"regressed": 4,
"skipped": 1,
Expand Down Expand Up @@ -212,6 +214,9 @@
{
"Single": "#db3026"
},
{
"Single": "#db3026"
},
{
"Single": "#65461e"
}
Expand All @@ -223,6 +228,7 @@
"build compiler error",
"build compiler error",
"build ICE",
"build build script failure",
"test failed (unknown)"
]
}
6 changes: 3 additions & 3 deletions tests/minicrater/full/markdown.md.context.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
"runs": [
{
"log": "stable/local/network-access",
"res": "build-fail:unknown"
"res": "build-fail:build-script"
},
{
"log": "beta/local/network-access",
Expand All @@ -156,11 +156,11 @@
}
]
],
"crates_count": 17,
"crates_count": 18,
"full": false,
"info": {
"broken": 2,
"build-fail": 2,
"build-fail": 3,
"fixed": 2,
"regressed": 4,
"skipped": 1,
Expand Down
Loading