Skip to content

Commit cfa4b5c

Browse files
authored
[Testing]: Add testing infrastructure and CI pipelines (#52)
- Integrate testcoe via CMake with optional GAMECOE_USE_TESTCOE flag - Create module-based test structure (tests/entity/, tests/integration/) - Implement custom test runner with CLI options (--help, --all, --suite, --test) - Add tests across 4 suites (EntityTests, SparseSetTests, ComponentPoolTests, ECSIntegrationTests) - Add CI workflows for Linux (GCC/Clang), macOS (Clang), Windows (MSVC/MinGW) - Rename old architecture files to .old (isolate during DoD ECS refactoring) - Delete empty files (material, mesh, sprite)
1 parent a6b73a6 commit cfa4b5c

57 files changed

Lines changed: 1260 additions & 34 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci-linux.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Linux
2+
3+
on:
4+
push:
5+
branches: [ main, refactor/dod_ecs ]
6+
pull_request:
7+
types: [ opened, synchronize, reopened, ready_for_review ]
8+
branches: [ main, refactor/dod_ecs ]
9+
10+
jobs:
11+
build-and-test:
12+
name: ${{ matrix.name }}
13+
runs-on: ubuntu-latest
14+
if: github.event.pull_request.draft == false || github.event_name == 'push'
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
include:
19+
# Linux with GCC
20+
- name: "Linux GCC"
21+
compiler: gcc
22+
cmake-generator: 'Ninja'
23+
cmake-options: '-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DGAMECOE_USE_TESTCOE=ON -DGAMECOE_GLFW_WAYLAND=OFF'
24+
25+
# Linux with Clang
26+
- name: "Linux Clang"
27+
compiler: clang
28+
cmake-generator: 'Ninja'
29+
cmake-options: '-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DGAMECOE_USE_TESTCOE=ON -DGAMECOE_GLFW_WAYLAND=OFF'
30+
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@v3
34+
with:
35+
submodules: 'recursive'
36+
37+
- name: Install dependencies
38+
run: |
39+
sudo apt-get update
40+
sudo apt-get install -y ninja-build xorg-dev libgl1-mesa-dev libglu1-mesa-dev
41+
shell: bash
42+
43+
- name: Configure CMake
44+
run: |
45+
cmake -B build -G "${{ matrix.cmake-generator }}" ${{ matrix.cmake-options }}
46+
47+
- name: Build
48+
run: |
49+
cmake --build build --config Release
50+
51+
- name: Run tests
52+
working-directory: build
53+
run: |
54+
echo "Running gamecoe tests"
55+
./tests/gamecoe_tests
56+
shell: bash

.github/workflows/ci-macos.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: macOS
2+
3+
on:
4+
push:
5+
branches: [ main, refactor/dod_ecs ]
6+
pull_request:
7+
types: [ opened, synchronize, reopened, ready_for_review ]
8+
branches: [ main, refactor/dod_ecs ]
9+
10+
jobs:
11+
build-and-test:
12+
name: ${{ matrix.name }}
13+
runs-on: macos-latest
14+
if: github.event.pull_request.draft == false || github.event_name == 'push'
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
include:
19+
# macOS with Apple Clang
20+
- name: "macOS Clang"
21+
compiler: clang
22+
cmake-generator: 'Ninja'
23+
cmake-options: '-DGAMECOE_USE_TESTCOE=ON'
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v3
28+
with:
29+
submodules: 'recursive'
30+
31+
- name: Install ninja-build
32+
run: |
33+
brew install ninja
34+
shell: bash
35+
36+
- name: Configure CMake
37+
run: |
38+
cmake -B build -G "${{ matrix.cmake-generator }}" ${{ matrix.cmake-options }}
39+
40+
- name: Build
41+
run: |
42+
cmake --build build --config Release
43+
44+
- name: Run tests
45+
working-directory: build
46+
run: |
47+
echo "Running gamecoe tests"
48+
./tests/gamecoe_tests
49+
shell: bash

.github/workflows/ci-windows.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Windows
2+
3+
on:
4+
push:
5+
branches: [ main, refactor/dod_ecs ]
6+
pull_request:
7+
types: [ opened, synchronize, reopened, ready_for_review ]
8+
branches: [ main, refactor/dod_ecs ]
9+
10+
jobs:
11+
build-and-test:
12+
name: ${{ matrix.name }}
13+
runs-on: windows-latest
14+
if: github.event.pull_request.draft == false || github.event_name == 'push'
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
include:
19+
# Windows with MSVC
20+
- name: "Windows MSVC"
21+
compiler: msvc
22+
cmake-generator: 'Visual Studio 17 2022'
23+
cmake-options: '-DGAMECOE_USE_TESTCOE=ON'
24+
25+
# Windows with MinGW (GCC)
26+
- name: "Windows MinGW"
27+
compiler: gcc
28+
cmake-generator: 'MinGW Makefiles'
29+
cmake-options: '-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DGAMECOE_USE_TESTCOE=ON'
30+
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@v3
34+
with:
35+
submodules: 'recursive'
36+
37+
- name: Install Windows build tools
38+
if: matrix.compiler != 'msvc'
39+
run: |
40+
if [ "${{ matrix.compiler }}" == "clang" ]; then
41+
choco install ninja
42+
elif [ "${{ matrix.compiler }}" == "gcc" ]; then
43+
choco install mingw
44+
fi
45+
shell: bash
46+
47+
48+
- name: Configure CMake
49+
run: |
50+
cmake -B build -G "${{ matrix.cmake-generator }}" ${{ matrix.cmake-options }}
51+
52+
- name: Build
53+
run: |
54+
cmake --build build --config Release
55+
56+
- name: Run tests
57+
working-directory: build
58+
run: |
59+
if [ "${{ matrix.compiler }}" == "gcc" ]; then
60+
# For MinGW - copy DLLs directly (no PATH manipulation)
61+
GCC_DIR=$(dirname $(which gcc))
62+
echo "GCC directory: $GCC_DIR"
63+
echo "Copying DLLs from $GCC_DIR"
64+
cp "$GCC_DIR"/libgcc*.dll tests/ 2>/dev/null || echo "No libgcc DLLs found"
65+
cp "$GCC_DIR"/libstdc*.dll tests/ 2>/dev/null || echo "No libstdc DLLs found"
66+
cp "$GCC_DIR"/libwinpthread*.dll tests/ 2>/dev/null || echo "No libwinpthread DLLs found"
67+
echo "Running gamecoe tests"
68+
cd tests
69+
./gamecoe_tests.exe
70+
else # MSVC
71+
echo "Running gamecoe tests"
72+
./tests/Release/gamecoe_tests.exe
73+
fi
74+
shell: bash

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ include(FetchContent)
1919

2020
# Fetching gamecoe toolkit libraries:
2121
fetch_logcoe()
22+
fetch_testcoe()
2223
fetch_soundcoe()
2324

2425
# Fetching external libraries for gamecoe:
@@ -33,6 +34,10 @@ message(STATUS "[gamecoe] Building gamecoe library...")
3334
add_subdirectory(include)
3435
add_subdirectory(src)
3536

37+
if(GAMECOE_USE_TESTCOE)
38+
add_subdirectory(tests)
39+
endif()
40+
3641
# gamecoe tester executable
3742
# add_executable(tester main.cpp)
3843

cmake/gamecoe_config.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/glfw.cmake)
66
include(${CMAKE_CURRENT_LIST_DIR}/glad.cmake)
77
include(${CMAKE_CURRENT_LIST_DIR}/glm.cmake)
88
include(${CMAKE_CURRENT_LIST_DIR}/logcoe.cmake)
9+
include(${CMAKE_CURRENT_LIST_DIR}/testcoe.cmake)
910
include(${CMAKE_CURRENT_LIST_DIR}/soundcoe.cmake)
1011
include(${CMAKE_CURRENT_LIST_DIR}/utils.cmake)
1112
include(${CMAKE_CURRENT_LIST_DIR}/config_header.cmake)

