Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ jobs:

wasm:
runs-on: ubuntu-22.04
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4

Expand All @@ -129,6 +128,7 @@ jobs:
run: emmake cmake --build build -j8 -t package

- name: Create Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: build/latebit-*
Expand Down
38 changes: 38 additions & 0 deletions docs/development/testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Testing
===

# Integration testing

Integration tests are test that are **not** run in CI, but rather manually by
the developers during development and review.

They are used in the following two cases:

* when a unit test is impactical or impossible
for example, when a behaviour depends heavily on the hardware or SDL

* when you want to see something happening in a real game, but you cannot

They are currently run both in native environments and in WASM.

## Running the tests

### Native

```sh
# Normal configure and build
cmake -B build && cmake --build build

# Launch the test
./build/test/NAME_OF_THE_TEST.test
```

### WASM

```sh
# Normal configure and build
emcmake cmake -B build && emmake cmake --build build

# Launch the test
emrun ./build/test/NAME_OF_THE_TEST.test.html
```
8 changes: 4 additions & 4 deletions latebit/core/GameManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,16 @@ struct EmscriptenLoopArgs {
long int* adjustTime = 0;
long int* loopTime = 0;
long int* steps = 0;
EventStep* step = 0;
Clock* clock = 0;
int frameTime = 0;
bool* paused = 0;
};

void GameManager::loop(void* a) {
EmscriptenLoopArgs* args = (EmscriptenLoopArgs*)a;
args->step->setStepCount(++(*args->steps));
GM.onEvent(args->step);
// Send a step event to all subscribers
const auto evt = EventStep(++(*args->steps));
GM.onEvent(&evt);

IM.getInput();
if (!*args->paused) {
Expand All @@ -155,7 +155,7 @@ void GameManager::run() {
long int steps = 0;
EventStep step(0);

EmscriptenLoopArgs args = {&adjustTime, &loopTime, &steps, &step,
EmscriptenLoopArgs args = {&adjustTime, &loopTime, &steps,
clock, frameTime, &this->paused};

emscripten_set_main_loop_arg(loop, &args, 0, 1);
Expand Down
7 changes: 7 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ project(integration_test LANGUAGES C CXX)
file(GLOB_RECURSE INTEGRATION_TESTS_FILES "${CMAKE_SOURCE_DIR}/test/integration/*")

if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
foreach(test_file ${INTEGRATION_TESTS_FILES})
get_filename_component(FILE_NAME ${test_file} NAME_WE)
add_executable(${FILE_NAME}.test ${test_file})
set_target_properties(${FILE_NAME}.test PROPERTIES LINK_FLAGS "-s USE_LIBPNG=1 -s USE_SDL=2 -sSTACK_SIZE=1MB --preload-file ../../test/fixtures")
set_target_properties(${FILE_NAME}.test PROPERTIES SUFFIX ".html")
target_link_libraries(${FILE_NAME}.test PRIVATE latebit)
endforeach()
else ()
foreach(test_file ${INTEGRATION_TESTS_FILES})
get_filename_component(FILE_NAME ${test_file} NAME_WE)
Expand Down