make tests auto terminate

This commit is contained in:
Green Sky 2022-11-07 00:52:37 +01:00 committed by Erik Scholz
parent 5ed71690c7
commit 9f6e9defb0
22 changed files with 162 additions and 8 deletions

View File

@ -39,9 +39,7 @@ jobs:
DISPLAY: :0 DISPLAY: :0
run: | run: |
sudo Xorg :0 -config ${{github.workspace}}/.github/workflows/x/dummy-1920x1080.conf -noautoBindGPU & sudo Xorg :0 -config ${{github.workspace}}/.github/workflows/x/dummy-1920x1080.conf -noautoBindGPU &
#export DISPLAY=:4
sleep 20s sleep 20s
#bin/sdl_service_test
ctest --output-on-failure --timeout 20 ctest --output-on-failure --timeout 20
sudo pkill -15 Xorg sudo pkill -15 Xorg

View File

@ -29,6 +29,7 @@ set(CPP_FILES
soloud/src/backend/alsa/soloud_alsa.cpp soloud/src/backend/alsa/soloud_alsa.cpp
soloud/src/backend/coreaudio/soloud_coreaudio.cpp soloud/src/backend/coreaudio/soloud_coreaudio.cpp
soloud/src/backend/null/soloud_null.cpp soloud/src/backend/null/soloud_null.cpp
soloud/src/backend/nosound/soloud_nosound.cpp
#soloud/src/backend/openal/soloud_openal.cpp #soloud/src/backend/openal/soloud_openal.cpp
#soloud/src/backend/openal/soloud_openal_dll.c #soloud/src/backend/openal/soloud_openal_dll.c
soloud/src/backend/opensles/soloud_opensles.cpp soloud/src/backend/opensles/soloud_opensles.cpp
@ -156,6 +157,7 @@ set(HPP_FILES
add_library(soloud ${CPP_FILES} ${HPP_FILES}) add_library(soloud ${CPP_FILES} ${HPP_FILES})
target_compile_definitions(soloud PRIVATE WITH_NULL) target_compile_definitions(soloud PRIVATE WITH_NULL)
target_compile_definitions(soloud PRIVATE WITH_NOSOUND)
#target_compile_definitions(soloud PRIVATE WITH_SDL2) #target_compile_definitions(soloud PRIVATE WITH_SDL2)
target_compile_definitions(soloud PRIVATE WITH_SDL2_STATIC) target_compile_definitions(soloud PRIVATE WITH_SDL2_STATIC)

View File

@ -0,0 +1,43 @@
#pragma once
#include <mm/engine.hpp>
namespace MM::Services {
// counts X times and stops engine
// useful for automatic testing
class CountDown : public Service {
public:
CountDown(int64_t start) : _counter(start) {}
const char* name(void) override { return "CountDown"; }
bool enable(Engine&, std::vector<UpdateStrategies::TaskInfo>& task_array) override {
// add task
task_array.push_back(
UpdateStrategies::TaskInfo{"CountDown::tick"}
.phase(UpdateStrategies::update_phase_t::POST)
.fn([this](Engine& e) { this->tick(e); })
);
return true;
}
void disable(Engine&) override {}
private:
void tick(Engine& engine) {
_counter--;
if (_counter == 0) {
engine.stop();
}
}
private:
int64_t _counter = 0;
};
} // MM::Services

View File

@ -7,6 +7,7 @@
#include <mm/services/imgui_s.hpp> #include <mm/services/imgui_s.hpp>
#include <mm/services/imgui_menu_bar.hpp> #include <mm/services/imgui_menu_bar.hpp>
#include <mm/services/engine_tools.hpp> #include <mm/services/engine_tools.hpp>
#include <mm/services/count_down.hpp>
#include <mm/services/opengl_renderer.hpp> #include <mm/services/opengl_renderer.hpp>
#include <mm/opengl/render_tasks/imgui.hpp> #include <mm/opengl/render_tasks/imgui.hpp>
@ -38,10 +39,14 @@ TEST(imgui_scene_tools, it) {
rs.addRenderTask<MM::OpenGL::RenderTasks::ImGuiRT>(engine); rs.addRenderTask<MM::OpenGL::RenderTasks::ImGuiRT>(engine);
#ifdef MM_AUTOTEST
engine.addService<MM::Services::CountDown>(50); // 50 frames
ASSERT_TRUE(engine.enableService<MM::Services::CountDown>());
#endif
engine.run(); engine.run();
sdl_ss.destroyWindow(); sdl_ss.destroyWindow();
} }
int main(int argc, char** argv) { int main(int argc, char** argv) {

View File

@ -1,4 +1,3 @@
#include "nlohmann/json_fwd.hpp"
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <mm/engine.hpp> #include <mm/engine.hpp>
@ -8,6 +7,7 @@
#include <mm/services/filesystem.hpp> #include <mm/services/filesystem.hpp>
#include <mm/services/opengl_renderer.hpp> #include <mm/services/opengl_renderer.hpp>
#include <mm/services/imgui_s.hpp> #include <mm/services/imgui_s.hpp>
#include <mm/services/count_down.hpp>
#include <mm/opengl/render_tasks/imgui.hpp> #include <mm/opengl/render_tasks/imgui.hpp>
@ -183,9 +183,13 @@ TEST(imgui_json_editor, basic) {
}; };
engine.addService<TestWindow>(); // engine dtr ????????????????? engine.addService<TestWindow>(); // engine dtr ?????????????????
ASSERT_TRUE(engine.enableService<TestWindow>()); ASSERT_TRUE(engine.enableService<TestWindow>());
#ifdef MM_AUTOTEST
engine.addService<MM::Services::CountDown>(50); // 50 frames
ASSERT_TRUE(engine.enableService<MM::Services::CountDown>());
#endif
engine.run(); engine.run();
sdl_ss.destroyWindow(); sdl_ss.destroyWindow();

View File

@ -10,6 +10,7 @@
#include <mm/services/imgui_s.hpp> #include <mm/services/imgui_s.hpp>
#include <mm/services/imgui_menu_bar.hpp> #include <mm/services/imgui_menu_bar.hpp>
#include <mm/services/engine_tools.hpp> #include <mm/services/engine_tools.hpp>
#include <mm/services/count_down.hpp>
#include <mm/services/opengl_renderer.hpp> #include <mm/services/opengl_renderer.hpp>
#include <mm/opengl/render_tasks/imgui.hpp> #include <mm/opengl/render_tasks/imgui.hpp>
@ -54,6 +55,11 @@ TEST(imgui_scene_tools, it) {
ASSERT_TRUE(engine.enableService<MM::Services::ImGuiSceneToolsService>()); ASSERT_TRUE(engine.enableService<MM::Services::ImGuiSceneToolsService>());
#ifdef MM_AUTOTEST
engine.addService<MM::Services::CountDown>(50); // 50 frames
ASSERT_TRUE(engine.enableService<MM::Services::CountDown>());
#endif
rs.addRenderTask<MM::OpenGL::RenderTasks::ImGuiRT>(engine); rs.addRenderTask<MM::OpenGL::RenderTasks::ImGuiRT>(engine);
engine.run(); engine.run();

View File

@ -10,6 +10,7 @@
#include <mm/services/imgui_s.hpp> #include <mm/services/imgui_s.hpp>
#include <mm/services/imgui_menu_bar.hpp> #include <mm/services/imgui_menu_bar.hpp>
#include <mm/services/engine_tools.hpp> #include <mm/services/engine_tools.hpp>
#include <mm/services/count_down.hpp>
#include <mm/opengl/render_tasks/imgui.hpp> #include <mm/opengl/render_tasks/imgui.hpp>
@ -171,6 +172,11 @@ TEST(imgui_sound, basic) {
engine.addService<ImGuiSpeechy>(); engine.addService<ImGuiSpeechy>();
ASSERT_TRUE(engine.enableService<ImGuiSpeechy>()); ASSERT_TRUE(engine.enableService<ImGuiSpeechy>());
#ifdef MM_AUTOTEST
engine.addService<MM::Services::CountDown>(50); // 50 frames
ASSERT_TRUE(engine.enableService<MM::Services::CountDown>());
#endif
engine.run(); engine.run();
sdl_ss.destroyWindow(); sdl_ss.destroyWindow();

View File

@ -1,4 +1,3 @@
#include <functional>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <mm/resource_manager.hpp> #include <mm/resource_manager.hpp>
@ -11,6 +10,7 @@
#include <mm/services/imgui_s.hpp> #include <mm/services/imgui_s.hpp>
#include <mm/services/imgui_menu_bar.hpp> #include <mm/services/imgui_menu_bar.hpp>
#include <mm/services/engine_tools.hpp> #include <mm/services/engine_tools.hpp>
#include <mm/services/count_down.hpp>
#include <mm/opengl/render_tasks/imgui.hpp> #include <mm/opengl/render_tasks/imgui.hpp>
@ -19,6 +19,8 @@
#include <mm/imgui/file_text_editor.hpp> #include <mm/imgui/file_text_editor.hpp>
#include <mm/imgui/file_shader_editor.hpp> #include <mm/imgui/file_shader_editor.hpp>
#include <functional>
static char* argv0; static char* argv0;
using namespace entt::literals; using namespace entt::literals;
@ -72,6 +74,11 @@ TEST(imgui_text_edit, it) {
}); });
ASSERT_TRUE(engine.enableService<TemplateUpdateMainService>()); ASSERT_TRUE(engine.enableService<TemplateUpdateMainService>());
#ifdef MM_AUTOTEST
engine.addService<MM::Services::CountDown>(50); // 50 frames
ASSERT_TRUE(engine.enableService<MM::Services::CountDown>());
#endif
engine.run(); engine.run();
// TODO: clear asset manager // TODO: clear asset manager
@ -112,6 +119,12 @@ TEST(imgui_text_edit, shader) {
}); });
ASSERT_TRUE(engine.enableService<TemplateUpdateMainService>()); ASSERT_TRUE(engine.enableService<TemplateUpdateMainService>());
#ifdef MM_AUTOTEST
engine.addService<MM::Services::CountDown>(50); // 50 frames
ASSERT_TRUE(engine.enableService<MM::Services::CountDown>());
#endif
// TODO: fix non existant files
fte.open("shader/quad_renderer/vert.glsl"); fte.open("shader/quad_renderer/vert.glsl");
fse.open("shader/quad_renderer/frag.glsl"); fse.open("shader/quad_renderer/frag.glsl");

