@@ -187,6 +187,14 @@ impl ReporterStderrImpl<'_> {
187187 ReporterStderrImpl :: TerminalWithoutBar | ReporterStderrImpl :: Buffer ( _) => { }
188188 }
189189 }
190+
191+ #[ cfg( test) ]
192+ fn buf_mut ( & mut self ) -> Option < & mut Vec < u8 > > {
193+ match self {
194+ Self :: Buffer ( buf) => Some ( buf) ,
195+ _ => None ,
196+ }
197+ }
190198}
191199
192200#[ derive( Debug ) ]
@@ -761,7 +769,7 @@ impl<'a> DisplayReporterImpl<'a> {
761769 let last_status = run_statuses. last_status ( ) ;
762770
763771 self . write_final_status_line (
764- * test_instance,
772+ test_instance. id ( ) ,
765773 run_statuses. describe ( ) ,
766774 writer,
767775 ) ?;
@@ -902,7 +910,7 @@ impl<'a> DisplayReporterImpl<'a> {
902910
903911 fn write_final_status_line (
904912 & self ,
905- test_instance : TestInstance < ' a > ,
913+ test_instance : TestInstanceId < ' a > ,
906914 describe : ExecutionDescription < ' _ > ,
907915 writer : & mut dyn Write ,
908916 ) -> io:: Result < ( ) > {
@@ -956,11 +964,11 @@ impl<'a> DisplayReporterImpl<'a> {
956964 } ;
957965
958966 // Next, print the time taken and the name of the test.
959- write ! (
967+ writeln ! (
960968 writer,
961969 "{}{}" ,
962970 DisplayBracketedDuration ( last_status. time_taken) ,
963- self . display_test_instance( test_instance. id ( ) ) ,
971+ self . display_test_instance( test_instance) ,
964972 ) ?;
965973
966974 // On Windows, also print out the exception if available.
@@ -1755,6 +1763,88 @@ mod tests {
17551763 f ( reporter) ;
17561764 }
17571765
1766+ #[ test]
1767+ fn final_status_line ( ) {
1768+ let binary_id = RustBinaryId :: new ( "my-binary-id" ) ;
1769+ let test_instance = TestInstanceId {
1770+ binary_id : & binary_id,
1771+ test_name : "test1" ,
1772+ } ;
1773+
1774+ let fail_result = ExecutionResult :: Fail {
1775+ abort_status : None ,
1776+ leaked : false ,
1777+ } ;
1778+
1779+ let fail_status = ExecuteStatus {
1780+ retry_data : RetryData {
1781+ attempt : 1 ,
1782+ total_attempts : 2 ,
1783+ } ,
1784+ // output is not relevant here.
1785+ output : make_split_output ( Some ( fail_result) , "" , "" ) ,
1786+ result : fail_result,
1787+ start_time : Local :: now ( ) . into ( ) ,
1788+ time_taken : Duration :: from_secs ( 1 ) ,
1789+ is_slow : false ,
1790+ delay_before_start : Duration :: ZERO ,
1791+ } ;
1792+ let fail_describe = ExecutionDescription :: Failure {
1793+ first_status : & fail_status,
1794+ last_status : & fail_status,
1795+ retries : & [ ] ,
1796+ } ;
1797+
1798+ let flaky_status = ExecuteStatus {
1799+ retry_data : RetryData {
1800+ attempt : 2 ,
1801+ total_attempts : 2 ,
1802+ } ,
1803+ // output is not relevant here.
1804+ output : make_split_output ( Some ( fail_result) , "" , "" ) ,
1805+ result : ExecutionResult :: Pass ,
1806+ start_time : Local :: now ( ) . into ( ) ,
1807+ time_taken : Duration :: from_secs ( 2 ) ,
1808+ is_slow : false ,
1809+ delay_before_start : Duration :: ZERO ,
1810+ } ;
1811+
1812+ // Make an `ExecutionStatuses` with a failure and a success, indicating flakiness.
1813+ let statuses = ExecutionStatuses :: new ( vec ! [ fail_status. clone( ) , flaky_status] ) ;
1814+ let flaky_describe = statuses. describe ( ) ;
1815+
1816+ let mut out = Vec :: new ( ) ;
1817+
1818+ with_reporter (
1819+ |mut reporter| {
1820+ // TODO: write a bunch more outputs here.
1821+ reporter
1822+ . inner
1823+ . write_final_status_line (
1824+ test_instance,
1825+ fail_describe,
1826+ reporter. stderr . buf_mut ( ) . unwrap ( ) ,
1827+ )
1828+ . unwrap ( ) ;
1829+
1830+ reporter
1831+ . inner
1832+ . write_final_status_line (
1833+ test_instance,
1834+ flaky_describe,
1835+ reporter. stderr . buf_mut ( ) . unwrap ( ) ,
1836+ )
1837+ . unwrap ( ) ;
1838+ } ,
1839+ & mut out,
1840+ ) ;
1841+
1842+ insta:: assert_snapshot!(
1843+ "final_status_output" ,
1844+ String :: from_utf8( out) . expect( "output only consists of UTF-8" ) ,
1845+ ) ;
1846+ }
1847+
17581848 // ---
17591849
17601850 /// Send an information response to the reporter and return the output.
0 commit comments