Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 63 additions & 6 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,104 @@ env:

jobs:
build:
name: Build
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: true

- name: Cache pFUnit install
uses: actions/cache@v4
id: pfunit-cache
with:
path: pFUnit/build/installed
key: pfunit-${{ runner.os }}-${{ env.BUILD_TYPE }}-${{ hashFiles('.gitmodules', 'pFUnit/CMakeLists.txt') }}
restore-keys: |
pfunit-${{ runner.os }}-${{ env.BUILD_TYPE }}-

- name: Configure CMake pFUnit
if: steps.pfunit-cache.outputs.cache-hit != 'true'
# Configure pFUnit
run: cmake -S pFUnit -B ${{github.workspace}}/pFUnit/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DENABLE_OpenMP_SUPPORT=OFF -DENABLE_POSTGRESQL_SUPPORT=OFF

- name: Build pFUnit
if: steps.pfunit-cache.outputs.cache-hit != 'true'
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/pFUnit/build --config ${{env.BUILD_TYPE}}

- name: Install pFUnit
if: steps.pfunit-cache.outputs.cache-hit != 'true'
# install libs and includes in libslam/build/
run: cmake --install ${{github.workspace}}/pFUnit/build --config ${{env.BUILD_TYPE}}

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_PREFIX_PATH=${{github.workspace}}/pFUnit/build/installed/
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_PREFIX_PATH=${{github.workspace}}/pFUnit/build/installed/ -DENABLE_PFUNIT=ON

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- name: Test
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: libslam-build
path: build

test:
name: Test
needs: [build]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Cache pFUnit install
uses: actions/cache@v4
id: pfunit-cache
with:
path: pFUnit/build/installed
key: pfunit-${{ runner.os }}-${{ env.BUILD_TYPE }}-${{ hashFiles('.gitmodules', 'pFUnit/CMakeLists.txt') }}
restore-keys: |
pfunit-${{ runner.os }}-${{ env.BUILD_TYPE }}-

- name: Configure CMake pFUnit
if: steps.pfunit-cache.outputs.cache-hit != 'true'
run: cmake -S pFUnit -B ${{github.workspace}}/pFUnit/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DENABLE_OpenMP_SUPPORT=OFF -DENABLE_POSTGRESQL_SUPPORT=OFF

- name: Build pFUnit
if: steps.pfunit-cache.outputs.cache-hit != 'true'
run: cmake --build ${{github.workspace}}/pFUnit/build --config ${{env.BUILD_TYPE}}

- name: Install pFUnit
if: steps.pfunit-cache.outputs.cache-hit != 'true'
run: cmake --install ${{github.workspace}}/pFUnit/build --config ${{env.BUILD_TYPE}}

- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: libslam-build
path: build

- name: Restore execute permissions on build artifact
run: chmod -R a+x build

- name: Run tests
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C ${{env.BUILD_TYPE}} --verbose --output-junit ../test_report.xml

