From f6ac1bea850ef991d9243f6392dd85cf98bfd4e4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 7 Jan 2026 00:00:30 +0000 Subject: [PATCH 1/4] Initial plan From d88cb25a16b06a2457f97ed79dc7d3657a9c98d3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 7 Jan 2026 00:07:36 +0000 Subject: [PATCH 2/4] Add documentation for skipping individual PSModule framework tests Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com> --- README.md | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/README.md b/README.md index c3538716..d05072de 100644 --- a/README.md +++ b/README.md @@ -445,6 +445,102 @@ This is useful for reviewing what was checked even when no issues are found. For a complete list of available environment variables and configuration options, see the [super-linter environment variables documentation](https://github.com/super-linter/super-linter#environment-variables). +## Skipping Individual Framework Tests + +The PSModule framework tests run automatically as part of the `Test-Module` and `Test-SourceCode` jobs. While you can skip entire test categories using the configuration settings (e.g., `Test.PSModule.Skip`), you can also skip individual framework tests on a per-file basis when needed. + +### How to Skip Tests + +To skip an individual framework test for a specific file, add a special comment at the top of that file: + +```powershell +#SkipTest:: +``` + +- ``: The unique identifier of the test to skip (see list below) +- ``: A brief explanation of why the test is being skipped + +The skip comment will cause the framework to skip that specific test for that file only, and will log a warning in the build output with the reason provided. + +### Available Framework Tests + +#### SourceCode Tests + +These tests run against your source code files in the `src` directory: + +| Test ID | Description | Example Skip Comment | +|---------|-------------|---------------------| +| `NumberOfProcessors` | Enforces use of `[System.Environment]::ProcessorCount` instead of `$env:NUMBER_OF_PROCESSORS` | `#SkipTest:NumberOfProcessors:Legacy code compatibility required` | +| `Verbose` | Ensures `-Verbose` is not used unless explicitly disabled with `:$false` | `#SkipTest:Verbose:Required for debugging output` | +| `OutNull` | Enforces use of `$null = ...` instead of `... \| Out-Null` for better performance | `#SkipTest:OutNull:Pipeline output needed for compatibility` | +| `NoTernary` | Checks for ternary operators (currently skipped by default for PowerShell 7+ compatibility) | `#SkipTest:NoTernary:PowerShell 7+ only module` | +| `LowercaseKeywords` | Ensures all PowerShell keywords are lowercase | `#SkipTest:LowercaseKeywords:Generated code` | +| `FunctionCount` | Ensures each file contains exactly one function | `#SkipTest:FunctionCount:Helper functions included` | +| `FunctionName` | Ensures the filename matches the function name | `#SkipTest:FunctionName:Legacy naming convention` | +| `CmdletBinding` | Requires all functions to have `[CmdletBinding()]` attribute | `#SkipTest:CmdletBinding:Simple helper function` | +| `ParamBlock` | Requires all functions to have a `param()` block | `#SkipTest:ParamBlock:No parameters needed` | +| `FunctionTest` | Ensures all public functions have corresponding tests | `#SkipTest:FunctionTest:Test in development` | + +#### Module Tests + +These tests run against the compiled module in the `outputs/module` directory: + +- Module import validation +- Module manifest validation + +Module tests typically don't need to be skipped as they validate the final built module. + +### Example Usage + +Here's an example of a function file that skips the `FunctionCount` test because it includes helper functions: + +```powershell +#SkipTest:FunctionCount:This file contains helper functions for the main function + +function Get-ComplexData { + <# + .SYNOPSIS + Retrieves complex data using helper functions. + #> + [CmdletBinding()] + param( + [Parameter(Mandatory)] + [string] $Path + ) + + $data = Get-RawData -Path $Path + $processed = Format-ComplexData -Data $data + return $processed +} + +function Get-RawData { + param([string]$Path) + # Helper function implementation +} + +function Format-ComplexData { + param($Data) + # Helper function implementation +} +``` + +### Best Practices + +- **Use skip comments sparingly**: Framework tests exist to maintain code quality and consistency. Only skip tests when absolutely necessary. +- **Provide clear reasons**: Always include a meaningful explanation in the skip comment to help reviewers understand why the test is being skipped. +- **Consider alternatives**: Before skipping a test, consider whether refactoring the code to comply with the test would be better for long-term maintainability. +- **Document exceptions**: If you skip a test, document the reason in your PR description or code comments. + +### Related Configuration + +For broader test control, use the configuration file settings: + +- Skip all framework tests: `Test.PSModule.Skip: true` +- Skip only source code tests: `Test.SourceCode.Skip: true` +- Skip framework tests on specific OS: `Test.PSModule.Windows.Skip: true` + +See the [Configuration](#configuration) section for more details. + ## Specifications and practices The process is compatible with: From 13e20357e022f67498bf2824b8a620128eabc316 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 7 Jan 2026 00:09:48 +0000 Subject: [PATCH 3/4] Improve test descriptions based on code review feedback Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com> --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d05072de..512a2bec 100644 --- a/README.md +++ b/README.md @@ -471,9 +471,9 @@ These tests run against your source code files in the `src` directory: | Test ID | Description | Example Skip Comment | |---------|-------------|---------------------| | `NumberOfProcessors` | Enforces use of `[System.Environment]::ProcessorCount` instead of `$env:NUMBER_OF_PROCESSORS` | `#SkipTest:NumberOfProcessors:Legacy code compatibility required` | -| `Verbose` | Ensures `-Verbose` is not used unless explicitly disabled with `:$false` | `#SkipTest:Verbose:Required for debugging output` | -| `OutNull` | Enforces use of `$null = ...` instead of `... \| Out-Null` for better performance | `#SkipTest:OutNull:Pipeline output needed for compatibility` | -| `NoTernary` | Checks for ternary operators (currently skipped by default for PowerShell 7+ compatibility) | `#SkipTest:NoTernary:PowerShell 7+ only module` | +| `Verbose` | Prevents use of `-Verbose` parameter in code (should only be used with `:$false` qualifier to explicitly disable) | `#SkipTest:Verbose:Required for debugging output` | +| `OutNull` | Enforces use of `$null = ...` instead of `... \| Out-Null` for better performance | `#SkipTest:OutNull:Pipeline processing required` | +| `NoTernary` | Prohibits ternary operators for PowerShell 5.1 compatibility (this test is skipped by default in the framework) | `#SkipTest:NoTernary:PowerShell 7+ only module` | | `LowercaseKeywords` | Ensures all PowerShell keywords are lowercase | `#SkipTest:LowercaseKeywords:Generated code` | | `FunctionCount` | Ensures each file contains exactly one function | `#SkipTest:FunctionCount:Helper functions included` | | `FunctionName` | Ensures the filename matches the function name | `#SkipTest:FunctionName:Legacy naming convention` | From fe4ed57728381e0d4ef4ba0efcf241ed26b5226b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 7 Jan 2026 00:11:09 +0000 Subject: [PATCH 4/4] Fix Verbose test description and add CmdletBinding to helper functions in example Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com> --- README.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 512a2bec..5a329c7c 100644 --- a/README.md +++ b/README.md @@ -471,7 +471,7 @@ These tests run against your source code files in the `src` directory: | Test ID | Description | Example Skip Comment | |---------|-------------|---------------------| | `NumberOfProcessors` | Enforces use of `[System.Environment]::ProcessorCount` instead of `$env:NUMBER_OF_PROCESSORS` | `#SkipTest:NumberOfProcessors:Legacy code compatibility required` | -| `Verbose` | Prevents use of `-Verbose` parameter in code (should only be used with `:$false` qualifier to explicitly disable) | `#SkipTest:Verbose:Required for debugging output` | +| `Verbose` | Ensures code does not pass `-Verbose` to other commands (which would override user preference), unless explicitly disabled with `-Verbose:$false` | `#SkipTest:Verbose:Required for debugging output` | | `OutNull` | Enforces use of `$null = ...` instead of `... \| Out-Null` for better performance | `#SkipTest:OutNull:Pipeline processing required` | | `NoTernary` | Prohibits ternary operators for PowerShell 5.1 compatibility (this test is skipped by default in the framework) | `#SkipTest:NoTernary:PowerShell 7+ only module` | | `LowercaseKeywords` | Ensures all PowerShell keywords are lowercase | `#SkipTest:LowercaseKeywords:Generated code` | @@ -514,12 +514,20 @@ function Get-ComplexData { } function Get-RawData { - param([string]$Path) + [CmdletBinding()] + param( + [Parameter(Mandatory)] + [string] $Path + ) # Helper function implementation } function Format-ComplexData { - param($Data) + [CmdletBinding()] + param( + [Parameter(Mandatory)] + $Data + ) # Helper function implementation } ```