PowerShellHelpDeepDive icon indicating copy to clipboard operation
PowerShellHelpDeepDive copied to clipboard

Verification for auto-generation synopsis is not correct (?)

Open it-praktyk opened this issue 8 years ago • 0 comments

Under work for updating help for Pester module I discovered that part of your tests is not correct.

The file PesterTestsForHelp/InModule.Help.Tests.ps1 contains the test for auto-generated synopsis

# If help is not found, synopsis in auto-generated help is the syntax diagramIt "should not be auto-generated" {
    (Get-Help $command -ErrorAction SilentlyContinue).Synopsis | Should Not BeLike '*`[`<CommonParameters`>`]*'
}

https://github.com/juneb/PowerShellHelpDeepDive/blob/master/PesterTestsForHelp/InModule.Help.Tests.ps1#L48-L51 but autogenerated synopsis has the different pattern.

PS > Function test1 { param($param1)}
PS > Function test2 { }

PS > (Get-Help test1 -Full).Synopsis
test1 [[-param1] <Object>]

PS > (Get-Help test2 -Full).Synopsis
test2

For the function saved in the file with declared comment based help if '.SYNOPSIS' is not filled the value $null is returned.

As the result the test is passed even for the function what looks like

function Get-TestDriveItem {
    #moved here from Pester.psm1
    param( [string]$Path )

    Assert-DescribeInProgress -CommandName Get-TestDriveItem
    & $SafeCommands['Get-Item'] $(& $SafeCommands['Join-Path'] $TestDrive $Path )
}

https://github.com/pester/Pester/blob/master/Functions/TestDrive.ps1#L48-L54

it-praktyk avatar Dec 24 '16 19:12 it-praktyk