Skip to content

Commit f0993d8

Browse files
committed
Include the large source test
1 parent 94eaff5 commit f0993d8

File tree

6 files changed

+68
-41
lines changed

6 files changed

+68
-41
lines changed

Syndiesis.Tests/BaseProjectCodeTests.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,23 @@ namespace Syndiesis.Tests;
77
public abstract class BaseProjectCodeTests
88
{
99
protected static readonly ProjectSourceProvider SourceProvider
10-
= ProjectSourceProvider.Get();
10+
= Syndiesis.ProjectSourceProviderGetter.Get();
1111

12-
protected static readonly ImmutableArray<FileInfo> FilesToTest
12+
protected static readonly ProjectSourceProvider TestSourceProvider
13+
= Syndiesis.Tests.ProjectSourceProviderGetter.Get();
14+
15+
protected static readonly ImmutableArray<FileInfo> MainFilesToTest
1316
= SourceProvider.GetFilePaths();
1417

18+
protected static readonly ImmutableArray<FileInfo> TestFilesToTest
19+
= TestSourceProvider.GetFilePaths();
20+
21+
protected static readonly ImmutableArray<FileInfo> FilesToTest =
22+
[
23+
.. MainFilesToTest,
24+
.. TestFilesToTest,
25+
];
26+
1527
[Test]
1628
public async Task TestAllFilesIndependently()
1729
{

Syndiesis.Tests/NodeViewDetailsHandlerTests.cs

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
using Microsoft.CodeAnalysis;
1+
using Garyon.Extensions;
2+
using Microsoft.CodeAnalysis;
23
using Microsoft.CodeAnalysis.Text;
34
using Syndiesis.Core;
5+
using Syndiesis.Utilities;
46

57
namespace Syndiesis.Tests;
68

@@ -18,16 +20,29 @@ protected override async Task TestSource(string text)
1820
private static async Task TestEntireHybridCompilationTree(
1921
HybridSingleTreeCompilationSource hybridCompilation)
2022
{
21-
var tree = hybridCompilation.CurrentSource.Tree;
22-
Assert.That(tree, Is.Not.Null);
23-
var root = await tree.GetRootAsync();
24-
Assert.That(root, Is.Not.Null);
23+
var profiling = new SimpleProfiling();
24+
int nodeCount = 0;
25+
int length = 0;
26+
using (var _ = profiling.BeginProcess())
27+
{
28+
var tree = hybridCompilation.CurrentSource.Tree;
29+
Assert.That(tree, Is.Not.Null);
30+
var root = await tree.GetRootAsync();
31+
Assert.That(root, Is.Not.Null);
32+
length = root.FullSpan.Length;
33+
34+
var nodes = root.DescendantNodesAndSelf(descendIntoTrivia: true)
35+
.ToList();
36+
nodeCount = nodes.Count;
37+
await Parallel.ForEachAsync(
38+
nodes,
39+
TestNodeLocal);
40+
}
2541

26-
var nodes = root.DescendantNodesAndSelf(descendIntoTrivia: true)
27-
.ToList();
28-
await Parallel.ForEachAsync(
29-
nodes,
30-
TestNodeLocal);
42+
var seconds = profiling.SnapshotResults!.Time.TotalSeconds;
43+
TestContext.Progress.WriteLine($"""
44+
Finished testing all {nodeCount} nodes from {length} characters in {seconds:N3}s
45+
""");
3146

3247
async ValueTask TestNodeLocal(SyntaxNode node, CancellationToken cancellationToken)
3348
{
@@ -55,6 +70,7 @@ private static async Task TestNode(
5570
{
5671
Assert.That(rootNode?.FullSpan, Is.EqualTo(node.FullSpan));
5772
}
73+
5874
}
5975

6076
private static async Task<NodeViewAnalysisExecution> TestExecutingResult(
@@ -68,26 +84,8 @@ private static async Task<NodeViewAnalysisExecution> TestExecutingResult(
6884
var result = execution.ExecuteCore(default);
6985
Assert.That(result, Is.Not.Null);
7086

71-
bool allSuccessful = await result.AwaitAllLoaded();
87+
bool allSuccessful = await result.AwaitAllLoaded(TimeSpan.FromMilliseconds(45));
7288
Assert.That(allSuccessful, Is.True);
7389
return execution;
7490
}
75-
76-
[Test]
77-
public async Task TestAllFilesWithFlow()
78-
{
79-
TestContext.Progress.WriteLine(
80-
"Began testing the node view data analysis on all files sequentially, this will take some more time.");
81-
82-
var hybridCompilation = new HybridSingleTreeCompilationSource();
83-
84-
foreach (var file in FilesToTest)
85-
{
86-
var text = await File.ReadAllTextAsync(file.FullName);
87-
hybridCompilation.SetSource(text, default);
88-
await TestEntireHybridCompilationTree(hybridCompilation);
89-
90-
TestContext.Progress.WriteLine($"Processed file {file.FullName}");
91-
}
92-
}
9391
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace Syndiesis.Tests;
2+
3+
public static class ProjectSourceProviderGetter
4+
{
5+
public static ProjectSourceProvider Get()
6+
{
7+
var thisPath = ProjectSourceProvider.CallerFilePath();
8+
return new(thisPath);
9+
}
10+
}

Syndiesis/Controls/AnalysisVisualization/NodeDetailsViewData.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Garyon.Functions;
22
using Syndiesis.Core.DisplayAnalysis;
3+
using System;
34
using System.Collections.Generic;
45
using System.Linq;
56
using System.Threading.Tasks;
@@ -40,14 +41,16 @@ SemanticModelSection SemanticModel
4041
];
4142
}
4243

43-
public async Task<bool> AwaitAllLoaded()
44+
public async Task<bool> AwaitAllLoaded(TimeSpan expectedDelay = default)
4445
{
4546
var nodeLoaders = AllNodes()
4647
.Select(s => s.NodeLoader)
4748
.Where(Predicates.NotNull)
4849
.ToList()
4950
;
5051

52+
await Task.Delay(expectedDelay);
53+
5154
await Task.WhenAll(nodeLoaders!);
5255
return nodeLoaders.All(l => l!.IsCompletedSuccessfully);
5356
}

Syndiesis/ProjectSourceProvider.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
namespace Syndiesis;
66

7-
public sealed class ProjectSourceProvider(string? callerFilePath)
7+
public class ProjectSourceProvider(string? callerFilePath)
88
{
99
private readonly string? _callerFilePath = callerFilePath;
10-
10+
1111
public ImmutableArray<FileInfo> GetFilePaths()
1212
{
1313
if (string.IsNullOrEmpty(_callerFilePath))
@@ -21,14 +21,8 @@ public ImmutableArray<FileInfo> GetFilePaths()
2121
return [.. files];
2222
}
2323

24-
private static string? ThisPath([CallerFilePath] string? callerFilePath = null)
24+
public static string? CallerFilePath([CallerFilePath] string? callerFilePath = null)
2525
{
2626
return callerFilePath;
2727
}
28-
29-
public static ProjectSourceProvider Get()
30-
{
31-
var thisPath = ThisPath();
32-
return new(thisPath);
33-
}
3428
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace Syndiesis;
2+
3+
public static class ProjectSourceProviderGetter
4+
{
5+
public static ProjectSourceProvider Get()
6+
{
7+
var thisPath = ProjectSourceProvider.CallerFilePath();
8+
return new(thisPath);
9+
}
10+
}

0 commit comments

Comments
 (0)