From b652e9c3c6d559cda55ef4dd040f330961b69714 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Mon, 8 Jul 2024 15:50:27 -0400 Subject: [PATCH 1/2] Fix up some ctest errors --- .github/workflows/main.yml | 26 ++++++++++++------- ChangeLog.md | 4 +++ bin/tests/inputs/MpiParameterizedTestCaseC.pf | 4 +-- bin/tests/inputs/MpiTestCaseB.pf | 4 +-- bin/tests/inputs/ParameterizedTestCaseB.pf | 4 +-- bin/tests/inputs/TestA.pf | 4 +-- bin/tests/inputs/TestCaseA.pf | 4 +-- 7 files changed, 30 insertions(+), 20 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f0a8cb51..8b837d6a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -97,10 +97,12 @@ jobs: run: cmake --build build --parallel 4 - name: Build Tests - run: cmake --build build --parallel 4 -t build-tests + run: | + cmake --build build --parallel 4 --target build-tests + cmake --build build --parallel 4 --target tests - - name: Run Tests - run: ctest --test-dir build --parallel 1 --output-on-failure --repeat until-pass:4 --schedule-random + - name: Run Ctest + run: ctest --test-dir build --parallel 1 --output-on-failure --repeat until-pass:4 - name: Archive log files on failure uses: actions/upload-artifact@v4 @@ -111,7 +113,7 @@ jobs: build/**/*.log Intel: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest env: FC: ifx @@ -164,10 +166,12 @@ jobs: run: cmake --build build --parallel - name: Build Tests - run: cmake --build build --parallel -t build-tests + run: | + cmake --build build --parallel 4 --target build-tests + cmake --build build --parallel 4 --target tests - - name: Run Tests - run: ctest --test-dir build --parallel 1 --output-on-failure --repeat until-pass:4 --schedule-random + - name: Run Ctest + run: ctest --test-dir build --parallel 1 --output-on-failure --repeat until-pass:4 - name: Archive log files on failure uses: actions/upload-artifact@v4 @@ -211,10 +215,12 @@ jobs: run: cmake --build build --parallel - name: Build Tests - run: cmake --build build --parallel -t build-tests + run: | + cmake --build build --parallel 4 --target build-tests + cmake --build build --parallel 4 --target tests - - name: Run Tests - run: ctest --test-dir build --parallel 1 --output-on-failure --repeat until-pass:4 --schedule-random + - name: Run Ctest + run: ctest --test-dir build --parallel 1 --output-on-failure --repeat until-pass:4 - name: Archive log files on failure uses: actions/upload-artifact@v4 diff --git a/ChangeLog.md b/ChangeLog.md index 6d82b389..23e4fd50 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -14,6 +14,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - LLVMFlang compiler support +### Fixed + +- Fixes some ctest failures + ## [4.9.0] - 2024-02-06 ### Added diff --git a/bin/tests/inputs/MpiParameterizedTestCaseC.pf b/bin/tests/inputs/MpiParameterizedTestCaseC.pf index a22180b5..3e046fd5 100644 --- a/bin/tests/inputs/MpiParameterizedTestCaseC.pf +++ b/bin/tests/inputs/MpiParameterizedTestCaseC.pf @@ -1,4 +1,4 @@ -module TestCaseC_mod +module MpiParameterizedTestCaseC use pfunit_mod implicit none @@ -117,6 +117,6 @@ contains end function toString -end module TestCaseC_mod +end module MpiParameterizedTestCaseC diff --git a/bin/tests/inputs/MpiTestCaseB.pf b/bin/tests/inputs/MpiTestCaseB.pf index daf82893..907937a1 100644 --- a/bin/tests/inputs/MpiTestCaseB.pf +++ b/bin/tests/inputs/MpiTestCaseB.pf @@ -1,4 +1,4 @@ -module MpiTestCaseB_mod +module MpiTestCaseB use pfunit_mod implicit none @@ -35,6 +35,6 @@ contains class (MpiTestCaseB), intent(inout) :: this end subroutine testB -end module MpiTestCaseB_mod +end module MpiTestCaseB diff --git a/bin/tests/inputs/ParameterizedTestCaseB.pf b/bin/tests/inputs/ParameterizedTestCaseB.pf index ddd64585..8c894cc0 100644 --- a/bin/tests/inputs/ParameterizedTestCaseB.pf +++ b/bin/tests/inputs/ParameterizedTestCaseB.pf @@ -1,4 +1,4 @@ -module TestCaseB_mod +module ParameterizedTestCaseB use pfunit_mod implicit none @@ -64,6 +64,6 @@ contains end function toString -end module TestCaseB_mod +end module ParameterizedTestCaseB diff --git a/bin/tests/inputs/TestA.pf b/bin/tests/inputs/TestA.pf index ee0ce16d..eece1473 100644 --- a/bin/tests/inputs/TestA.pf +++ b/bin/tests/inputs/TestA.pf @@ -1,4 +1,4 @@ -module TestA_mod +module TestA use pfunit_mod implicit none @@ -19,6 +19,6 @@ contains class (MpiTestMethod), intent(inout) :: this end subroutine testMethodC -end module TestA_mod +end module TestA diff --git a/bin/tests/inputs/TestCaseA.pf b/bin/tests/inputs/TestCaseA.pf index fa9bb5da..7205c978 100644 --- a/bin/tests/inputs/TestCaseA.pf +++ b/bin/tests/inputs/TestCaseA.pf @@ -1,4 +1,4 @@ -module TestCaseA_mod +module TestCaseA use pfunit_mod implicit none @@ -35,4 +35,4 @@ contains class (TestCaseA), intent(inout) :: this end subroutine testB -end module TestCaseA_mod +end module TestCaseA From c2a7c057329ceaf6fc2957ad935222a44b2b7eed Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Mon, 8 Jul 2024 16:58:21 -0400 Subject: [PATCH 2/2] Fix up ctest --- .gitignore | 3 ++- CMakeLists.txt | 43 +++++++++++++++++++++++-------------------- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index 58a7f4e6..44148945 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,5 @@ /mpi_pFUnit.x /nag *.zip -build/ \ No newline at end of file +build/ +Testing/ diff --git a/CMakeLists.txt b/CMakeLists.txt index b342c312..1bb09395 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,6 +138,12 @@ if (APPLE) SET(CMAKE_Fortran_ARCHIVE_FINISH " -no_warning_for_no_symbols -c ") endif () +# Enable testing before adding subdirectories +# to catch any tests in the main project +if (ENABLE_TESTS) + enable_testing() +endif () + include(build_submodule) # Find fArgParse first so that gFTL and gFTL-shared are consistent build_submodule(extern/fArgParse PROJECT FARGPARSE TARGET FARGPARSE::fargparse) @@ -150,28 +156,25 @@ if (ENABLE_BUILD_DOXYGEN) add_subdirectory(documentation) endif() -if (ENABLE_TESTS) - enable_testing() - if (NOT TARGET build-tests) - add_custom_target(build-tests) - endif() - - if (NOT TARGET tests) - add_custom_target(tests - COMMAND ${CMAKE_CTEST_COMMAND} - EXCLUDE_FROM_ALL) - endif () - add_dependencies(tests build-tests) - add_subdirectory (tests EXCLUDE_FROM_ALL) - - # The following forces tests to be built when using "make ctest" even if some targets - # are EXCLUDE_FROM_ALL - # From https://stackoverflow.com/questions/733475/cmake-ctest-make-test-doesnt-build-tests/56448477#56448477 - build_command(CTEST_CUSTOM_PRE_TEST TARGET build-tests) - string(CONFIGURE \"@CTEST_CUSTOM_PRE_TEST@\" CTEST_CUSTOM_PRE_TEST_QUOTED ESCAPE_QUOTES) - file(WRITE "${CMAKE_BINARY_DIR}/CTestCustom.cmake" "set(CTEST_CUSTOM_PRE_TEST ${CTEST_CUSTOM_PRE_TEST_QUOTED})" "\n") +if (NOT TARGET build-tests) + add_custom_target(build-tests) endif() +if (NOT TARGET tests) + add_custom_target(tests + COMMAND ${CMAKE_CTEST_COMMAND} + EXCLUDE_FROM_ALL) +endif () +add_dependencies(tests build-tests) +add_subdirectory (tests EXCLUDE_FROM_ALL) + +# The following forces tests to be built when using "make ctest" even if some targets +# are EXCLUDE_FROM_ALL +# From https://stackoverflow.com/questions/733475/cmake-ctest-make-test-doesnt-build-tests/56448477#56448477 +build_command(CTEST_CUSTOM_PRE_TEST TARGET build-tests) +string(CONFIGURE \"@CTEST_CUSTOM_PRE_TEST@\" CTEST_CUSTOM_PRE_TEST_QUOTED ESCAPE_QUOTES) +file(WRITE "${CMAKE_BINARY_DIR}/CTestCustom.cmake" "set(CTEST_CUSTOM_PRE_TEST ${CTEST_CUSTOM_PRE_TEST_QUOTED})" "\n") + # The following is needed for external projects using *nix make when # parent project builds pFUnit as a subproject. set (top_dir PFUNIT-${PFUNIT_VERSION_MAJOR}.${PFUNIT_VERSION_MINOR})