EvanZhu0721 / 公开仓库
SBMS
SBMS complete the calculation rules for the default logical desktop topology relationship and the physical dimensions of the displays in the Windows multi-screen collaboration system.
文件
../ build-installer-contract.Tests.ps13.0 KBinno-user-state.Tests.ps12.3 KBlaunch-entry-contract.Tests.ps18.1 KBmaintenance-compensation.Tests.ps15.3 KBprepare-upgrade.Tests.ps110.3 KBinstaller/tests/inno-user-state.Tests.ps12.3 KB
1
$ErrorActionPreference = 'Stop'2
Set-StrictMode -Version Latest3
4
$installerScript = [IO.Path]::GetFullPath(5
(Join-Path $PSScriptRoot '..\SBMS.iss')6
)7
8
function Get-InnoSection {9
param(10
[Parameter(Mandatory)]11
[string]$Source,12
13
[Parameter(Mandatory)]14
[string]$Name15
)16
17
$match = [regex]::Match(18
$Source,19
"(?ms)^\[$([regex]::Escape($Name))\]\s*(?<body>.*?)(?=^\[|\z)"20
)21
if (-not $match.Success) {22
throw "Inno Setup section [$Name] was not found."23
}24
$match.Groups['body'].Value25
}26
27
Describe 'Inno Setup user-state lifecycle contract' {28
BeforeAll {29
$script:source = [IO.File]::ReadAllText(30
$installerScript,31
[Text.Encoding]::UTF832
)33
}34
35
It 'does not delete LocalAppData SBMS state during install or upgrade' {36
$installDelete = Get-InnoSection `37
-Source $script:source `38
-Name 'InstallDelete'39
$activeEntries = @(40
$installDelete -split "`r?`n" |41
Where-Object { $_ -notmatch '^\s*;' }42
) -join "`n"43
44
$activeEntries | Should Not Match '(?i)\{localappdata\}\\SBMS'45
}46
47
It 'deletes the complete LocalAppData SBMS state on deliberate uninstall' {48
$uninstallDelete = Get-InnoSection `49
-Source $script:source `50
-Name 'UninstallDelete'51
$stateDeletes = @(52
[regex]::Matches(53
$uninstallDelete,54
'(?im)^\s*Type:\s*filesandordirs;\s*Name:\s*"\{localappdata\}\\SBMS"\s*$'55
)56
)57
58
$stateDeletes.Count | Should Be 159
}60
61
It 'prepares an existing installation before setup overwrites files' {62
$code = Get-InnoSection -Source $script:source -Name 'Code'63
64
$code | Should Match '(?s)function\s+PrepareToInstall\b.*?DirExists\(ExpandConstant\(''\{app\}''\)\).*?ExtractTemporaryFile\(''sbms-maintenance\.ps1''\).*?''PrepareUpgrade'''65
}66
67
It 'gates uninstall before changes and runs external cleanup at usUninstall' {68
$code = Get-InnoSection -Source $script:source -Name 'Code'69
70
$code | Should Match '(?s)function\s+InitializeUninstall\b.*?RunMaintenance\(''PreflightUninstall'''71
$code | Should Match '(?s)procedure\s+CurUninstallStepChanged\b.*?CurUninstallStep\s*=\s*usUninstall.*?RunMaintenance\(''Uninstall'''72
}73
}74