diff --git a/.github/workflows/build_engine_version.yml b/.github/workflows/build_engine_version.yml index 45d2e388..526518b7 100644 --- a/.github/workflows/build_engine_version.yml +++ b/.github/workflows/build_engine_version.yml @@ -36,6 +36,7 @@ jobs: with: version: ${{ inputs.version }} version_ref: ${{ inputs.version_ref }} + tests: ${{ github.event_name != 'release' }} macos-build: name: 🍎 macOS @@ -43,6 +44,7 @@ jobs: with: version: ${{ inputs.version }} version_ref: ${{ inputs.version_ref }} + tests: ${{ github.event_name != 'release' }} windows-build: name: 🏁 Windows @@ -50,6 +52,7 @@ jobs: with: version: ${{ inputs.version }} version_ref: ${{ inputs.version_ref }} + tests: ${{ github.event_name != 'release' }} web-build: name: 🌐 Web diff --git a/.github/workflows/build_ios.yml b/.github/workflows/build_ios.yml index 89eaac27..09f50122 100644 --- a/.github/workflows/build_ios.yml +++ b/.github/workflows/build_ios.yml @@ -14,6 +14,7 @@ on: env: # 4.4 SCONSFLAGS: >- + strict_checks=yes debug_symbols=no module_text_server_fb_enabled=yes # 4.5+ diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index 48a1754f..9790d559 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -9,13 +9,16 @@ on: description: "Godot engine commit reference" required: true type: string + tests: + type: boolean + default: true # Global Settings env: # 4.4 SCONSFLAGS: >- - module_text_server_fb_enabled=yes - strict_checks=yes + module_text_server_fb_enabled=yes + strict_checks=yes # 4.5 # Ideally we'd use dev_mode=yes. Unfortunately, v8 headers contain warnings. So we manually set some dev_mode options. SCONS_FLAGS: >- @@ -54,7 +57,6 @@ jobs: cache-name: linux-template-${{inputs.version}}-debug-v8 sconsflags: debug_symbols=no target: template_debug - bin: ./bin/godot.linuxbsd.template_debug.x86_64.v8 cache-limit: 1 - name: Editor (target=editor, qjs_ng) @@ -142,6 +144,7 @@ jobs: sconsflags: ${{ env.SCONSFLAGS }} ${{ matrix.sconsflags }} platform: linuxbsd target: ${{ matrix.target }} + tests: ${{ inputs.tests && matrix.target == 'editor' }} scons-cache-limit: ${{ matrix.cache-limit }} - name: Compilation [4.5+] @@ -150,6 +153,7 @@ jobs: with: scons-flags: ${{ env.SCONS_FLAGS }} ${{ matrix.sconsflags }} platform: linuxbsd + tests: ${{ inputs.tests && matrix.target == 'editor' }} - name: Save Godot build cache uses: ./.github/actions/godot-cache-save @@ -166,3 +170,12 @@ jobs: uses: ./.github/actions/upload-artifact with: name: ${{ matrix.cache-name }} + + - name: Unit tests + if: ${{ inputs.tests && matrix.target == 'editor' }} + env: + BIN: ./bin/godot.linuxbsd.editor.x86_64 + run: | + ${{ env.BIN }} --version + ${{ env.BIN }} --help + ${{ env.BIN }} --headless --test --test-case="[jsb]*" --force-colors \ No newline at end of file diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml index 556c3676..6df6420e 100644 --- a/.github/workflows/build_macos.yml +++ b/.github/workflows/build_macos.yml @@ -9,13 +9,16 @@ on: description: "Godot engine commit reference" required: true type: string + tests: + type: boolean + default: true # Global Settings env: # 4.4 SCONSFLAGS: >- - module_text_server_fb_enabled=yes - strict_checks=yes + module_text_server_fb_enabled=yes + strict_checks=yes # 4.5 # Ideally we'd use dev_mode=yes. Unfortunately, v8 headers contain warnings. So we manually set some dev_mode options. SCONS_FLAGS: >- @@ -143,6 +146,7 @@ jobs: sconsflags: ${{ env.SCONSFLAGS }} ${{ matrix.sconsflags }} arch=x86_64 vulkan=${{ steps.vulkan-sdk.outputs.VULKAN_ENABLED }} platform: macos target: ${{ matrix.target }} + tests: ${{ inputs.tests && matrix.target == 'editor' }} scons-cache-limit: 0 # Only cap on second run to avoid purging unnecessarily - name: Compilation [4.5+] (x86_64) @@ -152,6 +156,7 @@ jobs: scons-flags: ${{ env.SCONS_FLAGS }} ${{ matrix.sconsflags }} arch=x86_64 vulkan=${{ steps.vulkan-sdk.outputs.VULKAN_ENABLED }} platform: macos target: ${{ matrix.target }} + tests: ${{ inputs.tests && matrix.target == 'editor' }} - name: Compilation [4.4] (arm64) if: inputs.version == '4.4' @@ -160,6 +165,7 @@ jobs: sconsflags: ${{ env.SCONSFLAGS }} ${{ matrix.sconsflags }} arch=arm64 vulkan=${{ steps.vulkan-sdk.outputs.VULKAN_ENABLED }} platform: macos target: ${{ matrix.target }} + tests: ${{ inputs.tests && matrix.target == 'editor' }} scons-cache-limit: ${{ matrix.cache-limit }} - name: Compilation [4.5+] (arm64) @@ -169,6 +175,7 @@ jobs: scons-flags: ${{ env.SCONS_FLAGS }} ${{ matrix.sconsflags }} arch=arm64 vulkan=${{ steps.vulkan-sdk.outputs.VULKAN_ENABLED }} platform: macos target: ${{ matrix.target }} + tests: ${{ inputs.tests && matrix.target == 'editor' }} - name: Save Godot build cache uses: ./.github/actions/godot-cache-save @@ -193,6 +200,15 @@ jobs: with: name: ${{ matrix.cache-name }} + - name: Unit tests + if: ${{ inputs.tests && matrix.target == 'editor' }} + env: + BIN: ./bin/godot.macos.editor.universal + run: | + ${{ env.BIN }} --version + ${{ env.BIN }} --help + ${{ env.BIN }} --headless --test --test-case="[jsb]*" --force-colors + build-macos-apps: needs: - build-macos diff --git a/.github/workflows/build_web.yml b/.github/workflows/build_web.yml index ddb18190..f4178c56 100644 --- a/.github/workflows/build_web.yml +++ b/.github/workflows/build_web.yml @@ -14,12 +14,12 @@ on: env: # 4.4 SCONSFLAGS: >- - debug_symbols=no - use_closure_compiler=yes - strict_checks=yes - deprecated=no - lto=none - use_assertions=no + debug_symbols=no + use_closure_compiler=yes + strict_checks=yes + deprecated=no + lto=none + use_assertions=no use_safe_heap=yes # 4.5+ # Ideally we'd use dev_mode=yes. Unfortunately, v8 headers contain warnings. So we manually set some dev_mode options. diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml index 81fcecea..7982e46a 100644 --- a/.github/workflows/build_windows.yml +++ b/.github/workflows/build_windows.yml @@ -9,17 +9,19 @@ on: description: "Godot engine commit reference" required: true type: string + tests: + type: boolean + default: true # Global Settings # SCONS_CACHE for windows must be set in the build environment env: # 4.4 SCONSFLAGS: >- - module_text_server_fb_enabled=yes - d3d12=yes - strict_checks=yes - "angle_libs=${{ github.workspace }}/" - # 4.5+ + module_text_server_fb_enabled=yes + d3d12=yes + strict_checks=yes + "angle_libs=${{ github.workspace }}/"# 4.5+ # Ideally we'd use dev_mode=yes. Unfortunately, v8 headers contain warnings. So we manually set some dev_mode options. SCONS_FLAGS: >- verbose=yes @@ -69,10 +71,10 @@ jobs: target: editor # Skip debug symbols, they're way too big with MSVC. sconsflags: >- - debug_symbols=no - vsproj=yes - vsproj_gen_only=no - windows_subsystem=console + debug_symbols=no + vsproj=yes + vsproj_gen_only=no + windows_subsystem=console use_quickjs_ng=yes cache-limit: 2 engine: qjs_ng @@ -166,6 +168,7 @@ jobs: sconsflags: ${{ env.SCONSFLAGS }} ${{ matrix.sconsflags }} platform: windows target: ${{ matrix.target }} + tests: ${{ inputs.tests && matrix.target == 'editor' }} scons-cache-limit: ${{ matrix.cache-limit }} - name: Compilation (4.5+) @@ -175,6 +178,7 @@ jobs: scons-flags: ${{ env.SCONS_FLAGS }} ${{ matrix.sconsflags }} platform: windows target: ${{ matrix.target }} + tests: ${{ inputs.tests && matrix.target == 'editor' }} - name: Save Godot build cache uses: ./.github/actions/godot-cache-save @@ -190,3 +194,12 @@ jobs: uses: ./.github/actions/upload-artifact with: name: ${{ matrix.cache-name }} + + - name: Unit tests + if: ${{ inputs.tests && matrix.target == 'editor' }} + env: + BIN: ./bin/godot.windows.editor.x86_64.exe + run: | + ${{ env.BIN }} --version + ${{ env.BIN }} --help + ${{ env.BIN }} --headless --test --test-case="[jsb]*" --force-colors \ No newline at end of file diff --git a/tests/jsb_test_helpers.h b/tests/jsb_test_helpers.h index 203a4f96..f93a0034 100644 --- a/tests/jsb_test_helpers.h +++ b/tests/jsb_test_helpers.h @@ -4,6 +4,9 @@ #include "../weaver/jsb_script_language.h" #include "tests/test_macros.h" +#include +#include + #define JSB_TESTS_EXECUTION_SCOPE(env) const jsb::tests::V8ContextScope JSB_CONCAT(unique_, __COUNTER__)(env) namespace jsb::tests @@ -110,7 +113,9 @@ namespace jsb::tests CHECK(FileAccess::exists("project.godot")); // MESSAGE("init GodotJSScriptLanguage on thread ", Thread::get_caller_id()); - install_npm(); + install_npm(); + // Wait for 1 second until ./node_modules has been created + std::this_thread::sleep_for(std::chrono::seconds(1)); compile_scripts(); ignore_directories(); GodotJSScriptLanguage::get_singleton()->init(); @@ -143,6 +148,8 @@ namespace jsb::tests const String exe_path = OS::get_singleton()->get_name() != "Windows" ? "node" : "node.exe"; const Error err = OS::get_singleton()->create_process(exe_path, args); CHECK(err == OK); + // Wait for 1 second until ./.godot has been created + std::this_thread::sleep_for(std::chrono::seconds(1)); CHECK(FileAccess::exists("./.godot/GodotJS/test_01.js")); } diff --git a/tests/test_jsb_any_runtime.h b/tests/test_jsb_any_runtime.h index ce596f63..73ea6075 100644 --- a/tests/test_jsb_any_runtime.h +++ b/tests/test_jsb_any_runtime.h @@ -418,7 +418,7 @@ console.assert(!gd.is_instance_valid(node)); Error err; GodotJSScriptLanguage::get_singleton()->eval_source(R"--( let gd = require("godot"); -let mod = require("test_01"); +let mod = require(".godot/GodotJS/test_01"); console.assert(typeof mod === "object"); console.assert(mod.call_me() == 123); console.assert(typeof mod.default === "function");