- name: Publish Test Report
uses: mikepenz/action-junit-report@v5
if: success() || failure() # always run even if the previous step fails
if: success() || failure()
with:
report_paths: '**/test_report.xml'
comment: true
Expand Down
6 changes: 3 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ elif [[ "$OSTYPE" == "msys"* ]]; then
LIBSUFFIX="dll"
GENERATOR_FLAGS="-G MSYS Makefiles"
fi
git submodule update --init --recursive
################################################################################
# #
# Build pFUnit #
# #
################################################################################
if [[ "$ENABLE_PFUNIT" == "ON" ]]; then
git submodule update --init --recursive || exit
cd pFUnit || exit
# Create the build directory if it does not exist
if [[ ! -d "build" ]]; then
Expand All @@ -43,7 +43,7 @@ if [[ "$ENABLE_PFUNIT" == "ON" ]]; then
fi
cd build || exit
echo "Updating cmake"
export PFUNIT_DIR=..//pFUnit/build/installed
export PFUNIT_DIR=../pFUnit/build/installed
export FC=$Fortran_COMPILER
cmake -DSKIP_MPI=yes "$GENERATOR_FLAGS" ../
echo "Building pFUnit"
Expand Down Expand Up @@ -82,4 +82,4 @@ cd ../ || exit
ln -sf build/include include || exit
ln -sf build/lib lib || exit
echo "Leaving libslam"
echo "Done with $BUILD_TYPE build"
echo "Done with $BUILD_TYPE build"
2 changes: 1 addition & 1 deletion pFUnit
Submodule pFUnit updated 60 files
+232 −43 .github/workflows/main.yml
+2 −1 .gitignore
+20 −15 CMakeLists.txt
+138 −0 ChangeLog.md
+6 −5 README.md
+44 −44 bin/funit/pFUnitParser.py
+10 −2 bin/funitproc
+2 −2 bin/tests/inputs/MpiParameterizedTestCaseC.pf
+2 −2 bin/tests/inputs/MpiTestCaseB.pf
+2 −2 bin/tests/inputs/ParameterizedTestCaseB.pf
+2 −2 bin/tests/inputs/TestA.pf
+2 −2 bin/tests/inputs/TestCaseA.pf
+14 −0 cmake/Fujitsu.cmake
+1 −1 cmake/IntelLLVM.cmake
+7 −0 cmake/LLVMFlang.cmake
+1 −1 cmake/NAG.cmake
+2 −2 cmake/build_submodule.cmake
+ documentation/pFUnit3-ReferenceManual.pdf
+1 −1 extern/fArgParse
+13 −6 include/add_pfunit_ctest.cmake
+5 −1 include/add_pfunit_test.cmake
+3 −5 include/driver.F90
+3 −5 include/driver.F90.in
+15 −8 src/funit/CMakeLists.txt
+20 −11 src/funit/FUnit.F90
+12 −0 src/funit/asserts/AssertBasic.F90
+1 −1 src/funit/asserts/Assert_Real.tmpl
+3 −1 src/funit/asserts/CMakeLists.txt
+5 −5 src/funit/core/AbstractPattern.F90
+6 −0 src/funit/core/CMakeLists.txt
+4 −3 src/funit/core/ExceptionList.F90
+5 −5 src/funit/core/ExceptionVector.F90
+3 −3 src/funit/core/FUnit_Core.F90
+6 −1 src/funit/core/RemoteRunner.F90
+6 −1 src/funit/core/RobustRunner.F90
+7 −8 src/funit/core/TestAnnotation.F90
+9 −4 src/funit/core/TestFailureVector.F90
+5 −5 src/funit/core/TestListenerVector.F90
+31 −19 src/funit/core/TestSuite.F90
+5 −5 src/funit/core/TestVector.F90
+3 −0 src/funit/core/XmlPrinter.F90
+2 −2 src/funit/fhamcrest/AllOf.F90
+2 −2 src/funit/fhamcrest/AnyOf.F90
+1 −1 src/funit/fhamcrest/BaseDescription.F90
+1 −1 src/funit/fhamcrest/CMakeLists.txt
+29 −18 src/funit/fhamcrest/Every.F90
+11 −10 src/funit/fhamcrest/MatcherVector.F90
+10 −10 src/funit/fhamcrest/SelfDescribingVector.F90
+3 −1 src/pfunit/CMakeLists.txt
+10 −3 src/pfunit/core/pFUnit.F90
+8 −10 src/pfunit/pFUnit.F90
+1 −1 tests/fhamcrest/CMakeLists.txt
+32 −8 tests/fhamcrest/Test_IsEqual.pf
+1 −1 tests/funit-core/CMakeLists.txt
+3 −2 tests/funit-core/Test_DisableTest.pf
+66 −4 tests/funit-core/Test_TestSuite.F90
+5 −2 tests/funit-core/Test_XmlPrinter.F90
+1 −1 tests/funit-core/robustTestSuite.F90
+1 −1 tools/ci-install-mpi.sh
+11 −11 tools/overload_template.py
8 changes: 8 additions & 0 deletions pFUnittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,11 @@ LINK_LIBRARIES slam-Fortran)
add_pfunit_ctest (slam_strings_test
TEST_SOURCES test_slamstrings.pf
LINK_LIBRARIES slam-Fortran)

add_pfunit_ctest (slam_error_handling_test
TEST_SOURCES test_slam_error_handling.pf
LINK_LIBRARIES slam-Fortran)

