Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Run unit tests on desktop release templates #93780

Merged
merged 2 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .github/workflows/linux_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,18 @@ jobs:
- name: Template w/ Mono (target=template_release)
cache-name: linux-template-mono
target: template_release
sconsflags: module_mono_enabled=yes
sconsflags: module_mono_enabled=yes tests=yes
bin: "./bin/godot.linuxbsd.template_release.x86_64.mono"
build-mono: false
tests: false
tests: true
artifact: true

- name: Minimal template (target=template_release, everything disabled)
cache-name: linux-template-minimal
target: template_release
sconsflags: modules_enabled_by_default=no disable_3d=yes disable_advanced_gui=yes deprecated=no minizip=no
tests: false
sconsflags: modules_enabled_by_default=no disable_3d=yes disable_advanced_gui=yes deprecated=no minizip=no tests=yes
bin: "./bin/godot.linuxbsd.template_release.x86_64"
tests: true
artifact: true

steps:
Expand Down Expand Up @@ -174,7 +176,6 @@ jobs:
with:
bin: ${{ matrix.bin }}

# Execute unit tests for the editor
- name: Unit tests
if: ${{ matrix.tests }}
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/macos_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ jobs:
- name: Template (target=template_release)
cache-name: macos-template
target: template_release
tests: false
sconsflags: debug_symbols=no
tests: true
sconsflags: debug_symbols=no tests=yes
bin: "./bin/godot.macos.template_release.universal"

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -84,7 +85,6 @@ jobs:
with:
name: ${{ matrix.cache-name }}

# Execute unit tests for the editor
- name: Unit tests
if: ${{ matrix.tests }}
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/windows_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ jobs:
- name: Template (target=template_release)
cache-name: windows-template
target: template_release
tests: false
sconsflags: debug_symbols=no
tests: true
sconsflags: debug_symbols=no tests=yes
bin: "./bin/godot.windows.template_release.x86_64.console.exe"

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -91,7 +92,6 @@ jobs:
with:
name: ${{ matrix.cache-name }}

# Execute unit tests for the editor
- name: Unit tests
if: ${{ matrix.tests }}
run: |
Expand Down
3 changes: 3 additions & 0 deletions scene/gui/line_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2589,7 +2589,10 @@ void LineEdit::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_secret_character", "character"), &LineEdit::set_secret_character);
ClassDB::bind_method(D_METHOD("get_secret_character"), &LineEdit::get_secret_character);
ClassDB::bind_method(D_METHOD("menu_option", "option"), &LineEdit::menu_option);
// TODO: Properly handle popups when advanced GUI is disabled.
#ifndef ADVANCED_GUI_DISABLED
ClassDB::bind_method(D_METHOD("get_menu"), &LineEdit::get_menu);
#endif // ADVANCED_GUI_DISABLED
ClassDB::bind_method(D_METHOD("is_menu_visible"), &LineEdit::is_menu_visible);
ClassDB::bind_method(D_METHOD("set_context_menu_enabled", "enable"), &LineEdit::set_context_menu_enabled);
ClassDB::bind_method(D_METHOD("is_context_menu_enabled"), &LineEdit::is_context_menu_enabled);
Expand Down
3 changes: 3 additions & 0 deletions scene/gui/menu_bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,10 @@ void MenuBar::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_menu_hidden", "menu", "hidden"), &MenuBar::set_menu_hidden);
ClassDB::bind_method(D_METHOD("is_menu_hidden", "menu"), &MenuBar::is_menu_hidden);

// TODO: Properly handle popups when advanced GUI is disabled.
#ifndef ADVANCED_GUI_DISABLED
ClassDB::bind_method(D_METHOD("get_menu_popup", "menu"), &MenuBar::get_menu_popup);
#endif // ADVANCED_GUI_DISABLED

ADD_PROPERTY(PropertyInfo(Variant::BOOL, "flat"), "set_flat", "is_flat");
ADD_PROPERTY(PropertyInfo(Variant::INT, "start_index"), "set_start_index", "get_start_index");
Expand Down
3 changes: 3 additions & 0 deletions scene/gui/menu_button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@ bool MenuButton::_get(const StringName &p_name, Variant &r_ret) const {
}

