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 9076af87908..7db84e99433 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,16 @@ 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 + + # `|| 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 + 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