From babfaf5bbe386db9d5fcd9979d90630187a10145 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 27 Oct 2025 16:24:47 -0500 Subject: [PATCH 1/8] refactor(harness): Pull out error content --- crates/libtest2-harness/src/case.rs | 65 --------------------------- crates/libtest2-harness/src/error.rs | 66 ++++++++++++++++++++++++++++ crates/libtest2-harness/src/lib.rs | 2 + 3 files changed, 68 insertions(+), 65 deletions(-) create mode 100644 crates/libtest2-harness/src/error.rs diff --git a/crates/libtest2-harness/src/case.rs b/crates/libtest2-harness/src/case.rs index 2f94533..5662d06 100644 --- a/crates/libtest2-harness/src/case.rs +++ b/crates/libtest2-harness/src/case.rs @@ -48,68 +48,3 @@ pub enum Source { }, Path(std::path::PathBuf), } - -pub type RunResult = Result<(), RunError>; - -#[derive(Debug)] -pub struct RunError { - status: notify::MessageKind, - cause: Option>, -} - -impl RunError { - pub fn with_cause(cause: impl std::error::Error + Send + Sync + 'static) -> Self { - Self { - status: notify::MessageKind::Error, - cause: Some(Box::new(cause)), - } - } - - pub fn fail(cause: impl std::fmt::Display) -> Self { - Self::with_cause(Message(cause.to_string())) - } - - /// Should not be called with `libtest_lexarg::RunIgnored::Yes` - pub fn ignore() -> Self { - Self { - status: notify::MessageKind::Ignored, - cause: None, - } - } - - /// Should not be called with `libtest_lexarg::RunIgnored::Yes` - pub fn ignore_for(reason: String) -> Self { - Self { - status: notify::MessageKind::Ignored, - cause: Some(Box::new(Message(reason))), - } - } - - pub(crate) fn status(&self) -> notify::MessageKind { - self.status - } - - pub(crate) fn cause(&self) -> Option<&(dyn std::error::Error + Send + Sync)> { - self.cause.as_ref().map(|b| b.as_ref()) - } -} - -impl From for RunError -where - E: std::error::Error + Send + Sync + 'static, -{ - fn from(error: E) -> Self { - Self::with_cause(error) - } -} - -#[derive(Debug)] -struct Message(String); - -impl std::fmt::Display for Message { - fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - self.0.fmt(formatter) - } -} - -impl std::error::Error for Message {} diff --git a/crates/libtest2-harness/src/error.rs b/crates/libtest2-harness/src/error.rs new file mode 100644 index 0000000..388c987 --- /dev/null +++ b/crates/libtest2-harness/src/error.rs @@ -0,0 +1,66 @@ +pub(crate) use crate::*; + +pub type RunResult = Result<(), RunError>; + +#[derive(Debug)] +pub struct RunError { + status: notify::MessageKind, + cause: Option>, +} + +impl RunError { + pub fn with_cause(cause: impl std::error::Error + Send + Sync + 'static) -> Self { + Self { + status: notify::MessageKind::Error, + cause: Some(Box::new(cause)), + } + } + + pub fn fail(cause: impl std::fmt::Display) -> Self { + Self::with_cause(Message(cause.to_string())) + } + + /// Should not be called with `libtest_lexarg::RunIgnored::Yes` + pub fn ignore() -> Self { + Self { + status: notify::MessageKind::Ignored, + cause: None, + } + } + + /// Should not be called with `libtest_lexarg::RunIgnored::Yes` + pub fn ignore_for(reason: String) -> Self { + Self { + status: notify::MessageKind::Ignored, + cause: Some(Box::new(Message(reason))), + } + } + + pub(crate) fn status(&self) -> notify::MessageKind { + self.status + } + + pub(crate) fn cause(&self) -> Option<&(dyn std::error::Error + Send + Sync)> { + self.cause.as_ref().map(|b| b.as_ref()) + } +} + +impl From for RunError +where + E: std::error::Error + Send + Sync + 'static, +{ + fn from(error: E) -> Self { + Self::with_cause(error) + } +} + +#[derive(Debug)] +struct Message(String); + +impl std::fmt::Display for Message { + fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.0.fmt(formatter) + } +} + +impl std::error::Error for Message {} diff --git a/crates/libtest2-harness/src/lib.rs b/crates/libtest2-harness/src/lib.rs index f804542..79e0aef 100644 --- a/crates/libtest2-harness/src/lib.rs +++ b/crates/libtest2-harness/src/lib.rs @@ -6,6 +6,7 @@ mod case; mod context; +mod error; mod harness; mod notify; @@ -13,6 +14,7 @@ pub mod cli; pub use case::*; pub use context::*; +pub use error::*; pub use harness::*; pub use notify::RunMode; From 9a4086dae9f61f25eddd3250485788ee1389a746 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 24 Oct 2025 16:23:46 -0500 Subject: [PATCH 2/8] feat(test2): Make RunResult optional --- crates/libtest2-harness/src/error.rs | 16 ++++++++++++++++ crates/libtest2/examples/simple.rs | 15 ++++----------- crates/libtest2/src/lib.rs | 1 + crates/libtest2/src/macros.rs | 4 +++- crates/libtest2/tests/testsuite/all_passing.rs | 9 +++------ crates/libtest2/tests/testsuite/argfile.rs | 12 ++++-------- crates/libtest2/tests/testsuite/mixed_bag.rs | 9 +++------ crates/libtest2/tests/testsuite/panic.rs | 5 ++--- 8 files changed, 36 insertions(+), 35 deletions(-) diff --git a/crates/libtest2-harness/src/error.rs b/crates/libtest2-harness/src/error.rs index 388c987..fd35e81 100644 --- a/crates/libtest2-harness/src/error.rs +++ b/crates/libtest2-harness/src/error.rs @@ -64,3 +64,19 @@ impl std::fmt::Display for Message { } impl std::error::Error for Message {} + +pub trait IntoRunResult { + fn into_run_result(self) -> RunResult; +} + +impl IntoRunResult for () { + fn into_run_result(self) -> RunResult { + Ok(()) + } +} + +impl IntoRunResult for RunResult { + fn into_run_result(self) -> RunResult { + self + } +} diff --git a/crates/libtest2/examples/simple.rs b/crates/libtest2/examples/simple.rs index aeb778b..78098e1 100644 --- a/crates/libtest2/examples/simple.rs +++ b/crates/libtest2/examples/simple.rs @@ -8,24 +8,17 @@ fn main() {} // Tests #[libtest2::test] -fn check_toph(_context: &TestContext) -> RunResult { - Ok(()) -} +fn check_toph(_context: &TestContext) {} #[libtest2::test] -fn check_katara(_context: &TestContext) -> RunResult { - Ok(()) -} +fn check_katara(_context: &TestContext) {} #[libtest2::test] fn check_sokka(_context: &TestContext) -> RunResult { Err(RunError::fail("Sokka tripped and fell :(")) } #[libtest2::test] #[ignore = "slow"] -fn long_computation(_context: &TestContext) -> RunResult { +fn long_computation(_context: &TestContext) { std::thread::sleep(std::time::Duration::from_secs(1)); - Ok(()) } #[libtest2::test] -fn compile_fail_dummy(_context: &TestContext) -> RunResult { - Ok(()) -} +fn compile_fail_dummy(_context: &TestContext) {} diff --git a/crates/libtest2/src/lib.rs b/crates/libtest2/src/lib.rs index a47f3f3..aa1e2c2 100644 --- a/crates/libtest2/src/lib.rs +++ b/crates/libtest2/src/lib.rs @@ -51,6 +51,7 @@ pub mod _private { pub use case::main; pub use case::FnCase; +pub use libtest2_harness::IntoRunResult; pub use libtest2_harness::RunError; pub use libtest2_harness::RunResult; pub use libtest2_harness::TestContext; diff --git a/crates/libtest2/src/macros.rs b/crates/libtest2/src/macros.rs index 3ee0929..9f41afa 100644 --- a/crates/libtest2/src/macros.rs +++ b/crates/libtest2/src/macros.rs @@ -58,7 +58,9 @@ macro_rules! _test_parse { } )* - run(context) + use $crate::IntoRunResult; + let result = run(context); + IntoRunResult::into_run_result(result) } } }; diff --git a/crates/libtest2/tests/testsuite/all_passing.rs b/crates/libtest2/tests/testsuite/all_passing.rs index 4b98cf8..0fc4f6a 100644 --- a/crates/libtest2/tests/testsuite/all_passing.rs +++ b/crates/libtest2/tests/testsuite/all_passing.rs @@ -11,18 +11,15 @@ fn test_cmd() -> snapbox::cmd::Command { fn main() {} #[libtest2::test] -fn foo(_context: &libtest2::TestContext) -> libtest2::RunResult { - Ok(()) +fn foo(_context: &libtest2::TestContext) { } #[libtest2::test] -fn bar(_context: &libtest2::TestContext) -> libtest2::RunResult { - Ok(()) +fn bar(_context: &libtest2::TestContext) { } #[libtest2::test] -fn barro(_context: &libtest2::TestContext) -> libtest2::RunResult { - Ok(()) +fn barro(_context: &libtest2::TestContext) { } "#, false, diff --git a/crates/libtest2/tests/testsuite/argfile.rs b/crates/libtest2/tests/testsuite/argfile.rs index c2a3fc0..3e4622f 100644 --- a/crates/libtest2/tests/testsuite/argfile.rs +++ b/crates/libtest2/tests/testsuite/argfile.rs @@ -11,23 +11,19 @@ fn test_cmd() -> snapbox::cmd::Command { fn main() {} #[libtest2::test] -fn one(_context: &libtest2::TestContext) -> libtest2::RunResult { - Ok(()) +fn one(_context: &libtest2::TestContext) { } #[libtest2::test] -fn two(_context: &libtest2::TestContext) -> libtest2::RunResult { - Ok(()) +fn two(_context: &libtest2::TestContext) { } #[libtest2::test] -fn three(_context: &libtest2::TestContext) -> libtest2::RunResult { - Ok(()) +fn three(_context: &libtest2::TestContext) { } #[libtest2::test] -fn one_two(_context: &libtest2::TestContext) -> libtest2::RunResult { - Ok(()) +fn one_two(_context: &libtest2::TestContext) { } "#, false, diff --git a/crates/libtest2/tests/testsuite/mixed_bag.rs b/crates/libtest2/tests/testsuite/mixed_bag.rs index 4ee8a11..62b9599 100644 --- a/crates/libtest2/tests/testsuite/mixed_bag.rs +++ b/crates/libtest2/tests/testsuite/mixed_bag.rs @@ -11,8 +11,7 @@ fn test_cmd() -> snapbox::cmd::Command { fn main() {} #[libtest2::test] -fn cat(_context: &libtest2::TestContext) -> libtest2::RunResult { - Ok(()) +fn cat(_context: &libtest2::TestContext) { } #[libtest2::test] @@ -21,8 +20,7 @@ fn dog(_context: &libtest2::TestContext) -> libtest2::RunResult { } #[libtest2::test] -fn fox(_context: &libtest2::TestContext) -> libtest2::RunResult { - Ok(()) +fn fox(_context: &libtest2::TestContext) { } #[libtest2::test] @@ -63,8 +61,7 @@ fn sheep(context: &libtest2::TestContext) -> libtest2::RunResult { #[libtest2::test] #[ignore = "slow"] -fn horse(context: &libtest2::TestContext) -> libtest2::RunResult { - Ok(()) +fn horse(context: &libtest2::TestContext) { } "#, false, diff --git a/crates/libtest2/tests/testsuite/panic.rs b/crates/libtest2/tests/testsuite/panic.rs index ad4a6f7..f40cfa4 100644 --- a/crates/libtest2/tests/testsuite/panic.rs +++ b/crates/libtest2/tests/testsuite/panic.rs @@ -11,12 +11,11 @@ fn test_cmd() -> snapbox::cmd::Command { fn main() {} #[libtest2::test] -fn passes(_context: &libtest2::TestContext) -> libtest2::RunResult { - Ok(()) +fn passes(_context: &libtest2::TestContext) { } #[libtest2::test] -fn panics(_context: &libtest2::TestContext) -> libtest2::RunResult { +fn panics(_context: &libtest2::TestContext) { panic!("uh oh") } "#, From c124668b8d7c1a42001acceba2385392b2e109ce Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 29 Oct 2025 13:35:22 -0500 Subject: [PATCH 3/8] feat(mimic): Allow converting errors --- crates/libtest2-mimic/src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/libtest2-mimic/src/lib.rs b/crates/libtest2-mimic/src/lib.rs index 9273350..474380c 100644 --- a/crates/libtest2-mimic/src/lib.rs +++ b/crates/libtest2-mimic/src/lib.rs @@ -189,6 +189,15 @@ impl RunError { } } +impl From for RunError +where + E: std::error::Error + Send + Sync + 'static, +{ + fn from(error: E) -> Self { + Self::with_cause(error) + } +} + pub struct RunContext<'t> { inner: &'t libtest2_harness::TestContext, } From 10f8ad536e939f1b515f843bbaf5f9a2483c95e9 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 29 Oct 2025 13:48:51 -0500 Subject: [PATCH 4/8] test(test2): Cover using a foreign error type --- .../tests/testsuite/mixed_bag.rs | 354 +++++++++++------ crates/libtest2/tests/testsuite/mixed_bag.rs | 359 ++++++++++++------ 2 files changed, 473 insertions(+), 240 deletions(-) diff --git a/crates/libtest2-mimic/tests/testsuite/mixed_bag.rs b/crates/libtest2-mimic/tests/testsuite/mixed_bag.rs index 8c451c8..192efd1 100644 --- a/crates/libtest2-mimic/tests/testsuite/mixed_bag.rs +++ b/crates/libtest2-mimic/tests/testsuite/mixed_bag.rs @@ -43,6 +43,7 @@ fn main() { state.ignore_for("slow")?; Ok(()) }), + Trial::test("custom_error", |_| Err(RunError::from(std::io::Error::new(std::io::ErrorKind::Other, "I failed")))), ]) .main(); } @@ -76,46 +77,55 @@ fn normal() { 101, str![[r#" -running 10 tests -test bear ... ignored -test bunny ... ignored -test cat ... ok -test dog ... FAILED -test fly ... ignored -test fox ... ok -test frog ... ignored -test horse ... ignored -test owl ... ignored -test sheep ... ignored +running 11 tests +test bear ... ignored +test bunny ... ignored +test cat ... ok +test custom_error ... FAILED +test dog ... FAILED +test fly ... ignored +test fox ... ok +test frog ... ignored +test horse ... ignored +test owl ... ignored +test sheep ... ignored failures: +---- custom_error ---- +I failed + ---- dog ---- was not a good boy failures: + custom_error dog -test result: FAILED. 2 passed; 1 failed; 7 ignored; 0 filtered out; finished in [..]s +test result: FAILED. 2 passed; 2 failed; 7 ignored; 0 filtered out; finished in [..]s "#]], str![[r#" -running 10 tests +running 11 tests ... failures: +---- custom_error ---- +I failed + ---- dog ---- was not a good boy failures: + custom_error dog -test result: FAILED. 2 passed; 1 failed; 7 ignored; 0 filtered out; finished in [..]s +test result: FAILED. 2 passed; 2 failed; 7 ignored; 0 filtered out; finished in [..]s "#]], @@ -129,46 +139,55 @@ fn test_mode() { 101, str![[r#" -running 10 tests -test bear ... ignored -test bunny ... ignored -test cat ... ok -test dog ... FAILED -test fly ... ignored -test fox ... ok -test frog ... ignored -test horse ... ignored -test owl ... ignored -test sheep ... ignored +running 11 tests +test bear ... ignored +test bunny ... ignored +test cat ... ok +test custom_error ... FAILED +test dog ... FAILED +test fly ... ignored +test fox ... ok +test frog ... ignored +test horse ... ignored +test owl ... ignored +test sheep ... ignored failures: +---- custom_error ---- +I failed + ---- dog ---- was not a good boy failures: + custom_error dog -test result: FAILED. 2 passed; 1 failed; 7 ignored; 0 filtered out; finished in [..]s +test result: FAILED. 2 passed; 2 failed; 7 ignored; 0 filtered out; finished in [..]s "#]], str![[r#" -running 10 tests +running 11 tests ... failures: +---- custom_error ---- +I failed + ---- dog ---- was not a good boy failures: + custom_error dog -test result: FAILED. 2 passed; 1 failed; 7 ignored; 0 filtered out; finished in [..]s +test result: FAILED. 2 passed; 2 failed; 7 ignored; 0 filtered out; finished in [..]s "#]], @@ -182,46 +201,55 @@ fn bench_mode() { 101, str![[r#" -running 10 tests -test bear ... ignored -test bunny ... ignored -test cat ... ok -test dog ... FAILED -test fly ... ignored -test fox ... ok -test frog ... ignored -test horse ... ignored -test owl ... ignored -test sheep ... ignored +running 11 tests +test bear ... ignored +test bunny ... ignored +test cat ... ok +test custom_error ... FAILED +test dog ... FAILED +test fly ... ignored +test fox ... ok +test frog ... ignored +test horse ... ignored +test owl ... ignored +test sheep ... ignored failures: +---- custom_error ---- +I failed + ---- dog ---- was not a good boy failures: + custom_error dog -test result: FAILED. 2 passed; 1 failed; 7 ignored; 0 filtered out; finished in [..]s +test result: FAILED. 2 passed; 2 failed; 7 ignored; 0 filtered out; finished in [..]s "#]], str![[r#" -running 10 tests +running 11 tests ... failures: +---- custom_error ---- +I failed + ---- dog ---- was not a good boy failures: + custom_error dog -test result: FAILED. 2 passed; 1 failed; 7 ignored; 0 filtered out; finished in [..]s +test result: FAILED. 2 passed; 2 failed; 7 ignored; 0 filtered out; finished in [..]s "#]], @@ -244,8 +272,9 @@ fly: test bear: test sheep: test horse: test +custom_error: test -10 tests +11 tests "#]], @@ -260,8 +289,9 @@ fly: test bear: test sheep: test horse: test +custom_error: test -10 tests +11 tests "#]], @@ -284,8 +314,9 @@ fly: test bear: test sheep: test horse: test +custom_error: test -10 tests +11 tests "#]], @@ -300,8 +331,9 @@ fly: test bear: test sheep: test horse: test +custom_error: test -10 tests +11 tests "#]], @@ -371,7 +403,7 @@ running 2 tests test bear ... ignored test cat ... ok -test result: ok. 1 passed; 0 failed; 1 ignored; 8 filtered out; finished in [..]s +test result: ok. 1 passed; 0 failed; 1 ignored; 9 filtered out; finished in [..]s "#]], @@ -380,7 +412,7 @@ test result: ok. 1 passed; 0 failed; 1 ignored; 8 filtered out; finished in [..] running 2 tests ... -test result: ok. 1 passed; 0 failed; 1 ignored; 8 filtered out; finished in [..]s +test result: ok. 1 passed; 0 failed; 1 ignored; 9 filtered out; finished in [..]s "#]], @@ -398,7 +430,7 @@ running 2 tests test bear ... ignored test cat ... ok -test result: ok. 1 passed; 0 failed; 1 ignored; 8 filtered out; finished in [..]s +test result: ok. 1 passed; 0 failed; 1 ignored; 9 filtered out; finished in [..]s "#]], @@ -407,7 +439,7 @@ test result: ok. 1 passed; 0 failed; 1 ignored; 8 filtered out; finished in [..] running 2 tests ... -test result: ok. 1 passed; 0 failed; 1 ignored; 8 filtered out; finished in [..]s +test result: ok. 1 passed; 0 failed; 1 ignored; 9 filtered out; finished in [..]s "#]], @@ -421,15 +453,19 @@ fn filter_o_test_include_ignored() { 101, str![[r#" -running 5 tests -test dog ... FAILED -test fox ... ok -test frog ... ok -test horse ... ok -test owl ... FAILED +running 6 tests +test custom_error ... FAILED +test dog ... FAILED +test fox ... ok +test frog ... ok +test horse ... ok +test owl ... FAILED failures: +---- custom_error ---- +I failed + ---- dog ---- was not a good boy @@ -438,20 +474,24 @@ broke neck failures: + custom_error dog owl -test result: FAILED. 3 passed; 2 failed; 0 ignored; 5 filtered out; finished in [..]s +test result: FAILED. 3 passed; 3 failed; 0 ignored; 5 filtered out; finished in [..]s "#]], str![[r#" -running 5 tests +running 6 tests ... failures: +---- custom_error ---- +I failed + ---- dog ---- was not a good boy @@ -460,10 +500,11 @@ broke neck failures: + custom_error dog owl -test result: FAILED. 3 passed; 2 failed; 0 ignored; 5 filtered out; finished in [..]s +test result: FAILED. 3 passed; 3 failed; 0 ignored; 5 filtered out; finished in [..]s "#]], @@ -477,15 +518,19 @@ fn filter_o_test_ignored() { 101, str![[r#" -running 5 tests -test dog ... FAILED -test fox ... ok -test frog ... ok -test horse ... ok -test owl ... FAILED +running 6 tests +test custom_error ... FAILED +test dog ... FAILED +test fox ... ok +test frog ... ok +test horse ... ok +test owl ... FAILED failures: +---- custom_error ---- +I failed + ---- dog ---- was not a good boy @@ -494,20 +539,24 @@ broke neck failures: + custom_error dog owl -test result: FAILED. 3 passed; 2 failed; 0 ignored; 5 filtered out; finished in [..]s +test result: FAILED. 3 passed; 3 failed; 0 ignored; 5 filtered out; finished in [..]s "#]], str![[r#" -running 5 tests +running 6 tests ... failures: +---- custom_error ---- +I failed + ---- dog ---- was not a good boy @@ -516,10 +565,11 @@ broke neck failures: + custom_error dog owl -test result: FAILED. 3 passed; 2 failed; 0 ignored; 5 filtered out; finished in [..]s +test result: FAILED. 3 passed; 3 failed; 0 ignored; 5 filtered out; finished in [..]s "#]], @@ -533,17 +583,18 @@ fn normal_include_ignored() { 101, str![[r#" -running 10 tests -test bear ... FAILED -test bunny ... FAILED -test cat ... ok -test dog ... FAILED -test fly ... ok -test fox ... ok -test frog ... ok -test horse ... ok -test owl ... FAILED -test sheep ... FAILED +running 11 tests +test bear ... FAILED +test bunny ... FAILED +test cat ... ok +test custom_error ... FAILED +test dog ... FAILED +test fly ... ok +test fox ... ok +test frog ... ok +test horse ... ok +test owl ... FAILED +test sheep ... FAILED failures: @@ -553,6 +604,9 @@ no honey ---- bunny ---- jumped too high +---- custom_error ---- +I failed + ---- dog ---- was not a good boy @@ -566,17 +620,18 @@ got lost blindly following the flock failures: bear bunny + custom_error dog owl sheep -test result: FAILED. 5 passed; 5 failed; 0 ignored; 0 filtered out; finished in [..]s +test result: FAILED. 5 passed; 6 failed; 0 ignored; 0 filtered out; finished in [..]s "#]], str![[r#" -running 10 tests +running 11 tests ... failures: @@ -587,6 +642,9 @@ no honey ---- bunny ---- jumped too high +---- custom_error ---- +I failed + ---- dog ---- was not a good boy @@ -600,11 +658,12 @@ got lost blindly following the flock failures: bear bunny + custom_error dog owl sheep -test result: FAILED. 5 passed; 5 failed; 0 ignored; 0 filtered out; finished in [..]s +test result: FAILED. 5 passed; 6 failed; 0 ignored; 0 filtered out; finished in [..]s "#]], @@ -618,17 +677,18 @@ fn normal_ignored() { 101, str![[r#" -running 10 tests -test bear ... FAILED -test bunny ... FAILED -test cat ... ok -test dog ... FAILED -test fly ... ok -test fox ... ok -test frog ... ok -test horse ... ok -test owl ... FAILED -test sheep ... FAILED +running 11 tests +test bear ... FAILED +test bunny ... FAILED +test cat ... ok +test custom_error ... FAILED +test dog ... FAILED +test fly ... ok +test fox ... ok +test frog ... ok +test horse ... ok +test owl ... FAILED +test sheep ... FAILED failures: @@ -638,6 +698,9 @@ no honey ---- bunny ---- jumped too high +---- custom_error ---- +I failed + ---- dog ---- was not a good boy @@ -651,17 +714,18 @@ got lost blindly following the flock failures: bear bunny + custom_error dog owl sheep -test result: FAILED. 5 passed; 5 failed; 0 ignored; 0 filtered out; finished in [..]s +test result: FAILED. 5 passed; 6 failed; 0 ignored; 0 filtered out; finished in [..]s "#]], str![[r#" -running 10 tests +running 11 tests ... failures: @@ -672,6 +736,9 @@ no honey ---- bunny ---- jumped too high +---- custom_error ---- +I failed + ---- dog ---- was not a good boy @@ -685,11 +752,12 @@ got lost blindly following the flock failures: bear bunny + custom_error dog owl sheep -test result: FAILED. 5 passed; 5 failed; 0 ignored; 0 filtered out; finished in [..]s +test result: FAILED. 5 passed; 6 failed; 0 ignored; 0 filtered out; finished in [..]s "#]], @@ -703,39 +771,48 @@ fn lots_of_flags() { 101, str![[r#" -running 3 tests -test fox ... ok -test horse ... ok -test owl ... FAILED +running 4 tests +test custom_error ... FAILED +test fox ... ok +test horse ... ok +test owl ... FAILED failures: +---- custom_error ---- +I failed + ---- owl ---- broke neck failures: + custom_error owl -test result: FAILED. 2 passed; 1 failed; 0 ignored; 7 filtered out; finished in [..]s +test result: FAILED. 2 passed; 2 failed; 0 ignored; 7 filtered out; finished in [..]s "#]], str![[r#" -running 3 tests +running 4 tests ... failures: +---- custom_error ---- +I failed + ---- owl ---- broke neck failures: + custom_error owl -test result: FAILED. 2 passed; 1 failed; 0 ignored; 7 filtered out; finished in [..]s +test result: FAILED. 2 passed; 2 failed; 0 ignored; 7 filtered out; finished in [..]s "#]], @@ -811,6 +888,12 @@ fn list_json() { "name": "horse", "selected": false }, + { + "elapsed_s": "[..]", + "event": "discover_case", + "name": "custom_error", + "selected": false + }, { "elapsed_s": "[..]", "event": "discover_complete" @@ -883,6 +966,12 @@ fn list_json() { "name": "horse", "selected": false }, + { + "elapsed_s": "[..]", + "event": "discover_case", + "name": "custom_error", + "selected": false + }, { "elapsed_s": "[..]", "event": "discover_complete" @@ -963,6 +1052,12 @@ fn test_json() { "name": "horse", "selected": false }, + { + "elapsed_s": "[..]", + "event": "discover_case", + "name": "custom_error", + "selected": false + }, { "elapsed_s": "[..]", "event": "discover_complete" @@ -1108,6 +1203,12 @@ fn test_json() { "event": "discover_case", "name": "horse", "selected": false + }, + { + "elapsed_s": "[..]", + "event": "discover_case", + "name": "custom_error", + "selected": false } ] "#]] @@ -1124,35 +1225,43 @@ fn terse_output() { 101, str![[r#" -running 10 tests -ii.Fi.iiii +running 11 tests +ii.FFi.iiii failures: +---- custom_error ---- +I failed + ---- dog ---- was not a good boy failures: + custom_error dog -test result: FAILED. 2 passed; 1 failed; 7 ignored; 0 filtered out; finished in [..]s +test result: FAILED. 2 passed; 2 failed; 7 ignored; 0 filtered out; finished in [..]s "#]], str![[r#" -running 10 tests +running 11 tests ... failures: +---- custom_error ---- +I failed + ---- dog ---- was not a good boy failures: + custom_error dog -test result: FAILED. 2 passed; 1 failed; 7 ignored; 0 filtered out; finished in [..]s +test result: FAILED. 2 passed; 2 failed; 7 ignored; 0 filtered out; finished in [..]s "#]], @@ -1166,20 +1275,20 @@ fn fail_fast() { 101, str![[r#" -running 10 tests -test bear ... ignored -test bunny ... ignored -test cat ... ok -test dog ... FAILED +running 11 tests +test bear ... ignored +test bunny ... ignored +test cat ... ok +test custom_error ... FAILED failures: ----- dog ---- -was not a good boy +---- custom_error ---- +I failed failures: - dog + custom_error test result: FAILED. 1 passed; 1 failed; 2 ignored; 0 filtered out; finished in [..]s @@ -1253,6 +1362,11 @@ fn fail_fast_json() { "event": "discover_case", "name": "horse" }, + { + "elapsed_s": "[..]", + "event": "discover_case", + "name": "custom_error" + }, { "elapsed_s": "[..]", "event": "discover_complete" @@ -1308,19 +1422,19 @@ fn fail_fast_json() { { "elapsed_s": "[..]", "event": "case_start", - "name": "dog" + "name": "custom_error" }, { "elapsed_s": "[..]", "event": "case_message", "kind": "error", - "message": "was not a good boy", - "name": "dog" + "message": "I failed", + "name": "custom_error" }, { "elapsed_s": "[..]", "event": "case_complete", - "name": "dog" + "name": "custom_error" }, { "elapsed_s": "[..]", diff --git a/crates/libtest2/tests/testsuite/mixed_bag.rs b/crates/libtest2/tests/testsuite/mixed_bag.rs index 62b9599..5ff7593 100644 --- a/crates/libtest2/tests/testsuite/mixed_bag.rs +++ b/crates/libtest2/tests/testsuite/mixed_bag.rs @@ -63,6 +63,12 @@ fn sheep(context: &libtest2::TestContext) -> libtest2::RunResult { #[ignore = "slow"] fn horse(context: &libtest2::TestContext) { } + +#[libtest2::test] +fn custom_error(context: &libtest2::TestContext) -> libtest2::RunResult { + Err(libtest2::RunError::from(std::io::Error::new(std::io::ErrorKind::Other, "I failed"))) +} + "#, false, ); @@ -93,46 +99,55 @@ fn normal() { 101, str![[r#" -running 10 tests -test bear ... ignored -test bunny ... ignored -test cat ... ok -test dog ... FAILED -test fly ... ignored -test fox ... ok -test frog ... ignored -test horse ... ignored -test owl ... ignored -test sheep ... ignored +running 11 tests +test bear ... ignored +test bunny ... ignored +test cat ... ok +test custom_error ... FAILED +test dog ... FAILED +test fly ... ignored +test fox ... ok +test frog ... ignored +test horse ... ignored +test owl ... ignored +test sheep ... ignored failures: +---- custom_error ---- +I failed + ---- dog ---- was not a good boy failures: + custom_error dog -test result: FAILED. 2 passed; 1 failed; 7 ignored; 0 filtered out; finished in [..]s +test result: FAILED. 2 passed; 2 failed; 7 ignored; 0 filtered out; finished in [..]s "#]], str![[r#" -running 10 tests +running 11 tests ... failures: +---- custom_error ---- +I failed + ---- dog ---- was not a good boy failures: + custom_error dog -test result: FAILED. 2 passed; 1 failed; 7 ignored; 0 filtered out; finished in [..]s +test result: FAILED. 2 passed; 2 failed; 7 ignored; 0 filtered out; finished in [..]s "#]], @@ -146,46 +161,55 @@ fn test_mode() { 101, str![[r#" -running 10 tests -test bear ... ignored -test bunny ... ignored -test cat ... ok -test dog ... FAILED -test fly ... ignored -test fox ... ok -test frog ... ignored -test horse ... ignored -test owl ... ignored -test sheep ... ignored +running 11 tests +test bear ... ignored +test bunny ... ignored +test cat ... ok +test custom_error ... FAILED +test dog ... FAILED +test fly ... ignored +test fox ... ok +test frog ... ignored +test horse ... ignored +test owl ... ignored +test sheep ... ignored failures: +---- custom_error ---- +I failed + ---- dog ---- was not a good boy failures: + custom_error dog -test result: FAILED. 2 passed; 1 failed; 7 ignored; 0 filtered out; finished in [..]s +test result: FAILED. 2 passed; 2 failed; 7 ignored; 0 filtered out; finished in [..]s "#]], str![[r#" -running 10 tests +running 11 tests ... failures: +---- custom_error ---- +I failed + ---- dog ---- was not a good boy failures: + custom_error dog -test result: FAILED. 2 passed; 1 failed; 7 ignored; 0 filtered out; finished in [..]s +test result: FAILED. 2 passed; 2 failed; 7 ignored; 0 filtered out; finished in [..]s "#]], @@ -199,46 +223,55 @@ fn bench_mode() { 101, str![[r#" -running 10 tests -test bear ... ignored -test bunny ... ignored -test cat ... ok -test dog ... FAILED -test fly ... ignored -test fox ... ok -test frog ... ignored -test horse ... ignored -test owl ... ignored -test sheep ... ignored +running 11 tests +test bear ... ignored +test bunny ... ignored +test cat ... ok +test custom_error ... FAILED +test dog ... FAILED +test fly ... ignored +test fox ... ok +test frog ... ignored +test horse ... ignored +test owl ... ignored +test sheep ... ignored failures: +---- custom_error ---- +I failed + ---- dog ---- was not a good boy failures: + custom_error dog -test result: FAILED. 2 passed; 1 failed; 7 ignored; 0 filtered out; finished in [..]s +test result: FAILED. 2 passed; 2 failed; 7 ignored; 0 filtered out; finished in [..]s "#]], str![[r#" -running 10 tests +running 11 tests ... failures: +---- custom_error ---- +I failed + ---- dog ---- was not a good boy failures: + custom_error dog -test result: FAILED. 2 passed; 1 failed; 7 ignored; 0 filtered out; finished in [..]s +test result: FAILED. 2 passed; 2 failed; 7 ignored; 0 filtered out; finished in [..]s "#]], @@ -254,6 +287,7 @@ fn list() { bear: test bunny: test cat: test +custom_error: test dog: test fly: test fox: test @@ -262,7 +296,7 @@ horse: test owl: test sheep: test -10 tests +11 tests "#]], @@ -270,6 +304,7 @@ sheep: test bear: test bunny: test cat: test +custom_error: test dog: test fly: test fox: test @@ -278,7 +313,7 @@ horse: test owl: test sheep: test -10 tests +11 tests "#]], @@ -294,6 +329,7 @@ fn list_ignored() { bear: test bunny: test cat: test +custom_error: test dog: test fly: test fox: test @@ -302,7 +338,7 @@ horse: test owl: test sheep: test -10 tests +11 tests "#]], @@ -310,6 +346,7 @@ sheep: test bear: test bunny: test cat: test +custom_error: test dog: test fly: test fox: test @@ -318,7 +355,7 @@ horse: test owl: test sheep: test -10 tests +11 tests "#]], @@ -388,7 +425,7 @@ running 2 tests test bear ... ignored test cat ... ok -test result: ok. 1 passed; 0 failed; 1 ignored; 8 filtered out; finished in [..]s +test result: ok. 1 passed; 0 failed; 1 ignored; 9 filtered out; finished in [..]s "#]], @@ -397,7 +434,7 @@ test result: ok. 1 passed; 0 failed; 1 ignored; 8 filtered out; finished in [..] running 2 tests ... -test result: ok. 1 passed; 0 failed; 1 ignored; 8 filtered out; finished in [..]s +test result: ok. 1 passed; 0 failed; 1 ignored; 9 filtered out; finished in [..]s "#]], @@ -415,7 +452,7 @@ running 2 tests test bear ... ignored test cat ... ok -test result: ok. 1 passed; 0 failed; 1 ignored; 8 filtered out; finished in [..]s +test result: ok. 1 passed; 0 failed; 1 ignored; 9 filtered out; finished in [..]s "#]], @@ -424,7 +461,7 @@ test result: ok. 1 passed; 0 failed; 1 ignored; 8 filtered out; finished in [..] running 2 tests ... -test result: ok. 1 passed; 0 failed; 1 ignored; 8 filtered out; finished in [..]s +test result: ok. 1 passed; 0 failed; 1 ignored; 9 filtered out; finished in [..]s "#]], @@ -438,15 +475,19 @@ fn filter_o_test_include_ignored() { 101, str![[r#" -running 5 tests -test dog ... FAILED -test fox ... ok -test frog ... ok -test horse ... ok -test owl ... FAILED +running 6 tests +test custom_error ... FAILED +test dog ... FAILED +test fox ... ok +test frog ... ok +test horse ... ok +test owl ... FAILED failures: +---- custom_error ---- +I failed + ---- dog ---- was not a good boy @@ -455,20 +496,24 @@ broke neck failures: + custom_error dog owl -test result: FAILED. 3 passed; 2 failed; 0 ignored; 5 filtered out; finished in [..]s +test result: FAILED. 3 passed; 3 failed; 0 ignored; 5 filtered out; finished in [..]s "#]], str![[r#" -running 5 tests +running 6 tests ... failures: +---- custom_error ---- +I failed + ---- dog ---- was not a good boy @@ -477,10 +522,11 @@ broke neck failures: + custom_error dog owl -test result: FAILED. 3 passed; 2 failed; 0 ignored; 5 filtered out; finished in [..]s +test result: FAILED. 3 passed; 3 failed; 0 ignored; 5 filtered out; finished in [..]s "#]], @@ -494,15 +540,19 @@ fn filter_o_test_ignored() { 101, str![[r#" -running 5 tests -test dog ... FAILED -test fox ... ok -test frog ... ok -test horse ... ok -test owl ... FAILED +running 6 tests +test custom_error ... FAILED +test dog ... FAILED +test fox ... ok +test frog ... ok +test horse ... ok +test owl ... FAILED failures: +---- custom_error ---- +I failed + ---- dog ---- was not a good boy @@ -511,20 +561,24 @@ broke neck failures: + custom_error dog owl -test result: FAILED. 3 passed; 2 failed; 0 ignored; 5 filtered out; finished in [..]s +test result: FAILED. 3 passed; 3 failed; 0 ignored; 5 filtered out; finished in [..]s "#]], str![[r#" -running 5 tests +running 6 tests ... failures: +---- custom_error ---- +I failed + ---- dog ---- was not a good boy @@ -533,10 +587,11 @@ broke neck failures: + custom_error dog owl -test result: FAILED. 3 passed; 2 failed; 0 ignored; 5 filtered out; finished in [..]s +test result: FAILED. 3 passed; 3 failed; 0 ignored; 5 filtered out; finished in [..]s "#]], @@ -550,17 +605,18 @@ fn normal_include_ignored() { 101, str![[r#" -running 10 tests -test bear ... FAILED -test bunny ... FAILED -test cat ... ok -test dog ... FAILED -test fly ... ok -test fox ... ok -test frog ... ok -test horse ... ok -test owl ... FAILED -test sheep ... FAILED +running 11 tests +test bear ... FAILED +test bunny ... FAILED +test cat ... ok +test custom_error ... FAILED +test dog ... FAILED +test fly ... ok +test fox ... ok +test frog ... ok +test horse ... ok +test owl ... FAILED +test sheep ... FAILED failures: @@ -570,6 +626,9 @@ no honey ---- bunny ---- jumped too high +---- custom_error ---- +I failed + ---- dog ---- was not a good boy @@ -583,17 +642,18 @@ got lost blindly following the flock failures: bear bunny + custom_error dog owl sheep -test result: FAILED. 5 passed; 5 failed; 0 ignored; 0 filtered out; finished in [..]s +test result: FAILED. 5 passed; 6 failed; 0 ignored; 0 filtered out; finished in [..]s "#]], str![[r#" -running 10 tests +running 11 tests ... failures: @@ -604,6 +664,9 @@ no honey ---- bunny ---- jumped too high +---- custom_error ---- +I failed + ---- dog ---- was not a good boy @@ -617,11 +680,12 @@ got lost blindly following the flock failures: bear bunny + custom_error dog owl sheep -test result: FAILED. 5 passed; 5 failed; 0 ignored; 0 filtered out; finished in [..]s +test result: FAILED. 5 passed; 6 failed; 0 ignored; 0 filtered out; finished in [..]s "#]], @@ -635,17 +699,18 @@ fn normal_ignored() { 101, str![[r#" -running 10 tests -test bear ... FAILED -test bunny ... FAILED -test cat ... ok -test dog ... FAILED -test fly ... ok -test fox ... ok -test frog ... ok -test horse ... ok -test owl ... FAILED -test sheep ... FAILED +running 11 tests +test bear ... FAILED +test bunny ... FAILED +test cat ... ok +test custom_error ... FAILED +test dog ... FAILED +test fly ... ok +test fox ... ok +test frog ... ok +test horse ... ok +test owl ... FAILED +test sheep ... FAILED failures: @@ -655,6 +720,9 @@ no honey ---- bunny ---- jumped too high +---- custom_error ---- +I failed + ---- dog ---- was not a good boy @@ -668,17 +736,18 @@ got lost blindly following the flock failures: bear bunny + custom_error dog owl sheep -test result: FAILED. 5 passed; 5 failed; 0 ignored; 0 filtered out; finished in [..]s +test result: FAILED. 5 passed; 6 failed; 0 ignored; 0 filtered out; finished in [..]s "#]], str![[r#" -running 10 tests +running 11 tests ... failures: @@ -689,6 +758,9 @@ no honey ---- bunny ---- jumped too high +---- custom_error ---- +I failed + ---- dog ---- was not a good boy @@ -702,11 +774,12 @@ got lost blindly following the flock failures: bear bunny + custom_error dog owl sheep -test result: FAILED. 5 passed; 5 failed; 0 ignored; 0 filtered out; finished in [..]s +test result: FAILED. 5 passed; 6 failed; 0 ignored; 0 filtered out; finished in [..]s "#]], @@ -720,39 +793,48 @@ fn lots_of_flags() { 101, str![[r#" -running 3 tests -test fox ... ok -test horse ... ok -test owl ... FAILED +running 4 tests +test custom_error ... FAILED +test fox ... ok +test horse ... ok +test owl ... FAILED failures: +---- custom_error ---- +I failed + ---- owl ---- broke neck failures: + custom_error owl -test result: FAILED. 2 passed; 1 failed; 0 ignored; 7 filtered out; finished in [..]s +test result: FAILED. 2 passed; 2 failed; 0 ignored; 7 filtered out; finished in [..]s "#]], str![[r#" -running 3 tests +running 4 tests ... failures: +---- custom_error ---- +I failed + ---- owl ---- broke neck failures: + custom_error owl -test result: FAILED. 2 passed; 1 failed; 0 ignored; 7 filtered out; finished in [..]s +test result: FAILED. 2 passed; 2 failed; 0 ignored; 7 filtered out; finished in [..]s "#]], @@ -786,6 +868,12 @@ fn list_json() { "event": "discover_case", "name": "cat" }, + { + "elapsed_s": "[..]", + "event": "discover_case", + "name": "custom_error", + "selected": false + }, { "elapsed_s": "[..]", "event": "discover_case", @@ -858,6 +946,12 @@ fn list_json() { "event": "discover_case", "name": "cat" }, + { + "elapsed_s": "[..]", + "event": "discover_case", + "name": "custom_error", + "selected": false + }, { "elapsed_s": "[..]", "event": "discover_case", @@ -938,6 +1032,12 @@ fn test_json() { "event": "discover_case", "name": "cat" }, + { + "elapsed_s": "[..]", + "event": "discover_case", + "name": "custom_error", + "selected": false + }, { "elapsed_s": "[..]", "event": "discover_case", @@ -1125,6 +1225,12 @@ fn test_json() { "event": "discover_case", "name": "sheep", "selected": false + }, + { + "elapsed_s": "[..]", + "event": "discover_case", + "name": "custom_error", + "selected": false } ] "#]] @@ -1141,35 +1247,43 @@ fn terse_output() { 101, str![[r#" -running 10 tests -ii.Fi.iiii +running 11 tests +ii.FFi.iiii failures: +---- custom_error ---- +I failed + ---- dog ---- was not a good boy failures: + custom_error dog -test result: FAILED. 2 passed; 1 failed; 7 ignored; 0 filtered out; finished in [..]s +test result: FAILED. 2 passed; 2 failed; 7 ignored; 0 filtered out; finished in [..]s "#]], str![[r#" -running 10 tests +running 11 tests ... failures: +---- custom_error ---- +I failed + ---- dog ---- was not a good boy failures: + custom_error dog -test result: FAILED. 2 passed; 1 failed; 7 ignored; 0 filtered out; finished in [..]s +test result: FAILED. 2 passed; 2 failed; 7 ignored; 0 filtered out; finished in [..]s "#]], @@ -1183,20 +1297,20 @@ fn fail_fast() { 101, str![[r#" -running 10 tests -test bear ... ignored -test bunny ... ignored -test cat ... ok -test dog ... FAILED +running 11 tests +test bear ... ignored +test bunny ... ignored +test cat ... ok +test custom_error ... FAILED failures: ----- dog ---- -was not a good boy +---- custom_error ---- +I failed failures: - dog + custom_error test result: FAILED. 1 passed; 1 failed; 2 ignored; 0 filtered out; finished in [..]s @@ -1235,6 +1349,11 @@ fn fail_fast_json() { "event": "discover_case", "name": "cat" }, + { + "elapsed_s": "[..]", + "event": "discover_case", + "name": "custom_error" + }, { "elapsed_s": "[..]", "event": "discover_case", @@ -1325,19 +1444,19 @@ fn fail_fast_json() { { "elapsed_s": "[..]", "event": "case_start", - "name": "dog" + "name": "custom_error" }, { "elapsed_s": "[..]", "event": "case_message", "kind": "error", - "message": "was not a good boy", - "name": "dog" + "message": "I failed", + "name": "custom_error" }, { "elapsed_s": "[..]", "event": "case_complete", - "name": "dog" + "name": "custom_error" }, { "elapsed_s": "[..]", From df8b78fae3fbd5ea20c584ffc0fee184156edfef Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 29 Oct 2025 13:53:52 -0500 Subject: [PATCH 5/8] feat(test2): Allow use of custom error types --- crates/libtest2-harness/src/error.rs | 9 +++++++++ crates/libtest2/tests/testsuite/mixed_bag.rs | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/libtest2-harness/src/error.rs b/crates/libtest2-harness/src/error.rs index fd35e81..675b92a 100644 --- a/crates/libtest2-harness/src/error.rs +++ b/crates/libtest2-harness/src/error.rs @@ -80,3 +80,12 @@ impl IntoRunResult for RunResult { self } } + +impl IntoRunResult for Result<(), E> +where + E: std::error::Error + Send + Sync + 'static, +{ + fn into_run_result(self) -> RunResult { + self.map_err(RunError::with_cause) + } +} diff --git a/crates/libtest2/tests/testsuite/mixed_bag.rs b/crates/libtest2/tests/testsuite/mixed_bag.rs index 5ff7593..edbf2ae 100644 --- a/crates/libtest2/tests/testsuite/mixed_bag.rs +++ b/crates/libtest2/tests/testsuite/mixed_bag.rs @@ -65,8 +65,8 @@ fn horse(context: &libtest2::TestContext) { } #[libtest2::test] -fn custom_error(context: &libtest2::TestContext) -> libtest2::RunResult { - Err(libtest2::RunError::from(std::io::Error::new(std::io::ErrorKind::Other, "I failed"))) +fn custom_error(context: &libtest2::TestContext) -> std::io::Result<()> { + Err(std::io::Error::new(std::io::ErrorKind::Other, "I failed")) } "#, From 16317e70e5dd8df5ee4343d540bd596e51d77963 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 29 Oct 2025 13:56:54 -0500 Subject: [PATCH 6/8] docs(test2): Cover baseline behavio differences --- crates/libtest2/src/lib.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/crates/libtest2/src/lib.rs b/crates/libtest2/src/lib.rs index aa1e2c2..a36ef99 100644 --- a/crates/libtest2/src/lib.rs +++ b/crates/libtest2/src/lib.rs @@ -27,6 +27,19 @@ //! fn main() { //! } //! ``` +//! +//! # Known limitations and differences to the official test harness +//! +//! `libtest2` aims to be fully compatible with stable, non-deprecated parts of `libtest` +//! but there are differences for now. +//! +//! Some of the notable differences: +//! +//! - Output capture and `--no-capture`: simply not supported. The official +//! `libtest` uses internal `std` functions to temporarily redirect output. +//! `libtest` cannot use those, see also [libtest2#12](https://github.com/assert-rs/libtest2/issues/12) +//! - `--format=json` (unstable): our schema is part of an experiment to see what should be +//! stabilized for `libtest`, see also [libtest2#42](https://github.com/assert-rs/libtest2/issues/42) #![cfg_attr(docsrs, feature(doc_cfg))] //#![warn(clippy::print_stderr)] From e472bcf34bd16bf2094f2e43b94c828b73c257b5 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 29 Oct 2025 13:57:06 -0500 Subject: [PATCH 7/8] docs(test2): Cover macro return type differences --- crates/libtest2/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/libtest2/src/lib.rs b/crates/libtest2/src/lib.rs index a36ef99..c1c0989 100644 --- a/crates/libtest2/src/lib.rs +++ b/crates/libtest2/src/lib.rs @@ -35,6 +35,8 @@ //! //! Some of the notable differences: //! +//! - `#[test]` does not support all `Termination` types as return values, +//! only what [`IntoRunResult`] supports. //! - Output capture and `--no-capture`: simply not supported. The official //! `libtest` uses internal `std` functions to temporarily redirect output. //! `libtest` cannot use those, see also [libtest2#12](https://github.com/assert-rs/libtest2/issues/12) From e313c58b168c7056971ac24e4e141927e5e3b981 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 29 Oct 2025 13:57:37 -0500 Subject: [PATCH 8/8] docs(test2): Cover ignore macro differences --- crates/libtest2/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/libtest2/src/lib.rs b/crates/libtest2/src/lib.rs index c1c0989..900cae8 100644 --- a/crates/libtest2/src/lib.rs +++ b/crates/libtest2/src/lib.rs @@ -37,6 +37,7 @@ //! //! - `#[test]` does not support all `Termination` types as return values, //! only what [`IntoRunResult`] supports. +//! - `#[ignore]` must come after the `#[test]` macro //! - Output capture and `--no-capture`: simply not supported. The official //! `libtest` uses internal `std` functions to temporarily redirect output. //! `libtest` cannot use those, see also [libtest2#12](https://github.com/assert-rs/libtest2/issues/12)