Skip to content

Commit

Permalink
fix PrepareError and OverrideResult not being found in error chain
Browse files Browse the repository at this point in the history
  • Loading branch information
Skgland committed Jan 1, 2025
1 parent 9b2abe2 commit a1c5cdd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 26 deletions.
29 changes: 13 additions & 16 deletions src/runner/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,22 @@ pub(super) fn detect_broken<T>(res: Result<T, Error>) -> Result<T, Error> {
Ok(ok) => Ok(ok),
Err(err) => {
let mut reason = None;
for cause in err.chain() {
if let Some(error) = cause.downcast_ref() {
reason = match *error {
PrepareError::MissingCargoToml => Some(BrokenReason::CargoToml),
PrepareError::InvalidCargoTomlSyntax => Some(BrokenReason::CargoToml),
PrepareError::YankedDependencies(_) => Some(BrokenReason::Yanked),
PrepareError::MissingDependencies(_) => {
Some(BrokenReason::MissingDependencies)
}
PrepareError::PrivateGitRepository => {
Some(BrokenReason::MissingGitRepository)
}
_ => None,

if let Some(error) = err.downcast_ref() {
reason = match *error {
PrepareError::MissingCargoToml => Some(BrokenReason::CargoToml),
PrepareError::InvalidCargoTomlSyntax => Some(BrokenReason::CargoToml),
PrepareError::YankedDependencies(_) => Some(BrokenReason::Yanked),
PrepareError::MissingDependencies(_) => {
Some(BrokenReason::MissingDependencies)
}
}
if reason.is_some() {
break;
PrepareError::PrivateGitRepository => {
Some(BrokenReason::MissingGitRepository)
}
_ => None,
}
}

if let Some(reason) = reason {
Err(err.context(OverrideResult(TestResult::BrokenCrate(reason))))
} else {
Expand Down
15 changes: 5 additions & 10 deletions src/runner/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,8 @@ impl<'a> Worker<'a> {
TestResult::Error
};

for err in e.chain() {
if let Some(OverrideResult(res)) = err.downcast_ref() {
result = res.clone();
break;
}
if let Some(OverrideResult(res)) = e.downcast_ref() {
result = res.clone();
}

Err((e, result))
Expand Down Expand Up @@ -249,11 +246,9 @@ impl<'a> Worker<'a> {
} else {
TestResult::Error
};
for err in err.chain() {
if let Some(OverrideResult(res)) = err.downcast_ref() {
result = res.clone();
break;
}

if let Some(OverrideResult(res)) = err.downcast_ref() {
result = res.clone();
}

for tc in &self.ex.toolchains {
Expand Down

0 comments on commit a1c5cdd

Please sign in to comment.