diff --git a/.github/workflows/changelog-enforcer.yml b/.github/workflows/changelog-enforcer.yml new file mode 100644 index 00000000..6f012b3e --- /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. + diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3834cd31..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 @@ -91,22 +87,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() @@ -127,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 @@ -148,20 +132,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() diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d226e5f..f06d94a1 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) cmake_policy(SET CMP0077 NEW) @@ -108,7 +108,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") diff --git a/ChangeLog.md b/ChangeLog.md index b021ffc1..c966dcf9 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -5,6 +5,25 @@ 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 +- 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 option to set labels to ctests +- Added changelog enforcer GitHub Action + +### Fixed + +- `--verbose option` is now passed through by ctest runner +- Converted GitHub CI to use cmake abstract build commands + ## [4.6.3] - 2023-02-07 ### Fixed 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/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/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) 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) 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 diff --git a/include/add_pfunit_ctest.cmake b/include/add_pfunit_ctest.cmake index 34b94c10..25c44a39 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) @@ -144,13 +145,13 @@ function (add_pfunit_ctest test_package_name) endif() add_test (NAME ${test_package_name} WORKING_DIRECTORY ${workdir} - COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} ${PF_TEST_MAX_PES} ${CMAKE_CURRENT_BINARY_DIR}/${test_package_name} + COMMAND ${MPIEXEC_EXECUTABLE} ${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() @@ -158,4 +159,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() 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 4f6b2b7e..cecc0746 100644 --- a/src/funit/CMakeLists.txt +++ b/src/funit/CMakeLists.txt @@ -75,7 +75,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/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/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/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/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}) 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 diff --git a/tests/pfunit/CMakeLists.txt b/tests/pfunit/CMakeLists.txt index 8214856f..234e0b4e 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_EXECUTABLE} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} 4 ./parallel_tests.x + COMMAND ${MPIEXEC_EXECUTABLE} ${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_EXECUTABLE} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} 4 ./new_ptests.x + COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} 4 $ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) set_property (TEST new_ptests