From bc121924d53b71693ec74d516442e7b806151de1 Mon Sep 17 00:00:00 2001 From: Tom Clune Date: Sun, 23 Oct 2022 20:07:01 -0400 Subject: [PATCH 01/16] Quick and dirty AssertEqual for string arrays The generated errors are not particulary informative, as this implementation just iterates over individual strings. The whole StringAssert package needs serious refactoring. I fixed a bit with this PR, but really need to isolate a procedure for comparing the string and then drive it from different ranks. Then we can get an informative message out about _which_ string is the first one that is different and when which character is the first that is different. --- ChangeLog.md | 2 + src/funit/asserts/AssertString.F90 | 158 ++++++++++++-------------- src/funit/core/StringUtilities.F90 | 11 ++ tests/funit-core/CMakeLists.txt | 2 +- tests/funit-core/Test_AssertString.pf | 27 ++++- 5 files changed, 114 insertions(+), 86 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index b145e022..c2ee0171 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Added interface for `@asertEquals` for arrays of strings. Previously only string scalars could be compared. +- Added check in pFUnit preprocessor that raises an exception if the module name and filename do not agree unless `@suite` is used to override default assumptions. - Added `PFUNIT::pfunit-mpi-defines` ALIAS target - Added option to `add_pfunit_ctest()` macro to specify `WORKING_DIRECTORY`. This is the directory in which the specified test suite will _execute_. (Not where it is _built_). diff --git a/src/funit/asserts/AssertString.F90 b/src/funit/asserts/AssertString.F90 index 44314d80..b6d6d842 100644 --- a/src/funit/asserts/AssertString.F90 +++ b/src/funit/asserts/AssertString.F90 @@ -9,6 +9,8 @@ module pf_AssertString interface assertEqual module procedure assertEqual_string + module procedure assertEqual_string_0d1d + module procedure assertEqual_string_1d1d end interface assertEqual @@ -48,26 +50,27 @@ subroutine assertEqual_string(expected, found, message, location, & if(present(whitespace))then whitespace_ = whitespace + if (.not. any(whitespace_ == [TRIM_ALL, IGNORE_ALL, IGNORE_DIFFERENCES, KEEP_ALL])) then + throwMessage = & + & 'assertEqualString_InternalError: ' & + & // 'Unknown case for handling Whitespace' + call throw(appendWithSpace(message_,throwMessage), location) + return + end if + else ! This is the default whitespace option. TRIM_ALL is the legacy behavior. ! TODO: Change default behavior to IGNORE_DIFFERENCES. whitespace_ = TRIM_ALL end if - select case (whitespace_%value) - case (TRIM_ALL%value) - expected_ = trimAll(expected) - found_ = trimAll(found) - case (IGNORE_ALL%value) - expected_ = trimAll(expected) - found_ = trimAll(found) - case (IGNORE_DIFFERENCES%value) - expected_ = trimAll(expected) - found_ = trimAll(found) - case (KEEP_ALL%value) + if (whitespace_ == KEEP_ALL) then expected_ = expected found_ = found - end select + else + expected_ = trimAll(expected) + found_ = trimAll(found) + end if ! Determine if we need to iterate through the characters in the strings. ! Trim: ignore leading & trailing white space. @@ -75,58 +78,20 @@ subroutine assertEqual_string(expected, found, message, location, & ! Keep: white space is significant. ! Worry: Original code written to !print out trimmed strings. Not sure what effect ! Keep will have. - !print *,1000 - checkCharacterByCharacter = .true. - select case (whitespace_%value) - case (TRIM_ALL%value) - ! Check to see if we have to do more work. - checkCharacterByCharacter = expected_ /= found_ - numI = len(expected_); numJ = len(found_) - - case (IGNORE_ALL%value) - checkCharacterByCharacter = expected_ /= found_ - numI = len(expected_); numJ = len(found_) - - case (IGNORE_DIFFERENCES%value) - checkCharacterByCharacter = expected_ /= found_ - numI = len(expected_); numJ = len(found_) - !print *,1001,whitespace_%value - !print *,1002,'e="',expected_,'"' - !print *,1003,'f="',found_,'"' - - case (KEEP_ALL%value) - checkCharacterByCharacter = expected_ /= found_ - numI = len(expected_); numJ = len(found_) - - case default - throwMessage = & - & 'assertEqualString_InternalError: ' & - & // 'Unknown case for handling Whitespace' - call throw(appendWithSpace(message_,throwMessage), location) - end select - - ! Flag a check if zero-length arrays are involved. - if ((numI .eq. 0) .or. (numJ .eq. 0)) then - checkCharacterByCharacter = .true. - end if - - ! Fortran implicitly pads strings of different lengths with spaces - ! when comparing using /= or ==. Detect them and compare carefully. - if (numI .ne. numJ) then - checkCharacterByCharacter = .true. - end if - - !if (numI .eq. 0) then - ! print *,'e: "'//expected_//'"' - ! print *,'f: "'//found_//'"' - ! print *,'?: ',checkCharacterByCharacter - ! print *,'!: ',expected_ /= found_ - ! print *,'z: ',expected_ == found_ - !end if + checkCharacterByCharacter = expected_ /= found_ + numI = len(expected_); numJ = len(found_) - !print *,2000,whitespace_%value - -! if (trim(expected) /= trim(found)) then + ! Flag a check if zero-length arrays are involved. + if ((numI .eq. 0) .or. (numJ .eq. 0)) then + checkCharacterByCharacter = .true. + end if + + ! Fortran implicitly pads strings of different lengths with spaces + ! when comparing using /= or ==. Detect them and compare carefully. + if (numI .ne. numJ) then + checkCharacterByCharacter = .true. + end if + if (checkCharacterByCharacter) then numSameCharacters = 0 @@ -221,46 +186,30 @@ subroutine assertEqual_string(expected, found, message, location, & end if ! Fail if a traverse is complete. - !print *,2500,i,numI - !print *,2501,j,numJ if ( i .gt. numI .or. j .gt. numJ ) then - !print *,2502 throwException = .true. ; exit end if ! A character is not white space! ! Both characters are not whitespace: fail if unequal. - !print *,3001,i,j,whitespace_%value,expected_,found_ - !print *,3002,expected_(i:i),found_(j:j) - !print *,3003,expected_(i:i) /= found_(j:j) if (expected_(i:i) /= found_(j:j)) then - !print *,3004,'x' throwException = .true. ; exit end if - !print *,3005 ! Consume both of the equal characters. i=i+1; j=j+1; numSameCharacters = numSameCharacters + 1 end do countNumSameCharacters - !print *,4000 if (throwException) then - select case (whitespace_%value) - case (TRIM_ALL%value) - expected_ = trimTrailingWhitespace(expected) - found_ = trimTrailingWhitespace(found) - case (IGNORE_ALL%value) - expected_ = trimTrailingWhitespace(expected) - found_ = trimTrailingWhitespace(found) - case (IGNORE_DIFFERENCES%value) - expected_ = trimTrailingWhitespace(expected) - found_ = trimTrailingWhitespace(found) - case (KEEP_ALL%value) + if (whitespace_ == KEEP_ALL) then expected_ = expected found_ = found - end select + else + expected_ = trimTrailingWhitespace(expected) + found_ = trimTrailingWhitespace(found) + end if throwMessage = & & 'String assertion failed:' // new_line('A') // & @@ -278,4 +227,45 @@ subroutine assertEqual_string(expected, found, message, location, & end subroutine assertEqual_string + + subroutine assertEqual_string_0d1d(expected, found, message, location, & + & whitespace) + + character(len=*), intent(in) :: expected + character(len=*), intent(in) :: found(:) + character(len=*), optional, intent(in) :: message + type (SourceLocation), optional, intent(in) :: location + type (WhitespaceOptions), optional, intent(in) :: whitespace + + integer :: i + + do i = 1, size(found) + call assertEqual(expected, found(i), message=message, location=location, whitespace=whitespace) + end do + + end subroutine assertEqual_string_0d1d + + subroutine assertEqual_string_1d1d(expected, found, message, location, & + whitespace) + use PF_AssertUtilities + + character(len=*), intent(in) :: expected(:) + character(len=*), intent(in) :: found(:) + character(len=*), optional, intent(in) :: message + type (SourceLocation), optional, intent(in) :: location + type (WhitespaceOptions), optional, intent(in) :: whitespace + + integer :: i + + if (.not. size(expected) == size(found)) then + call fail_not_conformable(shape(expected), shape(found), message=message, location=location) + return + end if + + do i = 1, min(size(found),size(expected)) + call assertEqual(expected(i), found(i), message=message, location=location, whitespace=whitespace) + end do + + end subroutine assertEqual_string_1d1d + end module pf_AssertString diff --git a/src/funit/core/StringUtilities.F90 b/src/funit/core/StringUtilities.F90 index 04a11189..ee6a8a38 100644 --- a/src/funit/core/StringUtilities.F90 +++ b/src/funit/core/StringUtilities.F90 @@ -47,6 +47,7 @@ module PF_StringUtilities public :: nullTerminate public :: unlessScalar public :: WhitespaceOptions, IGNORE_ALL, TRIM_ALL, KEEP_ALL, IGNORE_DIFFERENCES + public :: operator(==) public :: whitespacep, trimAll, trimTrailingWhitespace public :: to_lower @@ -84,6 +85,11 @@ module PF_StringUtilities & KEEP_ALL =WhitespaceOptions(KEEP_ALL_), & & IGNORE_DIFFERENCES =WhitespaceOptions(IGNORE_DIFFERENCES_) + + interface operator(==) + module procedure equal_whitespace_options + end interface operator(==) + contains function toString_complex64Scalar(value) result(string) @@ -315,4 +321,9 @@ function to_lower(string) result(converted_string) end do end function to_lower + elemental logical function equal_whitespace_options(lhs, rhs) + type(WhitespaceOptions), intent(in) :: lhs, rhs + equal_whitespace_options = (lhs%value == rhs%value) + end function equal_whitespace_options + end module PF_StringUtilities diff --git a/tests/funit-core/CMakeLists.txt b/tests/funit-core/CMakeLists.txt index ee6e14d7..0207e908 100644 --- a/tests/funit-core/CMakeLists.txt +++ b/tests/funit-core/CMakeLists.txt @@ -72,7 +72,7 @@ endif () add_library (funit_tests STATIC ${test_srcs}) target_link_libraries(funit_tests other_shared) -#add_pfunit_sources (new_test_srcs ${pf_tests}) +add_pfunit_sources (new_test_srcs ${pf_tests}) #add_library(new_stests EXCLUDE_FROM_ALL ${new_test_srcs}) #target_link_libraries(new_stests other_shared) diff --git a/tests/funit-core/Test_AssertString.pf b/tests/funit-core/Test_AssertString.pf index ef52c75a..72a2c2c8 100644 --- a/tests/funit-core/Test_AssertString.pf +++ b/tests/funit-core/Test_AssertString.pf @@ -261,6 +261,31 @@ contains call assertEqual(expected=" ", found=" ", & & whitespace=IGNORE_ALL ) end subroutine testAssertEqualNonzeroBlanks4 - + + @test + subroutine testAssertEqualArray + call assertEqual(expected=['a','b'], found=['a','b']) + call assertEqual(expected='a', found=['a','a','a']) + call assertEqual(expected='a', found=['a','a','a']) + end subroutine testAssertEqualArray + + @test + subroutine testAssertEqualArray_fail_nonconformable + call assertEqual(expected=['a'], found=['a','a']) + call assertExceptionRaised( & + 'Arrays not conformable failure:' // new_line('A') // & + ' Expected shape: [1]' // new_line('A') // & + ' Actual shape: [2]') + end subroutine testAssertEqualArray_fail_nonconformable + + @test + subroutine testAssertEqualArray_fail_mismatch + call assertEqual(expected=['a','b'], found=['a','c']) + call assertExceptionRaised( & + 'String assertion failed:' // new_line('A') // & + ' expected: <"b">' // new_line('A') // & + ' but found: <"c">' // new_line('A') // & + ' first diff: ^') + end subroutine testAssertEqualArray_fail_mismatch end module Test_AssertString From 8c50504fbfe6a85e86232c3ffb9bcdcd3f10178d Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Mon, 28 Nov 2022 14:52:04 -0500 Subject: [PATCH 02/16] Add changelog enforcer --- .github/workflows/changelog-enforcer.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/changelog-enforcer.yml diff --git a/.github/workflows/changelog-enforcer.yml b/.github/workflows/changelog-enforcer.yml new file mode 100644 index 00000000..3643f7f4 --- /dev/null +++ b/.github/workflows/changelog-enforcer.yml @@ -0,0 +1,22 @@ +name: "Enforce Changelog" +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled] + +jobs: + # Enforces the update of a changelog file on every pull request + changelog: + runs-on: ubuntu-latest + steps: + - uses: dangoslen/changelog-enforcer@v3 + with: + changeLogPath: 'ChangeLog.md' + skipLabels: 'skip changelog' + missingUpdateErrorMessage: > + No update to ChangeLog.md found! Please add a changelog + entry to it describing your change. Please note that the + keepachangelog (https://keepachangelog.com) format is + used. If your change is very trivial not applicable for a + changelog entry, add a 'Skip Changelog' label to the pull + request to skip the changelog enforcer. + From 805624b48fb6ebd321f4b58e47fbd9b93cb58e39 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Mon, 28 Nov 2022 14:59:20 -0500 Subject: [PATCH 03/16] Update changelog --- .github/workflows/changelog-enforcer.yml | 2 +- ChangeLog.md | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/changelog-enforcer.yml b/.github/workflows/changelog-enforcer.yml index 3643f7f4..6f012b3e 100644 --- a/.github/workflows/changelog-enforcer.yml +++ b/.github/workflows/changelog-enforcer.yml @@ -17,6 +17,6 @@ jobs: entry to it describing your change. Please note that the keepachangelog (https://keepachangelog.com) format is used. If your change is very trivial not applicable for a - changelog entry, add a 'Skip Changelog' label to the pull + changelog entry, add a 'skip changelog' label to the pull request to skip the changelog enforcer. diff --git a/ChangeLog.md b/ChangeLog.md index 101fdd97..ee2793c1 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix GitHub CI workflow by pinning to CMake 3.24.3 +### Added + +- Added changelog enforcer GitHub Action + ## [4.6.1] - 2022-11-15 ### Fixed From 724f1539666fcbb05f99cf4132506020ab46583a Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Mon, 28 Nov 2022 18:58:51 -0500 Subject: [PATCH 04/16] add_definitions => add_compile_definitions. No -D to generalize across compilers. --- cmake/CheckFortranSource.cmake | 4 ++-- cmake/GNU.cmake | 2 +- cmake/Intel.cmake | 6 +++--- cmake/NAG.cmake | 2 +- cmake/XL.cmake | 3 +-- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/cmake/CheckFortranSource.cmake b/cmake/CheckFortranSource.cmake index d158de7b..45036014 100644 --- a/cmake/CheckFortranSource.cmake +++ b/cmake/CheckFortranSource.cmake @@ -23,7 +23,7 @@ function (CHECK_FORTRAN_SOURCE_RUN file var) set(${var} ${${var}} CACHE STRING "" FORCE) endif() - add_definitions(-D${var}=${${var}}) + add_compile_definitions(${var}=${${var}}) endfunction (CHECK_FORTRAN_SOURCE_RUN) @@ -50,5 +50,5 @@ function (CHECK_FORTRAN_SOURCE_COMPILE file var) set(${var} ${${var}} CACHE STRING "" FORCE) endif() - add_definitions(-D${var}) + add_compile_definitions(${var}) endfunction (CHECK_FORTRAN_SOURCE_COMPILE) diff --git a/cmake/GNU.cmake b/cmake/GNU.cmake index efdf1bfe..f97f84da 100644 --- a/cmake/GNU.cmake +++ b/cmake/GNU.cmake @@ -14,4 +14,4 @@ endif () set(CMAKE_Fortran_FLAGS_DEBUG "-g ${common_flags} ${traceback}") set(CMAKE_Fortran_FLAGS_RELEASE "${common_flags}") -add_definitions(-D_GNU) +add_compile_definitions(_GNU) diff --git a/cmake/Intel.cmake b/cmake/Intel.cmake index 3dbbea8a..b8bfbe05 100644 --- a/cmake/Intel.cmake +++ b/cmake/Intel.cmake @@ -7,7 +7,7 @@ else() set(no_optimize "-O0") set(check_all "-check all") endif() - + set(disable_warning_for_long_names "-diag-disable 5462") set(traceback "-traceback") @@ -18,5 +18,5 @@ set(common_flags "${cpp} ${disable_warning_for_long_names}") set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -g ${common_flags} ${traceback} ${no_optimize} ${check_all}") set(CMAKE_Fortran_FLAGS_RELEASE "-O3 ${common_flags}") -add_definitions(-D_INTEL) -add_definitions(-D__ifort_18) +add_compile_definitions(_INTEL) +add_compile_definitions(__ifort_18) diff --git a/cmake/NAG.cmake b/cmake/NAG.cmake index 4d791340..e7835fd9 100644 --- a/cmake/NAG.cmake +++ b/cmake/NAG.cmake @@ -12,4 +12,4 @@ set(common_flags "${cpp} -w=x95") set(CMAKE_Fortran_FLAGS_DEBUG "${common_flags} -O0 ${check_all} ${traceback}") set(CMAKE_Fortran_FLAGS_RELEASE ${common_flags}) -add_definitions(-D_NAG) +add_compile_definitions(_NAG) diff --git a/cmake/XL.cmake b/cmake/XL.cmake index 76373048..f0403229 100644 --- a/cmake/XL.cmake +++ b/cmake/XL.cmake @@ -8,5 +8,4 @@ set(CMAKE_Fortran_FLAGS_DEBUG "-O0") set(CMAKE_Fortran_FLAGS_RELEASE "-O3") set(CMAKE_Fortran_FLAGS "-g ${cpp} ${check_all}") -add_definitions(-DIBM) - +add_compile_definitions(IBM) From b1ea619e90419933571779eab7cd5aa7de7cf4a4 Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Mon, 28 Nov 2022 19:04:46 -0500 Subject: [PATCH 05/16] add_test: use modern syntax --- bin/CMakeLists.txt | 4 ++-- bin/tests/CMakeLists.txt | 15 ++++++++------- tests/pfunit/CMakeLists.txt | 4 ++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/bin/CMakeLists.txt b/bin/CMakeLists.txt index ee4c8454..fc881408 100644 --- a/bin/CMakeLists.txt +++ b/bin/CMakeLists.txt @@ -3,6 +3,6 @@ add_subdirectory(tests) install(PROGRAMS funitproc DESTINATION ${dest}/bin) -add_test(unit_test_processor - ${Python_EXECUTABLE} -m unittest discover +add_test(NAME unit_test_processor + COMMAND ${Python_EXECUTABLE} -m unittest discover --start-directory=${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/bin/tests/CMakeLists.txt b/bin/tests/CMakeLists.txt index 38163683..221ad971 100644 --- a/bin/tests/CMakeLists.txt +++ b/bin/tests/CMakeLists.txt @@ -3,7 +3,7 @@ file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/outputs) file(GLOB test_cases RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/inputs ${CMAKE_CURRENT_SOURCE_DIR}/inputs/*.pf) -foreach( case ${test_cases}) +foreach(case IN LISTS test_cases) get_filename_component(name ${case} NAME_WE) set(input_file "${CMAKE_CURRENT_SOURCE_DIR}/inputs/${name}.pf") @@ -12,11 +12,12 @@ foreach( case ${test_cases}) get_filename_component(executable_file "${CMAKE_CURRENT_SOURCE_DIR}/../funitproc" REALPATH) - add_test(processor_test_${name} ${CMAKE_COMMAND} - -D Python_EXECUTABLE=${Python_EXECUTABLE} - -D executable_file=${executable_file} - -D input_file=${input_file} - -D output_file=${output_file} - -D expected_file=${expected_file} + add_test(NAME processor_test_${name} + COMMAND ${CMAKE_COMMAND} + -DPython_EXECUTABLE=${Python_EXECUTABLE} + -Dexecutable_file=${executable_file} + -Dinput_file=${input_file} + -Doutput_file=${output_file} + -Dexpected_file=${expected_file} -P ${CMAKE_CURRENT_SOURCE_DIR}/run-test.cmake) endforeach() diff --git a/tests/pfunit/CMakeLists.txt b/tests/pfunit/CMakeLists.txt index 258411ef..c522cb06 100644 --- a/tests/pfunit/CMakeLists.txt +++ b/tests/pfunit/CMakeLists.txt @@ -60,13 +60,13 @@ if (NOT MPI_USE_MPIEXEC) endif() add_test(NAME mpi-tests - COMMAND ${MPIEXEC} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} 4 ./parallel_tests.x + COMMAND ${MPIEXEC} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} 4 $ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) add_dependencies(build-tests parallel_tests.x) add_test(NAME new_ptests - COMMAND ${MPIEXEC} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} 4 ./new_ptests.x + COMMAND ${MPIEXEC} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} 4 $ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) set_property (TEST new_ptests From 4d02d72873b6bd8552ebfc6a5ec5a2d7a9db0de9 Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Mon, 28 Nov 2022 19:07:18 -0500 Subject: [PATCH 06/16] foreach: use IN [ITEMS,LISTS] for clarity and robustness --- include/add_pfunit_sources.cmake | 14 ++++++-------- src/funit/CMakeLists.txt | 2 +- src/funit/asserts/CMakeLists.txt | 2 +- src/pfunit/CMakeLists.txt | 4 ++-- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/include/add_pfunit_sources.cmake b/include/add_pfunit_sources.cmake index 1fb787da..a6722a19 100644 --- a/include/add_pfunit_sources.cmake +++ b/include/add_pfunit_sources.cmake @@ -27,13 +27,13 @@ function( ADD_PFUNIT_SOURCES out_var ) set( out_files ) - foreach( file ${ARGN} ) + foreach( file IN LISTS ARGN ) get_filename_component (basename "${file}" NAME_WE) get_filename_component( abs_file "${file}" ABSOLUTE ) - + # replace the extension with .F90 to determine the output file name - + if (IS_ABSOLUTE ${file}) # it is in build tree, and out_file is sibling get_filename_component (file_dir "${file}" DIRECTORY BASE_DIR ${CMAKE_CURRENT_BINARY_DIR}) @@ -56,19 +56,17 @@ function( ADD_PFUNIT_SOURCES out_var ) # append the output file to the list of outputs list( APPEND out_files "${out_file}" ) - + # now add the custom command to generate the output file add_custom_command( OUTPUT "${out_file}" COMMAND ${PFUNIT_PARSER} "${abs_file}" "${out_file}" DEPENDS "${abs_file}" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) - + endforeach ( ) - + # set the output list in the calling scope set( ${out_var} ${${out_var}} ${out_files} PARENT_SCOPE ) endfunction( ADD_PFUNIT_SOURCES ) - - diff --git a/src/funit/CMakeLists.txt b/src/funit/CMakeLists.txt index 25ee8501..b88cf93b 100644 --- a/src/funit/CMakeLists.txt +++ b/src/funit/CMakeLists.txt @@ -79,7 +79,7 @@ if (BUILD_SHARED_LIBS) list(APPEND funit_targets funit_shared) endif() -foreach(funit_target ${funit_targets}) +foreach(funit_target IN LISTS funit_targets) set_funit_target_properties(${funit_target}) funit_target_link_pfunit(${funit_target}) diff --git a/src/funit/asserts/CMakeLists.txt b/src/funit/asserts/CMakeLists.txt index a94553ee..20ed13e0 100644 --- a/src/funit/asserts/CMakeLists.txt +++ b/src/funit/asserts/CMakeLists.txt @@ -18,7 +18,7 @@ function (expand in out) ) endfunction() -foreach(type Logical Integer Real Complex) +foreach(type IN ITEMS Logical Integer Real Complex) foreach(rank RANGE ${MAX_ASSERT_RANK}) expand (${CMAKE_CURRENT_SOURCE_DIR}/Assert_${type}.tmpl Assert${type}_${rank}d.F90) endforeach() diff --git a/src/pfunit/CMakeLists.txt b/src/pfunit/CMakeLists.txt index 8e0d4b6a..caeeeea8 100644 --- a/src/pfunit/CMakeLists.txt +++ b/src/pfunit/CMakeLists.txt @@ -23,8 +23,8 @@ endif() add_subdirectory (core) -foreach(pfunit_target ${pfunit_targets}) - set_target_properties (${pfunit_target} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod) +foreach(pfunit_target IN LISTS pfunit_targets) + set_property (TARGET ${pfunit_target} PROPERTY Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod) target_include_directories (${pfunit_target} PUBLIC ${MPI_Fortran_INCLUDE_PATH}) From b047847b9b92ddf43a2d2442214a6aa6dc97269d Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Mon, 28 Nov 2022 19:09:57 -0500 Subject: [PATCH 07/16] correct use of if() to compare string, not variable then string --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f80a425..87bac5b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,7 +106,7 @@ if (NOT SKIP_OPENMP) message (STATUS "OpenMP not found - skipping openmp support.") endif() # Kludge to workaround cmake+NAG+openmp linkage problem - if (CMAKE_Fortran_COMPILER_ID MATCHES NAG) + if (CMAKE_Fortran_COMPILER_ID STREQUAL "NAG") set_property(TARGET OpenMP::OpenMP_Fortran PROPERTY INTERFACE_LINK_LIBRARIES "") set_property(TARGET OpenMP::OpenMP_Fortran PROPERTY INTERFACE_LINK_OPTIONS "-openmp") From c2104332ed38a5b0b96246ce4fd4ed193d10d1ce Mon Sep 17 00:00:00 2001 From: Leonard Reuter <35964644+Leonard-Reuter@users.noreply.github.com> Date: Tue, 15 Nov 2022 16:22:39 +0100 Subject: [PATCH 08/16] Added option to set labels to ctests. --- include/add_pfunit_ctest.cmake | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/add_pfunit_ctest.cmake b/include/add_pfunit_ctest.cmake index 5a7b34fa..a536d5b8 100644 --- a/include/add_pfunit_ctest.cmake +++ b/include/add_pfunit_ctest.cmake @@ -15,6 +15,7 @@ # EXTRA_USE ... # EXTRA_INITIALIZE ... # EXTRA_FINALIZE ... +# LABELS ... # MAX_PES 5 # WORKING_DIRECTORY working_directory # ) @@ -45,7 +46,7 @@ include (add_pfunit_sources) function (add_pfunit_ctest test_package_name) set (oneValueArgs REGISTRY MAX_PES EXTRA_USE EXTRA_INITIALIZE EXTRA_FINALIZE WORKING_DIRECTORY) - set (multiValueArgs TEST_SOURCES OTHER_SOURCES LINK_LIBRARIES) + set (multiValueArgs TEST_SOURCES OTHER_SOURCES LINK_LIBRARIES LABELS) cmake_parse_arguments (PF_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) set (test_sources_f90) @@ -148,4 +149,10 @@ function (add_pfunit_ctest test_package_name) PROPERTY FAIL_REGULAR_EXPRESSION "Encountered 1 or more failures/errors during testing" ) + if (PF_TEST_LABELS) + set_property (TEST ${test_package_name} + PROPERTY LABELS ${PF_TEST_LABELS} + ) + endif() + endfunction() From 72f0fccbb9d54269bbb370808f52abe5e4599063 Mon Sep 17 00:00:00 2001 From: Leonard Reuter <35964644+Leonard-Reuter@users.noreply.github.com> Date: Tue, 15 Nov 2022 17:45:17 +0100 Subject: [PATCH 09/16] Made add_pfunit_ctest tests verbose. --- include/add_pfunit_ctest.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/add_pfunit_ctest.cmake b/include/add_pfunit_ctest.cmake index 5a7b34fa..56a1eb3d 100644 --- a/include/add_pfunit_ctest.cmake +++ b/include/add_pfunit_ctest.cmake @@ -134,13 +134,13 @@ function (add_pfunit_ctest test_package_name) endif() add_test (NAME ${test_package_name} WORKING_DIRECTORY ${workdir} - COMMAND ${MPIEXEC} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} ${PF_TEST_MAX_PES} ${CMAKE_CURRENT_BINARY_DIR}/${test_package_name} + COMMAND ${MPIEXEC} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} ${PF_TEST_MAX_PES} ${CMAKE_CURRENT_BINARY_DIR}/${test_package_name} --verbose ) else() target_link_libraries (${test_package_name} ${PFUNIT_SERIAL_LIBRARIES}) add_test (NAME ${test_package_name} WORKING_DIRECTORY ${workdir} - COMMAND ${test_package_name} + COMMAND ${test_package_name} --verbose ) endif() From 5f933fe6cc9a6ff60860bd16a64474e808ba6fcc Mon Sep 17 00:00:00 2001 From: Leonard Reuter Date: Tue, 29 Nov 2022 16:14:33 +0100 Subject: [PATCH 10/16] Added ChangeLog entry. --- ChangeLog.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 101fdd97..c07901f8 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -5,6 +5,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Added option to set labels to ctests + ### Fixed - Fix GitHub CI workflow by pinning to CMake 3.24.3 From 5a915d27968f93fa7d2fff8f361676c3d9b0259d Mon Sep 17 00:00:00 2001 From: Leonard Reuter Date: Tue, 29 Nov 2022 16:17:48 +0100 Subject: [PATCH 11/16] Added ChangeLog entry. --- ChangeLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog.md b/ChangeLog.md index 101fdd97..cb1372ec 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- `--verbose option` is now passed through by ctest runner - Fix GitHub CI workflow by pinning to CMake 3.24.3 ## [4.6.1] - 2022-11-15 From 2a433f25405fbc9c4dd22587ddc2e571cff6005c Mon Sep 17 00:00:00 2001 From: Leonard Reuter Date: Tue, 29 Nov 2022 16:44:28 +0100 Subject: [PATCH 12/16] Copied Intel.cmake to IntelLLVM.cmake. --- cmake/IntelLLVM.cmake | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 cmake/IntelLLVM.cmake diff --git a/cmake/IntelLLVM.cmake b/cmake/IntelLLVM.cmake new file mode 100644 index 00000000..3dbbea8a --- /dev/null +++ b/cmake/IntelLLVM.cmake @@ -0,0 +1,22 @@ +# Compiler specific flags for Intel Fortran compiler + +if(WIN32) + set(no_optimize "-Od") + set(check_all "-check:all") +else() + set(no_optimize "-O0") + set(check_all "-check all") +endif() + + +set(disable_warning_for_long_names "-diag-disable 5462") +set(traceback "-traceback") +set(cpp "-cpp") + + +set(common_flags "${cpp} ${disable_warning_for_long_names}") +set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -g ${common_flags} ${traceback} ${no_optimize} ${check_all}") +set(CMAKE_Fortran_FLAGS_RELEASE "-O3 ${common_flags}") + +add_definitions(-D_INTEL) +add_definitions(-D__ifort_18) From 986b192986d22e4f546de35a7151f1d930e5e945 Mon Sep 17 00:00:00 2001 From: Leonard Reuter Date: Tue, 29 Nov 2022 16:45:17 +0100 Subject: [PATCH 13/16] Added ChangeLog entry. --- ChangeLog.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 101fdd97..ec34d858 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -5,6 +5,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Added IntelLLVM.cmake to support ifx + ### Fixed - Fix GitHub CI workflow by pinning to CMake 3.24.3 From 0d2d9b10daf5ca0f1aee3f2d3063c0982ddffcd0 Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Mon, 28 Nov 2022 19:27:03 -0500 Subject: [PATCH 14/16] use CMake abstract build commands for clarity and simplicity --- .github/workflows/main.yml | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3834cd31..be075d28 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -91,22 +91,14 @@ jobs: ${FC} --version mpirun --version mpifort --show - - name: Build pFUnit - run: | - mkdir -p build - cd build - cmake .. - make - #make -j$(nproc) + - name: Configure pFUnit + run: cmake -Bbuild + - name: Build pfUnit + run: cmake --build build --parallel - name: Build Tests - run: | - cd build - make build-tests - #make -j$(nproc) build-tests + run: cmake --build build --parallel -t build-tests - name: Run Tests - run: | - cd build - ctest -j1 --output-on-failure --repeat until-pass:4 + run: ctest --test-dir build --parallel 1 --output-on-failure --repeat until-pass:4 --schedule-random - name: Archive log files on failure uses: actions/upload-artifact@v3 if: failure() @@ -148,20 +140,14 @@ jobs: ${CC} --version mpirun --version cmake --version - - name: Build pFUnit - run: | - mkdir -p build - cd build - cmake .. - make -j$(nproc) + - name: Configure pFUnit + run: cmake -Bbuild + - name: Build pfUnit + run: cmake --build build --parallel - name: Build Tests - run: | - cd build - make -j$(nproc) build-tests + run: cmake --build build --parallel -t build-tests - name: Run Tests - run: | - cd build - ctest -j1 --output-on-failure --repeat until-pass:4 + run: ctest --test-dir build --parallel 1 --output-on-failure --repeat until-pass:4 --schedule-random - name: Archive log files on failure uses: actions/upload-artifact@v3 if: failure() From e571413ed0f9b4489c9e1e166878447e25c06141 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Mon, 5 Dec 2022 15:21:00 -0500 Subject: [PATCH 15/16] Remove explicit CMake in CI --- .github/workflows/main.yml | 8 -------- ChangeLog.md | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index be075d28..dc9eff91 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -59,10 +59,6 @@ jobs: if: matrix.os == 'ubuntu-22.04' && matrix.compiler == 'gfortran-12' run: | sudo apt-get install gfortran-12 -y - # There is a bug between pFUnit and CMake 3.25.0 which is in ubuntu-latest. - # For now, we grab CMake 3.24.3 - - name: Get specific version CMake, v3.24.3 - uses: lukka/get-cmake@v3.24.3 - name: Compiler Versions run: | ${FC} --version @@ -119,10 +115,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - # There is a bug between pFUnit and CMake 3.25.0 which is in ubuntu-latest. - # For now, we grab CMake 3.24.3 - - name: Get specific version CMake, v3.24.3 - uses: lukka/get-cmake@v3.24.3 - name: Install Intel compilers run: | cd /tmp diff --git a/ChangeLog.md b/ChangeLog.md index 101fdd97..e00a4ff1 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- Fix GitHub CI workflow by pinning to CMake 3.24.3 +- Converted GitHub CI to use cmake abstract build commands ## [4.6.1] - 2022-11-15 From 3a7f6e19e0df3c4c780928c16718bedb97da3fdd Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Mon, 17 Apr 2023 10:24:30 -0400 Subject: [PATCH 16/16] Update to fArgParse v1.5.0 --- CMakeLists.txt | 2 +- ChangeLog.md | 6 ++++++ extern/fArgParse | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d853420b..b589f309 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,7 @@ cmake_minimum_required(VERSION 3.12) project (PFUNIT - VERSION 4.6.3 + VERSION 4.7.0 LANGUAGES Fortran C) # Determine if pFUnit is built as a subproject (using diff --git a/ChangeLog.md b/ChangeLog.md index 862beee1..c966dcf9 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -5,6 +5,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [4.7.0] - 2023-04-17 + +### Changed + +- Update fArgParse submodule to v1.5.0 + ### Added - Added IntelLLVM.cmake to support ifx diff --git a/extern/fArgParse b/extern/fArgParse index f7176689..cf0f1e10 160000 --- a/extern/fArgParse +++ b/extern/fArgParse @@ -1 +1 @@ -Subproject commit f71766897ca1fc5e119cd8bd315c8c72c6bea7d9 +Subproject commit cf0f1e10add5d8e1c7a1027e73dd58f782738350