From 127967b0b9a1091a1f9e8b4f16f39200f3b1a369 Mon Sep 17 00:00:00 2001 From: Callahan Kovacs Date: Mon, 19 Jun 2023 15:11:20 -0500 Subject: [PATCH 1/2] ros: make linter tests more flexible Signed-off-by: Callahan Kovacs --- .../expected_linter_output.txt | 7 ------- .../linters/linter-ros2-humble-mixed/task.yaml | 12 +++++++++++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/tests/spread/core22/linters/linter-ros2-humble-mixed/expected_linter_output.txt b/tests/spread/core22/linters/linter-ros2-humble-mixed/expected_linter_output.txt index 2442be15bb..e5aff790af 100644 --- a/tests/spread/core22/linters/linter-ros2-humble-mixed/expected_linter_output.txt +++ b/tests/spread/core22/linters/linter-ros2-humble-mixed/expected_linter_output.txt @@ -6,39 +6,32 @@ Lint warnings: - library: libexpat.so.1: unused library 'lib/x86_64-linux-gnu/libexpat.so.1.8.7'. (https://snapcraft.io/docs/linters-library) - library: libtirpc.so.3: unused library 'lib/x86_64-linux-gnu/libtirpc.so.3.0.0'. (https://snapcraft.io/docs/linters-library) - library: libz.so.1: unused library 'lib/x86_64-linux-gnu/libz.so.1.2.11'. (https://snapcraft.io/docs/linters-library) -- library: libaction_msgs__rosidl_generator_py.so: unused library 'opt/ros/humble/lib/libaction_msgs__rosidl_generator_py.so'. (https://snapcraft.io/docs/linters-library) - library: libaction_msgs__rosidl_typesupport_cpp.so: unused library 'opt/ros/humble/lib/libaction_msgs__rosidl_typesupport_cpp.so'. (https://snapcraft.io/docs/linters-library) - library: libaction_msgs__rosidl_typesupport_fastrtps_c.so: unused library 'opt/ros/humble/lib/libaction_msgs__rosidl_typesupport_fastrtps_c.so'. (https://snapcraft.io/docs/linters-library) - library: libaction_msgs__rosidl_typesupport_fastrtps_cpp.so: unused library 'opt/ros/humble/lib/libaction_msgs__rosidl_typesupport_fastrtps_cpp.so'. (https://snapcraft.io/docs/linters-library) - library: libaction_msgs__rosidl_typesupport_introspection_c.so: unused library 'opt/ros/humble/lib/libaction_msgs__rosidl_typesupport_introspection_c.so'. (https://snapcraft.io/docs/linters-library) - library: libaction_msgs__rosidl_typesupport_introspection_cpp.so: unused library 'opt/ros/humble/lib/libaction_msgs__rosidl_typesupport_introspection_cpp.so'. (https://snapcraft.io/docs/linters-library) -- library: libbuiltin_interfaces__rosidl_generator_py.so: unused library 'opt/ros/humble/lib/libbuiltin_interfaces__rosidl_generator_py.so'. (https://snapcraft.io/docs/linters-library) - library: libbuiltin_interfaces__rosidl_typesupport_cpp.so: unused library 'opt/ros/humble/lib/libbuiltin_interfaces__rosidl_typesupport_cpp.so'. (https://snapcraft.io/docs/linters-library) -- library: liblifecycle_msgs__rosidl_generator_py.so: unused library 'opt/ros/humble/lib/liblifecycle_msgs__rosidl_generator_py.so'. (https://snapcraft.io/docs/linters-library) - library: liblifecycle_msgs__rosidl_typesupport_cpp.so: unused library 'opt/ros/humble/lib/liblifecycle_msgs__rosidl_typesupport_cpp.so'. (https://snapcraft.io/docs/linters-library) - library: liblifecycle_msgs__rosidl_typesupport_fastrtps_c.so: unused library 'opt/ros/humble/lib/liblifecycle_msgs__rosidl_typesupport_fastrtps_c.so'. (https://snapcraft.io/docs/linters-library) - library: liblifecycle_msgs__rosidl_typesupport_fastrtps_cpp.so: unused library 'opt/ros/humble/lib/liblifecycle_msgs__rosidl_typesupport_fastrtps_cpp.so'. (https://snapcraft.io/docs/linters-library) - library: liblifecycle_msgs__rosidl_typesupport_introspection_c.so: unused library 'opt/ros/humble/lib/liblifecycle_msgs__rosidl_typesupport_introspection_c.so'. (https://snapcraft.io/docs/linters-library) - library: liblifecycle_msgs__rosidl_typesupport_introspection_cpp.so: unused library 'opt/ros/humble/lib/liblifecycle_msgs__rosidl_typesupport_introspection_cpp.so'. (https://snapcraft.io/docs/linters-library) -- library: librcl_interfaces__rosidl_generator_py.so: unused library 'opt/ros/humble/lib/librcl_interfaces__rosidl_generator_py.so'. (https://snapcraft.io/docs/linters-library) - library: librcl_interfaces__rosidl_typesupport_cpp.so: unused library 'opt/ros/humble/lib/librcl_interfaces__rosidl_typesupport_cpp.so'. (https://snapcraft.io/docs/linters-library) - library: librcl_interfaces__rosidl_typesupport_fastrtps_c.so: unused library 'opt/ros/humble/lib/librcl_interfaces__rosidl_typesupport_fastrtps_c.so'. (https://snapcraft.io/docs/linters-library) - library: librcl_interfaces__rosidl_typesupport_fastrtps_cpp.so: unused library 'opt/ros/humble/lib/librcl_interfaces__rosidl_typesupport_fastrtps_cpp.so'. (https://snapcraft.io/docs/linters-library) - library: librcl_interfaces__rosidl_typesupport_introspection_c.so: unused library 'opt/ros/humble/lib/librcl_interfaces__rosidl_typesupport_introspection_c.so'. (https://snapcraft.io/docs/linters-library) - library: librcl_interfaces__rosidl_typesupport_introspection_cpp.so: unused library 'opt/ros/humble/lib/librcl_interfaces__rosidl_typesupport_introspection_cpp.so'. (https://snapcraft.io/docs/linters-library) -- library: librmw_dds_common__rosidl_generator_py.so: unused library 'opt/ros/humble/lib/librmw_dds_common__rosidl_generator_py.so'. (https://snapcraft.io/docs/linters-library) - library: librmw_dds_common__rosidl_typesupport_fastrtps_c.so: unused library 'opt/ros/humble/lib/librmw_dds_common__rosidl_typesupport_fastrtps_c.so'. (https://snapcraft.io/docs/linters-library) - library: librmw_dds_common__rosidl_typesupport_fastrtps_cpp.so: unused library 'opt/ros/humble/lib/librmw_dds_common__rosidl_typesupport_fastrtps_cpp.so'. (https://snapcraft.io/docs/linters-library) - library: librmw_dds_common__rosidl_typesupport_introspection_c.so: unused library 'opt/ros/humble/lib/librmw_dds_common__rosidl_typesupport_introspection_c.so'. (https://snapcraft.io/docs/linters-library) - library: librmw_dds_common__rosidl_typesupport_introspection_cpp.so: unused library 'opt/ros/humble/lib/librmw_dds_common__rosidl_typesupport_introspection_cpp.so'. (https://snapcraft.io/docs/linters-library) - library: librmw_fastrtps_cpp.so: unused library 'opt/ros/humble/lib/librmw_fastrtps_cpp.so'. (https://snapcraft.io/docs/linters-library) -- library: librosgraph_msgs__rosidl_generator_py.so: unused library 'opt/ros/humble/lib/librosgraph_msgs__rosidl_generator_py.so'. (https://snapcraft.io/docs/linters-library) - library: librosgraph_msgs__rosidl_typesupport_cpp.so: unused library 'opt/ros/humble/lib/librosgraph_msgs__rosidl_typesupport_cpp.so'. (https://snapcraft.io/docs/linters-library) - library: librosgraph_msgs__rosidl_typesupport_fastrtps_c.so: unused library 'opt/ros/humble/lib/librosgraph_msgs__rosidl_typesupport_fastrtps_c.so'. (https://snapcraft.io/docs/linters-library) - library: librosgraph_msgs__rosidl_typesupport_fastrtps_cpp.so: unused library 'opt/ros/humble/lib/librosgraph_msgs__rosidl_typesupport_fastrtps_cpp.so'. (https://snapcraft.io/docs/linters-library) - library: librosgraph_msgs__rosidl_typesupport_introspection_c.so: unused library 'opt/ros/humble/lib/librosgraph_msgs__rosidl_typesupport_introspection_c.so'. (https://snapcraft.io/docs/linters-library) - library: librosgraph_msgs__rosidl_typesupport_introspection_cpp.so: unused library 'opt/ros/humble/lib/librosgraph_msgs__rosidl_typesupport_introspection_cpp.so'. (https://snapcraft.io/docs/linters-library) -- library: libunique_identifier_msgs__rosidl_generator_py.so: unused library 'opt/ros/humble/lib/libunique_identifier_msgs__rosidl_generator_py.so'. (https://snapcraft.io/docs/linters-library) - library: libunique_identifier_msgs__rosidl_typesupport_cpp.so: unused library 'opt/ros/humble/lib/libunique_identifier_msgs__rosidl_typesupport_cpp.so'. (https://snapcraft.io/docs/linters-library) - library: libatomic.so.1: unused library 'usr/lib/x86_64-linux-gnu/libatomic.so.1.2.0'. (https://snapcraft.io/docs/linters-library) - library: libicuio.so.70: unused library 'usr/lib/x86_64-linux-gnu/libicuio.so.70.1'. (https://snapcraft.io/docs/linters-library) diff --git a/tests/spread/core22/linters/linter-ros2-humble-mixed/task.yaml b/tests/spread/core22/linters/linter-ros2-humble-mixed/task.yaml index 9076af8790..08e8b9feae 100644 --- a/tests/spread/core22/linters/linter-ros2-humble-mixed/task.yaml +++ b/tests/spread/core22/linters/linter-ros2-humble-mixed/task.yaml @@ -10,4 +10,14 @@ execute: | test -f linter-ros2-humble-mixed_1.0_*.snap sed -n '/^Running linters/,/^Creating snap/p' < output.txt > linter_output.txt - diff -u linter_output.txt expected_linter_output.txt + + # diff everything except the list of libraries + diff --ignore-matching-lines "^- library: lib" expected_linter_output.txt linter_output.txt + + # the list of unused libraries may change from time to time, so check the output is similar but not identical + NUM_DIFFERENCES=$(diff expected_linter_output.txt linter_output.txt | grep --count "[<>]") + if [[ $NUM_DIFFERENCES -gt 10 ]]; then + echo "Error: linter warnings are significantly different:" + diff --unified expected_linter_output.txt linter_output.txt + exit 1 + fi From 4f2efca52e9d8b888368018848088cf40d290f36 Mon Sep 17 00:00:00 2001 From: Callahan Kovacs Date: Mon, 19 Jun 2023 16:36:47 -0500 Subject: [PATCH 2/2] fix grep call Signed-off-by: Callahan Kovacs --- .../spread/core22/linters/linter-ros2-humble-mixed/task.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/spread/core22/linters/linter-ros2-humble-mixed/task.yaml b/tests/spread/core22/linters/linter-ros2-humble-mixed/task.yaml index 08e8b9feae..7db84e9943 100644 --- a/tests/spread/core22/linters/linter-ros2-humble-mixed/task.yaml +++ b/tests/spread/core22/linters/linter-ros2-humble-mixed/task.yaml @@ -14,8 +14,10 @@ execute: | # diff everything except the list of libraries diff --ignore-matching-lines "^- library: lib" expected_linter_output.txt linter_output.txt + # `|| true` is used because grep will error if there is no output from the `diff` call + NUM_DIFFERENCES=$(diff expected_linter_output.txt linter_output.txt | grep --count "[<>]" || true) + # the list of unused libraries may change from time to time, so check the output is similar but not identical - NUM_DIFFERENCES=$(diff expected_linter_output.txt linter_output.txt | grep --count "[<>]") if [[ $NUM_DIFFERENCES -gt 10 ]]; then echo "Error: linter warnings are significantly different:" diff --unified expected_linter_output.txt linter_output.txt