1515 Target directory where the CloudEvents.Sdk will be created by the script. The default is the PS Script Root
1616
1717 . PARAMETER TestsType
18- Specifies the type of the test to be run post build. Possible values are 'none','unit', 'integration', 'all'.
18+ Specifies the type of the test to be run post build. Possible values are 'none','unit', 'integration', 'all'.
1919 The default is 'all'
2020
21+ . PARAMETER ExitProcess
22+ Specifies whther to exit the running process. Exits with exit code equal to the number of failing tests.
23+
2124#>
2225
2326param (
@@ -28,7 +31,11 @@ param(
2831 [Parameter ()]
2932 [ValidateSet (' none' , ' unit' , ' integration' , ' all' )]
3033 [string ]
31- $TestsType = ' all'
34+ $TestsType = ' all' ,
35+
36+ [Parameter ()]
37+ [switch ]
38+ $ExitProcess
3239)
3340
3441$moduleName = ' CloudEvents.Sdk'
@@ -89,7 +96,10 @@ param(
8996 - PassThru `
9097 - NoNewWindow
9198
92- $testProcess | Wait-Process
99+ $testProcess | Wait-Process | Out-Null
100+
101+ # Return the number of failed tests
102+ $testProcess.ExitCode
93103 }
94104}
95105# endregion
@@ -107,12 +117,18 @@ dotnet publish -c Release -o $OutputDir $dotnetProjectPath
107117# 3. Cleanup Unnecessary Outputs
108118Get-ChildItem " $dotnetProjectName *" - Path $OutputDir | Remove-Item - Confirm:$false
109119
120+ $failedTests = 0
110121# 4. Run Unit Tests
111122if ($TestsType -eq ' unit' -or $TestsType -eq ' all' ) {
112- Start-Tests - TestsType ' unit'
123+ $failedTests += ( Start-Tests - TestsType ' unit' )
113124}
114125
115126# 5. Run Integration Tests
116127if ($TestsType -eq ' integration' -or $TestsType -eq ' all' ) {
117- Start-Tests - TestsType ' integration'
128+ $failedTests += ( Start-Tests - TestsType ' integration' )
118129}
130+
131+ # 6. Set exit code
132+ if ($ExitProcess.IsPresent ) {
133+ exit $failedTests
134+ }
0 commit comments