add_pfunit_ctest (slam_io_test
TEST_SOURCES test_slam_io.pf
LINK_LIBRARIES slam-Fortran)
106 changes: 106 additions & 0 deletions pFUnittests/test_slam_error_handling.pf
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
!==============================================================================
!
!> @anchor test_slam_error_handling
!!
!> @brief pFUnit tests for slam_error_handling (language/verbosity, setError, compile_log_record)
!!
!------------------------------------------------------------------------
module test_slam_error_handling
use funit
use slam_error_handling
implicit none

! Language constants (match module: 1=ENGLISH, 2=GERMAN)
integer, parameter :: LANG_ENGLISH = 1
integer, parameter :: LANG_GERMAN = 2

contains

@test
subroutine test_setErrorLanguage_getErrorLanguage()
integer :: prev
prev = setErrorLanguage(LANG_GERMAN)
@assertEqual(LANG_GERMAN, getErrorLanguage())
prev = setErrorLanguage(LANG_ENGLISH)
@assertEqual(LANG_ENGLISH, getErrorLanguage())
end subroutine test_setErrorLanguage_getErrorLanguage

@test
subroutine test_setCliVerbosity_getCliVerbosity()
integer :: junk
junk = setCliVerbosity(WARNINGS)
@assertEqual(WARNINGS, getCliVerbosity())
junk = setCliVerbosity(ERRORS)
@assertEqual(ERRORS, getCliVerbosity())
end subroutine test_setCliVerbosity_getCliVerbosity

@test
subroutine test_setLogVerbosity_getLogVerbosity()
integer :: junk
junk = setLogVerbosity(REMARKS)
@assertEqual(REMARKS, getLogVerbosity())
junk = setLogVerbosity(QUIET)
@assertEqual(QUIET, getLogVerbosity())
end subroutine test_setLogVerbosity_getLogVerbosity

@test
subroutine test_setError_report_updates_latest_error()
call initErrorHandler(errAction='REPORT')
call setError(E_FILE_NOT_FOUND, WARNING, errorMessage='test message')
@assertEqual(E_FILE_NOT_FOUND, getLatestError())
@assertEqual(WARNING, getLatestErrorType())
end subroutine test_setError_report_updates_latest_error

@test
subroutine test_setError_fatal_hasFailed()
call initErrorHandler(errAction='REPORT')
call setError(E_FILE_NOT_FOUND, FATAL, errorMessage='fatal test')
@assertEqual(FATAL, getLatestErrorType())
@assertTrue(hasFailed())
end subroutine test_setError_fatal_hasFailed

@test
subroutine test_setError_remark_type()
call initErrorHandler(errAction='REPORT')
call setError(E_STRING_LENGTH, REMARK, errorMessage='remark')
@assertEqual(E_STRING_LENGTH, getLatestError())
@assertEqual(REMARK, getLatestErrorType())
end subroutine test_setError_remark_type

@test
subroutine test_setError_debug_msg_type()
call initErrorHandler(errAction='REPORT')
call setError(E_UNKNOWN_PARAMETER, DEBUG_MSG, errorMessage='debug')
@assertEqual(E_UNKNOWN_PARAMETER, getLatestError())
@assertEqual(DEBUG_MSG, getLatestErrorType())
end subroutine test_setError_debug_msg_type

@test
subroutine test_resetError_clears_latest()
call initErrorHandler(errAction='REPORT')
call setError(E_FILE_NOT_FOUND, WARNING, errorMessage='x')
call resetError()
@assertEqual(0, getLatestError())
@assertEqual(ERR_UNDEFINED, getLatestErrorType())
end subroutine test_resetError_clears_latest

@test
subroutine test_compile_log_record_format()
character(len=23) :: timestamp
character(len=1024) :: rec
timestamp = '2024-01-15 10:30:00.000'
rec = compile_log_record(timestamp, 2, ' - ', 'test message')
@assertTrue(len_trim(rec) > 0)
@assertTrue(index(trim(rec), '2024-01-15') > 0)
@assertTrue(index(trim(rec), 'WARNING') > 0)
@assertTrue(index(trim(rec), 'test message') > 0)
end subroutine test_compile_log_record_format

@test
subroutine test_getErrorMessage_returns_message()
character(len=512) :: msg
call getErrorMessage(E_FILE_NOT_FOUND, msg)
@assertTrue(len_trim(msg) > 0)
end subroutine test_getErrorMessage_returns_message

end module test_slam_error_handling
Loading