mirror of
https://github.com/snazy2000/SnipeitPS.git
synced 2025-12-12 17:32:30 +00:00
More test changes
This commit is contained in:
parent
7606d2d7a9
commit
420c59722b
2 changed files with 3 additions and 20 deletions
|
|
@ -9,7 +9,7 @@ variables:
|
|||
Test:
|
||||
stage: test
|
||||
script:
|
||||
- .\build.ps1 -Tasks 'analyze','test'
|
||||
- .\build.ps1 -Tasks 'test'
|
||||
except:
|
||||
- master
|
||||
|
||||
|
|
|
|||
21
build.ps1
21
build.ps1
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue