diff mbox series

[v2] check: fix parsing expunge file with comments

Message ID 20230814173132.767345-1-amir73il@gmail.com (mailing list archive)
State New, archived
Headers show
Series [v2] check: fix parsing expunge file with comments | expand

Commit Message

Amir Goldstein Aug. 14, 2023, 5:31 p.m. UTC
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.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---

Changes since v1:
- Use regex for whole word match

 check | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Zorro Lang Aug. 18, 2023, 12:34 p.m. UTC | #1
On Mon, Aug 14, 2023 at 08:31:32PM +0300, Amir Goldstein wrote:
> 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.
> 
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> ---

This version is good to me,
Reviewed-by: Zorro Lang <zlang@redhat.com>

> 
> Changes since v1:
> - Use regex for whole word match
> 
>  check | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/check b/check
> index 549725eb..71b9fbd0 100755
> --- a/check
> +++ b/check
> @@ -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
> -- 
> 2.34.1
>
diff mbox series

Patch

diff --git a/check b/check
index 549725eb..71b9fbd0 100755
--- a/check
+++ b/check
@@ -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