Skip to content

Commit 6eaae57

Browse files
committed
Handle different string in Release mode
1 parent 808b88d commit 6eaae57

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

itest/rust/src/object_tests/dynamic_call_test.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,19 +149,25 @@ fn dynamic_call_with_panic() {
149149
assert_eq!(call_error.class_name(), Some("Object"));
150150
assert_eq!(call_error.method_name(), "call");
151151

152-
#[cfg(target_os = "windows")]
153-
let path = "itest\\rust\\src\\object_tests\\object_test.rs";
154-
#[cfg(not(target_os = "windows"))]
155-
let path = "itest/rust/src/object_tests/object_test.rs";
152+
let appendix = if cfg!(debug_assertions) {
153+
let mut path = "itest/rust/src/object_tests/object_test.rs".to_string();
156154

157-
// Obtain line number dynamically, avoids tedious maintenance on code reorganization.
158-
let line = ObjPayload::get_panic_line();
155+
if cfg!(target_os = "windows") {
156+
path = path.replace('/', "\\")
157+
}
158+
159+
// Obtain line number dynamically, avoids tedious maintenance on code reorganization.
160+
let line = ObjPayload::get_panic_line();
161+
162+
format!("\n at {path}:{line}")
163+
} else {
164+
String::new()
165+
};
159166

160167
let expected_error_message = format!(
161168
"godot-rust function call failed: Object::call(&\"do_panic\")\
162169
\n Source: ObjPayload::do_panic()\
163-
\n Reason: [panic] do_panic exploded\
164-
\n at {path}:{line}"
170+
\n Reason: [panic] do_panic exploded{appendix}"
165171
);
166172

167173
assert_eq!(call_error.to_string(), expected_error_message);

0 commit comments

Comments
 (0)