Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
1df30e0
Update SECURITY.md to remove email reporting option (#26653)
TravisEz13 Jan 5, 2026
867d799
Add default CODEOWNERS entry for maintainers (#26660)
TravisEz13 Jan 6, 2026
4838a8d
Bump github/codeql-action from 4.31.8 to 4.31.9 (#26623)
dependabot[bot] Jan 6, 2026
7ace9e0
Improve error message from `Start-NativeExecution` (#26500)
logiclrd Jan 9, 2026
5ebba3c
Delete unused winget release script (#26683)
anamnavi Jan 12, 2026
bf03a14
Fix the CLR internal error and null ref exception when running `show-…
daxian-dbw Jan 12, 2026
c792b3c
Fix to use accurate message for validating a string argument is not n…
daxian-dbw Jan 12, 2026
9bc4795
Add `ValidateNotNullOrEmpty` attribute to the `-Property` of `Format-…
daxian-dbw Jan 12, 2026
20382c8
Update outdated package references (#26656)
pwshBot Jan 12, 2026
76bc34e
Bump github/codeql-action from 4.31.9 to 4.31.10 (#26686)
dependabot[bot] Jan 13, 2026
1241ad2
Remove unused runCodesignValidationInjection variable from pipeline t…
Copilot Jan 14, 2026
bd33c2d
Update metadata.json to update the Latest attribute with a better nam…
adityapatwardhan Jan 14, 2026
5fdc2a0
Fix macOS preview package identifier detection to use version string …
Copilot Jan 15, 2026
276989f
Update Microsoft.PowerShell.PSResourceGet version to 1.2.0-rc1 (#26691)
anamnavi Jan 20, 2026
0931a75
Fix `buildinfo.json` uploading for preview, LTS, and stable releases …
jshigetomi Jan 21, 2026
dab346a
Move PowerShell build to depend on .NET SDK 10.0.102 (#26697)
pwshBot Jan 21, 2026
f5c290c
Fix WSManInstance COM interface with ResourceURI (#26692)
jborean93 Jan 21, 2026
7f9c746
Support TargetObject position in ParserErrors (#26649)
jborean93 Jan 21, 2026
f57643f
Bump github/codeql-action from 4.31.10 to 4.32.0 (#26726)
dependabot[bot] Jan 27, 2026
b3a3864
Add policy to restrict the `Approved-LowRisk` label (#26728)
Copilot Jan 28, 2026
8489f8f
Mark `-NoTypeInformation` as obsolete no-op and evaluate `-IncludeTyp…
yotsuda Jan 28, 2026
34f6e26
Add CodeQL suppressions for NativeCommandProcessor (#26729)
anamnavi Feb 3, 2026
467059c
Bump github/codeql-action from 4.32.0 to 4.32.1 (#26741)
dependabot[bot] Feb 3, 2026
d549774
Update `Microsoft.PowerShell.Native` package version (#26746)
adityapatwardhan Feb 4, 2026
dd4f2fe
Add comprehensive scalar type tests for `ConvertTo-Json` (#26736)
yotsuda Feb 5, 2026
4382544
Add comprehensive array and dictionary tests for `ConvertTo-Json` (#2…
yotsuda Feb 6, 2026
e58d395
Create es-metadata (#26759)
TravisEz13 Feb 6, 2026
012529a
Update Microsoft.PowerShell.PSResourceGet version to 1.2.0-rc3 (#26753)
anamnavi Feb 9, 2026
664ac75
Add comprehensive depth and multilevel composition tests for `Convert…
yotsuda Feb 10, 2026
42371b8
Add `SubjectAlternativeName` property to the `Signature` object retur…
Copilot Feb 10, 2026
9f9f8b9
Bump github/codeql-action from 4.32.1 to 4.32.2 (#26755)
dependabot[bot] Feb 10, 2026
439c42f
Update outdated package references (#26771)
pwshBot Feb 10, 2026
2e26e4b
Update the `Update-Help` tests to use `-Force` to remove read-only fi…
daxian-dbw Feb 12, 2026
4db414c
Add GitHub Actions annotations for Pester test failures (#26789)
Copilot Feb 12, 2026
6b8d724
Mark flaky Update-Help web tests as pending to unblock CI (#26796)
Copilot Feb 13, 2026
08b13f2
Add Pester CI Analysis Skill (#26806)
TravisEz13 Feb 13, 2026
8f457fc
Skip the flaky `Update-Help` test for the `PackageManagement` module …
daxian-dbw Feb 17, 2026
f3b5603
Bump github/codeql-action from 4.32.2 to 4.32.3 (#26839)
dependabot[bot] Feb 18, 2026
9d68a05
Add comprehensive `PSCustomObject` tests for `ConvertTo-Json` (#26743)
yotsuda Feb 18, 2026
1965e05
Fix up default value for parameters with the `in` modifier (#26785)
jborean93 Feb 18, 2026
212c5f9
Update to .NET 11 SDK and update dependencies (#26783)
adityapatwardhan Feb 19, 2026
2af5ad1
Update `LangVersion` to `preview` (#26214)
xtqqczze Feb 19, 2026
2f08eb4
Add comprehensive PowerShell class tests for `ConvertTo-Json` (#26769)
yotsuda Feb 19, 2026
cf40400
Fetch latest ICU release version dynamically (#26827)
kasperk81 Feb 19, 2026
6a91b1f
Bring the `v7.6.0-rc.1` changelog to master (#26857)
SeeminglyScience Feb 20, 2026
f2c9775
Update metadata.json for v7.6.0-rc.1 (#26856)
SeeminglyScience Feb 20, 2026
b58ec36
Exclude .exe packages from publishing to GitHub (#26859)
daxian-dbw Feb 20, 2026
c19a440
Fix `Import-Module.Tests.ps1` to handle Arm32 platform (#26862)
daxian-dbw Feb 20, 2026
19fa6a9
Remove obsolete `CA2006` rule suppression (#25939)
xtqqczze Feb 23, 2026
cfd5966
Enable CA1852: Seal internal types (#25890)
xtqqczze Feb 23, 2026
7ca2b72
Fix a preview detection test for the packaging script (#26882)
daxian-dbw Feb 23, 2026
f3eb51b
Add GitOps policy to auto-label backport candidates when CL-BuildPack…
Copilot Feb 23, 2026
7cdcd58
Correct the package name for .deb and .rpm packages (#26877)
daxian-dbw Feb 23, 2026
43d4388
Bump github/codeql-action from 4.32.3 to 4.32.4 (#26879)
dependabot[bot] Feb 23, 2026
a6e0d94
Bump actions/dependency-review-action from 4.8.2 to 4.8.3 (#26861)
dependabot[bot] Feb 23, 2026
7311378
Add version in description and pass store task on failure (#26885)
jshigetomi Feb 24, 2026
6e2b4c7
Split TPN manifest and Component Governance manifest (#26891)
TravisEz13 Feb 25, 2026
95e3894
Add PMC packages for debian13 and rhel10 (#26912)
anamnavi Feb 26, 2026
3544ce5
Update PowerShell Profile DSC resource manifests to allow null for co…
adityapatwardhan Mar 2, 2026
eb1915e
Hardcode Official templates (#26928)
jshigetomi Mar 9, 2026
2c14e11
Bump github/codeql-action from 4.32.4 to 4.32.6 (#26942)
dependabot[bot] Mar 9, 2026
1ee3d71
Bump actions/dependency-review-action from 4.8.3 to 4.9.0 (#26938)
dependabot[bot] Mar 9, 2026
e170b72
Bump actions/upload-artifact from 6 to 7 (#26914)
dependabot[bot] Mar 9, 2026
3122917
Fix ConvertFrom-ClearlyDefinedCoordinates to handle API object coordi…
Copilot Mar 10, 2026
e31e949
Initial plan
Copilot Jan 1, 2026
610b11b
Add &! ThreadJob background operator support
Copilot Jan 1, 2026
7da107d
Add tests for ThreadJob background operator
Copilot Jan 1, 2026
e3629b5
Add exception handling for Start-ThreadJob cmdlet lookup
Copilot Jan 1, 2026
304fbd9
Use specific exception types in catch blocks for Start-ThreadJob lookup
Copilot Jan 1, 2026
9c1b31f
Fix compilation errors: move BackgroundThreadJob to ChainableAst and …
Copilot Jan 2, 2026
942a92a
Move BackgroundThreadJob property to PipelineBaseAst base class
Copilot Jan 2, 2026
ec2a360
Address PR review feedback: improve tests and simplify exception hand…
Copilot Mar 11, 2026
f8dbefe
Fix binary-breaking change: move AmpersandExclaim token to end of enum
Copilot Mar 11, 2026
41a0b69
Remove accidentally committed backup file
Copilot Mar 11, 2026
c13cfb7
Fix parser error with &! operator - set flags correctly
Copilot Mar 11, 2026
873f95a
Fix &! operator recognition in PipelineRule switch statement
Copilot Mar 11, 2026
fd02511
Fix missing backgroundThreadJob variable declaration in PipelineRule
Copilot Mar 11, 2026
25a95b8
Fix ThreadJob detection by using GetCommand instead of GetCmdlet
Copilot Mar 11, 2026
c70291b
Fix compilation error: properly handle CommandInfo type checking
Copilot Mar 11, 2026
10a2b53
Fix WorkingDirectory parameter error with Start-ThreadJob
Copilot Mar 11, 2026
a1370eb
Fix script block literal execution with &! operator
Copilot Mar 11, 2026
75d0598
Fix compilation error: cast PipelineBaseAst to PipelineAst before acc…
Copilot Mar 11, 2026
92ee6b3
Fix BackgroundThreadJob property not set on PipelineChainAst
Copilot Mar 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# Areas are not limited to the filters defined in this file
# First, let's start with areas with no filters or paths

# Default
* @PowerShell/powershell-maintainers

# Area: Performance
# @adityapatwardhan

Expand Down
4 changes: 1 addition & 3 deletions .github/SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ If you believe you have found a security vulnerability in any Microsoft-owned re

Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/security.md/msrc/create-report).

If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/security.md/msrc/pgp).

You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).
You should receive a response within 24 hours. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).

Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ $testIgnoredCount = 0
$testSkippedCount = 0
$testInvalidCount = 0

# Process test results and generate annotations for failures
Get-ChildItem -Path "${TestResultsFolder}/*.xml" -Recurse | ForEach-Object {
$results = [xml] (get-content $_.FullName)

Expand All @@ -35,6 +36,61 @@ Get-ChildItem -Path "${TestResultsFolder}/*.xml" -Recurse | ForEach-Object {
$testIgnoredCount += [int]$results.'test-results'.ignored
$testSkippedCount += [int]$results.'test-results'.skipped
$testInvalidCount += [int]$results.'test-results'.invalid

# Generate GitHub Actions annotations for test failures
# Select failed test cases
if ("System.Xml.XmlDocumentXPathExtensions" -as [Type]) {
$failures = [System.Xml.XmlDocumentXPathExtensions]::SelectNodes($results.'test-results', './/test-case[@result = "Failure"]')
}
else {
$failures = $results.SelectNodes('.//test-case[@result = "Failure"]')
}

foreach ($testfail in $failures) {
$description = $testfail.description
$testName = $testfail.name
$message = $testfail.failure.message
$stack_trace = $testfail.failure.'stack-trace'

# Parse stack trace to get file and line info
$fileInfo = Get-PesterFailureFileInfo -StackTraceString $stack_trace

if ($fileInfo.File) {
# Convert absolute path to relative path for GitHub Actions
$filePath = $fileInfo.File

# GitHub Actions expects paths relative to the workspace root
if ($env:GITHUB_WORKSPACE) {
$workspacePath = $env:GITHUB_WORKSPACE
if ($filePath.StartsWith($workspacePath)) {
$filePath = $filePath.Substring($workspacePath.Length).TrimStart('/', '\')
# Normalize to forward slashes for consistency
$filePath = $filePath -replace '\\', '/'
}
}

# Create annotation title
$annotationTitle = "Test Failure: $description / $testName"

# Build the annotation message
$annotationMessage = $message -replace "`n", "%0A" -replace "`r"

# Build and output the workflow command
$workflowCommand = "::error file=$filePath"
if ($fileInfo.Line) {
$workflowCommand += ",line=$($fileInfo.Line)"
}
$workflowCommand += ",title=$annotationTitle::$annotationMessage"

Write-Host $workflowCommand

# Output a link to the test run
if ($env:GITHUB_SERVER_URL -and $env:GITHUB_REPOSITORY -and $env:GITHUB_RUN_ID) {
$logUrl = "$($env:GITHUB_SERVER_URL)/$($env:GITHUB_REPOSITORY)/actions/runs/$($env:GITHUB_RUN_ID)"
Write-Host "Test logs: $logUrl"
}
}
}
}

@"
Expand Down
198 changes: 198 additions & 0 deletions .github/instructions/pester-set-itresult-pattern.instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
---
applyTo:
- "**/*.Tests.ps1"
---

# Pester Set-ItResult Pattern for Pending and Skipped Tests

## Purpose

This instruction explains when and how to use `Set-ItResult` in Pester tests to mark tests as Pending or Skipped dynamically within test execution.

## When to Use Set-ItResult

Use `Set-ItResult` when you need to conditionally mark a test as Pending or Skipped based on runtime conditions that can't be determined at test definition time.

### Pending vs Skipped

**Pending**: Use for tests that should be enabled but temporarily can't run due to:
- Intermittent external service failures (network, APIs)
- Known bugs being fixed
- Missing features being implemented
- Environmental issues that are being resolved

**Skipped**: Use for tests that aren't applicable to the current environment:
- Platform-specific tests running on wrong platform
- Tests requiring specific hardware/configuration not present
- Tests requiring elevated permissions when not available
- Feature-specific tests when feature is disabled

## Pattern

### Basic Usage

```powershell
It "Test description" {
if ($shouldBePending) {
Set-ItResult -Pending -Because "Explanation of why test is pending"
return
}

if ($shouldBeSkipped) {
Set-ItResult -Skipped -Because "Explanation of why test is skipped"
return
}

# Test code here
}
```

### Important: Always Return After Set-ItResult

After calling `Set-ItResult`, you **must** return from the test to prevent further execution:

```powershell
It "Test that checks environment" {
if ($env:SKIP_TESTS -eq 'true') {
Set-ItResult -Skipped -Because "SKIP_TESTS environment variable is set"
return # This is required!
}

# Test assertions
$result | Should -Be $expected
}
```

**Why?** Without `return`, the test continues executing and may fail with errors unrelated to the pending/skipped condition.

## Examples from the Codebase

### Example 1: Pending for Intermittent Network Issues

```powershell
It "Validate Update-Help for module" {
if ($markAsPending) {
Set-ItResult -Pending -Because "Update-Help from the web has intermittent connectivity issues. See issues #2807 and #6541."
return
}

Update-Help -Module $moduleName -Force
# validation code...
}
```

### Example 2: Skipped for Missing Environment

```powershell
It "Test requires CI environment" {
if (-not $env:CI) {
Set-ItResult -Skipped -Because "Test requires CI environment to safely install Pester"
return
}

Install-CIPester -ErrorAction Stop
}
```

### Example 3: Pending for Platform-Specific Issue

```powershell
It "Clear-Host works correctly" {
if ($IsARM64) {
Set-ItResult -Pending -Because "ARM64 runs in non-interactively mode and Clear-Host does not work."
return
}

& { Clear-Host; 'hi' } | Should -BeExactly 'hi'
}
```

### Example 4: Skipped for Missing Feature

```powershell
It "Test ACR authentication" {
if ($env:ACRTESTS -ne 'true') {
Set-ItResult -Skipped -Because "The tests require the ACRTESTS environment variable to be set to 'true' for ACR authentication."
return
}

$psgetModuleInfo = Find-PSResource -Name $ACRTestModule -Repository $ACRRepositoryName
# test assertions...
}
```

## Alternative: Static -Skip and -Pending Parameters

For conditions that can be determined at test definition time, use the static parameters instead:

```powershell
# Static skip - condition known at definition time
It "Windows-only test" -Skip:(-not $IsWindows) {
# test code
}

# Static pending - always pending
It "Test for feature being implemented" -Pending {
# test code that will fail until feature is done
}
```

**Use Set-ItResult when**:
- Condition depends on runtime state
- Condition is determined inside a helper function
- Need to check multiple conditions sequentially

**Use static parameters when**:
- Condition is known at test definition
- Condition doesn't change during test run
- Want Pester to show the condition in test discovery

## Best Practices

1. **Always include -Because parameter** with a clear explanation
2. **Always return after Set-ItResult** to prevent further execution
3. **Reference issues or documentation** when relevant (e.g., "See issue #1234")
4. **Be specific in the reason** - explain what's wrong and what's needed
5. **Use Pending sparingly** - it indicates a problem that should be fixed
6. **Prefer Skipped over Pending** when test truly isn't applicable

## Common Mistakes

### ❌ Mistake 1: Forgetting to Return

```powershell
It "Test" {
if ($condition) {
Set-ItResult -Pending -Because "Reason"
# Missing return - test code will still execute!
}
$value | Should -Be $expected # This runs and fails
}
```

### ❌ Mistake 2: Vague Reason

```powershell
Set-ItResult -Pending -Because "Doesn't work" # Too vague
```

### βœ… Correct:

```powershell
It "Test" {
if ($condition) {
Set-ItResult -Pending -Because "Update-Help has intermittent network timeouts. See issue #2807."
return
}
$value | Should -Be $expected
}
```

## See Also

- [Pester Documentation: Set-ItResult](https://pester.dev/docs/commands/Set-ItResult)
- [Pester Documentation: It](https://pester.dev/docs/commands/It)
- Examples in the codebase:
- `test/powershell/Host/ConsoleHost.Tests.ps1`
- `test/infrastructure/ciModule.Tests.ps1`
- `tools/packaging/releaseTests/sbom.tests.ps1`
Loading