check: fix parsing expunge file with comments
PATCH v2 1/1 check: fix parsing expunge file with comments
commit 60054d51 ("check: fix excluded tests are only expunged in the first iteration") change to use exclude_tests array instead of file.
The check if a test is in expunge file was using grep -q $TEST_ID FILE so it was checking if the test was a non-exact match to one of the lines, for a common example: "generic/001 # exclude this test" would be a match to test generic/001.
The commit regressed this example, because the new code checks for exact match of [ "generic/001" == "generic/001 " ]. Change the code to match a regular expression to deal with this case and any other suffix correctly.
NOTE that the original code would have matched test generic/100 with lines like "generic/1000" when we get to 4 digit seqnum, so the regular expression does an exact match to the first word of the line.
---
Changes since v1:
- Use regex for whole word match
check | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
check +3 -1
@@ -592,7 +592,9 @@ _expunge_test() local TEST_ID="$1" for f in "${exclude_tests[@]}"; do - if [ "${TEST_ID}" == "$f" ]; then + # $f may contain traling spaces and comments + local id_regex="^${TEST_ID}\b" + if [[ "$f" =~ ${id_regex} ]]; then echo " [expunged]" return 0 fi
Signature · 1 line
2.34.1
Quoted 12 lines · Amir Goldstein
commit
60054d51("check: fix excluded tests are only expunged in the first iteration") change to useexclude_testsarray instead of file.The check if a test is in expunge file was using grep -q $TEST_ID FILE so it was checking if the test was a non-exact match to one of the lines, for a common example: "generic/001 # exclude this test" would be a match to test generic/001.
The commit regressed this example, because the new code checks for exact match of [ "generic/001" == "generic/001 " ]. Change the code to match a regular expression to deal with this case and any other suffix correctly.
Quoted 6 lines
NOTE that the original code would have matched test generic/100 with lines like "generic/1000" when we get to 4 digit seqnum, so the regular expression does an exact match to the first word of the line.
Signed-off-by Amir Goldstein <[email protected]>---
This version is good to me,
Quoted 25 lines
Changes since v1:
- Use regex for whole word matchcheck | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)check +3
-1@@ -592,7 +592,9 @@ _expunge_test() local TEST_ID="$1" for f in "${exclude_tests[@]}"; do - if [ "${TEST_ID}" == "$f" ]; then + # $f may contain traling spaces and comments + local id_regex="^${TEST_ID}\b" + if [[ "$f" =~ ${id_regex} ]]; then echo " [expunged]" return 0 fiSignature · 1 line
2.34.1