diff --git a/.gitmodules b/.gitmodules index c041a5a3..22361ffd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "godot-cpp"] path = godot-cpp url = https://github.com/godotengine/godot-cpp.git +[submodule "ext/Gut"] + path = ext/Gut + url = https://github.com/bitwes/Gut.git diff --git a/ext/Gut b/ext/Gut new file mode 160000 index 00000000..a55b6c5e --- /dev/null +++ b/ext/Gut @@ -0,0 +1 @@ +Subproject commit a55b6c5e5f7d13ae83cfb4830f61e3d800ebc864 diff --git a/tests/addons/gut b/tests/addons/gut new file mode 120000 index 00000000..00881ed3 --- /dev/null +++ b/tests/addons/gut @@ -0,0 +1 @@ +../../ext/Gut/addons/gut \ No newline at end of file diff --git a/tests/extensions/bin/libgodot-riscv.linux.debug.x86_64.so b/tests/extensions/bin/libgodot-riscv.linux.debug.x86_64.so new file mode 120000 index 00000000..6d58d4e4 --- /dev/null +++ b/tests/extensions/bin/libgodot-riscv.linux.debug.x86_64.so @@ -0,0 +1 @@ +/home/gonzo/github/godot-riscv/.build/libgodot-riscv.so \ No newline at end of file diff --git a/tests/extensions/bin/libgodot-riscv.linux.release.x86_64.so b/tests/extensions/bin/libgodot-riscv.linux.release.x86_64.so new file mode 120000 index 00000000..6d58d4e4 --- /dev/null +++ b/tests/extensions/bin/libgodot-riscv.linux.release.x86_64.so @@ -0,0 +1 @@ +/home/gonzo/github/godot-riscv/.build/libgodot-riscv.so \ No newline at end of file diff --git a/tests/extensions/bin/libgodot_riscv.web.template_debug.wasm32.wasm b/tests/extensions/bin/libgodot_riscv.web.template_debug.wasm32.wasm new file mode 120000 index 00000000..8e3a5f62 --- /dev/null +++ b/tests/extensions/bin/libgodot_riscv.web.template_debug.wasm32.wasm @@ -0,0 +1 @@ +/home/gonzo/github/godot-riscv/bin/addons/godot_sandbox/bin/libgodot_riscv.web.template_debug.wasm32.wasm \ No newline at end of file diff --git a/tests/extensions/bin/libgodot_riscv.web.template_release.wasm32.wasm b/tests/extensions/bin/libgodot_riscv.web.template_release.wasm32.wasm new file mode 120000 index 00000000..d9781fa2 --- /dev/null +++ b/tests/extensions/bin/libgodot_riscv.web.template_release.wasm32.wasm @@ -0,0 +1 @@ +/home/gonzo/github/godot-riscv/bin/addons/godot_sandbox/bin/libgodot_riscv.web.template_release.wasm32.wasm \ No newline at end of file diff --git a/tests/extensions/libgodot-riscv.gdextension b/tests/extensions/libgodot-riscv.gdextension new file mode 100644 index 00000000..49dc0187 --- /dev/null +++ b/tests/extensions/libgodot-riscv.gdextension @@ -0,0 +1,18 @@ +[configuration] + +entry_symbol = "riscv_library_init" +compatibility_minimum = "4.1" + +[icons] + + +[libraries] + +macos.debug = "bin/libgodot-riscv.macos.debug.framework" +macos.release = "bin/libgodot-riscv.macos.release.framework" +windows.debug.x86_64 = "bin/libgodot-riscv.windows.debug.x86_64.dll" +windows.release.x86_64 = "bin/libgodot-riscv.windows.release.x86_64.dll" +linux.debug.x86_64 = "bin/libgodot-riscv.linux.debug.x86_64.so" +linux.release.x86_64 = "bin/libgodot-riscv.linux.release.x86_64.so" +web.debug.wasm32 = "bin/libgodot_riscv.web.template_debug.wasm32.wasm" +web.release.wasm32 = "bin/libgodot_riscv.web.template_release.wasm32.wasm" diff --git a/tests/icon.svg b/tests/icon.svg new file mode 100644 index 00000000..9d8b7fa1 --- /dev/null +++ b/tests/icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/icon.svg.import b/tests/icon.svg.import new file mode 100644 index 00000000..52eb3206 --- /dev/null +++ b/tests/icon.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://6xqmeymr5t3" +path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.svg" +dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/tests/project.godot b/tests/project.godot new file mode 100644 index 00000000..881db353 --- /dev/null +++ b/tests/project.godot @@ -0,0 +1,19 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=5 + +[application] + +config/name="tests" +config/features=PackedStringArray("4.3", "Forward Plus") +config/icon="res://icon.svg" + +[editor_plugins] + +enabled=PackedStringArray("res://addons/gut/plugin.cfg") diff --git a/tests/tests/test_basic.cpp b/tests/tests/test_basic.cpp new file mode 100644 index 00000000..8d6b91a8 --- /dev/null +++ b/tests/tests/test_basic.cpp @@ -0,0 +1,9 @@ +#include "api.hpp" + +extern "C" Variant public_function() { + return "Hello from the other side"; +} + +extern "C" Variant test_dictionary(Variant dict) { + return Dictionary(dict)["1"]; +} diff --git a/tests/tests/test_basic.gd b/tests/tests/test_basic.gd new file mode 100644 index 00000000..52ab91f6 --- /dev/null +++ b/tests/tests/test_basic.gd @@ -0,0 +1,17 @@ +extends GutTest + +func test_instantiation(): + # Create a new sandbox + var s = Sandbox.new() + # Set the test program + s.set_program(Sandbox_TestsTests) + + # Verify that a basic function that returns a String works + assert_eq(s.vmcall("public_function"), "Hello from the other side") + + # Verify that the sandbox can receive a Dictionary and return an element + var d : Dictionary + d["1"] = Dictionary() + d["1"]["2"] = "3" + + assert_eq(s.vmcall("test_dictionary", d), d["1"])