Skip to content

Commit 7ecdd5a

Browse files
committed
Use native methods for flaky test
1 parent eebe650 commit 7ecdd5a

6 files changed

+62
-36
lines changed

test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs

+35-31
Original file line numberDiff line numberDiff line change
@@ -1030,12 +1030,19 @@ await PsesLanguageClient
10301030
});
10311031
}
10321032

1033-
[SkippableFact]
1033+
[Fact]
10341034
public async Task CanSendCompletionAndCompletionResolveRequestAsync()
10351035
{
1036-
Skip.If(IsLinux, "This depends on the help system, which is flaky on Linux.");
1037-
Skip.If(PsesStdioLanguageServerProcessHost.IsWindowsPowerShell, "This help system isn't updated in CI.");
1038-
string filePath = NewTestFile("Write-H");
1036+
await PsesLanguageClient
1037+
.SendRequest(
1038+
"evaluate",
1039+
new EvaluateRequestArguments
1040+
{
1041+
Expression = $"Update-Help Microsoft.Powershell.Utility -SourcePath {s_binDir};"
1042+
})
1043+
.ReturningVoid(CancellationToken.None);
1044+
1045+
string filePath = NewTestFile("Get-Date");
10391046

10401047
CompletionList completionItems = await PsesLanguageClient.TextDocument.RequestCompletion(
10411048
new CompletionParams
@@ -1048,28 +1055,28 @@ public async Task CanSendCompletionAndCompletionResolveRequestAsync()
10481055
});
10491056

10501057
CompletionItem completionItem = Assert.Single(completionItems,
1051-
completionItem1 => completionItem1.FilterText == "Write-Host");
1058+
completionItem1 => completionItem1.FilterText == "Get-Date");
10521059

10531060
CompletionItem updatedCompletionItem = await PsesLanguageClient
10541061
.SendRequest("completionItem/resolve", completionItem)
10551062
.Returning<CompletionItem>(CancellationToken.None);
10561063

1057-
Assert.Contains("Writes customized output to a host", updatedCompletionItem.Documentation.String);
1064+
Assert.Contains("Gets the current date and time.", updatedCompletionItem.Documentation.String);
10581065
}
10591066

1060-
[SkippableFact(Skip = "Completion for Expand-SlowArchive is flaky.")]
1067+
[Fact]
10611068
public async Task CanSendCompletionResolveWithModulePrefixRequestAsync()
10621069
{
10631070
await PsesLanguageClient
10641071
.SendRequest(
10651072
"evaluate",
10661073
new EvaluateRequestArguments
10671074
{
1068-
Expression = "Import-Module Microsoft.PowerShell.Archive -Prefix Slow"
1075+
Expression = $"Update-Help Microsoft.Powershell.Utility -SourcePath {s_binDir};Import-Module Microsoft.PowerShell.Utility -Prefix Test -Force"
10691076
})
10701077
.ReturningVoid(CancellationToken.None);
10711078

1072-
string filePath = NewTestFile("Expand-SlowArch");
1079+
string filePath = NewTestFile("Get-TestDate");
10731080

10741081
CompletionList completionItems = await PsesLanguageClient.TextDocument.RequestCompletion(
10751082
new CompletionParams
@@ -1078,17 +1085,15 @@ await PsesLanguageClient
10781085
{
10791086
Uri = DocumentUri.FromFileSystemPath(filePath)
10801087
},
1081-
Position = new Position(line: 0, character: 15)
1088+
Position = new Position(line: 0, character: 12)
10821089
});
10831090

10841091
CompletionItem completionItem = Assert.Single(completionItems,
1085-
completionItem1 => completionItem1.Label == "Expand-SlowArchive");
1092+
completionItem1 => completionItem1.Label == "Get-TestDate");
10861093

1087-
CompletionItem updatedCompletionItem = await PsesLanguageClient
1088-
.SendRequest("completionItem/resolve", completionItem)
1089-
.Returning<CompletionItem>(CancellationToken.None);
1094+
CompletionItem updatedCompletionItem = await PsesLanguageClient.ResolveCompletion(completionItem);
10901095

1091-
Assert.Contains("Extracts files from a specified archive", updatedCompletionItem.Documentation.String);
1096+
Assert.Contains("Gets the current date and time.", updatedCompletionItem.Documentation.String);
10921097
}
10931098

