Skip to content

Commit ab01d62

Browse files
author
Steve Taylor
committed
fix: stop reporting errors when there are none
1 parent afda90f commit ab01d62

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

detection.sh

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,14 @@ find_fail(){
1414
target=$1
1515
file=$2
1616
suite_line=$(cat "$file" | grep "$target")
17-
if echo "$suite_line" | grep "failures=\"0\"";then
18-
if echo "$suite_line" | grep -L "errors=\"[1-9]\d*\"";then
19-
echo "Error found in $file: $suite_line"
20-
return 1
21-
else
22-
return 0
23-
fi
24-
elif echo "$suite_line" | grep -L "errors=\"0\"";then
25-
if echo "$suite_line" | grep -L "failures=\"[1-9]\d*\"";then
26-
echo "Error found in $file: $suite_line"
27-
return 1
28-
else
29-
return 0
30-
fi
31-
else
32-
echo "Failure found in $file: $suite_line"
17+
if echo "$suite_line" | grep -q -E "failures=\"[1-9]\\d*\""; then
18+
echo "Failure(s) found in $file: $suite_line"
19+
return 1
20+
elif echo "$suite_line" | grep -q -E "errors=\"[1-9]\\d*\""; then
21+
echo "Error(s) found in $file: $suite_line"
22+
return 1
23+
elif echo "$suite_line" | grep -qv -E "failures=\"0\""; then
24+
echo "Test report may be malformed: No errors were detected, but the failures attribute is missing from the testsuite element."
3325
return 1
3426
fi
3527
}

0 commit comments

Comments
 (0)