Skip to content

Commit

Permalink
tf2: Enable common linter tests
Browse files Browse the repository at this point in the history
Each of the common linters were individually `find_package`-d
and invoked in the CMakeLists.txt file. This is because there
is no simple way to pass file exclusion information through
`ament_lint_auto`.

File exclusion is necessary because we do not want to run linters
on the include/tf2/LinearMath/ headers, since these are
external and periodically synced with upstream. See
#258 (comment)
for more information.

Signed-off-by: Abrar Rahman Protyasha <aprotyas@u.rochester.edu>
  • Loading branch information
aprotyas committed Oct 19, 2021
1 parent 6bcf949 commit e7e279c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
34 changes: 32 additions & 2 deletions tf2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,39 @@ install(DIRECTORY include/${PROJECT_NAME}/

# Tests
if(BUILD_TESTING)
# TODO(clalancette) enable linters once https://github.com/ament/ament_lint/pull/238 lands
find_package(ament_cmake_copyright REQUIRED)
find_package(ament_cmake_cppcheck REQUIRED)
find_package(ament_cmake_cpplint REQUIRED)
find_package(ament_cmake_lint_cmake REQUIRED)
find_package(ament_cmake_uncrustify REQUIRED)
find_package(ament_cmake_xmllint REQUIRED)

find_package(ament_cmake_gtest)
# Should not lint external code
set(
_linter_excludes
include/tf2/LinearMath/Matrix3x3.h
include/tf2/LinearMath/MinMax.h
include/tf2/LinearMath/QuadWord.h
include/tf2/LinearMath/Quaternion.h
include/tf2/LinearMath/Scalar.h
include/tf2/LinearMath/Transform.h
include/tf2/LinearMath/Vector3.h
)

ament_copyright(EXCLUDE ${_linter_excludes})
ament_cppcheck(
EXCLUDE ${_linter_excludes}
LANGUAGE c++
)
ament_cpplint(EXCLUDE ${_linter_excludes})
ament_lint_cmake()
ament_uncrustify(
EXCLUDE ${_linter_excludes}
LANGUAGE c++
)
ament_xmllint()

find_package(ament_cmake_gtest REQUIRED)

ament_add_gtest(test_cache_unittest test/cache_unittest.cpp)
if(TARGET test_cache_unittest)
Expand Down
8 changes: 6 additions & 2 deletions tf2/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@
<depend>rcutils</depend>

<test_depend>ament_cmake_gtest</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<test_depend>ament_cmake_copyright</test_depend>
<test_depend>ament_cmake_cppcheck</test_depend>
<test_depend>ament_cmake_cpplint</test_depend>
<test_depend>ament_cmake_lint_cmake</test_depend>
<test_depend>ament_cmake_uncrustify</test_depend>
<test_depend>ament_cmake_xmllint</test_depend>

<export>
<build_type>ament_cmake</build_type>
Expand Down

0 comments on commit e7e279c

Please sign in to comment.