@@ -5,6 +5,7 @@ use std::path::PathBuf;
5
5
use super :: * ;
6
6
7
7
use crate :: {
8
+ console:: list_tests_console,
8
9
console:: OutputLocation ,
9
10
formatters:: PrettyFormatter ,
10
11
test:: {
@@ -957,6 +958,46 @@ fn test_dyn_bench_returning_err_fails_when_run_as_test() {
957
958
assert_eq ! ( result, TrFailed ) ;
958
959
}
959
960
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
+
960
1001
#[ test]
961
1002
fn test_logfile_format ( ) {
962
1003
let desc = TestDescAndFn {
0 commit comments