Commit 91fc7200 authored by Sebastian Müller's avatar Sebastian Müller 🐈
Browse files

pfUnit: add inital testing

parent f1290d47
......@@ -490,6 +490,21 @@ check-intel20MPI:
paths:
- check/logs/
unittest-gcc83:
when: always
stage: coverage
variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_RUNNER_SHORT_TOKEN/$CI_PROJECT_PATH/$CI_COMMIT_REF_NAME/$CI_JOB_NAME
needs:
- job: cmake-gcc83
script:
# we need pfUnit
- source moduleLoadScripts/eve.gcc83pfUnit
# run cmake with testing support
- cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON ..
# run all pfUnit tests
- make && make test
coverage-gcc73:
when: always
stage: coverage
......
module purge
module load foss/2019b
module load netCDF-Fortran
module load CMake
module use /global/apps/modulefiles
module load python_env_mpr
module load pFUnit/4.0.0_foss_2019b
export NETCDF_DIR="$EBROOTNETCDF"
export NETCDF_FORTRAN_DIR="$EBROOTNETCDFMINFORTRAN"
export FC=gfortran
......@@ -92,6 +92,10 @@ message(STATUS "mhm_lib compiler flags are: ${MAIN_CFLAGS}")
get_target_property(MAIN_CDEFS ${LIB_NAME} COMPILE_DEFINITIONS)
message(STATUS "mhm_lib compiler defs are: ${MAIN_CDEFS}")
# automatically enable testing (OFF by default)
option(BUILD_TESTING "" OFF)
include(CTest)
# add pfunit test folder
if(BUILD_TESTING)
add_subdirectory(./tests)
......
enable_testing()
set(LIB_NAME mhm_lib)
find_package(PFUNIT)
if(PFUNIT_FOUND)
set(pfunit_suffix ".pf")
file(GLOB testfiles ./*${pfunit_suffix})
foreach(file ${testfiles})
get_filename_component(testname ${file} NAME_WE)
add_pfunit_ctest(${testname}
TEST_SOURCES ${file}
LINK_LIBRARIES ${LIB_NAME}
)
endforeach()
else()
message(STATUS "No test program found, install PFUNIT")
endif()
module test_pet_priestly
use funit
use mo_pet, only : pet_priestly
use mo_kind, only : dp
implicit none
private
public :: test_priestly
contains
@test
subroutine test_priestly()
real(dp) :: reference = 4.978_dp
real(dp) :: calc_pet
calc_pet = pet_priestly(1.26_dp, 200.0_dp, 10.0_dp)
@assertEqual(reference, calc_pet, tolerance=0.001, message='PET Priestley-Taylor')
end subroutine test_priestly
end module test_pet_priestly
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment