From 0d7436b0422a4f89323e771f52935166be4897e4 Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Tue, 25 Aug 2026 10:51:42 -0700 Subject: [PATCH 1/2] Mark DSC Profile tests pending on MSIX test runs --- .../dsc/dsc.profileresource.Tests.ps1 | 79 ++++++++++++++++++- 1 file changed, 78 insertions(+), 1 deletion(-) diff --git a/test/powershell/dsc/dsc.profileresource.Tests.ps1 b/test/powershell/dsc/dsc.profileresource.Tests.ps1 index cb357c7350b..8e34fbc60c5 100644 --- a/test/powershell/dsc/dsc.profileresource.Tests.ps1 +++ b/test/powershell/dsc/dsc.profileresource.Tests.ps1 @@ -3,6 +3,13 @@ Describe "DSC PowerShell Profile Resource Tests" -Tag "CI" { BeforeAll { + + $isMsix = $pshome -like '*WindowsApps*' + if ($isMsix) { + Write-Verbose "Running in MSIX context. Marking tests as pending." -Verbose + return + } + $DSC_ROOT = $env:DSC_ROOT $skipCleanup = $false @@ -46,6 +53,10 @@ Describe "DSC PowerShell Profile Resource Tests" -Tag "CI" { return } + if ($isMsix) { + return + } + # Restore original profile $testProfilePathCurrentUserCurrentHost = $PROFILE.CurrentUserCurrentHost if (Test-Path "$TestDrive/currentuser-currenthost-profile.bak") { @@ -69,6 +80,12 @@ Describe "DSC PowerShell Profile Resource Tests" -Tag "CI" { } It 'DSC resource is located at $PSHome' { + + if ($isMsix) { + Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test." + return + } + $resourceFile = Join-Path -Path $PSHome -ChildPath 'pwsh.profile.resource.ps1' $resourceFile | Should -Exist @@ -77,39 +94,74 @@ Describe "DSC PowerShell Profile Resource Tests" -Tag "CI" { } It 'DSC resource can be found' { + if ($isMsix) { + Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test." + return + } + (& $dscExe resource list -o json | ConvertFrom-Json | Select-Object -Property type).type | Should -Contain 'Microsoft.PowerShell/Profile' } It 'DSC resource can set current user current host profile' { + if ($isMsix) { + Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test." + return + } + $setOutput = (& $dscExe config set --file $PSScriptRoot/psprofile_currentuser_currenthost.dsc.yaml -o json) | ConvertFrom-Json $expectedContent = "Write-Host 'Welcome to your PowerShell profile - CurrentUserCurrentHost!'" $setOutput.results.result.afterState.content | Should -BeExactly $expectedContent } It 'DSC resource can get current user current host profile' { + if ($isMsix) { + Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test." + return + } + $getOutput = (& $dscExe config get --file $PSScriptRoot/psprofile_currentuser_currenthost.dsc.yaml -o json) | ConvertFrom-Json $expectedContent = "Write-Host 'Welcome to your PowerShell profile - CurrentUserCurrentHost!'" $getOutput.results.result.actualState.content | Should -BeExactly $expectedContent } - It 'DSC resource can set content as empty for current user current host profile' -Pending { + It 'DSC resource can set content as empty for current user current host profile' { + if ($isMsix) { + Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test." + return + } + $setOutput = (& $dscExe config set --file $PSScriptRoot/psprofile_currentuser_currenthost_emptycontent.dsc.yaml -o json) | ConvertFrom-Json $setOutput.results.result.afterState.content | Should -BeExactly '' } It 'DSC resource can set current user all hosts profile' { + if ($isMsix) { + Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test." + return + } + $setOutput = (& $dscExe config set --file $PSScriptRoot/psprofile_currentuser_allhosts.dsc.yaml -o json) | ConvertFrom-Json $expectedContent = "Write-Host 'Welcome to your PowerShell profile - CurrentUserAllHosts!'" $setOutput.results.result.afterState.content | Should -BeExactly $expectedContent } It 'DSC resource can get current user all hosts profile' { + if ($isMsix) { + Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test." + return + } + $getOutput = (& $dscExe config get --file $PSScriptRoot/psprofile_currentuser_allhosts.dsc.yaml -o json) | ConvertFrom-Json $expectedContent = "Write-Host 'Welcome to your PowerShell profile - CurrentUserAllHosts!'" $getOutput.results.result.actualState.content | Should -BeExactly $expectedContent } It 'DSC resource can export all profiles' { + if ($isMsix) { + Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test." + return + } + $exportOutput = (& $dscExe config export --file $PSScriptRoot/psprofile_export.dsc.yaml -o json) | ConvertFrom-Json $exportOutput.resources | Should -HaveCount 4 @@ -123,6 +175,12 @@ Describe "DSC PowerShell Profile Resource Tests" -Tag "CI" { Describe "DSC PowerShell Profile resource elevated tests" -Tag "CI", 'RequireAdminOnWindows', 'RequireSudoOnUnix' { BeforeAll { + $isMsix = $pshome -like '*WindowsApps*' + if ($isMsix) { + Write-Verbose "Running in MSIX context. Marking tests as pending." -Verbose + return + } + $DSC_ROOT = $env:DSC_ROOT $skipCleanup = $false @@ -166,6 +224,10 @@ Describe "DSC PowerShell Profile resource elevated tests" -Tag "CI", 'RequireAdm return } + if ($isMsix) { + return + } + $env:PATH = $originalPath $testProfilePathAllUsersCurrentHost = $PROFILE.AllUsersCurrentHost @@ -189,6 +251,11 @@ Describe "DSC PowerShell Profile resource elevated tests" -Tag "CI", 'RequireAdm } It 'DSC resource can set all users all hosts profile' { + if ($isMsix) { + Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test." + return + } + $setOutput = (& $dscExe config set --file $PSScriptRoot/psprofile_alluser_allhost.dsc.yaml -o json) | ConvertFrom-Json $expectedContent = "Write-Host 'Welcome to your PowerShell profile - AllUsersAllHosts!'" $setOutput.results.result.afterState.content | Should -BeExactly $expectedContent @@ -201,12 +268,22 @@ Describe "DSC PowerShell Profile resource elevated tests" -Tag "CI", 'RequireAdm } It 'DSC resource can set all users current hosts profile' { + if ($isMsix) { + Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test." + return + } + $setOutput = (& $dscExe config set --file $PSScriptRoot/psprofile_allusers_currenthost.dsc.yaml -o json) | ConvertFrom-Json $expectedContent = "Write-Host 'Welcome to your PowerShell profile - AllUsersCurrentHost!'" $setOutput.results.result.afterState.content | Should -BeExactly $expectedContent } It 'DSC resource can get all users current hosts profile' { + if ($isMsix) { + Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test." + return + } + $getOutput = (& $dscExe config get --file $PSScriptRoot/psprofile_allusers_currenthost.dsc.yaml -o json) | ConvertFrom-Json $expectedContent = "Write-Host 'Welcome to your PowerShell profile - AllUsersCurrentHost!'" $getOutput.results.result.actualState.content | Should -BeExactly $expectedContent From c2ea044aff4e5baa7f61d8c408a446960cd055b9 Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Tue, 25 Aug 2026 11:02:07 -0700 Subject: [PATCH 2/2] Fix tests --- .../dsc/dsc.profileresource.Tests.ps1 | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/test/powershell/dsc/dsc.profileresource.Tests.ps1 b/test/powershell/dsc/dsc.profileresource.Tests.ps1 index 8e34fbc60c5..485646e4c28 100644 --- a/test/powershell/dsc/dsc.profileresource.Tests.ps1 +++ b/test/powershell/dsc/dsc.profileresource.Tests.ps1 @@ -82,7 +82,7 @@ Describe "DSC PowerShell Profile Resource Tests" -Tag "CI" { It 'DSC resource is located at $PSHome' { if ($isMsix) { - Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test." + Set-ItResult -Pending -Because "Running in MSIX context. Skipping test." return } @@ -95,7 +95,7 @@ Describe "DSC PowerShell Profile Resource Tests" -Tag "CI" { It 'DSC resource can be found' { if ($isMsix) { - Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test." + Set-ItResult -Pending -Because "Running in MSIX context. Skipping test." return } @@ -104,7 +104,7 @@ Describe "DSC PowerShell Profile Resource Tests" -Tag "CI" { It 'DSC resource can set current user current host profile' { if ($isMsix) { - Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test." + Set-ItResult -Pending -Because "Running in MSIX context. Skipping test." return } @@ -115,7 +115,7 @@ Describe "DSC PowerShell Profile Resource Tests" -Tag "CI" { It 'DSC resource can get current user current host profile' { if ($isMsix) { - Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test." + Set-ItResult -Pending -Because "Running in MSIX context. Skipping test." return } @@ -126,7 +126,7 @@ Describe "DSC PowerShell Profile Resource Tests" -Tag "CI" { It 'DSC resource can set content as empty for current user current host profile' { if ($isMsix) { - Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test." + Set-ItResult -Pending -Because "Running in MSIX context. Skipping test." return } @@ -136,7 +136,7 @@ Describe "DSC PowerShell Profile Resource Tests" -Tag "CI" { It 'DSC resource can set current user all hosts profile' { if ($isMsix) { - Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test." + Set-ItResult -Pending -Because "Running in MSIX context. Skipping test." return } @@ -147,7 +147,7 @@ Describe "DSC PowerShell Profile Resource Tests" -Tag "CI" { It 'DSC resource can get current user all hosts profile' { if ($isMsix) { - Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test." + Set-ItResult -Pending -Because "Running in MSIX context. Skipping test." return } @@ -158,7 +158,7 @@ Describe "DSC PowerShell Profile Resource Tests" -Tag "CI" { It 'DSC resource can export all profiles' { if ($isMsix) { - Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test." + Set-ItResult -Pending -Because "Running in MSIX context. Skipping test." return } @@ -252,7 +252,7 @@ Describe "DSC PowerShell Profile resource elevated tests" -Tag "CI", 'RequireAdm It 'DSC resource can set all users all hosts profile' { if ($isMsix) { - Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test." + Set-ItResult -Pending -Because "Running in MSIX context. Skipping test." return } @@ -262,6 +262,11 @@ Describe "DSC PowerShell Profile resource elevated tests" -Tag "CI", 'RequireAdm } It 'DSC resource can get all users all hosts profile' { + if ($isMsix) { + Set-ItResult -Pending -Because "Running in MSIX context. Skipping test." + return + } + $getOutput = (& $dscExe config get --file $PSScriptRoot/psprofile_alluser_allhost.dsc.yaml -o json) | ConvertFrom-Json $expectedContent = "Write-Host 'Welcome to your PowerShell profile - AllUsersAllHosts!'" $getOutput.results.result.actualState.content | Should -BeExactly $expectedContent @@ -269,7 +274,7 @@ Describe "DSC PowerShell Profile resource elevated tests" -Tag "CI", 'RequireAdm It 'DSC resource can set all users current hosts profile' { if ($isMsix) { - Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test." + Set-ItResult -Pending -Because "Running in MSIX context. Skipping test." return } @@ -280,7 +285,7 @@ Describe "DSC PowerShell Profile resource elevated tests" -Tag "CI", 'RequireAdm It 'DSC resource can get all users current hosts profile' { if ($isMsix) { - Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test." + Set-ItResult -Pending -Because "Running in MSIX context. Skipping test." return }