From 2d67f9ae8b26fd1b9086cc419e1423dbb7b8a54f Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Mon, 21 Jul 2025 17:07:18 +0800 Subject: [PATCH] fix: windows path in error tests (#6564) --- src/common/error/tests/ext.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/common/error/tests/ext.rs b/src/common/error/tests/ext.rs index 82f2ee4440..d22ad96a43 100644 --- a/src/common/error/tests/ext.rs +++ b/src/common/error/tests/ext.rs @@ -84,29 +84,32 @@ fn test_to_string() { assert_eq!(result.unwrap_err().to_string(), ""); } +fn normalize_path(s: &str) -> String { + s.replace('\\', "/") +} + #[test] fn test_debug_format() { let result = normal_error(); let debug_output = format!("{:?}", result.unwrap_err()); - let normalized_output = debug_output.replace('\\', "/"); + assert_eq!( - normalized_output, + normalize_path(&debug_output), format!( r#"0: A normal error with "display" attribute, message "blabla", at {}:55:22 1: PlainError {{ msg: "", status_code: Unexpected }}"#, - file!() + normalize_path(file!()) ) ); let result = transparent_error(); let debug_output = format!("{:?}", result.unwrap_err()); - let normalized_output = debug_output.replace('\\', "/"); assert_eq!( - normalized_output, + normalize_path(&debug_output), format!( r#"0: , at {}:60:5 1: PlainError {{ msg: "", status_code: Unexpected }}"#, - file!() + normalize_path(file!()) ) ); }