@@ -16,12 +16,18 @@ if (Test-Path $basePath) {
1616
1717New-Item $basePath - ItemType Directory | Out-Null
1818
19- $failureMessage = " "
19+ $failureMessages = @ ()
2020
2121foreach ($scenario in $scenarios ) {
22+ # these fail on windows in GH and because they use docker for the scenarios we don't need to run them twice anyway
23+ if ($env: GithubOS -eq " windows-latest" ) {
24+ continue
25+ }
26+
2227 Write-Host " ::group::$ ( $scenario.name ) "
2328
2429 $scenarioPath = Join-Path $basePath $scenario.name
30+ Write-Host $scenarioPath
2531 New-Item $scenarioPath - ItemType Directory | Out-Null
2632
2733 $dockerFile = Join-Path $scenarioPath " DockerFile"
@@ -38,7 +44,7 @@ RUN dotnet build -c Release
3844 $csprojFile = Join-Path $scenarioPath " Project.csproj"
3945
4046 $csharpierFrameworkVersion = " "
41- if ($null -ne $scenario . csharpier_frameworkVersion ) {
47+ if ([ bool ]( $scenario .PSobject.Properties.name -match " csharpier_frameworkVersion" ) ) {
4248 $csharpierFrameworkVersion = "
4349 <CSharpier_FrameworkVersion>$ ( $scenario.csharpier_frameworkVersion ) </CSharpier_FrameworkVersion>
4450"
@@ -61,14 +67,47 @@ RUN dotnet build -c Release
6167 docker build . -f $dockerFile
6268
6369 if ($LASTEXITCODE -ne 0 ) {
64- $failureMessage += " ::error:: The scenario $ ( $scenario.name ) failed to build. See the logs above for details`n "
70+ $failureMessages += " The scenario $ ( $scenario.name ) failed to build. See the logs above for details"
6571 }
6672
6773 Write-Host " ::endgroup::"
6874}
6975
70- if ($failureMessage -ne " " ) {
71- Write-Host $failureMessage
76+
77+ Write-Host " ::group::UnformattedFileCausesError"
78+ $output = [TestHelper ]::RunTestCase(" UnformattedFileCausesError" , $true )
79+ Write-Host " ::endgroup::"
80+
81+ Write-Host " ::group::FileThatCantCompileCausesOneError"
82+ $output = [TestHelper ]::RunTestCase(" FileThatCantCompileCausesOneError" , $true )
83+ if (-not ($output.Contains (" 1 Error(s)" ))) {
84+ $failureMessages += " The TestCase FileThatCantCompileCausesOneError did not contain the text '1 Error(s)1"
85+ }
86+
87+ Write-Host " ::endgroup::"
88+
89+ if ($failureMessages.Length -ne 0 ) {
90+ foreach ($message in $failureMessages ) {
91+ Write-Host " ::error::$message `n "
92+ }
7293 exit 1
7394}
7495
96+ class TestHelper {
97+ static [string ] RunTestCase([string ] $testCase , [bool ] $expectErrorCode ) {
98+ $output = (& dotnet build - c Release ./ TestCases/ $ ($testCase )/ Project.csproj) | Out-String
99+ Write-Host $output
100+
101+ $expectedExitCode = 0
102+ if ($expectErrorCode -eq $true ) {
103+ $expectedExitCode = 1
104+ }
105+
106+ if ($LASTEXITCODE -ne $expectedExitCode ) {
107+ $failureMessages += " The TestCase $testCase did not return an exit code of $expectedExitCode "
108+ }
109+
110+ return $output
111+ }
112+ }
113+
0 commit comments