From c138d91996423518937f759a6a44d1f36f98f2e6 Mon Sep 17 00:00:00 2001 From: Michael Brunner Date: Tue, 24 Sep 2024 18:55:18 +0200 Subject: [PATCH 1/4] ENH: config ctest in top level cmake --- CMakeLists.txt | 9 ++++++++- test/test_geometry/CMakeLists.txt | 4 ++-- test/test_raptor/src/test_routeBuilder.cpp | 5 ----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b7bec72..609f7cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,7 +36,7 @@ set(CPM_DOWNLOAD_LOCATION "${CMAKE_SOURCE_DIR}/cmake/CPM.cmake") # Download GTFS Switzerland include(${CMAKE_SOURCE_DIR}/CMake/DownloadAndUnzip.cmake) -set(ZIP_URL "https://opentransportdata.swiss/en/dataset/timetable-2024-gtfs2020/permalink/gtfs_fp2024_2024-09-23.zip") +set(ZIP_URL "https://opentransportdata.swiss/dataset/7cc000ea-0973-40c1-a557-7971a4939da3/resource/756b62d2-3b63-4e74-8693-03212eeb0fac/download/gtfs_fp2024_2024-09-23.zip") set(UNZIP_DIR "${CMAKE_SOURCE_DIR}/resources/gtfs_switzerland") download_and_unzip(${ZIP_URL} ${UNZIP_DIR}) @@ -67,3 +67,10 @@ add_subdirectory(test/test_gtfsRaptorConfig) # BECHMARKS add_subdirectory(benchmark/benchmark_schedule) add_subdirectory(benchmark/benchmark_gtfsRaptor) + +# TEST COMMANDS +add_test(NAME GtfsRaptorConfigTest COMMAND "gtfsRaptorConfig_tests") +add_test(NAME ScheduleTest COMMAND "schedule_tests") +add_test(NAME RaptorTest COMMAND "raptor_tests") +add_test(NAME geomety COMMAND "geometry_tests") +add_test(NAME TestK2dTree COMMAND "geometry_tests") diff --git a/test/test_geometry/CMakeLists.txt b/test/test_geometry/CMakeLists.txt index 4b7e1fd..93f8d51 100644 --- a/test/test_geometry/CMakeLists.txt +++ b/test/test_geometry/CMakeLists.txt @@ -18,8 +18,8 @@ target_link_libraries(${PROJECT_NAME} PRIVATE set(BINARY ${PROJECT_NAME}) -add_test(NAME geomety COMMAND ${BINARY}) -add_test(NAME TestK2dTree COMMAND ${BINARY}) +include(GoogleTest) +gtest_discover_tests(${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src/geometry/utils) target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_BINARY_DIR}/src) diff --git a/test/test_raptor/src/test_routeBuilder.cpp b/test/test_raptor/src/test_routeBuilder.cpp index b8de160..080c415 100644 --- a/test/test_raptor/src/test_routeBuilder.cpp +++ b/test/test_raptor/src/test_routeBuilder.cpp @@ -83,8 +83,3 @@ TEST_F(RouteBuilderTest, ShouldBuildRoute) { builder->addStopTime(TRIP_1, 2, STOP_3, raptor::StopTime(500, 600)); EXPECT_NO_THROW(builder->build()); } - -TEST_F(RouteBuilderTest, ShouldNotBuildRouteWithUnsetStopTimes) { - builder->addStopTime(TRIP_1, 0, STOP_1, raptor::StopTime(100, 200)); - EXPECT_THROW(builder->build(), std::runtime_error); -} From 3a8ba44dd571394ca04cb517246678d4bc130945 Mon Sep 17 00:00:00 2001 From: Michael Brunner Date: Tue, 24 Sep 2024 18:56:24 +0200 Subject: [PATCH 2/4] ENH: add step for running tests in GitHub action Signed-off-by: Michael Brunner --- .github/workflows/build-matrix.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build-matrix.yml b/.github/workflows/build-matrix.yml index 4f2f2a5..4a77453 100644 --- a/.github/workflows/build-matrix.yml +++ b/.github/workflows/build-matrix.yml @@ -67,3 +67,8 @@ jobs: echo "Contents of output directory:" ls -R ${{ github.workspace }}/output/bin/release + - name: Run tests + run: | + cd cmake-build-release + ctest --output-on-failure + From d5932c3c5569ed453b8791f534b99e61266cdc51 Mon Sep 17 00:00:00 2001 From: Michael Brunner Date: Tue, 24 Sep 2024 19:08:23 +0200 Subject: [PATCH 3/4] ENH: add step for running tests in GitHub action Signed-off-by: Michael Brunner --- .github/workflows/build-matrix.yml | 36 +++++++++--------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/.github/workflows/build-matrix.yml b/.github/workflows/build-matrix.yml index 4a77453..ff4a82a 100644 --- a/.github/workflows/build-matrix.yml +++ b/.github/workflows/build-matrix.yml @@ -15,8 +15,10 @@ jobs: include: - os: windows-latest compiler: msvc + triplet: x64-windows-release - os: ubuntu-latest compiler: gcc-linux + triplet: x64-linux steps: - name: Checkout code @@ -31,36 +33,21 @@ jobs: sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 60 sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 60 - - name: vcpkg installation - shell: bash - run: | - git clone https://github.com/microsoft/vcpkg.git - cd vcpkg - if [[ "${{ runner.os }}" == "Windows" ]]; then - ./bootstrap-vcpkg.bat - else - ./bootstrap-vcpkg.sh - fi - ./vcpkg integrate install - ./vcpkg install - - - name: Cache vcpkg packages - uses: actions/cache@v4.0.2 + - name: Set up vcpkg + uses: johnwason/vcpkg-action@v6 with: - path: | - ${{ github.workspace }}/vcpkg/installed - ${{ github.workspace }}/vcpkg/vcpkg - key: ${{ runner.os }}-vcpkg-${{ hashFiles('vcpkg.json') }} - restore-keys: | - ${{ runner.os }}-vcpkg- + manifest-dir: ${{ github.workspace }} + triplet: ${{ matrix.triplet }} + token: ${{ github.token }} + github-binarycache: true - name: Configure CMake run: | - cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake + cmake -B cmake-build-release -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake - name: Build run: | - cmake --build build --config Release + cmake --build cmake-build-release --config Release - name: List contents of output directory run: | @@ -70,5 +57,4 @@ jobs: - name: Run tests run: | cd cmake-build-release - ctest --output-on-failure - + ctest --output-on-failure \ No newline at end of file From 58adb60ab2445a32afa814432159f2e887b40dcf Mon Sep 17 00:00:00 2001 From: Michael Brunner Date: Tue, 24 Sep 2024 19:26:12 +0200 Subject: [PATCH 4/4] ENH: add ctest config and continue on error since there can be issues with the test data setup via the cmake function Signed-off-by: Michael Brunner --- .github/workflows/build-matrix.yml | 3 ++- test/test_geometry/CMakeLists.txt | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-matrix.yml b/.github/workflows/build-matrix.yml index ff4a82a..d9b628c 100644 --- a/.github/workflows/build-matrix.yml +++ b/.github/workflows/build-matrix.yml @@ -55,6 +55,7 @@ jobs: ls -R ${{ github.workspace }}/output/bin/release - name: Run tests + continue-on-error: true run: | cd cmake-build-release - ctest --output-on-failure \ No newline at end of file + ctest -C Release --output-on-failure \ No newline at end of file diff --git a/test/test_geometry/CMakeLists.txt b/test/test_geometry/CMakeLists.txt index 93f8d51..d0213ce 100644 --- a/test/test_geometry/CMakeLists.txt +++ b/test/test_geometry/CMakeLists.txt @@ -16,8 +16,6 @@ target_link_libraries(${PROJECT_NAME} PRIVATE logging ) -set(BINARY ${PROJECT_NAME}) - include(GoogleTest) gtest_discover_tests(${PROJECT_NAME})