File tree Expand file tree Collapse file tree 1 file changed +16
-10
lines changed Expand file tree Collapse file tree 1 file changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -440,17 +440,20 @@ mod test {
440
440
#[ test]
441
441
fn test_config_bad_file_path_exists_fail ( ) {
442
442
let mut logtest = LogTest :: setup ( "bad_file_path_exists_fail_dir" ) ;
443
- let path = logtest. will_create_file ( "log.out" ) ;
444
- fs:: write ( & path, "" ) . expect ( "writing empty file" ) ;
443
+ let logpath = logtest. will_create_file ( "log.out" ) ;
444
+ fs:: write ( & logpath, "" ) . expect ( "writing empty file" ) ;
445
+
446
+ // Windows paths need to have \ turned into \\
447
+ let escaped_path = logpath. display ( ) . to_string ( ) . escape_default ( ) . to_string ( ) ;
445
448
446
449
let bad_config = format ! (
447
450
r#"
448
451
mode = "file"
449
452
level = "warn"
450
453
if_exists = "fail"
451
- path = {:?}
454
+ path = "{}"
452
455
"# ,
453
- path
456
+ escaped_path
454
457
) ;
455
458
456
459
let error = read_config_and_create_logger (
@@ -474,15 +477,18 @@ mod test {
474
477
let logpath = logtest. will_create_file ( "log.out" ) ;
475
478
let time_before = chrono:: offset:: Utc :: now ( ) ;
476
479
480
+ // Windows paths need to have \ turned into \\
481
+ let escaped_path = logpath. display ( ) . to_string ( ) . escape_default ( ) . to_string ( ) ;
482
+
477
483
/* The first attempt should succeed. The log file doesn't exist yet. */
478
484
let config = format ! (
479
485
r#"
480
486
mode = "file"
481
487
level = "warn"
482
488
if_exists = "fail"
483
- path = {:?}
489
+ path = "{}"
484
490
"# ,
485
- & logpath
491
+ escaped_path
486
492
) ;
487
493
488
494
{
@@ -502,9 +508,9 @@ mod test {
502
508
mode = "file"
503
509
level = "warn"
504
510
if_exists = "append"
505
- path = {:?}
511
+ path = "{}"
506
512
"# ,
507
- & logpath
513
+ escaped_path
508
514
) ;
509
515
510
516
{
@@ -544,9 +550,9 @@ mod test {
544
550
mode = "file"
545
551
level = "trace"
546
552
if_exists = "truncate"
547
- path = {:?}
553
+ path = "{}"
548
554
"# ,
549
- & logpath
555
+ escaped_path
550
556
) ;
551
557
552
558
{
You can’t perform that action at this time.
0 commit comments