Browse Source

Stop awaiting decompiles those tests never read

The four `WaitForDecompiledTextAsync` calls in PreviewTabPromotionTests
asserted only on dock structure -- SourceNode, IsPreview, tab count,
Content reference -- never on decompiled Text. Those values are set
synchronously by ShowSelectedNode before DecompileAsync's first await
returns, so the ~25s wait was pure dead weight. Worse, the fire-and-forget
DecompileAsync kept chewing CPU after the test returned and contended on
the ThreadPool with the next test's decompile, which is what pushed the
same workload from 12-16s in isolation to 24-28s in full-suite -- right
up against the 30s budget. One slow GC pause and PinCurrentTab_Flips
timed out at 30.997s exactly.
pull/3755/head
Siegfried Pammer 2 months ago
parent
commit
3b7a898a2c
  1. 8
      ILSpy.Tests/Docking/PreviewTabPromotionTests.cs
  2. 11
      ILSpy/Docking/DockWorkspace.cs

8
ILSpy.Tests/Docking/PreviewTabPromotionTests.cs

@ -94,7 +94,7 @@ public class PreviewTabPromotionTests
var typeNode = vm.AssemblyTreeModel.FindNode<TypeTreeNode>( var typeNode = vm.AssemblyTreeModel.FindNode<TypeTreeNode>(
"System.Linq", "System.Linq", "System.Linq.Enumerable"); "System.Linq", "System.Linq", "System.Linq.Enumerable");
vm.AssemblyTreeModel.SelectNode(typeNode); vm.AssemblyTreeModel.SelectNode(typeNode);
await vm.DockWorkspace.WaitForDecompiledTextAsync(System.TimeSpan.FromSeconds(60)); vm.DockWorkspace.SettleSelection();
ReferenceEquals(previousMainTab.SourceNode, typeNode).Should().BeTrue( ReferenceEquals(previousMainTab.SourceNode, typeNode).Should().BeTrue(
"baseline: tree selection populated MainTab with the chosen node"); "baseline: tree selection populated MainTab with the chosen node");
@ -135,7 +135,7 @@ public class PreviewTabPromotionTests
var typeA = vm.AssemblyTreeModel.FindNode<TypeTreeNode>( var typeA = vm.AssemblyTreeModel.FindNode<TypeTreeNode>(
"System.Linq", "System.Linq", "System.Linq.Enumerable"); "System.Linq", "System.Linq", "System.Linq.Enumerable");
vm.AssemblyTreeModel.SelectNode(typeA); vm.AssemblyTreeModel.SelectNode(typeA);
await vm.DockWorkspace.WaitForDecompiledTextAsync(System.TimeSpan.FromSeconds(60)); vm.DockWorkspace.SettleSelection();
var pinnedTab = factory.MainTab!; var pinnedTab = factory.MainTab!;
var pinnedContent = pinnedTab.Content; var pinnedContent = pinnedTab.Content;
@ -150,7 +150,7 @@ public class PreviewTabPromotionTests
var typeB = vm.AssemblyTreeModel.FindNode<TypeTreeNode>( var typeB = vm.AssemblyTreeModel.FindNode<TypeTreeNode>(
"System.Private.Uri", "System", "System.Uri"); "System.Private.Uri", "System", "System.Uri");
vm.AssemblyTreeModel.SelectNode(typeB); vm.AssemblyTreeModel.SelectNode(typeB);
await vm.DockWorkspace.WaitForDecompiledTextAsync(System.TimeSpan.FromSeconds(60)); vm.DockWorkspace.SettleSelection();
// New tab spawned beside the pinned one. // New tab spawned beside the pinned one.
vm.DockWorkspace.Documents!.VisibleDockables!.Count.Should().Be(tabCountBeforeSelection + 1, vm.DockWorkspace.Documents!.VisibleDockables!.Count.Should().Be(tabCountBeforeSelection + 1,
@ -595,7 +595,7 @@ public class PreviewTabPromotionTests
var typeB = vm.AssemblyTreeModel.FindNode<TypeTreeNode>( var typeB = vm.AssemblyTreeModel.FindNode<TypeTreeNode>(
"System.Private.Uri", "System", "System.Uri"); "System.Private.Uri", "System", "System.Uri");
vm.AssemblyTreeModel.SelectNode(typeB); vm.AssemblyTreeModel.SelectNode(typeB);
await vm.DockWorkspace.WaitForDecompiledTextAsync(System.TimeSpan.FromSeconds(60)); vm.DockWorkspace.SettleSelection();
vm.DockWorkspace.Documents!.VisibleDockables!.Count.Should().Be(tabCountBefore + 1, vm.DockWorkspace.Documents!.VisibleDockables!.Count.Should().Be(tabCountBefore + 1,
"selecting a tree node while a frozen tab is active must spawn a new preview tab"); "selecting a tree node while a frozen tab is active must spawn a new preview tab");

11
ILSpy/Docking/DockWorkspace.cs

@ -1076,6 +1076,17 @@ namespace ILSpy.Docking
/// a fresh preview tab inside <see cref="ShowSelectedNode"/>. Re-clicking the same /// a fresh preview tab inside <see cref="ShowSelectedNode"/>. Re-clicking the same
/// node after pin is a no-op (the dedupe activates the pinned tab). /// node after pin is a no-op (the dedupe activates the pinned tab).
/// </summary> /// </summary>
/// <summary>
/// Pump dispatcher jobs so synchronously-set selection state (SourceNode, IsPreview,
/// tab count, Content reference) finishes propagating, without awaiting the
/// fire-and-forget DecompileAsync. Tests that assert on dock structure can use this
/// instead of WaitForDecompiledTextAsync to avoid the multi-second decompile wait.
/// </summary>
public void SettleSelection()
{
Avalonia.Threading.Dispatcher.UIThread.RunJobs();
}
public void PinCurrentTab() public void PinCurrentTab()
{ {
if (factory.PinCurrentMainTab() is null) if (factory.PinCurrentMainTab() is null)

Loading…
Cancel
Save