ps/Modules/test-solution.ps1

58 lines
1.5 KiB
PowerShell
Raw Permalink Normal View History

2023-05-30 22:51:22 -07:00
<#
.SYNOPSIS
Tests all project in the Alkami.PowerShell module system
.EXAMPLE
.\test-solution.ps1
.PARAMETER FilenameMatch
A wildcard pattern to match for the testing scope. This limits how many files are looked at.
Matching pattern is *$FilenameMatch*.test?.ps1
.PARAMETER Noisy
Show the output of the process instead of a synopsis
.PARAMETER NoAnalyzer
Don't run PSScriptAnalyzer on the project
#>
[CmdletBinding()]
Param(
$FilenameMatch,
[switch]$Noisy,
[switch]$NoAnalyzer,
[switch]$AsBuildServer
)
$global:SuppressReload = $true
. $PSScriptRoot\.build\Load-Includes.ps1
## Ensure that the modules are loaded properly
Get-Module Alkami* | Remove-Module -force
.$PSScriptRoot\Load-PesterModules.ps1
$folders = (Get-ChildItem $PSScriptRoot -Directory)
$failingResults = @()
foreach ($folder in $folders.Where({$_.Name -ne ".build"})) {
$folderPath = $folder.FullName
Write-Host "Testing $folderPath"
$failingResult = & $PSScriptRoot\test-project.ps1 $folderPath $FilenameMatch -Noisy:$Noisy -NoAnalyzer:$NoAnalyzer -AsBuildServer:$AsBuildServer -DontReloadPester
if ($null -ne $failingResult) {
$failingResults += $failingResult
}
}
$global:SuppressReload = $false
## finally, return the results array if any
$resultsToShow = @($failingResults.Where({$_.TestResult -or $_.Analyzer}))
if ($resultsToShow.Count -gt 0) {
return $resultsToShow
} else {
Write-Host "All tests finished, no failing results"
}