diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 71fa2fa..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,68 +0,0 @@ -version: 2.1 - -# If you only want circle to run on direct commits to master, you can uncomment this out -# and uncomment the filters: *filter-only-master down below too -# -aliases: - - &filter-only-master - branches: - only: - - master - -commands: - base-build-setup: - steps: - - run: - name: Setup - command: | - sudo apt update - sudo apt install -y --no-install-recommends g++ cmake libboost-all-dev - - build-tests-with-cmake: - description: "Build SPARTA tests with CMake" - steps: - - run: - name: Build - command: | - mkdir build - cd build - cmake .. - cmake --build . -j 4 - - run-all-tests: - description: "Test SPARTA" - steps: - - run: - name: Run tests - command: | - mkdir -p /tmp/test-results - export GTEST_OUTPUT=xml:/tmp/test-results/ - cd build - ./run_all_tests.sh - - store_test_results: - path: /tmp/test-results - -jobs: - build-deb_testing: - docker: - - image: circleci/buildpack-deps:testing - resource_class: large - steps: - - checkout - - base-build-setup - - build-tests-with-cmake - - run-all-tests - -workflows: - version: 2.1 - build: - jobs: - - build-deb_testing - - nightly: - triggers: - - schedule: - cron: "0 0 * * *" - filters: *filter-only-master - jobs: - - build-deb_testing diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml new file mode 100644 index 0000000..0737b54 --- /dev/null +++ b/.github/workflows/cmake.yml @@ -0,0 +1,27 @@ +name: CMake + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +env: + BUILD_TYPE: Release + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Install boost + run: sudo apt update && sudo apt install libboost-all-dev + - name: Configure CMake + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + - name: Build + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + - name: Test + working-directory: ${{github.workspace}}/build + run: ctest -C ${{env.BUILD_TYPE}} + diff --git a/CMakeLists.txt b/CMakeLists.txt index dd7e89f..2b13c51 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,6 +58,7 @@ file(GLOB test "test/*.cpp" ) +include(CTest) # ${test} contains all paths to the test cpps foreach(testfile ${test}) # ${testfile} is in the format of test/SomeTest.cpp @@ -67,7 +68,6 @@ foreach(testfile ${test}) # ${test_bin} is in the format of SomeTest_test add_executable(${test_bin} ${testfile}) target_link_libraries(${test_bin} PRIVATE sparta gmock_main) + add_test(NAME ${testfile} COMMAND ${test_bin}) endforeach() -# Copy the script that runs all tests under the build directory -configure_file(run_all_tests.sh run_all_tests.sh COPYONLY) diff --git a/README.md b/README.md index 81c439c..795e8ee 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ cmake --build . To run the unit tests, please type: ``` -./run_all_tests.sh +make test ``` To copy the header files into `/usr/local/include/sparta` and set up a cmake library for SPARTA, you can use the following command: diff --git a/run_all_tests.sh b/run_all_tests.sh deleted file mode 100755 index c2469e0..0000000 --- a/run_all_tests.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -# Copyright (c) Meta Platforms, Inc. and affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -N_TEST_FAILED=0 -FAILED_TESTS=$"" - -failed_test() { - ((N_TEST_FAILED++)) - FAILED_TESTS=$(printf "%s\n%s" "$FAILED_TESTS" "$1") -} - -for test in *_test; do - if [[ -f "$test" ]]; then - ./"$test" || failed_test "$test" - else - # Wildcard did not expand into any file (i.e. files don't exist) - echo "Tests not found. Please make sure you are in the build directory." - exit 2 - fi -done - -if [[ $N_TEST_FAILED -ne 0 ]]; then - printf "%s test(s) failed.%s\n" "$N_TEST_FAILED" "$FAILED_TESTS" - exit 1 -fi