diff --git a/first.jai b/first.jai index 0f797ef..54542df 100644 --- a/first.jai +++ b/first.jai @@ -4,14 +4,15 @@ Iprof :: #import "Iprof"(IMPORT_MODE = .METAPROGRAM); #import "File_Utilities"; Trueno_Build_Options :: struct { - wasm_build : bool; - release_build : bool; - tacoma_enabled : bool; - iprof_enabled : bool; - demo_build : bool; - test_engine : bool; - test_game : bool; - short_tests : bool; + wasm_build : bool; + release_build : bool; + tacoma_enabled : bool; + iprof_enabled : bool; + demo_build : bool; + test_engine : bool; + test_game : 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; } } diff --git a/sample_game/game.jai b/sample_game/game.jai deleted file mode 100644 index 74d2989..0000000 --- a/sample_game/game.jai +++ /dev/null @@ -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); - } -} diff --git a/src/main.jai b/src/main.jai index d9768a5..4c5a8ed 100644 --- a/src/main.jai +++ b/src/main.jai @@ -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; diff --git a/src/tests/engine_exe_tests/index.jai b/src/tests/engine_exe_tests/index.jai new file mode 100644 index 0000000..b54529b --- /dev/null +++ b/src/tests/engine_exe_tests/index.jai @@ -0,0 +1,5 @@ +engine_exe_tests_add :: () { + start_test_suite("Pause menu"); + start_test("Esc opens pause menu"); + add_command(.{type = .WAIT}); +} diff --git a/src/tests/exe_tests/index.jai b/src/tests/exe_tests/index.jai new file mode 100644 index 0000000..dae9b13 --- /dev/null +++ b/src/tests/exe_tests/index.jai @@ -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); +} diff --git a/src/tests/exe_tests/runner.jai b/src/tests/exe_tests/runner.jai new file mode 100644 index 0000000..3d80584 --- /dev/null +++ b/src/tests/exe_tests/runner.jai @@ -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); + } + } + } +} diff --git a/src/tests/index.jai b/src/tests/index.jai index ade7e8a..4b31c2e 100644 --- a/src/tests/index.jai +++ b/src/tests/index.jai @@ -1,2 +1,5 @@ #load "utils.jai"; #load "world_test.jai"; + +#load "engine_exe_tests/index.jai"; +#load "exe_tests/index.jai"; diff --git a/test_game/game.jai b/test_game/game.jai new file mode 100644 index 0000000..ced4652 --- /dev/null +++ b/test_game/game.jai @@ -0,0 +1,15 @@ +game_engine_config :: () { +} + +game_init :: () { +} + +game_ui :: (theme: *GR.Overall_Theme) { + +} + +game_tick :: (dt: float64) { +} + +game_draw :: () { +} diff --git a/sample_game/resources/postprocess.json b/test_game/resources/postprocess.json similarity index 100% rename from sample_game/resources/postprocess.json rename to test_game/resources/postprocess.json diff --git a/sample_game/resources/triles.json b/test_game/resources/triles.json similarity index 100% rename from sample_game/resources/triles.json rename to test_game/resources/triles.json diff --git a/sample_game/resources/worlds.json b/test_game/resources/worlds.json similarity index 100% rename from sample_game/resources/worlds.json rename to test_game/resources/worlds.json