Skip to content

Commit 6a28d20

Browse files
fix(ci): skip lidar ament linters in package pytest config
PYTEST_ADDOPTS -m not linter never reached ament pytest, so copyright / flake8 / pep257 still ran after the unit tests passed. Ignore those modules in setup.cfg and collect_ignore. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 1335554 commit 6a28d20

4 files changed

Lines changed: 24 additions & 10 deletions

File tree

‎robot/ros_ws/src/sensors/lidar_point_cloud_filter/setup.cfg‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,13 @@ python_classes = Test*
1010
python_functions = test_*
1111
markers =
1212
unit: Hermetic unit tests (no ROS stack required)
13+
linter: ament copyright/flake8/pep257 (run separately, not via colcon test)
14+
copyright: ament_copyright
15+
flake8: ament_flake8
16+
pep257: ament_pep257
17+
# colcon test / PYTEST_ADDOPTS -m is dropped by ament pytest. Ignore linter
18+
# modules here so only unit tests run.
19+
addopts =
20+
--ignore=test/test_copyright.py
21+
--ignore=test/test_flake8.py
22+
--ignore=test/test_pep257.py
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Skip ament linter modules during pytest/colcon test.
2+
# PYTEST_ADDOPTS -m is not forwarded by ament pytest; collect_ignore is.
3+
collect_ignore = [
4+
"test_copyright.py",
5+
"test_flake8.py",
6+
"test_pep257.py",
7+
]

‎tests/colcon_unit_test_packages.yaml‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ robot:
99
packages:
1010
- natnet_ros2
1111
- lidar_point_cloud_filter
12-
# Skips ament_copyright / flake8 / pep257 on Python packages; run linters separately.
13-
# launch_testing is disabled via PYTEST_DISABLE_PLUGIN_AUTOLOAD in the test
14-
# ( -p no:launch_testing is too late: pytest 8.1+ validates the plugin at
15-
# register, before -p is applied).
16-
pytest_args:
17-
- -m
18-
- not linter
12+
# Linter skip lives in lidar_point_cloud_filter setup.cfg + test/conftest.py.
13+
# ament pytest does not honor PYTEST_ADDOPTS -m.
14+
# launch_testing is skipped via PYTEST_DISABLE_PLUGIN_AUTOLOAD in the test.
15+
pytest_args: []

‎tests/system/test_build_packages.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ def test_colcon_test_robot(self):
7171
)
7272
assert build.returncode == 0, f"colcon build (with testing) failed:\n{read_log_tail()}"
7373

74-
# PYTEST_ADDOPTS via docker exec -e (not colcon --pytest-args).
7574
# PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 skips launch_testing before
76-
# pytest 8.1+ validates its removed path= hook. -p no:launch_testing
77-
# is too late. Needed on cache_* images that predate the pytest<8.1 pin.
75+
# pytest 8.1+ validates its removed path= hook. Linter skip is in
76+
# the package setup.cfg / test/conftest.py (ament pytest ignores
77+
# PYTEST_ADDOPTS -m).
7878
exec_env = {"PYTEST_DISABLE_PLUGIN_AUTOLOAD": "1"}
7979
if pytest_args:
8080
exec_env["PYTEST_ADDOPTS"] = format_pytest_addopts(pytest_args)

0 commit comments

Comments
 (0)