View File

@ -7,6 +7,7 @@
#include <mm/services/filesystem.hpp> #include <mm/services/filesystem.hpp>
#include <mm/services/opengl_renderer.hpp> #include <mm/services/opengl_renderer.hpp>
#include <mm/services/imgui_s.hpp> #include <mm/services/imgui_s.hpp>
#include <mm/services/count_down.hpp>
#include <mm/opengl/render_tasks/imgui.hpp> #include <mm/opengl/render_tasks/imgui.hpp>
@ -68,6 +69,11 @@ TEST(imgui_widgets, basic) {
engine.addService<TestWindow>(); engine.addService<TestWindow>();
ASSERT_TRUE(engine.enableService<TestWindow>()); ASSERT_TRUE(engine.enableService<TestWindow>());
#ifdef MM_AUTOTEST
engine.addService<MM::Services::CountDown>(50); // 50 frames
ASSERT_TRUE(engine.enableService<MM::Services::CountDown>());
#endif
engine.run(); engine.run();
sdl_ss.destroyWindow(); sdl_ss.destroyWindow();

View File

@ -29,5 +29,7 @@ target_link_libraries(input_service_visualizer_test
gtest_main gtest_main
) )
if(NOT MM_AUTOTEST)
add_test(NAME input_service_visualizer_test COMMAND input_service_visualizer_test) add_test(NAME input_service_visualizer_test COMMAND input_service_visualizer_test)
endif()