cmake/testcoe.cmake

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
function(fetch_testcoe)
2+
if(NOT DEFINED GAMECOE_USE_TESTCOE)
3+
set(GAMECOE_USE_TESTCOE OFF)
4+
endif()
5+
6+
if(GAMECOE_USE_TESTCOE)
7+
message(STATUS "[gamecoe] Using testcoe for testing")
8+
message(STATUS "[gamecoe] To disable: \"set(GAMECOE_USE_TESTCOE OFF)\" before fetching gamecoe")
9+
set(GAMECOE_USE_TESTCOE 1 PARENT_SCOPE)
10+
11+
message(STATUS "[gamecoe] Fetching testcoe from source...")
12+
13+
FetchContent_Declare(
14+
testcoe
15+
GIT_REPOSITORY https://github.com/nircoe/testcoe.git
16+
GIT_TAG v0.1.1
17+
)
18+
FetchContent_MakeAvailable(testcoe)
19+
else()
20+
message(STATUS "[gamecoe] testcoe disabled")
21+
message(STATUS "[gamecoe] To enable: \"set(GAMECOE_USE_TESTCOE ON)\" before fetching gamecoe")
22+
set(GAMECOE_USE_TESTCOE 0 PARENT_SCOPE)
23+
endif()
24+
endfunction()

include/gamecoe.hpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,9 @@
33
#include <gamecoe_config.hpp>
44

55
// gamecoe headers
6-
#include <gamecoe/core/game.hpp>
7-
#include <gamecoe/core/window.hpp>
8-
#include <gamecoe/core/scene.hpp>
9-
10-
#include <gamecoe/graphics/shader.hpp>
11-
#include <gamecoe/graphics/texture.hpp>
12-
13-
#include <gamecoe/entity/game_object.hpp>
14-
#include <gamecoe/entity/renderer/renderer.hpp>
15-
#include <gamecoe/entity/renderer/shape_renderer.hpp>
16-
#include <gamecoe/entity/camera.hpp>
6+
#include <gamecoe/entity/entity.hpp>
7+
#include <gamecoe/entity/sparse_set.hpp>
8+
#include <gamecoe/entity/component_pool.hpp>
179

1810
// gamecoe toolkit libraries headers
1911
#include <colorcoe.hpp>

0 commit comments

Comments
 (0)