Skip to content

Commit 8e6482b

Browse files
committed
Add a test to ensure that library path is absolute
1 parent 6d939e6 commit 8e6482b

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

test/project/main.gd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,12 @@ func _ready():
270270
assert_equal(example_child.get_value1(), 11)
271271
assert_equal(example_child.get_value2(), 22)
272272

273+
# Test that the extension's library path is absolute and valid.
274+
var library_path = Example.test_library_path()
275+
assert_equal(library_path.begins_with("res://"), false)
276+
assert_equal(library_path, ProjectSettings.globalize_path(library_path))
277+
assert_equal(FileAccess.file_exists(library_path), true)
278+
273279
exit_with_status()
274280

275281
func _on_Example_custom_signal(signal_name, value):

test/src/example.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ void Example::_bind_methods() {
248248
ClassDB::bind_static_method("Example", D_METHOD("test_static", "a", "b"), &Example::test_static);
249249
ClassDB::bind_static_method("Example", D_METHOD("test_static2"), &Example::test_static2);
250250

251+
ClassDB::bind_static_method("Example", D_METHOD("test_library_path"), &Example::test_library_path);
252+
251253
{
252254
MethodInfo mi;
253255
mi.arguments.push_back(PropertyInfo(Variant::STRING, "some_argument"));
@@ -695,6 +697,12 @@ String Example::test_use_engine_singleton() const {
695697
return OS::get_singleton()->get_name();
696698
}
697699

700+
String Example::test_library_path() {
701+
String library_path;
702+
internal::gdextension_interface_get_library_path(internal::library, library_path._native_ptr());
703+
return library_path;
704+
}
705+
698706
void ExampleRuntime::_bind_methods() {
699707
ClassDB::bind_method(D_METHOD("set_prop_value", "value"), &ExampleRuntime::set_prop_value);
700708
ClassDB::bind_method(D_METHOD("get_prop_value"), &ExampleRuntime::get_prop_value);

test/src/example.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ class Example : public Control {
194194
GDVIRTUAL1(_do_something_virtual_with_control, Control *);
195195

196196
String test_use_engine_singleton() const;
197+
198+
static String test_library_path();
197199
};
198200

199201
VARIANT_ENUM_CAST(Example::Constants);

0 commit comments

Comments
 (0)