Skip to content

Commit d84e68c

Browse files
Probe Microsoft.PowerShell.Archive in getModule E2E test
Merging #2328 un-skipped the Windows PowerShell E2E suite, which surfaced a pre-existing host gap in `CanSendGetModuleRequestAsync`: it probed `Microsoft.PowerShell.Management`, but Windows PowerShell's in-box core modules are snap-in based and are not returned by `Get-Module -ListAvailable`. The handler correctly resolved nothing, so `Assert.NotNull` failed on the Windows PowerShell leg while passing on PowerShell 7 (where the core modules ship as files). Probe `Microsoft.PowerShell.Archive` instead: it is a file-based module present in the module path on both Windows PowerShell and PowerShell 7+, so the test exercises the handler on every host without skipping or loosening any assertion. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent eca10bf commit d84e68c

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,18 +1306,25 @@ 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+.
1314+
const string moduleName = "Microsoft.PowerShell.Archive";
1315+
13091316
PSModuleMessage module =
13101317
await PsesLanguageClient
13111318
.SendRequest(
13121319
"powerShell/getModule",
13131320
new GetModuleParams
13141321
{
1315-
Name = "Microsoft.PowerShell.Management"
1322+
Name = moduleName
13161323
})
13171324
.Returning<PSModuleMessage>(CancellationToken.None);
13181325

13191326
Assert.NotNull(module);
1320-
Assert.Equal("Microsoft.PowerShell.Management", module.Name);
1327+
Assert.Equal(moduleName, module.Name);
13211328
Assert.NotEmpty(module.Version);
13221329
Assert.NotEmpty(module.Path);
13231330

@@ -1329,7 +1336,7 @@ await PsesLanguageClient
13291336
"powerShell/getModule",
13301337
new GetModuleParams
13311338
{
1332-
Name = "Microsoft.PowerShell.Management",
1339+
Name = moduleName,
13331340
Version = module.Version
13341341
})
13351342
.Returning<PSModuleMessage>(CancellationToken.None);

0 commit comments

Comments
 (0)