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
14 changes: 14 additions & 0 deletions test/CodoMetis.TypeKit.Analyzers.Tests/AnalyzerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ public AnalyzerTest(string source, bool referenceTypeKit = true)
}
}

/// <summary>What a sweep over a variant catalogue leaves to the focused tests of its rule.</summary>
/// <remarks>
/// The verifier runs a case that expects a diagnostic a second time, under <c>#pragma warning disable</c> for each id
/// it expects, and checks that nothing is left. Whether a pragma silences a rule is the compiler's, the same for every
/// shape, so a sweep paid for that pass once per row: 28% of DroppedTaskVariantTests' time (#245). The focused tests
/// of each rule keep it. The verifier's other pass, under an <c>&lt;auto-generated&gt;</c> header, never runs here:
/// every analyzer configures generated-code analysis (<c>GeneratedCode.AnalysisFlags</c>), and GeneratedCodeTests
/// holds what each rule does in generated code.
/// </remarks>
internal static class VariantSweep
{
public const TestBehaviors Behaviors = TestBehaviors.SkipSuppressionCheck;
}

/// <summary>A verifier run of one analyzer and its code fix: the source, then the source as the fix leaves it.</summary>
internal sealed class CodeFixTest<TAnalyzer, TCodeFix> : CSharpCodeFixTest<TAnalyzer, TCodeFix, DefaultVerifier>
where TAnalyzer : DiagnosticAnalyzer, new()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,15 @@
<PackageReference Include="System.Security.Cryptography.Pkcs" />
</ItemGroup>

<!--
parallelMode "all": every row of a theory runs in parallel, not only the test classes (xunit.v3 4.x). Each
variant sweep is one class of hundreds to thousands of rows, which the default mode ran one after another:
DroppedTaskVariantTests alone kept CI's test step going for two to seven minutes after every other test
project had finished (#245). Every test here builds its own compilation and shares nothing with another, so
none opts out.
-->
<ItemGroup>
<None Update="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public Task A_dropped_task_is_reported_in_every_form_and_a_kept_one_never(string
var (source, expected) = DroppedTaskShapes.Use(call, form);

var test = new AnalyzerTest<IgnoredOutcomeAnalyzer>(source);
test.TestBehaviors = VariantSweep.Behaviors;
test.TestState.Sources.Add(("Declarations.cs", DroppedTaskShapes.Declarations));
test.TestState.AdditionalReferences.Add(RealTesting.Reference);
test.ExpectedDiagnostics.AddRange(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ private static Task Sweep(QueryReceiver receiver, string element, string paramet
var (source, expected) = QueryDelegateShapes.Use(receiver, element, parameters, where);

var test = new AnalyzerTest<DefaultProducingCallAnalyzer>(TypeArgumentKinds.Candidates);
test.TestBehaviors = VariantSweep.Behaviors;
test.TestState.Sources.Add(("Declarations.cs", QueryDelegateShapes.Declarations));
test.TestState.Sources.Add(("Use.cs", source));
test.ExpectedDiagnostics.AddRange(expected.Select(call => new DiagnosticResult("CMTK0009", DiagnosticSeverity.Warning).WithLocation(call.Location)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ public void The_catalogue_names_are_unique_and_its_pairs_reach_every_verdict()
private static Task Run(string subject, string use, bool breaking)
{
var test = new AnalyzerTest<TypeArgumentConstraintAnalyzer>(TypeArgumentKinds.Candidates + subject);
test.TestBehaviors = VariantSweep.Behaviors;
test.TestState.Sources.Add(("Use.cs", use));

if (breaking)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public static Task Verify<TAnalyzer>(TypeArgumentSubject subject, string siteNam
var use = Fill(site.Use, subject, argument);

var test = new AnalyzerTest<TAnalyzer>(Fill(TypeArgumentSites.Subjects + subject.Declarations, subject, argument));
test.TestBehaviors = VariantSweep.Behaviors;
test.TestState.Sources.Add((site.File, reported ? use : Unmarked(use)));

if (reported)
Expand Down
4 changes: 4 additions & 0 deletions test/CodoMetis.TypeKit.Analyzers.Tests/xunit.runner.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://xunit.net/schema/v3/xunit.runner.schema.json",
"parallelMode": "all"
}
Loading