From d5e76011b25a8481acb350ba6b5fe3d183343ffe Mon Sep 17 00:00:00 2001 From: Matt Parker <61717342+MattParkerDev@users.noreply.github.com> Date: Tue, 4 Nov 2025 19:56:28 +1000 Subject: [PATCH] display test nodes v1 --- .../Features/Testing/TestRunnerService.cs | 1 + .../TestExplorer/TestExplorerPanel.cs | 35 +++++++++++++++++++ .../TestExplorer/TestExplorerPanel.tscn | 3 +- .../Features/TestExplorer/TestNodeEntry.cs | 24 +++++++++++++ .../TestExplorer/TestNodeEntry.cs.uid | 1 + .../Features/TestExplorer/TestNodeEntry.tscn | 22 ++++++++++++ 6 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 src/SharpIDE.Godot/Features/TestExplorer/TestNodeEntry.cs create mode 100644 src/SharpIDE.Godot/Features/TestExplorer/TestNodeEntry.cs.uid create mode 100644 src/SharpIDE.Godot/Features/TestExplorer/TestNodeEntry.tscn diff --git a/src/SharpIDE.Application/Features/Testing/TestRunnerService.cs b/src/SharpIDE.Application/Features/Testing/TestRunnerService.cs index 9ebb885..d9fd7c0 100644 --- a/src/SharpIDE.Application/Features/Testing/TestRunnerService.cs +++ b/src/SharpIDE.Application/Features/Testing/TestRunnerService.cs @@ -9,6 +9,7 @@ public class TestRunnerService { public async Task> DiscoverTests(SharpIdeSolutionModel solutionModel) { + await Task.WhenAll(solutionModel.AllProjects.Select(s => s.MsBuildEvaluationProjectTask)); var testProjects = solutionModel.AllProjects.Where(p => p.IsMtpTestProject).ToList(); List allDiscoveredTestNodes = []; foreach (var testProject in testProjects) diff --git a/src/SharpIDE.Godot/Features/TestExplorer/TestExplorerPanel.cs b/src/SharpIDE.Godot/Features/TestExplorer/TestExplorerPanel.cs index ffd1067..5548382 100644 --- a/src/SharpIDE.Godot/Features/TestExplorer/TestExplorerPanel.cs +++ b/src/SharpIDE.Godot/Features/TestExplorer/TestExplorerPanel.cs @@ -1,7 +1,42 @@ using Godot; +using SharpIDE.Application.Features.Testing; namespace SharpIDE.Godot.Features.TestExplorer; public partial class TestExplorerPanel : Control { + [Inject] private readonly SharpIdeSolutionAccessor _solutionAccessor = null!; + [Inject] private readonly TestRunnerService _testRunnerService = null!; + + private readonly PackedScene _testNodeEntryScene = ResourceLoader.Load("uid://dt50f2of66dlt"); + + private VBoxContainer _testNodesVBoxContainer = null!; + + public override void _Ready() + { + _testNodesVBoxContainer = GetNode("%TestNodesVBoxContainer"); + _ = Task.GodotRun(AsyncReady); + } + + private async Task AsyncReady() + { + await _solutionAccessor.SolutionReadyTcs.Task; + var solution = _solutionAccessor.SolutionModel!; + var testNodes = await _testRunnerService.DiscoverTests(solution); + testNodes.ForEach(s => GD.Print(s.DisplayName)); + var scenes = testNodes.Select(s => + { + var entry = _testNodeEntryScene.Instantiate(); + entry.TestNode = s; + return entry; + }); + await this.InvokeAsync(() => + { + _testNodesVBoxContainer.QueueFreeChildren(); + foreach (var scene in scenes) + { + _testNodesVBoxContainer.AddChild(scene); + } + }); + } } \ No newline at end of file diff --git a/src/SharpIDE.Godot/Features/TestExplorer/TestExplorerPanel.tscn b/src/SharpIDE.Godot/Features/TestExplorer/TestExplorerPanel.tscn index 7f2f43e..8248cf0 100644 --- a/src/SharpIDE.Godot/Features/TestExplorer/TestExplorerPanel.tscn +++ b/src/SharpIDE.Godot/Features/TestExplorer/TestExplorerPanel.tscn @@ -61,7 +61,8 @@ placeholder_text = "Search for a test" layout_mode = 2 size_flags_vertical = 3 -[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/MarginContainer2/HSplitContainer/VBoxContainer/ScrollContainer"] +[node name="TestNodesVBoxContainer" type="VBoxContainer" parent="VBoxContainer/MarginContainer2/HSplitContainer/VBoxContainer/ScrollContainer"] +unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 3 size_flags_vertical = 3 diff --git a/src/SharpIDE.Godot/Features/TestExplorer/TestNodeEntry.cs b/src/SharpIDE.Godot/Features/TestExplorer/TestNodeEntry.cs new file mode 100644 index 0000000..8fa54a5 --- /dev/null +++ b/src/SharpIDE.Godot/Features/TestExplorer/TestNodeEntry.cs @@ -0,0 +1,24 @@ +using Godot; +using SharpIDE.Application.Features.Testing.Client.Dtos; + +namespace SharpIDE.Godot.Features.TestExplorer; + +public partial class TestNodeEntry : MarginContainer +{ + private Label _testNameLabel = null!; + + public TestNode TestNode { get; set; } = null!; + + public override void _Ready() + { + _testNameLabel = GetNode