View File

@ -6,6 +6,7 @@
#include <mm/services/sdl_service.hpp> #include <mm/services/sdl_service.hpp>
#include <mm/services/organizer_scene.hpp> #include <mm/services/organizer_scene.hpp>
#include <mm/services/opengl_renderer.hpp> #include <mm/services/opengl_renderer.hpp>
#include <mm/services/count_down.hpp>
#include <entt/entity/registry.hpp> #include <entt/entity/registry.hpp>
#include <entt/entity/organizer.hpp> #include <entt/entity/organizer.hpp>
@ -68,6 +69,11 @@ TEST(batched_spritesheet_render_task, it) {
auto& rs = engine.addService<MM::Services::OpenGLRenderer>(); auto& rs = engine.addService<MM::Services::OpenGLRenderer>();
ASSERT_TRUE(engine.enableService<MM::Services::OpenGLRenderer>()); ASSERT_TRUE(engine.enableService<MM::Services::OpenGLRenderer>());
#ifdef MM_AUTOTEST
engine.addService<MM::Services::CountDown>(50); // 50 frames
ASSERT_TRUE(engine.enableService<MM::Services::CountDown>());
#endif
auto& cam = scene.ctx().emplace<MM::OpenGL::Camera3D>(); auto& cam = scene.ctx().emplace<MM::OpenGL::Camera3D>();
cam.horizontalViewPortSize = 5; cam.horizontalViewPortSize = 5;
cam.setOrthographic(); cam.setOrthographic();

View File

@ -7,6 +7,7 @@
#include <mm/services/organizer_scene.hpp> #include <mm/services/organizer_scene.hpp>
#include <mm/services/opengl_renderer.hpp> #include <mm/services/opengl_renderer.hpp>
#include <mm/services/imgui_s.hpp> #include <mm/services/imgui_s.hpp>
#include <mm/services/count_down.hpp>
#include <entt/entity/registry.hpp> #include <entt/entity/registry.hpp>
#include <entt/entity/organizer.hpp> #include <entt/entity/organizer.hpp>
@ -64,6 +65,11 @@ TEST(blur_render_task, it) {
auto& rs = engine.addService<MM::Services::OpenGLRenderer>(); auto& rs = engine.addService<MM::Services::OpenGLRenderer>();
ASSERT_TRUE(engine.enableService<MM::Services::OpenGLRenderer>()); ASSERT_TRUE(engine.enableService<MM::Services::OpenGLRenderer>());
#ifdef MM_AUTOTEST
engine.addService<MM::Services::CountDown>(50); // 50 frames
ASSERT_TRUE(engine.enableService<MM::Services::CountDown>());
#endif
//rs.addRenderTask<MM::OpenGL::RenderTasks::SimpleRect>(engine).target_fbo = "game_view"; //rs.addRenderTask<MM::OpenGL::RenderTasks::SimpleRect>(engine).target_fbo = "game_view";
rs.addRenderTask<MM::OpenGL::RenderTasks::Clear>(engine).target_fbo = "blur_io"; rs.addRenderTask<MM::OpenGL::RenderTasks::Clear>(engine).target_fbo = "blur_io";

View File

@ -6,6 +6,7 @@
#include <mm/services/sdl_service.hpp> #include <mm/services/sdl_service.hpp>
#include <mm/services/organizer_scene.hpp> #include <mm/services/organizer_scene.hpp>
#include <mm/services/opengl_renderer.hpp> #include <mm/services/opengl_renderer.hpp>
#include <mm/services/count_down.hpp>
#include <entt/entity/registry.hpp> #include <entt/entity/registry.hpp>
#include <entt/entity/organizer.hpp> #include <entt/entity/organizer.hpp>
@ -39,6 +40,11 @@ TEST(fast_sky_render_task, it) {
auto& rs = engine.addService<MM::Services::OpenGLRenderer>(); auto& rs = engine.addService<MM::Services::OpenGLRenderer>();
ASSERT_TRUE(engine.enableService<MM::Services::OpenGLRenderer>()); ASSERT_TRUE(engine.enableService<MM::Services::OpenGLRenderer>());
#ifdef MM_AUTOTEST
engine.addService<MM::Services::CountDown>(50); // 50 frames
ASSERT_TRUE(engine.enableService<MM::Services::CountDown>());
#endif
rs.addRenderTask<MM::OpenGL::RenderTasks::FastSky>(engine); rs.addRenderTask<MM::OpenGL::RenderTasks::FastSky>(engine);
// setup systems // setup systems

View File

@ -6,6 +6,7 @@
#include <mm/services/sdl_service.hpp> #include <mm/services/sdl_service.hpp>
#include <mm/services/organizer_scene.hpp> #include <mm/services/organizer_scene.hpp>
#include <mm/services/opengl_renderer.hpp> #include <mm/services/opengl_renderer.hpp>
#include <mm/services/count_down.hpp>
#include <entt/entity/registry.hpp> #include <entt/entity/registry.hpp>
#include <entt/entity/organizer.hpp> #include <entt/entity/organizer.hpp>
@ -149,6 +150,11 @@ TEST(hdr_bloom_pipeline, it) {
auto& rs = engine.addService<MM::Services::OpenGLRenderer>(); auto& rs = engine.addService<MM::Services::OpenGLRenderer>();
ASSERT_TRUE(engine.enableService<MM::Services::OpenGLRenderer>()); ASSERT_TRUE(engine.enableService<MM::Services::OpenGLRenderer>());
#ifdef MM_AUTOTEST
engine.addService<MM::Services::CountDown>(50); // 50 frames
ASSERT_TRUE(engine.enableService<MM::Services::CountDown>());
#endif
{ // setup rendering { // setup rendering
// TODO: split vertically // TODO: split vertically
setup_textures(engine); setup_textures(engine);

View File

@ -6,6 +6,7 @@
#include <mm/services/opengl_renderer.hpp> #include <mm/services/opengl_renderer.hpp>
#include <mm/services/imgui_s.hpp> #include <mm/services/imgui_s.hpp>
#include <mm/opengl/render_tasks/imgui.hpp> #include <mm/opengl/render_tasks/imgui.hpp>
#include <mm/services/count_down.hpp>
#include <imgui/imgui.h> #include <imgui/imgui.h>
@ -43,6 +44,11 @@ TEST(imgui_render_task, demowindow) {
rs.addRenderTask<MM::OpenGL::RenderTasks::ImGuiRT>(engine); rs.addRenderTask<MM::OpenGL::RenderTasks::ImGuiRT>(engine);
#ifdef MM_AUTOTEST
engine.addService<MM::Services::CountDown>(50); // 50 frames
ASSERT_TRUE(engine.enableService<MM::Services::CountDown>());
#endif
engine.run(); engine.run();
} }

View File

@ -6,6 +6,7 @@
#include <mm/services/sdl_service.hpp> #include <mm/services/sdl_service.hpp>
#include <mm/services/organizer_scene.hpp> #include <mm/services/organizer_scene.hpp>
#include <mm/services/opengl_renderer.hpp> #include <mm/services/opengl_renderer.hpp>
#include <mm/services/count_down.hpp>
#include <mm/fs_const_archiver.hpp> #include <mm/fs_const_archiver.hpp>
@ -259,6 +260,11 @@ TEST(lite_particles2d, it) {
auto& rs = engine.addService<MM::Services::OpenGLRenderer>(); auto& rs = engine.addService<MM::Services::OpenGLRenderer>();
ASSERT_TRUE(engine.enableService<MM::Services::OpenGLRenderer>()); ASSERT_TRUE(engine.enableService<MM::Services::OpenGLRenderer>());
#ifdef MM_AUTOTEST
engine.addService<MM::Services::CountDown>(50); // 50 frames
ASSERT_TRUE(engine.enableService<MM::Services::CountDown>());
#endif
// load particle types // load particle types
// before addRenderTask<LiteParticle2D> // before addRenderTask<LiteParticle2D>
// OR // OR

View File

@ -6,6 +6,7 @@
#include <mm/services/sdl_service.hpp> #include <mm/services/sdl_service.hpp>
#include <mm/services/organizer_scene.hpp> #include <mm/services/organizer_scene.hpp>
#include <mm/services/opengl_renderer.hpp> #include <mm/services/opengl_renderer.hpp>
#include <mm/services/count_down.hpp>
#include <entt/entity/registry.hpp> #include <entt/entity/registry.hpp>
#include <entt/entity/organizer.hpp> #include <entt/entity/organizer.hpp>
@ -49,6 +50,11 @@ TEST(simple_rect_render_task, it) {
auto& rs = engine.addService<MM::Services::OpenGLRenderer>(); auto& rs = engine.addService<MM::Services::OpenGLRenderer>();
ASSERT_TRUE(engine.enableService<MM::Services::OpenGLRenderer>()); ASSERT_TRUE(engine.enableService<MM::Services::OpenGLRenderer>());
#ifdef MM_AUTOTEST
engine.addService<MM::Services::CountDown>(50); // 50 frames
ASSERT_TRUE(engine.enableService<MM::Services::CountDown>());
#endif
rs.addRenderTask<MM::OpenGL::RenderTasks::SimpleRect>(engine); rs.addRenderTask<MM::OpenGL::RenderTasks::SimpleRect>(engine);
scene.on_construct<MM::Components::Position2D>().connect<&entt::registry::emplace_or_replace<MM::Components::Position2D_ZOffset>>(); scene.on_construct<MM::Components::Position2D>().connect<&entt::registry::emplace_or_replace<MM::Components::Position2D_ZOffset>>();

View File

@ -6,6 +6,7 @@
#include <mm/services/sdl_service.hpp> #include <mm/services/sdl_service.hpp>
#include <mm/services/organizer_scene.hpp> #include <mm/services/organizer_scene.hpp>
#include <mm/services/opengl_renderer.hpp> #include <mm/services/opengl_renderer.hpp>
#include <mm/services/count_down.hpp>
#include <entt/entity/registry.hpp> #include <entt/entity/registry.hpp>
#include <entt/entity/organizer.hpp> #include <entt/entity/organizer.hpp>
@ -52,6 +53,11 @@ TEST(simple_sprite_render_task, it) {
auto& rs = engine.addService<MM::Services::OpenGLRenderer>(); auto& rs = engine.addService<MM::Services::OpenGLRenderer>();
ASSERT_TRUE(engine.enableService<MM::Services::OpenGLRenderer>()); ASSERT_TRUE(engine.enableService<MM::Services::OpenGLRenderer>());
#ifdef MM_AUTOTEST
engine.addService<MM::Services::CountDown>(50); // 50 frames
ASSERT_TRUE(engine.enableService<MM::Services::CountDown>());
#endif
rs.addRenderTask<MM::OpenGL::RenderTasks::SimpleSprite>(engine); rs.addRenderTask<MM::OpenGL::RenderTasks::SimpleSprite>(engine);
scene.on_construct<MM::Components::Position2D>().connect<&entt::registry::emplace_or_replace<MM::Components::Position2D_ZOffset>>(); scene.on_construct<MM::Components::Position2D>().connect<&entt::registry::emplace_or_replace<MM::Components::Position2D_ZOffset>>();

View File

@ -6,6 +6,7 @@
#include <mm/services/sdl_service.hpp> #include <mm/services/sdl_service.hpp>
#include <mm/services/organizer_scene.hpp> #include <mm/services/organizer_scene.hpp>
#include <mm/services/opengl_renderer.hpp> #include <mm/services/opengl_renderer.hpp>
#include <mm/services/count_down.hpp>
#include <entt/entity/registry.hpp> #include <entt/entity/registry.hpp>
#include <entt/entity/organizer.hpp> #include <entt/entity/organizer.hpp>
@ -64,6 +65,11 @@ TEST(simple_spritesheet_render_task, it) {
auto& rs = engine.addService<MM::Services::OpenGLRenderer>(); auto& rs = engine.addService<MM::Services::OpenGLRenderer>();
ASSERT_TRUE(engine.enableService<MM::Services::OpenGLRenderer>()); ASSERT_TRUE(engine.enableService<MM::Services::OpenGLRenderer>());
#ifdef MM_AUTOTEST
engine.addService<MM::Services::CountDown>(50); // 50 frames
ASSERT_TRUE(engine.enableService<MM::Services::CountDown>());
#endif
auto& cam = scene.ctx().emplace<MM::OpenGL::Camera3D>(); auto& cam = scene.ctx().emplace<MM::OpenGL::Camera3D>();
cam.horizontalViewPortSize = 5; cam.horizontalViewPortSize = 5;
cam.setOrthographic(); cam.setOrthographic();

View File

@ -6,6 +6,7 @@
#include <mm/services/sdl_service.hpp> #include <mm/services/sdl_service.hpp>
#include <mm/services/organizer_scene.hpp> #include <mm/services/organizer_scene.hpp>
#include <mm/services/opengl_renderer.hpp> #include <mm/services/opengl_renderer.hpp>
#include <mm/services/count_down.hpp>
#include <entt/entity/registry.hpp> #include <entt/entity/registry.hpp>
#include <entt/entity/organizer.hpp> #include <entt/entity/organizer.hpp>
@ -51,6 +52,11 @@ TEST(tilemap_render_task_test, it) {
auto& rs = engine.addService<MM::Services::OpenGLRenderer>(); auto& rs = engine.addService<MM::Services::OpenGLRenderer>();
ASSERT_TRUE(engine.enableService<MM::Services::OpenGLRenderer>()); ASSERT_TRUE(engine.enableService<MM::Services::OpenGLRenderer>());
#ifdef MM_AUTOTEST
engine.addService<MM::Services::CountDown>(50); // 50 frames
ASSERT_TRUE(engine.enableService<MM::Services::CountDown>());
#endif
rs.addRenderTask<MM::OpenGL::RenderTasks::Tilemap>(engine); rs.addRenderTask<MM::OpenGL::RenderTasks::Tilemap>(engine);
scene.on_construct<MM::Components::Position2D>().connect<&entt::registry::emplace_or_replace<MM::Components::Position2D_ZOffset>>(); scene.on_construct<MM::Components::Position2D>().connect<&entt::registry::emplace_or_replace<MM::Components::Position2D_ZOffset>>();

View File

@ -5,6 +5,8 @@
#include <mm/services/sdl_service.hpp> #include <mm/services/sdl_service.hpp>
#include <mm/services/simple_sdl_renderer.hpp> #include <mm/services/simple_sdl_renderer.hpp>
#include <mm/services/count_down.hpp>
TEST(simple_sdl_renderer, basic) { TEST(simple_sdl_renderer, basic) {
srand(1); srand(1);
MM::Engine engine; MM::Engine engine;
@ -33,6 +35,11 @@ TEST(simple_sdl_renderer, basic) {
} }
); );
#ifdef MM_AUTOTEST
engine.addService<MM::Services::CountDown>(50); // 50 frames
ASSERT_TRUE(engine.enableService<MM::Services::CountDown>());
#endif
engine.run(); engine.run();
} }

View File

@ -5,6 +5,7 @@ if(NOT MM_INTERNAL_OPTIONS)
# MM options # MM options
option(BUILD_TESTING "Enable testing with ctest." OFF) option(BUILD_TESTING "Enable testing with ctest." OFF)
option(MM_AUTOTEST "Quits tests after some frames. for ci." ON)
option(MM_HEADLESS "Headless mode for MM, disables all kind of rendering stuff." OFF) option(MM_HEADLESS "Headless mode for MM, disables all kind of rendering stuff." OFF)
option(MM_NETWORKING "control networking implementations for MM." OFF) option(MM_NETWORKING "control networking implementations for MM." OFF)
@ -25,6 +26,7 @@ if(NOT MM_INTERNAL_OPTIONS)
endif() endif()
endmacro() endmacro()
gen_compile_definition(MM_AUTOTEST)
gen_compile_definition(MM_HEADLESS) gen_compile_definition(MM_HEADLESS)
gen_compile_definition(MM_NETWORKING) gen_compile_definition(MM_NETWORKING)
gen_compile_definition(MM_OPENGL_3) gen_compile_definition(MM_OPENGL_3)