@@ -62,14 +62,16 @@ impl TestOutcome {
6262 ///
6363 /// **For internal use only. API stablility is not guaranteed!**
6464 #[ doc( hidden) ]
65- pub fn close_current_test_outcome < E : Display > ( inner_result : Result < ( ) , E > ) -> Result < ( ) , ( ) > {
65+ pub fn close_current_test_outcome < E : Display > (
66+ inner_result : Result < ( ) , E > ,
67+ ) -> Result < ( ) , TestFailure > {
6668 TestOutcome :: with_current_test_outcome ( |mut outcome| {
6769 let outer_result = match & * outcome {
6870 Some ( TestOutcome :: Success ) => match inner_result {
6971 Ok ( ( ) ) => Ok ( ( ) ) ,
70- Err ( _) => Err ( ( ) ) ,
72+ Err ( _) => Err ( TestFailure ) ,
7173 } ,
72- Some ( TestOutcome :: Failure ) => Err ( ( ) ) ,
74+ Some ( TestOutcome :: Failure ) => Err ( TestFailure ) ,
7375 None => {
7476 panic ! ( "No test context found. This indicates a bug in GoogleTest." )
7577 }
@@ -114,6 +116,29 @@ No test context found.
114116 }
115117}
116118
119+ /// A marking struct indicating that a test has failed.
120+ ///
121+ /// This exists to implement the [Error][std::error::Error] trait. It displays
122+ /// to a message indicating that the actual test assertion failure messages are
123+ /// in the text above.
124+ pub struct TestFailure ;
125+
126+ impl std:: error:: Error for TestFailure { }
127+
128+ impl std:: fmt:: Debug for TestFailure {
129+ fn fmt ( & self , f : & mut Formatter < ' _ > ) -> Result < ( ) , Error > {
130+ writeln ! ( f, "See failure output above" ) ?;
131+ Ok ( ( ) )
132+ }
133+ }
134+
135+ impl std:: fmt:: Display for TestFailure {
136+ fn fmt ( & self , f : & mut Formatter < ' _ > ) -> Result < ( ) , Error > {
137+ writeln ! ( f, "See failure output above" ) ?;
138+ Ok ( ( ) )
139+ }
140+ }
141+
117142/// A report that a single test assertion failed.
118143///
119144/// **For internal use only. API stablility is not guaranteed!**
0 commit comments