From 591939fff4155d4c3ae161a1052a3309ec4bda3e Mon Sep 17 00:00:00 2001 From: Callahan Date: Mon, 19 Jun 2023 17:39:11 -0500 Subject: [PATCH] ros: make linter tests more flexible (#4223) Signed-off-by: Callahan Kovacs --- .../linters/linter-ros2-humble-mixed/task.yaml | 14 +++++++++++++- 1 file changed, 13 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 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