2424#![ warn( clippy:: print_stderr) ]
2525#![ warn( clippy:: print_stdout) ]
2626
27- pub use libtest2_harness:: RunError ;
28- pub use libtest2_harness:: RunResult ;
2927pub use libtest_json:: RunMode ;
3028
3129pub struct Harness {
@@ -92,8 +90,32 @@ impl libtest2_harness::Case for Trial {
9290 false
9391 }
9492
95- fn run ( & self , context : & libtest2_harness:: TestContext ) -> Result < ( ) , RunError > {
96- ( self . runner ) ( TestContext { inner : context } )
93+ fn run (
94+ & self ,
95+ context : & libtest2_harness:: TestContext ,
96+ ) -> Result < ( ) , libtest2_harness:: RunError > {
97+ ( self . runner ) ( TestContext { inner : context } ) . map_err ( |e| e. inner )
98+ }
99+ }
100+
101+ pub type RunResult = Result < ( ) , RunError > ;
102+
103+ #[ derive( Debug ) ]
104+ pub struct RunError {
105+ inner : libtest2_harness:: RunError ,
106+ }
107+
108+ impl RunError {
109+ pub fn with_cause ( cause : impl std:: error:: Error + Send + Sync + ' static ) -> Self {
110+ Self {
111+ inner : libtest2_harness:: RunError :: with_cause ( cause) ,
112+ }
113+ }
114+
115+ pub fn fail ( cause : impl std:: fmt:: Display ) -> Self {
116+ Self {
117+ inner : libtest2_harness:: RunError :: fail ( cause) ,
118+ }
97119 }
98120}
99121
@@ -104,11 +126,13 @@ pub struct TestContext<'t> {
104126
105127impl < ' t > TestContext < ' t > {
106128 pub fn ignore ( & self ) -> Result < ( ) , RunError > {
107- self . inner . ignore ( )
129+ self . inner . ignore ( ) . map_err ( |e| RunError { inner : e } )
108130 }
109131
110132 pub fn ignore_for ( & self , reason : impl std:: fmt:: Display ) -> Result < ( ) , RunError > {
111- self . inner . ignore_for ( reason)
133+ self . inner
134+ . ignore_for ( reason)
135+ . map_err ( |e| RunError { inner : e } )
112136 }
113137
114138 pub fn current_mode ( & self ) -> RunMode {
0 commit comments