Skip to content

Commit 268a1f5

Browse files
Skip attach E2E test at discovery time on Windows PowerShell
CanAttachScriptWithPathMappings wedges during the per-test InitializeAsync (PSES debug-adapter server startup) on in-box Windows PowerShell since the windows-2025-vs2026 runner image refresh, riding the job timeout in CI. The prior in-body Skip.If(IsWindowsPowerShell) never fired because xUnit runs IAsyncLifetime.InitializeAsync before the test body, and that setup is where the hang occurs. Add a SkippableFact subclass that sets Skip in its constructor so xUnit skips the test at discovery time, before it instantiates the class or runs InitializeAsync. The SkippableFact discoverer is retained so the runtime Constrained Language Mode skip still works off-Windows. See #2323. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent bd3aca8 commit 268a1f5

2 files changed

Lines changed: 42 additions & 8 deletions

File tree

test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -630,16 +630,16 @@ public async Task CanLaunchScriptWithNewChildAttachSessionAsJob()
630630
await terminatedTcs.Task;
631631
}
632632

633-
[SkippableFact(Timeout = 15000)]
633+
// NOTE: This passes against PowerShell Core but hangs against in-box Windows
634+
// PowerShell since the windows-2025-vs2026 runner image moved from 20260608 to
635+
// 20260614, where it wedges during server setup and rides the job timeout. The
636+
// skip must happen at discovery time (via the attribute) rather than with an
637+
// in-body Skip.If, because xUnit runs InitializeAsync (which is where the hang
638+
// occurs) before the test body. Skipped on Windows PowerShell pending a real
639+
// fix; see https://github.com/PowerShell/PowerShellEditorServices/issues/2323.
640+
[SkippableFactOnWindowsPowerShell(Timeout = 15000)]
634641
public async Task CanAttachScriptWithPathMappings()
635642
{
636-
// This passes against PowerShell Core but hangs against in-box Windows
637-
// PowerShell since the windows-2025-vs2026 runner image moved from
638-
// 20260608 to 20260614: the cross-process Debug-Runspace attach wedges
639-
// and rides the job timeout. Skipped pending a real fix; see #2323.
640-
Skip.If(PsesStdioLanguageServerProcessHost.IsWindowsPowerShell,
641-
"Attach wedges on Windows PowerShell since the 20260614 runner image; see #2323.");
642-
643643
Skip.If(PsesStdioLanguageServerProcessHost.RunningInConstrainedLanguageMode,
644644
"Breakpoints can't be set in Constrained Language Mode.");
645645

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
using Xunit;
5+
using Xunit.Sdk;
6+
7+
namespace PowerShellEditorServices.Test.E2E;
8+
9+
/// <summary>
10+
/// A <see cref="SkippableFactAttribute"/> that additionally skips the test at
11+
/// <em>discovery</em> time when running under in-box Windows PowerShell.
12+
/// </summary>
13+
/// <remarks>
14+
/// A runtime <see cref="Skip.If(bool, string)"/> in the test body cannot prevent
15+
/// the per-test <c>IAsyncLifetime.InitializeAsync</c> from running first, because
16+
/// xUnit invokes the lifetime setup (which starts the PSES server) before the
17+
/// method body. When the hang occurs during that setup, a body-level skip is never
18+
/// reached. Setting <see cref="FactAttribute.Skip"/> here makes xUnit treat the
19+
/// test as statically skipped, so it never instantiates the test class or runs
20+
/// <c>InitializeAsync</c>. The <see cref="SkippableFactAttribute"/> discoverer is
21+
/// retained so runtime <see cref="Skip"/> calls (e.g. for Constrained Language
22+
/// Mode) still work when the test is not skipped at discovery time.
23+
/// </remarks>
24+
[XunitTestCaseDiscoverer("Xunit.Sdk.SkippableFactDiscoverer", "Xunit.SkippableFact")]
25+
public sealed class SkippableFactOnWindowsPowerShellAttribute : SkippableFactAttribute
26+
{
27+
public SkippableFactOnWindowsPowerShellAttribute()
28+
{
29+
if (PsesStdioLanguageServerProcessHost.IsWindowsPowerShell)
30+
{
31+
Skip = "Attach wedges during setup on Windows PowerShell since the 20260614 runner image; see https://github.com/PowerShell/PowerShellEditorServices/issues/2323.";
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)