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: Test:
stage: test stage: test
script: script:
- .\build.ps1 -Tasks 'analyze','test' - .\build.ps1 -Tasks 'test'
except: except:
- master - 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 function Run-Tests
{ {
param( param(
[string]$Path = "$PSScriptRoot\SnipeitPS" [string]$Path = "$PSScriptRoot\SnipeitPS"
) )
$results = Invoke-Pester -Path $Path -PassThru $results = Invoke-Pester -PassThru
if($results.FailedCount -gt 0) { if($results.FailedCount -gt 0) {
Write-Output " > $($results.FailedCount) tests failed. The build cannot continue." 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)){ 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){ foreach($task in $Tasks){
switch($task) switch($task)
{ {
"analyze" {
Install-Dependency -Name "PSScriptAnalyzer"
Write-Output "Analyzing Scripts..."
Analyze-Scripts
}
"test" { "test" {
Install-Dependency -Name "PSScriptAnalyzer"
Install-Dependency -Name "Pester" Install-Dependency -Name "Pester"
Write-Output "Running Pester Tests..." Write-Output "Running Pester Tests..."
Run-Tests Run-Tests