|
21 | 21 | variables: |
22 | 22 | buildPlatform: 'Any CPU' |
23 | 23 | buildConfiguration: 'Release' |
24 | | - # Keep in sync with the test project TargetFramework values. |
25 | | - testTargetFramework: 'net10.0' |
26 | 24 | ProductBinPath: '$(Build.SourcesDirectory)\src\Microsoft.OpenApi\bin\$(BuildConfiguration)' |
27 | 25 | REGISTRY: 'msgraphprodregistry.azurecr.io' |
28 | 26 | IMAGE_NAME: 'public/openapi/hidi' |
@@ -104,20 +102,29 @@ extends: |
104 | 102 | # Run the Unit test |
105 | 103 | - pwsh: | |
106 | 104 | $testResultsDirectory = "$(Agent.TempDirectory)\TestResults" |
107 | | - $targetFramework = "$(testTargetFramework)" |
108 | 105 | New-Item -ItemType Directory -Force -Path $testResultsDirectory | Out-Null |
109 | 106 |
|
110 | 107 | $testApplications = @( |
111 | | - @{ Name = "Microsoft.OpenApi.Hidi.Tests"; Path = "$(Build.SourcesDirectory)\test\Microsoft.OpenApi.Hidi.Tests\bin\$(BuildConfiguration)\$targetFramework\Microsoft.OpenApi.Hidi.Tests.exe" }, |
112 | | - @{ Name = "Microsoft.OpenApi.Readers.Tests"; Path = "$(Build.SourcesDirectory)\test\Microsoft.OpenApi.Readers.Tests\bin\$(BuildConfiguration)\$targetFramework\Microsoft.OpenApi.Readers.Tests.exe" }, |
113 | | - @{ Name = "Microsoft.OpenApi.Tests"; Path = "$(Build.SourcesDirectory)\test\Microsoft.OpenApi.Tests\bin\$(BuildConfiguration)\$targetFramework\Microsoft.OpenApi.Tests.exe" } |
| 108 | + @{ Name = "Microsoft.OpenApi.Hidi.Tests"; Pattern = "$(Build.SourcesDirectory)\test\Microsoft.OpenApi.Hidi.Tests\bin\$(BuildConfiguration)\*\Microsoft.OpenApi.Hidi.Tests.exe" }, |
| 109 | + @{ Name = "Microsoft.OpenApi.Readers.Tests"; Pattern = "$(Build.SourcesDirectory)\test\Microsoft.OpenApi.Readers.Tests\bin\$(BuildConfiguration)\*\Microsoft.OpenApi.Readers.Tests.exe" }, |
| 110 | + @{ Name = "Microsoft.OpenApi.Tests"; Pattern = "$(Build.SourcesDirectory)\test\Microsoft.OpenApi.Tests\bin\$(BuildConfiguration)\*\Microsoft.OpenApi.Tests.exe" } |
114 | 111 | ) |
115 | 112 |
|
116 | 113 | $exitCode = 0 |
117 | 114 | foreach ($testApplication in $testApplications) { |
118 | | - & $testApplication.Path --report-xunit-trx --report-xunit-trx-filename "$($testApplication.Name).trx" --results-directory $testResultsDirectory --minimum-expected-tests 1 |
119 | | - if ($LASTEXITCODE -ne 0) { |
120 | | - $exitCode = $LASTEXITCODE |
| 115 | + $testExecutables = @(Get-Item -Path $testApplication.Pattern -ErrorAction SilentlyContinue) |
| 116 | + if ($testExecutables.Count -eq 0) { |
| 117 | + Write-Error "No test executable found for $($testApplication.Name)" |
| 118 | + $exitCode = 1 |
| 119 | + continue |
| 120 | + } |
| 121 | +
|
| 122 | + foreach ($testExecutable in $testExecutables) { |
| 123 | + $targetFramework = Split-Path -Path $testExecutable.DirectoryName -Leaf |
| 124 | + & $testExecutable.FullName --report-xunit-trx --report-xunit-trx-filename "$($testApplication.Name)-$targetFramework.trx" --results-directory $testResultsDirectory --minimum-expected-tests 1 |
| 125 | + if ($LASTEXITCODE -ne 0) { |
| 126 | + $exitCode = 1 |
| 127 | + } |
121 | 128 | } |
122 | 129 | } |
123 | 130 |
|
|
0 commit comments