Goddard-Fortran-Ecosystem / pFUnit

Parallel Fortran Unit Testing Framework
Other
173 stars 45 forks source link

Error adding test suite #298

Open SMijin opened 3 years ago

SMijin commented 3 years ago

I've recently noticed that my tests are not running and tracked the issue down to an empty TestSuites.inc file. After stripping my test cmake file to

project(test_failing Fortran)

file(GLOB pf_files "*.pf")

add_pfunit_ctest (${PROJECT_NAME} TEST_SOURCES ${pf_files} LINK_LIBRARIES ${MPI_Fortran_LIBRARIES} )

I now have a test_faling.inc file produced automatically with the necessary add suite line. However, when trying to make the test I get the following error:

test_failing.inc(1): error #7977: The type of the function reference does not match the type of the function definition. [FAILING_SUITE] call suite%addTest(failing_suite())

I couldn't find anyone with a similar error, and have spent the better part of an afternoon looking at the generated files fruitlessly. Am I missing something obvious?

For completeness, here's my top level CMakeLists.txt (and the test file is absolutely minimal so I've not included it here):

`cmake_minimum_required(VERSION 3.16)

project(add_suite_test Fortran)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
find_package(MPI REQUIRED)
find_package(Coarray REQUIRED)
find_package(PFUNIT)
add_definitions(${MPI_Fortran_COMPILE_FLAGS})
include_directories(${MPI_Fortran_INCLUDE_PATH})
link_directories(${MPI_Fortran_LIBRARIES})

# Check whether the user has selected a BUILD_TYPE
IF ("${CMAKE_BUILD_TYPE}" STREQUAL "")

    message(STATUS "Build type not explicitly set. Trying to guess...")
    get_filename_component(BINDIR ${PROJECT_BINARY_DIR} NAME)
    IF (${BINDIR} MATCHES "RELEASE")
        set(CMAKE_BUILD_TYPE "RELEASE")
        message(STATUS "Set to ${CMAKE_BUILD_TYPE}")
    ELSEIF(${BINDIR} MATCHES "DEBUG")
        set(CMAKE_BUILD_TYPE "DEBUG")
        message(STATUS "Set to ${CMAKE_BUILD_TYPE}")
    ELSE()
        message(WARNING "Unable to deduce build type. Use -DCMAKE_BUILD_TYPE=<RELEASE/DEBUG>")
    ENDIF(${BINDIR} MATCHES "RELEASE")

ELSE()
    message(STATUS "Build Type is ${CMAKE_BUILD_TYPE}")
ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")

set(CMAKE_Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/generated/mods)

include_directories(${CMAKE_Fortran_MODULE_DIRECTORY})
file(MAKE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY})

set(CMAKE_INSTALL_PREFIX ${PROJECT_BINARY_DIR})

# if DEBUG requested, set the various debug options.
IF(${CMAKE_BUILD_TYPE} MATCHES "DEBUG")
    set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} -O0")
    IF(${CMAKE_Fortran_COMPILER_ID} MATCHES "GNU")
        set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} -Wall -fcheck=all -fbacktrace -pedantic")
    ELSEIF(${CMAKE_Fortran_COMPILER_ID} MATCHES "Intel")
        set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} -warn all -check all -traceback -stand=f18")
    ELSE()
        message(WARNING "Unable to determine Compiler ID: ${CMAKE_Fortran_COMPILER_ID}")
    ENDIF(${CMAKE_Fortran_COMPILER_ID} MATCHES "GNU")
    message(STATUS "Debug flags for ${CMAKE_Fortran_COMPILER_ID}: ${CMAKE_Fortran_FLAGS_DEBUG}")
ENDIF(${CMAKE_BUILD_TYPE} MATCHES "DEBUG")

IF(${PFUNIT_FOUND})
    add_subdirectory(tests)
    enable_testing()
    # Add the tests below
    add_test(NAME test COMMAND test_failing)

ELSE()
    message(WARNING "pFUnit not installed, testing disabled")
ENDIF()`
SMijin commented 3 years ago

Looks like it's the -warn all flag. Removing it solves the problem. I'll have a look at the intel website, but I'd definitely prefer being able to toggle warnings.

tclune commented 3 years ago

I have been out of town for several days. I will try to look at this issue more closely over the coming weekend. But I agree there is some fragility in the construction of the .inc files that could possibly be improved. I usually have the luxury of just deleting my build tree and starting from scratch if I suspect a problem along these lines. Arises infrequently in practice, but may depend on other coding habits.