Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Commit

Permalink
Merge pull request #92 from brianbunke/master
Browse files Browse the repository at this point in the history
Fix #90
  • Loading branch information
brianbunke authored Mar 3, 2017
2 parents cccf6cc + efde342 commit 344e9f5
Showing 1 changed file with 35 additions and 30 deletions.
65 changes: 35 additions & 30 deletions Vester/Private/Get-VesterTest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,48 @@ function Get-VesterTest {
[object[]]$Test
)

# Construct empty array to throw file paths of tests into
$TestFiles = New-Object 'System.Collections.Generic.List[String]'

# Need to ForEach if multiple -Test locations
ForEach ($TestPath in $Test) {
# Gracefully handle FileSystemInfo objects (Get-Item / Get-ChildItem)
If ($TestPath.FullName) {
$TestPath = $TestPath.FullName
}

If (Test-Path $TestPath -PathType Container) {
# If Test-Path finds a folder, get all *.Vester.ps1 files beneath it
Write-Verbose "Discovering *.Vester.ps1 files below directory '$TestPath'."
$GCI = (Get-ChildItem $TestPath -Filter '*.Vester.ps1' -File -Recurse).FullName

If ($GCI) {
# Add each *.Vester.ps1 file found to the array
$GCI | ForEach-Object {
$TestFiles.Add($_)
}
} Else {
throw "No *.Vester.ps1 files found at location '$TestPath'."
BEGIN {
# Construct empty array to throw file paths of tests into
$TestFiles = New-Object 'System.Collections.Generic.List[String]'
}

PROCESS {
# Need to ForEach if multiple -Test locations
ForEach ($TestPath in $Test) {
# Gracefully handle FileSystemInfo objects (Get-Item / Get-ChildItem)
If ($TestPath.FullName) {
$TestPath = $TestPath.FullName
}

$GCI = $null
} Else {
# Add the single file to the array if it matches *.Vester.ps1
If ($TestPath -like '*.Vester.ps1') {
If (Test-Path $TestPath -PathType Container) {
# If Test-Path finds a folder, get all *.Vester.ps1 files beneath it
Write-Verbose "Discovering *.Vester.ps1 files below directory '$TestPath'."
$GCI = (Get-ChildItem $TestPath -Filter '*.Vester.ps1' -File -Recurse).FullName

If ($GCI) {
# Add each *.Vester.ps1 file found to the array
$GCI | ForEach-Object {
$TestFiles.Add($_)
}
} Else {
throw "No *.Vester.ps1 files found at location '$TestPath'."
}

$GCI = $null
} ElseIf ($TestPath -like '*.Vester.ps1') {
# Add the single file to the array if it matches *.Vester.ps1
$TestFiles.Add($TestPath)
} Else {
# Because Vester tests have a very specific format,
# and for future discoverability of that test if parent folder is specified,
# prefer that tests are consciously named *.Vester.ps1
throw "'$TestPath' does not match the *.Vester.ps1 naming convention for test files."
}
} #If Test-Path
} #ForEach -Test param entry
} #If Test-Path

} #ForEach -Test param entry
} #process

$TestFiles
END {
$TestFiles
}
} #function

0 comments on commit 344e9f5

Please sign in to comment.