|
124 | 124 | we use the project name (which looks something like "Aspire.Cli.Tests"). |
125 | 125 | --> |
126 | 126 | <_TestRunsheet>$(MSBuildProjectName)</_TestRunsheet> |
| 127 | + <_TestRunsheetFileNameWindows>$(ArtifactsTmpDir)\$(_TestRunsheet).win.runsheet.json</_TestRunsheetFileNameWindows> |
| 128 | + <_TestRunsheetFileNameLinux>$(ArtifactsTmpDir)\$(_TestRunsheet).linux.runsheet.json</_TestRunsheetFileNameLinux> |
| 129 | + <_TestRunsheetFileNameMacOS>$(ArtifactsTmpDir)\$(_TestRunsheet).macos.runsheet.json</_TestRunsheetFileNameMacOS> |
| 130 | + |
127 | 131 | <_TestBinLog>$([MSBuild]::NormalizePath($(ArtifactsLogDir), '$(_TestRunsheet).binlog'))</_TestBinLog> |
128 | 132 |
|
129 | 133 | <_RelativeTestProjectPath>$([System.String]::Copy('$(MSBuildProjectFullPath)').Replace('$(RepoRoot)', '%24(pwd)/'))</_RelativeTestProjectPath> |
|
133 | 137 | <_TestRunnerLinux>./eng/build.sh</_TestRunnerLinux> |
134 | 138 | <_TestCommand>-restore -build -test -projects "$(_RelativeTestProjectPath)" /bl:"$(_RelativeTestBinLog)" -c $(Configuration) -ci /p:RunQuarantinedTests=true /p:CI=false</_TestCommand> |
135 | 139 |
|
| 140 | + <_PreCommand>$(TestRunnerPreCommand)</_PreCommand> |
| 141 | + |
136 | 142 | <!-- |
137 | 143 | Some quarantinted test may only be executable on Windows or Linux, however we can't possibly know that at this time. |
138 | 144 | The MTP runner will return exit code 8 if no tests are found, and we need to ignore it instead of failing the test. |
139 | 145 | --> |
140 | 146 | <_TestCommand>$(_TestCommand) /p:IgnoreZeroTestResult=true</_TestCommand> |
141 | 147 |
|
142 | 148 | <!-- Replace \ with /, and then escape " with \", so we have a compliant JSON --> |
| 149 | + <_PreCommand>$([System.String]::Copy($(_PreCommand)).Replace("\", "/").Replace('"', '\"'))</_PreCommand> |
143 | 150 | <_TestCommand>$([System.String]::Copy($(_TestCommand)).Replace("\", "/").Replace('"', '\"'))</_TestCommand> |
144 | 151 |
|
145 | 152 | <_TestRunsheetWindows>{ "project": "$(_TestRunsheet)", "os": "windows-latest", "command": "./eng/build.ps1 $(_TestCommand)" }</_TestRunsheetWindows> |
146 | | - <_TestRunsheetLinux>{ "project": "$(_TestRunsheet)", "os": "ubuntu-latest", "command": "./eng/build.sh $(_TestCommand)" }</_TestRunsheetLinux> |
| 153 | + <_TestRunsheetLinux>{ "project": "$(_TestRunsheet)", "os": "ubuntu-latest", "command": "$(_PreCommand)./eng/build.sh $(_TestCommand)" }</_TestRunsheetLinux> |
| 154 | + <_TestRunsheetMacOS>{ "project": "$(_TestRunsheet)", "os": "macos-latest", "command": "$(_PreCommand)./eng/build.sh $(_TestCommand)" }</_TestRunsheetMacOS> |
147 | 155 | </PropertyGroup> |
148 | 156 |
|
| 157 | + <ItemGroup> |
| 158 | + <_OutputFiles Include="$(_TestRunsheetFileNameWindows)" /> |
| 159 | + <_OutputFiles Include="$(_TestRunsheetFileNameLinux)" /> |
| 160 | + <_OutputFiles Include="$(_TestRunsheetFileNameMacOS)" /> |
| 161 | + </ItemGroup> |
| 162 | + |
| 163 | + <MakeDir Directories="@(_OutputFiles->'%(RootDir)%(Directory)')"/> |
| 164 | + <Delete Files="@(_OutputFiles)" /> |
| 165 | + |
149 | 166 | <WriteLinesToFile |
150 | 167 | Condition=" '$(RunOnGithubActionsWindows)' == 'true' and '$(_HasQuarantinedTests)' == 'true'" |
151 | | - File="$(ArtifactsTmpDir)/$(_TestRunsheet).win.runsheet.json" |
| 168 | + File="$(_TestRunsheetFileNameWindows)" |
152 | 169 | Lines="$(_TestRunsheetWindows)" |
153 | 170 | Overwrite="true" |
154 | 171 | WriteOnlyWhenDifferent="true" /> |
155 | | - |
156 | 172 | <WriteLinesToFile |
157 | 173 | Condition=" '$(RunOnGithubActionsLinux)' == 'true' and '$(_HasQuarantinedTests)' == 'true' " |
158 | | - File="$(ArtifactsTmpDir)/$(_TestRunsheet).linux.runsheet.json" |
| 174 | + File="$(_TestRunsheetFileNameLinux)" |
159 | 175 | Lines="$(_TestRunsheetLinux)" |
160 | 176 | Overwrite="true" |
161 | 177 | WriteOnlyWhenDifferent="true" /> |
| 178 | + <WriteLinesToFile |
| 179 | + Condition=" '$(RunOnGithubActionsMacOS)' == 'true' and '$(_HasQuarantinedTests)' == 'true' " |
| 180 | + File="$(_TestRunsheetFileNameMacOS)" |
| 181 | + Lines="$(_TestRunsheetMacOS)" |
| 182 | + Overwrite="true" |
| 183 | + WriteOnlyWhenDifferent="true" /> |
162 | 184 |
|
163 | 185 | <!-- |
164 | 186 | On Linux there's a bug in MSBuild, which "normalises" all slashes (see https://github.com/dotnet/msbuild/issues/3468). |
165 | 187 | This is a workaround to replace `/"` with the required `\"`. |
166 | 188 | --> |
167 | | - <Exec Command="pwsh -Command "(Get-Content -Path '$(ArtifactsTmpDir)/$(_TestRunsheet).win.runsheet.json') -replace '/\"', '\\\"' | Set-Content -Path '$(ArtifactsTmpDir)/$(_TestRunsheet).win.runsheet.json'" " |
168 | | - Condition=" '$(RunOnGithubActionsWindows)' == 'true' and '$(_HasQuarantinedTests)' == 'true' and '$(BuildOs)' != 'windows' " /> |
169 | | - <Exec Command="pwsh -Command "(Get-Content -Path '$(ArtifactsTmpDir)/$(_TestRunsheet).linux.runsheet.json') -replace '/\"', '\\\"' | Set-Content -Path '$(ArtifactsTmpDir)/$(_TestRunsheet).linux.runsheet.json'" " |
170 | | - Condition=" '$(RunOnGithubActionsLinux)' == 'true' and '$(_HasQuarantinedTests)' == 'true' and '$(BuildOs)' != 'windows' " /> |
| 189 | + <Exec Command="pwsh -Command "(Get-Content -Path '$(_TestRunsheetFileNameWindows)') -replace '/\"', '\\\"' | Set-Content -Path '$(_TestRunsheetFileNameWindows)'" " |
| 190 | + Condition=" Exists('$(_TestRunsheetFileNameWindows)') and '$(BuildOs)' != 'windows' " /> |
| 191 | + <Exec Command="pwsh -Command "(Get-Content -Path '$(_TestRunsheetFileNameLinux)') -replace '/\"', '\\\"' | Set-Content -Path '$(_TestRunsheetFileNameLinux)'" " |
| 192 | + Condition=" Exists('$(_TestRunsheetFileNameLinux)') and '$(BuildOs)' != 'windows' " /> |
| 193 | + <Exec Command="pwsh -Command "(Get-Content -Path '$(_TestRunsheetFileNameMacOS)') -replace '/\"', '\\\"' | Set-Content -Path '$(_TestRunsheetFileNameMacOS)'" " |
| 194 | + Condition=" Exists('$(_TestRunsheetFileNameMacOS)') and '$(BuildOs)' != 'windows' " /> |
171 | 195 |
|
172 | 196 | <!-- |
173 | 197 | The final piece of the puzzle is in eng/AfterSolutionBuild.targets, where we combine the runsheets from all the test projects into a single runsheet. |
|
0 commit comments