| 1 | use super::Error; | 
| 2 | use crate::{per_test_config::TestConfig, Errored}; | 
|---|
| 3 | use spanned::Spanned; | 
|---|
| 4 | use std::process::ExitStatus; | 
|---|
| 5 |  | 
|---|
| 6 | impl TestConfig { | 
|---|
| 7 | #[ allow(clippy::result_large_err)] | 
|---|
| 8 | pub(crate) fn ok(&self, status: ExitStatus) -> Result<Option<Error>, Errored> { | 
|---|
| 9 | let Some(expected) = self.exit_status()? else { | 
|---|
| 10 | return Ok(None); | 
|---|
| 11 | }; | 
|---|
| 12 | if status.code() == Some(*expected) { | 
|---|
| 13 | Ok(None) | 
|---|
| 14 | } else { | 
|---|
| 15 | let span = expected.span.clone(); | 
|---|
| 16 | let expected = expected.content; | 
|---|
| 17 | Ok(Some(Error::ExitStatus { | 
|---|
| 18 | status, | 
|---|
| 19 | expected, | 
|---|
| 20 | reason: Spanned::new( | 
|---|
| 21 | match (expected, status.code()) { | 
|---|
| 22 | (_, Some(101)) => "the compiler panicked", | 
|---|
| 23 | (0, Some(1)) => "compilation failed, but was expected to succeed", | 
|---|
| 24 | (1, Some(0)) => "compilation succeeded, but was expected to fail", | 
|---|
| 25 | _ => "", | 
|---|
| 26 | } | 
|---|
| 27 | .into(), | 
|---|
| 28 | span, | 
|---|
| 29 | ), | 
|---|
| 30 | })) | 
|---|
| 31 | } | 
|---|
| 32 | } | 
|---|
| 33 | } | 
|---|
| 34 |  | 
|---|