Skip to content

Commit

Permalink
Add a test to ensure that library path is absolute
Browse files Browse the repository at this point in the history
(cherry picked from commit 92ace04)
  • Loading branch information
dsnopek committed Sep 3, 2024
1 parent 842a7f6 commit 1ac33c9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/project/main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,12 @@ func _ready():
assert_equal(example_child.get_value1(), 11)
assert_equal(example_child.get_value2(), 22)

# Test that the extension's library path is absolute and valid.
var library_path = Example.test_library_path()
assert_equal(library_path.begins_with("res://"), false)
assert_equal(library_path, ProjectSettings.globalize_path(library_path))
assert_equal(FileAccess.file_exists(library_path), true)

exit_with_status()

func _on_Example_custom_signal(signal_name, value):
Expand Down
8 changes: 8 additions & 0 deletions test/src/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ void Example::_bind_methods() {
ClassDB::bind_static_method("Example", D_METHOD("test_static", "a", "b"), &Example::test_static);
ClassDB::bind_static_method("Example", D_METHOD("test_static2"), &Example::test_static2);

ClassDB::bind_static_method("Example", D_METHOD("test_library_path"), &Example::test_library_path);

{
MethodInfo mi;
mi.arguments.push_back(PropertyInfo(Variant::STRING, "some_argument"));
Expand Down Expand Up @@ -709,6 +711,12 @@ String Example::test_use_engine_singleton() const {
return OS::get_singleton()->get_name();
}

String Example::test_library_path() {
String library_path;
internal::gdextension_interface_get_library_path(internal::library, library_path._native_ptr());
return library_path;
}

void ExampleRuntime::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_prop_value", "value"), &ExampleRuntime::set_prop_value);
ClassDB::bind_method(D_METHOD("get_prop_value"), &ExampleRuntime::get_prop_value);
Expand Down
2 changes: 2 additions & 0 deletions test/src/example.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ class Example : public Control {
GDVIRTUAL1(_do_something_virtual_with_control, Control *);

String test_use_engine_singleton() const;

static String test_library_path();
};

VARIANT_ENUM_CAST(Example::Constants);
Expand Down

0 comments on commit 1ac33c9

Please sign in to comment.