Skip to content

Commit

Permalink
Reset saved installer properties before each installer test.
Browse files Browse the repository at this point in the history
  • Loading branch information
reduckted committed Oct 3, 2023
1 parent 2669306 commit c41e497
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/packaging/windows/msi.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,20 @@ Describe -Name "Windows MSI" -Fixture {
$runtime = $env:PSMsiRuntime
$muEnabled = Test-IsMuEnabled

$propertiesRegKeyParent = "HKLM:\SOFTWARE\Microsoft\PowerShellCore"
if ($channel -eq "preview") {
$propertiesRegKeyName = "PreviewInstallerProperties"
} else {
$propertiesRegKeyName = "InstallerProperties"
}

# Rename the registry key that contains the saved installer
# properties so that the tests don't overwrite them.
$propertiesRegKeyPath = Join-Path -Path $propertiesRegKeyParent -ChildPath $propertiesRegKeyName
$propertiesBackupRegKeyName = "BackupInstallerProperties"
$propertiesBackupRegKeyPath = Join-Path -Path $propertiesRegKeyParent -ChildPath $propertiesBackupRegKeyName
Rename-Item -Path $propertiesRegKeyPath -NewName $propertiesBackupRegKeyName

# Get any existing powershell in the path
$beforePath = @(([System.Environment]::GetEnvironmentVariable('PATH', 'MACHINE')) -split ';' |
Where-Object {$_ -like '*files\powershell*'})
Expand All @@ -133,10 +147,15 @@ Describe -Name "Windows MSI" -Fixture {

AfterAll {
Set-StrictMode -Version 3.0

# Restore the original saved installer properties registry key.
Remove-Item -Path $propertiesRegKeyPath -ErrorAction SilentlyContinue
Rename-Item -Path $propertiesBackupRegKeyPath -NewName $propertiesRegKeyName
}

BeforeEach {
$error.Clear()
Remove-Item -Path $propertiesRegKeyPath -ErrorAction SilentlyContinue
}

Context "Upgrade code" {
Expand Down

0 comments on commit c41e497

Please sign in to comment.