Skip to content
This repository was archived by the owner on Feb 24, 2021. It is now read-only.

Commit 2a02339

Browse files
committed
Refactor again
1 parent c08a4d2 commit 2a02339

File tree

1 file changed

+26
-34
lines changed

1 file changed

+26
-34
lines changed

Meta.Tests.ps1

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,42 +1092,34 @@ Describe 'Common Tests - Spellcheck Files' -Tag 'Spellcheck' {
10921092
$spellcheckSettingsFilePath = $null
10931093
}
10941094

1095+
$cSpellArgumentList = @(
1096+
'"**/*.md"',
1097+
'--no-color'
1098+
)
10951099

1100+
if ($spellcheckSettingsFilePath)
10961101
{
1097-
<#
1098-
cSpell returns a verbose string in the error stream
1099-
"CSpell: Files checked: X, Issues found: Y in Z files".
1100-
It will return this in the error stream regardless if there
1101-
are any errors or not.
1102-
See issue https://github.com/Jason3S/cspell/issues/61.
1103-
This will redirect the output stream to file to be output
1104-
after the test fail.
1105-
#>
1106-
try
1107-
{
1108-
if ($spellcheckSettingsFilePath)
1109-
{
1110-
& cspell '**/*.md' --no-color --config $spellcheckSettingsFilePath >SpellingErrors.txt
1111-
}
1112-
else
1113-
{
1114-
& cspell '**/*.md' --no-color >SpellingErrors.txt
1115-
}
1116-
}
1117-
catch
1118-
{
1119-
$noErrorsRegEx = 'CSpell: Files checked: [0-9]+, Issues found: [0] in [0-9]+ files'
1120-
Write-Verbose $_.Exception.Message -Verbose
1121-
<#
1122-
Only throw an error if there are 0 issues found in the
1123-
error message.
1124-
#>
1125-
if (-not $_.Exception.Message -match $noErrorsRegEx)
1126-
{
1127-
throw $_.Exception.Message
1128-
}
1129-
}
1130-
} | Should -Not -Throw
1102+
$cSpellArgumentList += @(
1103+
'--config',
1104+
$spellcheckSettingsFilePath
1105+
)
1106+
}
1107+
1108+
# This must be last, we send output to the error file.
1109+
$cSpellArgumentList += @(
1110+
('>{0}' -f $errorFileName)
1111+
)
1112+
1113+
$startProcessParameters = @{
1114+
FilePath = 'cspell'
1115+
ArgumentList = $cSpellArgumentList
1116+
Wait = $true
1117+
PassThru = $true
1118+
NoNewWindow = $true
1119+
}
1120+
1121+
$process = Start-Process @startProcessParameters
1122+
$process.ExitCode | Should -Be 0
11311123
} -ErrorVariable itBlockError
11321124

11331125
# If the It-block did not pass the test, output the spelling errors.

0 commit comments

Comments
 (0)