Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="GitHubActionsTestLogger" Version="2.4.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageVersion Include="xunit" Version="2.9.2" />
Expand Down
35 changes: 31 additions & 4 deletions azure-pipelines/dotnet-test-cloud.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Param(

$RepoRoot = (Resolve-Path "$PSScriptRoot/..").Path
$ArtifactStagingFolder = & "$PSScriptRoot/Get-ArtifactsStagingDirectory.ps1"
$TestLogsPath = "$ArtifactStagingFolder/test_logs"
if (!(Test-Path $TestLogsPath)) { New-Item -ItemType Directory -Path $TestLogsPath | Out-Null }

$dotnet = 'dotnet'
if ($x86) {
Expand All @@ -44,21 +46,46 @@ if ($x86) {
}
}

$dotnetTestArgs = @()
$dotnetTestArgs2 = @()

# The GitHubActions test logger fails when combined with certain switches, but only on mac/linux.
# We avoid those switches in that specific context.
# Failure symptoms when using the wrong switch combinations on mac/linux are (depending on the switches) EITHER:
# - The test runner fails with exit code 1 (and no error message)
# - The test runner succeeds but the GitHubActions logger only adds annotations on Windows agents.
# See https://github.com/Tyrrrz/GitHubActionsTestLogger/discussions/37 for more info.
# Thus, the mess of conditions you see below, in order to get GitHubActions to work
# without undermining other value we have when running in other contexts.
if ($env:GITHUB_WORKFLOW -and ($IsLinux -or $IsMacOS)) {
$dotnetTestArgs += '--collect','Xplat Code Coverage'
$dotnetTestArgs2 += 'DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover'
} else {
$dotnetTestArgs += '--diag','$$TestLogsPath/diag.log;TraceLevel=info'
$dotnetTestArgs += '--collect','Code Coverage;Format=cobertura'
$dotnetTestArgs += '--settings',"$PSScriptRoot/test.runsettings"
}

if ($env:GITHUB_WORKFLOW) {
$dotnetTestArgs += '--logger','GitHubActions'
$dotnetTestArgs2 += 'RunConfiguration.CollectSourceInformation=true'
}

& $dotnet test $RepoRoot `
--no-build `
-c $Configuration `
--filter "TestCategory!=FailsInCloudTest" `
--collect "Code Coverage;Format=cobertura" `
--settings "$PSScriptRoot/test.runsettings" `
--blame-hang-timeout 60s `
--blame-crash `
-bl:"$ArtifactStagingFolder/build_logs/test.binlog" `
--diag "$ArtifactStagingFolder/test_logs/diag.log;TraceLevel=info" `
--logger trx `
@dotnetTestArgs `
-- `
@dotnetTestArgs2

$unknownCounter = 0
Get-ChildItem -Recurse -Path $RepoRoot\test\*.trx |% {
Copy-Item $_ -Destination $ArtifactStagingFolder/test_logs/
Copy-Item $_ -Destination $TestLogsPath/

if ($PublishResults) {
$x = [xml](Get-Content -LiteralPath $_)
Expand Down
3 changes: 3 additions & 0 deletions test/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GitHubActionsTestLogger" IncludeAssets="runtime" />
</ItemGroup>
</Project>