-
Notifications
You must be signed in to change notification settings - Fork 235
Move tests to PS7 and PS7.1 and fix IsNetCore check #1318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e2a1bb1
d20d860
424c7f0
71aab29
302d603
257d0e4
052b89f
00678bb
2762146
f2c11b2
f1e005f
0f69723
9459f72
7f359cc
e51395a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,18 +19,19 @@ param( | |
#Requires -Modules @{ModuleName="InvokeBuild";ModuleVersion="3.2.1"} | ||
|
||
$script:IsUnix = $PSVersionTable.PSEdition -and $PSVersionTable.PSEdition -eq "Core" -and !$IsWindows | ||
$script:RequiredSdkVersion = (Get-Content (Join-Path $PSScriptRoot 'global.json') | ConvertFrom-Json).sdk.version | ||
$script:BuildInfoPath = [System.IO.Path]::Combine($PSScriptRoot, "src", "PowerShellEditorServices.Hosting", "BuildInfo.cs") | ||
$script:PsesCommonProps = [xml](Get-Content -Raw "$PSScriptRoot/PowerShellEditorServices.Common.props") | ||
$script:IsPreview = [bool]($script:PsesCommonProps.Project.PropertyGroup.VersionSuffix) | ||
|
||
$script:NetRuntime = @{ | ||
Core = 'netcoreapp2.1' | ||
PS62 = 'netcoreapp2.1' | ||
PS7 = 'netcoreapp3.1' | ||
PS71 = 'net5.0' | ||
Desktop = 'net461' | ||
Standard = 'netstandard2.0' | ||
} | ||
|
||
$script:HostCoreOutput = "$PSScriptRoot/src/PowerShellEditorServices.Hosting/bin/$Configuration/$($script:NetRuntime.Core)/publish" | ||
$script:HostCoreOutput = "$PSScriptRoot/src/PowerShellEditorServices.Hosting/bin/$Configuration/$($script:NetRuntime.PS62)/publish" | ||
$script:HostDeskOutput = "$PSScriptRoot/src/PowerShellEditorServices.Hosting/bin/$Configuration/$($script:NetRuntime.Desktop)/publish" | ||
$script:PsesOutput = "$PSScriptRoot/src/PowerShellEditorServices/bin/$Configuration/$($script:NetRuntime.Standard)/publish" | ||
$script:VSCodeOutput = "$PSScriptRoot/src/PowerShellEditorServices.VSCode/bin/$Configuration/$($script:NetRuntime.Standard)/publish" | ||
|
@@ -52,64 +53,45 @@ function Invoke-WithCreateDefaultHook { | |
} | ||
} | ||
|
||
task SetupDotNet -Before Clean, Build, TestHost, TestServer, TestE2E { | ||
function Install-Dotnet { | ||
param ( | ||
$Channel | ||
) | ||
|
||
$dotnetPath = "$PSScriptRoot/.dotnet" | ||
$dotnetExePath = if ($script:IsUnix) { "$dotnetPath/dotnet" } else { "$dotnetPath/dotnet.exe" } | ||
$originalDotNetExePath = $dotnetExePath | ||
Write-Host "`n### Installing .NET CLI $Version...`n" -ForegroundColor Green | ||
|
||
if (!(Test-Path $dotnetExePath)) { | ||
$installedDotnet = Get-Command dotnet -ErrorAction Ignore | ||
if ($installedDotnet) { | ||
$dotnetExePath = $installedDotnet.Source | ||
} | ||
else { | ||
$dotnetExePath = $null | ||
} | ||
} | ||
# The install script is platform-specific | ||
$installScriptExt = if ($script:IsUnix) { "sh" } else { "ps1" } | ||
|
||
# Make sure the dotnet we found is the right version | ||
if ($dotnetExePath) { | ||
# dotnet --version can write to stderr, which causes builds to abort, therefore use --list-sdks instead. | ||
if ((& $dotnetExePath --list-sdks | ForEach-Object { $_.Split()[0] } ) -contains $script:RequiredSdkVersion) { | ||
$script:dotnetExe = $dotnetExePath | ||
} | ||
else { | ||
# Clear the path so that we invoke installation | ||
$script:dotnetExe = $null | ||
} | ||
} | ||
else { | ||
# Clear the path so that we invoke installation | ||
$script:dotnetExe = $null | ||
} | ||
# Download the official installation script and run it | ||
$installScriptPath = "$([System.IO.Path]::GetTempPath())dotnet-install.$installScriptExt" | ||
Invoke-WebRequest "https://dot.net/v1/dotnet-install.$installScriptExt" -OutFile $installScriptPath | ||
$env:DOTNET_INSTALL_DIR = "$PSScriptRoot/.dotnet" | ||
|
||
if ($script:dotnetExe -eq $null) { | ||
if ($script:IsUnix) { | ||
chmod +x $installScriptPath | ||
} | ||
|
||
Write-Host "`n### Installing .NET CLI $script:RequiredSdkVersion...`n" -ForegroundColor Green | ||
$paramArr = @('-Channel', $Channel, '-InstallDir', "'$env:DOTNET_INSTALL_DIR'", '-NoPath') | ||
Invoke-Expression "$installScriptPath $paramArr" | ||
$env:PATH = $env:DOTNET_INSTALL_DIR + [System.IO.Path]::PathSeparator + $env:PATH | ||
|
||
# The install script is platform-specific | ||
$installScriptExt = if ($script:IsUnix) { "sh" } else { "ps1" } | ||
Write-Host "`n### Installation complete." -ForegroundColor Green | ||
} | ||
|
||
# Download the official installation script and run it | ||
$installScriptPath = "$([System.IO.Path]::GetTempPath())dotnet-install.$installScriptExt" | ||
Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/sdk/master/scripts/obtain/dotnet-install.$installScriptExt" -OutFile $installScriptPath | ||
$env:DOTNET_INSTALL_DIR = "$PSScriptRoot/.dotnet" | ||
task SetupDotNet -Before Clean, Build, TestHost, TestServerWinPS, TestServerPS7, TestServerPS71, TestE2E { | ||
|
||
if (!$script:IsUnix) { | ||
& $installScriptPath -Version $script:RequiredSdkVersion -InstallDir "$env:DOTNET_INSTALL_DIR" | ||
} | ||
else { | ||
& /bin/bash $installScriptPath -Version $script:RequiredSdkVersion -InstallDir "$env:DOTNET_INSTALL_DIR" | ||
$env:PATH = $dotnetExeDir + [System.IO.Path]::PathSeparator + $env:PATH | ||
} | ||
$dotnetPath = "$PSScriptRoot/.dotnet" | ||
$dotnetExePath = if ($script:IsUnix) { "$dotnetPath/dotnet" } else { "$dotnetPath/dotnet.exe" } | ||
|
||
Write-Host "`n### Installation complete." -ForegroundColor Green | ||
$script:dotnetExe = $originalDotnetExePath | ||
if (!(Test-Path $dotnetExePath)) { | ||
Install-Dotnet -Channel '2.1' | ||
Install-Dotnet -Channel '3.1' | ||
Install-Dotnet -Channel 'release/5.0.1xx-preview6' | ||
} | ||
|
||
# This variable is used internally by 'dotnet' to know where it's installed | ||
$script:dotnetExe = Resolve-Path $script:dotnetExe | ||
$script:dotnetExe = Resolve-Path $dotnetExePath | ||
if (!$env:DOTNET_INSTALL_DIR) | ||
{ | ||
$dotnetExeDir = [System.IO.Path]::GetDirectoryName($script:dotnetExe) | ||
|
@@ -228,7 +210,7 @@ task SetupHelpForTests -Before Test { | |
|
||
task Build BinClean,{ | ||
exec { & $script:dotnetExe publish -c $Configuration .\src\PowerShellEditorServices\PowerShellEditorServices.csproj -f $script:NetRuntime.Standard } | ||
exec { & $script:dotnetExe publish -c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.Core } | ||
exec { & $script:dotnetExe publish -c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.PS62 } | ||
if (-not $script:IsUnix) | ||
{ | ||
exec { & $script:dotnetExe publish -c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.Desktop } | ||
|
@@ -245,15 +227,24 @@ function DotNetTestFilter { | |
|
||
task Test TestServer,TestE2E | ||
|
||
task TestServer { | ||
task TestServer TestServerWinPS,TestServerPS7,TestServerPS71 | ||
|
||
task TestServerWinPS -If (-not $script:IsUnix) { | ||
Set-Location .\test\PowerShellEditorServices.Test\ | ||
exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.Desktop (DotNetTestFilter) } | ||
} | ||
|
||
if (-not $script:IsUnix) { | ||
exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.Desktop (DotNetTestFilter) } | ||
task TestServerPS7 { | ||
Set-Location .\test\PowerShellEditorServices.Test\ | ||
Invoke-WithCreateDefaultHook -NewModulePath $script:PSCoreModulePath { | ||
exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS7 (DotNetTestFilter) } | ||
} | ||
} | ||
|
||
task TestServerPS71 { | ||
Set-Location .\test\PowerShellEditorServices.Test\ | ||
Invoke-WithCreateDefaultHook -NewModulePath $script:PSCoreModulePath { | ||
exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.Core (DotNetTestFilter) } | ||
exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS71 (DotNetTestFilter) } | ||
} | ||
} | ||
|
||
|
@@ -265,21 +256,21 @@ task TestHost { | |
exec { & $script:dotnetExe test -f $script:NetRuntime.Desktop (DotNetTestFilter) } | ||
} | ||
|
||
exec { & $script:dotnetExe build -c $Configuration -f $script:NetRuntime.Core } | ||
exec { & $script:dotnetExe test -f $script:NetRuntime.Core (DotNetTestFilter) } | ||
exec { & $script:dotnetExe build -c $Configuration -f $script:NetRuntime.PS62 } | ||
exec { & $script:dotnetExe test -f $script:NetRuntime.PS62 (DotNetTestFilter) } | ||
} | ||
|
||
task TestE2E { | ||
Set-Location .\test\PowerShellEditorServices.Test.E2E\ | ||
|
||
$env:PWSH_EXE_NAME = if ($IsCoreCLR) { "pwsh" } else { "powershell" } | ||
exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.Core (DotNetTestFilter) } | ||
exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS62 (DotNetTestFilter) } | ||
|
||
# Run E2E tests in ConstrainedLanguage mode. | ||
if (!$script:IsUnix) { | ||
try { | ||
[System.Environment]::SetEnvironmentVariable("__PSLockdownPolicy", "0x80000007", [System.EnvironmentVariableTarget]::Machine); | ||
exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.Core (DotNetTestFilter) } | ||
exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS62 (DotNetTestFilter) } | ||
} finally { | ||
[System.Environment]::SetEnvironmentVariable("__PSLockdownPolicy", $null, [System.EnvironmentVariableTarget]::Machine); | ||
} | ||
|
@@ -303,10 +294,6 @@ task LayoutModule -After Build { | |
# Copy Third Party Notices.txt to module folder | ||
Copy-Item -Force -Path "$PSScriptRoot\Third Party Notices.txt" -Destination $psesOutputPath | ||
|
||
# Copy UnixConsoleEcho native libraries | ||
Copy-Item -Path "$script:PsesOutput/runtimes/osx-64/native/*" -Destination $psesDepsPath -Force | ||
Copy-Item -Path "$script:PsesOutput/runtimes/linux-64/native/*" -Destination $psesDepsPath -Force | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this doesn't seem to be needed anymore... which is kinda odd to me... but moving to a newer SDK seems to not generate these folders anymore. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've had errors about those folders being missing since they were added tbh. I assumed they were important to CI but I've just been commenting them out. If the |
||
|
||
# Assemble PSES module | ||
|
||
$includedDlls = [System.Collections.Generic.HashSet[string]]::new() | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,9 +78,18 @@ await this.GetCompletionResults( | |
CompleteCommandFromModule.SourceDetails); | ||
|
||
Assert.NotEmpty(completionResults.Completions); | ||
|
||
Assert.Equal( | ||
CompleteCommandFromModule.ExpectedCompletion, | ||
completionResults.Completions[0]); | ||
CompleteCommandFromModule.ExpectedCompletion.CompletionText, | ||
completionResults.Completions[0].CompletionText | ||
); | ||
|
||
Assert.Equal( | ||
CompleteCommandFromModule.ExpectedCompletion.CompletionType, | ||
completionResults.Completions[0].CompletionType | ||
); | ||
|
||
Assert.NotNull(completionResults.Completions[0].ToolTipText); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note, the signature of |
||
} | ||
|
||
[Trait("Category", "Completions")] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
// | ||
|
||
using Microsoft.PowerShell.EditorServices.Utility; | ||
using Xunit; | ||
|
||
namespace Microsoft.PowerShell.EditorServices.Test.Utility | ||
{ | ||
public class VersionUtilsTests | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👌 |
||
{ | ||
[Trait("Category", "VersionUtils")] | ||
[Fact] | ||
public void IsNetCoreTest() | ||
{ | ||
#if CoreCLR | ||
Assert.True(VersionUtils.IsNetCore); | ||
#else | ||
Assert.False(VersionUtils.IsNetCore); | ||
#endif | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is nice -- should help us ensure forward compat