From 2f099fc8037cb0515e88322183e75d8b7fd981f3 Mon Sep 17 00:00:00 2001 From: Sander Mertens Date: Mon, 18 Sep 2023 13:11:44 -0700 Subject: [PATCH] Add CI job for running test suite with cmake --- .github/workflows/ci.yml | 24 ++++++++++++++++++++++++ docs/Quickstart.md | 22 ++++++++++++++++++++-- test/CMakeLists.txt | 12 +++++++++++- 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 83329f81ab..ad6bb482b3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/docs/Quickstart.md b/docs/Quickstart.md index 763f38a1a2..7ace58af84 100644 --- a/docs/Quickstart.md +++ b/docs/Quickstart.md @@ -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): @@ -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 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 528a103f8a..9e1534e7b3 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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}") @@ -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")