Skip to content

Commit

Permalink
Fixed detection of empty tests (#835)
Browse files Browse the repository at this point in the history
* Fixed detection of empty tests
  • Loading branch information
Remco Kapinga authored and nohwnd committed Jan 28, 2018
1 parent 0f5aff9 commit 0b994c9
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions Functions/It.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,26 @@ function ItImpl
if ($null -eq $test) { $test = {} }

#mark empty Its as Pending
#[String]::IsNullOrWhitespace is not available in .NET version used with PowerShell 2
if ($PSCmdlet.ParameterSetName -eq 'Normal' -and
[String]::IsNullOrEmpty((Remove-Comments $test.ToString()) -replace "\s"))
if ($PSVersionTable.PSVersion.Major -le 2 -and
$PSCmdlet.ParameterSetName -eq 'Normal' -and
[String]::IsNullOrEmpty((Remove-Comments $test.ToString()) -replace "\s"))
{
$Pending = $true
}
elseIf ($PSVersionTable.PSVersion.Major -gt 2)
{
#[String]::IsNullOrWhitespace is not available in .NET version used with PowerShell 2
# AST is not available also
$testIsEmpty =
[String]::IsNullOrEmpty($test.Ast.BeginBlock.Statements) -and
[String]::IsNullOrEmpty($test.Ast.ProcessBlock.Statements) -and
[String]::IsNullOrEmpty($test.Ast.EndBlock.Statements)

if ($PSCmdlet.ParameterSetName -eq 'Normal' -and $testIsEmpty)
{
$Pending = $true
}
}

$pendingSkip = @{}

Expand Down

0 comments on commit 0b994c9

Please sign in to comment.