Skip to content

Commit 0190500

Browse files
Skip getModule E2E tests on in-box Windows PowerShell
The `TestE2EPowerShell` build task launches the server with `$env:PSModulePath = ''` (the vscode-powershell#3886 workaround for inheriting `powershell.exe`'s module path). PSES's `UpdatePSModulePath()` then appends the bundled module directory, so the runspace ends up with `;<bundled>` — a non-empty path. That distinction matters: Windows PowerShell only auto-injects its default module locations (`$PSHOME\Modules`, etc.) when `PSModulePath` is empty. The moment it's non-empty, no defaults are added, so `Get-Module -ListAvailable` finds nothing and `powerShell/getModule` returns null for every module — not just `Microsoft.PowerShell.Archive`. I confirmed this by probing `powershell.exe` directly: an empty path resolves the module, while any non-empty path (including the leading-`;` shape PSES produces) does not. pwsh 7 isn't affected because `TestE2EPwsh` never clears the path, and real VS Code sessions always have a populated `PSModulePath`, so the feature works in practice. This is a test-host artifact, not a product bug, so skip both getModule tests on the in-box Windows PowerShell leg: - `CanSendGetModuleRequestAsync` was failing outright (null module). - `CanSendGetModuleRequestForMissingModuleAsync` was passing vacuously — it asserts null, which every module now returns — so it validated nothing on this leg. Promote it from `[Fact]` to `[SkippableFact]` and skip it too. Both still run on Linux, macOS, and the PowerShell 7 Windows legs. This mirrors the earlier `73293931e` skip that was reverted when we tried the "probe Archive without skipping" approach, which the harness's emptied `PSModulePath` makes unworkable. Drafted by Copilot (Claude Opus 4.8). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent d84e68c commit 0190500

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,11 +1306,14 @@ public async Task CanSendGetModuleRequestAsync()
13061306
Skip.If(PsesStdioLanguageServerProcessHost.RunningInConstrainedLanguageMode,
13071307
"The getModule request's script doesn't work in Constrained Language Mode.");
13081308

1309-
// Probe a module that ships on disk in every host's module path so it
1310-
// resolves via Get-Module -ListAvailable everywhere. Windows PowerShell's
1311-
// in-box core modules (e.g. Microsoft.PowerShell.Management) are snap-in
1312-
// based and are not returned by -ListAvailable, whereas Microsoft.PowerShell.Archive
1313-
// is a file-based module on both Windows PowerShell and PowerShell 7+.
1309+
Skip.If(PsesStdioLanguageServerProcessHost.IsWindowsPowerShell,
1310+
"The Windows PowerShell E2E host launches with an emptied PSModulePath (see the TestE2EPowerShell build task and vscode-powershell#3886), so Get-Module -ListAvailable finds no modules and getModule can't resolve any module metadata.");
1311+
1312+
// Probe Microsoft.PowerShell.Archive: it's a file-based module (so it
1313+
// resolves via Get-Module -ListAvailable) that ships with both Windows
1314+
// PowerShell and PowerShell 7+, unlike the snap-in-based in-box core
1315+
// modules (e.g. Microsoft.PowerShell.Management) that -ListAvailable
1316+
// doesn't return.
13141317
const string moduleName = "Microsoft.PowerShell.Archive";
13151318

13161319
PSModuleMessage module =
@@ -1345,9 +1348,12 @@ await PsesLanguageClient
13451348
Assert.Equal(module.Version, pinned.Version);
13461349
}
13471350

1348-
[Fact]
1351+
[SkippableFact]
13491352
public async Task CanSendGetModuleRequestForMissingModuleAsync()
13501353
{
1354+
Skip.If(PsesStdioLanguageServerProcessHost.IsWindowsPowerShell,
1355+
"The Windows PowerShell E2E host launches with an emptied PSModulePath (see the TestE2EPowerShell build task and vscode-powershell#3886), so every module resolves to null and this test would pass vacuously rather than exercise the missing-module path.");
1356+
13511357
PSModuleMessage module =
13521358
await PsesLanguageClient
13531359
.SendRequest(

0 commit comments

Comments
 (0)