diff --git a/src/crates/lists.rs b/src/crates/lists.rs index ef533f589..c13408d21 100644 --- a/src/crates/lists.rs +++ b/src/crates/lists.rs @@ -1,4 +1,5 @@ use crate::config::Config; +use crate::crates::sources::github::GitHubRepo; use crate::crates::{Crate, RegistryCrate}; use crate::db::{Database, QueryUtils}; use crate::experiments::CrateSelect; @@ -129,6 +130,7 @@ pub(crate) fn get_crates( CrateSelect::Local => { crates.append(&mut LocalList::get(db)?); } + CrateSelect::Dummy => crates.push(Crate::GitHub(GitHubRepo::dummy())), } crates.sort(); diff --git a/src/crates/sources/github.rs b/src/crates/sources/github.rs index c8284bb1b..c6063f308 100644 --- a/src/crates/sources/github.rs +++ b/src/crates/sources/github.rs @@ -5,6 +5,8 @@ use std::str::FromStr; static CACHED_LIST: &str = "https://raw.githubusercontent.com/rust-ops/rust-repos/master/data/github.csv"; +const DUMMY_ORG: &str = "ghost"; +const DUMMY_NAME: &str = "missing"; #[derive(Deserialize)] struct ListRepo { @@ -73,6 +75,13 @@ impl GitHubRepo { pub(crate) fn slug(&self) -> String { format!("{}/{}", self.org, self.name) } + + pub(crate) fn dummy() -> GitHubRepo { + GitHubRepo { + org: DUMMY_ORG.to_string(), + name: DUMMY_NAME.to_string(), + } + } } impl FromStr for GitHubRepo { diff --git a/src/experiments.rs b/src/experiments.rs index 71451da47..2225e73dc 100644 --- a/src/experiments.rs +++ b/src/experiments.rs @@ -33,6 +33,7 @@ string_enum!(pub enum CrateSelect { SmallRandom => "small-random", Top100 => "top-100", Local => "local", + Dummy => "dummy", }); string_enum!(pub enum CapLints { diff --git a/src/report/html.rs b/src/report/html.rs index 00212183a..385273c48 100644 --- a/src/report/html.rs +++ b/src/report/html.rs @@ -68,6 +68,7 @@ impl ResultName for BrokenReason { BrokenReason::Unknown => "broken crate".into(), BrokenReason::CargoToml => "broken Cargo.toml".into(), BrokenReason::Yanked => "deps yanked".into(), + BrokenReason::MissingGitRepository => "missing repo".into(), } } } diff --git a/src/results/mod.rs b/src/results/mod.rs index d7818e793..d0818b731 100644 --- a/src/results/mod.rs +++ b/src/results/mod.rs @@ -185,6 +185,7 @@ string_enum!(pub enum BrokenReason { Unknown => "unknown", CargoToml => "cargo-toml", Yanked => "yanked", + MissingGitRepository => "missing-git-repository", }); test_result_enum!(pub enum TestResult { diff --git a/src/runner/tasks.rs b/src/runner/tasks.rs index dbb046f84..b6813af4c 100644 --- a/src/runner/tasks.rs +++ b/src/runner/tasks.rs @@ -3,6 +3,7 @@ use crate::crates::Crate; use crate::experiments::Experiment; use crate::prelude::*; use crate::results::{EncodingType, TestResult, WriteResults}; +use crate::runner::test::detect_broken; use crate::runner::{test, RunnerState}; use crate::toolchain::Toolchain; use crate::utils; @@ -178,7 +179,7 @@ impl Task { .insert(self.krate.clone(), storage.clone()); logging::capture(&storage, || { let rustwide_crate = self.krate.to_rustwide(); - rustwide_crate.fetch(workspace)?; + detect_broken(rustwide_crate.fetch(workspace))?; if let Crate::GitHub(repo) = &self.krate { if let Some(sha) = rustwide_crate.git_commit(workspace) { diff --git a/src/runner/test.rs b/src/runner/test.rs index 63ba146cf..ae3de9132 100644 --- a/src/runner/test.rs +++ b/src/runner/test.rs @@ -21,22 +21,26 @@ fn failure_reason(err: &Error) -> FailureReason { FailureReason::Unknown } -fn detect_broken(res: Result) -> Result { +pub(super) fn detect_broken(res: Result) -> Result { match res { Ok(ok) => Ok(ok), Err(err) => { let mut reason = None; for cause in err.iter_chain() { - if let Some(&PrepareError::MissingCargoToml) = cause.downcast_ctx() { - reason = Some(BrokenReason::CargoToml); - } else if let Some(&PrepareError::InvalidCargoTomlSyntax) = cause.downcast_ctx() { - reason = Some(BrokenReason::CargoToml); - } else if let Some(&PrepareError::YankedDependencies) = cause.downcast_ctx() { - reason = Some(BrokenReason::Yanked); - } else { - continue; + if let Some(error) = cause.downcast_ctx() { + reason = match *error { + PrepareError::MissingCargoToml => Some(BrokenReason::CargoToml), + PrepareError::InvalidCargoTomlSyntax => Some(BrokenReason::CargoToml), + PrepareError::YankedDependencies => Some(BrokenReason::Yanked), + PrepareError::PrivateGitRepository => { + Some(BrokenReason::MissingGitRepository) + } + _ => None, + } + } + if reason.is_some() { + break; } - break; } if let Some(reason) = reason { Err(err diff --git a/tests/minicrater/missing-repo/config.toml b/tests/minicrater/missing-repo/config.toml new file mode 100644 index 000000000..b59a6cab0 --- /dev/null +++ b/tests/minicrater/missing-repo/config.toml @@ -0,0 +1,24 @@ +[server.bot-acl] +rust-teams = true +github = ["pietroalbini"] + +[server.labels] +remove = "^S-" +experiment-queued = "S-waiting-on-crater" +experiment-completed = "S-waiting-on-review" + +[demo-crates] +crates = [] +github-repos = [] +local-crates = [] + +[sandbox] +memory-limit = "512M" +build-log-max-size = "2M" +build-log-max-lines = 1000 + +[crates] + +[github-repos] + +[local-crates] diff --git a/tests/minicrater/missing-repo/results.expected.json b/tests/minicrater/missing-repo/results.expected.json new file mode 100644 index 000000000..bed62b26f --- /dev/null +++ b/tests/minicrater/missing-repo/results.expected.json @@ -0,0 +1,19 @@ +{ + "crates": [ + { + "name": "ghost.missing", + "res": "broken", + "runs": [ + { + "log": "stable/gh/ghost.missing", + "res": "broken:missing-git-repository" + }, + { + "log": "beta/gh/ghost.missing", + "res": "broken:missing-git-repository" + } + ], + "url": "https://github.com/ghost/missing" + } + ] +} diff --git a/tests/minicrater/mod.rs b/tests/minicrater/mod.rs index c04f311e3..dd387d937 100644 --- a/tests/minicrater/mod.rs +++ b/tests/minicrater/mod.rs @@ -42,6 +42,12 @@ minicrater! { ..Default::default() }, + single_thread_missing_repo { + ex: "missing-repo", + crate_select: "dummy", + ..Default::default() + }, + #[cfg(not(windows))] // `State.OOMKilled` is not set on Windows resource_exhaustion { ex: "resource-exhaustion",