Skip to content

Commit

Permalink
Add CI job for running test suite with cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderMertens committed Sep 30, 2023
1 parent b6224c2 commit 2f099fc
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 3 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -807,3 +807,27 @@ jobs:
- name: run tests
run: |
bake run test/cpp_api --cfg sanitize -- -j 8
test-cmake:
needs: [ build-linux, build-macos ]
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macOS-latest ]

steps:
- uses: actions/checkout@v3
- name: clone bake
run: |
git clone https://github.com/SanderMertens/bake
- name: build flecs & tests
run: |
cmake -DFLECS_TESTS=ON -DBAKE_DIRECTORY=bake
cmake --build . -j 4
- name: run tests
run: |
ctest -C Debug --verbose
22 changes: 20 additions & 2 deletions docs/Quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ Download or `git clone` the [flecs repository](https://github.com/SanderMertens/
"use": ["flecs"]
```

### Running tests
To run the Flecs test suite, first make sure you have [bake](https://github.com/SanderMertens/bake) installed (see the bake repository for instructions).
### Running tests (bake)
First make sure you have [bake](https://github.com/SanderMertens/bake) installed (see the bake repository for instructions).

Run the following commands to run all tests (use `-j` to specify the number of threads):

Expand All @@ -64,6 +64,24 @@ To run tests with asan enabled, add `--cfg sanitize` to the command:
bake run --cfg sanitize test/api -- -j 4
```

#### Running tests (cmake, experimental)
First make sure to clone [bake](https://github.com/SanderMertens/bake).

Run the following commands to run all the tests:

```bash
# Generate make files for Flecs and tests
cmake -DFLECS_TESTS=ON -DBAKE_DIRECTORY="path to cloned bake repository"

# Build flecs and test suites
cmake --build . -j 4

# Run the tests
ctest -C Debug --verbose
```

```bash

### Emscripten
When building for emscripten, add the following command line options to the `emcc` link command:
```bash
Expand Down
12 changes: 11 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ project(flecs_tests LANGUAGES C CXX)

if(NOT BAKE_DIRECTORY)
set(BAKE_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/bake")
else()
set(BAKE_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/../${BAKE_DIRECTORY}")
endif()

if(NOT IS_DIRECTORY "${BAKE_DIRECTORY}")
Expand Down Expand Up @@ -60,18 +62,26 @@ else()
list(FILTER BAKE_SOURCES EXCLUDE REGEX "src/win")
endif()

message(STATUS ${BAKE_DIRECTORY})

add_library(bake_base SHARED ${BAKE_SOURCES})

target_include_directories(
bake_base PUBLIC "${BAKE_DIRECTORY}/include" "${BAKE_DIRECTORY}/util/include"
"${BAKE_DIRECTORY}/drivers/test/include")

target_compile_definitions(
bake_base
PUBLIC __BAKE__=1
PRIVATE bake_test_EXPORTS=1 UT_IMPL=1)
PRIVATE bake_test_EXPORTS=1 UT_IMPL=1
_XOPEN_SOURCE=600)

if(WIN32)
target_link_libraries(bake_base PUBLIC Dbghelp Shlwapi Ws2_32)
endif()
if(UNIX AND NOT APPLE)
target_link_libraries(bake_base PUBLIC m)
endif()

add_flecs_test("${CMAKE_CURRENT_LIST_DIR}/addons")
add_flecs_test("${CMAKE_CURRENT_LIST_DIR}/api")
Expand Down

0 comments on commit 2f099fc

Please sign in to comment.