Skip to content

Commit fd31fab

Browse files
committed
Add a test to ensure that library path is absolute
(cherry picked from commit 92ace04)
1 parent 9d26e34 commit fd31fab

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
@@ -257,6 +257,12 @@ func _ready():
257257
assert_equal(example_child.get_value1(), 11)
258258
assert_equal(example_child.get_value2(), 22)
259259

260+
# Test that the extension's library path is absolute and valid.
261+
var library_path = Example.test_library_path()
262+
assert_equal(library_path.begins_with("res://"), false)
263+
assert_equal(library_path, ProjectSettings.globalize_path(library_path))
264+
assert_equal(FileAccess.file_exists(library_path), true)
265+
260266
exit_with_status()
261267

262268
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
@@ -238,6 +238,8 @@ void Example::_bind_methods() {
238238
ClassDB::bind_static_method("Example", D_METHOD("test_static", "a", "b"), &Example::test_static);
239239
ClassDB::bind_static_method("Example", D_METHOD("test_static2"), &Example::test_static2);
240240

241+
ClassDB::bind_static_method("Example", D_METHOD("test_library_path"), &Example::test_library_path);
242+
241243
{
242244
MethodInfo mi;
243245
mi.arguments.push_back(PropertyInfo(Variant::STRING, "some_argument"));
@@ -675,3 +677,9 @@ void ExampleChild::_notification(int p_what) {
675677
String Example::test_use_engine_singleton() const {
676678
return OS::get_singleton()->get_name();
677679
}
680+
681+
String Example::test_library_path() {
682+
String library_path;
683+
internal::gdextension_interface_get_library_path(internal::library, library_path._native_ptr());
684+
return library_path;
685+
}

test/src/example.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ class Example : public Control {
185185
virtual void _input(const Ref<InputEvent> &event) override;
186186

187187
String test_use_engine_singleton() const;
188+
189+
static String test_library_path();
188190
};
189191

190192
VARIANT_ENUM_CAST(Example::Constants);

0 commit comments

Comments
 (0)