void MenuButton::_bind_methods() {
// TODO: Properly handle popups when advanced GUI is disabled.
#ifndef ADVANCED_GUI_DISABLED
ClassDB::bind_method(D_METHOD("get_popup"), &MenuButton::get_popup);
#endif // ADVANCED_GUI_DISABLED
ClassDB::bind_method(D_METHOD("show_popup"), &MenuButton::show_popup);
ClassDB::bind_method(D_METHOD("set_switch_on_hover", "enable"), &MenuButton::set_switch_on_hover);
ClassDB::bind_method(D_METHOD("is_switch_on_hover"), &MenuButton::is_switch_on_hover);
Expand Down
4 changes: 4 additions & 0 deletions tests/core/io/test_http_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

#include "tests/test_macros.h"

#include "modules/modules_enabled.gen.h"

namespace TestHTTPClient {

TEST_CASE("[HTTPClient] Instantiation") {
Expand Down Expand Up @@ -90,6 +92,7 @@ TEST_CASE("[HTTPClient] verify_headers") {
ERR_PRINT_ON;
}

#if defined(MODULE_MBEDTLS_ENABLED) || defined(WEB_ENABLED)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't expect tests to be run on web (I don't even know how to do that) but the dedicated test is because web has its own http client, so just made this change for completeness

TEST_CASE("[HTTPClient] connect_to_host") {
Ref<HTTPClient> client = HTTPClient::create();
String host = "https://www.example.com";
Expand All @@ -100,6 +103,7 @@ TEST_CASE("[HTTPClient] connect_to_host") {
Error err = client->connect_to_host(host, port, tls_options);
CHECK_MESSAGE(err == OK, "Expected OK for successful connection");
}
#endif // MODULE_MBEDTLS_ENABLED || WEB_ENABLED

} // namespace TestHTTPClient

Expand Down
10 changes: 10 additions & 0 deletions tests/core/io/test_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#include "tests/test_utils.h"
#include "thirdparty/doctest/doctest.h"

#include "modules/modules_enabled.gen.h"

namespace TestImage {

TEST_CASE("[Image] Instantiation") {
Expand Down Expand Up @@ -107,6 +109,7 @@ TEST_CASE("[Image] Saving and loading") {
image->get_data() == image_load->get_data(),
"The loaded image should have the same data as the one that got saved.");

#ifdef MODULE_BMP_ENABLED
// Load BMP
Ref<Image> image_bmp = memnew(Image());
Ref<FileAccess> f_bmp = FileAccess::open(TestUtils::get_data_path("images/icon.bmp"), FileAccess::READ, &err);
Expand All @@ -117,7 +120,9 @@ TEST_CASE("[Image] Saving and loading") {
CHECK_MESSAGE(
image_bmp->load_bmp_from_buffer(data_bmp) == OK,
"The BMP image should load successfully.");
#endif // MODULE_BMP_ENABLED

#ifdef MODULE_JPG_ENABLED
// Load JPG
Ref<Image> image_jpg = memnew(Image());
Ref<FileAccess> f_jpg = FileAccess::open(TestUtils::get_data_path("images/icon.jpg"), FileAccess::READ, &err);
Expand All @@ -128,7 +133,9 @@ TEST_CASE("[Image] Saving and loading") {
CHECK_MESSAGE(
image_jpg->load_jpg_from_buffer(data_jpg) == OK,
"The JPG image should load successfully.");
#endif // MODULE_JPG_ENABLED

#ifdef MODULE_WEBP_ENABLED
// Load WebP
Ref<Image> image_webp = memnew(Image());
Ref<FileAccess> f_webp = FileAccess::open(TestUtils::get_data_path("images/icon.webp"), FileAccess::READ, &err);
Expand All @@ -139,6 +146,7 @@ TEST_CASE("[Image] Saving and loading") {
CHECK_MESSAGE(
image_webp->load_webp_from_buffer(data_webp) == OK,
"The WebP image should load successfully.");
#endif // MODULE_WEBP_ENABLED

// Load PNG
Ref<Image> image_png = memnew(Image());
Expand All @@ -151,6 +159,7 @@ TEST_CASE("[Image] Saving and loading") {
image_png->load_png_from_buffer(data_png) == OK,
"The PNG image should load successfully.");

#ifdef MODULE_TGA_ENABLED
// Load TGA
Ref<Image> image_tga = memnew(Image());
Ref<FileAccess> f_tga = FileAccess::open(TestUtils::get_data_path("images/icon.tga"), FileAccess::READ, &err);
Expand All @@ -161,6 +170,7 @@ TEST_CASE("[Image] Saving and loading") {
CHECK_MESSAGE(
image_tga->load_tga_from_buffer(data_tga) == OK,
"The TGA image should load successfully.");
#endif // MODULE_TGA_ENABLED
}

TEST_CASE("[Image] Basic getters") {
Expand Down
2 changes: 1 addition & 1 deletion tests/scene/test_graph_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ TEST_CASE("[GraphNode][SceneTree]") {
SUBCASE("[GraphNode] Graph Node only child on delete should not cause error.") {
// Setup.
GraphNode *test_node = memnew(GraphNode);
test_child->set_name("Graph Node");
test_node->set_name("Graph Node");
Control *test_child = memnew(Control);
test_child->set_name("child");
test_node->add_child(test_child);
Expand Down
23 changes: 16 additions & 7 deletions tests/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

#include "test_main.h"

#include "modules/modules_enabled.gen.h"

#ifdef TOOLS_ENABLED
#include "editor/editor_paths.h"
#include "editor/editor_settings.h"
Expand Down Expand Up @@ -103,8 +105,6 @@
#include "tests/scene/test_audio_stream_wav.h"
#include "tests/scene/test_bit_map.h"
#include "tests/scene/test_camera_2d.h"
#include "tests/scene/test_code_edit.h"
#include "tests/scene/test_color_picker.h"
#include "tests/scene/test_control.h"
#include "tests/scene/test_curve.h"
#include "tests/scene/test_curve_2d.h"
Expand All @@ -118,7 +118,6 @@
#include "tests/scene/test_packed_scene.h"
#include "tests/scene/test_path_2d.h"
#include "tests/scene/test_sprite_frames.h"
#include "tests/scene/test_text_edit.h"
#include "tests/scene/test_theme.h"
#include "tests/scene/test_timer.h"
#include "tests/scene/test_viewport.h"
Expand All @@ -128,19 +127,29 @@
#include "tests/servers/test_text_server.h"
#include "tests/test_validate_testing.h"

#ifndef ADVANCED_GUI_DISABLED
#include "tests/scene/test_code_edit.h"
#include "tests/scene/test_color_picker.h"
#include "tests/scene/test_graph_node.h"
#include "tests/scene/test_text_edit.h"
#endif // ADVANCED_GUI_DISABLED

#ifndef _3D_DISABLED
#include "tests/scene/test_arraymesh.h"
#include "tests/scene/test_camera_3d.h"
#ifdef MODULE_NAVIGATION_ENABLED
#include "tests/scene/test_navigation_agent_2d.h"
#include "tests/scene/test_navigation_agent_3d.h"
#include "tests/scene/test_navigation_obstacle_2d.h"
#include "tests/scene/test_navigation_obstacle_3d.h"
#include "tests/scene/test_navigation_region_2d.h"
#include "tests/scene/test_navigation_region_3d.h"
#include "tests/scene/test_path_3d.h"
#include "tests/scene/test_primitives.h"
#include "tests/servers/test_navigation_server_2d.h"
#include "tests/servers/test_navigation_server_3d.h"
#endif // MODULE_NAVIGATION_ENABLED
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the nav tests could be run without the module theoretically to confirm default values, and that could be a future improvement to put some of the test code in those files in their own #ifdef MODULE_NAVIGATION_ENABLED blocks to split it off, but kept it simple here, I think we can trust that the basic default stuff of the navigation "works" when navigation is disabled


#include "tests/scene/test_arraymesh.h"
#include "tests/scene/test_camera_3d.h"
#include "tests/scene/test_path_3d.h"
#include "tests/scene/test_primitives.h"
#endif // _3D_DISABLED

#include "modules/modules_tests.gen.h"
Expand Down
Loading