10941099
[SkippableFact]
@@ -1123,22 +1128,21 @@ public async Task CanSendSignatureHelpRequestAsync()
11231128
{
11241129
string filePath = NewTestFile("Get-Date -");
11251130

1126-
SignatureHelp signatureHelp = await PsesLanguageClient
1127-
.SendRequest(
1128-
"textDocument/signatureHelp",
1129-
new SignatureHelpParams
1131+
SignatureHelp signatureHelp = await PsesLanguageClient.RequestSignatureHelp
1132+
(
1133+
new SignatureHelpParams
1134+
{
1135+
TextDocument = new TextDocumentIdentifier
11301136
{
1131-
TextDocument = new TextDocumentIdentifier
1132-
{
1133-
Uri = new Uri(filePath)
1134-
},
1135-
Position = new Position
1136-
{
1137-
Line = 0,
1138-
Character = 10
1139-
}
1140-
})
1141-
.Returning<SignatureHelp>(CancellationToken.None);
1137+
Uri = new Uri(filePath)
1138+
},
1139+
Position = new Position
1140+
{
1141+
Line = 0,
1142+
Character = 10
1143+
}
1144+
}
1145+
);
11421146

11431147
Assert.Contains("Get-Date", signatureHelp.Signatures.First().Label);
11441148
}
@@ -1231,7 +1235,7 @@ await PsesLanguageClient
12311235
Assert.Equal(0, evaluateResponseBody.VariablesReference);
12321236
}
12331237

1234-
[Fact]
1238+
[Fact(Timeout = 60000)]
12351239
public async Task CanSendGetCommandRequestAsync()
12361240
{
12371241
List<object> pSCommandMessages =

test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), PowerShellEditorServices.Common.props))\PowerShellEditorServices.Common.props" />
2+
<Import
3+
Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), PowerShellEditorServices.Common.props))\PowerShellEditorServices.Common.props" />
34

45
<PropertyGroup>
56
<TargetFrameworks>net8.0</TargetFrameworks>
@@ -18,8 +19,10 @@
1819
<Choose>
1920
<When Condition=" '$(LocalOmniSharp)' == 'true' ">
2021
<ItemGroup>
21-
<ProjectReference Include="..\..\..\csharp-language-server-protocol\src\Client\Client.csproj" />
22-
<ProjectReference Include="..\..\..\csharp-language-server-protocol\src\Dap.Client\Dap.client.csproj" />
22+
<ProjectReference
23+
Include="..\..\..\csharp-language-server-protocol\src\Client\Client.csproj" />
24+
<ProjectReference
25+
Include="..\..\..\csharp-language-server-protocol\src\Dap.Client\Dap.client.csproj" />
2326
</ItemGroup>
2427
</When>
2528
<Otherwise>
@@ -37,4 +40,11 @@
3740
<ItemGroup>
3841
<Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
3942
</ItemGroup>
43+
44+
<ItemGroup>
45+
<!-- Used for Update-Help for some test fixtures -->
46+
<Content Include="..\PowerShellEditorServices.Test.Shared\PSHelp\**\*"
47+
CopyToOutputDirectory="PreserveNewest" />
48+
</ItemGroup>
49+
4050
</Project>

test/PowerShellEditorServices.Test.E2E/xunit.runner.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
33
"appDomain": "denied",
44
"parallelizeTestCollections": true,
5-
"parallelAlgorithm": "aggressive",
5+
"parallelAlgorithm": "conservative",
66
"methodDisplay": "method",
77
"diagnosticMessages": true,
8-
"longRunningTestSeconds": 60
8+
"longRunningTestSeconds": 10,
9+
"showLiveOutput": true
910
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<HelpInfo xmlns="http://schemas.microsoft.com/powershell/help/2010/05">
3+
<HelpContentURI>https://aka.ms/powershell51-help</HelpContentURI>
4+
<SupportedUICultures>
5+
<UICulture>
6+
<UICultureName>en-US</UICultureName>
7+
<UICultureVersion>5.2.0.0</UICultureVersion>
8+
</UICulture>
9+
</SupportedUICultures>
10+
</HelpInfo>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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.

0 commit comments

Comments
 (0)