Skip to content

Mark DSC Profile tests pending on MSIX test runs - #27884

Open
Aditya Patwardhan (adityapatwardhan) wants to merge 2 commits into
masterfrom
pendingDSCProfileTests
Open

Mark DSC Profile tests pending on MSIX test runs#27884
Aditya Patwardhan (adityapatwardhan) wants to merge 2 commits into
masterfrom
pendingDSCProfileTests

Conversation

@adityapatwardhan

Copy link
Copy Markdown
Member

PR Summary

This pull request updates the dsc.profileresource.Tests.ps1 test suite to improve compatibility with MSIX-packaged PowerShell environments. The main enhancement is the detection of the MSIX context, which results in tests being marked as pending and skipped when running in this environment. This prevents false failures due to known limitations of MSIX installations.

Key changes:

MSIX Context Detection and Handling:

  • Added logic at the start of each test group (BeforeAll) to detect if the tests are running in an MSIX context by checking if $pshome contains WindowsApps. If so, a verbose message is logged and the tests are marked as pending or skipped. [1] [2]
  • Inserted checks at the beginning of each test case to skip the test and mark it as pending with a clear reason if running in MSIX context. This is done using Set-ItResult -Pending. [1] [2] [3] [4]

Test Flow Adjustments:

  • Ensured that cleanup and restoration logic in AfterAll and BeforeAll blocks also respect the MSIX context and exit early if detected. [1] [2]

These changes make the test suite more robust and prevent unnecessary test failures when running under MSIX-packaged PowerShell.

PR Context

PR Checklist

Copilot AI lite review requested due to automatic review settings August 25, 2026 17:52
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the DSC profile resource Pester tests to detect when they’re running under an MSIX-installed PowerShell (WindowsApps path) and avoid false failures by short-circuiting setup/cleanup and marking tests as Pending in that environment.

Changes:

  • Added MSIX-context detection ($PSHome -like '*WindowsApps*') in each BeforeAll and early-exit behavior.
  • Added per-test MSIX guards intended to mark affected tests as Pending during MSIX runs.
  • Updated cleanup blocks (AfterAll) to no-op under MSIX context.
Suppressed comments (10)

test/powershell/dsc/dsc.profileresource.Tests.ps1:98

  • Set-ItResult in Pester uses -Because, not -Reason. Using -Reason will throw a parameter binding error and fail the test instead of marking it Pending.
            Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test."

test/powershell/dsc/dsc.profileresource.Tests.ps1:107

  • Set-ItResult in Pester uses -Because, not -Reason. Using -Reason will throw a parameter binding error and fail the test instead of marking it Pending.
            Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test."

test/powershell/dsc/dsc.profileresource.Tests.ps1:118

  • Set-ItResult in Pester uses -Because, not -Reason. Using -Reason will throw a parameter binding error and fail the test instead of marking it Pending.
            Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test."

test/powershell/dsc/dsc.profileresource.Tests.ps1:129

  • Set-ItResult in Pester uses -Because, not -Reason. Using -Reason will throw a parameter binding error and fail the test instead of marking it Pending.
            Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test."

test/powershell/dsc/dsc.profileresource.Tests.ps1:139

  • Set-ItResult in Pester uses -Because, not -Reason. Using -Reason will throw a parameter binding error and fail the test instead of marking it Pending.
            Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test."

test/powershell/dsc/dsc.profileresource.Tests.ps1:150

  • Set-ItResult in Pester uses -Because, not -Reason. Using -Reason will throw a parameter binding error and fail the test instead of marking it Pending.
            Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test."

test/powershell/dsc/dsc.profileresource.Tests.ps1:161

  • Set-ItResult in Pester uses -Because, not -Reason. Using -Reason will throw a parameter binding error and fail the test instead of marking it Pending.
            Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test."

test/powershell/dsc/dsc.profileresource.Tests.ps1:255

  • Set-ItResult in Pester uses -Because, not -Reason. Using -Reason will throw a parameter binding error and fail the test instead of marking it Pending.
            Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test."

test/powershell/dsc/dsc.profileresource.Tests.ps1:272

  • Set-ItResult in Pester uses -Because, not -Reason. Using -Reason will throw a parameter binding error and fail the test instead of marking it Pending.
            Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test."

test/powershell/dsc/dsc.profileresource.Tests.ps1:283

  • Set-ItResult in Pester uses -Because, not -Reason. Using -Reason will throw a parameter binding error and fail the test instead of marking it Pending.
            Set-ItResult -Pending -Reason "Running in MSIX context. Skipping test."

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread test/powershell/dsc/dsc.profileresource.Tests.ps1 Outdated
Comment thread test/powershell/dsc/dsc.profileresource.Tests.ps1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants