From fcf5ccf357cda4ad1aa1b4f3fff2bbf9dbbcc96d Mon Sep 17 00:00:00 2001 From: Matt Parker <61717342+MattParkerDev@users.noreply.github.com> Date: Tue, 4 Nov 2025 20:55:51 +1000 Subject: [PATCH] run all tests v1 --- .../Features/Testing/TestRunnerService.cs | 35 +++++++--------- .../TestExplorer/TestExplorerPanel.cs | 41 +++++++++++++++++++ .../TestExplorer/TestExplorerPanel.tscn | 23 +++++++++-- .../Features/TestExplorer/TestNodeEntry.cs | 4 ++ .../Features/TestExplorer/TestNodeEntry.tscn | 5 +++ 5 files changed, 85 insertions(+), 23 deletions(-) diff --git a/src/SharpIDE.Application/Features/Testing/TestRunnerService.cs b/src/SharpIDE.Application/Features/Testing/TestRunnerService.cs index d9fd7c0..1570aab 100644 --- a/src/SharpIDE.Application/Features/Testing/TestRunnerService.cs +++ b/src/SharpIDE.Application/Features/Testing/TestRunnerService.cs @@ -30,35 +30,30 @@ public class TestRunnerService return allDiscoveredTestNodes; } + public async Task RunTestsAsync(SharpIdeSolutionModel solutionModel, Func func) + { + await Task.WhenAll(solutionModel.AllProjects.Select(s => s.MsBuildEvaluationProjectTask)); + var testProjects = solutionModel.AllProjects.Where(p => p.IsMtpTestProject).ToList(); + foreach (var testProject in testProjects) + { + await RunTestsAsync(testProject, func); + } + } + // Assumes it has already been built - public async Task RunTestsAsync(SharpIdeProjectModel project) + public async Task RunTestsAsync(SharpIdeProjectModel project, Func func) { using var client = await GetInitialisedClientAsync(project); List testNodeUpdates = []; - var discoveryResponse = await client.DiscoverTestsAsync(Guid.NewGuid(), node => + var discoveryResponse = await client.DiscoverTestsAsync(Guid.NewGuid(), async nodeUpdates => { - testNodeUpdates.AddRange(node); - return Task.CompletedTask; + testNodeUpdates.AddRange(nodeUpdates); + await func(nodeUpdates); }); await discoveryResponse.WaitCompletionAsync(); - Console.WriteLine($"Discovery finished: {testNodeUpdates.Count} tests discovered"); - Console.WriteLine(string.Join(Environment.NewLine, testNodeUpdates.Select(n => n.Node.DisplayName))); - - List runResults = []; - ResponseListener runRequest = await client.RunTestsAsync(Guid.NewGuid(), testNodeUpdates.Select(x => x.Node).ToArray(), node => - { - runResults.AddRange(node); - return Task.CompletedTask; - }); + ResponseListener runRequest = await client.RunTestsAsync(Guid.NewGuid(), testNodeUpdates.Select(x => x.Node).ToArray(), func); await runRequest.WaitCompletionAsync(); - - - var passedCount = runResults.Where(tn => tn.Node.ExecutionState == ExecutionStates.Passed).Count(); - var failedCount = runResults.Where(tn => tn.Node.ExecutionState == ExecutionStates.Failed).Count(); - var skippedCount = runResults.Where(tn => tn.Node.ExecutionState == ExecutionStates.Skipped).Count(); - - Console.WriteLine($"Passed: {passedCount}; Skipped: {skippedCount}; Failed: {failedCount};"); await client.ExitAsync(); } diff --git a/src/SharpIDE.Godot/Features/TestExplorer/TestExplorerPanel.cs b/src/SharpIDE.Godot/Features/TestExplorer/TestExplorerPanel.cs index 7ae0865..797c31d 100644 --- a/src/SharpIDE.Godot/Features/TestExplorer/TestExplorerPanel.cs +++ b/src/SharpIDE.Godot/Features/TestExplorer/TestExplorerPanel.cs @@ -1,6 +1,7 @@ using Godot; using SharpIDE.Application.Features.Build; using SharpIDE.Application.Features.Testing; +using SharpIDE.Application.Features.Testing.Client.Dtos; namespace SharpIDE.Godot.Features.TestExplorer; @@ -14,13 +15,16 @@ public partial class TestExplorerPanel : Control private Button _refreshButton = null!; private VBoxContainer _testNodesVBoxContainer = null!; + private Button _runAllTestsButton = null!; public override void _Ready() { _refreshButton = GetNode