More test changes

This commit is contained in:
Stephen Maunder 2017-12-31 19:42:27 +00:00
parent 7606d2d7a9
commit 420c59722b
2 changed files with 3 additions and 20 deletions

View file

@ -9,7 +9,7 @@ variables:
Test:
stage: test
script:
- .\build.ps1 -Tasks 'analyze','test'
- .\build.ps1 -Tasks 'test'
except:
- master

View file

@ -14,26 +14,13 @@ function Install-Dependency([string] $Name)
}
}
function Analyze-Scripts
{
param(
[string]$Path = "$PSScriptRoot\SnipeitPS\"
)
$result = Invoke-ScriptAnalyzer -Path $Path -Severity @('Error', 'Warning') -Recurse
if ($result) {
$result | Format-Table
Write-Error -Message "$($result.SuggestedCorrections.Count) linting errors or warnings were found. The build cannot continue."
EXIT 1
}
}
function Run-Tests
{
param(
[string]$Path = "$PSScriptRoot\SnipeitPS"
)
$results = Invoke-Pester -Path $Path -PassThru
$results = Invoke-Pester -PassThru
if($results.FailedCount -gt 0) {
Write-Output " > $($results.FailedCount) tests failed. The build cannot continue."
foreach($result in $($results.TestResult | Where {$_.Passed -eq $false} | Select-Object -Property Describe,Context,Name,Passed,Time)){
@ -47,12 +34,8 @@ function Run-Tests
foreach($task in $Tasks){
switch($task)
{
"analyze" {
Install-Dependency -Name "PSScriptAnalyzer"
Write-Output "Analyzing Scripts..."
Analyze-Scripts
}
"test" {
Install-Dependency -Name "PSScriptAnalyzer"
Install-Dependency -Name "Pester"
Write-Output "Running Pester Tests..."
Run-Tests