Skip to content

Commit

Permalink
Remove stale test
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi committed Mar 15, 2024
1 parent b77e470 commit 616fc28
Showing 1 changed file with 0 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -942,81 +942,6 @@ void M()
}
}

[Theory, CombinatorialData]
internal async Task TestCancellationDuringDiagnosticComputation_InProc(AnalyzerRegisterActionKind actionKind)
{
// This test verifies that we do no attempt to re-use CompilationWithAnalyzers instance in IDE in-proc diagnostic computation in presence of an OperationCanceledException during analysis.
// Attempting to do so has led to large number of reliability issues and flakiness in diagnostic computation, which we want to avoid.

var source = @"
class A
{
void M()
{
int x = 0;
}
}";

using var workspace = EditorTestWorkspace.CreateCSharp(source,
composition: s_editorFeaturesCompositionWithMockDiagnosticUpdateSourceRegistrationService.AddParts(typeof(TestDocumentTrackingService)));
Assert.True(workspace.TryApplyChanges(workspace.CurrentSolution.WithOptions(
workspace.CurrentSolution.Options.WithChangedOption(new OptionKey(DiagnosticOptionsStorage.PullDiagnosticsFeatureFlag), false))));

var analyzer = new CancellationTestAnalyzer(actionKind);
var analyzerReference = new AnalyzerImageReference(ImmutableArray.Create<DiagnosticAnalyzer>(analyzer));
workspace.TryApplyChanges(workspace.CurrentSolution.WithAnalyzerReferences(new[] { analyzerReference }));

var project = workspace.CurrentSolution.Projects.Single();
var document = project.Documents.Single();

Assert.IsType<MockDiagnosticUpdateSourceRegistrationService>(workspace.GetService<IDiagnosticUpdateSourceRegistrationService>());
var service = Assert.IsType<DiagnosticAnalyzerService>(workspace.GetService<IDiagnosticAnalyzerService>());
var globalOptions = workspace.GetService<IGlobalOptionService>();

DiagnosticData diagnostic = null;
service.DiagnosticsUpdated += (s, eCollection) =>
{
foreach (var e in eCollection)
{
var diagnostics = e.Diagnostics;
if (diagnostics.IsEmpty)
{
continue;
}
Assert.Null(diagnostic);
diagnostic = Assert.Single(diagnostics);
}
};

var incrementalAnalyzer = service.CreateIncrementalAnalyzer(workspace);

OpenDocumentAndMakeActive(document, workspace);

// First invoke analysis with cancellation token, and verify canceled compilation and no reported diagnostics.
Assert.Empty(analyzer.CanceledCompilations);
try
{
await incrementalAnalyzer.ForceAnalyzeProjectAsync(project, analyzer.CancellationToken);

throw ExceptionUtilities.Unreachable();
}
catch (OperationCanceledException ex) when (ex.CancellationToken == analyzer.CancellationToken)
{
}

Assert.Single(analyzer.CanceledCompilations);
Assert.Null(diagnostic);

// Then invoke analysis without cancellation token, and verify non-cancelled diagnostic.
await incrementalAnalyzer.ForceAnalyzeProjectAsync(project, CancellationToken.None);

await ((AsynchronousOperationListener)service.Listener).ExpeditedWaitAsync();

Assert.True(diagnostic != null);
Assert.Equal(CancellationTestAnalyzer.DiagnosticId, diagnostic.Id);
}

[Theory, CombinatorialData]
[WorkItem("https://github.com/dotnet/roslyn/issues/49698")]
internal async Task TestOnlyRequiredAnalyzerExecutedDuringDiagnosticComputation(bool documentAnalysis)
Expand Down

0 comments on commit 616fc28

Please sign in to comment.