Set clean state before testing UseMU in the MSI (#16543)

This commit is contained in:
Travis Plunk
2021-12-07 13:03:31 -08:00
committed by unknown
parent 6d4febaa35
commit f85ff3a62e
2 changed files with 39 additions and 1 deletions
+1
View File
@@ -51,6 +51,7 @@ pr:
- src/Microsoft.WSMan.Runtime/Microsoft.WSMan.Runtime.csproj
- src/Modules/PSGalleryModules.csproj
- src/powershell-win-core/powershell-win-core.csproj
- test/packaging/windows/*
- tools/ci.psm1
- tools/packaging/*
+38 -1
View File
@@ -39,7 +39,7 @@ Describe -Name "Windows MSI" -Fixture {
}
function Get-UseMU {
$useMu = 0
$useMu = $null
$key = 'HKLM:\SOFTWARE\Microsoft\PowerShellCore\'
if ($runtime -like '*x86*') {
$key = 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\PowerShellCore\'
@@ -49,6 +49,25 @@ Describe -Name "Windows MSI" -Fixture {
$useMu = Get-ItemPropertyValue -Path $key -Name UseMU -ErrorAction SilentlyContinue
} catch {}
if (!$useMu) {
$useMu = 0
}
return $useMu
}
function Set-UseMU {
param(
[int]
$Value
)
$key = 'HKLM:\SOFTWARE\Microsoft\PowerShellCore\'
if ($runtime -like '*x86*') {
$key = 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\PowerShellCore\'
}
Set-ItemProperty -Path $key -Name UseMU -Value $Value -Type DWord
return $useMu
}
@@ -185,6 +204,15 @@ Describe -Name "Windows MSI" -Fixture {
}
Context "Add Path disabled" {
BeforeAll {
Set-UseMU -Value 0
}
It "UseMU should be 0 before install" -Skip:(!(Test-Elevated)) {
$useMu = Get-UseMU
$useMu | Should -Be 0
}
It "MSI should install without error" -Skip:(!(Test-Elevated)) {
{
Invoke-MsiExec -Install -MsiPath $msiX64Path -Properties @{ADD_PATH = 0; USE_MU = 1; ENABLE_MU = 1}
@@ -213,6 +241,15 @@ Describe -Name "Windows MSI" -Fixture {
}
Context "USE_MU disabled" {
BeforeAll {
Set-UseMU -Value 0
}
It "UseMU should be 0 before install" -Skip:(!(Test-Elevated)) {
$useMu = Get-UseMU
$useMu | Should -Be 0
}
It "MSI should install without error" -Skip:(!(Test-Elevated)) {
{
Invoke-MsiExec -Install -MsiPath $msiX64Path -Properties @{USE_MU = 0}