Skip to content

Commit df8b78f

Browse files
committed
feat(test2): Allow use of custom error types
1 parent 10f8ad5 commit df8b78f

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

crates/libtest2-harness/src/error.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,12 @@ impl IntoRunResult for RunResult {
8080
self
8181
}
8282
}
83+
84+
impl<E> IntoRunResult for Result<(), E>
85+
where
86+
E: std::error::Error + Send + Sync + 'static,
87+
{
88+
fn into_run_result(self) -> RunResult {
89+
self.map_err(RunError::with_cause)
90+
}
91+
}

crates/libtest2/tests/testsuite/mixed_bag.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ fn horse(context: &libtest2::TestContext) {
6565
}
6666
6767
#[libtest2::test]
68-
fn custom_error(context: &libtest2::TestContext) -> libtest2::RunResult {
69-
Err(libtest2::RunError::from(std::io::Error::new(std::io::ErrorKind::Other, "I failed")))
68+
fn custom_error(context: &libtest2::TestContext) -> std::io::Result<()> {
69+
Err(std::io::Error::new(std::io::ErrorKind::Other, "I failed"))
7070
}
7171
7272
"#,

0 commit comments

Comments
 (0)