start building foundation for exe test runner

This commit is contained in:
Tuomas Katajisto 2026-03-24 22:36:32 +02:00
parent c672990e27
commit 9f647ea5c5
11 changed files with 101 additions and 52 deletions

View File

@ -11,7 +11,8 @@ Trueno_Build_Options :: struct {
demo_build : bool;
test_engine : bool;
test_game : bool;
short_tests : bool;
test_exe_engine : bool;
test_exe_game : bool;
}
build_options_from_args :: (args: []string) -> Trueno_Build_Options {
@ -36,8 +37,10 @@ build_options_from_args :: (args: []string) -> Trueno_Build_Options {
opts.test_game = true;
case "test_engine";
opts.test_engine = true;
case "test_short";
opts.short_tests = true;
case "test_exe_game";
opts.test_exe_game = true;
case "test_exe_engine";
opts.test_exe_engine = true;
}
}

View File

@ -1,40 +0,0 @@
#scope_file
char_pos : Vector3 = .{0.0, 0.0, 0.0};
rotation : float = 0.0;
cam : Camera = .{
far = 2000.0,
near = 1.0,
target = .{0.0, 0.0, 0.0},
position = .{5.0, 5.0, 0.0}
};
#scope_export
game_engine_config :: () {
}
game_init :: () {
}
game_ui :: () {
}
game_tick :: () {
speed := 0.1;
if input_button_states[#char "W"] & .DOWN then char_pos += speed * Vector3.{-1.0, 0.0, 0.0};
if input_button_states[#char "S"] & .DOWN then char_pos += speed * Vector3.{1.0, 0.0, 0.0};
if input_button_states[#char "A"] & .DOWN then char_pos += speed * Vector3.{0.0, 0.0, 1.0};
if input_button_states[#char "D"] & .DOWN then char_pos += speed * Vector3.{0.0, 0.0, -1.0};
cam.target = char_pos;
cam.position = char_pos + .{10,5,0};
}
game_draw :: () {
curworld := get_current_world();
if curworld.valid {
create_set_cam_rendering_task(cam, curworld.world.conf.planeHeight);
create_world_rendering_tasks(curworld.world);
}
}

View File

@ -15,7 +15,7 @@ String :: #import "String";
Jaison :: #import "Jaison";
stbi :: #import "stb_image";
#if FLAG_TEST_ENGINE { #load "tests/index.jai"; }
#if (FLAG_TEST_ENGINE || FLAG_TEST_EXE_ENGINE) { #load "tests/index.jai"; }
#load "logging.jai";
#load "pseudophysics/core.jai";
@ -39,7 +39,11 @@ stbi :: #import "stb_image";
#load "settings_menu.jai";
#load "ui/demo.jai";
#load "../game/game.jai";
#if !FLAG_TEST_EXE_ENGINE {
#load "../game/game.jai";
} else {
#load "../test_game/game.jai";
}
last_frame_time : float64; // timestamp of the last frame
delta\ _time : float64;
@ -122,6 +126,9 @@ init :: () {
load_pack("core", true, false);
load_pack("game_core", true, false);
#if FLAG_TEST_EXE_ENGINE {
engine_exe_tests_add();
}
}
init_after_core :: () {
@ -191,6 +198,10 @@ frame :: () {
add_frame_profiling_point("After loading logic");
#if FLAG_TEST_EXE_ENGINE {
run_exe_tests();
}
frame_start_time := get_time();
dpis := state.dpi_scale;

View File

@ -0,0 +1,5 @@
engine_exe_tests_add :: () {
start_test_suite("Pause menu");
start_test("Esc opens pause menu");
add_command(.{type = .WAIT});
}

View File

@ -0,0 +1,41 @@
g_test_runner_state : [..]Exe_Test_Suite;
#load "runner.jai";
Exe_Test_Suite :: struct {
name : string;
tests : [..]Exe_Test;
}
Exe_Test :: struct {
name : string;
cmds : [..]Exe_Test_Command;
}
Exe_Test_Command_Type :: enum {
INVALID;
WAIT;
KEYPRESS;
}
Exe_Test_Command :: struct {
type : Exe_Test_Command_Type = .INVALID;
}
start_test_suite :: (name: string) {
array_add(*g_test_runner_state, .{ name = name });
}
start_test :: (name: string) {
assert(g_test_runner_state.count > 0);
latest_suite := *g_test_runner_state[g_test_runner_state.count - 1];
array_add(*latest_suite.tests, Exe_Test.{ name = name });
}
add_command :: (cmd: Exe_Test_Command) {
assert(g_test_runner_state.count > 0);
latest_suite := *g_test_runner_state[g_test_runner_state.count - 1];
assert(latest_suite.tests.count > 0);
latest_test := *latest_suite.tests[latest_suite.tests.count - 1];
array_add(*latest_test.cmds, cmd);
}

View File

@ -0,0 +1,11 @@
run_exe_tests :: () {
for g_test_runner_state {
print("SUITE: %\n", it.name);
for it.tests {
print(" TEST: %\n", it.name);
for it.cmds {
print(" CMD: %\n", it.type);
}
}
}
}

View File

@ -1,2 +1,5 @@
#load "utils.jai";
#load "world_test.jai";
#load "engine_exe_tests/index.jai";
#load "exe_tests/index.jai";

15
test_game/game.jai Normal file
View File

@ -0,0 +1,15 @@
game_engine_config :: () {
}
game_init :: () {
}
game_ui :: (theme: *GR.Overall_Theme) {
}
game_tick :: (dt: float64) {
}
game_draw :: () {
}