|
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 | | - |
131 | 127 | <_TestBinLog>$([MSBuild]::NormalizePath($(ArtifactsLogDir), '$(_TestRunsheet).binlog'))</_TestBinLog> |
132 | 128 |
|
133 | 129 | <_RelativeTestProjectPath>$([System.String]::Copy('$(MSBuildProjectFullPath)').Replace('$(RepoRoot)', '%24(pwd)/'))</_RelativeTestProjectPath> |
|
137 | 133 | <_TestRunnerLinux>./eng/build.sh</_TestRunnerLinux> |
138 | 134 | <_TestCommand>-restore -build -test -projects "$(_RelativeTestProjectPath)" /bl:"$(_RelativeTestBinLog)" -c $(Configuration) -ci /p:RunQuarantinedTests=true /p:CI=false</_TestCommand> |
139 | 135 |
|
140 | | - <_PreCommand>$(TestRunnerPreCommand)</_PreCommand> |
141 | | - |
142 | 136 | <!-- |
143 | 137 | Some quarantinted test may only be executable on Windows or Linux, however we can't possibly know that at this time. |
144 | 138 | The MTP runner will return exit code 8 if no tests are found, and we need to ignore it instead of failing the test. |
145 | 139 | --> |
146 | 140 | <_TestCommand>$(_TestCommand) /p:IgnoreZeroTestResult=true</_TestCommand> |
147 | 141 |
|
148 | 142 | <!-- Replace \ with /, and then escape " with \", so we have a compliant JSON --> |
149 | | - <_PreCommand>$([System.String]::Copy($(_PreCommand)).Replace("\", "/").Replace('"', '\"'))</_PreCommand> |
150 | 143 | <_TestCommand>$([System.String]::Copy($(_TestCommand)).Replace("\", "/").Replace('"', '\"'))</_TestCommand> |
151 | 144 |
|
152 | 145 | <_TestRunsheetWindows>{ "project": "$(_TestRunsheet)", "os": "windows-latest", "command": "./eng/build.ps1 $(_TestCommand)" }</_TestRunsheetWindows> |
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> |
| 146 | + <_TestRunsheetLinux>{ "project": "$(_TestRunsheet)", "os": "ubuntu-latest", "command": "./eng/build.sh $(_TestCommand)" }</_TestRunsheetLinux> |
155 | 147 | </PropertyGroup> |
156 | 148 |
|
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 | | - |
166 | 149 | <WriteLinesToFile |
167 | 150 | Condition=" '$(RunOnGithubActionsWindows)' == 'true' and '$(_HasQuarantinedTests)' == 'true'" |
168 | | - File="$(_TestRunsheetFileNameWindows)" |
| 151 | + File="$(ArtifactsTmpDir)/$(_TestRunsheet).win.runsheet.json" |
169 | 152 | Lines="$(_TestRunsheetWindows)" |
170 | 153 | Overwrite="true" |
171 | 154 | WriteOnlyWhenDifferent="true" /> |
| 155 | + |
172 | 156 | <WriteLinesToFile |
173 | 157 | Condition=" '$(RunOnGithubActionsLinux)' == 'true' and '$(_HasQuarantinedTests)' == 'true' " |
174 | | - File="$(_TestRunsheetFileNameLinux)" |
| 158 | + File="$(ArtifactsTmpDir)/$(_TestRunsheet).linux.runsheet.json" |
175 | 159 | Lines="$(_TestRunsheetLinux)" |
176 | 160 | Overwrite="true" |
177 | 161 | WriteOnlyWhenDifferent="true" /> |
178 | | - <WriteLinesToFile |
179 | | - Condition=" '$(RunOnGithubActionsMacOS)' == 'true' and '$(_HasQuarantinedTests)' == 'true' " |
180 | | - File="$(_TestRunsheetFileNameMacOS)" |
181 | | - Lines="$(_TestRunsheetMacOS)" |
182 | | - Overwrite="true" |
183 | | - WriteOnlyWhenDifferent="true" /> |
184 | 162 |
|
185 | 163 | <!-- |
186 | 164 | On Linux there's a bug in MSBuild, which "normalises" all slashes (see https://github.com/dotnet/msbuild/issues/3468). |
187 | 165 | This is a workaround to replace `/"` with the required `\"`. |
188 | 166 | --> |
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' " /> |
| 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' " /> |
195 | 171 |
|
196 | 172 | <!-- |
197 | 173 | 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