Skip to content
This repository has been archived by the owner on Apr 14, 2022. It is now read-only.

Use an infinite timeout when debugger is attached #1655

Merged
merged 1 commit into from Oct 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Analysis/Ast/Test/AnalysisTestBase.cs
Expand Up @@ -39,6 +39,8 @@ namespace Microsoft.Python.Analysis.Tests {
public abstract class AnalysisTestBase {
protected TimeSpan AnalysisTimeout { get; set; } = TimeSpan.FromMinutes(1);

private TimeSpan GetAnalysisTimeout() => Debugger.IsAttached ? Timeout.InfiniteTimeSpan : AnalysisTimeout;

protected TestLogger TestLogger { get; } = new TestLogger();
protected ServiceManager Services { get; private set; }

Expand Down Expand Up @@ -156,7 +158,7 @@ protected Task<IDocumentAnalysis> GetAnalysisAsync(string code, PythonLanguageVe
TestLogger.Log(TraceEventType.Information, "Test: Analysis begin.");

IDocumentAnalysis analysis;
using (var cts = new CancellationTokenSource(AnalysisTimeout)) {
using (var cts = new CancellationTokenSource(GetAnalysisTimeout())) {
await services.GetService<IPythonAnalyzer>().WaitForCompleteAnalysisAsync(cts.Token);
analysis = await doc.GetAnalysisAsync(-1, cts.Token);
}
Expand All @@ -169,7 +171,7 @@ protected Task<IDocumentAnalysis> GetAnalysisAsync(string code, PythonLanguageVe

protected async Task<IDocumentAnalysis> GetDocumentAnalysisAsync(IDocument document) {
var analyzer = Services.GetService<IPythonAnalyzer>();
using (var cts = new CancellationTokenSource(AnalysisTimeout)) {
using (var cts = new CancellationTokenSource(GetAnalysisTimeout())) {
await analyzer.WaitForCompleteAnalysisAsync(cts.Token);
return await document.GetAnalysisAsync(Timeout.Infinite, cts.Token);
}
Expand Down