@@ -452,6 +452,40 @@ function(caf_compile_executable target main_depend)
452452 DEPENDS "${target} " )
453453endfunction (caf_compile_executable)
454454
455+ enable_testing ()
456+
457+ #--------------------------------------------------------
458+ # Setup shellcheck if present for testing/linting scripts
459+ #--------------------------------------------------------
460+ find_program (SHELLCHECK_EXE shellcheck
461+ DOC "Path to shellcheck executable for linting scripts"
462+ )
463+ if (CAF_RUN_DEVELOPER_TESTS OR $ENV{OPENCOARRAYS_DEVELOPER} )
464+ if (NOT SHELLCHECK_EXE)
465+ message ( AUTHOR_WARNING "OpenCoarrays developers should install shellcheck to test/lint all shell scripts.
466+ See https://github.com/koalaman/shellcheck#installing for info on obtaining shellcheck." )
467+ endif ()
468+ endif ()
469+
470+ function (lint_script script_dir script_name)
471+ if (SHELLCHECK_EXE)
472+ add_test (NAME "shellcheck:${script_name} "
473+ COMMAND ${SHELLCHECK_EXE} -x "${script_dir} /${script_name} "
474+ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR} " )
475+ elseif (CAF_RUN_DEVELOPER_TESTS OR $ENV{OPENCOARRAYS_DEVELOPER} )
476+ message ( AUTHOR_WARNING "test: shellcheck:${script_name} not run because shellcheck not installed." )
477+ endif ()
478+ endfunction ()
479+
480+ #-----------------------------------------------
481+ # Setup script style testing & enforcement macro
482+ #-----------------------------------------------
483+
484+ function (check_script_style script_full_path)
485+ add_test (NAME "style:${script_full_path} "
486+ COMMAND "${CMAKE_SOURCE_DIR} /developer-scripts/style.pl" "${script_full_path} " )
487+ endfunction ()
488+
455489#-------------------------------
456490# Recurse into the src directory
457491#-------------------------------
@@ -499,8 +533,6 @@ configure_file ( "${CMAKE_SOURCE_DIR}/cmake/uninstall.cmake.in" "${CMAKE_BINARY_
499533add_custom_target ( uninstall
500534 COMMAND ${CMAKE_COMMAND} -P "${CMAKE_BINARY_DIR} /uninstall.cmake" )
501535
502- enable_testing ()
503-
504536add_custom_target (check COMMAND ${CMAKE_CTEST_COMMAND} --output -on -failure)
505537# See JSON-Fortran's CMakeLists.txt file to find out how to get the check target to depend
506538# on the test executables
0 commit comments