End-to-end testing of the compile path.

This commit is contained in:
2023-04-08 14:20:49 -07:00
parent 8dfcc67e51
commit 8d8b200513
14 changed files with 215 additions and 32 deletions

View File

@@ -18,6 +18,8 @@ pub enum BackendError {
SetError(#[from] SetError),
#[error(transparent)]
LookupError(#[from] LookupError),
#[error(transparent)]
Write(#[from] cranelift_object::object::write::Error),
}
impl From<BackendError> for Diagnostic<usize> {
@@ -41,6 +43,41 @@ impl From<BackendError> for Diagnostic<usize> {
BackendError::LookupError(me) => {
Diagnostic::error().with_message(format!("Internal error: {}", me))
}
BackendError::Write(me) => {
Diagnostic::error().with_message(format!("Cranelift object write error: {}", me))
}
}
}
}
impl PartialEq for BackendError {
fn eq(&self, other: &Self) -> bool {
match self {
BackendError::BuiltinError(a) => match other {
BackendError::BuiltinError(b) => a == b,
_ => false,
},
BackendError::CodegenError(_) => matches!(other, BackendError::CodegenError(_)),
BackendError::Cranelift(_) => matches!(other, BackendError::Cranelift(_)),
BackendError::LookupError(a) => match other {
BackendError::LookupError(b) => a == b,
_ => false,
},
BackendError::SetError(a) => match other {
BackendError::SetError(b) => a == b,
_ => false,
},
BackendError::VariableLookupFailure => other == &BackendError::VariableLookupFailure,
BackendError::Write(a) => match other {
BackendError::Write(b) => a == b,
_ => false,
},
}
}
}