Skip to content

Commit d477589

Browse files
authored
Merge pull request godotengine#1520 from dsnopek/test-library-path-absolute
Add a test to ensure that library path is absolute
2 parents aac0164 + 92ace04 commit d477589

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
@@ -249,6 +249,8 @@ void Example::_bind_methods() {
249249
ClassDB::bind_static_method("Example", D_METHOD("test_static", "a", "b"), &Example::test_static);
250250
ClassDB::bind_static_method("Example", D_METHOD("test_static2"), &Example::test_static2);
251251

252+
ClassDB::bind_static_method("Example", D_METHOD("test_library_path"), &Example::test_library_path);
253+
252254
{
253255
MethodInfo mi;
254256
mi.arguments.push_back(PropertyInfo(Variant::STRING, "some_argument"));
@@ -709,6 +711,12 @@ String Example::test_use_engine_singleton() const {
709711
return OS::get_singleton()->get_name();
710712
}
711713

714+
String Example::test_library_path() {
715+
String library_path;
716+
internal::gdextension_interface_get_library_path(internal::library, library_path._native_ptr());
717+
return library_path;
718+
}
719+
712720
void ExampleRuntime::_bind_methods() {
713721
ClassDB::bind_method(D_METHOD("set_prop_value", "value"), &ExampleRuntime::set_prop_value);
714722
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
@@ -195,6 +195,8 @@ class Example : public Control {
195195
GDVIRTUAL1(_do_something_virtual_with_control, Control *);
196196

197197
String test_use_engine_singleton() const;
198+
199+
static String test_library_path();
198200
};
199201

200202
VARIANT_ENUM_CAST(Example::Constants);

0 commit comments

Comments
 (0)