Skip to content

Commit

Permalink
Updates to community script
Browse files Browse the repository at this point in the history
  • Loading branch information
adbertram committed Feb 12, 2017
1 parent e6b20e3 commit bfacd7e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Tests/Community.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,15 @@ $defaultModules = (Get-Module -Name 'Microsoft.PowerShell.*','Pester').Name
if ($scripts = Get-ChildItem -Path $FolderPath -Recurse -Filter '*.ps*' | Sort-Object Name) {
$scripts | foreach({
$script = $_.FullName

$ast = [System.Management.Automation.Language.Parser]::ParseFile($script,[ref]$null,[ref]$null)
$commandRefs = $ast.FindAll({$args[0] -is [System.Management.Automation.Language.CommandAst]},$true)
$script:commandRefNames += @($commandRefs).foreach({ [string]$_.CommandElements[0] }) | Select-Object -Unique
if ($testRefs = (Select-String -path $script -Pattern "mock [`"|'](.*)[`"|']").Matches) {
$commandRefsInTest = $testRefs | foreach {
$_.Groups[1].Value
}
}

$script:commandRefNames += (@($commandRefs).foreach({ [string]$_.CommandElements[0] }) | Select-Object -Unique) + $commandRefsInTest
$script:commandDeclarationNames += $ast.FindAll({ $args[0] -is [System.Management.Automation.Language.FunctionDefinitionAst] }, $true) | Select-Object -ExpandProperty Name

describe "[$($script)] Test" {
Expand All @@ -71,7 +76,8 @@ if ($scripts = Get-ChildItem -Path $FolderPath -Recurse -Filter '*.ps*' | Sort-O
}
}
)
$privateCommandNames = $commandRefNames | Select-Object -Property $properties | Where {

$privateCommandNames = $script:commandRefNames | Select-Object -Property $properties | Where {
$_.Command -notin $defaultCommandNames -and
$_.Command -notin $commandDeclarationNames -and
$_.Command -match '^\w' -and
Expand Down

0 comments on commit bfacd7e

Please sign in to comment.