File tree Expand file tree Collapse file tree 8 files changed +36
-35
lines changed Expand file tree Collapse file tree 8 files changed +36
-35
lines changed Original file line number Diff line number Diff line change @@ -64,3 +64,19 @@ impl std::fmt::Display for Message {
6464}
6565
6666impl std:: error:: Error for Message { }
67+
68+ pub trait IntoRunResult {
69+ fn into_run_result ( self ) -> RunResult ;
70+ }
71+
72+ impl IntoRunResult for ( ) {
73+ fn into_run_result ( self ) -> RunResult {
74+ Ok ( ( ) )
75+ }
76+ }
77+
78+ impl IntoRunResult for RunResult {
79+ fn into_run_result ( self ) -> RunResult {
80+ self
81+ }
82+ }
Original file line number Diff line number Diff line change @@ -8,24 +8,17 @@ fn main() {}
88// Tests
99
1010#[ libtest2:: test]
11- fn check_toph ( _context : & TestContext ) -> RunResult {
12- Ok ( ( ) )
13- }
11+ fn check_toph ( _context : & TestContext ) { }
1412#[ libtest2:: test]
15- fn check_katara ( _context : & TestContext ) -> RunResult {
16- Ok ( ( ) )
17- }
13+ fn check_katara ( _context : & TestContext ) { }
1814#[ libtest2:: test]
1915fn check_sokka ( _context : & TestContext ) -> RunResult {
2016 Err ( RunError :: fail ( "Sokka tripped and fell :(" ) )
2117}
2218#[ libtest2:: test]
2319#[ ignore = "slow" ]
24- fn long_computation ( _context : & TestContext ) -> RunResult {
20+ fn long_computation ( _context : & TestContext ) {
2521 std:: thread:: sleep ( std:: time:: Duration :: from_secs ( 1 ) ) ;
26- Ok ( ( ) )
2722}
2823#[ libtest2:: test]
29- fn compile_fail_dummy ( _context : & TestContext ) -> RunResult {
30- Ok ( ( ) )
31- }
24+ fn compile_fail_dummy ( _context : & TestContext ) { }
Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ pub mod _private {
5151
5252pub use case:: main;
5353pub use case:: FnCase ;
54+ pub use libtest2_harness:: IntoRunResult ;
5455pub use libtest2_harness:: RunError ;
5556pub use libtest2_harness:: RunResult ;
5657pub use libtest2_harness:: TestContext ;
Original file line number Diff line number Diff line change @@ -58,7 +58,9 @@ macro_rules! _test_parse {
5858 }
5959 ) *
6060
61- run( context)
61+ use $crate:: IntoRunResult ;
62+ let result = run( context) ;
63+ IntoRunResult :: into_run_result( result)
6264 }
6365 }
6466 } ;
Original file line number Diff line number Diff line change @@ -11,18 +11,15 @@ fn test_cmd() -> snapbox::cmd::Command {
1111fn main() {}
1212
1313#[libtest2::test]
14- fn foo(_context: &libtest2::TestContext) -> libtest2::RunResult {
15- Ok(())
14+ fn foo(_context: &libtest2::TestContext) {
1615}
1716
1817#[libtest2::test]
19- fn bar(_context: &libtest2::TestContext) -> libtest2::RunResult {
20- Ok(())
18+ fn bar(_context: &libtest2::TestContext) {
2119}
2220
2321#[libtest2::test]
24- fn barro(_context: &libtest2::TestContext) -> libtest2::RunResult {
25- Ok(())
22+ fn barro(_context: &libtest2::TestContext) {
2623}
2724"# ,
2825 false ,
Original file line number Diff line number Diff line change @@ -11,23 +11,19 @@ fn test_cmd() -> snapbox::cmd::Command {
1111fn main() {}
1212
1313#[libtest2::test]
14- fn one(_context: &libtest2::TestContext) -> libtest2::RunResult {
15- Ok(())
14+ fn one(_context: &libtest2::TestContext) {
1615}
1716
1817#[libtest2::test]
19- fn two(_context: &libtest2::TestContext) -> libtest2::RunResult {
20- Ok(())
18+ fn two(_context: &libtest2::TestContext) {
2119}
2220
2321#[libtest2::test]
24- fn three(_context: &libtest2::TestContext) -> libtest2::RunResult {
25- Ok(())
22+ fn three(_context: &libtest2::TestContext) {
2623}
2724
2825#[libtest2::test]
29- fn one_two(_context: &libtest2::TestContext) -> libtest2::RunResult {
30- Ok(())
26+ fn one_two(_context: &libtest2::TestContext) {
3127}
3228"# ,
3329 false ,
Original file line number Diff line number Diff line change @@ -11,8 +11,7 @@ fn test_cmd() -> snapbox::cmd::Command {
1111fn main() {}
1212
1313#[libtest2::test]
14- fn cat(_context: &libtest2::TestContext) -> libtest2::RunResult {
15- Ok(())
14+ fn cat(_context: &libtest2::TestContext) {
1615}
1716
1817#[libtest2::test]
@@ -21,8 +20,7 @@ fn dog(_context: &libtest2::TestContext) -> libtest2::RunResult {
2120}
2221
2322#[libtest2::test]
24- fn fox(_context: &libtest2::TestContext) -> libtest2::RunResult {
25- Ok(())
23+ fn fox(_context: &libtest2::TestContext) {
2624}
2725
2826#[libtest2::test]
@@ -63,8 +61,7 @@ fn sheep(context: &libtest2::TestContext) -> libtest2::RunResult {
6361
6462#[libtest2::test]
6563#[ignore = "slow"]
66- fn horse(context: &libtest2::TestContext) -> libtest2::RunResult {
67- Ok(())
64+ fn horse(context: &libtest2::TestContext) {
6865}
6966"# ,
7067 false ,
Original file line number Diff line number Diff line change @@ -11,12 +11,11 @@ fn test_cmd() -> snapbox::cmd::Command {
1111fn main() {}
1212
1313#[libtest2::test]
14- fn passes(_context: &libtest2::TestContext) -> libtest2::RunResult {
15- Ok(())
14+ fn passes(_context: &libtest2::TestContext) {
1615}
1716
1817#[libtest2::test]
19- fn panics(_context: &libtest2::TestContext) -> libtest2::RunResult {
18+ fn panics(_context: &libtest2::TestContext) {
2019 panic!("uh oh")
2120}
2221"# ,
You can’t perform that action at this time.
0 commit comments