@@ -27,6 +27,14 @@ $safetyTerms = @(
2727 ' not hardware certification'
2828)
2929
30+ $installerAssetName = ' LemonSerialMonitor-Setup-x64.exe'
31+ $installerDownloadPaths = @ (
32+ ' README.md' ,
33+ ' README.en.md' ,
34+ ' docs/INSTALL.md' ,
35+ ' docs/INSTALL.en.md'
36+ )
37+
3038function Write-TestUtf8File {
3139 param (
3240 [Parameter (Mandatory )][string ] $Path ,
@@ -51,14 +59,17 @@ function New-BilingualDocsFixture {
5159 ' # Chinese fixture' ,
5260 " [English]($englishBaseName )"
5361 )
54- if ($pair .Key -eq ' README.md ' ) {
55- $chineseLines += ' Download LemonSerialMonitor-Setup-x64.exe. '
62+ if ($script :installerDownloadPaths -contains $pair .Key ) {
63+ $chineseLines += " Download $ script :installerAssetName . "
5664 }
5765
5866 $englishLines = @ (
5967 ' # English fixture' ,
6068 " [Chinese]($chineseBaseName )"
6169 )
70+ if ($script :installerDownloadPaths -contains $pair.Value ) {
71+ $englishLines += " Download $script :installerAssetName ."
72+ }
6273 if ($pair.Value -eq ' README.en.md' ) {
6374 $englishLines += $script :safetyTerms
6475 }
@@ -165,20 +176,28 @@ Describe 'Bilingual documentation guard' {
165176 $message | Should Match ' UTF-8'
166177 }
167178
168- It ' rejects the wrong installer asset name in README.md' {
169- $root = Join-Path $TestDrive ' wrong-installer'
179+ It ' rejects the wrong installer asset name in <RelativePath>' - TestCases @ (
180+ @ { RelativePath = ' README.md' },
181+ @ { RelativePath = ' README.en.md' },
182+ @ { RelativePath = ' docs/INSTALL.md' },
183+ @ { RelativePath = ' docs/INSTALL.en.md' }
184+ ) {
185+ param ([string ] $RelativePath )
186+
187+ $fixtureName = $RelativePath -replace ' [^A-Za-z0-9]' , ' -'
188+ $root = Join-Path $TestDrive (' wrong-installer-' + $fixtureName )
170189 New-BilingualDocsFixture - Root $root
171- $readmePath = Join-Path $root ' README.md '
172- $readme = [IO.File ]::ReadAllText($readmePath )
190+ $documentPath = Join-Path $root $RelativePath
191+ $document = [IO.File ]::ReadAllText($documentPath )
173192 Write-TestUtf8File `
174- - Path $readmePath `
175- - Content $readme .Replace (
176- ' LemonSerialMonitor-Setup-x64.exe ' ,
193+ - Path $documentPath `
194+ - Content $document .Replace (
195+ $installerAssetName ,
177196 ' LemonSerialMonitor-Setup.exe' )
178197
179198 $message = Get-BilingualGuardError - Root $root
180199
181- $message | Should Match ' README\.md '
200+ $message | Should Match ([ regex ]::Escape( $RelativePath ))
182201 $message | Should Match ' LemonSerialMonitor-Setup-x64\.exe'
183202 }
184203
0 commit comments