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
39 changes: 39 additions & 0 deletions eng/AnalyzerTestReferencePacks.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<Project>
<!--
Restores the reference packs that the analyzer tests' ReferenceAssemblies resolve, so they are
already in the NuGet global packages folder when the tests start.

Microsoft.CodeAnalysis.Testing resolves each ReferenceAssemblies under one machine-wide file lock
($TMPDIR/test-packages/.lock, retried once a second) and checks the global packages folder
before any feed. Without these downloads every analyzer test process on a fresh CI runner
fetches the ~50 MB packs from nuget.org while holding that lock, and the processes running in
parallel queue behind each other. On macOS the first tests waited up to 5 minutes, which
tripped the hang dump (#7575).

Keep the versions in step with the ReferenceAssemblies the tests use: ReferenceAssemblies.Net.Net80
and .Net90 (8.0.0, 9.0.0), the explicit net10.0 pack (10.0.0), ReferenceAssemblies.NetFramework.Net472
(1.0.2), the explicit net48 pack (1.0.3), and every PackageIdentity passed to AddPackages. A
version missing here still works; it is just downloaded at test time again.
-->
<ItemGroup>
<PackageDownload Include="Microsoft.NETCore.App.Ref" Version="[8.0.0];[9.0.0];[10.0.0]" />
<PackageDownload Include="Microsoft.NETFramework.ReferenceAssemblies.net472" Version="[1.0.2]" />
<PackageDownload Include="Microsoft.NETFramework.ReferenceAssemblies.net48" Version="[1.0.3]" />

<!-- Packages the verifiers add with ReferenceAssemblies.AddPackages, and their dependencies.
PackageDownload does not restore dependencies, so each one is listed: the walk resolves
the dependency group nearest the ReferenceAssemblies framework (net8.0/net9.0/net10.0,
and net472 on Windows). -->
<PackageDownload Include="Microsoft.Bcl.AsyncInterfaces" Version="[6.0.0];[9.0.0]" />
<PackageDownload Include="xunit.v3.assert" Version="[2.0.0];[3.2.0]" />
<PackageDownload Include="xunit.v3.extensibility.core" Version="[3.0.1]" />
<PackageDownload Include="xunit.v3.common" Version="[3.0.1]" />
<PackageDownload Include="System.Collections.Immutable" Version="[6.0.0]" />
<PackageDownload Include="System.Memory" Version="[4.5.4];[4.5.5]" />
<PackageDownload Include="System.Runtime.CompilerServices.Unsafe" Version="[4.5.3];[6.0.0]" />
<!-- Only the net472 dependency groups need these. -->
<PackageDownload Include="System.Threading.Tasks.Extensions" Version="[4.5.4]" />
<PackageDownload Include="System.Buffers" Version="[4.5.1]" />
<PackageDownload Include="System.Numerics.Vectors" Version="[4.5.0]" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions tests/TUnit.Analyzers.Tests/TUnit.Analyzers.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\eng\TestProject.props" />
<Import Project="..\..\eng\AnalyzerTestReferencePacks.props" />

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\eng\TestProject.props" />
<Import Project="..\..\eng\AnalyzerTestReferencePacks.props" />

<PropertyGroup>
<!-- ASP.NET Core only supports .NET 8.0+ -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\eng\TestProject.props" />
<Import Project="..\..\eng\AnalyzerTestReferencePacks.props" />

<ItemGroup>
<ProjectReference Include="..\..\src\TUnit.Assertions.Analyzers.CodeFixers\TUnit.Assertions.Analyzers.CodeFixers.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="..\..\eng\TestProject.props" />
<Import Project="..\..\eng\AnalyzerTestReferencePacks.props" />

<ItemGroup>
<ProjectReference Include="..\..\src\TUnit.Assertions.Analyzers\TUnit.Assertions.Analyzers.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="..\..\eng\TestProject.props" />
<Import Project="..\..\eng\AnalyzerTestReferencePacks.props" />

<ItemGroup>
<ProjectReference Include="..\..\src\TUnit.Mocks.Analyzers\TUnit.Mocks.Analyzers.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public abstract class EngineTestsModuleBase : Module<CommandResult>
Configuration = "Release",
Framework = "net10.0",
Arguments = [
"--hangdump", "--hangdump-filename", $"hangdump.{RuntimeInformation.RuntimeIdentifier}.engine-tests-{TestMode}.dmp", "--hangdump-timeout", "30m",
..HangDumpArguments.Create($"hangdump.{RuntimeInformation.RuntimeIdentifier}.engine-tests-{TestMode}.dmp", "30m"),
"--timeout", "35m",
// Each engine test mostly waits on a child test-application process, so the
// engine's default limit (twice the processor count) leaves the CPUs idle. Four
Expand Down
24 changes: 24 additions & 0 deletions tools/TUnit.Pipeline/Modules/Abstract/HangDumpArguments.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Runtime.InteropServices;

namespace TUnit.Pipeline.Modules.Abstract;

/// <summary>
/// Builds the Microsoft.Testing.Platform hang-dump arguments every test module passes.
/// </summary>
public static class HangDumpArguments
{
/// <summary>
/// Returns <c>--hangdump</c> with the given dump file name and inactivity timeout. On macOS it also
/// asks for a heap dump instead of the default full dump: a full dump of an arm64 test process
/// is about 7.6 GB because it includes every reserved region, and writing one on the 3-core,
/// 7 GB macOS runner never finished, so a slow-but-passing run sat until the 30-minute module
/// timeout (#7575). A heap dump of the same process is about 0.5 GB, is written in under a
/// second, and still holds the async state machines that <c>dotnet-dump analyze</c> needs for
/// <c>dumpasync</c>. Linux and Windows keep the default full dump on purpose: it finishes there,
/// and it holds the native memory a heap dump leaves out.
/// </summary>
public static string[] Create(string fileName, string timeout) =>
RuntimeInformation.IsOSPlatform(OSPlatform.OSX)
? ["--hangdump", "--hangdump-filename", fileName, "--hangdump-timeout", timeout, "--hangdump-type", "Heap"]
: ["--hangdump", "--hangdump-filename", fileName, "--hangdump-timeout", timeout];
}
2 changes: 1 addition & 1 deletion tools/TUnit.Pipeline/Modules/RunAnalyzersTestsModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class RunAnalyzersTestsModule : TestBaseModule
NoBuild = true,
Configuration = "Release",
Framework = framework,
Arguments = ["--hangdump", "--hangdump-filename", $"hangdump.analyzers-tests-{framework}.dmp", "--hangdump-timeout", "5m"],
Arguments = [..HangDumpArguments.Create($"hangdump.analyzers-tests-{framework}.dmp", "5m")],
},
new CommandExecutionOptions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class RunAspNetCoreAnalyzersTestsModule : TestBaseModule
NoBuild = true,
Configuration = "Release",
Framework = framework,
Arguments = ["--hangdump", "--hangdump-filename", $"hangdump.aspnetcore-analyzers-tests-{framework}.dmp", "--hangdump-timeout", "5m"],
Arguments = [..HangDumpArguments.Create($"hangdump.aspnetcore-analyzers-tests-{framework}.dmp", "5m")],
},
new CommandExecutionOptions
{
Expand Down
3 changes: 2 additions & 1 deletion tools/TUnit.Pipeline/Modules/RunAspNetTestsModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using ModularPipelines.Models;
using ModularPipelines.Modules;
using ModularPipelines.Options;
using TUnit.Pipeline.Modules.Abstract;

namespace TUnit.Pipeline.Modules;

Expand All @@ -29,7 +30,7 @@ public class RunAspNetTestsModule : Module<CommandResult>
NoBuild = true,
Configuration = "Release",
Framework = "net10.0",
Arguments = ["--hangdump", "--hangdump-filename", "hangdump.aspnet-tests.dmp", "--hangdump-timeout", "5m"],
Arguments = [..HangDumpArguments.Create("hangdump.aspnet-tests.dmp", "5m")],
}, new CommandExecutionOptions
{
WorkingDirectory = project.Folder!.Path,
Expand Down
3 changes: 2 additions & 1 deletion tools/TUnit.Pipeline/Modules/RunAspireTestsModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using ModularPipelines.Models;
using ModularPipelines.Modules;
using ModularPipelines.Options;
using TUnit.Pipeline.Modules.Abstract;

namespace TUnit.Pipeline.Modules;

Expand All @@ -29,7 +30,7 @@ public class RunAspireTestsModule : Module<CommandResult>
NoBuild = true,
Configuration = "Release",
Framework = "net10.0",
Arguments = ["--hangdump", "--hangdump-filename", "hangdump.aspire-tests.dmp", "--hangdump-timeout", "5m"],
Arguments = [..HangDumpArguments.Create("hangdump.aspire-tests.dmp", "5m")],
}, new CommandExecutionOptions
{
WorkingDirectory = project.Folder!.Path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class RunAssertionsAnalyzersTestsModule : TestBaseModule
NoBuild = true,
Configuration = "Release",
Framework = framework,
Arguments = ["--hangdump", "--hangdump-filename", $"hangdump.assertions-analyzers-tests-{framework}.dmp", "--hangdump-timeout", "5m"],
Arguments = [..HangDumpArguments.Create($"hangdump.assertions-analyzers-tests-{framework}.dmp", "5m")],
},
new CommandExecutionOptions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class RunAssertionsCodeFixersTestsModule : TestBaseModule
NoBuild = true,
Configuration = "Release",
Framework = framework,
Arguments = ["--hangdump", "--hangdump-filename", $"hangdump.assertions-codefixers-tests-{framework}.dmp", "--hangdump-timeout", "5m"],
Arguments = [..HangDumpArguments.Create($"hangdump.assertions-codefixers-tests-{framework}.dmp", "5m")],
},
new CommandExecutionOptions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class RunInternalAnalyzersTestsModule : TestBaseModule
NoBuild = true,
Configuration = "Release",
Framework = framework,
Arguments = ["--hangdump", "--hangdump-filename", $"hangdump.internal-analyzers-tests-{framework}.dmp", "--hangdump-timeout", "5m"],
Arguments = [..HangDumpArguments.Create($"hangdump.internal-analyzers-tests-{framework}.dmp", "5m")],
},
new CommandExecutionOptions
{
Expand Down
3 changes: 2 additions & 1 deletion tools/TUnit.Pipeline/Modules/RunOpenTelemetryTestsModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using ModularPipelines.Models;
using ModularPipelines.Modules;
using ModularPipelines.Options;
using TUnit.Pipeline.Modules.Abstract;

namespace TUnit.Pipeline.Modules;

Expand All @@ -23,7 +24,7 @@ public class RunOpenTelemetryTestsModule : Module<CommandResult>
NoBuild = true,
Configuration = "Release",
Framework = "net10.0",
Arguments = ["--hangdump", "--hangdump-filename", "hangdump.opentelemetry-tests.dmp", "--hangdump-timeout", "5m"],
Arguments = [..HangDumpArguments.Create("hangdump.opentelemetry-tests.dmp", "5m")],
}, new CommandExecutionOptions
{
WorkingDirectory = project.Folder!.Path,
Expand Down
3 changes: 2 additions & 1 deletion tools/TUnit.Pipeline/Modules/RunTemplateTestsModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using ModularPipelines.Models;
using ModularPipelines.Modules;
using ModularPipelines.Options;
using TUnit.Pipeline.Modules.Abstract;

namespace TUnit.Pipeline.Modules;

Expand All @@ -22,7 +23,7 @@ public class RunTemplateTestsModule : Module<CommandResult>
NoBuild = true,
Configuration = "Release",
Framework = "net10.0",
Arguments = ["--", "--hangdump", "--hangdump-filename", "hangdump.template-tests.dmp", "--hangdump-timeout", "5m"],
Arguments = ["--", ..HangDumpArguments.Create("hangdump.template-tests.dmp", "5m")],
}, new CommandExecutionOptions
{
WorkingDirectory = project.Folder!.Path,
Expand Down
Loading