Skip to content

Commit 0e5bf76

Browse files
[ament_cmake_pep257] Add file exclude support (#458)
The `ament_cmake_pep257` respects the `AMENT_LINT_AUTO_FILE_EXCLUDE` variable.
1 parent 79b625e commit 0e5bf76

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

ament_cmake_pep257/cmake/ament_cmake_pep257_lint_hook.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,9 @@
1515
file(GLOB_RECURSE _python_files FOLLOW_SYMLINKS "*.py")
1616
if(_python_files)
1717
message(STATUS "Added test 'pep257' to check Python code against some of the docstring style conventions in PEP 257")
18-
ament_pep257()
18+
if(DEFINED AMENT_LINT_AUTO_FILE_EXCLUDE)
19+
ament_pep257(EXCLUDE ${AMENT_LINT_AUTO_FILE_EXCLUDE})
20+
else()
21+
ament_pep257()
22+
endif()
1923
endif()

ament_cmake_pep257/cmake/ament_pep257.cmake

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@
1717
#
1818
# :param TESTNAME: the name of the test, default: "pep257"
1919
# :type TESTNAME: string
20+
# :param EXCLUDE: an optional list of exclude files or directories for cmake pep257 check
21+
# :type EXCLUDE: list
2022
# :param ARGN: the files or directories to check
2123
# :type ARGN: list of strings
2224
#
2325
# @public
2426
#
2527
function(ament_pep257)
26-
cmake_parse_arguments(ARG "" "TESTNAME" "" ${ARGN})
28+
cmake_parse_arguments(ARG "" "TESTNAME" "EXCLUDE" ${ARGN})
2729
if(NOT ARG_TESTNAME)
2830
set(ARG_TESTNAME "pep257")
2931
endif()
@@ -35,6 +37,9 @@ function(ament_pep257)
3537

3638
set(result_file "${AMENT_TEST_RESULTS_DIR}/${PROJECT_NAME}/${ARG_TESTNAME}.xunit.xml")
3739
set(cmd "${ament_pep257_BIN}" "--xunit-file" "${result_file}")
40+
if(ARG_EXCLUDE)
41+
list(APPEND cmd "--exclude" "${ARG_EXCLUDE}")
42+
endif()
3843
list(APPEND cmd ${ARG_UNPARSED_ARGUMENTS})
3944

4045
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/ament_pep257")

0 commit comments

Comments
 (0)