@@ -37,7 +37,7 @@ Describe 'Invoke-NovaModuleToolsCI' {
3737 $projectRoot = Join-Path $TestDrive ' project'
3838 $outputDirectory = Join-Path $TestDrive ' artifacts-out'
3939 $callLogPath = Join-Path $TestDrive ' call-log.txt'
40- $excludeTagLogPath = Join-Path $TestDrive ' exclude-tags .txt'
40+ $commandLogPath = Join-Path $TestDrive ' commands .txt'
4141 $unitResultPath = Join-Path $projectRoot ' artifacts/UnitTestResults.xml'
4242 $integrationResultPath = Join-Path $projectRoot ' artifacts/TestResults.xml'
4343
@@ -64,24 +64,24 @@ function Get-NovaProjectInfo {
6464 }
6565}
6666
67- function Remove-Module {
67+ function pwsh {
6868 [CmdletBinding()]
69- param([string]`$ Name)
70- }
71-
72- function Invoke-NovaTest {
73- [CmdletBinding()]
74- param([string[]]`$ ExcludeTagFilter)
69+ param(
70+ [switch]`$ NoLogo,
71+ [switch]`$ NoProfile,
72+ [string]`$ Command
73+ )
7574
76- Add-Content -LiteralPath '$callLogPath ' -Value 'Invoke-NovaTest'
77- Set-Content -LiteralPath '$excludeTagLogPath ' -Value (`$ ExcludeTagFilter -join ',') -Encoding utf8
78- }
75+ Add-Content -LiteralPath '$commandLogPath ' -Value `$ Command
76+ if (`$ Command -match 'Invoke-NovaTest') {
77+ Add-Content -LiteralPath '$callLogPath ' -Value 'Invoke-NovaTest'
78+ }
7979
80- function Test-NovaBuild {
81- [CmdletBinding()]
82- param([string[]] `$ ExcludeTagFilter)
80+ if ( `$ Command -match ' Test-NovaBuild') {
81+ Add-Content -LiteralPath ' $callLogPath ' -Value 'Test-NovaBuild'
82+ }
8383
84- Add-Content -LiteralPath ' $callLogPath ' -Value 'Test-NovaBuild'
84+ `$ global:LASTEXITCODE = 0
8585}
8686
8787& '$script :novaModuleToolsCiScriptPath ' -OutputDirectory '$outputDirectory ' -ExcludeTag 'slow','integration'
@@ -90,7 +90,10 @@ function Test-NovaBuild {
9090
9191 $result.ExitCode | Should - Be 0 - Because ($result.Output -join [Environment ]::NewLine)
9292 (Get-Content - LiteralPath $callLogPath ) | Should - Be @ (' Invoke-NovaTest' , ' Test-NovaBuild' )
93- (Get-Content - LiteralPath $excludeTagLogPath - Raw).Trim() | Should - Be ' slow,integration'
93+ $commands = Get-Content - LiteralPath $commandLogPath
94+ $commands | Should - HaveCount 2
95+ $commands [0 ] | Should -Match " Import-Module '.*/dist/NovaModuleTools/NovaModuleTools\.psd1' -Force -ErrorAction Stop; Invoke-NovaTest -ExcludeTagFilter @\('slow', 'integration'\)"
96+ $commands [1 ] | Should -Match " Import-Module '.*/dist/NovaModuleTools/NovaModuleTools\.psd1' -Force -ErrorAction Stop; Test-NovaBuild -ExcludeTagFilter @\('slow', 'integration'\)"
9497 (Get-Content - LiteralPath (Join-Path $outputDirectory ' novamoduletools-unit-nunit.xml' ) - Raw).Trim() | Should - Be ' <unit-test-results />'
9598 (Get-Content - LiteralPath (Join-Path $outputDirectory ' novamoduletools-integration-nunit.xml' ) - Raw).Trim() | Should - Be ' <integration-test-results />'
9699 }
@@ -122,24 +125,29 @@ function Get-NovaProjectInfo {
122125 }
123126}
124127
125- function Remove-Module {
128+ function pwsh {
126129 [CmdletBinding()]
127- param([string]`$ Name)
128- }
130+ param(
131+ [switch]`$ NoLogo,
132+ [switch]`$ NoProfile,
133+ [string]`$ Command
134+ )
129135
130- function Invoke-NovaTest {
131- throw 'boom'
132- }
136+ if (`$ Command -match 'Invoke-NovaTest') {
137+ `$ global:LASTEXITCODE = 1
138+ return
139+ }
133140
134- function Test-NovaBuild {}
141+ `$ global:LASTEXITCODE = 0
142+ }
135143
136144& '$script :novaModuleToolsCiScriptPath ' -OutputDirectory '$outputDirectory '
137145"@
138146 $result = Invoke-NovaModuleToolsCIRunner - RunnerContent $runnerContent
139147 $outputText = $result.Output -join [Environment ]::NewLine
140148
141149 $result.ExitCode | Should - Be 1
142- $outputText | Should -Match ' Nova test workflow failed: boom '
150+ $outputText | Should -Match ' Nova test workflow failed: Validation command failed: .*Invoke-NovaTest '
143151 (Get-Content - LiteralPath (Join-Path $outputDirectory ' novamoduletools-unit-nunit.xml' ) - Raw).Trim() | Should - Be ' <failed-unit-test-results />'
144152 Test-Path - LiteralPath (Join-Path $outputDirectory ' novamoduletools-integration-nunit.xml' ) | Should - BeFalse
145153 }
0 commit comments