Skip to content

Commit 7f70070

Browse files
committed
include severity in the tests
1 parent 6c974a3 commit 7f70070

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

tests/run-test.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,18 @@ fi
1818
TEST_NAME=$(sed -n '3s/ \* //p' "$TEST_FILE")
1919

2020
echo ""
21-
echo "Running test: $TEST_NAME with ruleset: $RULESET"
21+
echo "Running test: ${TEST_NAME} with ruleset: $RULESET"
2222
echo "$TEST_FILE"
2323

2424
# Use --basepath=. to ensure relative paths in the report.
2525
JSON_REPORT=$(phpcs --standard="./$RULESET/ruleset.xml" --report=json --basepath=. "$TEST_FILE" 2>/dev/null | sed -n '/{/,$p')
2626

2727
# Debug
28-
# echo "JSON Report:"
29-
# echo "$JSON_REPORT"
28+
# echo "JSON Report: ${JSON_REPORT}"
3029

31-
# Extract actual and expected errors.
32-
ACTUAL_OUTPUT=$(echo "$JSON_REPORT" | jq -r '.files."'"$TEST_FILE"'".messages[]?.source' | sort)
33-
EXPECTED_OUTPUT=$( (sed -n "s/.*@expectedError\[$RULESET\] //p" "$TEST_FILE"; sed -n "s/.*@expectedWarning\[$RULESET\] //p" "$TEST_FILE") | sort)
30+
# Extract actual and expected errors, including severity.
31+
ACTUAL_OUTPUT=$(echo "$JSON_REPORT" | jq -r '.files."'"$TEST_FILE"'".messages[] | "[\(.type | ascii_upcase)] \(.source)"' | sort)
32+
EXPECTED_OUTPUT=$( (sed -n "s/.*@expectedError\[$RULESET\] /\[ERROR\] /p" "$TEST_FILE"; sed -n "s/.*@expectedWarning\[$RULESET\] /\[WARNING\] /p" "$TEST_FILE") | sort)
3433

3534
echo "--------------------------------------------------"
3635
echo "EXPECTED ISSUES:"

0 commit comments

Comments
 (0)