From 3009e52a15d6bce9b62836afdc0f12ed509cbab6 Mon Sep 17 00:00:00 2001 From: xfiderek Date: Wed, 13 Mar 2024 20:00:42 +0100 Subject: [PATCH] Add AMENT_LINT_AUTO_SKIP_PREEXISTING_TESTS flag (space-ros/space-ros#57). Signed-off-by: xfiderek --- ament_cmake_clang_format/cmake/ament_clang_format.cmake | 9 +++++++++ ament_cmake_clang_tidy/cmake/ament_clang_tidy.cmake | 9 +++++++++ ament_cmake_copyright/cmake/ament_copyright.cmake | 9 +++++++++ ament_cmake_cppcheck/cmake/ament_cppcheck.cmake | 9 +++++++++ ament_cmake_cpplint/cmake/ament_cpplint.cmake | 9 +++++++++ ament_cmake_flake8/cmake/ament_flake8.cmake | 9 +++++++++ ament_cmake_lint_cmake/cmake/ament_lint_cmake.cmake | 9 +++++++++ ament_cmake_mypy/cmake/ament_mypy.cmake | 9 +++++++++ ament_cmake_pclint/cmake/ament_pclint.cmake | 9 +++++++++ ament_cmake_pep257/cmake/ament_pep257.cmake | 9 +++++++++ ament_cmake_pycodestyle/cmake/ament_pycodestyle.cmake | 9 +++++++++ ament_cmake_pyflakes/cmake/ament_pyflakes.cmake | 9 +++++++++ ament_cmake_uncrustify/cmake/ament_uncrustify.cmake | 9 +++++++++ ament_cmake_xmllint/cmake/ament_xmllint.cmake | 9 +++++++++ 14 files changed, 126 insertions(+) diff --git a/ament_cmake_clang_format/cmake/ament_clang_format.cmake b/ament_cmake_clang_format/cmake/ament_clang_format.cmake index de56c61c..7088724e 100644 --- a/ament_cmake_clang_format/cmake/ament_clang_format.cmake +++ b/ament_cmake_clang_format/cmake/ament_clang_format.cmake @@ -39,6 +39,15 @@ function(ament_clang_format) set(ARG_TESTNAME "clang_format") endif() + # https://cmake.org/cmake/help/latest/prop_dir/TESTS.html + get_directory_property(_declared_tests TESTS) + if(DEFINED AMENT_LINT_AUTO_SKIP_PREEXISTING_TESTS) + if((AMENT_LINT_AUTO_SKIP_PREEXISTING_TESTS) AND (${ARG_TESTNAME} IN_LIST _declared_tests)) + message(VERBOSE "skipping test '${ARG_TESTNAME}' as it has already been added") + return() + endif() + endif() + find_program(ament_clang_format_BIN NAMES "ament_clang_format") if(NOT ament_clang_format_BIN) message(FATAL_ERROR "ament_clang_format() variable 'ament_clang_format_BIN' must not be empty") diff --git a/ament_cmake_clang_tidy/cmake/ament_clang_tidy.cmake b/ament_cmake_clang_tidy/cmake/ament_clang_tidy.cmake index 5576ca5d..bd1c577f 100644 --- a/ament_cmake_clang_tidy/cmake/ament_clang_tidy.cmake +++ b/ament_cmake_clang_tidy/cmake/ament_clang_tidy.cmake @@ -40,6 +40,15 @@ function(ament_clang_tidy) set(ARG_TESTNAME "clang_tidy") endif() + # https://cmake.org/cmake/help/latest/prop_dir/TESTS.html + get_directory_property(_declared_tests TESTS) + if(DEFINED AMENT_LINT_AUTO_SKIP_PREEXISTING_TESTS) + if((AMENT_LINT_AUTO_SKIP_PREEXISTING_TESTS) AND (${ARG_TESTNAME} IN_LIST _declared_tests)) + message(VERBOSE "skipping test '${ARG_TESTNAME}' as it has already been added") + return() + endif() + endif() + find_program(ament_clang_tidy_BIN NAMES "ament_clang_tidy") if(NOT ament_clang_tidy_BIN) message(FATAL_ERROR "ament_clang_tidy() variable 'ament_clang_tidy_BIN' must not be empty") diff --git a/ament_cmake_copyright/cmake/ament_copyright.cmake b/ament_cmake_copyright/cmake/ament_copyright.cmake index 485a022c..459df19b 100644 --- a/ament_cmake_copyright/cmake/ament_copyright.cmake +++ b/ament_cmake_copyright/cmake/ament_copyright.cmake @@ -33,6 +33,15 @@ function(ament_copyright) set(ARG_TIMEOUT 120) endif() + # https://cmake.org/cmake/help/latest/prop_dir/TESTS.html + get_directory_property(_declared_tests TESTS) + if(DEFINED AMENT_LINT_AUTO_SKIP_PREEXISTING_TESTS) + if((AMENT_LINT_AUTO_SKIP_PREEXISTING_TESTS) AND (${ARG_TESTNAME} IN_LIST _declared_tests)) + message(VERBOSE "skipping test '${ARG_TESTNAME}' as it has already been added") + return() + endif() + endif() + find_program(ament_copyright_BIN NAMES "ament_copyright") if(NOT ament_copyright_BIN) message(FATAL_ERROR "ament_copyright() could not find program 'ament_copyright'") diff --git a/ament_cmake_cppcheck/cmake/ament_cppcheck.cmake b/ament_cmake_cppcheck/cmake/ament_cppcheck.cmake index 3db15c16..4153910c 100644 --- a/ament_cmake_cppcheck/cmake/ament_cppcheck.cmake +++ b/ament_cmake_cppcheck/cmake/ament_cppcheck.cmake @@ -40,6 +40,15 @@ function(ament_cppcheck) set(ARG_TESTNAME "cppcheck") endif() + # https://cmake.org/cmake/help/latest/prop_dir/TESTS.html + get_directory_property(_declared_tests TESTS) + if(DEFINED AMENT_LINT_AUTO_SKIP_PREEXISTING_TESTS) + if((AMENT_LINT_AUTO_SKIP_PREEXISTING_TESTS) AND (${ARG_TESTNAME} IN_LIST _declared_tests)) + message(VERBOSE "skipping test '${ARG_TESTNAME}' as it has already been added") + return() + endif() + endif() + find_program(ament_cppcheck_BIN NAMES "ament_cppcheck") if(NOT ament_cppcheck_BIN) message(FATAL_ERROR "ament_cppcheck() could not find program 'ament_cppcheck'") diff --git a/ament_cmake_cpplint/cmake/ament_cpplint.cmake b/ament_cmake_cpplint/cmake/ament_cpplint.cmake index cf024f8b..c840aa0a 100644 --- a/ament_cmake_cpplint/cmake/ament_cpplint.cmake +++ b/ament_cmake_cpplint/cmake/ament_cpplint.cmake @@ -39,6 +39,15 @@ function(ament_cpplint) set(ARG_TESTNAME "cpplint") endif() + # https://cmake.org/cmake/help/latest/prop_dir/TESTS.html + get_directory_property(_declared_tests TESTS) + if(DEFINED AMENT_LINT_AUTO_SKIP_PREEXISTING_TESTS) + if((AMENT_LINT_AUTO_SKIP_PREEXISTING_TESTS) AND (${ARG_TESTNAME} IN_LIST _declared_tests)) + message(VERBOSE "skipping test '${ARG_TESTNAME}' as it has already been added") + return() + endif() + endif() + find_program(ament_cpplint_BIN NAMES "ament_cpplint") if(NOT ament_cpplint_BIN) message(FATAL_ERROR "ament_cpplint() could not find program 'ament_cpplint'") diff --git a/ament_cmake_flake8/cmake/ament_flake8.cmake b/ament_cmake_flake8/cmake/ament_flake8.cmake index 610c1897..e6b129a5 100644 --- a/ament_cmake_flake8/cmake/ament_flake8.cmake +++ b/ament_cmake_flake8/cmake/ament_flake8.cmake @@ -32,6 +32,15 @@ function(ament_flake8) set(ARG_TESTNAME "flake8") endif() + # https://cmake.org/cmake/help/latest/prop_dir/TESTS.html + get_directory_property(_declared_tests TESTS) + if(DEFINED AMENT_LINT_AUTO_SKIP_PREEXISTING_TESTS) + if((AMENT_LINT_AUTO_SKIP_PREEXISTING_TESTS) AND (${ARG_TESTNAME} IN_LIST _declared_tests)) + message(VERBOSE "skipping test '${ARG_TESTNAME}' as it has already been added") + return() + endif() + endif() + find_program(ament_flake8_BIN NAMES "ament_flake8") if(NOT ament_flake8_BIN) message(FATAL_ERROR "ament_flake8() could not find program 'ament_flake8'") diff --git a/ament_cmake_lint_cmake/cmake/ament_lint_cmake.cmake b/ament_cmake_lint_cmake/cmake/ament_lint_cmake.cmake index 3360e0a3..08578908 100644 --- a/ament_cmake_lint_cmake/cmake/ament_lint_cmake.cmake +++ b/ament_cmake_lint_cmake/cmake/ament_lint_cmake.cmake @@ -31,6 +31,15 @@ function(ament_lint_cmake) set(ARG_TESTNAME "lint_cmake") endif() + # https://cmake.org/cmake/help/latest/prop_dir/TESTS.html + get_directory_property(_declared_tests TESTS) + if(DEFINED AMENT_LINT_AUTO_SKIP_PREEXISTING_TESTS) + if((AMENT_LINT_AUTO_SKIP_PREEXISTING_TESTS) AND (${ARG_TESTNAME} IN_LIST _declared_tests)) + message(VERBOSE "skipping test '${ARG_TESTNAME}' as it has already been added") + return() + endif() + endif() + find_program(ament_lint_cmake_BIN NAMES "ament_lint_cmake") if(NOT ament_lint_cmake_BIN) message(FATAL_ERROR "ament_lint_cmake() could not find program 'ament_lint_cmake'") diff --git a/ament_cmake_mypy/cmake/ament_mypy.cmake b/ament_cmake_mypy/cmake/ament_mypy.cmake index 34017bbb..9be3370b 100644 --- a/ament_cmake_mypy/cmake/ament_mypy.cmake +++ b/ament_cmake_mypy/cmake/ament_mypy.cmake @@ -30,6 +30,15 @@ function(ament_mypy) set(ARG_TESTNAME "mypy") endif() + # https://cmake.org/cmake/help/latest/prop_dir/TESTS.html + get_directory_property(_declared_tests TESTS) + if(DEFINED AMENT_LINT_AUTO_SKIP_PREEXISTING_TESTS) + if((AMENT_LINT_AUTO_SKIP_PREEXISTING_TESTS) AND (${ARG_TESTNAME} IN_LIST _declared_tests)) + message(VERBOSE "skipping test '${ARG_TESTNAME}' as it has already been added") + return() + endif() + endif() + find_program(ament_mypy_BIN NAMES "ament_mypy") if(NOT ament_mypy_BIN) message(FATAL_ERROR "ament_mypy() could not find program 'ament_mypy'") diff --git a/ament_cmake_pclint/cmake/ament_pclint.cmake b/ament_cmake_pclint/cmake/ament_pclint.cmake index 3f4994c0..0c783706 100644 --- a/ament_cmake_pclint/cmake/ament_pclint.cmake +++ b/ament_cmake_pclint/cmake/ament_pclint.cmake @@ -35,6 +35,15 @@ function(ament_pclint) set(ARG_TESTNAME "pclint") endif() + # https://cmake.org/cmake/help/latest/prop_dir/TESTS.html + get_directory_property(_declared_tests TESTS) + if(DEFINED AMENT_LINT_AUTO_SKIP_PREEXISTING_TESTS) + if((AMENT_LINT_AUTO_SKIP_PREEXISTING_TESTS) AND (${ARG_TESTNAME} IN_LIST _declared_tests)) + message(VERBOSE "skipping test '${ARG_TESTNAME}' as it has already been added") + return() + endif() + endif() + find_program(ament_pclint_BIN NAMES "ament_pclint") if(NOT ament_pclint_BIN) message(FATAL_ERROR "ament_pclint() could not find program 'ament_pclint'") diff --git a/ament_cmake_pep257/cmake/ament_pep257.cmake b/ament_cmake_pep257/cmake/ament_pep257.cmake index ece07e4b..8bff45e2 100644 --- a/ament_cmake_pep257/cmake/ament_pep257.cmake +++ b/ament_cmake_pep257/cmake/ament_pep257.cmake @@ -28,6 +28,15 @@ function(ament_pep257) set(ARG_TESTNAME "pep257") endif() + # https://cmake.org/cmake/help/latest/prop_dir/TESTS.html + get_directory_property(_declared_tests TESTS) + if(DEFINED AMENT_LINT_AUTO_SKIP_PREEXISTING_TESTS) + if((AMENT_LINT_AUTO_SKIP_PREEXISTING_TESTS) AND (${ARG_TESTNAME} IN_LIST _declared_tests)) + message(VERBOSE "skipping test '${ARG_TESTNAME}' as it has already been added") + return() + endif() + endif() + find_program(ament_pep257_BIN NAMES "ament_pep257") if(NOT ament_pep257_BIN) message(FATAL_ERROR "ament_pep257() could not find program 'ament_pep257'") diff --git a/ament_cmake_pycodestyle/cmake/ament_pycodestyle.cmake b/ament_cmake_pycodestyle/cmake/ament_pycodestyle.cmake index 2177ea0d..6e42e301 100644 --- a/ament_cmake_pycodestyle/cmake/ament_pycodestyle.cmake +++ b/ament_cmake_pycodestyle/cmake/ament_pycodestyle.cmake @@ -31,6 +31,15 @@ function(ament_pycodestyle) set(ARG_TESTNAME "pycodestyle") endif() + # https://cmake.org/cmake/help/latest/prop_dir/TESTS.html + get_directory_property(_declared_tests TESTS) + if(DEFINED AMENT_LINT_AUTO_SKIP_PREEXISTING_TESTS) + if((AMENT_LINT_AUTO_SKIP_PREEXISTING_TESTS) AND (${ARG_TESTNAME} IN_LIST _declared_tests)) + message(VERBOSE "skipping test '${ARG_TESTNAME}' as it has already been added") + return() + endif() + endif() + find_program(ament_pycodestyle_BIN NAMES "ament_pycodestyle") if(NOT ament_pycodestyle_BIN) message(FATAL_ERROR "ament_pycodestyle() could not find program 'ament_pycodestyle'") diff --git a/ament_cmake_pyflakes/cmake/ament_pyflakes.cmake b/ament_cmake_pyflakes/cmake/ament_pyflakes.cmake index 34f1917f..dd88b928 100644 --- a/ament_cmake_pyflakes/cmake/ament_pyflakes.cmake +++ b/ament_cmake_pyflakes/cmake/ament_pyflakes.cmake @@ -28,6 +28,15 @@ function(ament_pyflakes) set(ARG_TESTNAME "pyflakes") endif() + # https://cmake.org/cmake/help/latest/prop_dir/TESTS.html + get_directory_property(_declared_tests TESTS) + if(DEFINED AMENT_LINT_AUTO_SKIP_PREEXISTING_TESTS) + if((AMENT_LINT_AUTO_SKIP_PREEXISTING_TESTS) AND (${ARG_TESTNAME} IN_LIST _declared_tests)) + message(VERBOSE "skipping test '${ARG_TESTNAME}' as it has already been added") + return() + endif() + endif() + find_program(ament_pyflakes_BIN NAMES "ament_pyflakes") if(NOT ament_pyflakes_BIN) message(FATAL_ERROR "ament_pyflakes() could not find program 'ament_pyflakes'") diff --git a/ament_cmake_uncrustify/cmake/ament_uncrustify.cmake b/ament_cmake_uncrustify/cmake/ament_uncrustify.cmake index dbb19b3d..4c4ccb5c 100644 --- a/ament_cmake_uncrustify/cmake/ament_uncrustify.cmake +++ b/ament_cmake_uncrustify/cmake/ament_uncrustify.cmake @@ -42,6 +42,15 @@ function(ament_uncrustify) set(ARG_TESTNAME "uncrustify") endif() + # https://cmake.org/cmake/help/latest/prop_dir/TESTS.html + get_directory_property(_declared_tests TESTS) + if(DEFINED AMENT_LINT_AUTO_SKIP_PREEXISTING_TESTS) + if((AMENT_LINT_AUTO_SKIP_PREEXISTING_TESTS) AND (${ARG_TESTNAME} IN_LIST _declared_tests)) + message(VERBOSE "skipping test '${ARG_TESTNAME}' as it has already been added") + return() + endif() + endif() + find_program(ament_uncrustify_BIN NAMES "ament_uncrustify") if(NOT ament_uncrustify_BIN) message(FATAL_ERROR "ament_uncrustify() could not find program 'ament_uncrustify'") diff --git a/ament_cmake_xmllint/cmake/ament_xmllint.cmake b/ament_cmake_xmllint/cmake/ament_xmllint.cmake index cf42857a..1eb4c4fa 100644 --- a/ament_cmake_xmllint/cmake/ament_xmllint.cmake +++ b/ament_cmake_xmllint/cmake/ament_xmllint.cmake @@ -28,6 +28,15 @@ function(ament_xmllint) set(ARG_TESTNAME "xmllint") endif() + # https://cmake.org/cmake/help/latest/prop_dir/TESTS.html + get_directory_property(_declared_tests TESTS) + if(DEFINED AMENT_LINT_AUTO_SKIP_PREEXISTING_TESTS) + if((AMENT_LINT_AUTO_SKIP_PREEXISTING_TESTS) AND (${ARG_TESTNAME} IN_LIST _declared_tests)) + message(VERBOSE "skipping test '${ARG_TESTNAME}' as it has already been added") + return() + endif() + endif() + find_program(ament_xmllint_BIN NAMES "ament_xmllint") if(NOT ament_xmllint_BIN) message(FATAL_ERROR "ament_xmllint() could not find program 'ament_xmllint'")