Correct casing for automatic variables (#11568)

* Remove BOM, insert newline at EOF

* Correct case of $MyInvocation special variable

* Correct case of $OFS special variable

* Correct case of $NestedPromptLevel special variable

* Correct case of $Matches special variable

* Correct case of $LASTEXITCODE special variable

* Correct case of $StackTrace special variable

* Correct case of $args special variable

* Correct case of $this special variable

* Correct case of $input special variable

* Correct case of $PSCmdlet special variable

* Correct case of $error special variable

* Correct case of $PSDefaultParameterValues special variable

* Correct case of $PSScriptRoot special variable

* Correct case of $PWD special variable

* Correct case of $null special variable

* Correct case of $true special variable

* Correct case of $false special variable

* Correct case of $PSModuleAutoLoadingPreference special variable

* Correct case of $IsLinux special variable

* Correct case of $IsMacOS special variable

* Correct case of $IsWindows special variable

* Correct case of $IsCoreCLR special variable

* Correct case of $DebugPreference special variable

* Correct case of $VerbosePreference special variable

* Correct case of $InformationPreference special variable

* Correct case of $ExecutionContext special variable

* Correct case of $HOME special variable

* Correct case of $Host special variable

* Correct case of $PID special variable

* Correct case of $PSCulture special variable

* Correct case of $PSHOME special variable

* Correct case of $PSUICulture special variable

* Correct case of $PSVersionTable special variable

* Fix false positives
This commit is contained in:
Ilya 2020-01-14 21:39:30 +05:00 committed by GitHub
commit aefb82a308
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
123 changed files with 419 additions and 419 deletions

View file

@ -289,7 +289,7 @@ function Start-PSBuild {
[switch]$Detailed
)
if ($PsCmdlet.ParameterSetName -eq "Default" -and !$NoPSModuleRestore)
if ($PSCmdlet.ParameterSetName -eq "Default" -and !$NoPSModuleRestore)
{
$PSModuleRestore = $true
}
@ -438,7 +438,7 @@ Fix steps:
$Arguments += "/property:SDKToUse=Microsoft.NET.Sdk.WindowsDesktop"
}
Write-Log "Run dotnet $Arguments from $pwd"
Write-Log "Run dotnet $Arguments from $PWD"
Start-NativeExecution { dotnet $Arguments }
Write-Log "PowerShell output: $($Options.Output)"
@ -456,14 +456,14 @@ Fix steps:
$Arguments += "/property:SDKToUse=Microsoft.NET.Sdk.WindowsDesktop"
}
Write-Log "Run dotnet $Arguments from $pwd"
Write-Log "Run dotnet $Arguments from $PWD"
Start-NativeExecution { dotnet $Arguments }
Write-Log "PowerShell output: $($Options.Output)"
try {
Push-Location $globalToolSrcFolder
$Arguments += "--output", $publishPath
Write-Log "Run dotnet $Arguments from $pwd to build global tool entry point"
Write-Log "Run dotnet $Arguments from $PWD to build global tool entry point"
Start-NativeExecution { dotnet $Arguments }
}
finally {
@ -498,7 +498,7 @@ Fix steps:
$psVersion = $ReleaseTag
}
else {
$psVersion = git --git-dir="$PSSCriptRoot/.git" describe
$psVersion = git --git-dir="$PSScriptRoot/.git" describe
}
if ($Environment.IsRedHatFamily -or $Environment.IsDebian) {
@ -1393,19 +1393,19 @@ function Show-PSPesterError
[PSCustomObject]$testFailureObject
)
if ($PSCmdLet.ParameterSetName -eq 'xml')
if ($PSCmdlet.ParameterSetName -eq 'xml')
{
$description = $testFailure.description
$name = $testFailure.name
$message = $testFailure.failure.message
$stackTrace = $testFailure.failure."stack-trace"
$StackTrace = $testFailure.failure."stack-trace"
}
elseif ($PSCmdLet.ParameterSetName -eq 'object')
elseif ($PSCmdlet.ParameterSetName -eq 'object')
{
$description = $testFailureObject.Describe + '/' + $testFailureObject.Context
$name = $testFailureObject.Name
$message = $testFailureObject.FailureMessage
$stackTrace = $testFailureObject.StackTrace
$StackTrace = $testFailureObject.StackTrace
}
else
{
@ -1417,7 +1417,7 @@ function Show-PSPesterError
Write-Log -Error "message:"
Write-Log -Error $message
Write-Log -Error "stack-trace:"
Write-Log -Error $stackTrace
Write-Log -Error $StackTrace
}
@ -1455,14 +1455,14 @@ function Test-XUnitTestResults
$description = $failure.test.type
$name = $failure.test.method
$message = $failure.test.failure.message.'#cdata-section'
$stackTrace = $failure.test.failure.'stack-trace'.'#cdata-section'
$StackTrace = $failure.test.failure.'stack-trace'.'#cdata-section'
Write-Log -Error ("Description: " + $description)
Write-Log -Error ("Name: " + $name)
Write-Log -Error "message:"
Write-Log -Error $message
Write-Log -Error "stack-trace:"
Write-Log -Error $stackTrace
Write-Log -Error $StackTrace
}
throw "$($failedTests.failed) tests failed"
@ -1488,7 +1488,7 @@ function Test-PSPesterResults
[switch] $CanHaveNoResult
)
if($PSCmdLet.ParameterSetName -eq 'file')
if($PSCmdlet.ParameterSetName -eq 'file')
{
if(!(Test-Path $TestResultsFile))
{
@ -1515,7 +1515,7 @@ function Test-PSPesterResults
throw "$($x.'test-results'.failures) tests in $TestArea failed"
}
}
elseif ($PSCmdLet.ParameterSetName -eq 'PesterPassThruObject')
elseif ($PSCmdlet.ParameterSetName -eq 'PesterPassThruObject')
{
if ($ResultObject.TotalCount -le 0 -and -not $CanHaveNoResult)
{
@ -1646,7 +1646,7 @@ function Install-Dotnet {
} else {
# dotnet-install.ps1 uses APIs that are not supported in .NET Core, so we run it with Windows PowerShell
$fullPSPath = Join-Path -Path $env:windir -ChildPath "System32\WindowsPowerShell\v1.0\powershell.exe"
$fullDotnetInstallPath = Join-Path -Path $pwd.Path -ChildPath $installScript
$fullDotnetInstallPath = Join-Path -Path $PWD.Path -ChildPath $installScript
Start-NativeExecution { & $fullPSPath -NoLogo -NoProfile -File $fullDotnetInstallPath -Channel $Channel -Version $Version }
}
}
@ -2385,7 +2385,7 @@ function Copy-PSGalleryModules
$cache = dotnet nuget locals global-packages -l
if ($cache -match "info : global-packages: (.*)") {
$nugetCache = $matches[1]
$nugetCache = $Matches[1]
}
else {
throw "Can't find nuget global cache"
@ -2400,7 +2400,7 @@ function Copy-PSGalleryModules
# Remove the build revision from the src (nuget drops it).
$srcVer = if ($version -match "(\d+.\d+.\d+).0") {
$matches[1]
$Matches[1]
} elseif ($version -match "^\d+.\d+$") {
# Two digit versions are stored as three digit versions
"$version.0"

View file

@ -56,7 +56,7 @@ function Invoke-CronTab ([String] $user, [String[]] $arguments, [Switch] $noThro
Write-Verbose "Running: $crontabcmd $arguments"
$output = & $crontabcmd @arguments 2>&1
if ($LastExitCode -ne 0 -and -not $noThrow) {
if ($LASTEXITCODE -ne 0 -and -not $noThrow) {
$e = New-Object System.InvalidOperationException -ArgumentList $output.Exception.Message
throw $e
} else {
@ -125,7 +125,7 @@ function Remove-CronJob {
$e = New-Object System.Exception -ArgumentList "Job not found"
throw $e
}
if ($Force -or $pscmdlet.ShouldProcess($Job.Command,"Remove")) {
if ($Force -or $PSCmdlet.ShouldProcess($Job.Command,"Remove")) {
Import-CronTab -user $UserName -crontab $newcrontab
}
}

View file

@ -24,7 +24,7 @@ function Get-Issue
{
if ($link -match '\s*<(.*)>;\s+rel="next"')
{
$uri = $matches[1]
$uri = $Matches[1]
}
}
}

View file

@ -72,7 +72,7 @@ function Get-LinuxContainer
{
Write-Output @{
Name = $os
Path = "$psscriptroot/../release/$os"
Path = "$PSScriptRoot/../release/$os"
}
}
}
@ -84,7 +84,7 @@ function Get-WindowsContainer
{
Write-Output @{
Name = $os
Path = "$psscriptroot/../release/$os"
Path = "$PSScriptRoot/../release/$os"
}
}
}
@ -183,7 +183,7 @@ function Get-ContainerPowerShellVersion
$runParams = @()
$localVolumeName = $testContext.resolvedTestDrive
$runParams += '--rm'
if($TestContext.Type -ne 'Windows' -and $isWindows)
if($TestContext.Type -ne 'Windows' -and $IsWindows)
{
# use a container volume on windows because host volumes are not automatic
$volumeName = "test-volume-" + (Get-Random -Minimum 100 -Maximum 999)
@ -204,7 +204,7 @@ function Get-ContainerPowerShellVersion
$runParams += ('$PSVersionTable.PSVersion.ToString() | out-string | out-file -encoding ascii -FilePath '+$testContext.containerLogPath)
$null = Invoke-Docker -Command run -Params $runParams -SuppressHostOutput
if($TestContext.Type -ne 'Windows' -and $isWindows)
if($TestContext.Type -ne 'Windows' -and $IsWindows)
{
$null = Invoke-Docker -Command cp -Params "${volumeName}:$($testContext.containerLogPath)", $TestContext.ResolvedLogPath
$null = Invoke-Docker -Command container, rm -Params $volumeName, '--force' -SuppressHostOutput

View file

@ -172,17 +172,17 @@ function Enable-PSWSManCombinedTrace
$traceFileName = [string][Guid]::NewGuid()
if ($DoNotOverwriteExistingTrace) {
$fileName = [string][guid]::newguid()
$logfile = $pshome + "\\Traces\\PSTrace_$fileName.etl"
$logfile = $PSHOME + "\\Traces\\PSTrace_$fileName.etl"
} else {
$logfile = $pshome + "\\Traces\\PSTrace.etl"
$logfile = $PSHOME + "\\Traces\\PSTrace.etl"
}
"Microsoft-Windows-PowerShell 0 5" | out-file $provfile -encoding ascii
"Microsoft-Windows-WinRM 0 5" | out-file $provfile -encoding ascii -append
if (!(Test-Path $pshome\Traces))
if (!(Test-Path $PSHOME\Traces))
{
New-Item -ItemType Directory -Force $pshome\Traces | out-null
New-Item -ItemType Directory -Force $PSHOME\Traces | out-null
}
if (Test-Path $logfile)

View file

@ -41,7 +41,7 @@ Describe "Basic remoting test with docker" -tags @("Scenario","Slow"){
# capture the versions of full and core PowerShell
write-verbose -verbose "getting powershell full version"
$fullVersion = docker exec $client powershell -c "`$psversiontable.psversion.tostring()"
$fullVersion = docker exec $client powershell -c "`$PSVersionTable.psversion.tostring()"
if ( ! $fullVersion )
{
$pending = $true
@ -50,7 +50,7 @@ Describe "Basic remoting test with docker" -tags @("Scenario","Slow"){
}
write-verbose -verbose "getting powershell version"
$coreVersion = docker exec $client "$powershellcorepath" -c "`$psversiontable.psversion.tostring()"
$coreVersion = docker exec $client "$powershellcorepath" -c "`$PSVersionTable.psversion.tostring()"
if ( ! $coreVersion )
{
$pending = $true
@ -68,22 +68,22 @@ Describe "Basic remoting test with docker" -tags @("Scenario","Slow"){
}
It "Full powershell can get correct remote powershell version" -pending:$pending {
$result = docker exec $client powershell -c "`$ss = [security.securestring]::new(); '11aa!!AA'.ToCharArray() | ForEach-Object { `$ss.appendchar(`$_)}; `$c = [pscredential]::new('testuser',`$ss); `$ses=new-pssession $serverhostname -configurationname $powershellcoreConfiguration -auth basic -credential `$c; invoke-command -session `$ses { `$psversiontable.psversion.tostring() }"
$result = docker exec $client powershell -c "`$ss = [security.securestring]::new(); '11aa!!AA'.ToCharArray() | ForEach-Object { `$ss.appendchar(`$_)}; `$c = [pscredential]::new('testuser',`$ss); `$ses=new-pssession $serverhostname -configurationname $powershellcoreConfiguration -auth basic -credential `$c; invoke-command -session `$ses { `$PSVersionTable.psversion.tostring() }"
$result | Should -Be $coreVersion
}
It "Full powershell can get correct remote powershell full version" -pending:$pending {
$result = docker exec $client powershell -c "`$ss = [security.securestring]::new(); '11aa!!AA'.ToCharArray() | ForEach-Object { `$ss.appendchar(`$_)}; `$c = [pscredential]::new('testuser',`$ss); `$ses=new-pssession $serverhostname -auth basic -credential `$c; invoke-command -session `$ses { `$psversiontable.psversion.tostring() }"
$result = docker exec $client powershell -c "`$ss = [security.securestring]::new(); '11aa!!AA'.ToCharArray() | ForEach-Object { `$ss.appendchar(`$_)}; `$c = [pscredential]::new('testuser',`$ss); `$ses=new-pssession $serverhostname -auth basic -credential `$c; invoke-command -session `$ses { `$PSVersionTable.psversion.tostring() }"
$result | Should -Be $fullVersion
}
It "Core powershell can get correct remote powershell version" -pending:$pending {
$result = docker exec $client "$powershellcorepath" -c "`$ss = [security.securestring]::new(); '11aa!!AA'.ToCharArray() | ForEach-Object { `$ss.appendchar(`$_)}; `$c = [pscredential]::new('testuser',`$ss); `$ses=new-pssession $serverhostname -configurationname $powershellcoreConfiguration -auth basic -credential `$c; invoke-command -session `$ses { `$psversiontable.psversion.tostring() }"
$result = docker exec $client "$powershellcorepath" -c "`$ss = [security.securestring]::new(); '11aa!!AA'.ToCharArray() | ForEach-Object { `$ss.appendchar(`$_)}; `$c = [pscredential]::new('testuser',`$ss); `$ses=new-pssession $serverhostname -configurationname $powershellcoreConfiguration -auth basic -credential `$c; invoke-command -session `$ses { `$PSVersionTable.psversion.tostring() }"
$result | Should -Be $coreVersion
}
It "Core powershell can get correct remote powershell full version" -pending:$pending {
$result = docker exec $client "$powershellcorepath" -c "`$ss = [security.securestring]::new(); '11aa!!AA'.ToCharArray() | ForEach-Object { `$ss.appendchar(`$_)}; `$c = [pscredential]::new('testuser',`$ss); `$ses=new-pssession $serverhostname -auth basic -credential `$c; invoke-command -session `$ses { `$psversiontable.psversion.tostring() }"
$result = docker exec $client "$powershellcorepath" -c "`$ss = [security.securestring]::new(); '11aa!!AA'.ToCharArray() | ForEach-Object { `$ss.appendchar(`$_)}; `$c = [pscredential]::new('testuser',`$ss); `$ses=new-pssession $serverhostname -auth basic -credential `$c; invoke-command -session `$ses { `$PSVersionTable.psversion.tostring() }"
$result | Should -Be $fullVersion
}
}

View file

@ -28,7 +28,7 @@ function Invoke-Msiexec {
[HashTable] $Properties
)
$action = "$($PsCmdlet.ParameterSetName)ing"
$action = "$($PSCmdlet.ParameterSetName)ing"
if ($Install.IsPresent) {
$switch = '/I'
} else {
@ -70,10 +70,10 @@ Describe -Name "Windows MSI" -Fixture {
$uploadedLog = $false
}
BeforeEach {
$Error.Clear()
$error.Clear()
}
AfterEach {
if ($Error.Count -ne 0 -and !$uploadedLog) {
if ($error.Count -ne 0 -and !$uploadedLog) {
Copy-Item -Path $msiLog -Destination $env:temp -Force
Write-Verbose "MSI log is at $env:temp\msilog.txt" -Verbose
$uploadedLog = $true

View file

@ -3,7 +3,7 @@
Describe "Configuration file locations" -tags "CI","Slow" {
BeforeAll {
$powershell = Join-Path -Path $PsHome -ChildPath "pwsh"
$powershell = Join-Path -Path $PSHOME -ChildPath "pwsh"
$profileName = "Microsoft.PowerShell_profile.ps1"
}

View file

@ -11,7 +11,7 @@ using namespace System.Diagnostics
Describe 'minishell for native executables' -Tag 'CI' {
BeforeAll {
$powershell = Join-Path -Path $PsHome -ChildPath "pwsh"
$powershell = Join-Path -Path $PSHOME -ChildPath "pwsh"
}
Context 'Streams from minishell' {
@ -53,7 +53,7 @@ Describe 'minishell for native executables' -Tag 'CI' {
Describe "ConsoleHost unit tests" -tags "Feature" {
BeforeAll {
$powershell = Join-Path -Path $PsHome -ChildPath "pwsh"
$powershell = Join-Path -Path $PSHOME -ChildPath "pwsh"
$ExitCodeBadCommandLineParameter = 64
function NewProcessStartInfo([string]$CommandLine, [switch]$RedirectStdIn)
@ -88,7 +88,7 @@ Describe "ConsoleHost unit tests" -tags "Feature" {
}
AfterEach {
$Error.Clear()
$error.Clear()
}
It "Clear-Host does not injects data into PowerShell output stream" {
@ -571,10 +571,10 @@ foo
}
It "Redirected input w/ nested prompt" -Pending:($IsWindows) {
$si = NewProcessStartInfo "-noprofile -noexit -c ""`$function:prompt = { 'PS' + ('>'*(`$nestedPromptLevel+1)) + ' ' }""" -RedirectStdIn
$si = NewProcessStartInfo "-noprofile -noexit -c ""`$function:prompt = { 'PS' + ('>'*(`$NestedPromptLevel+1)) + ' ' }""" -RedirectStdIn
$process = RunPowerShell $si
$process.StandardInput.Write("`$host.EnterNestedPrompt()`n")
$process.StandardOutput.ReadLine() | Should -Be "PS> `$host.EnterNestedPrompt()"
$process.StandardInput.Write("`$Host.EnterNestedPrompt()`n")
$process.StandardOutput.ReadLine() | Should -Be "PS> `$Host.EnterNestedPrompt()"
$process.StandardInput.Write("exit`n")
$process.StandardOutput.ReadLine() | Should -Be "PS>> exit"
$process.StandardInput.Close()
@ -655,7 +655,7 @@ namespace StackTest {
Context "PATH environment variable" {
It "`$PSHOME should be in front so that pwsh.exe starts current running PowerShell" {
& $powershell -v | Should -Match $psversiontable.GitCommitId
& $powershell -v | Should -Match $PSVersionTable.GitCommitId
}
It "powershell starts if PATH is not set" -Skip:($IsWindows) {
@ -706,7 +706,7 @@ namespace StackTest {
@{ parameter = '-wo' }
) {
param($parameter)
$output = & $powershell -NoProfile $parameter ~ -Command "`$pwd.Path"
$output = & $powershell -NoProfile $parameter ~ -Command "`$PWD.Path"
$output | Should -BeExactly $((Get-Item ~).FullName)
}
@ -761,7 +761,7 @@ namespace StackTest {
# Generate a string that is larger than the max pipe name length.
$longPipeName = [string]::new("A", 200)
"`$pid" | & $powershell -CustomPipeName $longPipeName -c -
"`$PID" | & $powershell -CustomPipeName $longPipeName -c -
$LASTEXITCODE | Should -Be $ExitCodeBadCommandLineParameter
}
}
@ -909,7 +909,7 @@ Describe "Console host api tests" -Tag CI {
@{InputObject = "${esc}abc"; Length = 4; Name = "Malformed escape - no csi"},
@{InputObject = "[31mabc"; Length = 7; Name = "Malformed escape - no escape"}
$testCases += if ($host.UI.SupportsVirtualTerminal)
$testCases += if ($Host.UI.SupportsVirtualTerminal)
{
@{InputObject = "$esc[31mabc"; Length = 3; Name = "Escape at start"}
@{InputObject = "$esc[31mabc$esc[0m"; Length = 3; Name = "Escape at start and end"}
@ -940,7 +940,7 @@ Describe "Console host api tests" -Tag CI {
It "Should properly calculate buffer cell width of '<Name>'" -TestCases $testCases {
param($InputObject, $Length)
$host.UI.RawUI.LengthInBufferCells($InputObject) | Should -Be $Length
$Host.UI.RawUI.LengthInBufferCells($InputObject) | Should -Be $Length
}
}
}
@ -960,13 +960,13 @@ Describe "Pwsh exe resources tests" -Tag CI {
It "Manifest contains compatibility section" -Skip:(!$IsWindows) {
$osversion = [System.Environment]::OSVersion.Version
$psversiontable.os | Should -MatchExactly "$($osversion.Major).$($osversion.Minor)"
$PSVersionTable.os | Should -MatchExactly "$($osversion.Major).$($osversion.Minor)"
}
}
Describe 'Pwsh startup in directories that contain wild cards' -Tag CI {
BeforeAll {
$powershell = Join-Path -Path $PsHome -ChildPath "pwsh"
$powershell = Join-Path -Path $PSHOME -ChildPath "pwsh"
$dirnames = "[T]est","[Test","T][est","Test"
$testcases = @()
foreach ( $d in $dirnames ) {

View file

@ -4,7 +4,7 @@ Describe "InvokeOnRunspace method argument error handling" -tags "Feature" {
BeforeAll {
$command = [System.Management.Automation.PSCommand]::new()
$localRunspace = $host.Runspace
$localRunspace = $Host.Runspace
}
It "Null argument exception should be thrown for null PSCommand argument" {
@ -24,7 +24,7 @@ Describe "InvokeOnRunspace method as nested command" -tags "Feature" {
$command = [System.Management.Automation.PSCommand]::new()
$command.AddScript('"Hello!"')
$currentRunspace = $host.Runspace
$currentRunspace = $Host.Runspace
$results = [System.Management.Automation.HostUtilities]::InvokeOnRunspace($command, $currentRunspace)

View file

@ -155,7 +155,7 @@ Describe 'Basic SysLog tests on Linux' -Tag @('CI','RequireSudoOnUnix') {
Write-Warning -Message 'Unsupported Linux syslog configuration.'
$IsSupportedEnvironment = $false
}
[string] $powershell = Join-Path -Path $PSHome -ChildPath 'pwsh'
[string] $powershell = Join-Path -Path $PSHOME -ChildPath 'pwsh'
$scriptBlockCreatedRegExTemplate = @"
Creating Scriptblock text \(1 of 1\):#012{0}(⏎|#012)*ScriptBlock ID: [0-9a-z\-]*#012Path:.*
"@
@ -191,7 +191,7 @@ Creating Scriptblock text \(1 of 1\):#012{0}(⏎|#012)*ScriptBlock ID: [0-9a-z\-
It 'Verifies scriptblock logging' -Skip:(!$IsSupportedEnvironment) {
$configFile = WriteLogSettings -LogId $logId -ScriptBlockLogging -LogLevel Verbose
$script = @'
$pid
$PID
& ([scriptblock]::create("Write-Verbose 'testheader123' ;Write-verbose 'after'"))
'@
$testFileName = 'test01.ps1'
@ -220,7 +220,7 @@ $pid
It 'Verifies scriptblock logging with null character' -Skip:(!$IsSupportedEnvironment) {
$configFile = WriteLogSettings -LogId $logId -ScriptBlockLogging -LogLevel Verbose
$script = @'
$pid
$PID
& ([scriptblock]::create("Write-Verbose 'testheader123$([char]0x0000)' ;Write-verbose 'after'"))
'@
$testFileName = 'test01.ps1'
@ -273,7 +273,7 @@ Describe 'Basic os_log tests on MacOS' -Tag @('CI','RequireSudoOnUnix') {
Set-OsLogPersistence -Enable
}
}
[string] $powershell = Join-Path -Path $PSHome -ChildPath 'pwsh'
[string] $powershell = Join-Path -Path $PSHOME -ChildPath 'pwsh'
$scriptBlockCreatedRegExTemplate = @'
Creating Scriptblock text \(1 of 1\):
{0}
@ -338,7 +338,7 @@ Path:.*
It 'Verifies scriptblock logging' -Skip:(!$IsSupportedEnvironment) {
try {
$script = @'
$pid
$PID
& ([scriptblock]::create("Write-Verbose 'testheader123' ;Write-verbose 'after'"))
'@
$configFile = WriteLogSettings -ScriptBlockLogging -LogId $logId -LogLevel Verbose
@ -376,7 +376,7 @@ $pid
It 'Verifies scriptblock logging with null character' -Skip:(!$IsSupportedEnvironment) {
try {
$script = @'
$pid
$PID
& ([scriptblock]::create("Write-Verbose 'testheader123$([char]0x0000)' ;Write-verbose 'after'"))
'@
$configFile = WriteLogSettings -ScriptBlockLogging -LogId $logId -LogLevel Verbose
@ -436,7 +436,7 @@ $pid
Describe 'Basic EventLog tests on Windows' -Tag @('CI','RequireAdminOnWindows') {
BeforeAll {
[bool] $IsSupportedEnvironment = $IsWindows
[string] $powershell = Join-Path -Path $PSHome -ChildPath 'pwsh'
[string] $powershell = Join-Path -Path $PSHOME -ChildPath 'pwsh'
$scriptBlockLoggingCases = @(
@{
name = 'normal script block'
@ -452,7 +452,7 @@ Describe 'Basic EventLog tests on Windows' -Tag @('CI','RequireAdminOnWindows')
if ($IsSupportedEnvironment)
{
& "$PSHome\RegisterManifest.ps1"
& "$PSHOME\RegisterManifest.ps1"
}
}

View file

@ -3,7 +3,7 @@
Describe "PSVersionTable" -Tags "CI" {
BeforeAll {
$sma = Get-Item (Join-Path $PSHome "System.Management.Automation.dll")
$sma = Get-Item (Join-Path $PSHOME "System.Management.Automation.dll")
$formattedVersion = $sma.VersionInfo.ProductVersion
$mainVersionPattern = "(\d+\.\d+\.\d+)(-.+)?"
@ -78,7 +78,7 @@ Describe "PSVersionTable" -Tags "CI" {
}
It "Verify `$PSVersionTable.PSEdition" {
if ($isCoreCLR) {
if ($IsCoreCLR) {
$edition = "Core"
}
else

View file

@ -3,7 +3,7 @@
Describe "Read-Host" -Tags "Slow","Feature" {
Context "[Console]::ReadKey() implementation on non-Windows" {
BeforeAll {
$powershell = Join-Path -Path $PsHome -ChildPath "pwsh"
$powershell = Join-Path -Path $PSHOME -ChildPath "pwsh"
$assetsDir = Join-Path -Path $PSScriptRoot -ChildPath assets
if ($IsWindows) {
$ItArgs = @{ skip = $true }

View file

@ -612,8 +612,8 @@ Describe "TabCompletion" -Tags CI {
@{ inputStr = "get-childitem -Fil"; expected = "-Filter"; setup = $null }
@{ inputStr = '$arg'; expected = '$args'; setup = $null }
@{ inputStr = '$args.'; expected = 'Count'; setup = $null }
@{ inputStr = '$host.UI.Ra'; expected = 'RawUI'; setup = $null }
@{ inputStr = '$host.UI.WriteD'; expected = 'WriteDebugLine('; setup = $null }
@{ inputStr = '$Host.UI.Ra'; expected = 'RawUI'; setup = $null }
@{ inputStr = '$Host.UI.WriteD'; expected = 'WriteDebugLine('; setup = $null }
@{ inputStr = '$MaximumHistoryCount.'; expected = 'CompareTo('; setup = $null }
@{ inputStr = '$A=[datetime]::now;$A.'; expected = 'Date'; setup = $null }
@{ inputStr = '$e=$null;try { 1/0 } catch {$e=$_};$e.'; expected = 'CategoryInfo'; setup = $null }
@ -697,8 +697,8 @@ Describe "TabCompletion" -Tags CI {
@{ inputStr = '$PSMod'; expected = '$PSModuleAutoLoadingPreference'; setup = $null }
## tab completion for variable in path
## if $PSHOME contains a space tabcompletion adds ' around the path
@{ inputStr = 'cd $pshome\Modu'; expected = if($PSHOME.Contains(' ')) { "'$(Join-Path $PSHOME 'Modules')'" } else { Join-Path $PSHOME 'Modules' }; setup = $null }
@{ inputStr = 'cd "$pshome\Modu"'; expected = "`"$(Join-Path $PSHOME 'Modules')`""; setup = $null }
@{ inputStr = 'cd $PSHOME\Modu'; expected = if($PSHOME.Contains(' ')) { "'$(Join-Path $PSHOME 'Modules')'" } else { Join-Path $PSHOME 'Modules' }; setup = $null }
@{ inputStr = 'cd "$PSHOME\Modu"'; expected = "`"$(Join-Path $PSHOME 'Modules')`""; setup = $null }
@{ inputStr = '$PSHOME\System.Management.Au'; expected = if($PSHOME.Contains(' ')) { "`& '$(Join-Path $PSHOME 'System.Management.Automation.dll')'" } else { Join-Path $PSHOME 'System.Management.Automation.dll'; setup = $null }}
@{ inputStr = '"$PSHOME\System.Management.Au"'; expected = "`"$(Join-Path $PSHOME 'System.Management.Automation.dll')`""; setup = $null }
@{ inputStr = '& "$PSHOME\System.Management.Au"'; expected = "`"$(Join-Path $PSHOME 'System.Management.Automation.dll')`""; setup = $null }
@ -1112,7 +1112,7 @@ dir -Recurse `
"Overridden-TabExpansion-Function"
}
$inputStr = '$pid.'
$inputStr = '$PID.'
$res = [System.Management.Automation.CommandCompletion]::CompleteInput($inputStr, $inputst.Length, $null)
$res.CompletionMatches | Should -HaveCount 1
$res.CompletionMatches[0].CompletionText | Should -BeExactly 'Overridden-TabExpansion-Function'
@ -1124,7 +1124,7 @@ dir -Recurse `
}
Set-Alias -Name TabExpansion -Value OverrideTabExpansion
$inputStr = '$pid.'
$inputStr = '$PID.'
$res = [System.Management.Automation.CommandCompletion]::CompleteInput($inputStr, $inputst.Length, $null)
$res.CompletionMatches | Should -HaveCount 1
$res.CompletionMatches[0].CompletionText | Should -BeExactly "Overridden-TabExpansion-Alias"
@ -1153,12 +1153,12 @@ dir -Recurse `
$ast = {}.Ast;
$tokens = [System.Management.Automation.Language.Token[]]@()
$testCases = @(
@{ inputStr = {[System.Management.Automation.CommandCompletion]::MapStringInputToParsedInput('$pid.', 7)}; expected = "PSArgumentException" }
@{ inputStr = {[System.Management.Automation.CommandCompletion]::MapStringInputToParsedInput('$PID.', 7)}; expected = "PSArgumentException" }
@{ inputStr = {[System.Management.Automation.CommandCompletion]::CompleteInput($null, $null, $null, $null)}; expected = "PSArgumentNullException" }
@{ inputStr = {[System.Management.Automation.CommandCompletion]::CompleteInput($ast, $null, $null, $null)}; expected = "PSArgumentNullException" }
@{ inputStr = {[System.Management.Automation.CommandCompletion]::CompleteInput($ast, $tokens, $null, $null)}; expected = "PSArgumentNullException" }
@{ inputStr = {[System.Management.Automation.CommandCompletion]::CompleteInput('$pid.', 7, $null, $null)}; expected = "PSArgumentException" }
@{ inputStr = {[System.Management.Automation.CommandCompletion]::CompleteInput('$pid.', 5, $null, $null)}; expected = "PSArgumentNullException" }
@{ inputStr = {[System.Management.Automation.CommandCompletion]::CompleteInput('$PID.', 7, $null, $null)}; expected = "PSArgumentException" }
@{ inputStr = {[System.Management.Automation.CommandCompletion]::CompleteInput('$PID.', 5, $null, $null)}; expected = "PSArgumentNullException" }
@{ inputStr = {[System.Management.Automation.CommandCompletion]::CompleteInput($null, $null, $null, $null, $null)}; expected = "PSArgumentNullException" }
@{ inputStr = {[System.Management.Automation.CommandCompletion]::CompleteInput($ast, $null, $null, $null, $null)}; expected = "PSArgumentNullException" }
@{ inputStr = {[System.Management.Automation.CommandCompletion]::CompleteInput($ast, $tokens, $null, $null, $null)}; expected = "PSArgumentNullException" }
@ -1218,7 +1218,7 @@ dir -Recurse `
$testCases = @(
@{ inputStr = "Invoke-CimMethod -ClassName Win32_Process -MethodName Crea"; expected = "Create" }
@{ inputStr = "Get-CimInstance -ClassName Win32_Process | Invoke-CimMethod -MethodName AttachDeb"; expected = "AttachDebugger" }
@{ inputStr = 'Get-CimInstance Win32_Process | ?{ $_.ProcessId -eq $Pid } | Get-CimAssociatedInstance -ResultClassName Win32_Co*uterSyst'; expected = "Win32_ComputerSystem" }
@{ inputStr = 'Get-CimInstance Win32_Process | ?{ $_.ProcessId -eq $PID } | Get-CimAssociatedInstance -ResultClassName Win32_Co*uterSyst'; expected = "Win32_ComputerSystem" }
@{ inputStr = "Get-CimInstance -ClassName Win32_Environm"; expected = "Win32_Environment" }
@{ inputStr = "New-CimInstance -ClassName Win32_Environm"; expected = "Win32_Environment" }
@{ inputStr = 'New-CimInstance -ClassName Win32_Process | %{ $_.Captio'; expected = "Caption" }
@ -1228,7 +1228,7 @@ dir -Recurse `
@{ inputStr = 'Invoke-CimMethod -Namespace root/StandardCimv2 -ClassName MSFT_NetIPAddress -MethodName Crea'; expected = 'Create' }
@{ inputStr = '$win32_process = Get-CimInstance -ClassName Win32_Process; $win32_process | Invoke-CimMethod -MethodName AttachDe'; expected = 'AttachDebugger' }
@{ inputStr = '$win32_process = Get-CimInstance -ClassName Win32_Process; Invoke-CimMethod -InputObject $win32_process -MethodName AttachDe'; expected = 'AttachDebugger' }
@{ inputStr = 'Get-CimInstance Win32_Process | ?{ $_.ProcessId -eq $Pid } | Get-CimAssociatedInstance -ResultClassName Win32_ComputerS'; expected = 'Win32_ComputerSystem' }
@{ inputStr = 'Get-CimInstance Win32_Process | ?{ $_.ProcessId -eq $PID } | Get-CimAssociatedInstance -ResultClassName Win32_ComputerS'; expected = 'Win32_ComputerSystem' }
@{ inputStr = 'Get-CimInstance -Namespace root/Interop -ClassName Win32_PowerSupplyP'; expected = 'Win32_PowerSupplyProfile' }
@{ inputStr = 'Get-CimInstance __NAMESP'; expected = '__NAMESPACE' }
@{ inputStr = 'Get-CimInstance -Namespace root/Inter'; expected = 'root/Interop' }

View file

@ -229,7 +229,7 @@ Describe 'Positive Parse Properties Tests' -Tags "CI" {
'111' -Match '1'
$Matches
$mAtches
$Error[0]
$error[0]
$error
$pwd
foreach ($i in 1..10) {$foreach}

View file

@ -300,7 +300,7 @@ Describe 'NullConditionalMemberAccess' -Tag 'CI' {
${array}?.length | Should -Be 3
${hash}?.a | Should -Be 1
(Get-Process -Id $pid)?.Name | Should -BeLike "pwsh*"
(Get-Process -Id $PID)?.Name | Should -BeLike "pwsh*"
(Get-Item $TestDrive)?.EnumerateFiles()?.Name | Should -BeExactly 'testfile.txt'
[int32]::MaxValue?.ToString() | Should -BeExactly '2147483647'
@ -365,7 +365,7 @@ Describe 'NullConditionalMemberAccess' -Tag 'CI' {
It 'Use ?. on a dynamic property name' {
$testContent = @'
$propName = 'Name'
(Get-Process -Id $pid)?.$propName | Should -BeLike 'pwsh*'
(Get-Process -Id $PID)?.$propName | Should -BeLike 'pwsh*'
${doesNotExist}?.$propName() | Should -BeNullOrEmpty
'@

View file

@ -14,12 +14,12 @@ Describe "Experimental Feature: && and || operators - Feature-Enabled" -Tag CI {
param(
[Parameter(ValueFromPipeline)]
[object[]]
$Input
$input
)
if ($Input -ne 2)
if ($input -ne 2)
{
return $Input
return $input
}
$exception = [System.Exception]::new("NTERROR")
@ -222,12 +222,12 @@ filter Test-NonTerminatingError
param(
[Parameter(ValueFromPipeline)]
[object[]]
$Input
$input
)
if ($Input -ne 2)
if ($input -ne 2)
{
return $Input
return $input
}
$exception = [System.Exception]::new("NTERROR")
@ -241,11 +241,11 @@ filter Test-NonTerminatingError
filter Test-PipelineTerminatingError
{
[CmdletBinding()]
param([Parameter(ValueFromPipeline)][int[]]$Input)
param([Parameter(ValueFromPipeline)][int[]]$input)
if ($Input -ne 4)
if ($input -ne 4)
{
return $Input
return $input
}
$exception = [System.Exception]::new("PIPELINE")

View file

@ -88,15 +88,15 @@ Describe "Using of ternary operator" -Tags CI {
It "Tab completion for variables assigned with ternary expression should work as expected" {
## Type inference for the ternary expression should aggregate the inferred values from both branches
$text1 = '$var1 = $IsCoreCLR ? (Get-Item $PSHome) : (Get-Process -Id $PID); $var1.Full'
$text1 = '$var1 = $IsCoreCLR ? (Get-Item $PSHOME) : (Get-Process -Id $PID); $var1.Full'
$result = TabExpansion2 -inputScript $text1 -cursorColumn $text1.Length
$result.CompletionMatches[0].CompletionText | Should -BeExactly FullName
$text2 = '$var1 = $IsCoreCLR ? (Get-Item $PSHome) : (Get-Process -Id $PID); $var1.Proce'
$text2 = '$var1 = $IsCoreCLR ? (Get-Item $PSHOME) : (Get-Process -Id $PID); $var1.Proce'
$result = TabExpansion2 -inputScript $text2 -cursorColumn $text2.Length
$result.CompletionMatches[0].CompletionText | Should -BeExactly ProcessName
$text3 = '$IsCoreCLR ? ($var2 = Get-Item $PSHome) : "blah"; $var2.Full'
$text3 = '$IsCoreCLR ? ($var2 = Get-Item $PSHOME) : "blah"; $var2.Full'
$result = TabExpansion2 -inputScript $text3 -cursorColumn $text3.Length
$result.CompletionMatches[0].CompletionText | Should -BeExactly FullName
}

View file

@ -137,7 +137,7 @@ Describe "Assign automatic variables" -Tags "CI" {
& { [object]$this = 1; $this } | Should -Be 1
& { [object]$input = 1; $input } | Should -Be 1
# Can't test PSCmdlet or PSBoundParameters, they use an internal type
& { [System.Management.Automation.InvocationInfo]$myInvocation = $myInvocation; $myInvocation.Line } | Should -Match Automation.InvocationInfo
& { [System.Management.Automation.InvocationInfo]$MyInvocation = $MyInvocation; $MyInvocation.Line } | Should -Match Automation.InvocationInfo
& { [string]$PSScriptRoot = 'abc'; $PSScriptRoot } | Should -BeExactly 'abc'
& { [string]$PSCommandPath = 'abc'; $PSCommandPath } | Should -BeExactly 'abc'
}

View file

@ -741,28 +741,28 @@ foo``u{2195}abc
@{ Script = 'if (0 -or 1) { $true } else { $false }'; Expected = $true }
@{ Script = 'if (0 -or 0) { $true } else { $false }'; Expected = $false }
#-eq
@{ Script = 'if ($False -eq $True -and $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($False -and $True -eq $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($false -eq $true -and $false) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($false -and $true -eq $false) { $true } else { $false }'; Expected = $false }
#-ieq
@{ Script = 'if ($False -ieq $True -and $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($False -and $True -ieq $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($false -ieq $true -and $false) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($false -and $true -ieq $false) { $true } else { $false }'; Expected = $false }
#-le
@{ Script = 'if ($False -le $True -and $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($False -and $True -le $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($false -le $true -and $false) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($false -and $true -le $false) { $true } else { $false }'; Expected = $false }
#-ile
@{ Script = 'if ($False -ile $True -and $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($False -and $True -ile $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($false -ile $true -and $false) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($false -and $true -ile $false) { $true } else { $false }'; Expected = $false }
#-ge
@{ Script = 'if ($False -ge $True -and $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($False -and $True -ge $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($false -ge $true -and $false) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($false -and $true -ge $false) { $true } else { $false }'; Expected = $false }
#-ige
@{ Script = 'if ($False -ige $True -and $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($False -and $True -ige $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($false -ige $true -and $false) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($false -and $true -ige $false) { $true } else { $false }'; Expected = $false }
#-like
@{ Script = 'if ($False -like $True -and $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($False -and $True -like $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($false -like $true -and $false) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($false -and $true -like $false) { $true } else { $false }'; Expected = $false }
#!
@{ Script = 'if (!$True -and $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if (!$true -and $false) { $true } else { $false }'; Expected = $false }
)
It "<Script> should return <Expected>" -TestCases $testData {
param ( $Script, $Expected )

View file

@ -14,8 +14,8 @@ Describe "Redirection operator now supports encoding changes" -Tags "CI" {
# If Out-File -Encoding happens to have a default, be sure to
# save it away
$SavedValue = $null
$oldDefaultParameterValues = $psDefaultParameterValues.Clone()
$psDefaultParameterValues = @{}
$oldDefaultParameterValues = $PSDefaultParameterValues.Clone()
$PSDefaultParameterValues = @{}
}
AfterAll {
# be sure to tidy up afterwards
@ -23,11 +23,11 @@ Describe "Redirection operator now supports encoding changes" -Tags "CI" {
}
BeforeEach {
# start each test with a clean plate!
$psdefaultParameterValues.Remove("Out-File:Encoding")
$PSDefaultParameterValues.Remove("Out-File:Encoding")
}
AfterEach {
# end each test with a clean plate!
$psdefaultParameterValues.Remove("Out-File:Encoding")
$PSDefaultParameterValues.Remove("Out-File:Encoding")
}
It "If encoding is unset, redirection should be UTF8 without bom" {
@ -70,7 +70,7 @@ Describe "Redirection operator now supports encoding changes" -Tags "CI" {
$TXT = $enc.GetBytes($asciiString)
$CR = $enc.GetBytes($asciiCR)
$expectedBytes = .{ $BOM; $TXT; $CR }
$psdefaultparameterValues["Out-File:Encoding"] = "$encoding"
$PSDefaultParameterValues["Out-File:Encoding"] = "$encoding"
$asciiString > TESTDRIVE:/file.txt
$observedBytes = Get-Content -AsByteStream TESTDRIVE:/file.txt
# THE TEST

View file

@ -154,7 +154,7 @@ Describe "Common parameters support for script cmdlets" -Tags "CI" {
[CmdletBinding(SupportsShouldProcess=$true)]
param()
if($pscmdlet.shouldprocess("foo", "foo action"))
if($PSCmdlet.shouldprocess("foo", "foo action"))
{
write-output "foo action"
}
@ -205,7 +205,7 @@ Describe "Common parameters support for script cmdlets" -Tags "CI" {
[CmdletBinding(supportsshouldprocess=$true, ConfirmImpact="none")]
param()
if($pscmdlet.shouldprocess("foo", "foo action"))
if($PSCmdlet.shouldprocess("foo", "foo action"))
{
write-output "foo action"
}
@ -239,7 +239,7 @@ Describe "Common parameters support for script cmdlets" -Tags "CI" {
[CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact="low")]
param()
if($pscmdlet.shouldprocess("foo", "foo action"))
if($PSCmdlet.shouldprocess("foo", "foo action"))
{
write-output "foo action"
}
@ -274,7 +274,7 @@ Describe "Common parameters support for script cmdlets" -Tags "CI" {
[CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact="medium")]
param()
if($pscmdlet.shouldprocess("foo", "foo action"))
if($PSCmdlet.shouldprocess("foo", "foo action"))
{
write-output "foo action"
}
@ -310,7 +310,7 @@ Describe "Common parameters support for script cmdlets" -Tags "CI" {
[CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact="high")]
param()
if($pscmdlet.shouldprocess("foo", "foo action"))
if($PSCmdlet.shouldprocess("foo", "foo action"))
{
write-output "foo action"
}
@ -346,7 +346,7 @@ Describe "Common parameters support for script cmdlets" -Tags "CI" {
[CmdletBinding()]
param()
if($pscmdlet.shouldcontinue("foo", "foo action"))
if($PSCmdlet.shouldcontinue("foo", "foo action"))
{
write-output "foo action"
}

View file

@ -10,13 +10,13 @@ Describe "Tests Debugger GetCallStack() on runspaces when attached to a WinRM ho
{
# Create PSSession
$wc = [System.Management.Automation.Runspaces.WSManConnectionInfo]::new()
$rs = [runspacefactory]::CreateRunspace($host, $wc)
$rs = [runspacefactory]::CreateRunspace($Host, $wc)
$rs.Open()
# Get WinRM host process id
[powershell] $ps = [powershell]::Create()
$ps.Runspace = $rs
$result = $ps.AddScript('$pid').Invoke()
$result = $ps.AddScript('$PID').Invoke()
It "Verifies the WinRM host process Id was found" {
$result | Should -Not -BeNullOrEmpty
($result.Count -eq 1) | Should -BeTrue
@ -69,7 +69,7 @@ Describe "Tests Debugger GetCallStack() on runspaces when attached to a WinRM ho
finally
{
# Clean up
if ($host.IsRunspacePushed) { $host.PopRunspace() }
if ($Host.IsRunspacePushed) { $Host.PopRunspace() }
if ($null -ne $psHost) { $psHost.Dispose() }
if ($null -ne $hostRS) { $hostRS.Dispose() }

View file

@ -4,7 +4,7 @@ Describe 'Test for conversion b/w script block and delegate' -Tags "CI" {
BeforeAll {
function lineno
{
$myInvocation.ScriptLineNumber
$MyInvocation.ScriptLineNumber
}
function Generate-ArgumentTypesAndParameters

View file

@ -18,4 +18,4 @@ Describe "DeserializedMethods" -Tags "CI" {
$d | Get-Member -MemberType *Method* Add | Should -BeNullOrEmpty
}
}
}

View file

@ -120,7 +120,7 @@ Describe 'Testing of script internationalization' -Tags "CI" {
import-localizedData mydata -filename if
if ($psculture -eq 'en-US')
if ($PSCulture -eq 'en-US')
{
$mydata.string1 | Should -BeExactly 'string1 for en-US in if'
$mydata.string2 | Should -BeExactly 'string2 for en-US in if'

View file

@ -7,7 +7,7 @@ Describe 'Tests for indexers' -Tags "CI" {
$hashtable["Hello"] | Should -BeExactly "There"
}
It 'Accessing a Indexed property of a dictionary that does not exist should return $NULL' {
It 'Accessing a Indexed property of a dictionary that does not exist should return $null' {
$hashtable = @{ "Hello"="There" }
$hashtable["Hello There"] | Should -BeNullOrEmpty
}
@ -19,7 +19,7 @@ Describe 'Tests for indexers' -Tags "CI" {
$service.CimClassProperties["DisplayName"].Name | Should -BeExactly 'DisplayName'
}
It 'Accessing a Indexed property of a CimClass that does not exist should return $NULL' -Skip:(-not $IsWindows) {
It 'Accessing a Indexed property of a CimClass that does not exist should return $null' -Skip:(-not $IsWindows) {
$service = Get-CimClass -ClassName Win32_Service
$service.CimClassProperties["Hello There"] | Should -BeNullOrEmpty

View file

@ -10,7 +10,7 @@ Describe 'Native pipeline should have proper encoding' -tags 'CI' {
Describe 'native commands with pipeline' -tags 'Feature' {
BeforeAll {
$powershell = Join-Path -Path $PsHome -ChildPath "pwsh"
$powershell = Join-Path -Path $PSHOME -ChildPath "pwsh"
}
It "native | ps | native doesn't block" {

View file

@ -2,7 +2,7 @@
# Licensed under the MIT License.
Describe "Native streams behavior with PowerShell" -Tags 'CI' {
BeforeAll {
$powershell = Join-Path -Path $PsHome -ChildPath "pwsh"
$powershell = Join-Path -Path $PSHOME -ChildPath "pwsh"
}
Context "Error stream" {

View file

@ -50,9 +50,9 @@ Describe 'Native UNIX globbing tests' -tags "CI" {
}
# Test globbing with absolute paths - it shouldn't turn absolute paths into relative paths (#7089)
It 'Should not normalize absolute paths' {
$matches = /bin/echo /etc/*
$Matches = /bin/echo /etc/*
# Matched path should start with '/etc/' not '../..'
$matches.substring(0,5) | Should -Be '/etc/'
$Matches.substring(0,5) | Should -Be '/etc/'
}
It 'Globbing should not happen with quoted expressions' {
$v = "$TESTDRIVE/abc*"
@ -120,11 +120,11 @@ Describe 'Native UNIX globbing tests' -tags "CI" {
}
# Test ~ expansion
It 'Tilde should be replaced by the filesystem provider home directory' {
/bin/echo ~ | Should -BeExactly ($executioncontext.SessionState.Provider.Get("FileSystem").Home)
/bin/echo ~ | Should -BeExactly ($ExecutionContext.SessionState.Provider.Get("FileSystem").Home)
}
# Test ~ expansion with a path fragment (e.g. ~/foo)
It '~/foo should be replaced by the <filesystem provider home directory>/foo' {
/bin/echo ~/foo | Should -BeExactly "$($executioncontext.SessionState.Provider.Get("FileSystem").Home)/foo"
/bin/echo ~/foo | Should -BeExactly "$($ExecutionContext.SessionState.Provider.Get("FileSystem").Home)/foo"
}
It '~ should not be replaced when quoted' {
/bin/echo '~' | Should -BeExactly '~'

View file

@ -16,7 +16,7 @@ Describe "Tests OutVariable only" -Tags "CI" {
[CmdletBinding()]
param()
$pscmdlet.writeobject("foo")
$PSCmdlet.writeobject("foo")
}
function get-bar
@ -35,7 +35,7 @@ Describe "Tests OutVariable only" -Tags "CI" {
OutVariable = 'a';
Expected = 'foo'
},
@{ Name = 'Updating OutVariable Case 2: $pscmdlet.writeobject';
@{ Name = 'Updating OutVariable Case 2: $PSCmdlet.writeobject';
Command = "get-foo2";
OutVariable = 'a';
Expected = 'foo'
@ -46,7 +46,7 @@ Describe "Tests OutVariable only" -Tags "CI" {
PreSet = 'a','b';
Expected = @("a", "b", "foo")
},
@{ Name = 'Appending OutVariable Case 2: $pscmdlet.writeobject';
@{ Name = 'Appending OutVariable Case 2: $PSCmdlet.writeobject';
Command = "get-foo2";
OutVariable = 'a';
PreSet = 'a','b';
@ -92,7 +92,7 @@ Describe "Test ErrorVariable only" -Tags "CI" {
[CmdletBinding()]
param()
$pscmdlet.WriteError($script:foo[0])
$PSCmdlet.WriteError($script:foo[0])
}
function get-bar
@ -111,7 +111,7 @@ Describe "Test ErrorVariable only" -Tags "CI" {
ErrorVariable = 'a';
Expected = 'foo'
},
@{ Name = 'Updating ErrorVariable Case 2: $pscmdlet.WriteError';
@{ Name = 'Updating ErrorVariable Case 2: $PSCmdlet.WriteError';
Command = "get-foo1";
ErrorVariable = 'a';
Expected = 'foo'
@ -140,7 +140,7 @@ Describe "Test ErrorVariable only" -Tags "CI" {
$a | Should -BeExactly $Expected
}
It 'Appending ErrorVariable Case 2: $pscmdlet.writeerror' {
It 'Appending ErrorVariable Case 2: $PSCmdlet.writeerror' {
write-error "foo" -errorVariable script:foo 2> $null
$a = 'a','b'
@ -193,7 +193,7 @@ Describe "Update both OutVariable and ErrorVariable" -Tags "CI" {
[CmdletBinding()]
param()
$pscmdlet.WriteError($script:foo[0])
$PSCmdlet.WriteError($script:foo[0])
}
function get-bar

View file

@ -29,4 +29,4 @@ function Run-TestOnWinFull
}
}
}
}

View file

@ -502,7 +502,7 @@ Describe "PSModulePath changes interacting with other PowerShell processes" -Tag
Restore-ModulePath
}
It "Allows Windows PowerShell subprocesses to call `$PSHome modules still" {
It "Allows Windows PowerShell subprocesses to call `$PSHOME modules still" {
$errors = powershell.exe -Command "Get-ChildItem" 2>&1 | Where-Object { $_ -is [System.Management.Automation.ErrorRecord] }
$errors | Should -Be $null
}
@ -516,7 +516,7 @@ Describe "PSModulePath changes interacting with other PowerShell processes" -Tag
<# Remove Pending status and update test after issue #11575 is fixed #>
It "Does not duplicate the System32 module path in subprocesses" -Pending:$true {
$sys32ModPathCount = & $pwsh -C {
& "$PSHOME/pwsh" -C '$null = $env:PSModulePath -match ([regex]::Escape((Join-Path $env:windir "System32" "WindowsPowerShell" "v1.0" "Modules"))); $matches.Count'
& "$PSHOME/pwsh" -C '$null = $env:PSModulePath -match ([regex]::Escape((Join-Path $env:windir "System32" "WindowsPowerShell" "v1.0" "Modules"))); $Matches.Count'
}
$sys32ModPathCount | Should -Be 1

View file

@ -1,7 +1,7 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
$powershell = Join-Path -Path $PsHome -ChildPath "pwsh"
$powershell = Join-Path -Path $PSHOME -ChildPath "pwsh"
function Wait-JobPid {
param (
@ -40,7 +40,7 @@ function Invoke-PSHostProcessScript {
$commandStr = @'
Start-Sleep -Seconds {0}
Enter-PSHostProcess {1} -ErrorAction Stop
$pid
$PID
Exit-PSHostProcess
'@ -f $i, $ArgumentString
@ -69,10 +69,10 @@ Describe "Enter-PSHostProcess tests" -Tag Feature {
Context "By Process Id" {
BeforeEach {
# Start a normal job where the first thing it does is return $pid. After that, spin forever.
# Start a normal job where the first thing it does is return $PID. After that, spin forever.
# We will use this job as the target process for Enter-PSHostProcess
$pwshJob = Start-Job {
$pid
$PID
while ($true) {
Start-Sleep -Seconds 30 | Out-Null
}
@ -98,10 +98,10 @@ Describe "Enter-PSHostProcess tests" -Tag Feature {
}
It "Can enter, exit, and re-enter another Windows PowerShell PSHost" -Skip:(!$IsWindows) {
# Start a PowerShell job where the first thing it does is return $pid. After that, spin forever.
# Start a PowerShell job where the first thing it does is return $PID. After that, spin forever.
# We will use this job as the target process for Enter-PSHostProcess
$powershellJob = Start-Job {
$pid
$PID
while ($true) {
Start-Sleep -Seconds 30 | Out-Null
}
@ -134,7 +134,7 @@ Describe "Enter-PSHostProcess tests" -Tag Feature {
$rs.Open()
$ps = [powershell]::Create()
$ps.Runspace = $rs
$ps.AddScript('$pid')
$ps.AddScript('$PID')
[int]$retry = 0
$result = $null
@ -164,12 +164,12 @@ Describe "Enter-PSHostProcess tests" -Tag Feature {
$pipeName = [System.IO.Path]::GetRandomFileName()
$pipePath = Get-PipePath -PipeName $pipeName
# Start a job where the first thing it does is set the custom pipe name, then return $pid.
# Start a job where the first thing it does is set the custom pipe name, then return $PID.
# After that, spin forever.
# We will use this job as the target process for Enter-PSHostProcess
$pwshJob = Start-Job -ArgumentList $pipeName {
[System.Management.Automation.Remoting.RemoteSessionNamedPipeServer]::CreateCustomNamedPipeServer($args[0])
$pid
$PID
while ($true) { Start-Sleep -Seconds 30 | Out-Null }
}

View file

@ -26,7 +26,7 @@ Describe "Get-PSHostProcessInfo tests" -Tag CI {
}
It "Should return own self" {
(Get-PSHostProcessInfo).ProcessId | Should -Contain $pid
(Get-PSHostProcessInfo).ProcessId | Should -Contain $PID
}
It "Should list info for other PowerShell hosted processes" {

View file

@ -65,9 +65,9 @@ Describe "History cmdlet test cases" -Tags "CI" {
"Output"
}
$informationPreference = "Continue"
$debugPreference = "Continue"
$verbosePreference = "Continue"
$InformationPreference = "Continue"
$DebugPreference = "Continue"
$VerbosePreference = "Continue"
'
$invocationSettings = New-Object System.Management.Automation.PSInvocationSettings
@ -100,7 +100,7 @@ Describe "History cmdlet test cases" -Tags "CI" {
$ps = [PowerShell]::Create()
$null = $ps.AddScript("(Get-Command Get-Process).Visibility = 'Private'").Invoke()
$ps.Commands.Clear()
$null = $ps.AddScript("Get-Process -id $pid")
$null = $ps.AddScript("Get-Process -id $PID")
$null = $ps.Invoke($null, $invocationSettings)
$ps.Commands.Clear()
$null = $ps.AddScript("Invoke-History -id 1")

View file

@ -264,11 +264,11 @@ Describe "Import-Module for Binary Modules" -Tags 'CI' {
Describe "Import-Module should be case insensitive" -Tags 'CI' {
BeforeAll {
$defaultPSModuleAutoloadingPreference = $PSModuleAutoloadingPreference
$defaultPSModuleAutoloadingPreference = $PSModuleAutoLoadingPreference
$originalPSModulePath = $env:PSModulePath.Clone()
$modulesPath = "$TestDrive\Modules"
$env:PSModulePath += [System.IO.Path]::PathSeparator + $modulesPath
$PSModuleAutoloadingPreference = "none"
$PSModuleAutoLoadingPreference = "none"
}
AfterAll {

View file

@ -205,18 +205,18 @@ Describe "Ampersand background test" -tag "CI","Slow" {
Receive-Job $j -Wait | Should -BeExactly "Hi Bob! Hi Mary! Hi Bill!"
}
It 'Make sure that $PID from the parent process does not overwrite $PID in the child process' {
$j = Write-Output $pid &
$j = Write-Output $PID &
$cpid = Receive-Job $j -Wait
$pid | Should -Not -BeExactly $cpid
$PID | Should -Not -BeExactly $cpid
}
It 'Make sure that $global:PID from the parent process does not overwrite $global:PID in the child process' {
$j = Write-Output $global:pid &
$cpid = Receive-Job -Wait $j
$pid | Should -Not -BeExactly $cpid
$PID | Should -Not -BeExactly $cpid
}
It "starts in the current directory" {
$j = Get-Location | Foreach-Object -MemberName Path &
Receive-Job -Wait $j | Should -Be ($pwd.Path)
Receive-Job -Wait $j | Should -Be ($PWD.Path)
}
It "Test that output redirection is done in the background job" {
$j = Write-Output hello > $TESTDRIVE/hello.txt &

View file

@ -21,7 +21,7 @@ try
#
if ($IsNotSkipped)
{
$endpointName = "PowerShell.$($psversiontable.GitCommitId)"
$endpointName = "PowerShell.$($PSVersionTable.GitCommitId)"
$matchedEndpoint = Get-PSSessionConfiguration $endpointName -ErrorAction SilentlyContinue
@ -255,7 +255,7 @@ try
It "$Description" {
$Result = [PSObject] @{Output = $true ; Error = $null}
$Error.Clear()
$error.Clear()
try
{
$null = Unregister-PSSessionConfiguration -name $SessionConfigName -ErrorAction stop
@ -700,12 +700,12 @@ namespace PowershellTestConfigNamespace
FunctionDefinitions=@(
@{
Name = "sysmodules";
ScriptBlock = 'pushd $pshome\Modules';
ScriptBlock = 'pushd $PSHOME\Modules';
Options = "AllScope";
},
@{
Name = "mymodules";
ScriptBlock = 'pushd $home\Documents\WindowsPowerShell\Modules';
ScriptBlock = 'pushd $HOME\Documents\WindowsPowerShell\Modules';
Options = "ReadOnly";
}
)

View file

@ -329,7 +329,7 @@ Describe "Remove-Module : module is readOnly | Constant" -Tags "CI" {
Describe "Remove-Module : module provides the PSDrive for current PS Session" -Tags "CI" {
It "Remove-Module : module provides the PSDrive for current PS Session" {
$module = Get-Module (Join-Path $PSHome "System.Management.Automation.dll") -ListAvailable
$module = Get-Module (Join-Path $PSHOME "System.Management.Automation.dll") -ListAvailable
{ Remove-Module $module -ErrorAction Stop } | Should -Throw -ErrorId "InvalidOperation,Microsoft.PowerShell.Commands.RemoveModuleCommand"
}
}

View file

@ -3,7 +3,7 @@
Describe "Clear-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') {
BeforeAll {
$defaultParamValues = $PSdefaultParameterValues.Clone()
$defaultParamValues = $PSDefaultParameterValues.Clone()
$PSDefaultParameterValues["it:skip"] = !$IsWindows -or $IsCoreCLR
}
@ -11,7 +11,7 @@ Describe "Clear-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') {
$global:PSDefaultParameterValues = $defaultParamValues
}
It "should be able to Clear-EventLog" -Pending:($True) {
It "should be able to Clear-EventLog" -Pending:($true) {
Remove-EventLog -LogName TestLog -ErrorAction Ignore
{ New-EventLog -LogName TestLog -Source TestSource -ErrorAction Stop } | Should -Not -Throw
{ Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventID 1 -ErrorAction Stop } | Should -Not -Throw
@ -24,11 +24,11 @@ Describe "Clear-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') {
{ Remove-EventLog -LogName TestLog -ErrorAction Stop } | Should -Not -Throw
}
It "should throw 'System.InvalidOperationException' when asked to clear a log that does not exist" -Pending:($True) {
It "should throw 'System.InvalidOperationException' when asked to clear a log that does not exist" -Pending:($true) {
{ Clear-EventLog -LogName MissingTestLog -ErrorAction Stop } | Should -Throw -ExceptionType "System.InvalidOperationException"
}
It "should throw 'Microsoft.PowerShell.Commands.ClearEventLogCommand' ErrorId when asked to clear a log that does not exist" -Pending:($True) {
It "should throw 'Microsoft.PowerShell.Commands.ClearEventLogCommand' ErrorId when asked to clear a log that does not exist" -Pending:($true) {
{ Clear-EventLog -LogName MissingTestLog -ErrorAction Stop } | Should -Throw -ErrorId "Microsoft.PowerShell.Commands.ClearEventLogCommand"
}
}

View file

@ -8,7 +8,7 @@ Describe 'Clipboard cmdlet tests' -Tag CI {
Context 'Text' {
BeforeAll {
$defaultParamValues = $PSdefaultParameterValues.Clone()
$defaultParamValues = $PSDefaultParameterValues.Clone()
$PSDefaultParameterValues["it:skip"] = ($IsWindows -and $env:PROCESSOR_ARCHITECTURE.Contains("arm")) -or ($IsLinux -and $xclip -eq $null)
}

View file

@ -104,7 +104,7 @@ Describe "Basic FileSystem Provider Tests" -Tags "CI" {
It "Verify Rename-Item will not rename to an existing name" {
{ Rename-Item -Path $testFile -NewName $testDir -ErrorAction Stop } | Should -Throw -ErrorId "RenameItemIOError,Microsoft.PowerShell.Commands.RenameItemCommand"
$Error[0].Exception | Should -BeOfType System.IO.IOException
$error[0].Exception | Should -BeOfType System.IO.IOException
$testFile | Should -Exist
}
@ -133,7 +133,7 @@ Describe "Basic FileSystem Provider Tests" -Tags "CI" {
It "Verify Move-Item will not move to an existing file" {
{ Move-Item -Path $testDir -Destination $testFile -ErrorAction Stop } | Should -Throw -ErrorId "MoveDirectoryItemIOError,Microsoft.PowerShell.Commands.MoveItemCommand"
$Error[0].Exception | Should -BeOfType System.IO.IOException
$error[0].Exception | Should -BeOfType System.IO.IOException
$testDir | Should -Exist
}
@ -748,8 +748,8 @@ Describe "Copy-Item can avoid copying an item onto itself" -Tags "CI", "RequireA
else
{
{ Copy-Item -Path $sourcePath -Destination $destinationPath -ErrorAction Stop } | Should -Throw -ErrorId "CopyError,Microsoft.PowerShell.Commands.CopyItemCommand"
$Error[0].Exception | Should -BeOfType System.IO.IOException
$Error[0].Exception.Data[$selfCopyKey] | Should -Not -BeNullOrEmpty
$error[0].Exception | Should -BeOfType System.IO.IOException
$error[0].Exception.Data[$selfCopyKey] | Should -Not -BeNullOrEmpty
}
}
}
@ -811,8 +811,8 @@ Describe "Copy-Item can avoid copying an item onto itself" -Tags "CI", "RequireA
)
{ Copy-Item -Path $Source -Destination $Destination -ErrorAction Stop } | Should -Throw -ErrorId "CopyError,Microsoft.PowerShell.Commands.CopyItemCommand"
$Error[0].Exception | Should -BeOfType System.IO.IOException
$Error[0].Exception.Data[$selfCopyKey] | Should -Not -BeNullOrEmpty
$error[0].Exception | Should -BeOfType System.IO.IOException
$error[0].Exception.Data[$selfCopyKey] | Should -Not -BeNullOrEmpty
}
}

View file

@ -196,7 +196,7 @@ baz
Set-Content -Path $testPath $testContent
$result = Get-Content @GetContentParams
$result.Length | Should -Be $expectedLength
if ($isWindows) {
if ($IsWindows) {
$result | Should -BeExactly $expectedWindowsContent
} else {
$result | Should -BeExactly $expectedNotWindowsContent

View file

@ -3,7 +3,7 @@
Describe "Get-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') {
BeforeAll {
$defaultParamValues = $PSdefaultParameterValues.Clone()
$defaultParamValues = $PSDefaultParameterValues.Clone()
$PSDefaultParameterValues["it:skip"] = !$IsWindows -or $IsCoreCLR
}
@ -11,15 +11,15 @@ Describe "Get-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') {
$global:PSDefaultParameterValues = $defaultParamValues
}
#CmdLets are not yet implemented, so these cases are -Pending:($True) for now...
It "should return an array of eventlogs objects when called with -AsString parameter" -Pending:($True) {
#CmdLets are not yet implemented, so these cases are -Pending:($true) for now...
It "should return an array of eventlogs objects when called with -AsString parameter" -Pending:($true) {
{ $result=Get-EventLog -AsString -ErrorAction Stop } | Should -Not -Throw
$result | Should -Not -BeNullOrEmpty
,$result | Should -BeOfType "System.Array"
$result | Should -BeExactly "Application"
$result.Count | Should -BeGreaterThan 3
}
It "should return a list of eventlog objects when called with -List parameter" -Pending:($True) {
It "should return a list of eventlog objects when called with -List parameter" -Pending:($true) {
{ $result=Get-EventLog -List -ErrorAction Stop } | Should -Not -Throw
$result | Should -Not -BeNullOrEmpty
,$result | Should -BeOfType "System.Array"
@ -27,22 +27,22 @@ Describe "Get-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') {
$logs | Should -BeExactly "System"
$logs.Count | Should -BeGreaterThan 3
}
It "should be able to Get-EventLog -LogName Application -Newest 100" -Pending:($True) {
It "should be able to Get-EventLog -LogName Application -Newest 100" -Pending:($true) {
{ $result=get-eventlog -LogName Application -Newest 100 -ErrorAction Stop } | Should -Not -Throw
$result | Should -Not -BeNullOrEmpty
$result.Length | Should -BeLessThan 100
$result[0] | Should -BeOfType "EventLogEntry"
}
It "should throw 'AmbiguousParameterSetException' when called with both -LogName and -List parameters" -Pending:($True) {
It "should throw 'AmbiguousParameterSetException' when called with both -LogName and -List parameters" -Pending:($true) {
{ Get-EventLog -LogName System -List -ErrorAction Stop } | Should -Throw -ErrorId "AmbiguousParameterSet,Microsoft.PowerShell.Commands.GetEventLogCommand"
}
It "should be able to Get-EventLog -LogName * with multiple matches" -Pending:($True) {
It "should be able to Get-EventLog -LogName * with multiple matches" -Pending:($true) {
{ $result=get-eventlog -LogName * -ErrorAction Stop } | Should -Not -Throw
$result | Should -Not -BeNullOrEmpty
$result | Should -BeExactly "Security"
$result.Count | Should -BeGreaterThan 3
}
It "should throw 'InvalidOperationException' when asked to get a log that does not exist" -Pending:($True) {
It "should throw 'InvalidOperationException' when asked to get a log that does not exist" -Pending:($true) {
{ Get-EventLog -LogName MissingTestLog -ErrorAction Stop } | Should -Throw -ErrorId "System.InvalidOperationException,Microsoft.PowerShell.Commands.GetEventLogCommand"
}
}

View file

@ -2,11 +2,11 @@
# Licensed under the MIT License.
Describe "Get-Process for admin" -Tags @('CI', 'RequireAdminOnWindows') {
It "Should support -IncludeUserName" {
(Get-Process -Id $pid -IncludeUserName).UserName | Should -Match $env:USERNAME
(Get-Process -Id $PID -IncludeUserName).UserName | Should -Match $env:USERNAME
}
It "Should support -Module" -Pending:$IsMacOS {
$modules = Get-Process -Id $pid -Module
$modules = Get-Process -Id $PID -Module
$modules.GetType() | Should -BeExactly "System.Object[]"
foreach ($module in $modules) {
$module.GetType() | Should -BeExactly "System.Diagnostics.ProcessModule"
@ -14,7 +14,7 @@ Describe "Get-Process for admin" -Tags @('CI', 'RequireAdminOnWindows') {
}
It "Should support -FileVersionInfo" {
$pwshVersion = Get-Process -Id $pid -FileVersionInfo
$pwshVersion = Get-Process -Id $PID -FileVersionInfo
if ($IsWindows) {
$pwshVersion.FileVersion | Should -Match $PSVersionTable.PSVersion.ToString().Split("-")[0]
$pwshVersion.FileMajorPart | Should -BeExactly $PSVersionTable.PSVersion.Major
@ -71,11 +71,11 @@ Describe "Get-Process" -Tags "CI" {
}
It "Test for process property = Name" {
(Get-Process -Id $pid).Name | Should -BeExactly "pwsh"
(Get-Process -Id $PID).Name | Should -BeExactly "pwsh"
}
It "Test for process property = Id" {
(Get-Process -Id $pid).Id | Should -BeExactly $pid
(Get-Process -Id $PID).Id | Should -BeExactly $PID
}
It "Should fail to run Get-Process with -IncludeUserName without admin" -Skip:(!$IsWindows) {
@ -119,12 +119,12 @@ Describe "Get-Process Formatting" -Tags "Feature" {
Describe "Process Parent property" -Tags "CI" {
It "Has Parent process property" {
$powershellexe = (get-process -id $PID).mainmodule.filename
& $powershellexe -noprofile -command '(Get-Process -Id $pid).Parent' | Should -Not -BeNullOrEmpty
& $powershellexe -noprofile -command '(Get-Process -Id $PID).Parent' | Should -Not -BeNullOrEmpty
}
It "Has valid parent process ID property" {
$powershellexe = (get-process -id $PID).mainmodule.filename
& $powershellexe -noprofile -command '(Get-Process -Id $pid).Parent.Id' | Should -Be $pid
& $powershellexe -noprofile -command '(Get-Process -Id $PID).Parent.Id' | Should -Be $PID
}
}

View file

@ -3,7 +3,7 @@
Describe "New-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') {
BeforeAll {
$defaultParamValues = $PSdefaultParameterValues.Clone()
$defaultParamValues = $PSDefaultParameterValues.Clone()
$IsNotSkipped = ($IsWindows -and !$IsCoreCLR)
$PSDefaultParameterValues["it:skip"] = !$IsNotSkipped
}
@ -18,34 +18,34 @@ Describe "New-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') {
}
}
It "should be able to create a New-EventLog with a -Source parameter" -Skip:($True) {
It "should be able to create a New-EventLog with a -Source parameter" -Skip:($true) {
{New-EventLog -LogName TestLog -Source TestSource -ErrorAction Stop} | Should -Not -Throw
{Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventID 1 -ErrorAction Stop} | Should -Not -Throw
$result=Get-EventLog -LogName TestLog
$result.Count | Should -Be 1
}
It "should be able to create a New-EventLog with a -ComputerName parameter" -Skip:($True) {
It "should be able to create a New-EventLog with a -ComputerName parameter" -Skip:($true) {
{New-EventLog -LogName TestLog -Source TestSource -ComputerName $env:COMPUTERNAME -ErrorAction Stop} | Should -Not -Throw
{Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventID 1 -ErrorAction Stop} | Should -Not -Throw
$result=Get-EventLog -LogName TestLog
$result.Count | Should -Be 1
$result.EventID | Should -Be 1
}
It "should be able to create a New-EventLog with a -CategoryResourceFile parameter" -Skip:($True) {
It "should be able to create a New-EventLog with a -CategoryResourceFile parameter" -Skip:($true) {
{New-EventLog -LogName TestLog -Source TestSource -CategoryResourceFile "CategoryMessageFile" -ErrorAction Stop} | Should -Not -Throw
{Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventID 2 -ErrorAction Stop} | Should -Not -Throw
$result=Get-EventLog -LogName TestLog
$result.Count | Should -Be 1
$result.EventID | Should -Be 2
}
It "should be able to create a New-EventLog with a -MessageResourceFile parameter" -Skip:($True) {
It "should be able to create a New-EventLog with a -MessageResourceFile parameter" -Skip:($true) {
{New-EventLog -LogName TestLog -Source TestSource -MessageResourceFile "ResourceMessageFile" -ErrorAction Stop} | Should -Not -Throw
{Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventID 3 -ErrorAction Stop} | Should -Not -Throw
$result=Get-EventLog -LogName TestLog
$result.Count | Should -Be 1
$result.EventID | Should -Be 3
}
It "should be able to create a New-EventLog with a -ParameterResourceFile parameter" -Skip:($True) {
It "should be able to create a New-EventLog with a -ParameterResourceFile parameter" -Skip:($true) {
{New-EventLog -LogName TestLog -Source TestSource -ParameterResourceFile "ParameterMessageFile" -ErrorAction Stop} | Should -Not -Throw
{Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventID 4 -ErrorAction Stop} | Should -Not -Throw
$result=Get-EventLog -LogName TestLog

View file

@ -2,7 +2,7 @@
# Licensed under the MIT License.
try {
#skip all tests on non-windows platform
$defaultParamValues = $PSdefaultParameterValues.Clone()
$defaultParamValues = $PSDefaultParameterValues.Clone()
$PSDefaultParameterValues["it:skip"] = !$IsWindows
Describe "Basic Registry Provider Tests" -Tags @("CI", "RequireAdminOnWindows") {

View file

@ -3,7 +3,7 @@
Describe "New-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') {
BeforeAll {
$defaultParamValues = $PSdefaultParameterValues.Clone()
$defaultParamValues = $PSDefaultParameterValues.Clone()
$IsNotSkipped = ($IsWindows -and !$IsCoreCLR)
$PSDefaultParameterValues["it:skip"] = !$IsNotSkipped
}
@ -20,13 +20,13 @@ Describe "New-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') {
}
}
#CmdLet is NYI - change to -Skip:($NonWinAdmin) when implemented
It "should be able to Remove-EventLog -LogName <string> -ComputerName <string>" -Pending:($True) {
It "should be able to Remove-EventLog -LogName <string> -ComputerName <string>" -Pending:($true) {
{ Remove-EventLog -LogName TestLog -ComputerName $env:COMPUTERNAME -ErrorAction Stop } | Should -Not -Throw
{ Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventID 1 -ErrorAction Stop } | Should -Throw -ErrorId "Microsoft.PowerShell.Commands.WriteEventLogCommand"
{ Get-EventLog -LogName TestLog -ErrorAction Stop } | Should -Throw -ErrorId "System.InvalidOperationException,Microsoft.PowerShell.Commands.GetEventLogCommand"
}
#CmdLet is NYI - change to -Skip:($NonWinAdmin) when implemented
It "should be able to Remove-EventLog -Source <string> -ComputerName <string>" -Pending:($True) {
It "should be able to Remove-EventLog -Source <string> -ComputerName <string>" -Pending:($true) {
{Remove-EventLog -Source TestSource -ComputerName $env:COMPUTERNAME -ErrorAction Stop} | Should -Not -Throw
{ Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventID 1 -ErrorAction Stop } | Should -Throw -ErrorId "Microsoft.PowerShell.Commands.WriteEventLogCommand"
{ Get-EventLog -LogName TestLog -ErrorAction Stop; } | Should -Throw -ErrorId "System.InvalidOperationException,Microsoft.PowerShell.Commands.GetEventLogCommand"

View file

@ -202,7 +202,7 @@ Describe "Set-Location" -Tags "CI" {
}
It 'The LocationChangedAction should fire when changing location' {
$initialPath = $pwd
$initialPath = $PWD
$oldPath = $null
$newPath = $null
$eventSessionState = $null
@ -214,7 +214,7 @@ Describe "Set-Location" -Tags "CI" {
(Get-Variable newPath).Value = $_.newPath
}
Set-Location ..
$newPath.Path | Should -Be $pwd.Path
$newPath.Path | Should -Be $PWD.Path
$oldPath.Path | Should -Be $initialPath.Path
$eventSessionState | Should -Be $ExecutionContext.SessionState
$eventRunspace | Should -Be ([runspace]::DefaultRunspace)

View file

@ -82,7 +82,7 @@ Describe "Set/New/Remove-Service cmdlet tests" -Tags "Feature", "RequireAdminOnW
param($parameter, $value, $script, $expectedNull)
$setServiceCommand = [Microsoft.PowerShell.Commands.SetServiceCommand]::new()
if ($script -ne $Null) {
if ($script -ne $null) {
$value = & $script
}
$setServiceCommand.$parameter = $value

View file

@ -64,10 +64,10 @@ Describe "Test-Connection" -tags "CI" {
{ $result = Test-Connection "fakeHost" -Count 1 -Quiet -ErrorAction Stop } |
Should -Throw -ErrorId "TestConnectionException,Microsoft.PowerShell.Commands.TestConnectionCommand"
# Error code = 11001 - Host not found.
if (!$isWindows) {
$Error[0].Exception.InnerException.ErrorCode | Should -Be -131073
if (!$IsWindows) {
$error[0].Exception.InnerException.ErrorCode | Should -Be -131073
} else {
$Error[0].Exception.InnerException.ErrorCode | Should -Be 11001
$error[0].Exception.InnerException.ErrorCode | Should -Be 11001
}
}
@ -77,7 +77,7 @@ Describe "Test-Connection" -tags "CI" {
$result[0].Address | Should -BeExactly $realAddress
$result[0].Reply.Options.Ttl | Should -BeLessOrEqual 128
if ($isWindows) {
if ($IsWindows) {
$result[0].Reply.Options.DontFragment | Should -BeFalse
}
}
@ -94,7 +94,7 @@ Describe "Test-Connection" -tags "CI" {
$result1.Address | Should -BeExactly $realAddress
$result1.Reply.Options.Ttl | Should -BeLessOrEqual 128
if (!$isWindows) {
if (!$IsWindows) {
$result1.Reply.Options.DontFragment | Should -BeFalse
# Depending on the network configuration any of the following should be returned
$result2.Status | Should -BeIn "TtlExpired", "TimedOut", "Success"
@ -216,7 +216,7 @@ Describe "Test-Connection" -tags "CI" {
$pingResults.Count | Should -BeGreaterThan 4
$pingResults[0].Address | Should -BeExactly $targetAddress
$pingResults.Status | Should -Contain "Success"
if ($isWindows) {
if ($IsWindows) {
$pingResults.Where( { $_.Status -eq 'Success' }, 'Default', 1 ).BufferSize | Should -Be 32
}
}
@ -254,7 +254,7 @@ Describe "Test-Connection" -tags "CI" {
$result[0].Hop | Should -Be 1
$result[0].HopAddress | Should -BeExactly $realAddress
$result[0].Status | Should -BeExactly "Success"
if (!$isWindows) {
if (!$IsWindows) {
$result[0].Reply.Buffer.Count | Should -Match '^0$|^32$'
} else {
$result[0].Reply.Buffer.Count | Should -Be 32

View file

@ -30,7 +30,7 @@ Describe "Get-Timezone test cases" -Tags "CI" {
BeforeAll {
$TimeZonesAvailable = [System.TimeZoneInfo]::GetSystemTimeZones()
$defaultParamValues = $PSdefaultParameterValues.Clone()
$defaultParamValues = $PSDefaultParameterValues.Clone()
$PSDefaultParameterValues["it:skip"] = ($TimeZonesAvailable.Count -eq 0)
}
@ -127,7 +127,7 @@ Describe "Get-Timezone test cases" -Tags "CI" {
}
try {
$defaultParamValues = $PSdefaultParameterValues.Clone()
$defaultParamValues = $PSDefaultParameterValues.Clone()
$PSDefaultParameterValues["it:skip"] = !$IsWindows
Describe "Set-Timezone test case: call by single Id" -Tags @('CI', 'RequireAdminOnWindows') {

View file

@ -1,4 +1,4 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
try

View file

@ -86,8 +86,8 @@ Describe "CmsMessage cmdlets thorough tests" -Tags "Feature" {
else
{
# Skip for non-Windows platforms
$defaultParamValues = $PSdefaultParameterValues.Clone()
$PSdefaultParameterValues = @{ "it:skip" = $true }
$defaultParamValues = $PSDefaultParameterValues.Clone()
$PSDefaultParameterValues = @{ "it:skip" = $true }
}
}
@ -161,7 +161,7 @@ Describe "CmsMessage cmdlets thorough tests" -Tags "Feature" {
$errors = $null
$recipient = [System.Management.Automation.CmsMessageRecipient] $protectedEventLoggingCertPath
$recipient.Resolve($executionContext.SessionState, "Decryption", [ref] $errors)
$recipient.Resolve($ExecutionContext.SessionState, "Decryption", [ref] $errors)
$recipient.Certificates.Count | Should -Be 1
}
@ -327,9 +327,9 @@ Describe "CmsMessage cmdlets thorough tests" -Tags "Feature" {
}
It "Verify protect message using OutString" {
$protected = Get-Process -Id $pid | Protect-CmsMessage -To (Get-GoodCertificateLocation)
$protected = Get-Process -Id $PID | Protect-CmsMessage -To (Get-GoodCertificateLocation)
$decrypted = $protected | Unprotect-CmsMessage -To (Get-GoodCertificateLocation)
# Should have had PID in output
$decrypted | Should -Match $pid
$decrypted | Should -Match $PID
}
}

View file

@ -1,4 +1,4 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
##

View file

@ -1,4 +1,4 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
##

View file

@ -470,7 +470,7 @@ try
BeforeAll {
function VulnerableFunctionFromFullLanguage { Invoke-Expression $Args[0] }
function VulnerableFunctionFromFullLanguage { Invoke-Expression $args[0] }
$TestCasesIEX = @(
@{testName = "Verifies direct Invoke-Expression does not bypass constrained language mode";

View file

@ -1,4 +1,4 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
##

View file

@ -100,8 +100,8 @@ try {
$LocalSignatureCorruptedScript = Join-Path -Path $remoteTestDirectory -ChildPath LocalSignatureCorruptedScript.ps1
$LocalSignedScript = Join-Path -Path $remoteTestDirectory -ChildPath LocalSignedScript.ps1
$LocalUnsignedScript = Join-Path -Path $remoteTestDirectory -ChildPath LocalUnsignedScript.ps1
$PSHomeUnsignedModule = Join-Path -Path $PSHome -ChildPath 'Modules' -AdditionalChildPath 'LocalUnsignedModule', 'LocalUnsignedModule.psm1'
$PSHomeUntrustedModule = Join-Path -Path $PSHome -ChildPath 'Modules' -AdditionalChildPath 'LocalUntrustedModule', 'LocalUntrustedModule.psm1'
$PSHomeUnsignedModule = Join-Path -Path $PSHOME -ChildPath 'Modules' -AdditionalChildPath 'LocalUnsignedModule', 'LocalUnsignedModule.psm1'
$PSHomeUntrustedModule = Join-Path -Path $PSHOME -ChildPath 'Modules' -AdditionalChildPath 'LocalUntrustedModule', 'LocalUntrustedModule.psm1'
$TrustedSignatureCorruptedScript = Join-Path -Path $remoteTestDirectory -ChildPath TrustedSignatureCorruptedScript.ps1
$TrustedSignedScript = Join-Path -Path $remoteTestDirectory -ChildPath TrustedSignedScript.ps1
$TrustedUnsignedScript = Join-Path -Path $remoteTestDirectory -ChildPath TrustedUnsignedScript.ps1

View file

@ -5,7 +5,7 @@
try {
#skip all tests on non-windows platform
$defaultParamValues = $PSdefaultParameterValues.Clone()
$defaultParamValues = $PSDefaultParameterValues.Clone()
$PSDefaultParameterValues["it:skip"] = !$IsWindows
$script:catalogPath = ""

View file

@ -101,8 +101,8 @@ Describe 'ForEach-Object -Parallel Basic Tests' -Tags 'CI' {
}
It 'Verifies that the current working directory is preserved' {
$parallelScriptLocation = 1..1 | ForEach-Object -Parallel { $pwd }
$parallelScriptLocation.Path | Should -BeExactly $pwd.Path
$parallelScriptLocation = 1..1 | ForEach-Object -Parallel { $PWD }
$parallelScriptLocation.Path | Should -BeExactly $PWD.Path
}
}
@ -307,10 +307,10 @@ Describe 'ForEach-Object -Parallel -AsJob Basic Tests' -Tags 'CI' {
}
It 'Verifies that the current working directory is preserved' {
$job = 1..1 | ForEach-Object -AsJob -Parallel { $pwd }
$job = 1..1 | ForEach-Object -AsJob -Parallel { $PWD }
$parallelScriptLocation = $job | Wait-Job | Receive-Job
$job | Remove-Job
$parallelScriptLocation.Path | Should -BeExactly $pwd.Path
$parallelScriptLocation.Path | Should -BeExactly $PWD.Path
}
}

View file

@ -7,14 +7,14 @@ Describe "Get-Culture" -Tags "CI" {
$culture = Get-Culture
$culture | Should -BeOfType [CultureInfo]
($culture).EnglishName | Should -BeExactly $host.CurrentCulture.EnglishName
($culture).EnglishName | Should -BeExactly $Host.CurrentCulture.EnglishName
Get-Culture -NoUserOverrides | Should -BeOfType [CultureInfo]
}
It "Should have (Get-Culture).Name variable be equivalent to `$PSCulture" {
(Get-Culture).Name | Should -BeExactly $PsCulture
(Get-Culture).Name | Should -BeExactly $PSCulture
}
It "Should return the specified culture with '-Name' parameter" {

View file

@ -28,7 +28,7 @@ Describe "Get-Date DRT Unit Tests" -Tags "CI" {
$seconds = Get-date -Date:"Jan 1, 2020Z" -UFormat:"%s"
$seconds | Should -Be "1577836800"
if ($isLinux) {
if ($IsLinux) {
$dateString = "01/01/2020 UTC"
if ( (Get-PlatformInfo) -eq "alpine" ) {
$dateString = "2020-01-01"

View file

@ -2,7 +2,7 @@
# Licensed under the MIT License.
Describe 'Get-Error tests' -Tag CI {
It 'Get-Error resolves $Error[0] and includes InnerException' {
It 'Get-Error resolves $error[0] and includes InnerException' {
try {
1/0
}
@ -103,7 +103,7 @@ Describe 'Get-Error tests' -Tag CI {
$null = Get-Error
$Error[0].pstypenames | Should -Be System.Management.Automation.ErrorRecord, System.Object
$error[0].pstypenames | Should -Be System.Management.Automation.ErrorRecord, System.Object
}
It 'Get-Error adds ExceptionType for Exceptions' {

View file

@ -24,7 +24,7 @@ Describe "Get-FileHash" -Tags "CI" {
}
It "Should write non-terminating error if argument is a folder" {
$result = $pshome, "${pshome}\pwsh.dll" | Get-FileHash -ErrorVariable errorVariable
$result = $PSHOME, "${pshome}\pwsh.dll" | Get-FileHash -ErrorVariable errorVariable
$result.Count | Should -Be 1
$errorVariable.FullyQualifiedErrorId | Should -BeExactly "UnauthorizedAccessError,Microsoft.PowerShell.Commands.GetFileHashCommand"
}

View file

@ -3,7 +3,7 @@
Describe "Get-UICulture" -Tags "CI" {
It "Should have $ PsUICulture variable be equivalent to Get-UICulture object" {
$result = Get-UICulture
$result.Name | Should -Be $PsUICulture
$result.Name | Should -Be $PSUICulture
$result | Should -BeOfType CultureInfo
}
}

View file

@ -354,7 +354,7 @@ try
}
It "Verifies that proxy returns remote pid" {
(Get-Variable -Name pid).Value | Should -Not -Be $pid
(Get-Variable -Name pid).Value | Should -Not -Be $PID
}
It "Verfies Remove-Module doesn't remove user's runspace" {
@ -762,15 +762,15 @@ try
}
It "proxy should return remote pid" {
(Get-VariableProxy -Name:pid).Value | Should -Not -Be $pid
(Get-VariableProxy -Name:pid).Value | Should -Not -Be $PID
}
It "proxy should return remote pid" {
(Get-Variable -Name:pid).Value | Should -Not -Be $pid
(Get-Variable -Name:pid).Value | Should -Not -Be $PID
}
It "proxy should return remote pid" {
$(& (Get-Command gvalias -Type alias) -Name:pid).Value | Should -Not -Be $pid
$(& (Get-Command gvalias -Type alias) -Name:pid).Value | Should -Not -Be $PID
}
It "NoName-c8aeb5c8-2388-4d64-98c1-a9c6c218d404" {
@ -857,7 +857,7 @@ try
$ipaddress
)
"Bound parameter: $($myInvocation.BoundParameters.Keys | Sort-Object)"
"Bound parameter: $($MyInvocation.BoundParameters.Keys | Sort-Object)"
}
}
@ -898,7 +898,7 @@ try
$ipaddress
)
"Bound parameter: $($myInvocation.BoundParameters.Keys)"
"Bound parameter: $($MyInvocation.BoundParameters.Keys)"
}
}
@ -939,7 +939,7 @@ try
$ipaddress
)
"Bound parameter: $($myInvocation.BoundParameters.Keys | Sort-Object)"
"Bound parameter: $($MyInvocation.BoundParameters.Keys | Sort-Object)"
}
}
@ -990,14 +990,14 @@ try
$PriorityClass
)
"Bound parameter: $($myInvocation.BoundParameters.Keys | Sort-Object)"
"Bound parameter: $($MyInvocation.BoundParameters.Keys | Sort-Object)"
}
}
# Sanity checks.
Invoke-Command $session {Get-Process -pid $pid | foo} | Should -BeExactly "Bound parameter: PriorityClass TotalProcessorTime"
Invoke-Command $session {Get-Process -pid $pid | foo -Total 5} | Should -BeExactly "Bound parameter: PriorityClass TotalProcessorTime"
Invoke-Command $session {Get-Process -pid $pid | foo -Priority normal} | Should -BeExactly "Bound parameter: PriorityClass TotalProcessorTime"
Invoke-Command $session {Get-Process -pid $PID | foo} | Should -BeExactly "Bound parameter: PriorityClass TotalProcessorTime"
Invoke-Command $session {Get-Process -pid $PID | foo -Total 5} | Should -BeExactly "Bound parameter: PriorityClass TotalProcessorTime"
Invoke-Command $session {Get-Process -pid $PID | foo -Priority normal} | Should -BeExactly "Bound parameter: PriorityClass TotalProcessorTime"
$module = Import-PSSession $session foo -AllowClobber
}
@ -1008,15 +1008,15 @@ try
}
It "Pipeline binding works by property name" {
(Get-Process -id $pid | foo) | Should -BeExactly "Bound parameter: PriorityClass TotalProcessorTime"
(Get-Process -id $PID | foo) | Should -BeExactly "Bound parameter: PriorityClass TotalProcessorTime"
}
It "Pipeline binding works by property name" {
(Get-Process -id $pid | foo -Total 5) | Should -BeExactly "Bound parameter: PriorityClass TotalProcessorTime"
(Get-Process -id $PID | foo -Total 5) | Should -BeExactly "Bound parameter: PriorityClass TotalProcessorTime"
}
It "Pipeline binding works by property name" {
(Get-Process -id $pid | foo -Priority normal) | Should -BeExactly "Bound parameter: PriorityClass TotalProcessorTime"
(Get-Process -id $PID | foo -Priority normal) | Should -BeExactly "Bound parameter: PriorityClass TotalProcessorTime"
}
}
@ -1036,7 +1036,7 @@ try
$ipaddress
)
"Bound parameter: $($myInvocation.BoundParameters.Keys | Sort-Object)"
"Bound parameter: $($MyInvocation.BoundParameters.Keys | Sort-Object)"
}
}
@ -1860,11 +1860,11 @@ try
}
It "Removing a module should clean-up event handlers (Windows 7: #268819)" {
$oldNumberOfHandlers = $executionContext.GetType().GetProperty("Events").GetValue($executionContext, $null).Subscribers.Count
$oldNumberOfHandlers = $ExecutionContext.GetType().GetProperty("Events").GetValue($ExecutionContext, $null).Subscribers.Count
$module = Import-PSSession -Session $session -Name Get-Random -AllowClobber
Remove-Module $module -Force
$newNumberOfHandlers = $executionContext.GetType().GetProperty("Events").GetValue($executionContext, $null).Subscribers.Count
$newNumberOfHandlers = $ExecutionContext.GetType().GetProperty("Events").GetValue($ExecutionContext, $null).Subscribers.Count
## Event should be unregistered when the module is removed
$oldNumberOfHandlers | Should -Be $newNumberOfHandlers

View file

@ -25,13 +25,13 @@ Describe "Join-String" -Tags "CI" {
}
It "Should join property values with default separator" {
$expected = $testObject.Name -join $ofs
$expected = $testObject.Name -join $OFS
$actual = $testObject | Join-String -Property Name
$actual | Should -BeExactly $expected
}
It "Should join property values positionally with default separator" {
$expected = $testObject.Name -join $ofs
$expected = $testObject.Name -join $OFS
$actual = $testObject | Join-String Name
$actual | Should -BeExactly $expected
}
@ -69,7 +69,7 @@ Describe "Join-String" -Tags "CI" {
It "Should join script block results with default separator" {
$sb = {$_.Name + $_.Length}
$expected = ($testObject | ForEach-Object $sb) -join $ofs
$expected = ($testObject | ForEach-Object $sb) -join $OFS
$actual = $testObject | Join-String -Property $sb
$actual | Should -BeExactly $expected
}
@ -83,13 +83,13 @@ Describe "Join-String" -Tags "CI" {
It "Should join script block results SingleQuoted" {
$sb = {$_.Name + $_.Length}
$expected = ($testObject | ForEach-Object $sb).ForEach{"'$_'"} -join $ofs
$expected = ($testObject | ForEach-Object $sb).ForEach{"'$_'"} -join $OFS
$actual = $testObject | Join-String -Property $sb -SingleQuote
$actual | Should -BeExactly $expected
}
It "Should join script block results DoubleQuoted" {
$sb = {$_.Name + $_.Length}
$expected = ($testObject | ForEach-Object $sb).ForEach{"""$_"""} -join $ofs
$expected = ($testObject | ForEach-Object $sb).ForEach{"""$_"""} -join $OFS
$actual = $testObject | Join-String -Property $sb -DoubleQuote
$actual | Should -BeExactly $expected
}
@ -102,7 +102,7 @@ Describe "Join-String" -Tags "CI" {
}
It "Should Handle OutputPrefix and OutputSuffix" {
$ofs = ','
$OFS = ','
$expected = "A 1,2,3 B"
$actual = 1..3 | Join-String -OutputPrefix "A " -OutputSuffix " B"
$actual | Should -BeExactly $expected

View file

@ -2,7 +2,7 @@
# Licensed under the MIT License.
Describe "New-Object" -Tags "CI" {
It "Support 'ComObject' parameter on platforms" {
if ($IsLinux -or $IsMacOs ) {
if ($IsLinux -or $IsMacOS ) {
{ New-Object -ComObject "Shell.Application" } | Should -Throw -ErrorId "NamedParameterNotFound,Microsoft.PowerShell.Commands.NewObjectCommand"
} else {
# It works on NanoServer and IoT too
@ -133,7 +133,7 @@ Describe "New-Object DRT basic functionality" -Tags "CI" {
try
{
$defaultParamValues = $PSdefaultParameterValues.Clone()
$defaultParamValues = $PSDefaultParameterValues.Clone()
$PSDefaultParameterValues["it:skip"] = ![System.Management.Automation.Platform]::IsWindowsDesktop
Describe "New-Object COM functionality" -Tags "CI" {

View file

@ -346,7 +346,7 @@ Describe "Select-Object with Property = '*'" -Tags "CI" {
}
It "Select-Object with ExpandProperty and Property don't skip processing ExcludeProperty" {
$p = Get-Process -Id $pid | Select-Object -Property Process* -ExcludeProperty ProcessorAffinity -ExpandProperty Modules
$p = Get-Process -Id $PID | Select-Object -Property Process* -ExcludeProperty ProcessorAffinity -ExpandProperty Modules
$p[0].psobject.Properties.Item("ProcessorAffinity") | Should -BeNullOrEmpty
}
}

View file

@ -4,7 +4,7 @@
Describe "Select-String" -Tags "CI" {
BeforeAll {
$nl = [Environment]::NewLine
$currentDirectory = $pwd.Path
$currentDirectory = $PWD.Path
}
AfterAll {

View file

@ -1,6 +1,6 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
$ps = Join-Path -Path $PsHome -ChildPath "pwsh"
$ps = Join-Path -Path $PSHOME -ChildPath "pwsh"
Describe "Set-PSBreakpoint DRT Unit Tests" -Tags "CI" {
#Set up

View file

@ -80,7 +80,7 @@ Describe "Trace-Command" -tags "CI" {
$log = Get-Content $logfile | Where-Object {$_ -like "*ProcessID=*"}
$results = $log | ForEach-Object {$_.Split("=")[1]}
$results | ForEach-Object { $_ | Should -Be $pid }
$results | ForEach-Object { $_ | Should -Be $PID }
}
}

View file

@ -75,7 +75,7 @@ Describe "Unblock-File" -Tags "CI" {
It "Write an error if a file is read only" {
$TestFile = Join-Path $TestDrive "testfileunlock.ps1"
Block-File -Path $TestFile
Set-ItemProperty -Path $TestFile -Name IsReadOnly -Value $True
Set-ItemProperty -Path $TestFile -Name IsReadOnly -Value $true
$TestFileCreated = Get-ChildItem $TestFile
$TestFileCreated.IsReadOnly | Should -BeTrue

View file

@ -1,4 +1,4 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# This is a Pester test suite which validate the Web cmdlets.

View file

@ -3,7 +3,7 @@
Describe "Write-Host with default Console Host" -Tags "Slow","Feature" {
BeforeAll {
$powershell = Join-Path -Path $PsHome -ChildPath "pwsh"
$powershell = Join-Path -Path $PSHOME -ChildPath "pwsh"
$testData = @(
@{ Name = '-Separator'; Command = "Write-Host a,b,c -Separator '+'"; returnCount = 1; returnValue = @("a+b+c") }

View file

@ -47,10 +47,10 @@ Describe "Stream writer tests" -Tags "CI" {
}
Context "Error automatic variable" {
It "Should write error messages to the `$Error automatic variable" {
It "Should write error messages to the `$error automatic variable" {
Write-Error "Test Error Message" -ErrorAction SilentlyContinue
$Error[0] | Should -Match "Test Error Message"
$error[0] | Should -Match "Test Error Message"
}
}
@ -80,7 +80,7 @@ Describe "Stream writer tests" -Tags "CI" {
# redirect the streams is sufficient
$result = Write-Information "Test Message" *>&1
$result.NativeThreadId | Should -Not -Be 0
$result.ProcessId | Should -Be $pid
$result.ProcessId | Should -Be $PID
$result | Should -BeOfType System.Management.Automation.InformationRecord
# Use Match instead of Be so we can avoid dealing with a potential domain name
@ -115,7 +115,7 @@ Describe "Stream writer tests" -Tags "CI" {
(Compare-Object $result $returnValue -SyncWindow 0).length | Should -Be 0
}
It "Write-Information accepts `$Null" {
It "Write-Information accepts `$null" {
$streamPath = Join-Path $testdrive information.txt
$null | Write-Information -Tags myTag -ErrorAction Stop -InformationAction SilentlyContinue -InformationVariable i
$i.Tags | Should -BeExactly "myTag"

View file

@ -106,7 +106,7 @@ Describe "XmlCommand DRT basic functionality Tests" -Tags "CI" {
It "Import-Clixml should work with XML serialization from pwsh.exe" {
# need to create separate process so that current powershell doesn't interpret clixml output
Start-Process -FilePath $pshome\pwsh -RedirectStandardOutput $testfile -Args "-noprofile -nologo -outputformat xml -command get-command import-clixml" -Wait
Start-Process -FilePath $PSHOME\pwsh -RedirectStandardOutput $testfile -Args "-noprofile -nologo -outputformat xml -command get-command import-clixml" -Wait
$out = Import-Clixml -Path $testfile
$out.Name | Should -Be "Import-CliXml"
$out.CommandType.ToString() | Should -Be "Cmdlet"

View file

@ -76,7 +76,7 @@ Describe "Trace-Command" -tags "Feature" {
$log = Get-Content $logfile | Where-Object {$_ -like "*ProcessID=*"}
$results = $log | ForEach-Object {$_.Split("=")[1]}
$results | ForEach-Object { $_ | Should -Be $pid }
$results | ForEach-Object { $_ | Should -Be $PID }
}
}
}

View file

@ -69,11 +69,11 @@ Describe "String cmdlets" -Tags "CI" {
It "match object supports RelativePath method" {
$file = "Modules${sep}Microsoft.PowerShell.Utility${sep}Microsoft.PowerShell.Utility.psd1"
$match = Select-String CmdletsToExport $pshome/$file
$match = Select-String CmdletsToExport $PSHOME/$file
$match.RelativePath($pshome) | Should -Be $file
$match.RelativePath($pshome.ToLower()) | Should -Be $file
$match.RelativePath($pshome.ToUpper()) | Should -Be $file
$match.RelativePath($PSHOME) | Should -Be $file
$match.RelativePath($PSHOME.ToLower()) | Should -Be $file
$match.RelativePath($PSHOME.ToUpper()) | Should -Be $file
}
}
}

View file

@ -53,12 +53,12 @@ Describe "Start-Transcript, Stop-Transcript tests" -tags "CI" {
AfterEach {
Remove-Item $transcriptFilePath -ErrorAction SilentlyContinue
[System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('ForcePromptForChoiceDefaultOption', $False)
[System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('ForcePromptForChoiceDefaultOption', $false)
}
It "Should create Transcript file at default path" {
$script = "Start-Transcript"
if ($isWindows) {
if ($IsWindows) {
$defaultTranscriptFilePath = [io.path]::Combine($env:USERPROFILE, "Documents", "PowerShell_transcript*")
} else {
$defaultTranscriptFilePath = [io.path]::Combine($env:HOME, "PowerShell_transcript*")
@ -220,7 +220,7 @@ Describe "Start-Transcript, Stop-Transcript tests" -tags "CI" {
$newLine = [System.Environment]::NewLine
$expectedContent = "$message$($newLine)Confirm$($newLine)Continue with this operation?"
$script = {
[System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('ForcePromptForChoiceDefaultOption', $True)
[System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('ForcePromptForChoiceDefaultOption', $true)
Start-Transcript -Path $transcriptFilePath
Write-Information -Message $message -InformationAction Inquire
Stop-Transcript
@ -280,7 +280,7 @@ Describe "Start-Transcript, Stop-Transcript tests" -tags "CI" {
$newLine = [System.Environment]::NewLine
$expectedContent = "$message$($newLine)Confirm$($newLine)Continue with this operation?"
$script = {
[System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('ForcePromptForChoiceDefaultOption', $True)
[System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('ForcePromptForChoiceDefaultOption', $true)
Start-Transcript -Path $transcriptFilePath
Write-Host -Message $message -InformationAction Inquire
Stop-Transcript

View file

@ -1,4 +1,4 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# Helper function to wait for job to reach a running or completed state

View file

@ -10,7 +10,7 @@ function CreateVHD ($VHDPath, $Size)
Mount-VHD -Passthru | `
get-disk -number {$_.DiskNumber} | `
Initialize-Disk -PartitionStyle MBR -PassThru | `
New-Partition -UseMaximumSize -AssignDriveLetter:$False -MbrType IFS | `
New-Partition -UseMaximumSize -AssignDriveLetter:$false -MbrType IFS | `
Format-Volume -Confirm:$false -FileSystem NTFS -force | `
get-partition | `
Add-PartitionAccessPath -AssignDriveLetter -PassThru | `

View file

@ -9,7 +9,7 @@ $script:TestSourceRoot = $PSScriptRoot
Describe "Test suite for validating automounted PowerShell drives" -Tags @('Feature', 'Slow', 'RequireAdminOnWindows') {
BeforeAll {
$powershell = Join-Path -Path $PsHome -ChildPath "pwsh"
$powershell = Join-Path -Path $PSHOME -ChildPath "pwsh"
$AutomountVHDDriveScriptPath = Join-Path $script:TestSourceRoot 'AutomountVHDDrive.ps1'
$vhdPath = Join-Path $TestDrive 'TestAutomountVHD.vhd'
@ -27,7 +27,7 @@ Describe "Test suite for validating automounted PowerShell drives" -Tags @('Feat
$tmpVhdPath = Join-Path $TestDrive 'TestVHD.vhd'
New-VHD -path $tmpVhdPath -SizeBytes 5mb -Dynamic -ErrorAction Stop
Remove-Item $tmpVhdPath
$VHDToolsNotFound = (Get-Module Hyper-V).PrivateData.ImplicitRemoting -eq $True
$VHDToolsNotFound = (Get-Module Hyper-V).PrivateData.ImplicitRemoting -eq $true
Remove-Module Hyper-V
}
catch

View file

@ -35,49 +35,49 @@ Describe 'Breakpoint SDK Unit Tests' -Tags 'CI' {
Context 'Managing breakpoints in the host runspace via the SDK' {
AfterAll {
foreach ($bp in $host.Runspace.Debugger.GetBreakpoints()) {
$host.Runspace.Debugger.RemoveBreakpoint($bp) | Should -BeTrue
foreach ($bp in $Host.Runspace.Debugger.GetBreakpoints()) {
$Host.Runspace.Debugger.RemoveBreakpoint($bp) | Should -BeTrue
}
}
It 'Can set command breakpoints' {
$host.Runspace.Debugger.SetCommandBreakpoint('Test-ThisCommandDoesNotExist') | Should -BeOfType [System.Management.Automation.CommandBreakpoint]
$Host.Runspace.Debugger.SetCommandBreakpoint('Test-ThisCommandDoesNotExist') | Should -BeOfType [System.Management.Automation.CommandBreakpoint]
}
It 'Can set variable breakpoints' {
$host.Runspace.Debugger.SetVariableBreakpoint('DebugPreference', 'ReadWrite', { continue }) | Should -BeOfType [System.Management.Automation.VariableBreakpoint]
$Host.Runspace.Debugger.SetVariableBreakpoint('DebugPreference', 'ReadWrite', { continue }) | Should -BeOfType [System.Management.Automation.VariableBreakpoint]
}
It 'Can set line breakpoints' {
$host.Runspace.Debugger.SetLineBreakpoint($PSCommandPath, 1, 1, { continue }) | Should -BeOfType [System.Management.Automation.LineBreakpoint]
$Host.Runspace.Debugger.SetLineBreakpoint($PSCommandPath, 1, 1, { continue }) | Should -BeOfType [System.Management.Automation.LineBreakpoint]
}
It 'Can get breakpoints' {
$host.Runspace.Debugger.GetBreakpoints() | Should -HaveCount 3
$Host.Runspace.Debugger.GetBreakpoints() | Should -HaveCount 3
}
It 'Can disable breakpoints' {
foreach ($bp in $host.Runspace.Debugger.GetBreakpoints()) {
$bp = $host.Runspace.Debugger.DisableBreakpoint($bp)
foreach ($bp in $Host.Runspace.Debugger.GetBreakpoints()) {
$bp = $Host.Runspace.Debugger.DisableBreakpoint($bp)
$bp.Enabled | Should -BeFalse
}
}
It 'Can enable breakpoints' {
foreach ($bp in $host.Runspace.Debugger.GetBreakpoints()) {
$bp = $host.Runspace.Debugger.EnableBreakpoint($bp)
foreach ($bp in $Host.Runspace.Debugger.GetBreakpoints()) {
$bp = $Host.Runspace.Debugger.EnableBreakpoint($bp)
$bp.Enabled | Should -BeTrue
}
}
It 'Can remove breakpoints' {
foreach ($bp in $host.Runspace.Debugger.GetBreakpoints()) {
$host.Runspace.Debugger.RemoveBreakpoint($bp) | Should -BeTrue
foreach ($bp in $Host.Runspace.Debugger.GetBreakpoints()) {
$Host.Runspace.Debugger.RemoveBreakpoint($bp) | Should -BeTrue
}
}
It 'Returns an empty collection when there are no breakpoints' {
$host.Runspace.Debugger.GetBreakpoints() | Should -HaveCount 0
$Host.Runspace.Debugger.GetBreakpoints() | Should -HaveCount 0
}
It 'Can set multiple breakpoints' {
@ -87,8 +87,8 @@ Describe 'Breakpoint SDK Unit Tests' -Tags 'CI' {
[System.Management.Automation.LineBreakpoint]::new("/Path/to/foo.ps1", 3)
)
$host.Runspace.Debugger.SetBreakpoints($breakpoints)
$host.Runspace.Debugger.GetBreakpoints() | Should -HaveCount 3
$Host.Runspace.Debugger.SetBreakpoints($breakpoints)
$Host.Runspace.Debugger.GetBreakpoints() | Should -HaveCount 3
}
}
@ -136,7 +136,7 @@ Describe 'Breakpoint SDK Unit Tests' -Tags 'CI' {
# Ensure that breakpoints were not created in the default runspace.
# Prior to this issue being fixed, breakpoints with the same id
# would be created or updated in the default runspace.
$host.Runspace.Debugger.GetBreakpoints() | Should -BeNullOrEmpty
$Host.Runspace.Debugger.GetBreakpoints() | Should -BeNullOrEmpty
}
It 'Can remove breakpoints' {
@ -168,15 +168,15 @@ Describe 'Breakpoint SDK Unit Tests' -Tags 'CI' {
}
It 'Returns false when trying to disable a breakpoint that does not exist' {
$host.Runspace.Debugger.DisableBreakpoint($bp) | Should -Be $null
$Host.Runspace.Debugger.DisableBreakpoint($bp) | Should -Be $null
}
It 'Returns false when trying to enable a breakpoint that does not exist' {
$host.Runspace.Debugger.EnableBreakpoint($bp) | Should -Be $null
$Host.Runspace.Debugger.EnableBreakpoint($bp) | Should -Be $null
}
It 'Returns false when trying to remove a breakpoint that does not exist' {
$host.Runspace.Debugger.RemoveBreakpoint($bp) | Should -BeFalse
$Host.Runspace.Debugger.RemoveBreakpoint($bp) | Should -BeFalse
}
}
@ -212,47 +212,47 @@ Describe 'Breakpoint SDK Unit Tests' -Tags 'CI' {
}
It 'Can set command breakpoints' {
$host.Runspace.Debugger.SetCommandBreakpoint('Test-ThisCommandDoesNotExist', $null, $null, $runspace.Id) | Should -BeOfType [System.Management.Automation.CommandBreakpoint]
$Host.Runspace.Debugger.SetCommandBreakpoint('Test-ThisCommandDoesNotExist', $null, $null, $runspace.Id) | Should -BeOfType [System.Management.Automation.CommandBreakpoint]
}
It 'Can set variable breakpoints' {
$host.Runspace.Debugger.SetVariableBreakpoint('DebugPreference', 'ReadWrite', { continue }, $null, $runspace.Id) | Should -BeOfType [System.Management.Automation.VariableBreakpoint]
$Host.Runspace.Debugger.SetVariableBreakpoint('DebugPreference', 'ReadWrite', { continue }, $null, $runspace.Id) | Should -BeOfType [System.Management.Automation.VariableBreakpoint]
}
It 'Can set line breakpoints' {
$host.Runspace.Debugger.SetLineBreakpoint($PSCommandPath, 1, 1, { continue }, $runspace.Id) | Should -BeOfType [System.Management.Automation.LineBreakpoint]
$Host.Runspace.Debugger.SetLineBreakpoint($PSCommandPath, 1, 1, { continue }, $runspace.Id) | Should -BeOfType [System.Management.Automation.LineBreakpoint]
}
It 'Can get breakpoints' {
$host.Runspace.Debugger.GetBreakpoints($runspace.Id) | Should -HaveCount 3
$Host.Runspace.Debugger.GetBreakpoints($runspace.Id) | Should -HaveCount 3
}
It 'Can disable breakpoints' {
foreach ($bp in $host.Runspace.Debugger.GetBreakpoints($runspace.Id)) {
$bp = $host.Runspace.Debugger.DisableBreakpoint($bp, $runspace.Id)
foreach ($bp in $Host.Runspace.Debugger.GetBreakpoints($runspace.Id)) {
$bp = $Host.Runspace.Debugger.DisableBreakpoint($bp, $runspace.Id)
$bp.Enabled | Should -BeFalse
}
}
It 'Can enable breakpoints' {
foreach ($bp in $host.Runspace.Debugger.GetBreakpoints($runspace.Id)) {
$bp = $host.Runspace.Debugger.EnableBreakpoint($bp, $runspace.Id)
foreach ($bp in $Host.Runspace.Debugger.GetBreakpoints($runspace.Id)) {
$bp = $Host.Runspace.Debugger.EnableBreakpoint($bp, $runspace.Id)
$bp.Enabled | Should -BeTrue
}
}
It 'Doesn''t manipulate any breakpoints in the default runspace' {
$host.Runspace.Debugger.GetBreakpoints() | Should -BeNullOrEmpty
$Host.Runspace.Debugger.GetBreakpoints() | Should -BeNullOrEmpty
}
It 'Can remove breakpoints' {
foreach ($bp in $host.Runspace.Debugger.GetBreakpoints($runspace.Id)) {
$host.Runspace.Debugger.RemoveBreakpoint($bp, $runspace.Id) | Should -BeTrue
foreach ($bp in $Host.Runspace.Debugger.GetBreakpoints($runspace.Id)) {
$Host.Runspace.Debugger.RemoveBreakpoint($bp, $runspace.Id) | Should -BeTrue
}
}
It 'Returns an empty collection when there are no breakpoints' {
$host.Runspace.Debugger.GetBreakpoints($runspace.Id) | Should -HaveCount 0
$Host.Runspace.Debugger.GetBreakpoints($runspace.Id) | Should -HaveCount 0
}
It 'Can set multiple breakpoints' {
@ -262,8 +262,8 @@ Describe 'Breakpoint SDK Unit Tests' -Tags 'CI' {
[System.Management.Automation.LineBreakpoint]::new("/Path/to/foo.ps1", 3)
)
$host.Runspace.Debugger.SetBreakpoints($breakpoints, $runspace.Id)
$host.Runspace.Debugger.GetBreakpoints($runspace.Id) | Should -HaveCount 3
$Host.Runspace.Debugger.SetBreakpoints($breakpoints, $runspace.Id)
$Host.Runspace.Debugger.GetBreakpoints($runspace.Id) | Should -HaveCount 3
}
}
}

View file

@ -6,7 +6,7 @@ using namespace System.Management.Automation.Internal
Describe "PowerShell Command Debugging" -tags "CI" {
BeforeAll {
$powershell = Join-Path -Path $PsHome -ChildPath "pwsh"
$powershell = Join-Path -Path $PSHOME -ChildPath "pwsh"
}
function NewProcessStartInfo([string]$CommandLine, [switch]$RedirectStdIn)

View file

@ -23,7 +23,7 @@ Describe "Can load a native assembly" -Tags "CI" {
$arch = "linux-" + $processArch
$nativeDllName = "nativedll.so"
$sourceDllName = "libhostpolicy.so"
} elseif ($IsMacOs) {
} elseif ($IsMacOS) {
$arch = "osx-" + $processArch
$nativeDllName = "nativedll.dylib"
$sourceDllName = "libhostpolicy.dylib"

View file

@ -2,9 +2,9 @@
# Licensed under the MIT License.
Describe "Verify approved aliases list" -Tags "CI" {
BeforeAll {
$FullCLR = !$isCoreCLR
$CoreWindows = $isCoreCLR -and $IsWindows
$CoreUnix = $isCoreCLR -and !$IsWindows
$FullCLR = !$IsCoreCLR
$CoreWindows = $IsCoreCLR -and $IsWindows
$CoreUnix = $IsCoreCLR -and !$IsWindows
$isPreview = $PSVersionTable.GitCommitId.Contains("preview")
if ($IsWindows) {
$configPath = Join-Path -Path $env:USERPROFILE -ChildPath 'Documents' -AdditionalChildPath 'PowerShell'

View file

@ -8,13 +8,13 @@ Describe 'Group policy settings tests' -Tag CI,RequireAdminOnWindows {
$PSDefaultParameterValues["it:skip"] = $true
}
else {
[System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('BypassGroupPolicyCaching', $True)
[System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('BypassGroupPolicyCaching', $true)
}
}
AfterAll {
$global:PSDefaultParameterValues = $originalDefaultParameterValues
if ( $IsWindows ) {
[System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('BypassGroupPolicyCaching', $False)
[System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('BypassGroupPolicyCaching', $false)
}
}
@ -80,7 +80,7 @@ Describe 'Group policy settings tests' -Tag CI,RequireAdminOnWindows {
Get-Alias $RareCommand -ErrorAction SilentlyContinue | Out-Null
(Get-Module $ModuleToLog).LogPipelineExecutionDetails = $False # turn off logging
(Get-Module $ModuleToLog).LogPipelineExecutionDetails = $false # turn off logging
Remove-ItemProperty -Path $KeyPath -Name EnableModuleLogging -Force # turn off GP setting
Remove-item $ModuleNamesKeyPath -Recurse -Force
# usually event becomes visible in the log after ~500 ms

View file

@ -2,7 +2,7 @@
# Licensed under the MIT License.
try {
$defaultParamValues = $PSdefaultParameterValues.Clone()
$defaultParamValues = $PSDefaultParameterValues.Clone()
$PSDefaultParameterValues["it:skip"] = ![System.Management.Automation.Platform]::IsWindowsDesktop
Describe 'Basic COM Tests' -Tags "CI" {

View file

@ -217,7 +217,7 @@ Describe "Validate that get-help works for provider specific help" -Tags @('CI')
Describe "Validate about_help.txt under culture specific folder works" -Tags @('CI', 'RequireAdminOnWindows', 'RequireSudoOnUnix') {
BeforeAll {
$modulePath = "$pshome\Modules\Test"
$modulePath = "$PSHOME\Modules\Test"
if (Test-CanWriteToPsHome) {
$null = New-Item -Path $modulePath\en-US -ItemType Directory -Force
New-ModuleManifest -Path $modulePath\test.psd1 -RootModule test.psm1
@ -241,7 +241,7 @@ Describe "Validate about_help.txt under culture specific folder works" -Tags @('
Get-ChildItem -Path $aboutHelpPath -Include @('about_*.txt', "*help.xml") -Recurse | Remove-Item -Force -ErrorAction SilentlyContinue
}
It "Get-Help should return help text and not multiple HelpInfo objects when help is under `$pshome path" -Skip:(!(Test-CanWriteToPsHome)) {
It "Get-Help should return help text and not multiple HelpInfo objects when help is under `$PSHOME path" -Skip:(!(Test-CanWriteToPsHome)) {
$help = Get-Help about_testhelp
$help.count | Should -Be 1

View file

@ -50,7 +50,7 @@ $testCases = @{
HelpFiles = "Microsoft.Management.Infrastructure.CimCmdlets.dll-help.xml"
HelpInfoFiles = "CimCmdlets_fb6cc51d-c096-4b38-b78d-0fed6277096a_HelpInfo.xml"
CompressedFiles = "CimCmdlets_fb6cc51d-c096-4b38-b78d-0fed6277096a_en-US_HelpContent$extension"
HelpInstallationPath = "$pshome\Modules\CimCmdlets\en-US"
HelpInstallationPath = "$PSHOME\Modules\CimCmdlets\en-US"
HelpInstallationPathHome = "$userHelpRoot\CimCmdlets\en-US"
}
@ -58,14 +58,14 @@ $testCases = @{
HelpFiles = "Microsoft.PowerShell.Archive-help.xml"
HelpInfoFiles = "Microsoft.PowerShell.Archive_eb74e8da-9ae2-482a-a648-e96550fb8733_HelpInfo.xml"
CompressedFiles = "Microsoft.PowerShell.Archive_eb74e8da-9ae2-482a-a648-e96550fb8733_en-US_HelpContent$extension"
HelpInstallationPath = "$pshome\Modules\Microsoft.PowerShell.Archive\en-US"
HelpInstallationPath = "$PSHOME\Modules\Microsoft.PowerShell.Archive\en-US"
}
"Microsoft.PowerShell.Core" = @{
HelpFiles = "System.Management.Automation.dll-help.xml"
HelpInfoFiles = "Microsoft.PowerShell.Core_00000000-0000-0000-0000-000000000000_HelpInfo.xml"
CompressedFiles = "Microsoft.PowerShell.Core_00000000-0000-0000-0000-000000000000_en-US_HelpContent$extension"
HelpInstallationPath = "$pshome\en-US"
HelpInstallationPath = "$PSHOME\en-US"
HelpInstallationPathHome = "$userHelpRoot\en-US"
}
@ -73,7 +73,7 @@ $testCases = @{
HelpFiles = "Microsoft.PowerShell.Commands.Diagnostics.dll-help.xml"
HelpInfoFiles = "Microsoft.PowerShell.Diagnostics_ca046f10-ca64-4740-8ff9-2565dba61a4f_HelpInfo.xml"
CompressedFiles = "Microsoft.PowerShell.Diagnostics_ca046f10-ca64-4740-8ff9-2565dba61a4f_en-US_helpcontent$extension"
HelpInstallationPath = "$pshome\en-US"
HelpInstallationPath = "$PSHOME\en-US"
HelpInstallationPathHome = "$userHelpRoot\en-US"
}
@ -81,7 +81,7 @@ $testCases = @{
HelpFiles = "Microsoft.PowerShell.ConsoleHost.dll-help.xml"
HelpInfoFiles = "Microsoft.PowerShell.Host_56d66100-99a0-4ffc-a12d-eee9a6718aef_HelpInfo.xml"
CompressedFiles = "Microsoft.PowerShell.Host_56d66100-99a0-4ffc-a12d-eee9a6718aef_en-US_helpcontent$extension"
HelpInstallationPath = "$pshome\en-US"
HelpInstallationPath = "$PSHOME\en-US"
HelpInstallationPathHome = "$userHelpRoot\en-US"
}
@ -89,7 +89,7 @@ $testCases = @{
HelpFiles = "Microsoft.Powershell.LocalAccounts.dll-help.xml"
HelpInfoFiles = "Microsoft.PowerShell.LocalAccounts_8e362604-2c0b-448f-a414-a6a690a644e2_HelpInfo.xml"
CompressedFiles = "Microsoft.PowerShell.LocalAccounts_8e362604-2c0b-448f-a414-a6a690a644e2_en-US_HelpContent$extension"
HelpInstallationPath = "$pshome\Modules\Microsoft.PowerShell.LocalAccounts\en-US"
HelpInstallationPath = "$PSHOME\Modules\Microsoft.PowerShell.LocalAccounts\en-US"
HelpInstallationPathHome = "$userHelpRoot\Microsoft.PowerShell.LocalAccounts\en-US"
}
@ -97,7 +97,7 @@ $testCases = @{
HelpFiles = "Microsoft.PowerShell.Commands.Management.dll-help.xml"
HelpInfoFiles = "Microsoft.PowerShell.Management_eefcb906-b326-4e99-9f54-8b4bb6ef3c6d_HelpInfo.xml"
CompressedFiles = "Microsoft.PowerShell.Management_eefcb906-b326-4e99-9f54-8b4bb6ef3c6d_en-US_helpcontent$extension"
HelpInstallationPath = "$pshome\en-US"
HelpInstallationPath = "$PSHOME\en-US"
HelpInstallationPathHome = "$userHelpRoot\en-US"
}
@ -105,7 +105,7 @@ $testCases = @{
HelpFiles = "Microsoft.PowerShell.Security.dll-help.xml"
HelpInfoFiles = "Microsoft.PowerShell.Security_a94c8c7e-9810-47c0-b8af-65089c13a35a_HelpInfo.xml"
CompressedFiles = "Microsoft.PowerShell.Security_a94c8c7e-9810-47c0-b8af-65089c13a35a_en-US_helpcontent$extension"
HelpInstallationPath = "$pshome\en-US"
HelpInstallationPath = "$PSHOME\en-US"
HelpInstallationPathHome = "$userHelpRoot\en-US"
}
@ -113,7 +113,7 @@ $testCases = @{
HelpFiles = "Microsoft.PowerShell.Commands.Utility.dll-Help.xml", "Microsoft.PowerShell.Utility-help.xml"
HelpInfoFiles = "Microsoft.PowerShell.Utility_1da87e53-152b-403e-98dc-74d7b4d63d59_HelpInfo.xml"
CompressedFiles = "Microsoft.PowerShell.Utility_1da87e53-152b-403e-98dc-74d7b4d63d59_en-US_helpcontent$extension"
HelpInstallationPath = "$pshome\en-US"
HelpInstallationPath = "$PSHOME\en-US"
HelpInstallationPathHome = "$userHelpRoot\en-US"
}
@ -121,7 +121,7 @@ $testCases = @{
HelpFiles = "Microsoft.WSMan.Management.dll-help.xml"
HelpInfoFiles = "Microsoft.WsMan.Management_766204A6-330E-4263-A7AB-46C87AFC366C_HelpInfo.xml"
CompressedFiles = "Microsoft.WsMan.Management_766204A6-330E-4263-A7AB-46C87AFC366C_en-US_helpcontent$extension"
HelpInstallationPath = "$pshome\en-US"
HelpInstallationPath = "$PSHOME\en-US"
HelpInstallationPathHome = "$userHelpRoot\en-US"
}
@ -129,7 +129,7 @@ $testCases = @{
HelpFiles = "Microsoft.PowerShell.PackageManagement.dll-help.xml"
HelpInfoFiles = "PackageManagement_4ae9fd46-338a-459c-8186-07f910774cb8_HelpInfo.xml"
CompressedFiles = "PackageManagement_4ae9fd46-338a-459c-8186-07f910774cb8_en-US_helpcontent$extension"
HelpInstallationPath = "$pshome\Modules\PackageManagement\en-US"
HelpInstallationPath = "$PSHOME\Modules\PackageManagement\en-US"
HelpInstallationPathHome = "$userHelpRoot\PackageManagement\en-US"
}
@ -137,7 +137,7 @@ $testCases = @{
HelpFiles = "PSGet.psm1-help.xml"
HelpInfoFiles = "PowershellGet_1d73a601-4a6c-43c5-ba3f-619b18bbb404_HelpInfo.xml"
CompressedFiles = "PowershellGet_1d73a601-4a6c-43c5-ba3f-619b18bbb404_en-US_helpcontent$extension"
HelpInstallationPath = "$pshome\Modules\PowershellGet\en-US"
HelpInstallationPath = "$PSHOME\Modules\PowershellGet\en-US"
HelpInstallationPathHome = "$userHelpRoot\PackageManagement\en-US"
}
}

View file

@ -81,7 +81,7 @@ Describe 'Basic Job Tests' -Tags 'Feature' {
It 'Can use the user specified working directory parameter with whitespace' {
$path = Join-Path -Path $TestDrive -ChildPath "My Dir"
$null = New-Item -ItemType Directory -Path "$path"
$job = Start-Job -ScriptBlock { $pwd } -WorkingDirectory $path | Wait-Job
$job = Start-Job -ScriptBlock { $PWD } -WorkingDirectory $path | Wait-Job
$jobOutput = Receive-Job $job
$jobOutput | Should -BeExactly $path.ToString()
}
@ -89,13 +89,13 @@ Describe 'Basic Job Tests' -Tags 'Feature' {
It 'Can use the user specified working directory parameter with quote' -Skip:($IsWindows) {
$path = Join-Path -Path $TestDrive -ChildPath "My ""Dir"
$null = New-Item -ItemType Directory -Path "$path"
$job = Start-Job -ScriptBlock { $pwd } -WorkingDirectory $path | Wait-Job
$job = Start-Job -ScriptBlock { $PWD } -WorkingDirectory $path | Wait-Job
$jobOutput = Receive-Job $job
$jobOutput | Should -BeExactly $path.ToString()
}
It 'Verifies the working directory parameter path with trailing backslash' -Skip:(! $IsWindows) {
$job = Start-Job { $pwd } -WorkingDirectory '\' | Wait-Job
$job = Start-Job { $PWD } -WorkingDirectory '\' | Wait-Job
$job.JobStateInfo.State | Should -BeExactly 'Completed'
}
@ -106,10 +106,10 @@ Describe 'Basic Job Tests' -Tags 'Feature' {
}
It 'Verifies that the current working directory is preserved' {
$job = Start-Job -ScriptBlock { $pwd }
$job = Start-Job -ScriptBlock { $PWD }
$location = $job | Wait-Job | Receive-Job
$job | Remove-Job
$location.Path | Should -BeExactly $pwd.Path
$location.Path | Should -BeExactly $PWD.Path
}
It "Create job with native command" {

View file

@ -240,7 +240,7 @@ Describe "Tests for circular references in required modules" -tags "CI" {
Describe "Test-ModuleManifest Performance bug followup" -tags "CI" {
BeforeAll {
$TestModulesPath = [System.IO.Path]::Combine($PSScriptRoot, 'assets', 'testmodulerunspace')
$PSHomeModulesPath = "$pshome\Modules"
$PSHomeModulesPath = "$PSHOME\Modules"
# Install the Test Module
if (Test-CanWriteToPsHome) {
@ -253,7 +253,7 @@ Describe "Test-ModuleManifest Performance bug followup" -tags "CI" {
$job = start-job -name "job1" -ScriptBlock {test-modulemanifest "$using:PSHomeModulesPath\ModuleWithDependencies2\2.0\ModuleWithDependencies2.psd1" -verbose} | Wait-Job
$verbose = $job.ChildJobs[0].Verbose.ReadAll()
# Before the fix, all modules under $pshome will be imported and will be far more than 15 verbose messages. However, we cannot fix the number in case verbose message may vary.
# Before the fix, all modules under $PSHOME will be imported and will be far more than 15 verbose messages. However, we cannot fix the number in case verbose message may vary.
$verbose.Count | Should -BeLessThan 15
}

View file

@ -1,11 +1,11 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
Describe "TestImplicitRemotingBatching hook should correctly batch simple remote command pipelines" -Tag 'Feature','RequireAdminOnWindows' {
BeforeAll {
if (! $isWindows) { return }
if (! $IsWindows) { return }
function ThrowSetupError
{
@ -149,7 +149,7 @@ Describe "TestImplicitRemotingBatching hook should correctly batch simple remote
AfterAll {
if (! $isWindows) { return }
if (! $IsWindows) { return }
if ($remoteSession -ne $null) { Remove-PSSession $remoteSession -ErrorAction Ignore }
if ($powershell -ne $null) { $powershell.Dispose() }

View file

@ -205,7 +205,7 @@ Describe "Remoting loopback tests" -Tags @('CI', 'RequireAdminOnWindows') {
AfterAll {
$global:PSDefaultParameterValues = $originalDefaultParameterValues
if($isWindows)
if($IsWindows)
{
Remove-PSSession $disconnectedSession,$closedSession,$openSession -ErrorAction SilentlyContinue
}

View file

@ -8,7 +8,7 @@ Describe "Remote runspace pool should expose commands in endpoint configuration"
BeforeAll {
if ($isWindows -and (Test-CanWriteToPsHome))
if ($IsWindows -and (Test-CanWriteToPsHome))
{
$configName = "restrictedV"
$configPath = Join-Path $TestDrive ($configName + ".pssc")

View file

@ -30,7 +30,7 @@ try {
$result.SkipCACheck = $true
$result.SkipCNCheck = $true
$result.SkipRevocationCheck = $true
$result.UseUtf16 = $True
$result.UseUtf16 = $true
$result.UseEncryption = $false
$result.ProxyAuthentication = "Negotiate"
$result.SPNPort = 10

View file

@ -1,6 +1,6 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
. "$psscriptroot/TestRunner.ps1"
. "$PSScriptRoot/TestRunner.ps1"
$assemblyName = "Microsoft.Management.Infrastructure.CimCmdlets"

Some files were not shown because too many files have changed in this diff Show more