start building foundation for exe test runner
This commit is contained in:
parent
c672990e27
commit
9f647ea5c5
23
first.jai
23
first.jai
@ -4,14 +4,15 @@ Iprof :: #import "Iprof"(IMPORT_MODE = .METAPROGRAM);
|
|||||||
#import "File_Utilities";
|
#import "File_Utilities";
|
||||||
|
|
||||||
Trueno_Build_Options :: struct {
|
Trueno_Build_Options :: struct {
|
||||||
wasm_build : bool;
|
wasm_build : bool;
|
||||||
release_build : bool;
|
release_build : bool;
|
||||||
tacoma_enabled : bool;
|
tacoma_enabled : bool;
|
||||||
iprof_enabled : bool;
|
iprof_enabled : bool;
|
||||||
demo_build : bool;
|
demo_build : bool;
|
||||||
test_engine : bool;
|
test_engine : bool;
|
||||||
test_game : bool;
|
test_game : bool;
|
||||||
short_tests : bool;
|
test_exe_engine : bool;
|
||||||
|
test_exe_game : bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
build_options_from_args :: (args: []string) -> Trueno_Build_Options {
|
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;
|
opts.test_game = true;
|
||||||
case "test_engine";
|
case "test_engine";
|
||||||
opts.test_engine = true;
|
opts.test_engine = true;
|
||||||
case "test_short";
|
case "test_exe_game";
|
||||||
opts.short_tests = true;
|
opts.test_exe_game = true;
|
||||||
|
case "test_exe_engine";
|
||||||
|
opts.test_exe_engine = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
15
src/main.jai
15
src/main.jai
@ -15,7 +15,7 @@ String :: #import "String";
|
|||||||
Jaison :: #import "Jaison";
|
Jaison :: #import "Jaison";
|
||||||
stbi :: #import "stb_image";
|
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 "logging.jai";
|
||||||
#load "pseudophysics/core.jai";
|
#load "pseudophysics/core.jai";
|
||||||
@ -39,7 +39,11 @@ stbi :: #import "stb_image";
|
|||||||
#load "settings_menu.jai";
|
#load "settings_menu.jai";
|
||||||
#load "ui/demo.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
|
last_frame_time : float64; // timestamp of the last frame
|
||||||
delta\ _time : float64;
|
delta\ _time : float64;
|
||||||
@ -122,6 +126,9 @@ init :: () {
|
|||||||
load_pack("core", true, false);
|
load_pack("core", true, false);
|
||||||
load_pack("game_core", true, false);
|
load_pack("game_core", true, false);
|
||||||
|
|
||||||
|
#if FLAG_TEST_EXE_ENGINE {
|
||||||
|
engine_exe_tests_add();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
init_after_core :: () {
|
init_after_core :: () {
|
||||||
@ -191,6 +198,10 @@ frame :: () {
|
|||||||
|
|
||||||
add_frame_profiling_point("After loading logic");
|
add_frame_profiling_point("After loading logic");
|
||||||
|
|
||||||
|
#if FLAG_TEST_EXE_ENGINE {
|
||||||
|
run_exe_tests();
|
||||||
|
}
|
||||||
|
|
||||||
frame_start_time := get_time();
|
frame_start_time := get_time();
|
||||||
|
|
||||||
dpis := state.dpi_scale;
|
dpis := state.dpi_scale;
|
||||||
|
|||||||
5
src/tests/engine_exe_tests/index.jai
Normal file
5
src/tests/engine_exe_tests/index.jai
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
engine_exe_tests_add :: () {
|
||||||
|
start_test_suite("Pause menu");
|
||||||
|
start_test("Esc opens pause menu");
|
||||||
|
add_command(.{type = .WAIT});
|
||||||
|
}
|
||||||
41
src/tests/exe_tests/index.jai
Normal file
41
src/tests/exe_tests/index.jai
Normal 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);
|
||||||
|
}
|
||||||
11
src/tests/exe_tests/runner.jai
Normal file
11
src/tests/exe_tests/runner.jai
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,2 +1,5 @@
|
|||||||
#load "utils.jai";
|
#load "utils.jai";
|
||||||
#load "world_test.jai";
|
#load "world_test.jai";
|
||||||
|
|
||||||
|
#load "engine_exe_tests/index.jai";
|
||||||
|
#load "exe_tests/index.jai";
|
||||||
|
|||||||
15
test_game/game.jai
Normal file
15
test_game/game.jai
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
game_engine_config :: () {
|
||||||
|
}
|
||||||
|
|
||||||
|
game_init :: () {
|
||||||
|
}
|
||||||
|
|
||||||
|
game_ui :: (theme: *GR.Overall_Theme) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
game_tick :: (dt: float64) {
|
||||||
|
}
|
||||||
|
|
||||||
|
game_draw :: () {
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user