Skip to content

Commit 3f94056

Browse files
Javagedesmergify[bot]
authored andcommitted
.pytool/SpellCheck: Fix silent cspell run error
In the implementation of the SpellCheck prior to this commit, the logic assumed that if it was able to successfully call `cspell --version` to get the version, then any future usage of cspell would work without error. PR #11783 brought to light an issue in this logic where if the node version was too out of date, `cspell` could successfully run `cspell --version` but would hit a runtime error when actually performing a spell check on a package. This ultimetly resulted in cspell not running for any package but still reporting a "Success". This commit updates the error handling logic in the SpellCheck when running cspell to ensure that when cspell error lines were reported, at least one misspelled word must be found. In the scenario where error lines are reported, but no misspelled words were found, we now assume a runtime error occurred in cspell, log it, and fail the plugin. Signed-off-by: Joey Vagedes <[email protected]>
1 parent faa0ebc commit 3f94056

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

.pytool/Plugin/SpellCheck/SpellCheck.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,14 @@ def RunBuildPlugin(self, packagename, Edk2pathObj, pkgconfig, environment, PLM,
163163
# result is a list of strings like this
164164
# C:\src\sp-edk2\edk2\FmpDevicePkg\FmpDevicePkg.dec:53:9 - Unknown word (Capule)
165165
EasyFix = []
166+
MisspelledWordFound = False
166167
results = self._check_spelling(cpsell_paths, config_file_path)
167168
for r in results:
168169
path, _, word = r.partition(" - Unknown word ")
169170
if len(word) == 0:
170171
# didn't find pattern
171172
continue
173+
MisspelledWordFound = True
172174

173175
pathinfo = path.rsplit(":", 2) # remove the line no info
174176
if(ignore(pathinfo[0])): # check against ignore list
@@ -179,6 +181,14 @@ def RunBuildPlugin(self, packagename, Edk2pathObj, pkgconfig, environment, PLM,
179181
EasyFix.append(word.strip().strip("()"))
180182
Errors.append(r)
181183

184+
# _check_spelling reported errors lines, but none of them were misspelled words
185+
# This indicates a different kind of error occured, e.g. an error in running cspell
186+
if len(results) > 0 and not MisspelledWordFound:
187+
tc.LogStdError("Error running cspell. See output below:")
188+
tc.LogStdError("\n".join(results))
189+
tc.SetFailed(f"SpellCheck for {packagename} Failed to run cspell.", "CHECK_FAILED")
190+
return -1
191+
182192
# Log all errors tc StdError
183193
for l in Errors:
184194
tc.LogStdError(l.strip())

0 commit comments

Comments
 (0)