-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from theohbrothers/test/integration-add-tests-…
…for-src-scripts-ci-invoke-generate.ps1 Test (integration): Add tests for `src/scripts/ci/Invoke-Generate.ps1`
- Loading branch information
Showing
2 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
[CmdletBinding()] | ||
param() | ||
|
||
$ErrorActionPreference = 'Continue' | ||
$VerbosePreference = 'Continue' | ||
|
||
$failedCount = 0 | ||
|
||
$functionTestScriptBlock = { | ||
try { | ||
"Command: $script:cmd" | Write-Verbose | ||
"Args:" | Write-Verbose | ||
$script:cmdArgs | Out-String -Stream | % { $_.Trim() } | ? { $_ } | Write-Verbose | ||
for ($i=0; $i -le $script:iterations-1; $i++) { | ||
"Iteration: $($i+1)" | Write-Verbose | ||
if ($script:cmdArgs) { | ||
$stdout = & $script:cmd @script:cmdArgs | ||
}else { | ||
$stdout = & $script:cmd | ||
} | ||
"Generate notes content:" | Write-Verbose | ||
Get-Content -Path "$stdout" | Out-String -Stream | % { $_.Trim() } | ? { $_ } | Write-Host | ||
} | ||
}catch { | ||
$_ | Write-Error | ||
$script:failedCount++ | ||
} | ||
} | ||
|
||
# Globals | ||
$env:RELEASE_TAG_REF = git describe --tags --abbrev=0 | ||
|
||
# Script: ci/Invoke-Generate.ps1 | ||
$ReleaseNotesVariant = Get-ChildItem "../src/PSRepositoryReleaseManager/generate/variants" | % { $_.BaseName } | ||
"Release Notes Variants:" | Write-Verbose | ||
$ReleaseNotesVariant | Write-Host | ||
|
||
foreach ($variant in $ReleaseNotesVariant) { | ||
$env:RELEASE_NOTES_VARIANT = $variant | ||
$env:RELEASE_NOTES_PATH = "$(git rev-parse --show-toplevel)/test/.release-notes.$variant.md" | ||
|
||
$cmd = "../src/scripts/ci/Invoke-Generate.ps1" | ||
$cmdArgs=@{} | ||
$iterations = 1 | ||
& $functionTestScriptBlock | ||
} | ||
|
||
########### | ||
# Results # | ||
########### | ||
if ($failedCount -gt 0) { | ||
"$failedCount tests failed." | Write-Warning | ||
} | ||
$failedCount |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
[CmdletBinding()] | ||
param() | ||
|
||
Set-StrictMode -Version Latest | ||
$VerbosePreference = 'Continue' | ||
$global:PesterDebugPreference_ShowFullErrors = $true | ||
|
||
try { | ||
Push-Location $PSScriptRoot | ||
|
||
# Install test dependencies | ||
# "Installing test dependencies" | Write-Verbose | ||
# & "$PSScriptRoot\scripts\dep\Install-TestDependencies.ps1" > $null | ||
|
||
# Run unit tests | ||
"Running unit tests" | Write-Verbose | ||
$testFailed = $false | ||
$unitResult = Invoke-Pester -Script "$PSScriptRoot\..\src\PSRepositoryReleaseManager" -PassThru | ||
if ($unitResult.FailedCount -gt 0) { | ||
"$($unitResult.FailedCount) tests failed." | Write-Warning | ||
$testFailed = $true | ||
} | ||
|
||
# Run integration tests | ||
"Running integration tests" | Write-Verbose | ||
$integratedFailedCount = & "$PSScriptRoot\PSRepositoryReleaseManager.Tests.ps1" | ||
if ($integratedFailedCount -gt 0) { | ||
$testFailed = $true | ||
} | ||
|
||
"Listing test artifacts" | Write-Verbose | ||
git ls-files --others --exclude-standard | ||
|
||
"End of tests" | Write-Verbose | ||
if ($testFailed) { | ||
throw "One or more tests failed." | ||
} | ||
}catch { | ||
throw | ||
}finally { | ||
Pop-Location | ||
} |