File tree 2 files changed +9
-1
lines changed
itest/rust/src/object_tests
2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -154,11 +154,14 @@ fn dynamic_call_with_panic() {
154
154
#[ cfg( not( target_os = "windows" ) ) ]
155
155
let path = "itest/rust/src/object_tests/object_test.rs" ;
156
156
157
+ // Obtain line number dynamically, avoids tedious maintenance on code reorganization.
158
+ let line = ObjPayload :: get_panic_line ( ) ;
159
+
157
160
let expected_error_message = format ! (
158
161
"godot-rust function call failed: Object::call(&\" do_panic\" )\
159
162
\n Source: ObjPayload::do_panic()\
160
163
\n Reason: [panic] do_panic exploded\
161
- \n at {path}:893 "
164
+ \n at {path}:{line} "
162
165
) ;
163
166
164
167
assert_eq ! ( call_error. to_string( ) , expected_error_message) ;
Original file line number Diff line number Diff line change @@ -887,6 +887,11 @@ impl ObjPayload {
887
887
fn do_panic ( & self ) {
888
888
panic ! ( "do_panic exploded" ) ;
889
889
}
890
+
891
+ // Obtain the line number of the panic!() call above; keep equidistant to do_panic() method.
892
+ pub fn get_panic_line ( ) -> u32 {
893
+ line ! ( ) - 5
894
+ }
890
895
}
891
896
892
897
// ----------------------------------------------------------------------------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments