Skip to contentSkip to conversation

check: fix parsing expunge file with comments

PATCH In review Amir Goldstein 2 participants 2 messages Aug 14, 2023 – Aug 18, 2023

lore
Share & tools
lore
#0 lore raw

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
index 549725eb..71b9fbd0 100755
@@ -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
Reviewed-by on v2 1/1
#1 lore raw
Quoted 12 lines · Amir Goldstein

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.

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.

---

This version is good to me,

Quoted 25 lines

Changes since v1:
- Use regex for whole word match

 check | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
check +3 -1
index 549725eb..71b9fbd0 100755
@@ -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