Skip to content

Commit 34e6fc7

Browse files
authored
Read the error count backwards from the bottom (after all the errors)
1 parent 452ccc8 commit 34e6fc7

1 file changed

Lines changed: 11 additions & 14 deletions

File tree

test/test.bats

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ SUBFOLDER_MISSPELLING_COUNT=1
1717
# From all files called example.txt
1818
EXAMPLE_MISSPELLING_COUNT=5
1919

20-
ERROR_COUNT_LINE_NUMBER=10
21-
BOOLEAN_OPTION_LINE_OFFSET=1
22-
2320
export RUNNER_TEMP="/foo/runner_temp"
2421

2522
# This function runs before every test
@@ -58,7 +55,7 @@ function setup() {
5855
[ "${lines[0]}" == "::add-matcher::${RUNNER_TEMP}/_github_workflow/codespell-matcher.json" ]
5956
outputRegex="^Running codespell on '${INPUT_PATH}'"
6057
[[ "${lines[1]}" =~ $outputRegex ]]
61-
[ "${lines[$ERROR_COUNT_LINE_NUMBER]}" == "$errorCount" ]
58+
[ "${lines[-4 - $errorCount]}" == "$errorCount" ]
6259
[ "${lines[-3]}" == "Codespell found one or more problems" ]
6360
[ "${lines[-2]}" == "::remove-matcher owner=codespell-matcher-default::" ]
6461
[ "${lines[-1]}" == "::remove-matcher owner=codespell-matcher-specified::" ]
@@ -71,7 +68,7 @@ function setup() {
7168
INPUT_CHECK_FILENAMES=true
7269
run "./entrypoint.sh"
7370
[ $status -eq $expectedExitStatus ]
74-
[ "${lines[$ERROR_COUNT_LINE_NUMBER+$BOOLEAN_OPTION_LINE_OFFSET]}" == "$errorCount" ]
71+
[ "${lines[-4 - $errorCount]}" == "$errorCount" ]
7572
}
7673

7774
@test "Check a hidden file" {
@@ -82,7 +79,7 @@ function setup() {
8279
INPUT_PATH="./test/testdata/.hidden"
8380
run "./entrypoint.sh"
8481
[ $status -eq $expectedExitStatus ]
85-
[ "${lines[$ERROR_COUNT_LINE_NUMBER+$BOOLEAN_OPTION_LINE_OFFSET]}" == "$errorCount" ]
82+
[ "${lines[-4 - $errorCount]}" == "$errorCount" ]
8683
}
8784

8885
@test "Check a hidden file without INPUT_CHECK_HIDDEN set" {
@@ -92,7 +89,7 @@ function setup() {
9289
INPUT_PATH="./test/testdata/.hidden"
9390
run "./entrypoint.sh"
9491
[ $status -eq $expectedExitStatus ]
95-
[ "${lines[$ERROR_COUNT_LINE_NUMBER]}" == "$errorCount" ]
92+
[ "${lines[-4 - $errorCount]}" == "$errorCount" ]
9693
}
9794

9895
@test "Use an exclude file" {
@@ -102,7 +99,7 @@ function setup() {
10299
INPUT_EXCLUDE_FILE="./test/exclude-file.txt"
103100
run "./entrypoint.sh"
104101
[ $status -eq $expectedExitStatus ]
105-
[ "${lines[$ERROR_COUNT_LINE_NUMBER]}" == "$errorCount" ]
102+
[ "${lines[-4 - $errorCount]}" == "$errorCount" ]
106103
}
107104

108105
@test "Check the skip option" {
@@ -112,7 +109,7 @@ function setup() {
112109
INPUT_SKIP="example.txt"
113110
run "./entrypoint.sh"
114111
[ $status -eq $expectedExitStatus ]
115-
[ "${lines[$ERROR_COUNT_LINE_NUMBER]}" == "$errorCount" ]
112+
[ "${lines[-4 - $errorCount]}" == "$errorCount" ]
116113
}
117114

118115
@test "Use an additional builtin dictionary" {
@@ -122,7 +119,7 @@ function setup() {
122119
INPUT_BUILTIN="clear,rare,names"
123120
run "./entrypoint.sh"
124121
[ $status -eq $expectedExitStatus ]
125-
[ "${lines[$ERROR_COUNT_LINE_NUMBER]}" == "$errorCount" ]
122+
[ "${lines[-4 - $errorCount]}" == "$errorCount" ]
126123
}
127124

128125
@test "Use an ignore words file" {
@@ -132,7 +129,7 @@ function setup() {
132129
INPUT_IGNORE_WORDS_FILE="./test/ignore-words-file.txt"
133130
run "./entrypoint.sh"
134131
[ $status -eq $expectedExitStatus ]
135-
[ "${lines[$ERROR_COUNT_LINE_NUMBER]}" == "$errorCount" ]
132+
[ "${lines[-4 - $errorCount]}" == "$errorCount" ]
136133
}
137134

138135
@test "Use an ignore words list" {
@@ -142,7 +139,7 @@ function setup() {
142139
INPUT_IGNORE_WORDS_LIST="abandonned"
143140
run "./entrypoint.sh"
144141
[ $status -eq $expectedExitStatus ]
145-
[ "${lines[$ERROR_COUNT_LINE_NUMBER]}" == "$errorCount" ]
142+
[ "${lines[-4 - $errorCount]}" == "$errorCount" ]
146143
}
147144

148145
@test "Custom path" {
@@ -152,7 +149,7 @@ function setup() {
152149
INPUT_PATH="./test/testdata/subfolder"
153150
run "./entrypoint.sh"
154151
[ $status -eq $expectedExitStatus ]
155-
[ "${lines[$ERROR_COUNT_LINE_NUMBER]}" == "$errorCount" ]
152+
[ "${lines[-4 - $errorCount]}" == "$errorCount" ]
156153
}
157154

158155
@test "Only warn" {
@@ -162,5 +159,5 @@ function setup() {
162159
INPUT_ONLY_WARN=true
163160
run "./entrypoint.sh"
164161
[ $status -eq $expectedExitStatus ]
165-
#[ "${lines[$ERROR_COUNT_LINE_NUMBER+$BOOLEAN_OPTION_LINE_OFFSET]}" == "$errorCount" ]
162+
#[ "${lines[-4 - $errorCount]}" == "$errorCount" ]
166163
}

0 commit comments

Comments
 (0)