@@ -5,6 +5,7 @@ use std::path::PathBuf;
55use super :: * ;
66
77use crate :: {
8+ console:: list_tests_console,
89 console:: OutputLocation ,
910 formatters:: PrettyFormatter ,
1011 test:: {
@@ -957,6 +958,46 @@ fn test_dyn_bench_returning_err_fails_when_run_as_test() {
957958 assert_eq ! ( result, TrFailed ) ;
958959}
959960
961+ #[ test]
962+ fn test_discovery_logfile_format ( ) {
963+ let desc = TestDescAndFn {
964+ desc : TestDesc {
965+ name : StaticTestName ( "whatever" ) ,
966+ ignore : false ,
967+ ignore_message : None ,
968+ source_file : "" ,
969+ start_line : 0 ,
970+ start_col : 0 ,
971+ end_line : 0 ,
972+ end_col : 0 ,
973+ should_panic : ShouldPanic :: No ,
974+ compile_fail : false ,
975+ no_run : false ,
976+ test_type : TestType :: Unknown ,
977+ } ,
978+ testfn : DynTestFn ( Box :: new ( move || Ok ( ( ) ) ) ) ,
979+ } ;
980+
981+ let tmpdir = tmpdir ( ) ;
982+ let output_path = & tmpdir. join ( "output.txt" ) ;
983+
984+ let opts = TestOpts {
985+ run_tests : true ,
986+ logfile : Some ( output_path. clone ( ) ) ,
987+ format : OutputFormat :: Pretty ,
988+ list : true ,
989+ ..TestOpts :: new ( )
990+ } ;
991+ list_tests_console ( & opts, vec ! [ desc] ) . unwrap ( ) ;
992+
993+ let contents = fs:: read_to_string ( output_path) . expect ( "`--logfile` did not create file" ) ;
994+
995+ // Split output at line breaks to make the comparison platform-agnostic regarding newline style.
996+ let contents_lines = contents. as_str ( ) . lines ( ) . collect :: < Vec < & str > > ( ) ;
997+
998+ assert_eq ! ( contents_lines, vec![ "test whatever" ] ) ;
999+ }
1000+
9601001#[ test]
9611002fn test_logfile_format ( ) {
9621003 let desc = TestDescAndFn {
0 commit comments