Skip to content
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

Test fixes for stabilizing tests #19068

Merged
merged 30 commits into from Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d54937c
Add loggin for package management test failures
adityapatwardhan Jan 17, 2023
5434c88
Build Microsoft.PowerShell.NamedPipeConnection as part on test artifacts
adityapatwardhan Jan 24, 2023
7f99d09
Add logging for Package management test
adityapatwardhan Jan 24, 2023
4cf7bc4
Add checks on DiskImage tests
adityapatwardhan Jan 24, 2023
b262267
Remove private sma reference
adityapatwardhan Jan 25, 2023
d7d17b0
Tab completion test fixes
adityapatwardhan Jan 26, 2023
f85c749
Add quotes
adityapatwardhan Jan 26, 2023
ef27dc4
Check for exception in COM test
adityapatwardhan Jan 26, 2023
72f3fc8
Add logging for CMS tests
adityapatwardhan Jan 26, 2023
61da3a9
Normalize CRLF for table tests
adityapatwardhan Jan 26, 2023
0ea8887
Fix table color test
adityapatwardhan Jan 31, 2023
b1963d7
Make import-pfxcertifcate call from pwsh
adityapatwardhan Jan 31, 2023
36d8cbe
some test fixes for release branch.
JamesWTruher Jan 31, 2023
7c4e636
Skip remoting tests on Windows x86
adityapatwardhan Feb 1, 2023
47a391e
Dont throw from Install-TestCertificate in test setup
adityapatwardhan Feb 1, 2023
8653eb8
small fixes
adityapatwardhan Feb 1, 2023
a205d51
Increase timeout of signing job
adityapatwardhan Feb 1, 2023
3d7ff72
Fix tab completion help test
adityapatwardhan Feb 8, 2023
f481137
Fix WindowStyle tests
adityapatwardhan Feb 8, 2023
f33d26c
Add PSCommandWithArgs experimental feature to json files
adityapatwardhan Feb 14, 2023
6cb0837
Fix skip condition
adityapatwardhan Feb 14, 2023
d57daeb
Revert windows style changes
adityapatwardhan Mar 10, 2023
2755095
CR feedback
adityapatwardhan Mar 10, 2023
5d6ca5e
CR feedback 2
adityapatwardhan Mar 10, 2023
10d417d
Reset changes to JEA tests
adityapatwardhan Mar 10, 2023
b102c00
Fix condition
adityapatwardhan Mar 11, 2023
1da070d
Revert install cert changes
adityapatwardhan Mar 11, 2023
1c13b2e
Fixes
adityapatwardhan Mar 13, 2023
9759db7
Revert pipeline change
adityapatwardhan Mar 13, 2023
a687e67
Revert package management test changes
adityapatwardhan Mar 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 3 additions & 12 deletions build.psm1
Expand Up @@ -1118,17 +1118,6 @@ function Publish-CustomConnectionTestModule
$sourcePath = "${PSScriptRoot}/test/tools/NamedPipeConnection"
$outPath = "${PSScriptRoot}/test/tools/NamedPipeConnection/out/Microsoft.PowerShell.NamedPipeConnection"
$publishPath = "${PSScriptRoot}/test/tools/Modules"
$refPath = "${sourcePath}/src/code/Ref"

# Copy the current SMA build to the refPath.
$smaPath = Join-Path -Path (Split-Path -Path (Get-PSOutput)) -ChildPath 'System.Management.Automation.dll'
if (! (Test-Path -Path $smaPath)) {
throw "Publish-CustomConnectionTestModule: Cannot find reference SMA at: ${smaPath}"
}
if (! (Test-Path -Path $refPath)) {
$null = New-Item -Path $refPath -ItemType Directory -Force
}
Copy-Item -Path $smapath -Destination $refPath -Force

Find-DotNet

Expand All @@ -1146,7 +1135,6 @@ function Publish-CustomConnectionTestModule

