diff --git a/test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs b/test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs index 02767023c..91704bd84 100644 --- a/test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs +++ b/test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs @@ -1030,12 +1030,19 @@ await PsesLanguageClient }); } - [SkippableFact] + [Fact] public async Task CanSendCompletionAndCompletionResolveRequestAsync() { - Skip.If(IsLinux, "This depends on the help system, which is flaky on Linux."); - Skip.If(PsesStdioLanguageServerProcessHost.IsWindowsPowerShell, "This help system isn't updated in CI."); - string filePath = NewTestFile("Write-H"); + await PsesLanguageClient + .SendRequest( + "evaluate", + new EvaluateRequestArguments + { + Expression = $"Update-Help Microsoft.Powershell.Utility -SourcePath {s_binDir};" + }) + .ReturningVoid(CancellationToken.None); + + string filePath = NewTestFile("Get-Date"); CompletionList completionItems = await PsesLanguageClient.TextDocument.RequestCompletion( new CompletionParams @@ -1048,16 +1055,16 @@ public async Task CanSendCompletionAndCompletionResolveRequestAsync() }); CompletionItem completionItem = Assert.Single(completionItems, - completionItem1 => completionItem1.FilterText == "Write-Host"); + completionItem1 => completionItem1.FilterText == "Get-Date"); CompletionItem updatedCompletionItem = await PsesLanguageClient .SendRequest("completionItem/resolve", completionItem) .Returning(CancellationToken.None); - Assert.Contains("Writes customized output to a host", updatedCompletionItem.Documentation.String); + Assert.Contains("Gets the current date and time.", updatedCompletionItem.Documentation.String); } - [SkippableFact(Skip = "Completion for Expand-SlowArchive is flaky.")] + [Fact] public async Task CanSendCompletionResolveWithModulePrefixRequestAsync() { await PsesLanguageClient @@ -1065,11 +1072,11 @@ await PsesLanguageClient "evaluate", new EvaluateRequestArguments { - Expression = "Import-Module Microsoft.PowerShell.Archive -Prefix Slow" + Expression = $"Update-Help Microsoft.Powershell.Utility -SourcePath {s_binDir};Import-Module Microsoft.PowerShell.Utility -Prefix Test -Force" }) .ReturningVoid(CancellationToken.None); - string filePath = NewTestFile("Expand-SlowArch"); + string filePath = NewTestFile("Get-TestDate"); CompletionList completionItems = await PsesLanguageClient.TextDocument.RequestCompletion( new CompletionParams @@ -1078,17 +1085,15 @@ await PsesLanguageClient { Uri = DocumentUri.FromFileSystemPath(filePath) }, - Position = new Position(line: 0, character: 15) + Position = new Position(line: 0, character: 12) }); CompletionItem completionItem = Assert.Single(completionItems, - completionItem1 => completionItem1.Label == "Expand-SlowArchive"); + completionItem1 => completionItem1.Label == "Get-TestDate"); - CompletionItem updatedCompletionItem = await PsesLanguageClient - .SendRequest("completionItem/resolve", completionItem) - .Returning(CancellationToken.None); + CompletionItem updatedCompletionItem = await PsesLanguageClient.ResolveCompletion(completionItem); - Assert.Contains("Extracts files from a specified archive", updatedCompletionItem.Documentation.String); + Assert.Contains("Gets the current date and time.", updatedCompletionItem.Documentation.String); } [SkippableFact] @@ -1123,22 +1128,21 @@ public async Task CanSendSignatureHelpRequestAsync() { string filePath = NewTestFile("Get-Date -"); - SignatureHelp signatureHelp = await PsesLanguageClient - .SendRequest( - "textDocument/signatureHelp", - new SignatureHelpParams + SignatureHelp signatureHelp = await PsesLanguageClient.RequestSignatureHelp + ( + new SignatureHelpParams + { + TextDocument = new TextDocumentIdentifier { - TextDocument = new TextDocumentIdentifier - { - Uri = new Uri(filePath) - }, - Position = new Position - { - Line = 0, - Character = 10 - } - }) - .Returning(CancellationToken.None); + Uri = new Uri(filePath) + }, + Position = new Position + { + Line = 0, + Character = 10 + } + } + ); Assert.Contains("Get-Date", signatureHelp.Signatures.First().Label); } @@ -1231,7 +1235,7 @@ await PsesLanguageClient Assert.Equal(0, evaluateResponseBody.VariablesReference); } - [Fact] + [Fact(Timeout = 60000)] public async Task CanSendGetCommandRequestAsync() { List pSCommandMessages = diff --git a/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj b/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj index 2ea39d3fd..3f110f212 100644 --- a/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj +++ b/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj @@ -1,5 +1,6 @@ - + net8.0 @@ -18,8 +19,10 @@ - - + + @@ -37,4 +40,11 @@ + + + + + + diff --git a/test/PowerShellEditorServices.Test.E2E/xunit.runner.json b/test/PowerShellEditorServices.Test.E2E/xunit.runner.json index 09cc13a99..f1c3b37cd 100644 --- a/test/PowerShellEditorServices.Test.E2E/xunit.runner.json +++ b/test/PowerShellEditorServices.Test.E2E/xunit.runner.json @@ -2,8 +2,9 @@ "$schema": "https://xunit.net/schema/current/xunit.runner.schema.json", "appDomain": "denied", "parallelizeTestCollections": true, - "parallelAlgorithm": "aggressive", + "parallelAlgorithm": "conservative", "methodDisplay": "method", "diagnosticMessages": true, - "longRunningTestSeconds": 60 + "longRunningTestSeconds": 10, + "showLiveOutput": true } diff --git a/test/PowerShellEditorServices.Test.Shared/PSHelp/Microsoft.PowerShell.Utility_1da87e53-152b-403e-98dc-74d7b4d63d59_HelpInfo.xml b/test/PowerShellEditorServices.Test.Shared/PSHelp/Microsoft.PowerShell.Utility_1da87e53-152b-403e-98dc-74d7b4d63d59_HelpInfo.xml new file mode 100644 index 000000000..1b6473db8 --- /dev/null +++ b/test/PowerShellEditorServices.Test.Shared/PSHelp/Microsoft.PowerShell.Utility_1da87e53-152b-403e-98dc-74d7b4d63d59_HelpInfo.xml @@ -0,0 +1,10 @@ + + + https://aka.ms/powershell51-help + + + en-US + 5.2.0.0 + + + \ No newline at end of file diff --git a/test/PowerShellEditorServices.Test.Shared/PSHelp/Microsoft.PowerShell.Utility_1da87e53-152b-403e-98dc-74d7b4d63d59_en-US_HelpContent.cab b/test/PowerShellEditorServices.Test.Shared/PSHelp/Microsoft.PowerShell.Utility_1da87e53-152b-403e-98dc-74d7b4d63d59_en-US_HelpContent.cab new file mode 100644 index 000000000..7c4175b2e Binary files /dev/null and b/test/PowerShellEditorServices.Test.Shared/PSHelp/Microsoft.PowerShell.Utility_1da87e53-152b-403e-98dc-74d7b4d63d59_en-US_HelpContent.cab differ diff --git a/test/PowerShellEditorServices.Test.Shared/PSHelp/README b/test/PowerShellEditorServices.Test.Shared/PSHelp/README new file mode 100644 index 000000000..57c3e6007 --- /dev/null +++ b/test/PowerShellEditorServices.Test.Shared/PSHelp/README @@ -0,0 +1 @@ +Windows PowerShell does not have updated help in CI by default and we utilize a private Azure Devops repo for builds that has no internet access. The completion tests validate the Windows Help so we update it offline from here so these tests can work.