Fix bunch of issues with reference related tests#176
Fix bunch of issues with reference related tests#176MikhailArkhipov merged 16 commits intomicrosoft:masterfrom MikhailArkhipov:refs2
Conversation
MikhailArkhipov
commented
Oct 1, 2018
- Properly resolve function arguments vs global variables
- Treat reassignments as reference, not as definition
- Improve CancelAnalysis test (took forever with my 6500 files library)
- Fix some dispose issues (queue was not always empty after dispose/cancel)
- Dispose of stuff in order
- Update signature test to new behavior
- Update reference tests to new behavior
| LogMessage(MessageType.Error, t.Exception.Message); | ||
| return; | ||
| } | ||
| _shutdownCts.Token.ThrowIfCancellationRequested(); |
There was a problem hiding this comment.
It's enough to call it either here or in OnDocumentChangeProcessingCompleteAsync.
| } | ||
|
|
||
| if (doc is IAnalyzable analyzable && enqueueForAnalysis) { | ||
| _shutdownCts.Token.ThrowIfCancellationRequested(); |
There was a problem hiding this comment.
We can check this unconditionally.
|
|
||
| private async Task OnDocumentChangeProcessingCompleteAsync(IDocument doc, VersionCookie vc, bool enqueueForAnalysis, AnalysisPriority priority, IDisposable disposeWhenEnqueued) { | ||
| try { | ||
| _shutdownCts.Token.ThrowIfCancellationRequested(); |
There was a problem hiding this comment.
Then we don't need to call _disposableBag.ThrowIfDisposed(); here (and catch it at the end).
There was a problem hiding this comment.
Actually OnDocumentChangeProcessingCompleteAsync is not even async anymore
| foreach (var defScope in scope.EnumerateTowardsGlobal | ||
| .Where(s => s.ContainsVariable(name.Name) && (s == scope || s.VisibleToChildren || IsFirstLineOfFunction(scope, s, location)))) { | ||
| var scopeVariables = GetVariablesInScope(name, defScope).Distinct(); | ||
| foreach (var s in scope.EnumerateTowardsGlobal) { |
There was a problem hiding this comment.
Can we extract the body of if (expr is NameExpression name) { into separate method (something like GetVariablesFromNameExpression)?
|
Do you want the last change to be part of the same review? |
|
Yes. It actually fixes |
|
Ok, I'll take a look tomorrow morning. |
| "; | ||
| await server.SendDidOpenTextDocument(uri, text); | ||
|
|
||
| var references = await server.SendFindReferences(uri, 3, 15); | ||
| references.Should().OnlyHaveReferences( | ||
| var expected = new (Uri documentUri, (int, int, int, int), ReferenceKind?) [] { |
There was a problem hiding this comment.
You don't need documentUri here: var expected = new (Uri, (int, int, int, int), ReferenceKind?) [] {
There was a problem hiding this comment.
Or maybe we should just add an overload for OnlyHaveReferences with (Uri documentUri, (int, int, int, int), ReferenceKind) tuple.
| @@ -5341,7 +5365,7 @@ class test(): | |||
|
|
|||
| var files = Directory.GetFiles(Path.Combine(configuration.PrefixPath, "Lib"), "*.py", SearchOption.AllDirectories); | |||
| Trace.TraceInformation($"Files count: {files}"); | |||
| var contentTasks = files.Select(f => File.ReadAllTextAsync(f)).ToArray(); | |||
| var contentTasks = files.Take(Math.Min(50, files.Length)).Select(f => File.ReadAllTextAsync(f)).ToArray(); | |||
There was a problem hiding this comment.
files.Take(50) is enough.
From sources:
private static IEnumerable<TSource> TakeIterator<TSource>(IEnumerable<TSource> source, int count)
{
if (count > 0)
{
foreach (TSource source1 in source)
{
yield return source1;
if (--count == 0)
break;
}
}
}| await server.SendDidOpenTextDocument(new Uri(files[i]), contentTasks[i].Result); | ||
| } | ||
|
|
||
| server.AnalysisQueue.Count.Should().NotBe(0); | ||
| } finally { | ||
| if (server != null) { | ||
| analysisCompleteTask = EventTaskSources.AnalysisQueue.AnalysisComplete.Create(server.AnalysisQueue, new CancellationTokenSource(10000).Token); | ||
| serverDisposeTask = Task.WhenAny(Task.Run(() => server.Dispose()), Task.Delay(1000)); | ||
| serverDisposeTask = Task.WhenAny(Task.Run(() => server.Dispose()), Task.Delay(5000)); |
There was a problem hiding this comment.
Do we really need 5 seconds to dispose?
| class MyBaseClass1(object): | ||
| def base_method(self): pass | ||
| /* | ||
| [TestMethod, Priority(0)] |
There was a problem hiding this comment.
The whole block of commented tests is offset, please undo it.
Fix bunch of issues with reference related tests