# Clean up build artifacts
./build.ps1 -Clean
Remove-Item -Path $refPath -Recurse -Force -ErrorAction SilentlyContinue
}
finally {
Pop-Location
Expand Down Expand Up @@ -1219,6 +1207,9 @@ function Publish-PSTestTools {

# `dotnet restore` on test project is not called if product projects have been restored unless -Force is specified.
Copy-PSGalleryModules -Destination "${PSScriptRoot}/test/tools/Modules" -CsProjPath "$PSScriptRoot/test/tools/Modules/PSGalleryTestModules.csproj" -Force

# Publish the Microsoft.PowerShell.NamedPipeConnection module
Publish-CustomConnectionTestModule
}

function Get-ExperimentalFeatureTests {
Expand Down
3 changes: 2 additions & 1 deletion experimental-feature-linux.json
Expand Up @@ -5,5 +5,6 @@
"PSNativeCommandErrorActionPreference",
"PSSubsystemPluginModel",
"PSModuleAutoLoadSkipOfflineFiles",
"PSFeedbackProvider"
"PSFeedbackProvider",
"PSCommandWithArgs"
]
3 changes: 2 additions & 1 deletion experimental-feature-windows.json
Expand Up @@ -5,5 +5,6 @@
"PSNativeCommandErrorActionPreference",
"PSSubsystemPluginModel",
"PSModuleAutoLoadSkipOfflineFiles",
"PSFeedbackProvider"
"PSFeedbackProvider",
"PSCommandWithArgs"
]
8 changes: 8 additions & 0 deletions test/powershell/Host/HostUtilities.Tests.ps1
Expand Up @@ -35,6 +35,12 @@ Describe "InvokeOnRunspace method as nested command" -tags "Feature" {
Describe "InvokeOnRunspace method on remote runspace" -tags "Feature","RequireAdminOnWindows" {

BeforeAll {
$originalDefaultParameterValues = $PSDefaultParameterValues.Clone()

if (Test-IsWinWow64) {
adityapatwardhan marked this conversation as resolved.
Show resolved Hide resolved
$global:PSDefaultParameterValues["it:skip"] = $true
return
}

if ($IsWindows) {
$script:remoteRunspace = New-RemoteRunspace
Expand All @@ -46,6 +52,8 @@ Describe "InvokeOnRunspace method on remote runspace" -tags "Feature","RequireAd
{
$script:remoteRunspace.Dispose();
}

$global:PSDefaultParameterValues = $originalDefaultParameterValues
}

It "Method should successfully invoke command on remote runspace" -Skip:(!$IsWindows) {
Expand Down
101 changes: 79 additions & 22 deletions test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1
Expand Up @@ -541,11 +541,16 @@ using `
It 'Should show multiple constructors in the tooltip' {
$res = TabExpansion2 -inputScript 'class ConstructorTestClass{ConstructorTestClass ([string] $s){}ConstructorTestClass ([int] $i){}ConstructorTestClass ([int] $i, [bool]$b){}};[ConstructorTestClass]::new'
$res.CompletionMatches | Should -HaveCount 1
$completionText = $res.CompletionMatches.ToolTip | Should -BeExactly @'
$completionText = $res.CompletionMatches.ToolTip
$completionText.replace("`r`n", [System.Environment]::NewLine).trim()

$expected = @'
ConstructorTestClass(string s)
ConstructorTestClass(int i)
ConstructorTestClass(int i, bool b)
'@
$expected.replace("`r`n", [System.Environment]::NewLine).trim()
$completionText.replace("`r`n", [System.Environment]::NewLine).trim() | Should -BeExactly $expected
}

It 'Should complete parameter in param block' {
Expand Down Expand Up @@ -1229,12 +1234,8 @@ class InheritedClassTest : System.Attribute
}

It "Tab completion UNC path" -Skip:(!$IsWindows) {
if (!$env:HOMEDRIVE) {
Set-ItResult -Skipped -Because "Homerdrive is not set"
}
$homeDrive = $env:HOMEDRIVE.Replace(":", "$")
$beforeTab = "\\localhost\$homeDrive\wind"
$afterTab = "& '\\localhost\$homeDrive\Windows'"
$beforeTab = "\\localhost\ADMIN$\boo"
$afterTab = "& '\\localhost\ADMIN$\Boot'"
$res = TabExpansion2 -inputScript $beforeTab -cursorColumn $beforeTab.Length
$res.CompletionMatches.Count | Should -BeGreaterThan 0
$res.CompletionMatches[0].CompletionText | Should -BeExactly $afterTab
Expand Down Expand Up @@ -2101,7 +2102,7 @@ dir -Recurse `

Context "Tab completion help test" {
BeforeAll {
if ([System.Management.Automation.Platform]::IsWindows) {
if ($IsWindows) {
$userHelpRoot = Join-Path $HOME "Documents/PowerShell/Help/"
} else {
$userModulesRoot = [System.Management.Automation.Platform]::SelectProductNameForDirectory([System.Management.Automation.Platform+XDG_Type]::USER_MODULES)
Expand All @@ -2110,33 +2111,89 @@ dir -Recurse `
}

It 'Should complete about help topic' {
$aboutHelpPathUserScope = Join-Path $userHelpRoot (Get-Culture).Name
$aboutHelpPathAllUsersScope = Join-Path $PSHOME (Get-Culture).Name
$helpName = "about_Splatting"
$helpFileName = "${helpName}.help.txt"
$inputScript = "get-help about_spla"
$culture = "en-US"
$aboutHelpPathUserScope = Join-Path $userHelpRoot $culture
$aboutHelpPathAllUsersScope = Join-Path $PSHOME $culture
$expectedCompletionCount = 0

## If help content does not exist, tab completion will not work. So update it first.
$userScopeHelp = Test-Path (Join-Path $aboutHelpPathUserScope "about_Splatting.help.txt")
$allUserScopeHelp = Test-Path (Join-Path $aboutHelpPathAllUsersScope "about_Splatting.help.txt")
if ((-not $userScopeHelp) -and (-not $aboutHelpPathAllUsersScope)) {
$userHelpPath = Join-Path $aboutHelpPathUserScope $helpFileName
$userScopeHelp = Test-Path $userHelpPath
if ($userScopeHelp) {
$expectedCompletionCount++
} else {
Update-Help -Force -ErrorAction SilentlyContinue -Scope 'CurrentUser'
if (Test-Path $userHelpPath) {
$expectedCompletionCount++
}
}

# If help content is present on both scopes, expect 2 or else expect 1 completion.
$expectedCompletions = if ($userScopeHelp -and $allUserScopeHelp) { 2 } else { 1 }
$allUserScopeHelpPath = Test-Path (Join-Path $aboutHelpPathAllUsersScope $helpFileName)
if ($allUserScopeHelpPath) {
$expectedCompletionCount++
}

$res = TabExpansion2 -inputScript 'get-help about_spla' -cursorColumn 'get-help about_spla'.Length
$res.CompletionMatches | Should -HaveCount $expectedCompletions
$res.CompletionMatches[0].CompletionText | Should -BeExactly 'about_Splatting'
$res = TabExpansion2 -inputScript $inputScript -cursorColumn $inputScript.Length
$res.CompletionMatches | Should -HaveCount $expectedCompletionCount
$res.CompletionMatches[0].CompletionText | Should -BeExactly $helpName
}

It 'Should complete about help topic regardless of culture' {
try
{
## Save original culture and temporarily set it to da-DK because there's no localized help for da-DK.
$OriginalCulture = [cultureinfo]::CurrentCulture
[cultureinfo]::CurrentCulture="da-DK"
$defaultCulture = "en-US"
$culture = "da-DK"
[cultureinfo]::CurrentCulture = $culture
$helpName = "about_Splatting"
$helpFileName = "${helpName}.help.txt"

$aboutHelpPathUserScope = Join-Path $userHelpRoot $culture
$aboutHelpPathAllUsersScope = Join-Path $PSHOME $culture
$expectedCompletionCount = 0

## If help content does not exist, tab completion will not work. So update it first.
$userHelpPath = Join-Path $aboutHelpPathUserScope $helpFileName
$userScopeHelp = Test-Path $userHelpPath
if ($userScopeHelp) {
$expectedCompletionCount++
}
else { Update-Help -Force -ErrorAction SilentlyContinue -Scope 'CurrentUser'
if (Test-Path $userHelpPath) {
$expectedCompletionCount++
}
else {
$aboutHelpPathUserScope = Join-Path $userHelpRoot $defaultCulture
$aboutHelpPathAllUsersScope = Join-Path $PSHOME $defaultCulture
$userHelpDefaultPath = Join-Path $aboutHelpPathUserScope $helpFileName
$userDefaultScopeHelp = Test-Path $userHelpDefaultPath

if ($userDefaultScopeHelp) {
$expectedCompletionCount++
}
}
}

$allUserScopeHelpPath = Test-Path (Join-Path $aboutHelpPathAllUsersScope $helpFileName)
if ($allUserScopeHelpPath) {
$expectedCompletionCount++
}
else {
$aboutHelpPathAllUsersDefaultScope = Join-Path $PSHOME $defaultCulture
$allUsersDefaultScopeHelpPath = Test-Path (Join-Path $aboutHelpPathAllUsersDefaultScope $helpFileName)

if ($allUsersDefaultScopeHelpPath) {
$expectedCompletionCount++
}
}

$res = TabExpansion2 -inputScript 'get-help about_spla' -cursorColumn 'get-help about_spla'.Length
$res.CompletionMatches | Should -HaveCount 1
$res.CompletionMatches[0].CompletionText | Should -BeExactly 'about_Splatting'
$res.CompletionMatches | Should -HaveCount $expectedCompletionCount
$res.CompletionMatches[0].CompletionText | Should -BeExactly $helpName
}
finally
{
Expand Down Expand Up @@ -2351,7 +2408,7 @@ function MyFunction ($param1, $param2)

Describe "Tab completion tests with remote Runspace" -Tags Feature,RequireAdminOnWindows {
BeforeAll {
if ($IsWindows) {
if ($IsWindows -and -not (Test-IsWinWow64)) {
$session = New-RemoteSession
$powershell = [powershell]::Create()
$powershell.Runspace = $session.Runspace
Expand Down
Expand Up @@ -312,6 +312,14 @@ Describe "Run native command from a mounted FAT-format VHD" -tags @("Feature", "
if (-not $IsWindows) {
return;
}
else {
$storageModule = Get-Module -Name 'Storage' -ListAvailable -ErrorAction SilentlyContinue

if (-not $storageModule) {
Write-Verbose -Verbose "Storage module is not available."
return;
}
}

$vhdx = Join-Path -Path $TestDrive -ChildPath ncp.vhdx

Expand All @@ -335,11 +343,18 @@ Describe "Run native command from a mounted FAT-format VHD" -tags @("Feature", "
diskpart.exe /s $create_vhdx
Mount-DiskImage -ImagePath $vhdx > $null

Copy-Item "$env:WinDir\System32\whoami.exe" T:\whoami.exe
Copy-Item "$env:WinDir\System32\whoami.exe" "T:\whoami.exe"
}

AfterAll {
if ($IsWindows) {
$storageModule = Get-Module -Name 'Storage' -ListAvailable -ErrorAction SilentlyContinue

if (-not $storageModule) {
Write-Verbose -Verbose "Storage module is not available."
return;
}

Dismount-DiskImage -ImagePath $vhdx
Remove-Item $vhdx, $create_vhdx -Force
}
Expand Down
Expand Up @@ -4,7 +4,7 @@ Describe "Remote module tests" -Tags 'Feature','RequireAdminOnWindows' {

BeforeAll {

if (!$IsWindows)
if (!$IsWindows -or (Test-IsWinWow64))
{
$originalDefaultParameterValues = $PSDefaultParameterValues.Clone()
$PSDefaultParameterValues["it:skip"] = $true
Expand Down
Expand Up @@ -5,7 +5,7 @@ Describe "Remote import-module tests" -Tags 'Feature','RequireAdminOnWindows' {
BeforeAll {
$originalDefaultParameterValues = $PSDefaultParameterValues.Clone()
$modulePath = "$testdrive\Modules\TestImport"
if (!$IsWindows) {
if (!$IsWindows -or (Test-IsWinWow64)) {
$PSDefaultParameterValues["it:skip"] = $true
} else {
$pssession = New-RemoteSession
Expand Down