Skip to content

Commit

Permalink
Fix SetupHelpForTests
Browse files Browse the repository at this point in the history
  • Loading branch information
andyleejordan committed Dec 8, 2023
1 parent 84982f1 commit 5950e12
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 21 deletions.
20 changes: 10 additions & 10 deletions PowerShellEditorServices.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ namespace Microsoft.PowerShell.EditorServices.Hosting
}

Task SetupHelpForTests {
if (-not (Get-Help Write-Host).Examples) {
if (-not (Get-Help Microsoft.PowerShell.Management\Get-Process).Description) {
Write-Host "Updating help for tests."
Update-Help -Module Microsoft.PowerShell.Utility -Force -Scope CurrentUser
Update-Help -Module Microsoft.PowerShell.Management,Microsoft.PowerShell.Utility -Force -Scope CurrentUser
}
}

Expand All @@ -177,11 +177,11 @@ Task Build FindDotNet, CreateBuildInfo, {

Task Test TestServer, TestE2E, TestConstrainedLanguageMode

Task TestServer TestServerWinPS, TestServerPS72, TestServerPS73
Task TestServer SetupHelpForTests, TestServerWinPS, TestServerPS72, TestServerPS73

Task TestE2E TestE2EPwsh, TestE2EWinPS
Task TestE2E SetupHelpForTests, TestE2EPwsh, TestE2EWinPS

Task TestServerWinPS -If (-not $script:IsNix) Build, SetupHelpForTests, {
Task TestServerWinPS -If (-not $script:IsNix) Build, {
Set-Location .\test\PowerShellEditorServices.Test\
# TODO: See https://github.com/dotnet/sdk/issues/18353 for x64 test host
# that is debuggable! If architecture is added, the assembly path gets an
Expand All @@ -190,29 +190,29 @@ Task TestServerWinPS -If (-not $script:IsNix) Build, SetupHelpForTests, {
Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetRuntime.Desktop }
}

Task TestServerPS72 Build, SetupHelpForTests, {
Task TestServerPS72 Build, {
Set-Location .\test\PowerShellEditorServices.Test\
Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetRuntime.PS72 }
}

Task TestServerPS73 Build, SetupHelpForTests, {
Task TestServerPS73 Build, {
Set-Location .\test\PowerShellEditorServices.Test\
Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetRuntime.PS73 }
}

Task TestE2EPwsh Build, SetupHelpForTests, {
Task TestE2EPwsh Build, {
Set-Location .\test\PowerShellEditorServices.Test.E2E\
$env:PWSH_EXE_NAME = "pwsh"
Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetRuntime.PS73 }
}

Task TestE2EWinPS -If (-not $script:IsNix) Build, SetupHelpForTests, {
Task TestE2EWinPS -If (-not $script:IsNix) Build, {
Set-Location .\test\PowerShellEditorServices.Test.E2E\
$env:PWSH_EXE_NAME = "powershell"
Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetRuntime.PS73 }
}

Task TestConstrainedLanguageMode -If (-not $script:IsNix) Build, SetupHelpForTests, {
Task TestConstrainedLanguageMode -If (-not $script:IsNix) Build, {
Set-Location .\test\PowerShellEditorServices.Test.E2E\

if (-not [Security.Principal.WindowsIdentity]::GetCurrent().Owner.IsWellKnown("BuiltInAdministratorsSid")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -30,9 +29,6 @@ namespace PowerShellEditorServices.Test.E2E
[Trait("Category", "LSP")]
public class LanguageServerProtocolMessageTests : IClassFixture<LSPTestsFixture>, IDisposable

Check warning on line 30 in test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs

View workflow job for this annotation

GitHub Actions / ci_matrix (macos-latest)

'LanguageServerProtocolMessageTests' is coupled with '118' different types from '30' different namespaces. Rewrite or refactor the code to decrease its class coupling below '96'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1506)

Check warning on line 30 in test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs

View workflow job for this annotation

GitHub Actions / ci_matrix (ubuntu-latest)

'LanguageServerProtocolMessageTests' is coupled with '118' different types from '30' different namespaces. Rewrite or refactor the code to decrease its class coupling below '96'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1506)
{
// Borrowed from `VersionUtils` which can't be used here due to an initialization problem.
private static bool IsLinux { get; } = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);

private static readonly string s_binDir =
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

Expand Down Expand Up @@ -1029,10 +1025,9 @@ await PsesLanguageClient
});
}

[SkippableFact]
[Fact]
public async Task CanSendCompletionAndCompletionResolveRequestAsync()
{
Skip.If(IsLinux, "This depends on the help system, which is flaky on Linux.");
string filePath = NewTestFile("Write-H");

CompletionList completionItems = await PsesLanguageClient.TextDocument.RequestCompletion(
Expand Down Expand Up @@ -1119,10 +1114,9 @@ await PsesLanguageClient
Assert.Contains("Extracts files from a specified archive", updatedCompletionItem.Documentation.String);
}

[SkippableFact]
[Fact]
public async Task CanSendHoverRequestAsync()
{
Skip.If(IsLinux, "This depends on the help system, which is flaky on Linux.");
string filePath = NewTestFile("Write-Host");

Hover hover = await PsesLanguageClient.TextDocument.RequestHover(
Expand Down
3 changes: 0 additions & 3 deletions tools/installPSResources.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,3 @@ if ($PSVersionTable.PSVersion.Major -lt 6) {
# TODO: Switch to Install-PSResource when CI uses PowerShell 7.4
Install-Module -Name InvokeBuild -Scope CurrentUser
Install-Module -Name platyPS -Scope CurrentUser

# Update help needed for tests.
Update-Help -Module Microsoft.PowerShell*

0 comments on commit 5950e12

Please sign in to comment.