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

Commit 7ffc9db

Browse files
author
MikhailArkhipov
committed
Tests
1 parent 069910b commit 7ffc9db

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

src/Analysis/Ast/Impl/Analyzer/PythonAnalyzer.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,14 @@ private async Task AnalyzeAffectedEntriesAsync(IDependencyChainWalker<ModuleKey,
227227
StartAnalysis(node, walker.Version, stopWatch, cancellationToken);
228228
}
229229
}
230-
231-
if (walker.MissingKeys.Where(k => !k.IsTypeshed).Count == 0) {
230+
231+
var count = walker.MissingKeys.Where(k => !k.IsTypeshed).Count;
232+
_log?.Log(TraceEventType.Verbose, $"Walker count is {count}, missing keys:");
233+
foreach (var key in walker.MissingKeys) {
234+
_log?.Log(TraceEventType.Verbose, $" Name: {key.Name}, Path: {key.FilePath}");
235+
}
236+
237+
if (count == 0) {
232238
Interlocked.Exchange(ref _runningTasks, 0);
233239
_analysisCompleteEvent.Set();
234240
}

src/Analysis/Ast/Impl/Modules/PythonModule.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ internal PythonModule(ModuleCreationOptions creationOptions, IServiceContainer s
111111
ContentState = State.Analyzed;
112112
}
113113
InitializeContent(creationOptions.Content);
114+
Log?.Log(TraceEventType.Verbose, $"Created module: {Name} {FilePath}");
114115
}
115116

116117
#region IPythonType
@@ -385,21 +386,16 @@ private void Parse(CancellationToken cancellationToken) {
385386
_diagnosticsService?.Replace(Uri, _parseErrors);
386387
}
387388

388-
ContentState = State.Parsed;
389-
}
390-
391-
NewAst?.Invoke(this, EventArgs.Empty);
392-
393-
if (ContentState < State.Analyzing) {
394389
ContentState = State.Analyzing;
395390

391+
Log?.Log(TraceEventType.Verbose, $"Enqueue: {Name} {FilePath}");
396392
var analyzer = Services.GetService<IPythonAnalyzer>();
397393
analyzer.EnqueueDocumentForAnalysis(this, ast, version, _allProcessingCts.Token);
398-
}
399394

400-
lock (AnalysisLock) {
401395
_parsingTask = null;
402396
}
397+
398+
NewAst?.Invoke(this, EventArgs.Empty);
403399
}
404400

405401
private class CollectingErrorSink : ErrorSink {

src/Analysis/Ast/Test/BasicTests.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,14 @@ public async Task ImportTest() {
7575
import sys
7676
x = sys.path
7777
";
78-
var analysis = await GetAnalysisAsync(code);
79-
analysis.GlobalScope.Variables.Count.Should().Be(2);
80-
81-
analysis.Should()
82-
.HaveVariable("sys").OfType(BuiltinTypeId.Module)
83-
.And.HaveVariable("x").OfType(BuiltinTypeId.List);
78+
for (var i = 0; i < 20; i++) {
79+
var analysis = await GetAnalysisAsync(code);
80+
analysis.GlobalScope.Variables.Count.Should().Be(2);
81+
82+
analysis.Should()
83+
.HaveVariable("sys").OfType(BuiltinTypeId.Module)
84+
.And.HaveVariable("x").OfType(BuiltinTypeId.List);
85+
}
8486
}
8587

8688
[TestMethod, Priority(0)]

0 commit comments

Comments
 (0)