mirror of
https://github.com/PowerShell/PowerShell.git
synced 2024-11-27 03:46:23 +08:00
Use correct casing for cmdlet name and cmdlet parameter name in *.ps1 files (#12584)
This commit is contained in:
parent
71d8876e60
commit
f4382202ae
22
build.psm1
22
build.psm1
@ -538,10 +538,10 @@ Fix steps:
|
|||||||
$cryptoTarget = "/lib64/libcrypto.so.10"
|
$cryptoTarget = "/lib64/libcrypto.so.10"
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! (test-path "$publishPath/libssl.so.1.0.0")) {
|
if ( ! (Test-Path "$publishPath/libssl.so.1.0.0")) {
|
||||||
$null = New-Item -Force -ItemType SymbolicLink -Target $sslTarget -Path "$publishPath/libssl.so.1.0.0" -ErrorAction Stop
|
$null = New-Item -Force -ItemType SymbolicLink -Target $sslTarget -Path "$publishPath/libssl.so.1.0.0" -ErrorAction Stop
|
||||||
}
|
}
|
||||||
if ( ! (test-path "$publishPath/libcrypto.so.1.0.0")) {
|
if ( ! (Test-Path "$publishPath/libcrypto.so.1.0.0")) {
|
||||||
$null = New-Item -Force -ItemType SymbolicLink -Target $cryptoTarget -Path "$publishPath/libcrypto.so.1.0.0" -ErrorAction Stop
|
$null = New-Item -Force -ItemType SymbolicLink -Target $cryptoTarget -Path "$publishPath/libcrypto.so.1.0.0" -ErrorAction Stop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -888,7 +888,7 @@ function Get-PesterTag {
|
|||||||
$alltags = @{}
|
$alltags = @{}
|
||||||
$warnings = @()
|
$warnings = @()
|
||||||
|
|
||||||
get-childitem -Recurse $testbase -File | Where-Object {$_.name -match "tests.ps1"}| ForEach-Object {
|
Get-ChildItem -Recurse $testbase -File | Where-Object {$_.name -match "tests.ps1"}| ForEach-Object {
|
||||||
$fullname = $_.fullname
|
$fullname = $_.fullname
|
||||||
$tok = $err = $null
|
$tok = $err = $null
|
||||||
$ast = [System.Management.Automation.Language.Parser]::ParseFile($FullName, [ref]$tok,[ref]$err)
|
$ast = [System.Management.Automation.Language.Parser]::ParseFile($FullName, [ref]$tok,[ref]$err)
|
||||||
@ -1276,7 +1276,7 @@ function Start-PSPester {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
$count = ($lines | measure-object).Count
|
$count = ($lines | Measure-Object).Count
|
||||||
if ($count -eq 0)
|
if ($count -eq 0)
|
||||||
{
|
{
|
||||||
Start-Sleep -Seconds 1
|
Start-Sleep -Seconds 1
|
||||||
@ -1469,7 +1469,7 @@ function Test-XUnitTestResults
|
|||||||
throw "Cannot convert $TestResultsFile to xml : $($_.message)"
|
throw "Cannot convert $TestResultsFile to xml : $($_.message)"
|
||||||
}
|
}
|
||||||
|
|
||||||
$failedTests = $results.assemblies.assembly.collection | Where-Object failed -gt 0
|
$failedTests = $results.assemblies.assembly.collection | Where-Object failed -GT 0
|
||||||
|
|
||||||
if(-not $failedTests)
|
if(-not $failedTests)
|
||||||
{
|
{
|
||||||
@ -1521,7 +1521,7 @@ function Test-PSPesterResults
|
|||||||
throw "Test result file '$testResultsFile' not found for $TestArea."
|
throw "Test result file '$testResultsFile' not found for $TestArea."
|
||||||
}
|
}
|
||||||
|
|
||||||
$x = [xml](Get-Content -raw $testResultsFile)
|
$x = [xml](Get-Content -Raw $testResultsFile)
|
||||||
if ([int]$x.'test-results'.failures -gt 0)
|
if ([int]$x.'test-results'.failures -gt 0)
|
||||||
{
|
{
|
||||||
Write-Log -Error "TEST FAILURES"
|
Write-Log -Error "TEST FAILURES"
|
||||||
@ -2093,7 +2093,7 @@ function script:Use-MSBuild {
|
|||||||
# msbuild v14 and msbuild v4 behaviors are different for XAML generation
|
# msbuild v14 and msbuild v4 behaviors are different for XAML generation
|
||||||
$frameworkMsBuildLocation = "${env:SystemRoot}\Microsoft.Net\Framework\v4.0.30319\msbuild"
|
$frameworkMsBuildLocation = "${env:SystemRoot}\Microsoft.Net\Framework\v4.0.30319\msbuild"
|
||||||
|
|
||||||
$msbuild = get-command msbuild -ErrorAction Ignore
|
$msbuild = Get-Command msbuild -ErrorAction Ignore
|
||||||
if ($msbuild) {
|
if ($msbuild) {
|
||||||
# all good, nothing to do
|
# all good, nothing to do
|
||||||
return
|
return
|
||||||
@ -2873,17 +2873,17 @@ assembly
|
|||||||
PROCESS {
|
PROCESS {
|
||||||
#### MAIN ####
|
#### MAIN ####
|
||||||
foreach ( $log in $Logfile ) {
|
foreach ( $log in $Logfile ) {
|
||||||
foreach ( $logpath in (resolve-path $log).path ) {
|
foreach ( $logpath in (Resolve-Path $log).path ) {
|
||||||
write-progress "converting file $logpath"
|
Write-Progress "converting file $logpath"
|
||||||
if ( ! $logpath) { throw "Cannot resolve $Logfile" }
|
if ( ! $logpath) { throw "Cannot resolve $Logfile" }
|
||||||
$x = [xml](get-content -raw -readcount 0 $logpath)
|
$x = [xml](Get-Content -Raw -ReadCount 0 $logpath)
|
||||||
|
|
||||||
if ( $x.psobject.properties['test-results'] ) {
|
if ( $x.psobject.properties['test-results'] ) {
|
||||||
$Logs += convert-pesterlog $x $logpath -includeempty:$includeempty
|
$Logs += convert-pesterlog $x $logpath -includeempty:$includeempty
|
||||||
} elseif ( $x.psobject.properties['assemblies'] ) {
|
} elseif ( $x.psobject.properties['assemblies'] ) {
|
||||||
$Logs += convert-xunitlog $x $logpath -includeEmpty:$includeEmpty
|
$Logs += convert-xunitlog $x $logpath -includeEmpty:$includeEmpty
|
||||||
} else {
|
} else {
|
||||||
write-error "Cannot determine log type"
|
Write-Error "Cannot determine log type"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,12 @@ Write-Host -Foreground Blue "Get installed Apache Modules like *proxy* and Sort
|
|||||||
Get-ApacheModule | Where-Object {$_.ModuleName -like "*proxy*"} | Sort-Object ModuleName | Out-Host
|
Get-ApacheModule | Where-Object {$_.ModuleName -like "*proxy*"} | Sort-Object ModuleName | Out-Host
|
||||||
|
|
||||||
#Graceful restart of Apache
|
#Graceful restart of Apache
|
||||||
Write-host -Foreground Blue "Restart Apache Server gracefully"
|
Write-Host -Foreground Blue "Restart Apache Server gracefully"
|
||||||
Restart-ApacheHTTPServer -Graceful | Out-Host
|
Restart-ApacheHTTPServer -Graceful | Out-Host
|
||||||
|
|
||||||
#Enumerate current virtual hosts (web sites)
|
#Enumerate current virtual hosts (web sites)
|
||||||
Write-Host -Foreground Blue "Enumerate configured Apache Virtual Hosts"
|
Write-Host -Foreground Blue "Enumerate configured Apache Virtual Hosts"
|
||||||
Get-ApacheVHost |out-host
|
Get-ApacheVHost |Out-Host
|
||||||
|
|
||||||
#Add a new virtual host
|
#Add a new virtual host
|
||||||
Write-Host -Foreground Yellow "Create a new Apache Virtual Host"
|
Write-Host -Foreground Yellow "Create a new Apache Virtual Host"
|
||||||
@ -21,7 +21,7 @@ New-ApacheVHost -ServerName "mytestserver" -DocumentRoot /var/www/html/mytestser
|
|||||||
|
|
||||||
#Enumerate new set of virtual hosts
|
#Enumerate new set of virtual hosts
|
||||||
Write-Host -Foreground Blue "Enumerate Apache Virtual Hosts Again"
|
Write-Host -Foreground Blue "Enumerate Apache Virtual Hosts Again"
|
||||||
Get-ApacheVHost |out-host
|
Get-ApacheVHost |Out-Host
|
||||||
|
|
||||||
#Cleanup
|
#Cleanup
|
||||||
Write-Host -Foreground Blue "Remove demo virtual host"
|
Write-Host -Foreground Blue "Remove demo virtual host"
|
||||||
|
@ -20,10 +20,10 @@ Run-ContainerImage hello-world # Linux
|
|||||||
cls
|
cls
|
||||||
|
|
||||||
# List all containers that have exited
|
# List all containers that have exited
|
||||||
Get-Container | Where-Object State -eq "exited"
|
Get-Container | Where-Object State -EQ "exited"
|
||||||
|
|
||||||
# That found the right one, so go ahead and remove it
|
# That found the right one, so go ahead and remove it
|
||||||
Get-Container | Where-Object State -eq "exited" | Remove-Container
|
Get-Container | Where-Object State -EQ "exited" | Remove-Container
|
||||||
|
|
||||||
# Now remove the container image
|
# Now remove the container image
|
||||||
Remove-ContainerImage hello-world
|
Remove-ContainerImage hello-world
|
||||||
|
@ -11,7 +11,7 @@ Function Get-SystemDJournal {
|
|||||||
$Result = & $sudocmd $cmd $journalctlParameters -o json --no-pager
|
$Result = & $sudocmd $cmd $journalctlParameters -o json --no-pager
|
||||||
Try
|
Try
|
||||||
{
|
{
|
||||||
$JSONResult = $Result|ConvertFrom-JSON
|
$JSONResult = $Result|ConvertFrom-Json
|
||||||
$JSONResult
|
$JSONResult
|
||||||
}
|
}
|
||||||
Catch
|
Catch
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
Import-Module $PSScriptRoot/SystemD/SystemD.psm1
|
Import-Module $PSScriptRoot/SystemD/SystemD.psm1
|
||||||
|
|
||||||
#list recent journal events
|
#list recent journal events
|
||||||
Write-host -Foreground Blue "Get recent SystemD journal messages"
|
Write-Host -Foreground Blue "Get recent SystemD journal messages"
|
||||||
Get-SystemDJournal -args "-xe" |Out-Host
|
Get-SystemDJournal -args "-xe" |Out-Host
|
||||||
|
|
||||||
#Drill into SystemD unit messages
|
#Drill into SystemD unit messages
|
||||||
Write-host -Foreground Blue "Get recent SystemD journal messages for services and return Unit, Message"
|
Write-Host -Foreground Blue "Get recent SystemD journal messages for services and return Unit, Message"
|
||||||
Get-SystemDJournal -args "-xe" | Where-Object {$_._SYSTEMD_UNIT -like "*.service"} | Format-Table _SYSTEMD_UNIT, MESSAGE | Select-Object -first 10 | Out-Host
|
Get-SystemDJournal -args "-xe" | Where-Object {$_._SYSTEMD_UNIT -like "*.service"} | Format-Table _SYSTEMD_UNIT, MESSAGE | Select-Object -First 10 | Out-Host
|
||||||
|
@ -10,5 +10,5 @@
|
|||||||
# picking up the Python script from the same directory
|
# picking up the Python script from the same directory
|
||||||
#
|
#
|
||||||
|
|
||||||
& $PSScriptRoot/class1.py | ConvertFrom-JSON
|
& $PSScriptRoot/class1.py | ConvertFrom-Json
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ $data
|
|||||||
@"
|
@"
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
print('Hi!')
|
print('Hi!')
|
||||||
"@ | out-file -encoding ascii hi
|
"@ | Out-File -Encoding ascii hi
|
||||||
|
|
||||||
# Make it executable
|
# Make it executable
|
||||||
chmod +x hi
|
chmod +x hi
|
||||||
@ -35,7 +35,7 @@ cat class1.py
|
|||||||
./class1.py
|
./class1.py
|
||||||
|
|
||||||
# Capture the data as structured objects (arrays and hashtables)
|
# Capture the data as structured objects (arrays and hashtables)
|
||||||
$data = ./class1.py | ConvertFrom-JSON
|
$data = ./class1.py | ConvertFrom-Json
|
||||||
|
|
||||||
# look at the first element of the returned array
|
# look at the first element of the returned array
|
||||||
$data[0]
|
$data[0]
|
||||||
|
@ -130,35 +130,35 @@ function Enable-WSManTrace
|
|||||||
{
|
{
|
||||||
|
|
||||||
# winrm
|
# winrm
|
||||||
"{04c6e16d-b99f-4a3a-9b3e-b8325bbc781e} 0xffffffff 0xff" | out-file $script:wsmprovfile -encoding ascii
|
"{04c6e16d-b99f-4a3a-9b3e-b8325bbc781e} 0xffffffff 0xff" | Out-File $script:wsmprovfile -Encoding ascii
|
||||||
|
|
||||||
# winrsmgr
|
# winrsmgr
|
||||||
"{c0a36be8-a515-4cfa-b2b6-2676366efff7} 0xffffffff 0xff" | out-file $script:wsmprovfile -encoding ascii -append
|
"{c0a36be8-a515-4cfa-b2b6-2676366efff7} 0xffffffff 0xff" | Out-File $script:wsmprovfile -Encoding ascii -Append
|
||||||
|
|
||||||
# WinrsExe
|
# WinrsExe
|
||||||
"{f1cab2c0-8beb-4fa2-90e1-8f17e0acdd5d} 0xffffffff 0xff" | out-file $script:wsmprovfile -encoding ascii -append
|
"{f1cab2c0-8beb-4fa2-90e1-8f17e0acdd5d} 0xffffffff 0xff" | Out-File $script:wsmprovfile -Encoding ascii -Append
|
||||||
|
|
||||||
# WinrsCmd
|
# WinrsCmd
|
||||||
"{03992646-3dfe-4477-80e3-85936ace7abb} 0xffffffff 0xff" | out-file $script:wsmprovfile -encoding ascii -append
|
"{03992646-3dfe-4477-80e3-85936ace7abb} 0xffffffff 0xff" | Out-File $script:wsmprovfile -Encoding ascii -Append
|
||||||
|
|
||||||
# IPMIPrv
|
# IPMIPrv
|
||||||
"{651d672b-e11f-41b7-add3-c2f6a4023672} 0xffffffff 0xff" | out-file $script:wsmprovfile -encoding ascii -append
|
"{651d672b-e11f-41b7-add3-c2f6a4023672} 0xffffffff 0xff" | Out-File $script:wsmprovfile -Encoding ascii -Append
|
||||||
|
|
||||||
#IpmiDrv
|
#IpmiDrv
|
||||||
"{D5C6A3E9-FA9C-434e-9653-165B4FC869E4} 0xffffffff 0xff" | out-file $script:wsmprovfile -encoding ascii -append
|
"{D5C6A3E9-FA9C-434e-9653-165B4FC869E4} 0xffffffff 0xff" | Out-File $script:wsmprovfile -Encoding ascii -Append
|
||||||
|
|
||||||
# WSManProvHost
|
# WSManProvHost
|
||||||
"{6e1b64d7-d3be-4651-90fb-3583af89d7f1} 0xffffffff 0xff" | out-file $script:wsmprovfile -encoding ascii -append
|
"{6e1b64d7-d3be-4651-90fb-3583af89d7f1} 0xffffffff 0xff" | Out-File $script:wsmprovfile -Encoding ascii -Append
|
||||||
|
|
||||||
# Event Forwarding
|
# Event Forwarding
|
||||||
"{6FCDF39A-EF67-483D-A661-76D715C6B008} 0xffffffff 0xff" | out-file $script:wsmprovfile -encoding ascii -append
|
"{6FCDF39A-EF67-483D-A661-76D715C6B008} 0xffffffff 0xff" | Out-File $script:wsmprovfile -Encoding ascii -Append
|
||||||
|
|
||||||
Start-Trace -SessionName $script:wsmsession -ETS -OutputFilePath $script:wsmanlogfile -Format bincirc -MinBuffers 16 -MaxBuffers 256 -BufferSizeInKb 64 -MaxLogFileSizeInMB 256 -ProviderFilePath $script:wsmprovfile
|
Start-Trace -SessionName $script:wsmsession -ETS -OutputFilePath $script:wsmanlogfile -Format bincirc -MinBuffers 16 -MaxBuffers 256 -BufferSizeInKB 64 -MaxLogFileSizeInMB 256 -ProviderFilePath $script:wsmprovfile
|
||||||
}
|
}
|
||||||
|
|
||||||
function Disable-WSManTrace
|
function Disable-WSManTrace
|
||||||
{
|
{
|
||||||
Stop-Trace $script:wsmsession -ets
|
Stop-Trace $script:wsmsession -ETS
|
||||||
}
|
}
|
||||||
|
|
||||||
function Enable-PSWSManCombinedTrace
|
function Enable-PSWSManCombinedTrace
|
||||||
@ -177,27 +177,27 @@ function Enable-PSWSManCombinedTrace
|
|||||||
$logfile = $PSHOME + "\\Traces\\PSTrace.etl"
|
$logfile = $PSHOME + "\\Traces\\PSTrace.etl"
|
||||||
}
|
}
|
||||||
|
|
||||||
"Microsoft-Windows-PowerShell 0 5" | out-file $provfile -encoding ascii
|
"Microsoft-Windows-PowerShell 0 5" | Out-File $provfile -Encoding ascii
|
||||||
"Microsoft-Windows-WinRM 0 5" | out-file $provfile -encoding ascii -append
|
"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)
|
if (Test-Path $logfile)
|
||||||
{
|
{
|
||||||
Remove-Item -Force $logfile | out-null
|
Remove-Item -Force $logfile | Out-Null
|
||||||
}
|
}
|
||||||
|
|
||||||
Start-Trace -SessionName $script:pssession -OutputFilePath $logfile -ProviderFilePath $provfile -ets
|
Start-Trace -SessionName $script:pssession -OutputFilePath $logfile -ProviderFilePath $provfile -ETS
|
||||||
|
|
||||||
remove-item $provfile -Force -ea 0
|
Remove-Item $provfile -Force -ea 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function Disable-PSWSManCombinedTrace
|
function Disable-PSWSManCombinedTrace
|
||||||
{
|
{
|
||||||
Stop-Trace -SessionName $script:pssession -ets
|
Stop-Trace -SessionName $script:pssession -ETS
|
||||||
}
|
}
|
||||||
|
|
||||||
function Set-LogProperties
|
function Set-LogProperties
|
||||||
@ -220,7 +220,7 @@ function Set-LogProperties
|
|||||||
$retention = $LogDetails.Retention.ToString()
|
$retention = $LogDetails.Retention.ToString()
|
||||||
$autobackup = $LogDetails.AutoBackup.ToString()
|
$autobackup = $LogDetails.AutoBackup.ToString()
|
||||||
$maxLogSize = $LogDetails.MaxLogSize.ToString()
|
$maxLogSize = $LogDetails.MaxLogSize.ToString()
|
||||||
$osVersion = [Version] (Get-Ciminstance Win32_OperatingSystem).Version
|
$osVersion = [Version] (Get-CimInstance Win32_OperatingSystem).Version
|
||||||
|
|
||||||
if (($LogDetails.Type -eq "Analytic") -or ($LogDetails.Type -eq "Debug"))
|
if (($LogDetails.Type -eq "Analytic") -or ($LogDetails.Type -eq "Debug"))
|
||||||
{
|
{
|
||||||
@ -347,7 +347,7 @@ function Disable-PSTrace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add-type @"
|
Add-Type @"
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Microsoft.PowerShell.Diagnostics
|
namespace Microsoft.PowerShell.Diagnostics
|
||||||
|
@ -215,7 +215,7 @@ function Install-PluginEndpoint {
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Write-Host "`nGet-PSSessionConfiguration $pluginEndpointName" -foregroundcolor "green"
|
Write-Host "`nGet-PSSessionConfiguration $pluginEndpointName" -ForegroundColor "green"
|
||||||
Get-PSSessionConfiguration $pluginEndpointName -ErrorAction Stop
|
Get-PSSessionConfiguration $pluginEndpointName -ErrorAction Stop
|
||||||
}
|
}
|
||||||
catch [Microsoft.PowerShell.Commands.WriteErrorException]
|
catch [Microsoft.PowerShell.Commands.WriteErrorException]
|
||||||
@ -227,6 +227,6 @@ function Install-PluginEndpoint {
|
|||||||
Install-PluginEndpoint -Force $Force
|
Install-PluginEndpoint -Force $Force
|
||||||
Install-PluginEndpoint -Force $Force -VersionIndependent
|
Install-PluginEndpoint -Force $Force -VersionIndependent
|
||||||
|
|
||||||
Write-Host "Restarting WinRM to ensure that the plugin configuration change takes effect.`nThis is required for WinRM running on Windows SKUs prior to Windows 10." -foregroundcolor Magenta
|
Write-Host "Restarting WinRM to ensure that the plugin configuration change takes effect.`nThis is required for WinRM running on Windows SKUs prior to Windows 10." -ForegroundColor Magenta
|
||||||
Restart-Service winrm
|
Restart-Service winrm
|
||||||
|
|
||||||
|
@ -23,8 +23,8 @@ Describe "SSHRemoting Basic Tests" -tags CI {
|
|||||||
Context "New-PSSession Tests" {
|
Context "New-PSSession Tests" {
|
||||||
|
|
||||||
AfterEach {
|
AfterEach {
|
||||||
if ($script:session -ne $null) { Remove-PSSession -session $script:session }
|
if ($script:session -ne $null) { Remove-PSSession -Session $script:session }
|
||||||
if ($script:sessions -ne $null) { Remove-PSSession -session $script:sessions }
|
if ($script:sessions -ne $null) { Remove-PSSession -Session $script:sessions }
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Verifies new connection with implicit current User" {
|
It "Verifies new connection with implicit current User" {
|
||||||
|
@ -17,12 +17,12 @@ Describe "Verify Markdown Links" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Cleanup jobs for reliability
|
# Cleanup jobs for reliability
|
||||||
get-job | remove-job -force
|
Get-Job | Remove-Job -Force
|
||||||
}
|
}
|
||||||
|
|
||||||
AfterAll {
|
AfterAll {
|
||||||
# Cleanup jobs to leave the process the same
|
# Cleanup jobs to leave the process the same
|
||||||
get-job | remove-job -force
|
Get-Job | Remove-Job -Force
|
||||||
}
|
}
|
||||||
|
|
||||||
$groups = Get-ChildItem -Path "$PSScriptRoot\..\..\..\*.md" -Recurse | Where-Object {$_.DirectoryName -notlike '*node_modules*'} | Group-Object -Property directory
|
$groups = Get-ChildItem -Path "$PSScriptRoot\..\..\..\*.md" -Recurse | Where-Object {$_.DirectoryName -notlike '*node_modules*'} | Group-Object -Property directory
|
||||||
@ -31,7 +31,7 @@ Describe "Verify Markdown Links" {
|
|||||||
# start all link verification in parallel
|
# start all link verification in parallel
|
||||||
Foreach($group in $groups)
|
Foreach($group in $groups)
|
||||||
{
|
{
|
||||||
Write-Verbose -verbose "starting jobs for $($group.Name) ..."
|
Write-Verbose -Verbose "starting jobs for $($group.Name) ..."
|
||||||
$job = Start-ThreadJob {
|
$job = Start-ThreadJob {
|
||||||
param([object] $group)
|
param([object] $group)
|
||||||
foreach($file in $group.Group)
|
foreach($file in $group.Group)
|
||||||
@ -46,13 +46,13 @@ Describe "Verify Markdown Links" {
|
|||||||
$jobs.add($group.name,$job)
|
$jobs.add($group.name,$job)
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Verbose -verbose "Getting results ..."
|
Write-Verbose -Verbose "Getting results ..."
|
||||||
# Get the results and verify
|
# Get the results and verify
|
||||||
foreach($key in $jobs.keys)
|
foreach($key in $jobs.keys)
|
||||||
{
|
{
|
||||||
$job = $jobs.$key
|
$job = $jobs.$key
|
||||||
$results = Receive-Job -Job $job -Wait
|
$results = Receive-Job -Job $job -Wait
|
||||||
Remove-job -job $Job
|
Remove-Job -Job $Job
|
||||||
foreach($jobResult in $results)
|
foreach($jobResult in $results)
|
||||||
{
|
{
|
||||||
$file = $jobResult.file
|
$file = $jobResult.file
|
||||||
@ -85,14 +85,14 @@ Describe "Verify Markdown Links" {
|
|||||||
|
|
||||||
if($passes)
|
if($passes)
|
||||||
{
|
{
|
||||||
it "<url> should work" -TestCases $passes {
|
It "<url> should work" -TestCases $passes {
|
||||||
noop
|
noop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($trueFailures)
|
if($trueFailures)
|
||||||
{
|
{
|
||||||
it "<url> should work" -TestCases $trueFailures {
|
It "<url> should work" -TestCases $trueFailures {
|
||||||
param($url)
|
param($url)
|
||||||
|
|
||||||
# there could be multiple reasons why a failure is ok
|
# there could be multiple reasons why a failure is ok
|
||||||
@ -111,7 +111,7 @@ Describe "Verify Markdown Links" {
|
|||||||
# If invoke-WebRequest can handle the URL, re-verify, with 6 retries
|
# If invoke-WebRequest can handle the URL, re-verify, with 6 retries
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$null = Invoke-WebRequest -uri $url -RetryIntervalSec 10 -MaximumRetryCount 6
|
$null = Invoke-WebRequest -Uri $url -RetryIntervalSec 10 -MaximumRetryCount 6
|
||||||
}
|
}
|
||||||
catch [Microsoft.PowerShell.Commands.HttpResponseException]
|
catch [Microsoft.PowerShell.Commands.HttpResponseException]
|
||||||
{
|
{
|
||||||
@ -128,7 +128,7 @@ Describe "Verify Markdown Links" {
|
|||||||
|
|
||||||
if($verifyFailures)
|
if($verifyFailures)
|
||||||
{
|
{
|
||||||
it "<url> should work" -TestCases $verifyFailures -Pending {
|
It "<url> should work" -TestCases $verifyFailures -Pending {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ Describe "Basic remoting test with docker" -tags @("Scenario","Slow"){
|
|||||||
$dockerimage = docker images --format "{{ .Repository }}" $imageName
|
$dockerimage = docker images --format "{{ .Repository }}" $imageName
|
||||||
if ( $dockerimage -ne $imageName ) {
|
if ( $dockerimage -ne $imageName ) {
|
||||||
$pending = $true
|
$pending = $true
|
||||||
write-warning "Docker image '$imageName' not found, not running tests"
|
Write-Warning "Docker image '$imageName' not found, not running tests"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -15,18 +15,18 @@ Describe "Basic remoting test with docker" -tags @("Scenario","Slow"){
|
|||||||
}
|
}
|
||||||
|
|
||||||
# give the containers something to do, otherwise they will exit and be removed
|
# give the containers something to do, otherwise they will exit and be removed
|
||||||
Write-Verbose -verbose "setting up docker container PowerShell server"
|
Write-Verbose -Verbose "setting up docker container PowerShell server"
|
||||||
$server = docker run -d $imageName powershell -c Start-Sleep -Seconds $timeout
|
$server = docker run -d $imageName powershell -c Start-Sleep -Seconds $timeout
|
||||||
Write-Verbose -verbose "setting up docker container PowerShell client"
|
Write-Verbose -Verbose "setting up docker container PowerShell client"
|
||||||
$client = docker run -d $imageName powershell -c Start-Sleep -Seconds $timeout
|
$client = docker run -d $imageName powershell -c Start-Sleep -Seconds $timeout
|
||||||
|
|
||||||
# get fullpath to installed core powershell
|
# get fullpath to installed core powershell
|
||||||
Write-Verbose -verbose "Getting path to PowerShell"
|
Write-Verbose -Verbose "Getting path to PowerShell"
|
||||||
$powershellcorepath = docker exec $server powershell -c "(get-childitem 'c:\program files\powershell\*\pwsh.exe').fullname"
|
$powershellcorepath = docker exec $server powershell -c "(get-childitem 'c:\program files\powershell\*\pwsh.exe').fullname"
|
||||||
if ( ! $powershellcorepath )
|
if ( ! $powershellcorepath )
|
||||||
{
|
{
|
||||||
$pending = $true
|
$pending = $true
|
||||||
write-warning "Cannot find powershell executable, not running tests"
|
Write-Warning "Cannot find powershell executable, not running tests"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
$powershellcoreversion = ($powershellcorepath -split "[\\/]")[-2]
|
$powershellcoreversion = ($powershellcorepath -split "[\\/]")[-2]
|
||||||
@ -34,27 +34,27 @@ Describe "Basic remoting test with docker" -tags @("Scenario","Slow"){
|
|||||||
$powershellcoreConfiguration = "powershell.${powershellcoreversion}"
|
$powershellcoreConfiguration = "powershell.${powershellcoreversion}"
|
||||||
|
|
||||||
# capture the hostnames of the containers which will be used by the tests
|
# capture the hostnames of the containers which will be used by the tests
|
||||||
write-verbose -verbose "getting server hostname"
|
Write-Verbose -Verbose "getting server hostname"
|
||||||
$serverhostname = docker exec $server hostname
|
$serverhostname = docker exec $server hostname
|
||||||
write-verbose -verbose "getting client hostname"
|
Write-Verbose -Verbose "getting client hostname"
|
||||||
$clienthostname = docker exec $client hostname
|
$clienthostname = docker exec $client hostname
|
||||||
|
|
||||||
# capture the versions of full and core PowerShell
|
# capture the versions of full and core PowerShell
|
||||||
write-verbose -verbose "getting powershell full version"
|
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 )
|
if ( ! $fullVersion )
|
||||||
{
|
{
|
||||||
$pending = $true
|
$pending = $true
|
||||||
write-warning "Cannot determine PowerShell full version, not running tests"
|
Write-Warning "Cannot determine PowerShell full version, not running tests"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
write-verbose -verbose "getting powershell version"
|
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 )
|
if ( ! $coreVersion )
|
||||||
{
|
{
|
||||||
$pending = $true
|
$pending = $true
|
||||||
write-warning "Cannot determine PowerShell version, not running tests"
|
Write-Warning "Cannot determine PowerShell version, not running tests"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -67,22 +67,22 @@ Describe "Basic remoting test with docker" -tags @("Scenario","Slow"){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Full powershell can get correct remote powershell version" -pending:$pending {
|
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
|
$result | Should -Be $coreVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Full powershell can get correct remote powershell full version" -pending:$pending {
|
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
|
$result | Should -Be $fullVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Core powershell can get correct remote powershell version" -pending:$pending {
|
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
|
$result | Should -Be $coreVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Core powershell can get correct remote powershell full version" -pending:$pending {
|
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
|
$result | Should -Be $fullVersion
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ $script:Constants = @{
|
|||||||
|
|
||||||
#### DOCKER OPS #####
|
#### DOCKER OPS #####
|
||||||
# is docker installed?
|
# is docker installed?
|
||||||
$dockerExe = get-command docker -ea silentlycontinue
|
$dockerExe = Get-Command docker -ea silentlycontinue
|
||||||
if ( $dockerExe.name -ne "docker.exe" ) {
|
if ( $dockerExe.name -ne "docker.exe" ) {
|
||||||
throw "Cannot find docker, is it installed?"
|
throw "Cannot find docker, is it installed?"
|
||||||
}
|
}
|
||||||
@ -43,7 +43,7 @@ if ( $TestImage -eq $Constants.TestImageName)
|
|||||||
|
|
||||||
#### MSI CHECKS ####
|
#### MSI CHECKS ####
|
||||||
# check to see if the MSI is present
|
# check to see if the MSI is present
|
||||||
$MsiExists = test-path $Constants.MsiName
|
$MsiExists = Test-Path $Constants.MsiName
|
||||||
$msg = "{0} exists, use -Force to remove or -UseExistingMsi to use" -f $Constants.MsiName
|
$msg = "{0} exists, use -Force to remove or -UseExistingMsi to use" -f $Constants.MsiName
|
||||||
if ( $MsiExists -and ! ($force -or $useExistingMsi))
|
if ( $MsiExists -and ! ($force -or $useExistingMsi))
|
||||||
{
|
{
|
||||||
@ -53,7 +53,7 @@ if ( $MsiExists -and ! ($force -or $useExistingMsi))
|
|||||||
# remove the msi
|
# remove the msi
|
||||||
if ( $MsiExists -and $Force -and ! $UseExistingMsi )
|
if ( $MsiExists -and $Force -and ! $UseExistingMsi )
|
||||||
{
|
{
|
||||||
Remove-Item -force $Constants.MsiName
|
Remove-Item -Force $Constants.MsiName
|
||||||
$MsiExists = $false
|
$MsiExists = $false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ elseif ( $MsiExists -and ! $UseExistingMsi )
|
|||||||
}
|
}
|
||||||
|
|
||||||
# last check before bulding the image
|
# last check before bulding the image
|
||||||
if ( ! (test-path $Constants.MsiName) )
|
if ( ! (Test-Path $Constants.MsiName) )
|
||||||
{
|
{
|
||||||
throw ("{0} does not exist, giving up" -f $Constants.MsiName)
|
throw ("{0} does not exist, giving up" -f $Constants.MsiName)
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
Describe "Verify PowerShell Runs" {
|
Describe "Verify PowerShell Runs" {
|
||||||
BeforeAll{
|
BeforeAll{
|
||||||
$options = (Get-PSOptions)
|
$options = (Get-PSOptions)
|
||||||
$path = split-path -path $options.Output
|
$path = Split-Path -Path $options.Output
|
||||||
Write-Verbose "Path: '$path'" -Verbose
|
Write-Verbose "Path: '$path'" -Verbose
|
||||||
$rootPath = split-Path -path $path
|
$rootPath = Split-Path -Path $path
|
||||||
$mount = 'C:\powershell'
|
$mount = 'C:\powershell'
|
||||||
$container = 'mcr.microsoft.com/powershell:nanoserver-1803'
|
$container = 'mcr.microsoft.com/powershell:nanoserver-1803'
|
||||||
}
|
}
|
||||||
|
|
||||||
it "Verify Version " {
|
It "Verify Version " {
|
||||||
$version = docker run --rm -v "${rootPath}:${mount}" ${container} "${mount}\publish\pwsh" -NoLogo -NoProfile -Command '$PSVersionTable.PSVersion.ToString()'
|
$version = docker run --rm -v "${rootPath}:${mount}" ${container} "${mount}\publish\pwsh" -NoLogo -NoProfile -Command '$PSVersionTable.PSVersion.ToString()'
|
||||||
$version | Should -Match '^7\.'
|
$version | Should -Match '^7\.'
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ Describe "Configuration file locations" -tags "CI","Slow" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
It @ItArgs "PSReadLine history save location should be correct" {
|
It @ItArgs "PSReadLine history save location should be correct" {
|
||||||
& $powershell -noprofile { (Get-PSReadlineOption).HistorySavePath } | Should -Be $expectedReadline
|
& $powershell -noprofile { (Get-PSReadLineOption).HistorySavePath } | Should -Be $expectedReadline
|
||||||
}
|
}
|
||||||
|
|
||||||
# This feature (and thus test) has been disabled because of the AssemblyLoadContext scenario
|
# This feature (and thus test) has been disabled because of the AssemblyLoadContext scenario
|
||||||
@ -104,7 +104,7 @@ Describe "Configuration file locations" -tags "CI","Slow" {
|
|||||||
It @ItArgs "PSReadLine history should respect XDG_DATA_HOME" {
|
It @ItArgs "PSReadLine history should respect XDG_DATA_HOME" {
|
||||||
$env:XDG_DATA_HOME = $TestDrive
|
$env:XDG_DATA_HOME = $TestDrive
|
||||||
$expected = [IO.Path]::Combine($TestDrive, "powershell", "PSReadLine", "ConsoleHost_history.txt")
|
$expected = [IO.Path]::Combine($TestDrive, "powershell", "PSReadLine", "ConsoleHost_history.txt")
|
||||||
& $powershell -noprofile { (Get-PSReadlineOption).HistorySavePath } | Should -Be $expected
|
& $powershell -noprofile { (Get-PSReadLineOption).HistorySavePath } | Should -Be $expected
|
||||||
}
|
}
|
||||||
|
|
||||||
# This feature (and thus test) has been disabled because of the AssemblyLoadContext scenario
|
# This feature (and thus test) has been disabled because of the AssemblyLoadContext scenario
|
||||||
|
@ -351,12 +351,12 @@ export $envVarName='$guid'
|
|||||||
# must use an explicit scope of LocalMachine to ensure the setting is written to the expected file.
|
# must use an explicit scope of LocalMachine to ensure the setting is written to the expected file.
|
||||||
# Skip the tests on Unix platforms because *-ExecutionPolicy cmdlets don't work by design.
|
# Skip the tests on Unix platforms because *-ExecutionPolicy cmdlets don't work by design.
|
||||||
|
|
||||||
It "Verifies PowerShell reads from the custom -settingsFile" -skip:(!$IsWindows) {
|
It "Verifies PowerShell reads from the custom -settingsFile" -Skip:(!$IsWindows) {
|
||||||
$actualValue = & $powershell -NoProfile -SettingsFile $CustomSettingsFile -Command {(Get-ExecutionPolicy -Scope LocalMachine).ToString()}
|
$actualValue = & $powershell -NoProfile -SettingsFile $CustomSettingsFile -Command {(Get-ExecutionPolicy -Scope LocalMachine).ToString()}
|
||||||
$actualValue | Should -Be $DefaultExecutionPolicy
|
$actualValue | Should -Be $DefaultExecutionPolicy
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Verifies PowerShell writes to the custom -settingsFile" -skip:(!$IsWindows) {
|
It "Verifies PowerShell writes to the custom -settingsFile" -Skip:(!$IsWindows) {
|
||||||
$expectedValue = 'AllSigned'
|
$expectedValue = 'AllSigned'
|
||||||
|
|
||||||
# Update the execution policy; this should update the settings file.
|
# Update the execution policy; this should update the settings file.
|
||||||
@ -371,7 +371,7 @@ export $envVarName='$guid'
|
|||||||
$actualValue | Should -Be $expectedValue
|
$actualValue | Should -Be $expectedValue
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Verify PowerShell removes a setting from the custom -settingsFile" -skip:(!$IsWindows) {
|
It "Verify PowerShell removes a setting from the custom -settingsFile" -Skip:(!$IsWindows) {
|
||||||
# Remove the LocalMachine execution policy; this should update the settings file.
|
# Remove the LocalMachine execution policy; this should update the settings file.
|
||||||
& $powershell -NoProfile -SettingsFile $CustomSettingsFile -Command {Set-ExecutionPolicy -ExecutionPolicy Undefined -Scope LocalMachine }
|
& $powershell -NoProfile -SettingsFile $CustomSettingsFile -Command {Set-ExecutionPolicy -ExecutionPolicy Undefined -Scope LocalMachine }
|
||||||
|
|
||||||
@ -385,8 +385,8 @@ export $envVarName='$guid'
|
|||||||
$p = [PSCustomObject]@{X=10;Y=20}
|
$p = [PSCustomObject]@{X=10;Y=20}
|
||||||
|
|
||||||
It "xml input" {
|
It "xml input" {
|
||||||
$p | & $powershell -noprofile { $input | Foreach-Object {$a = 0} { $a += $_.X + $_.Y } { $a } } | Should -Be 30
|
$p | & $powershell -noprofile { $input | ForEach-Object {$a = 0} { $a += $_.X + $_.Y } { $a } } | Should -Be 30
|
||||||
$p | & $powershell -noprofile -inputFormat xml { $input | Foreach-Object {$a = 0} { $a += $_.X + $_.Y } { $a } } | Should -Be 30
|
$p | & $powershell -noprofile -inputFormat xml { $input | ForEach-Object {$a = 0} { $a += $_.X + $_.Y } { $a } } | Should -Be 30
|
||||||
}
|
}
|
||||||
|
|
||||||
It "text input" {
|
It "text input" {
|
||||||
@ -395,8 +395,8 @@ export $envVarName='$guid'
|
|||||||
}
|
}
|
||||||
|
|
||||||
It "xml output" {
|
It "xml output" {
|
||||||
& $powershell -noprofile { [PSCustomObject]@{X=10;Y=20} } | Foreach-Object {$a = 0} { $a += $_.X + $_.Y } { $a } | Should -Be 30
|
& $powershell -noprofile { [PSCustomObject]@{X=10;Y=20} } | ForEach-Object {$a = 0} { $a += $_.X + $_.Y } { $a } | Should -Be 30
|
||||||
& $powershell -noprofile -outputFormat xml { [PSCustomObject]@{X=10;Y=20} } | Foreach-Object {$a = 0} { $a += $_.X + $_.Y } { $a } | Should -Be 30
|
& $powershell -noprofile -outputFormat xml { [PSCustomObject]@{X=10;Y=20} } | ForEach-Object {$a = 0} { $a += $_.X + $_.Y } { $a } | Should -Be 30
|
||||||
}
|
}
|
||||||
|
|
||||||
It "text output" {
|
It "text output" {
|
||||||
@ -638,17 +638,17 @@ namespace StackTest {
|
|||||||
$env:XDG_CONFIG_HOME = $XDG_CONFIG_HOME
|
$env:XDG_CONFIG_HOME = $XDG_CONFIG_HOME
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Should start if Data, Config, and Cache location is not accessible" -skip:($IsWindows) {
|
It "Should start if Data, Config, and Cache location is not accessible" -Skip:($IsWindows) {
|
||||||
$env:XDG_CACHE_HOME = "/dev/cpu"
|
$env:XDG_CACHE_HOME = "/dev/cpu"
|
||||||
$env:XDG_DATA_HOME = "/dev/cpu"
|
$env:XDG_DATA_HOME = "/dev/cpu"
|
||||||
$env:XDG_CONFIG_HOME = "/dev/cpu"
|
$env:XDG_CONFIG_HOME = "/dev/cpu"
|
||||||
$output = & $powershell -noprofile -Command { (get-command).count }
|
$output = & $powershell -noprofile -Command { (Get-Command).count }
|
||||||
[int]$output | Should -BeGreaterThan 0
|
[int]$output | Should -BeGreaterThan 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Context "HOME environment variable" {
|
Context "HOME environment variable" {
|
||||||
It "Should start if HOME is not defined" -skip:($IsWindows) {
|
It "Should start if HOME is not defined" -Skip:($IsWindows) {
|
||||||
bash -c "unset HOME;$powershell -c '1+1'" | Should -BeExactly 2
|
bash -c "unset HOME;$powershell -c '1+1'" | Should -BeExactly 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -769,7 +769,7 @@ namespace StackTest {
|
|||||||
Context "ApartmentState WPF tests" -Tag Slow {
|
Context "ApartmentState WPF tests" -Tag Slow {
|
||||||
|
|
||||||
It "WPF requires STA and will work" -Skip:(!$IsWindows -or [System.Management.Automation.Platform]::IsNanoServer) {
|
It "WPF requires STA and will work" -Skip:(!$IsWindows -or [System.Management.Automation.Platform]::IsNanoServer) {
|
||||||
add-type -AssemblyName presentationframework
|
Add-Type -AssemblyName presentationframework
|
||||||
|
|
||||||
$xaml = [xml]@"
|
$xaml = [xml]@"
|
||||||
<Window
|
<Window
|
||||||
@ -970,12 +970,12 @@ Describe 'Pwsh startup in directories that contain wild cards' -Tag CI {
|
|||||||
$dirnames = "[T]est","[Test","T][est","Test"
|
$dirnames = "[T]est","[Test","T][est","Test"
|
||||||
$testcases = @()
|
$testcases = @()
|
||||||
foreach ( $d in $dirnames ) {
|
foreach ( $d in $dirnames ) {
|
||||||
$null = New-Item -type Directory -path "${TESTDRIVE}/$d"
|
$null = New-Item -type Directory -Path "${TESTDRIVE}/$d"
|
||||||
$testcases += @{ Dirname = $d }
|
$testcases += @{ Dirname = $d }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
It "pwsh can startup in a directory named <dirname>" -testcases $testcases {
|
It "pwsh can startup in a directory named <dirname>" -TestCases $testcases {
|
||||||
param ( $dirname )
|
param ( $dirname )
|
||||||
try {
|
try {
|
||||||
Push-Location -LiteralPath "${TESTDRIVE}/${dirname}"
|
Push-Location -LiteralPath "${TESTDRIVE}/${dirname}"
|
||||||
@ -1013,6 +1013,6 @@ Describe 'Pwsh startup and PATH' -Tag CI {
|
|||||||
Describe 'Console host name' -Tag CI {
|
Describe 'Console host name' -Tag CI {
|
||||||
It 'Name is pwsh' -Pending {
|
It 'Name is pwsh' -Pending {
|
||||||
# waiting on https://github.com/dotnet/runtime/issues/33673
|
# waiting on https://github.com/dotnet/runtime/issues/33673
|
||||||
(Get-Process -id $PID).Name | Should -BeExactly 'pwsh'
|
(Get-Process -Id $PID).Name | Should -BeExactly 'pwsh'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,7 @@ $PID
|
|||||||
|
|
||||||
$items | Should -Not -Be $null
|
$items | Should -Not -Be $null
|
||||||
$items.Count | Should -BeGreaterThan 2
|
$items.Count | Should -BeGreaterThan 2
|
||||||
$createdEvents = $items | where-object {$_.EventId -eq 'ScriptBlock_Compile_Detail:ExecuteCommand.Create.Verbose'}
|
$createdEvents = $items | Where-Object {$_.EventId -eq 'ScriptBlock_Compile_Detail:ExecuteCommand.Create.Verbose'}
|
||||||
$createdEvents.Count | Should -BeGreaterOrEqual 3
|
$createdEvents.Count | Should -BeGreaterOrEqual 3
|
||||||
|
|
||||||
# Verify we log that we are executing a file
|
# Verify we log that we are executing a file
|
||||||
@ -233,7 +233,7 @@ $PID
|
|||||||
|
|
||||||
$items | Should -Not -Be $null
|
$items | Should -Not -Be $null
|
||||||
$items.Count | Should -BeGreaterThan 2
|
$items.Count | Should -BeGreaterThan 2
|
||||||
$createdEvents = $items | where-object {$_.EventId -eq 'ScriptBlock_Compile_Detail:ExecuteCommand.Create.Verbose'}
|
$createdEvents = $items | Where-Object {$_.EventId -eq 'ScriptBlock_Compile_Detail:ExecuteCommand.Create.Verbose'}
|
||||||
$createdEvents.Count | Should -BeGreaterOrEqual 3
|
$createdEvents.Count | Should -BeGreaterOrEqual 3
|
||||||
|
|
||||||
# Verify we log that we are executing a file
|
# Verify we log that we are executing a file
|
||||||
@ -353,7 +353,7 @@ $PID
|
|||||||
|
|
||||||
$items | Should -Not -Be $null
|
$items | Should -Not -Be $null
|
||||||
$items.Count | Should -BeGreaterThan 2
|
$items.Count | Should -BeGreaterThan 2
|
||||||
$createdEvents = $items | where-object {$_.EventId -eq 'ScriptBlock_Compile_Detail:ExecuteCommand.Create.Verbose'}
|
$createdEvents = $items | Where-Object {$_.EventId -eq 'ScriptBlock_Compile_Detail:ExecuteCommand.Create.Verbose'}
|
||||||
$createdEvents.Count | Should -BeGreaterOrEqual 3
|
$createdEvents.Count | Should -BeGreaterOrEqual 3
|
||||||
|
|
||||||
# Verify we log that we are executing a file
|
# Verify we log that we are executing a file
|
||||||
@ -391,7 +391,7 @@ $PID
|
|||||||
|
|
||||||
$items | Should -Not -Be $null
|
$items | Should -Not -Be $null
|
||||||
$items.Count | Should -BeGreaterThan 2
|
$items.Count | Should -BeGreaterThan 2
|
||||||
$createdEvents = $items | where-object {$_.EventId -eq 'ScriptBlock_Compile_Detail:ExecuteCommand.Create.Verbose'}
|
$createdEvents = $items | Where-Object {$_.EventId -eq 'ScriptBlock_Compile_Detail:ExecuteCommand.Create.Verbose'}
|
||||||
$createdEvents.Count | Should -BeGreaterOrEqual 3
|
$createdEvents.Count | Should -BeGreaterOrEqual 3
|
||||||
|
|
||||||
# Verify we log that we are executing a file
|
# Verify we log that we are executing a file
|
||||||
|
@ -105,8 +105,8 @@ Describe "Validate start of console host" -Tag CI {
|
|||||||
$diffs = Compare-Object -ReferenceObject $allowedAssemblies -DifferenceObject $loadedAssemblies
|
$diffs = Compare-Object -ReferenceObject $allowedAssemblies -DifferenceObject $loadedAssemblies
|
||||||
|
|
||||||
if ($null -ne $diffs) {
|
if ($null -ne $diffs) {
|
||||||
$assembliesAllowedButNotLoaded = $diffs | Where-Object SideIndicator -eq "<=" | ForEach-Object InputObject
|
$assembliesAllowedButNotLoaded = $diffs | Where-Object SideIndicator -EQ "<=" | ForEach-Object InputObject
|
||||||
$assembliesLoadedButNotAllowed = $diffs | Where-Object SideIndicator -eq "=>" | ForEach-Object InputObject
|
$assembliesLoadedButNotAllowed = $diffs | Where-Object SideIndicator -EQ "=>" | ForEach-Object InputObject
|
||||||
|
|
||||||
if ($assembliesAllowedButNotLoaded) {
|
if ($assembliesAllowedButNotLoaded) {
|
||||||
Write-Host ("Assemblies that are expected but not loaded: {0}" -f ($assembliesAllowedButNotLoaded -join ", "))
|
Write-Host ("Assemblies that are expected but not loaded: {0}" -f ($assembliesAllowedButNotLoaded -join ", "))
|
||||||
|
@ -34,12 +34,12 @@ Describe "TabCompletion" -Tags CI {
|
|||||||
$res.CompletionMatches[0].CompletionText | Should -BeExactly 'ToString('
|
$res.CompletionMatches[0].CompletionText | Should -BeExactly 'ToString('
|
||||||
}
|
}
|
||||||
|
|
||||||
It 'Should complete dotnet method with null conditional operator' -skip:$nullConditionalFeatureDisabled {
|
It 'Should complete dotnet method with null conditional operator' -Skip:$nullConditionalFeatureDisabled {
|
||||||
$res = TabExpansion2 -inputScript '(1)?.ToSt' -cursorColumn '(1)?.ToSt'.Length
|
$res = TabExpansion2 -inputScript '(1)?.ToSt' -cursorColumn '(1)?.ToSt'.Length
|
||||||
$res.CompletionMatches[0].CompletionText | Should -BeExactly 'ToString('
|
$res.CompletionMatches[0].CompletionText | Should -BeExactly 'ToString('
|
||||||
}
|
}
|
||||||
|
|
||||||
It 'Should complete dotnet method with null conditional operator without first letter' -skip:$nullConditionalFeatureDisabled {
|
It 'Should complete dotnet method with null conditional operator without first letter' -Skip:$nullConditionalFeatureDisabled {
|
||||||
$res = TabExpansion2 -inputScript '(1)?.' -cursorColumn '(1)?.'.Length
|
$res = TabExpansion2 -inputScript '(1)?.' -cursorColumn '(1)?.'.Length
|
||||||
$res.CompletionMatches[0].CompletionText | Should -BeExactly 'CompareTo('
|
$res.CompletionMatches[0].CompletionText | Should -BeExactly 'CompareTo('
|
||||||
}
|
}
|
||||||
@ -147,18 +147,18 @@ Describe "TabCompletion" -Tags CI {
|
|||||||
$res.CompletionMatches.Count | Should -BeGreaterThan 0
|
$res.CompletionMatches.Count | Should -BeGreaterThan 0
|
||||||
}
|
}
|
||||||
|
|
||||||
It 'Should complete keyword' -skip {
|
It 'Should complete keyword' -Skip {
|
||||||
$res = TabExpansion2 -inputScript 'using nam' -cursorColumn 'using nam'.Length
|
$res = TabExpansion2 -inputScript 'using nam' -cursorColumn 'using nam'.Length
|
||||||
$res.CompletionMatches[0].CompletionText | Should -BeExactly 'namespace'
|
$res.CompletionMatches[0].CompletionText | Should -BeExactly 'namespace'
|
||||||
}
|
}
|
||||||
|
|
||||||
It 'Should first suggest -Full and then -Functionality when using Get-Help -Fu<tab>' -skip {
|
It 'Should first suggest -Full and then -Functionality when using Get-Help -Fu<tab>' -Skip {
|
||||||
$res = TabExpansion2 -inputScript 'Get-Help -Fu' -cursorColumn 'Get-Help -Fu'.Length
|
$res = TabExpansion2 -inputScript 'Get-Help -Fu' -cursorColumn 'Get-Help -Fu'.Length
|
||||||
$res.CompletionMatches[0].CompletionText | Should -BeExactly '-Full'
|
$res.CompletionMatches[0].CompletionText | Should -BeExactly '-Full'
|
||||||
$res.CompletionMatches[1].CompletionText | Should -BeExactly '-Functionality'
|
$res.CompletionMatches[1].CompletionText | Should -BeExactly '-Functionality'
|
||||||
}
|
}
|
||||||
|
|
||||||
It 'Should first suggest -Full and then -Functionality when using help -Fu<tab>' -skip {
|
It 'Should first suggest -Full and then -Functionality when using help -Fu<tab>' -Skip {
|
||||||
$res = TabExpansion2 -inputScript 'help -Fu' -cursorColumn 'help -Fu'.Length
|
$res = TabExpansion2 -inputScript 'help -Fu' -cursorColumn 'help -Fu'.Length
|
||||||
$res.CompletionMatches[0].CompletionText | Should -BeExactly '-Full'
|
$res.CompletionMatches[0].CompletionText | Should -BeExactly '-Full'
|
||||||
$res.CompletionMatches[1].CompletionText | Should -BeExactly '-Functionality'
|
$res.CompletionMatches[1].CompletionText | Should -BeExactly '-Functionality'
|
||||||
@ -349,7 +349,7 @@ Describe "TabCompletion" -Tags CI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$line = "$nativeCommand --f"
|
$line = "$nativeCommand --f"
|
||||||
$res = TaBexpansion2 -inputScript $line -cursorColumn $line.Length
|
$res = TabExpansion2 -inputScript $line -cursorColumn $line.Length
|
||||||
$res.CompletionMatches | Should -HaveCount 1
|
$res.CompletionMatches | Should -HaveCount 1
|
||||||
$res.CompletionMatches.CompletionText | Should -BeExactly "--flag"
|
$res.CompletionMatches.CompletionText | Should -BeExactly "--flag"
|
||||||
}
|
}
|
||||||
@ -365,7 +365,7 @@ Describe "TabCompletion" -Tags CI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$line = "$nativeCommand -o"
|
$line = "$nativeCommand -o"
|
||||||
$res = TaBexpansion2 -inputScript $line -cursorColumn $line.Length
|
$res = TabExpansion2 -inputScript $line -cursorColumn $line.Length
|
||||||
$res.CompletionMatches | Should -HaveCount 1
|
$res.CompletionMatches | Should -HaveCount 1
|
||||||
$res.CompletionMatches.CompletionText | Should -BeExactly "-option"
|
$res.CompletionMatches.CompletionText | Should -BeExactly "-option"
|
||||||
}
|
}
|
||||||
@ -380,8 +380,8 @@ Describe "TabCompletion" -Tags CI {
|
|||||||
|
|
||||||
Context "Script name completion" {
|
Context "Script name completion" {
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
setup -f 'install-powershell.ps1' -content ""
|
Setup -f 'install-powershell.ps1' -Content ""
|
||||||
setup -f 'remove-powershell.ps1' -content ""
|
Setup -f 'remove-powershell.ps1' -Content ""
|
||||||
|
|
||||||
$scriptWithWildcardCases = @(
|
$scriptWithWildcardCases = @(
|
||||||
@{
|
@{
|
||||||
@ -415,7 +415,7 @@ Describe "TabCompletion" -Tags CI {
|
|||||||
Pop-Location
|
Pop-Location
|
||||||
}
|
}
|
||||||
|
|
||||||
it "Input <name> should successfully complete" -TestCases $scriptWithWildcardCases {
|
It "Input <name> should successfully complete" -TestCases $scriptWithWildcardCases {
|
||||||
param($command, $expectedCommand)
|
param($command, $expectedCommand)
|
||||||
$res = TabExpansion2 -inputScript $command -cursorColumn $command.Length
|
$res = TabExpansion2 -inputScript $command -cursorColumn $command.Length
|
||||||
$res.CompletionMatches.Count | Should -BeGreaterThan 0
|
$res.CompletionMatches.Count | Should -BeGreaterThan 0
|
||||||
@ -699,7 +699,7 @@ Describe "TabCompletion" -Tags CI {
|
|||||||
## if $PSHOME contains a space tabcompletion adds ' around the 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 = 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 = "`"$(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 = 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 }
|
||||||
@{ 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 }
|
||||||
## tab completion AST-based tests
|
## tab completion AST-based tests
|
||||||
|
@ -13,7 +13,7 @@ Describe "Windows Installer" -Tags "Scenario" {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
It "WiX (Windows Installer XML) file contains pre-requisites link $preRequisitesLink" -skip:$skipTest {
|
It "WiX (Windows Installer XML) file contains pre-requisites link $preRequisitesLink" -Skip:$skipTest {
|
||||||
$wixProductFile = Join-Path -Path $PSScriptRoot -ChildPath "..\..\..\assets\Product.wxs"
|
$wixProductFile = Join-Path -Path $PSScriptRoot -ChildPath "..\..\..\assets\Product.wxs"
|
||||||
(Get-Content $wixProductFile -Raw).Contains($preRequisitesLink) | Should -BeTrue
|
(Get-Content $wixProductFile -Raw).Contains($preRequisitesLink) | Should -BeTrue
|
||||||
}
|
}
|
||||||
@ -21,7 +21,7 @@ Describe "Windows Installer" -Tags "Scenario" {
|
|||||||
## Running 'Invoke-WebRequest' with WMF download URLs has been failing intermittently,
|
## Running 'Invoke-WebRequest' with WMF download URLs has been failing intermittently,
|
||||||
## because sometimes the URLs lead to a 'this download is no longer available' page.
|
## because sometimes the URLs lead to a 'this download is no longer available' page.
|
||||||
## We use a retry logic here. Retry for 5 times with 1 second interval.
|
## We use a retry logic here. Retry for 5 times with 1 second interval.
|
||||||
It "Pre-Requisistes link for '<Name>' is reachable: <url>" -TestCases $linkCheckTestCases -skip:$skipTest {
|
It "Pre-Requisistes link for '<Name>' is reachable: <url>" -TestCases $linkCheckTestCases -Skip:$skipTest {
|
||||||
param ($Url)
|
param ($Url)
|
||||||
|
|
||||||
foreach ($i in 1..5) {
|
foreach ($i in 1..5) {
|
||||||
|
@ -105,7 +105,7 @@ Describe 'Positive Parse Properties Tests' -Tags "CI" {
|
|||||||
class C12c { [void] f() { [System.Management.Automation.Host.Rectangle]$foo = [System.Management.Automation.Host.Rectangle]::new(0, 0, 0, 0) } }
|
class C12c { [void] f() { [System.Management.Automation.Host.Rectangle]$foo = [System.Management.Automation.Host.Rectangle]::new(0, 0, 0, 0) } }
|
||||||
}
|
}
|
||||||
|
|
||||||
context "Positive ParseMethods return type Test" {
|
Context "Positive ParseMethods return type Test" {
|
||||||
# Method with return type of self
|
# Method with return type of self
|
||||||
class C9 { [C9] f() { return [C9]::new() } }
|
class C9 { [C9] f() { return [C9]::new() } }
|
||||||
$c9 = [C9]::new().f()
|
$c9 = [C9]::new().f()
|
||||||
@ -710,7 +710,7 @@ visibleX visibleY
|
|||||||
|
|
||||||
# Get-Member should not include hidden members by default
|
# Get-Member should not include hidden members by default
|
||||||
$member = $instance | Get-Member hiddenZ
|
$member = $instance | Get-Member hiddenZ
|
||||||
it "Get-Member should not find hidden member w/o -Force" { $member | Should -BeNullOrEmpty }
|
It "Get-Member should not find hidden member w/o -Force" { $member | Should -BeNullOrEmpty }
|
||||||
|
|
||||||
# Get-Member should include hidden members with -Force
|
# Get-Member should include hidden members with -Force
|
||||||
$member = $instance | Get-Member hiddenZ -Force
|
$member = $instance | Get-Member hiddenZ -Force
|
||||||
@ -742,10 +742,10 @@ Describe 'Scoped Types Test' -Tags "CI" {
|
|||||||
{
|
{
|
||||||
class C1 { [string] GetContext() { return "f2 scope" } }
|
class C1 { [string] GetContext() { return "f2 scope" } }
|
||||||
|
|
||||||
return (new-object C1).GetContext()
|
return (New-Object C1).GetContext()
|
||||||
}
|
}
|
||||||
|
|
||||||
It "New-Object at test scope" { (new-object C1).GetContext() | Should -BeExactly "Test scope" }
|
It "New-Object at test scope" { (New-Object C1).GetContext() | Should -BeExactly "Test scope" }
|
||||||
It "[C1]::new() at test scope" { [C1]::new().GetContext() | Should -BeExactly "Test scope" }
|
It "[C1]::new() at test scope" { [C1]::new().GetContext() | Should -BeExactly "Test scope" }
|
||||||
|
|
||||||
It "[C1]::new() in nested scope" { (f1) | Should -BeExactly "f1 scope" }
|
It "[C1]::new() in nested scope" { (f1) | Should -BeExactly "f1 scope" }
|
||||||
@ -804,7 +804,7 @@ Describe 'Type building' -Tags "CI" {
|
|||||||
|
|
||||||
Describe 'RuntimeType created for TypeDefinitionAst' -Tags "CI" {
|
Describe 'RuntimeType created for TypeDefinitionAst' -Tags "CI" {
|
||||||
|
|
||||||
It 'can make cast to the right RuntimeType in two different contexts' -pending {
|
It 'can make cast to the right RuntimeType in two different contexts' -Pending {
|
||||||
|
|
||||||
$ssfe = [System.Management.Automation.Runspaces.SessionStateFunctionEntry]::new("foo", @'
|
$ssfe = [System.Management.Automation.Runspaces.SessionStateFunctionEntry]::new("foo", @'
|
||||||
class Base
|
class Base
|
||||||
|
@ -9,7 +9,7 @@ Describe 'NestedModules' -Tags "CI" {
|
|||||||
[string[]]$NestedContents
|
[string[]]$NestedContents
|
||||||
)
|
)
|
||||||
|
|
||||||
new-item -type directory -Force "TestDrive:\$Name" > $null
|
New-Item -type directory -Force "TestDrive:\$Name" > $null
|
||||||
$manifestParams = @{
|
$manifestParams = @{
|
||||||
Path = "TestDrive:\$Name\$Name.psd1"
|
Path = "TestDrive:\$Name\$Name.psd1"
|
||||||
}
|
}
|
||||||
@ -21,7 +21,7 @@ Describe 'NestedModules' -Tags "CI" {
|
|||||||
|
|
||||||
if ($NestedContents) {
|
if ($NestedContents) {
|
||||||
$manifestParams['NestedModules'] = 1..$NestedContents.Count | ForEach-Object {
|
$manifestParams['NestedModules'] = 1..$NestedContents.Count | ForEach-Object {
|
||||||
$null = new-item -type directory TestDrive:\$Name\Nested$_
|
$null = New-Item -type directory TestDrive:\$Name\Nested$_
|
||||||
$null = Set-Content -Path "${TestDrive}\$Name\Nested$_\Nested$_.psm1" -Value $NestedContents[$_ - 1]
|
$null = Set-Content -Path "${TestDrive}\$Name\Nested$_\Nested$_.psm1" -Value $NestedContents[$_ - 1]
|
||||||
"Nested$_"
|
"Nested$_"
|
||||||
}
|
}
|
||||||
@ -29,7 +29,7 @@ Describe 'NestedModules' -Tags "CI" {
|
|||||||
|
|
||||||
New-ModuleManifest @manifestParams
|
New-ModuleManifest @manifestParams
|
||||||
|
|
||||||
$resolvedTestDrivePath = Split-Path ((get-childitem TestDrive:\)[0].FullName)
|
$resolvedTestDrivePath = Split-Path ((Get-ChildItem TestDrive:\)[0].FullName)
|
||||||
if (-not ($env:PSModulePath -like "*$resolvedTestDrivePath*")) {
|
if (-not ($env:PSModulePath -like "*$resolvedTestDrivePath*")) {
|
||||||
$env:PSModulePath += "$([System.IO.Path]::PathSeparator)$resolvedTestDrivePath"
|
$env:PSModulePath += "$([System.IO.Path]::PathSeparator)$resolvedTestDrivePath"
|
||||||
}
|
}
|
||||||
@ -103,7 +103,7 @@ using module WithRoot
|
|||||||
# We need to think about it: should it work or not.
|
# We need to think about it: should it work or not.
|
||||||
# Currently, types are resolved in compile-time to the 'local' versions
|
# Currently, types are resolved in compile-time to the 'local' versions
|
||||||
# So at runtime we don't call the module versions.
|
# So at runtime we don't call the module versions.
|
||||||
It 'Can execute type creation in the module context with new()' -pending {
|
It 'Can execute type creation in the module context with new()' -Pending {
|
||||||
& (Get-Module ABC) { [C]::new().foo() } | Should -Be C
|
& (Get-Module ABC) { [C]::new().foo() } | Should -Be C
|
||||||
& (Get-Module NoRoot) { [A]::new().foo() } | Should -Be A2
|
& (Get-Module NoRoot) { [A]::new().foo() } | Should -Be A2
|
||||||
& (Get-Module WithRoot) { [A]::new().foo() } | Should -Be A0
|
& (Get-Module WithRoot) { [A]::new().foo() } | Should -Be A0
|
||||||
|
@ -103,7 +103,7 @@ Describe 'Classes inheritance syntax' -Tags "CI" {
|
|||||||
[void]ExitNestedPrompt(){ throw "Unsupported" }
|
[void]ExitNestedPrompt(){ throw "Unsupported" }
|
||||||
[void]NotifyBeginApplication() { }
|
[void]NotifyBeginApplication() { }
|
||||||
[void]NotifyEndApplication() { }
|
[void]NotifyEndApplication() { }
|
||||||
[string]get_Name() { return $this.myName; write-host "MyName" }
|
[string]get_Name() { return $this.myName; Write-Host "MyName" }
|
||||||
[version]get_Version() { return $this.myVersion }
|
[version]get_Version() { return $this.myVersion }
|
||||||
[System.Globalization.CultureInfo]get_CurrentCulture() { return $this.myCurrentCulture }
|
[System.Globalization.CultureInfo]get_CurrentCulture() { return $this.myCurrentCulture }
|
||||||
[System.Globalization.CultureInfo]get_CurrentUICulture() { return $this.myCurrentUICulture }
|
[System.Globalization.CultureInfo]get_CurrentUICulture() { return $this.myCurrentUICulture }
|
||||||
|
@ -14,15 +14,15 @@ Describe 'using module' -Tags "CI" {
|
|||||||
)
|
)
|
||||||
|
|
||||||
if ($manifest) {
|
if ($manifest) {
|
||||||
new-item -type directory -Force "${TestDrive}\$ModulePathPrefix\$Name\$Version" > $null
|
New-Item -type directory -Force "${TestDrive}\$ModulePathPrefix\$Name\$Version" > $null
|
||||||
Set-Content -Path "${TestDrive}\$ModulePathPrefix\$Name\$Version\$Name.psm1" -Value $Content
|
Set-Content -Path "${TestDrive}\$ModulePathPrefix\$Name\$Version\$Name.psm1" -Value $Content
|
||||||
New-ModuleManifest -RootModule "$Name.psm1" -Path "${TestDrive}\$ModulePathPrefix\$Name\$Version\$Name.psd1" -ModuleVersion $Version
|
New-ModuleManifest -RootModule "$Name.psm1" -Path "${TestDrive}\$ModulePathPrefix\$Name\$Version\$Name.psd1" -ModuleVersion $Version
|
||||||
} else {
|
} else {
|
||||||
new-item -type directory -Force "${TestDrive}\$ModulePathPrefix\$Name" > $null
|
New-Item -type directory -Force "${TestDrive}\$ModulePathPrefix\$Name" > $null
|
||||||
Set-Content -Path "${TestDrive}\$ModulePathPrefix\$Name\$Name.psm1" -Value $Content
|
Set-Content -Path "${TestDrive}\$ModulePathPrefix\$Name\$Name.psm1" -Value $Content
|
||||||
}
|
}
|
||||||
|
|
||||||
$resolvedTestDrivePath = Split-Path ((get-childitem "${TestDrive}\$ModulePathPrefix")[0].FullName)
|
$resolvedTestDrivePath = Split-Path ((Get-ChildItem "${TestDrive}\$ModulePathPrefix")[0].FullName)
|
||||||
if (-not ($env:PSModulePath -like "*$resolvedTestDrivePath*")) {
|
if (-not ($env:PSModulePath -like "*$resolvedTestDrivePath*")) {
|
||||||
$env:PSModulePath += "$([System.IO.Path]::PathSeparator)$resolvedTestDrivePath"
|
$env:PSModulePath += "$([System.IO.Path]::PathSeparator)$resolvedTestDrivePath"
|
||||||
}
|
}
|
||||||
@ -416,7 +416,7 @@ function foo()
|
|||||||
}
|
}
|
||||||
'@
|
'@
|
||||||
# resolve name to absolute path
|
# resolve name to absolute path
|
||||||
$scriptToProcessPath = (get-childitem $scriptToProcessPath).FullName
|
$scriptToProcessPath = (Get-ChildItem $scriptToProcessPath).FullName
|
||||||
$iss = [System.Management.Automation.Runspaces.initialsessionstate]::CreateDefault()
|
$iss = [System.Management.Automation.Runspaces.initialsessionstate]::CreateDefault()
|
||||||
$iss.StartupScripts.Add($scriptToProcessPath)
|
$iss.StartupScripts.Add($scriptToProcessPath)
|
||||||
|
|
||||||
@ -442,7 +442,7 @@ function foo()
|
|||||||
New-TestModule -Name FooForPaths -Content 'class Foo { [string] GetModuleName() { return "FooForPaths" } }'
|
New-TestModule -Name FooForPaths -Content 'class Foo { [string] GetModuleName() { return "FooForPaths" } }'
|
||||||
$env:PSModulePath = $originalPSModulePath
|
$env:PSModulePath = $originalPSModulePath
|
||||||
|
|
||||||
new-item -type directory -Force TestDrive:\FooRelativeConsumer
|
New-Item -type directory -Force TestDrive:\FooRelativeConsumer
|
||||||
Set-Content -Path "${TestDrive}\FooRelativeConsumer\FooRelativeConsumer.ps1" -Value @'
|
Set-Content -Path "${TestDrive}\FooRelativeConsumer\FooRelativeConsumer.ps1" -Value @'
|
||||||
using module ..\modules\FooForPaths
|
using module ..\modules\FooForPaths
|
||||||
class Bar : Foo {}
|
class Bar : Foo {}
|
||||||
@ -471,7 +471,7 @@ class Bar : Foo {}
|
|||||||
}
|
}
|
||||||
|
|
||||||
It "can be accessed by absolute path" {
|
It "can be accessed by absolute path" {
|
||||||
$resolvedTestDrivePath = Split-Path ((get-childitem TestDrive:\modules)[0].FullName)
|
$resolvedTestDrivePath = Split-Path ((Get-ChildItem TestDrive:\modules)[0].FullName)
|
||||||
$s = @"
|
$s = @"
|
||||||
using module $resolvedTestDrivePath\FooForPaths
|
using module $resolvedTestDrivePath\FooForPaths
|
||||||
[Foo]::new()
|
[Foo]::new()
|
||||||
@ -483,7 +483,7 @@ using module $resolvedTestDrivePath\FooForPaths
|
|||||||
}
|
}
|
||||||
|
|
||||||
It "can be accessed by absolute path with file extension" {
|
It "can be accessed by absolute path with file extension" {
|
||||||
$resolvedTestDrivePath = Split-Path ((get-childitem TestDrive:\modules)[0].FullName)
|
$resolvedTestDrivePath = Split-Path ((Get-ChildItem TestDrive:\modules)[0].FullName)
|
||||||
$barObject = [scriptblock]::Create(@"
|
$barObject = [scriptblock]::Create(@"
|
||||||
using module $resolvedTestDrivePath\FooForPaths\FooForPaths.psm1
|
using module $resolvedTestDrivePath\FooForPaths\FooForPaths.psm1
|
||||||
[Foo]::new()
|
[Foo]::new()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Copyright (c) Microsoft Corporation.
|
# Copyright (c) Microsoft Corporation.
|
||||||
# Licensed under the MIT License.
|
# Licensed under the MIT License.
|
||||||
Describe "ComparisonOperator" -tag "CI" {
|
Describe "ComparisonOperator" -Tag "CI" {
|
||||||
|
|
||||||
It "Should be <result> for <lhs> <operator> <rhs>" -TestCases @(
|
It "Should be <result> for <lhs> <operator> <rhs>" -TestCases @(
|
||||||
@{lhs = 1; operator = "-lt"; rhs = 2; result = $true},
|
@{lhs = 1; operator = "-lt"; rhs = 2; result = $true},
|
||||||
@ -84,7 +84,7 @@ Describe "ComparisonOperator" -tag "CI" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Describe "Bytewise Operator" -tag "CI" {
|
Describe "Bytewise Operator" -Tag "CI" {
|
||||||
|
|
||||||
It "Test -bor on enum with [byte] as underlying type" {
|
It "Test -bor on enum with [byte] as underlying type" {
|
||||||
$result = [System.Security.AccessControl.AceFlags]::ObjectInherit -bxor `
|
$result = [System.Security.AccessControl.AceFlags]::ObjectInherit -bxor `
|
||||||
|
@ -341,6 +341,6 @@ function Test-FullyTerminatingError
|
|||||||
It "Recognises invalid assignment" {
|
It "Recognises invalid assignment" {
|
||||||
{
|
{
|
||||||
Invoke-Expression -Command '$x = $x, $y += $z = testexe -returncode 0 && testexe -returncode 1'
|
Invoke-Expression -Command '$x = $x, $y += $z = testexe -returncode 0 && testexe -returncode 1'
|
||||||
} | Should -Throw -ErrorID 'InvalidLeftHandSide,Microsoft.PowerShell.Commands.InvokeExpressionCommand'
|
} | Should -Throw -ErrorId 'InvalidLeftHandSide,Microsoft.PowerShell.Commands.InvokeExpressionCommand'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ Describe "Using of ternary operator" -Tags CI {
|
|||||||
@{ Script = { $IsCoreCLR ? $false ? 'nested-if-true' : $true ? 'nested-nested-if-true' : 'nested-nested-if-false' : 'if-false' }; ExpectedValue = 'nested-nested-if-true' }
|
@{ Script = { $IsCoreCLR ? $false ? 'nested-if-true' : $true ? 'nested-nested-if-true' : 'nested-nested-if-false' : 'if-false' }; ExpectedValue = 'nested-nested-if-true' }
|
||||||
|
|
||||||
## Binary operator has higher precedence order than ternary
|
## Binary operator has higher precedence order than ternary
|
||||||
@{ Script = { !$IsCoreCLR ? 'Core' : 'Desktop' -eq 'Core' }; ExpectedValue = !$IsCoreCLR ? 'Core' : ('Desktop' -eq 'Core') }
|
@{ Script = { !$IsCoreCLR ? 'Core' : 'Desktop' -EQ 'Core' }; ExpectedValue = !$IsCoreCLR ? 'Core' : ('Desktop' -eq 'Core') }
|
||||||
@{ Script = { ($IsCoreCLR ? 'Core' : 'Desktop') -eq 'Core' }; ExpectedValue = $true }
|
@{ Script = { ($IsCoreCLR ? 'Core' : 'Desktop') -eq 'Core' }; ExpectedValue = $true }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -57,7 +57,7 @@ Describe "Using of ternary operator" -Tags CI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
It "Ternary expression which generates a terminating error should halt appropriately" {
|
It "Ternary expression which generates a terminating error should halt appropriately" {
|
||||||
{ (write-error -Message error -ErrorAction Stop) ? 1 : 2 } | Should -Throw -ErrorId Microsoft.PowerShell.Commands.WriteErrorException
|
{ (Write-Error -Message error -ErrorAction Stop) ? 1 : 2 } | Should -Throw -ErrorId Microsoft.PowerShell.Commands.WriteErrorException
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Use ternary operator in parameter default values" {
|
It "Use ternary operator in parameter default values" {
|
||||||
|
@ -108,7 +108,7 @@ function Test-Completions
|
|||||||
{
|
{
|
||||||
$skip = $false
|
$skip = $false
|
||||||
if ( $expected.CompletionText -Match "System.Management.Automation.PerformanceData|System.Management.Automation.Security" ) { $skip = $true }
|
if ( $expected.CompletionText -Match "System.Management.Automation.PerformanceData|System.Management.Automation.Security" ) { $skip = $true }
|
||||||
It ($expected.CompletionText) -skip:$skip {
|
It ($expected.CompletionText) -Skip:$skip {
|
||||||
$expected.Found | Should -BeTrue
|
$expected.Found | Should -BeTrue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -435,7 +435,7 @@ Describe "ArgumentCompletionsAttribute tests" -Tags "CI" {
|
|||||||
param($attributeName, $cmdletName)
|
param($attributeName, $cmdletName)
|
||||||
|
|
||||||
$line = "$cmdletName -Alpha val"
|
$line = "$cmdletName -Alpha val"
|
||||||
$res = TaBexpansion2 -inputScript $line -cursorColumn $line.Length
|
$res = TabExpansion2 -inputScript $line -cursorColumn $line.Length
|
||||||
$res.CompletionMatches.Count | Should -Be 3
|
$res.CompletionMatches.Count | Should -Be 3
|
||||||
$res.CompletionMatches.CompletionText -join " " | Should -BeExactly "value1 value2 value3"
|
$res.CompletionMatches.CompletionText -join " " | Should -BeExactly "value1 value2 value3"
|
||||||
{ TestArgumentCompletionsAttribute -Alpha unExpectedValue } | Should -Not -Throw
|
{ TestArgumentCompletionsAttribute -Alpha unExpectedValue } | Should -Not -Throw
|
||||||
@ -445,7 +445,7 @@ Describe "ArgumentCompletionsAttribute tests" -Tags "CI" {
|
|||||||
param($attributeName, $cmdletName)
|
param($attributeName, $cmdletName)
|
||||||
|
|
||||||
$line = "$cmdletName -Param1 val"
|
$line = "$cmdletName -Param1 val"
|
||||||
$res = TaBexpansion2 -inputScript $line -cursorColumn $line.Length
|
$res = TabExpansion2 -inputScript $line -cursorColumn $line.Length
|
||||||
$res.CompletionMatches.Count | Should -Be 3
|
$res.CompletionMatches.Count | Should -Be 3
|
||||||
$res.CompletionMatches.CompletionText -join " " | Should -BeExactly "value1 value2 value3"
|
$res.CompletionMatches.CompletionText -join " " | Should -BeExactly "value1 value2 value3"
|
||||||
{ TestArgumentCompletionsAttribute -Param1 unExpectedValue } | Should -Not -Throw
|
{ TestArgumentCompletionsAttribute -Param1 unExpectedValue } | Should -Not -Throw
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Copyright (c) Microsoft Corporation.
|
# Copyright (c) Microsoft Corporation.
|
||||||
# Licensed under the MIT License.
|
# Licensed under the MIT License.
|
||||||
$powershellexe = (get-process -id $PID).mainmodule.filename
|
$powershellexe = (Get-Process -Id $PID).mainmodule.filename
|
||||||
|
|
||||||
Describe "Clone array" -Tags "CI" {
|
Describe "Clone array" -Tags "CI" {
|
||||||
It "Cast in target expr" {
|
It "Cast in target expr" {
|
||||||
@ -27,7 +27,7 @@ Describe "Set fields through PSMemberInfo" -Tags "CI" {
|
|||||||
([AStruct]@{s = "abc" }).s | Should -BeExactly "abc"
|
([AStruct]@{s = "abc" }).s | Should -BeExactly "abc"
|
||||||
}
|
}
|
||||||
It "via new-object" {
|
It "via new-object" {
|
||||||
(new-object AStruct -prop @{s="abc"}).s | Should -BeExactly "abc"
|
(New-Object AStruct -prop @{s="abc"}).s | Should -BeExactly "abc"
|
||||||
}
|
}
|
||||||
It "via PSObject" {
|
It "via PSObject" {
|
||||||
$x = [AStruct]::new()
|
$x = [AStruct]::new()
|
||||||
|
@ -79,23 +79,23 @@ Describe 'Argument transformation attribute on optional argument with explicit $
|
|||||||
It "Script function takes uint64" {
|
It "Script function takes uint64" {
|
||||||
Invoke-ScriptFunctionTakesUInt64 | Should -Be 42
|
Invoke-ScriptFunctionTakesUInt64 | Should -Be 42
|
||||||
}
|
}
|
||||||
it "csharp cmdlet takes object" {
|
It "csharp cmdlet takes object" {
|
||||||
Invoke-CSharpCmdletTakesObject | Should -Be "passed in null"
|
Invoke-CSharpCmdletTakesObject | Should -Be "passed in null"
|
||||||
}
|
}
|
||||||
it "csharp cmdlet takes uint64" {
|
It "csharp cmdlet takes uint64" {
|
||||||
Invoke-CSharpCmdletTakesUInt64 | Should -Be 0
|
Invoke-CSharpCmdletTakesUInt64 | Should -Be 0
|
||||||
}
|
}
|
||||||
|
|
||||||
it "script function takes object when parameter is null" {
|
It "script function takes object when parameter is null" {
|
||||||
Invoke-ScriptFunctionTakesObject -Address $null | Should -Be 42
|
Invoke-ScriptFunctionTakesObject -Address $null | Should -Be 42
|
||||||
}
|
}
|
||||||
it "script function takes unit64 when parameter is null" {
|
It "script function takes unit64 when parameter is null" {
|
||||||
Invoke-ScriptFunctionTakesUInt64 -Address $null | Should -Be 42
|
Invoke-ScriptFunctionTakesUInt64 -Address $null | Should -Be 42
|
||||||
}
|
}
|
||||||
it "script csharp cmdlet takes object when parameter is null" {
|
It "script csharp cmdlet takes object when parameter is null" {
|
||||||
Invoke-CSharpCmdletTakesObject -Address $null | Should -Be 42
|
Invoke-CSharpCmdletTakesObject -Address $null | Should -Be 42
|
||||||
}
|
}
|
||||||
it "script csharp cmdlet takes uint64 when parameter is null" {
|
It "script csharp cmdlet takes uint64 when parameter is null" {
|
||||||
Invoke-CSharpCmdletTakesUInt64 -Address $null | Should -Be 42
|
Invoke-CSharpCmdletTakesUInt64 -Address $null | Should -Be 42
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -703,7 +703,7 @@ foo``u{2195}abc
|
|||||||
if ( $IsLinux -or $IsMacOS ) {
|
if ( $IsLinux -or $IsMacOS ) {
|
||||||
# because we execute on *nix based on executable bit, and the file name doesn't matter
|
# because we execute on *nix based on executable bit, and the file name doesn't matter
|
||||||
# so we can use the same filename as for windows, just make sure it's executable with chmod
|
# so we can use the same filename as for windows, just make sure it's executable with chmod
|
||||||
"#!/bin/sh`necho ""Hello World""" | Out-File -encoding ASCII $shellfile
|
"#!/bin/sh`necho ""Hello World""" | Out-File -Encoding ASCII $shellfile
|
||||||
/bin/chmod +x $shellfile
|
/bin/chmod +x $shellfile
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Copyright (c) Microsoft Corporation.
|
# Copyright (c) Microsoft Corporation.
|
||||||
# Licensed under the MIT License.
|
# Licensed under the MIT License.
|
||||||
set-strictmode -v 2
|
Set-StrictMode -v 2
|
||||||
|
|
||||||
Describe 'for statement parsing' -Tags "CI" {
|
Describe 'for statement parsing' -Tags "CI" {
|
||||||
ShouldBeParseError 'for' MissingOpenParenthesisAfterKeyword 4 -CheckColumnNumber
|
ShouldBeParseError 'for' MissingOpenParenthesisAfterKeyword 4 -CheckColumnNumber
|
||||||
|
@ -44,7 +44,7 @@ public class ABC {}
|
|||||||
$err[0].ErrorId | Should -Be CannotLoadAssemblyWithUriSchema
|
$err[0].ErrorId | Should -Be CannotLoadAssemblyWithUriSchema
|
||||||
}
|
}
|
||||||
|
|
||||||
It "parse does not load the assembly" -pending {
|
It "parse does not load the assembly" -Pending {
|
||||||
$assemblies = [Appdomain]::CurrentDomain.GetAssemblies().GetName().Name
|
$assemblies = [Appdomain]::CurrentDomain.GetAssemblies().GetName().Name
|
||||||
$assemblies -contains "UsingAssemblyTest$guid" | Should -BeFalse
|
$assemblies -contains "UsingAssemblyTest$guid" | Should -BeFalse
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ public class ABC {}
|
|||||||
$e.Exception.InnerException.ErrorRecord.FullyQualifiedErrorId | Should -Be 'ErrorLoadingAssembly'
|
$e.Exception.InnerException.ErrorRecord.FullyQualifiedErrorId | Should -Be 'ErrorLoadingAssembly'
|
||||||
}
|
}
|
||||||
#>
|
#>
|
||||||
It "Assembly loaded at runtime" -pending {
|
It "Assembly loaded at runtime" -Pending {
|
||||||
$assemblies = & "$PSHOME/pwsh" -noprofile -command @"
|
$assemblies = & "$PSHOME/pwsh" -noprofile -command @"
|
||||||
using assembly .\UsingAssemblyTest$guid.dll
|
using assembly .\UsingAssemblyTest$guid.dll
|
||||||
[Appdomain]::CurrentDomain.GetAssemblies().GetName().Name
|
[Appdomain]::CurrentDomain.GetAssemblies().GetName().Name
|
||||||
|
@ -60,7 +60,7 @@ Describe "Using Namespace" -Tags "CI" {
|
|||||||
New-Object CompilerGeneratedAttribute | Should -Be System.Runtime.CompilerServices.CompilerGeneratedAttribute
|
New-Object CompilerGeneratedAttribute | Should -Be System.Runtime.CompilerServices.CompilerGeneratedAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Attributes w/ using namespace" -pending {
|
It "Attributes w/ using namespace" -Pending {
|
||||||
function foo
|
function foo
|
||||||
{
|
{
|
||||||
[DebuggerStepThrough()]
|
[DebuggerStepThrough()]
|
||||||
|
@ -209,7 +209,7 @@ Describe "Tests for (error, warning, etc) action preference" -Tags "CI" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Describe 'ActionPreference.Break tests' -tag 'CI' {
|
Describe 'ActionPreference.Break tests' -Tag 'CI' {
|
||||||
|
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
Register-DebuggerHandler
|
Register-DebuggerHandler
|
||||||
@ -239,7 +239,7 @@ Describe 'ActionPreference.Break tests' -tag 'CI' {
|
|||||||
Test-Break -ErrorAction Break
|
Test-Break -ErrorAction Break
|
||||||
}
|
}
|
||||||
|
|
||||||
$results = @(Test-Debugger -ScriptBlock $testScript -CommandQueue 'v', 'v')
|
$results = @(Test-Debugger -Scriptblock $testScript -CommandQueue 'v', 'v')
|
||||||
}
|
}
|
||||||
|
|
||||||
It 'Should show 3 debugger commands were invoked' {
|
It 'Should show 3 debugger commands were invoked' {
|
||||||
@ -280,7 +280,7 @@ Describe 'ActionPreference.Break tests' -tag 'CI' {
|
|||||||
Test-Break -ErrorAction Break
|
Test-Break -ErrorAction Break
|
||||||
}
|
}
|
||||||
|
|
||||||
$results = @(Test-Debugger -ScriptBlock $testScript -CommandQueue 'v', 'v')
|
$results = @(Test-Debugger -Scriptblock $testScript -CommandQueue 'v', 'v')
|
||||||
}
|
}
|
||||||
|
|
||||||
It 'Should show 3 debugger commands were invoked' {
|
It 'Should show 3 debugger commands were invoked' {
|
||||||
@ -321,7 +321,7 @@ Describe 'ActionPreference.Break tests' -tag 'CI' {
|
|||||||
Test-Break -ErrorAction Break
|
Test-Break -ErrorAction Break
|
||||||
}
|
}
|
||||||
|
|
||||||
$results = @(Test-Debugger -ScriptBlock $testScript)
|
$results = @(Test-Debugger -Scriptblock $testScript)
|
||||||
}
|
}
|
||||||
|
|
||||||
It 'Should show 1 debugger command was invoked' {
|
It 'Should show 1 debugger command was invoked' {
|
||||||
@ -354,7 +354,7 @@ Describe 'ActionPreference.Break tests' -tag 'CI' {
|
|||||||
Test-Break -ErrorAction Break
|
Test-Break -ErrorAction Break
|
||||||
}
|
}
|
||||||
|
|
||||||
$results = @(Test-Debugger -ScriptBlock $testScript)
|
$results = @(Test-Debugger -Scriptblock $testScript)
|
||||||
}
|
}
|
||||||
|
|
||||||
It 'Should show 2 debugger commands were invoked' {
|
It 'Should show 2 debugger commands were invoked' {
|
||||||
@ -390,7 +390,7 @@ Describe 'ActionPreference.Break tests' -tag 'CI' {
|
|||||||
Test-Break *>$null
|
Test-Break *>$null
|
||||||
}
|
}
|
||||||
|
|
||||||
$results = @(Test-Debugger -ScriptBlock $testScript)
|
$results = @(Test-Debugger -Scriptblock $testScript)
|
||||||
}
|
}
|
||||||
|
|
||||||
It 'Should show 7 debugger commands were invoked' {
|
It 'Should show 7 debugger commands were invoked' {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# Licensed under the MIT License.
|
# Licensed under the MIT License.
|
||||||
Describe "Test restricted language check method on scriptblocks" -Tags "CI" {
|
Describe "Test restricted language check method on scriptblocks" -Tags "CI" {
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
set-strictmode -v 2
|
Set-StrictMode -v 2
|
||||||
function list {
|
function list {
|
||||||
|
|
||||||
$l = [System.Collections.Generic.List[String]]::new()
|
$l = [System.Collections.Generic.List[String]]::new()
|
||||||
@ -62,12 +62,12 @@ Describe "Test restricted language check method on scriptblocks" -Tags "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
It 'Check for restricted commands' {
|
It 'Check for restricted commands' {
|
||||||
{ {get-date}.CheckRestrictedLangauge($null, $null, $false) } | Should -Throw -ErrorId 'MethodNotFound'
|
{ {Get-Date}.CheckRestrictedLangauge($null, $null, $false) } | Should -Throw -ErrorId 'MethodNotFound'
|
||||||
}
|
}
|
||||||
|
|
||||||
It 'Check for allowed commands and variables' {
|
It 'Check for allowed commands and variables' {
|
||||||
|
|
||||||
{ { get-process | where name -Match $pattern | foreach $prop }.CheckRestrictedLanguage(
|
{ { Get-Process | where name -Match $pattern | foreach $prop }.CheckRestrictedLanguage(
|
||||||
(list get-process where foreach),
|
(list get-process where foreach),
|
||||||
(list prop pattern)
|
(list prop pattern)
|
||||||
, $false) } | Should -Not -Throw
|
, $false) } | Should -Not -Throw
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Copyright (c) Microsoft Corporation.
|
# Copyright (c) Microsoft Corporation.
|
||||||
# Licensed under the MIT License.
|
# Licensed under the MIT License.
|
||||||
|
|
||||||
Describe 'Basic debugger command tests' -tag 'CI' {
|
Describe 'Basic debugger command tests' -Tag 'CI' {
|
||||||
|
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
Register-DebuggerHandler
|
Register-DebuggerHandler
|
||||||
@ -27,11 +27,11 @@ Describe 'Basic debugger command tests' -tag 'CI' {
|
|||||||
$bp = Set-PSBreakpoint -Command Get-Process
|
$bp = Set-PSBreakpoint -Command Get-Process
|
||||||
Get-Process -Id $PID > $null
|
Get-Process -Id $PID > $null
|
||||||
} finally {
|
} finally {
|
||||||
Remove-PSBreakPoint -Breakpoint $bp
|
Remove-PSBreakpoint -Breakpoint $bp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$results = @(Test-Debugger -ScriptBlock $testScript -CommandQueue '?','h')
|
$results = @(Test-Debugger -Scriptblock $testScript -CommandQueue '?','h')
|
||||||
$result = @{
|
$result = @{
|
||||||
'?' = if ($results.Count -gt 0) {$results[0].Output -join [Environment]::NewLine}
|
'?' = if ($results.Count -gt 0) {$results[0].Output -join [Environment]::NewLine}
|
||||||
'h' = if ($results.Count -gt 1) {$results[1].Output -join [Environment]::NewLine}
|
'h' = if ($results.Count -gt 1) {$results[1].Output -join [Environment]::NewLine}
|
||||||
@ -71,7 +71,7 @@ Describe 'Basic debugger command tests' -tag 'CI' {
|
|||||||
$bp = Set-PSBreakpoint -Command Get-Process
|
$bp = Set-PSBreakpoint -Command Get-Process
|
||||||
Get-Process -Id $PID > $null
|
Get-Process -Id $PID > $null
|
||||||
} finally {
|
} finally {
|
||||||
Remove-PSBreakPoint -Breakpoint $bp
|
Remove-PSBreakpoint -Breakpoint $bp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,13 +81,13 @@ Describe 'Basic debugger command tests' -tag 'CI' {
|
|||||||
3: $bp = Set-PSBreakpoint -Command Get-Process
|
3: $bp = Set-PSBreakpoint -Command Get-Process
|
||||||
4:* Get-Process -Id $PID > $null
|
4:* Get-Process -Id $PID > $null
|
||||||
5: } finally {
|
5: } finally {
|
||||||
6: Remove-PSBreakPoint -Breakpoint $bp
|
6: Remove-PSBreakpoint -Breakpoint $bp
|
||||||
7: }
|
7: }
|
||||||
8:
|
8:
|
||||||
'@
|
'@
|
||||||
$testScriptList = NormalizeLineEnd -string $testScriptList
|
$testScriptList = NormalizeLineEnd -string $testScriptList
|
||||||
|
|
||||||
$results = @(Test-Debugger -ScriptBlock $testScript -CommandQueue 'l','list')
|
$results = @(Test-Debugger -Scriptblock $testScript -CommandQueue 'l','list')
|
||||||
$result = @{
|
$result = @{
|
||||||
'l' = if ($results.Count -gt 0) {$results[0].Output -replace '\s+$' -join [Environment]::NewLine -replace "^[`r`n]+|[`r`n]+$"}
|
'l' = if ($results.Count -gt 0) {$results[0].Output -replace '\s+$' -join [Environment]::NewLine -replace "^[`r`n]+|[`r`n]+$"}
|
||||||
'list' = if ($results.Count -gt 1) {$results[1].Output -replace '\s+$' -join [Environment]::NewLine -replace "^[`r`n]+|[`r`n]+$"}
|
'list' = if ($results.Count -gt 1) {$results[1].Output -replace '\s+$' -join [Environment]::NewLine -replace "^[`r`n]+|[`r`n]+$"}
|
||||||
@ -120,21 +120,21 @@ Describe 'Basic debugger command tests' -tag 'CI' {
|
|||||||
$bp = Set-PSBreakpoint -Command Get-Process
|
$bp = Set-PSBreakpoint -Command Get-Process
|
||||||
Get-Process -Id $PID > $null
|
Get-Process -Id $PID > $null
|
||||||
} finally {
|
} finally {
|
||||||
Remove-PSBreakPoint -Breakpoint $bp
|
Remove-PSBreakpoint -Breakpoint $bp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$testScriptList = @'
|
$testScriptList = @'
|
||||||
4:* Get-Process -Id $PID > $null
|
4:* Get-Process -Id $PID > $null
|
||||||
5: } finally {
|
5: } finally {
|
||||||
6: Remove-PSBreakPoint -Breakpoint $bp
|
6: Remove-PSBreakpoint -Breakpoint $bp
|
||||||
7: }
|
7: }
|
||||||
8:
|
8:
|
||||||
'@
|
'@
|
||||||
|
|
||||||
$testScriptList = NormalizeLineEnd -string $testScriptList
|
$testScriptList = NormalizeLineEnd -string $testScriptList
|
||||||
|
|
||||||
$results = @(Test-Debugger -ScriptBlock $testScript -CommandQueue 'l 4','list 4')
|
$results = @(Test-Debugger -Scriptblock $testScript -CommandQueue 'l 4','list 4')
|
||||||
$result = @{
|
$result = @{
|
||||||
'l 4' = if ($results.Count -gt 0) {$results[0].Output -replace '\s+$' -join [Environment]::NewLine -replace "^[`r`n]+|[`r`n]+$"}
|
'l 4' = if ($results.Count -gt 0) {$results[0].Output -replace '\s+$' -join [Environment]::NewLine -replace "^[`r`n]+|[`r`n]+$"}
|
||||||
'list 4' = if ($results.Count -gt 1) {$results[1].Output -replace '\s+$' -join [Environment]::NewLine -replace "^[`r`n]+|[`r`n]+$"}
|
'list 4' = if ($results.Count -gt 1) {$results[1].Output -replace '\s+$' -join [Environment]::NewLine -replace "^[`r`n]+|[`r`n]+$"}
|
||||||
@ -167,7 +167,7 @@ Describe 'Basic debugger command tests' -tag 'CI' {
|
|||||||
$bp = Set-PSBreakpoint -Command Get-Process
|
$bp = Set-PSBreakpoint -Command Get-Process
|
||||||
Get-Process -Id $PID > $null
|
Get-Process -Id $PID > $null
|
||||||
} finally {
|
} finally {
|
||||||
Remove-PSBreakPoint -Breakpoint $bp
|
Remove-PSBreakpoint -Breakpoint $bp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ Describe 'Basic debugger command tests' -tag 'CI' {
|
|||||||
|
|
||||||
$testScriptList = NormalizeLineEnd -string $testScriptList
|
$testScriptList = NormalizeLineEnd -string $testScriptList
|
||||||
|
|
||||||
$results = @(Test-Debugger -ScriptBlock $testScript -CommandQueue 'l 3 2','list 3 2')
|
$results = @(Test-Debugger -Scriptblock $testScript -CommandQueue 'l 3 2','list 3 2')
|
||||||
$result = @{
|
$result = @{
|
||||||
'l 3 2' = if ($results.Count -gt 0) {$results[0].Output -replace '\s+$' -join [Environment]::NewLine -replace "^[`r`n]+|[`r`n]+$"}
|
'l 3 2' = if ($results.Count -gt 0) {$results[0].Output -replace '\s+$' -join [Environment]::NewLine -replace "^[`r`n]+|[`r`n]+$"}
|
||||||
'list 3 2' = if ($results.Count -gt 1) {$results[1].Output -replace '\s+$' -join [Environment]::NewLine -replace "^[`r`n]+|[`r`n]+$"}
|
'list 3 2' = if ($results.Count -gt 1) {$results[1].Output -replace '\s+$' -join [Environment]::NewLine -replace "^[`r`n]+|[`r`n]+$"}
|
||||||
@ -211,11 +211,11 @@ Describe 'Basic debugger command tests' -tag 'CI' {
|
|||||||
$bp = Set-PSBreakpoint -Command Get-Process
|
$bp = Set-PSBreakpoint -Command Get-Process
|
||||||
Get-Process -Id $PID > $null
|
Get-Process -Id $PID > $null
|
||||||
} finally {
|
} finally {
|
||||||
Remove-PSBreakPoint -Breakpoint $bp
|
Remove-PSBreakpoint -Breakpoint $bp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$results = @(Test-Debugger -ScriptBlock $testScript -CommandQueue 'k','Get-PSCallStack')
|
$results = @(Test-Debugger -Scriptblock $testScript -CommandQueue 'k','Get-PSCallStack')
|
||||||
$result = @{
|
$result = @{
|
||||||
'k' = if ($results.Count -gt 0) {$results[0].Output}
|
'k' = if ($results.Count -gt 0) {$results[0].Output}
|
||||||
'Get-PSCallStack' = if ($results.Count -gt 1) {$results[1].Output}
|
'Get-PSCallStack' = if ($results.Count -gt 1) {$results[1].Output}
|
||||||
@ -238,7 +238,7 @@ Describe 'Basic debugger command tests' -tag 'CI' {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Describe 'Simple debugger stepping command tests' -tag 'CI' {
|
Describe 'Simple debugger stepping command tests' -Tag 'CI' {
|
||||||
|
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
Register-DebuggerHandler
|
Register-DebuggerHandler
|
||||||
@ -258,13 +258,13 @@ Describe 'Simple debugger stepping command tests' -tag 'CI' {
|
|||||||
'Red fish, blue fish'
|
'Red fish, blue fish'
|
||||||
} *> $null
|
} *> $null
|
||||||
} finally {
|
} finally {
|
||||||
Remove-PSBreakPoint -Breakpoint $bp
|
Remove-PSBreakpoint -Breakpoint $bp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = @{
|
$result = @{
|
||||||
's' = @(Test-Debugger -ScriptBlock $testScript -CommandQueue 's','s','s','s')
|
's' = @(Test-Debugger -Scriptblock $testScript -CommandQueue 's','s','s','s')
|
||||||
'stepInto' = @(Test-Debugger -ScriptBlock $testScript -CommandQueue 'stepInto','stepInto','stepInto','stepInto')
|
'stepInto' = @(Test-Debugger -Scriptblock $testScript -CommandQueue 'stepInto','stepInto','stepInto','stepInto')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,13 +311,13 @@ Describe 'Simple debugger stepping command tests' -tag 'CI' {
|
|||||||
Get-Date | ConvertTo-Csv
|
Get-Date | ConvertTo-Csv
|
||||||
} *> $null
|
} *> $null
|
||||||
} finally {
|
} finally {
|
||||||
Remove-PSBreakPoint -Breakpoint $bp1,$bp2
|
Remove-PSBreakpoint -Breakpoint $bp1,$bp2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = @{
|
$result = @{
|
||||||
'v' = @(Test-Debugger -ScriptBlock $testScript -CommandQueue 'v','v','v','v')
|
'v' = @(Test-Debugger -Scriptblock $testScript -CommandQueue 'v','v','v','v')
|
||||||
'stepOver' = @(Test-Debugger -ScriptBlock $testScript -CommandQueue 'stepOver','stepOver','stepOver','stepOver')
|
'stepOver' = @(Test-Debugger -Scriptblock $testScript -CommandQueue 'stepOver','stepOver','stepOver','stepOver')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -362,13 +362,13 @@ Describe 'Simple debugger stepping command tests' -tag 'CI' {
|
|||||||
$date = Get-Date
|
$date = Get-Date
|
||||||
$date | ConvertTo-Csv
|
$date | ConvertTo-Csv
|
||||||
} finally {
|
} finally {
|
||||||
Remove-PSBreakPoint -Breakpoint $bps
|
Remove-PSBreakpoint -Breakpoint $bps
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = @{
|
$result = @{
|
||||||
'o' = @(Test-Debugger -ScriptBlock $testScript -CommandQueue 'o','o','o')
|
'o' = @(Test-Debugger -Scriptblock $testScript -CommandQueue 'o','o','o')
|
||||||
'stepOut' = @(Test-Debugger -ScriptBlock $testScript -CommandQueue 'stepOut','stepOut','stepOut')
|
'stepOut' = @(Test-Debugger -Scriptblock $testScript -CommandQueue 'stepOut','stepOut','stepOut')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -398,7 +398,7 @@ Describe 'Simple debugger stepping command tests' -tag 'CI' {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Describe 'Debugger bug fix tests' -tag 'CI' {
|
Describe 'Debugger bug fix tests' -Tag 'CI' {
|
||||||
|
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
Register-DebuggerHandler
|
Register-DebuggerHandler
|
||||||
@ -413,16 +413,16 @@ Describe 'Debugger bug fix tests' -tag 'CI' {
|
|||||||
$testScript = {
|
$testScript = {
|
||||||
function Test-Issue9824 {
|
function Test-Issue9824 {
|
||||||
$bp = Set-PSBreakpoint -Command Remove-PSBreakpoint
|
$bp = Set-PSBreakpoint -Command Remove-PSBreakpoint
|
||||||
Remove-PSBreakPoint -Breakpoint $bp
|
Remove-PSBreakpoint -Breakpoint $bp
|
||||||
}
|
}
|
||||||
Test-Issue9824
|
Test-Issue9824
|
||||||
1 + 1
|
1 + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = @{
|
$result = @{
|
||||||
's' = @(Test-Debugger -ScriptBlock $testScript -CommandQueue 's','s','s')
|
's' = @(Test-Debugger -Scriptblock $testScript -CommandQueue 's','s','s')
|
||||||
'v' = @(Test-Debugger -ScriptBlock $testScript -CommandQueue 'v','v','v')
|
'v' = @(Test-Debugger -Scriptblock $testScript -CommandQueue 'v','v','v')
|
||||||
'o' = @(Test-Debugger -ScriptBlock $testScript -CommandQueue 'o','o')
|
'o' = @(Test-Debugger -Scriptblock $testScript -CommandQueue 'o','o')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,18 +22,18 @@ Describe "Breakpoints set on custom FileSystem provider files should work" -Tags
|
|||||||
$scriptName = "DebuggerScriptTests-ExposeBug221362.ps1"
|
$scriptName = "DebuggerScriptTests-ExposeBug221362.ps1"
|
||||||
$scriptFullName = [io.path]::Combine($scriptPath, $scriptName)
|
$scriptFullName = [io.path]::Combine($scriptPath, $scriptName)
|
||||||
|
|
||||||
write-output '"hello"' > $scriptFullName
|
Write-Output '"hello"' > $scriptFullName
|
||||||
|
|
||||||
#
|
#
|
||||||
# Create a file system provider
|
# Create a file system provider
|
||||||
#
|
#
|
||||||
new-psdrive -name tmpTestA1 -psprovider FileSystem -root $scriptPath > $null
|
New-PSDrive -Name tmpTestA1 -PSProvider FileSystem -Root $scriptPath > $null
|
||||||
|
|
||||||
#
|
#
|
||||||
# Verify that the breakpoint is hit when using the provider
|
# Verify that the breakpoint is hit when using the provider
|
||||||
#
|
#
|
||||||
Push-Location tmpTestA1:\
|
Push-Location tmpTestA1:\
|
||||||
$breakpoint = set-psbreakpoint .\$scriptName 1 -action { continue }
|
$breakpoint = Set-PSBreakpoint .\$scriptName 1 -Action { continue }
|
||||||
& .\$scriptName
|
& .\$scriptName
|
||||||
|
|
||||||
It "Breakpoint hit count" {
|
It "Breakpoint hit count" {
|
||||||
@ -44,7 +44,7 @@ Describe "Breakpoints set on custom FileSystem provider files should work" -Tags
|
|||||||
{
|
{
|
||||||
Pop-Location
|
Pop-Location
|
||||||
|
|
||||||
if ($null -ne $breakpoint) { $breakpoint | remove-psbreakpoint }
|
if ($null -ne $breakpoint) { $breakpoint | Remove-PSBreakpoint }
|
||||||
if (Test-Path $scriptFullName) { Remove-Item $scriptFullName -Force }
|
if (Test-Path $scriptFullName) { Remove-Item $scriptFullName -Force }
|
||||||
if ($null -ne (Get-PSDrive -Name tmpTestA1 2> $null)) { Remove-PSDrive -Name tmpTestA1 -Force }
|
if ($null -ne (Get-PSDrive -Name tmpTestA1 2> $null)) { Remove-PSDrive -Name tmpTestA1 -Force }
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ Describe "Tests line breakpoints on dot-sourced files" -Tags "CI" {
|
|||||||
#
|
#
|
||||||
$scriptFile = [io.path]::Combine([io.path]::GetTempPath(), "DebuggerScriptTests-ExposeBug245331.ps1")
|
$scriptFile = [io.path]::Combine([io.path]::GetTempPath(), "DebuggerScriptTests-ExposeBug245331.ps1")
|
||||||
|
|
||||||
write-output '
|
Write-Output '
|
||||||
function fibonacci
|
function fibonacci
|
||||||
{
|
{
|
||||||
param($number)
|
param($number)
|
||||||
@ -89,7 +89,7 @@ Describe "Tests line breakpoints on dot-sourced files" -Tags "CI" {
|
|||||||
#
|
#
|
||||||
# Set the breakpoint and verify it is hit
|
# Set the breakpoint and verify it is hit
|
||||||
#
|
#
|
||||||
$breakpoint = Set-PsBreakpoint $scriptFile 17 -action { continue; }
|
$breakpoint = Set-PSBreakpoint $scriptFile 17 -Action { continue; }
|
||||||
|
|
||||||
& $scriptFile
|
& $scriptFile
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ Describe "Tests line breakpoints on dot-sourced files" -Tags "CI" {
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if ($null -ne $breakpoint) { $breakpoint | remove-psbreakpoint }
|
if ($null -ne $breakpoint) { $breakpoint | Remove-PSBreakpoint }
|
||||||
if (Test-Path $scriptFile) { Remove-Item -Path $scriptFile -Force }
|
if (Test-Path $scriptFile) { Remove-Item -Path $scriptFile -Force }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,7 +123,7 @@ Describe "Function calls clear debugger cache too early" -Tags "CI" {
|
|||||||
#
|
#
|
||||||
$scriptFile = [io.path]::Combine([io.path]::GetTempPath(), "DebuggerScriptTests-ExposeBug248703.ps1")
|
$scriptFile = [io.path]::Combine([io.path]::GetTempPath(), "DebuggerScriptTests-ExposeBug248703.ps1")
|
||||||
|
|
||||||
write-output '
|
Write-Output '
|
||||||
function Hello
|
function Hello
|
||||||
{
|
{
|
||||||
write-output "hello"
|
write-output "hello"
|
||||||
@ -137,8 +137,8 @@ Describe "Function calls clear debugger cache too early" -Tags "CI" {
|
|||||||
#
|
#
|
||||||
# Set the breakpoints and verify they are hit
|
# Set the breakpoints and verify they are hit
|
||||||
#
|
#
|
||||||
$breakpoint1 = Set-PsBreakpoint $scriptFile 7 -action { continue; }
|
$breakpoint1 = Set-PSBreakpoint $scriptFile 7 -Action { continue; }
|
||||||
$breakpoint2 = Set-PsBreakpoint $scriptFile 9 -action { continue; }
|
$breakpoint2 = Set-PSBreakpoint $scriptFile 9 -Action { continue; }
|
||||||
|
|
||||||
& $scriptFile
|
& $scriptFile
|
||||||
|
|
||||||
@ -152,8 +152,8 @@ Describe "Function calls clear debugger cache too early" -Tags "CI" {
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if ($null -ne $breakpoint1) { $breakpoint1 | remove-psbreakpoint }
|
if ($null -ne $breakpoint1) { $breakpoint1 | Remove-PSBreakpoint }
|
||||||
if ($null -ne $breakpoint2) { $breakpoint2 | remove-psbreakpoint }
|
if ($null -ne $breakpoint2) { $breakpoint2 | Remove-PSBreakpoint }
|
||||||
if (Test-Path $scriptFile) { Remove-Item $scriptFile -Force }
|
if (Test-Path $scriptFile) { Remove-Item $scriptFile -Force }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -180,7 +180,7 @@ Describe "Line breakpoints on commands in multi-line pipelines" -Tags "CI" {
|
|||||||
get-unique
|
get-unique
|
||||||
'@
|
'@
|
||||||
|
|
||||||
$breakpoints = Set-PsBreakpoint $script 1,2,3 -action { continue }
|
$breakpoints = Set-PSBreakpoint $script 1,2,3 -Action { continue }
|
||||||
|
|
||||||
$null = & $script
|
$null = & $script
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ Describe "Line breakpoints on commands in multi-line pipelines" -Tags "CI" {
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if ($null -ne $breakpoints) { $breakpoints | remove-psbreakpoint }
|
if ($null -ne $breakpoints) { $breakpoints | Remove-PSBreakpoint }
|
||||||
if (Test-Path $script)
|
if (Test-Path $script)
|
||||||
{
|
{
|
||||||
Remove-Item $script -Force
|
Remove-Item $script -Force
|
||||||
@ -210,7 +210,7 @@ Describe "Line breakpoints on commands in multi-line pipelines" -Tags "CI" {
|
|||||||
BeforeAll {
|
BeforeAll {
|
||||||
if ( $IsCoreCLR ) { return } # no COM on core
|
if ( $IsCoreCLR ) { return } # no COM on core
|
||||||
$scriptPath1 = Join-Path $TestDrive SBPShortPathBug133807.DRT.tmp.ps1
|
$scriptPath1 = Join-Path $TestDrive SBPShortPathBug133807.DRT.tmp.ps1
|
||||||
$scriptPath1 = setup -f SBPShortPathBug133807.DRT.tmp.ps1 -content '
|
$scriptPath1 = Setup -f SBPShortPathBug133807.DRT.tmp.ps1 -Content '
|
||||||
1..3 |
|
1..3 |
|
||||||
ForEach-Object { $_ } | sort-object |
|
ForEach-Object { $_ } | sort-object |
|
||||||
get-unique'
|
get-unique'
|
||||||
@ -218,7 +218,7 @@ Describe "Line breakpoints on commands in multi-line pipelines" -Tags "CI" {
|
|||||||
$f = $a.GetFile($scriptPath1)
|
$f = $a.GetFile($scriptPath1)
|
||||||
$scriptPath2 = $f.ShortPath
|
$scriptPath2 = $f.ShortPath
|
||||||
|
|
||||||
$breakpoints = Set-PsBreakpoint $scriptPath2 1,2,3 -action { continue }
|
$breakpoints = Set-PSBreakpoint $scriptPath2 1,2,3 -Action { continue }
|
||||||
$null = & $scriptPath2
|
$null = & $scriptPath2
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,15 +227,15 @@ Describe "Line breakpoints on commands in multi-line pipelines" -Tags "CI" {
|
|||||||
if ($null -ne $breakpoints) { $breakpoints | Remove-PSBreakpoint }
|
if ($null -ne $breakpoints) { $breakpoints | Remove-PSBreakpoint }
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Short path Breakpoint on line 1 hit count" -skip:$IsCoreCLR {
|
It "Short path Breakpoint on line 1 hit count" -Skip:$IsCoreCLR {
|
||||||
$breakpoints[0].HitCount | Should -Be 1
|
$breakpoints[0].HitCount | Should -Be 1
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Short path Breakpoint on line 2 hit count" -skip:$IsCoreCLR {
|
It "Short path Breakpoint on line 2 hit count" -Skip:$IsCoreCLR {
|
||||||
$breakpoints[1].HitCount | Should -Be 3
|
$breakpoints[1].HitCount | Should -Be 3
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Short path Breakpoint on line 3 hit count" -skip:$IsCoreCLR {
|
It "Short path Breakpoint on line 3 hit count" -Skip:$IsCoreCLR {
|
||||||
$breakpoints[2].HitCount | Should -Be 1
|
$breakpoints[2].HitCount | Should -Be 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -251,7 +251,7 @@ Describe "Unit tests for various script breakpoints" -Tags "CI" {
|
|||||||
|
|
||||||
if ($null -eq $path)
|
if ($null -eq $path)
|
||||||
{
|
{
|
||||||
$path = split-path $MyInvocation.InvocationName
|
$path = Split-Path $MyInvocation.InvocationName
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -290,7 +290,7 @@ Describe "Unit tests for various script breakpoints" -Tags "CI" {
|
|||||||
#
|
#
|
||||||
# Ensure there are no breakpoints at start of test
|
# Ensure there are no breakpoints at start of test
|
||||||
#
|
#
|
||||||
Get-PsBreakpoint | Remove-PsBreakpoint
|
Get-PSBreakpoint | Remove-PSBreakpoint
|
||||||
|
|
||||||
#
|
#
|
||||||
# Create a couple of scripts
|
# Create a couple of scripts
|
||||||
@ -298,54 +298,54 @@ Describe "Unit tests for various script breakpoints" -Tags "CI" {
|
|||||||
$scriptFile1 = [io.path]::Combine([io.path]::GetTempPath(), "DebuggerScriptTests-Get-PsBreakpoint1.ps1")
|
$scriptFile1 = [io.path]::Combine([io.path]::GetTempPath(), "DebuggerScriptTests-Get-PsBreakpoint1.ps1")
|
||||||
$scriptFile2 = [io.path]::Combine([io.path]::GetTempPath(), "DebuggerScriptTests-Get-PsBreakpoint2.ps1")
|
$scriptFile2 = [io.path]::Combine([io.path]::GetTempPath(), "DebuggerScriptTests-Get-PsBreakpoint2.ps1")
|
||||||
|
|
||||||
write-output '' > $scriptFile1
|
Write-Output '' > $scriptFile1
|
||||||
write-output '' > $scriptFile2
|
Write-Output '' > $scriptFile2
|
||||||
|
|
||||||
#
|
#
|
||||||
# Set several breakpoints of different types
|
# Set several breakpoints of different types
|
||||||
#
|
#
|
||||||
$line1 = Set-PsBreakpoint $scriptFile1 1
|
$line1 = Set-PSBreakpoint $scriptFile1 1
|
||||||
$line2 = Set-PsBreakpoint $scriptFile2 2
|
$line2 = Set-PSBreakpoint $scriptFile2 2
|
||||||
|
|
||||||
$cmd1 = Set-PsBreakpoint -c command1 -s $scriptFile1
|
$cmd1 = Set-PSBreakpoint -c command1 -s $scriptFile1
|
||||||
$cmd2 = Set-PsBreakpoint -c command2 -s $scriptFile2
|
$cmd2 = Set-PSBreakpoint -c command2 -s $scriptFile2
|
||||||
$cmd3 = Set-PsBreakpoint -c command3
|
$cmd3 = Set-PSBreakpoint -c command3
|
||||||
|
|
||||||
$var1 = Set-PsBreakpoint -v variable1 -s $scriptFile1
|
$var1 = Set-PSBreakpoint -v variable1 -s $scriptFile1
|
||||||
$var2 = Set-PsBreakpoint -v variable2 -s $scriptFile2
|
$var2 = Set-PSBreakpoint -v variable2 -s $scriptFile2
|
||||||
$var3 = Set-PsBreakpoint -v variable3
|
$var3 = Set-PSBreakpoint -v variable3
|
||||||
|
|
||||||
#
|
#
|
||||||
# The default parameter set must return all breakpoints
|
# The default parameter set must return all breakpoints
|
||||||
#
|
#
|
||||||
Verify { get-psbreakpoint } $line1,$line2,$cmd1,$cmd2,$cmd3,$var1,$var2,$var3
|
Verify { Get-PSBreakpoint } $line1,$line2,$cmd1,$cmd2,$cmd3,$var1,$var2,$var3
|
||||||
|
|
||||||
#
|
#
|
||||||
# Query by ID
|
# Query by ID
|
||||||
#
|
#
|
||||||
Verify { get-psbreakpoint -id $line1.ID,$cmd1.ID,$var1.ID } $line1,$cmd1,$var1 # -id
|
Verify { Get-PSBreakpoint -Id $line1.ID,$cmd1.ID,$var1.ID } $line1,$cmd1,$var1 # -id
|
||||||
Verify { get-psbreakpoint $line2.ID,$cmd2.ID,$var2.ID } $line2,$cmd2,$var2 # positional
|
Verify { Get-PSBreakpoint $line2.ID,$cmd2.ID,$var2.ID } $line2,$cmd2,$var2 # positional
|
||||||
Verify { $cmd3.ID,$var3.ID | get-psbreakpoint } $cmd3,$var3 # value from pipeline
|
Verify { $cmd3.ID,$var3.ID | Get-PSBreakpoint } $cmd3,$var3 # value from pipeline
|
||||||
|
|
||||||
VerifyException { get-psbreakpoint -id $null } "ParameterBindingValidationException"
|
VerifyException { Get-PSBreakpoint -Id $null } "ParameterBindingValidationException"
|
||||||
VerifyException { get-psbreakpoint -id $line1.ID -script $scriptFile1 } "ParameterBindingException"
|
VerifyException { Get-PSBreakpoint -Id $line1.ID -Script $scriptFile1 } "ParameterBindingException"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Query by Script
|
# Query by Script
|
||||||
#
|
#
|
||||||
Verify { get-psbreakpoint -script $scriptFile1 } $line1,$cmd1,$var1 # -script
|
Verify { Get-PSBreakpoint -Script $scriptFile1 } $line1,$cmd1,$var1 # -script
|
||||||
Verify { get-psbreakpoint $scriptFile2 } $line2,$cmd2,$var2 # positional
|
Verify { Get-PSBreakpoint $scriptFile2 } $line2,$cmd2,$var2 # positional
|
||||||
Verify { $scriptFile2 | get-psbreakpoint } $line2,$cmd2,$var2 # value from pipeline
|
Verify { $scriptFile2 | Get-PSBreakpoint } $line2,$cmd2,$var2 # value from pipeline
|
||||||
|
|
||||||
VerifyException { get-psbreakpoint -script $null } "ParameterBindingValidationException"
|
VerifyException { Get-PSBreakpoint -Script $null } "ParameterBindingValidationException"
|
||||||
VerifyException { get-psbreakpoint -script $scriptFile1,$null } "ParameterBindingValidationException"
|
VerifyException { Get-PSBreakpoint -Script $scriptFile1,$null } "ParameterBindingValidationException"
|
||||||
|
|
||||||
# Verify that relative paths are handled correctly
|
# Verify that relative paths are handled correctly
|
||||||
$directoryName = [System.IO.Path]::GetDirectoryName($scriptFile1)
|
$directoryName = [System.IO.Path]::GetDirectoryName($scriptFile1)
|
||||||
$fileName = [System.IO.Path]::GetFileName($scriptFile1)
|
$fileName = [System.IO.Path]::GetFileName($scriptFile1)
|
||||||
|
|
||||||
Push-Location $directoryName
|
Push-Location $directoryName
|
||||||
Verify { get-psbreakpoint -script $fileName } $line1,$cmd1,$var1
|
Verify { Get-PSBreakpoint -Script $fileName } $line1,$cmd1,$var1
|
||||||
Pop-Location
|
Pop-Location
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -354,28 +354,28 @@ Describe "Unit tests for various script breakpoints" -Tags "CI" {
|
|||||||
$commandType = [Microsoft.PowerShell.Commands.BreakpointType]"command"
|
$commandType = [Microsoft.PowerShell.Commands.BreakpointType]"command"
|
||||||
$variableType = [Microsoft.PowerShell.Commands.BreakpointType]"variable"
|
$variableType = [Microsoft.PowerShell.Commands.BreakpointType]"variable"
|
||||||
|
|
||||||
Verify { get-psbreakpoint -type "line" } $line1,$line2 # -type
|
Verify { Get-PSBreakpoint -Type "line" } $line1,$line2 # -type
|
||||||
Verify { get-psbreakpoint $commandType } $cmd1,$cmd2,$cmd3 # positional
|
Verify { Get-PSBreakpoint $commandType } $cmd1,$cmd2,$cmd3 # positional
|
||||||
Verify { $variableType | get-psbreakpoint } $var1,$var2,$var3 # value from pipeline
|
Verify { $variableType | Get-PSBreakpoint } $var1,$var2,$var3 # value from pipeline
|
||||||
Verify { get-psbreakpoint -type "line" -script $scriptFile1 } @($line1) # -script parameter
|
Verify { Get-PSBreakpoint -Type "line" -Script $scriptFile1 } @($line1) # -script parameter
|
||||||
|
|
||||||
VerifyException { get-psbreakpoint -type $null } "ParameterBindingValidationException"
|
VerifyException { Get-PSBreakpoint -Type $null } "ParameterBindingValidationException"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Query by Command
|
# Query by Command
|
||||||
#
|
#
|
||||||
Verify { get-psbreakpoint -command "command1","command2" } $cmd1,$cmd2 # -command
|
Verify { Get-PSBreakpoint -Command "command1","command2" } $cmd1,$cmd2 # -command
|
||||||
Verify { get-psbreakpoint -command "command1","command2" -script $scriptFile1 } @($cmd1) # -script parameter
|
Verify { Get-PSBreakpoint -Command "command1","command2" -Script $scriptFile1 } @($cmd1) # -script parameter
|
||||||
|
|
||||||
VerifyException { get-psbreakpoint -command $null } "ParameterBindingValidationException"
|
VerifyException { Get-PSBreakpoint -Command $null } "ParameterBindingValidationException"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Query by Variable
|
# Query by Variable
|
||||||
#
|
#
|
||||||
Verify { get-psbreakpoint -variable "variable1","variable2" } $var1,$var2 # -command
|
Verify { Get-PSBreakpoint -Variable "variable1","variable2" } $var1,$var2 # -command
|
||||||
Verify { get-psbreakpoint -variable "variable1","variable2" -script $scriptFile1 } @($var1) # -script parameter
|
Verify { Get-PSBreakpoint -Variable "variable1","variable2" -Script $scriptFile1 } @($var1) # -script parameter
|
||||||
|
|
||||||
VerifyException { get-psbreakpoint -variable $null } "ParameterBindingValidationException"
|
VerifyException { Get-PSBreakpoint -Variable $null } "ParameterBindingValidationException"
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@ -404,7 +404,7 @@ Describe "Unit tests for line breakpoints on dot-sourced files" -Tags "CI" {
|
|||||||
|
|
||||||
if ($null -eq $path)
|
if ($null -eq $path)
|
||||||
{
|
{
|
||||||
$path = split-path $MyInvocation.InvocationName
|
$path = Split-Path $MyInvocation.InvocationName
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -414,7 +414,7 @@ Describe "Unit tests for line breakpoints on dot-sourced files" -Tags "CI" {
|
|||||||
#
|
#
|
||||||
$scriptFile = [io.path]::Combine([io.path]::GetTempPath(), "DebuggerScriptTests-InMemoryBreakpoints.ps1")
|
$scriptFile = [io.path]::Combine([io.path]::GetTempPath(), "DebuggerScriptTests-InMemoryBreakpoints.ps1")
|
||||||
|
|
||||||
write-output '
|
Write-Output '
|
||||||
function Function1
|
function Function1
|
||||||
{
|
{
|
||||||
write-host "In Function1" # line 4
|
write-host "In Function1" # line 4
|
||||||
@ -450,9 +450,9 @@ Describe "Unit tests for line breakpoints on dot-sourced files" -Tags "CI" {
|
|||||||
#
|
#
|
||||||
# Set a couple of line breakpoints on the file, dot-source it and verify that the breakpoints are hit
|
# Set a couple of line breakpoints on the file, dot-source it and verify that the breakpoints are hit
|
||||||
#
|
#
|
||||||
$breakpoint1 = Set-PsBreakpoint $scriptFile 4 -action { continue; }
|
$breakpoint1 = Set-PSBreakpoint $scriptFile 4 -Action { continue; }
|
||||||
$breakpoint2 = Set-PsBreakpoint $scriptFile 9 -action { continue; }
|
$breakpoint2 = Set-PSBreakpoint $scriptFile 9 -Action { continue; }
|
||||||
$breakpoint3 = Set-PsBreakpoint $scriptFile 24 -action { continue; }
|
$breakpoint3 = Set-PSBreakpoint $scriptFile 24 -Action { continue; }
|
||||||
|
|
||||||
. $scriptFile
|
. $scriptFile
|
||||||
|
|
||||||
@ -500,7 +500,7 @@ Describe "Unit tests for line breakpoints on modules" -Tags "CI" {
|
|||||||
|
|
||||||
New-Item -ItemType Directory $moduleDirectory 2> $null
|
New-Item -ItemType Directory $moduleDirectory 2> $null
|
||||||
|
|
||||||
write-output '
|
Write-Output '
|
||||||
function ModuleFunction1
|
function ModuleFunction1
|
||||||
{
|
{
|
||||||
write-output "In ModuleFunction1" # line 4
|
write-output "In ModuleFunction1" # line 4
|
||||||
@ -542,15 +542,15 @@ Describe "Unit tests for line breakpoints on modules" -Tags "CI" {
|
|||||||
#
|
#
|
||||||
$ENV:PSModulePath = $moduleRoot
|
$ENV:PSModulePath = $moduleRoot
|
||||||
|
|
||||||
import-module $moduleName
|
Import-Module $moduleName
|
||||||
|
|
||||||
#
|
#
|
||||||
# Set a couple of line breakpoints on the module and verify that they are hit
|
# Set a couple of line breakpoints on the module and verify that they are hit
|
||||||
#
|
#
|
||||||
$breakpoint1 = Set-PsBreakpoint $moduleFile 4 -action { continue }
|
$breakpoint1 = Set-PSBreakpoint $moduleFile 4 -Action { continue }
|
||||||
$breakpoint2 = Set-PsBreakpoint $moduleFile 9 -action { continue }
|
$breakpoint2 = Set-PSBreakpoint $moduleFile 9 -Action { continue }
|
||||||
$breakpoint3 = Set-PsBreakpoint $moduleFile 24 -Action { continue }
|
$breakpoint3 = Set-PSBreakpoint $moduleFile 24 -Action { continue }
|
||||||
$breakpoint4 = Set-PsBreakpoint $moduleFile 25 -Action { continue }
|
$breakpoint4 = Set-PSBreakpoint $moduleFile 25 -Action { continue }
|
||||||
|
|
||||||
ModuleFunction1
|
ModuleFunction1
|
||||||
|
|
||||||
@ -579,8 +579,8 @@ Describe "Unit tests for line breakpoints on modules" -Tags "CI" {
|
|||||||
if ($null -ne $breakpoint2) { Remove-PSBreakpoint $breakpoint2 }
|
if ($null -ne $breakpoint2) { Remove-PSBreakpoint $breakpoint2 }
|
||||||
if ($null -ne $breakpoint3) { Remove-PSBreakpoint $breakpoint3 }
|
if ($null -ne $breakpoint3) { Remove-PSBreakpoint $breakpoint3 }
|
||||||
if ($null -ne $breakpoint4) { Remove-PSBreakpoint $breakpoint4 }
|
if ($null -ne $breakpoint4) { Remove-PSBreakpoint $breakpoint4 }
|
||||||
get-module $moduleName | remove-module
|
Get-Module $moduleName | Remove-Module
|
||||||
if (Test-Path $moduleDirectory) { Remove-Item $moduleDirectory -Recurse -force -ErrorAction silentlycontinue }
|
if (Test-Path $moduleDirectory) { Remove-Item $moduleDirectory -Recurse -Force -ErrorAction silentlycontinue }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -639,7 +639,7 @@ Describe "Sometimes line breakpoints are ignored" -Tags "CI" {
|
|||||||
if ($null -ne $bp1) { Remove-PSBreakpoint $bp1 }
|
if ($null -ne $bp1) { Remove-PSBreakpoint $bp1 }
|
||||||
if ($null -ne $bp2) { Remove-PSBreakpoint $bp2 }
|
if ($null -ne $bp2) { Remove-PSBreakpoint $bp2 }
|
||||||
|
|
||||||
if (Test-Path -Path $tempFileName1) { Remove-Item $tempFileName1 -force }
|
if (Test-Path -Path $tempFileName1) { Remove-Item $tempFileName1 -Force }
|
||||||
if (Test-Path -Path $tempFileName2) { Remove-Item $tempFileName2 -force }
|
if (Test-Path -Path $tempFileName2) { Remove-Item $tempFileName2 -Force }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Copyright (c) Microsoft Corporation.
|
# Copyright (c) Microsoft Corporation.
|
||||||
# Licensed under the MIT License.
|
# Licensed under the MIT License.
|
||||||
|
|
||||||
Describe 'Basic debugger tests' -tag 'CI' {
|
Describe 'Basic debugger tests' -Tag 'CI' {
|
||||||
|
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
Register-DebuggerHandler
|
Register-DebuggerHandler
|
||||||
@ -17,7 +17,7 @@ Describe 'Basic debugger tests' -tag 'CI' {
|
|||||||
function Test-DollarQuestionMark {
|
function Test-DollarQuestionMark {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param()
|
param()
|
||||||
Get-Process -id ([int]::MaxValue)
|
Get-Process -Id ([int]::MaxValue)
|
||||||
if (-not $?) {
|
if (-not $?) {
|
||||||
'The value of $? was preserved during debugging.'
|
'The value of $? was preserved during debugging.'
|
||||||
} else {
|
} else {
|
||||||
@ -27,7 +27,7 @@ Describe 'Basic debugger tests' -tag 'CI' {
|
|||||||
$global:DollarQuestionMarkResults = Test-DollarQuestionMark -ErrorAction Break
|
$global:DollarQuestionMarkResults = Test-DollarQuestionMark -ErrorAction Break
|
||||||
}
|
}
|
||||||
|
|
||||||
$global:results = @(Test-Debugger -ScriptBlock $testScript -CommandQueue '$?')
|
$global:results = @(Test-Debugger -Scriptblock $testScript -CommandQueue '$?')
|
||||||
}
|
}
|
||||||
|
|
||||||
AfterAll {
|
AfterAll {
|
||||||
@ -51,7 +51,7 @@ Describe 'Basic debugger tests' -tag 'CI' {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Describe "Breakpoints when set should be hit" -tag "CI" {
|
Describe "Breakpoints when set should be hit" -Tag "CI" {
|
||||||
Context "Basic tests" {
|
Context "Basic tests" {
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
$script = @'
|
$script = @'
|
||||||
@ -63,11 +63,11 @@ Describe "Breakpoints when set should be hit" -tag "CI" {
|
|||||||
'bbb'
|
'bbb'
|
||||||
'@
|
'@
|
||||||
$path = Setup -PassThru -File BasicTest.ps1 -Content $script
|
$path = Setup -PassThru -File BasicTest.ps1 -Content $script
|
||||||
$bps = 1..6 | ForEach-Object { set-psbreakpoint -script $path -line $_ -Action { continue } }
|
$bps = 1..6 | ForEach-Object { Set-PSBreakpoint -Script $path -Line $_ -Action { continue } }
|
||||||
}
|
}
|
||||||
|
|
||||||
AfterAll {
|
AfterAll {
|
||||||
$bps | Remove-PSBreakPoint
|
$bps | Remove-PSBreakpoint
|
||||||
}
|
}
|
||||||
|
|
||||||
It "A redirected breakpoint is hit" {
|
It "A redirected breakpoint is hit" {
|
||||||
@ -333,7 +333,7 @@ elseif (Test-Path $PSCommandPath)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Describe "It should be possible to reset runspace debugging" -tag "Feature" {
|
Describe "It should be possible to reset runspace debugging" -Tag "Feature" {
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
$script = @'
|
$script = @'
|
||||||
"line 1"
|
"line 1"
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
Describe "Tests Debugger GetCallStack() on runspaces when attached to a WinRM host process" -Tags "CI" {
|
Describe "Tests Debugger GetCallStack() on runspaces when attached to a WinRM host process" -Tags "CI" {
|
||||||
|
|
||||||
It -skip "Disabled test because it is fragile and does not consistently succeed on test VMs" { }
|
It -Skip "Disabled test because it is fragile and does not consistently succeed on test VMs" { }
|
||||||
return
|
return
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -88,7 +88,7 @@ Describe "Tests conversion of deserialized types to original type using object p
|
|||||||
|
|
||||||
Context 'Type conversion and parameter binding of deserialized Type case 1: type definition contains public fields' {
|
Context 'Type conversion and parameter binding of deserialized Type case 1: type definition contains public fields' {
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
$t1 = new-object test1 -Property @{name="TestName1";port=80;scriptText="1..5"}
|
$t1 = New-Object test1 -Property @{name="TestName1";port=80;scriptText="1..5"}
|
||||||
$s = [System.Management.Automation.PSSerializer]::Serialize($t1)
|
$s = [System.Management.Automation.PSSerializer]::Serialize($t1)
|
||||||
$dst1 = [System.Management.Automation.PSSerializer]::Deserialize($s)
|
$dst1 = [System.Management.Automation.PSSerializer]::Deserialize($s)
|
||||||
}
|
}
|
||||||
@ -114,7 +114,7 @@ Describe "Tests conversion of deserialized types to original type using object p
|
|||||||
|
|
||||||
Context 'Type conversion and parameter binding of deserialized Type case 2: type definition contains public properties' {
|
Context 'Type conversion and parameter binding of deserialized Type case 2: type definition contains public properties' {
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
$t2 = new-object test2 -Property @{Name="TestName2";Port=80;ScriptText="1..5"}
|
$t2 = New-Object test2 -Property @{Name="TestName2";Port=80;ScriptText="1..5"}
|
||||||
$s = [System.Management.Automation.PSSerializer]::Serialize($t2)
|
$s = [System.Management.Automation.PSSerializer]::Serialize($t2)
|
||||||
$dst2 = [System.Management.Automation.PSSerializer]::Deserialize($s)
|
$dst2 = [System.Management.Automation.PSSerializer]::Deserialize($s)
|
||||||
}
|
}
|
||||||
@ -138,7 +138,7 @@ Describe "Tests conversion of deserialized types to original type using object p
|
|||||||
|
|
||||||
Context 'Type conversion and parameter binding of deserialized Type case 1: type definition contains 2 public properties and 1 read only property' {
|
Context 'Type conversion and parameter binding of deserialized Type case 1: type definition contains 2 public properties and 1 read only property' {
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
$t3 = new-object test3 -Property @{Name="TestName3";Port=80}
|
$t3 = New-Object test3 -Property @{Name="TestName3";Port=80}
|
||||||
$s = [System.Management.Automation.PSSerializer]::Serialize($t3)
|
$s = [System.Management.Automation.PSSerializer]::Serialize($t3)
|
||||||
$dst3 = [System.Management.Automation.PSSerializer]::Deserialize($s)
|
$dst3 = [System.Management.Automation.PSSerializer]::Deserialize($s)
|
||||||
}
|
}
|
||||||
@ -165,7 +165,7 @@ Describe "Tests conversion of deserialized types to original type using object p
|
|||||||
|
|
||||||
Context 'Type conversion and parameter binding of deserialized Type case 1: type definition contains 2 public properties' {
|
Context 'Type conversion and parameter binding of deserialized Type case 1: type definition contains 2 public properties' {
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
$t4 = new-object test4 -Property @{Name="TestName4";Port=80}
|
$t4 = New-Object test4 -Property @{Name="TestName4";Port=80}
|
||||||
$s = [System.Management.Automation.PSSerializer]::Serialize($t4)
|
$s = [System.Management.Automation.PSSerializer]::Serialize($t4)
|
||||||
$dst4 = [System.Management.Automation.PSSerializer]::Deserialize($s)
|
$dst4 = [System.Management.Automation.PSSerializer]::Deserialize($s)
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,6 @@ Describe "Dynamic parameter support in script cmdlets." -Tags "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
It "Parameter is defined in Class" {
|
It "Parameter is defined in Class" {
|
||||||
foo-bar -path class -name "myName" | Should -BeExactly 'myName'
|
foo-bar -path class -Name "myName" | Should -BeExactly 'myName'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ Describe "Generics support" -Tags "CI" {
|
|||||||
$x = [dictionary[dictionary[list[int],string], stack[double]]]::new()
|
$x = [dictionary[dictionary[list[int],string], stack[double]]]::new()
|
||||||
$x.gettype().fullname | Should -Match "double"
|
$x.gettype().fullname | Should -Match "double"
|
||||||
|
|
||||||
$y = new-object "dictionary[dictionary[list[int],string], stack[double]]"
|
$y = New-Object "dictionary[dictionary[list[int],string], stack[double]]"
|
||||||
$y.gettype().fullname | Should -Match "double"
|
$y.gettype().fullname | Should -Match "double"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ Describe "Generics support" -Tags "CI" {
|
|||||||
$e | Should -Match "\[T\]"
|
$e | Should -Match "\[T\]"
|
||||||
}
|
}
|
||||||
|
|
||||||
It 'Array type works properly' -skip:$IsCoreCLR{
|
It 'Array type works properly' -Skip:$IsCoreCLR{
|
||||||
$x = [system.array]::ConvertAll.OverloadDefinitions
|
$x = [system.array]::ConvertAll.OverloadDefinitions
|
||||||
$x | Should -Match "static\s+TOutput\[\]\s+ConvertAll\[TInput,\s+TOutput\]\("
|
$x | Should -Match "static\s+TOutput\[\]\s+ConvertAll\[TInput,\s+TOutput\]\("
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ Describe "Tests for hashtable to PSCustomObject conversion" -Tags "CI" {
|
|||||||
|
|
||||||
It 'Type Validation: <Name>' -TestCases:$testdata {
|
It 'Type Validation: <Name>' -TestCases:$testdata {
|
||||||
param ($Name, $Cmd, $ExpectedType)
|
param ($Name, $Cmd, $ExpectedType)
|
||||||
Invoke-expression $Cmd -OutVariable a
|
Invoke-Expression $Cmd -OutVariable a
|
||||||
$a = Get-Variable -Name a -ValueOnly
|
$a = Get-Variable -Name a -ValueOnly
|
||||||
$a | Should -BeOfType $ExpectedType
|
$a | Should -BeOfType $ExpectedType
|
||||||
}
|
}
|
||||||
@ -47,7 +47,7 @@ Describe "Tests for hashtable to PSCustomObject conversion" -Tags "CI" {
|
|||||||
|
|
||||||
$p = 0
|
$p = 0
|
||||||
# Checks if the first property is One
|
# Checks if the first property is One
|
||||||
$x.psobject.Properties | foreach-object `
|
$x.psobject.Properties | ForEach-Object `
|
||||||
{
|
{
|
||||||
if ($p -eq 0)
|
if ($p -eq 0)
|
||||||
{
|
{
|
||||||
@ -64,7 +64,7 @@ Describe "Tests for hashtable to PSCustomObject conversion" -Tags "CI" {
|
|||||||
|
|
||||||
$p = 0
|
$p = 0
|
||||||
# Checks if the first property is One
|
# Checks if the first property is One
|
||||||
$x.psobject.Properties | foreach-object `
|
$x.psobject.Properties | ForEach-Object `
|
||||||
{
|
{
|
||||||
if ($p -eq 0)
|
if ($p -eq 0)
|
||||||
{
|
{
|
||||||
@ -136,7 +136,7 @@ Describe "Tests for hashtable to PSCustomObject conversion" -Tags "CI" {
|
|||||||
$obj = $null
|
$obj = $null
|
||||||
$ht = @{one=1;two=2}
|
$ht = @{one=1;two=2}
|
||||||
|
|
||||||
{ $obj = New-Object System.Management.Automation.PSCustomObject -property $ht } |
|
{ $obj = New-Object System.Management.Automation.PSCustomObject -Property $ht } |
|
||||||
Should -Throw -ErrorId "CannotFindAppropriateCtor,Microsoft.PowerShell.Commands.NewObjectCommand"
|
Should -Throw -ErrorId "CannotFindAppropriateCtor,Microsoft.PowerShell.Commands.NewObjectCommand"
|
||||||
$obj | Should -BeNullOrEmpty
|
$obj | Should -BeNullOrEmpty
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ Describe 'Testing of script internationalization' -Tags "CI" {
|
|||||||
|
|
||||||
It 'Import default culture is done correctly' {
|
It 'Import default culture is done correctly' {
|
||||||
|
|
||||||
import-localizedData mydata;
|
Import-LocalizedData mydata;
|
||||||
|
|
||||||
$mydata.string1 | Should -BeExactly 'string1 for en-US'
|
$mydata.string1 | Should -BeExactly 'string1 for en-US'
|
||||||
$mydata.string2 | Should -BeExactly 'string2 for en-US'
|
$mydata.string2 | Should -BeExactly 'string2 for en-US'
|
||||||
@ -38,12 +38,12 @@ Describe 'Testing of script internationalization' -Tags "CI" {
|
|||||||
|
|
||||||
It 'Import specific culture(en-US)' {
|
It 'Import specific culture(en-US)' {
|
||||||
|
|
||||||
import-localizedData mydata -uiculture en-US
|
Import-LocalizedData mydata -UICulture en-US
|
||||||
|
|
||||||
$mydata.string1 | Should -BeExactly 'string1 for en-US'
|
$mydata.string1 | Should -BeExactly 'string1 for en-US'
|
||||||
$mydata.string2 | Should -BeExactly 'string2 for en-US'
|
$mydata.string2 | Should -BeExactly 'string2 for en-US'
|
||||||
|
|
||||||
import-localizedData mydata -uiculture fr-FR
|
Import-LocalizedData mydata -UICulture fr-FR
|
||||||
|
|
||||||
$mydata.string1 | Should -BeExactly 'string1 for fr-FR'
|
$mydata.string1 | Should -BeExactly 'string1 for fr-FR'
|
||||||
$mydata.string2 | Should -BeExactly 'string2 for fr-FR'
|
$mydata.string2 | Should -BeExactly 'string2 for fr-FR'
|
||||||
@ -51,7 +51,7 @@ Describe 'Testing of script internationalization' -Tags "CI" {
|
|||||||
|
|
||||||
It 'Import non existing culture is done correctly' {
|
It 'Import non existing culture is done correctly' {
|
||||||
|
|
||||||
import-localizedData mydata -uiculture nl-NL -ErrorAction SilentlyContinue -ErrorVariable ev
|
Import-LocalizedData mydata -UICulture nl-NL -ErrorAction SilentlyContinue -ErrorVariable ev
|
||||||
|
|
||||||
$ev | Should -Not -BeNullOrEmpty
|
$ev | Should -Not -BeNullOrEmpty
|
||||||
$ev[0].Exception | Should -BeOfType System.Management.Automation.PSInvalidOperationException
|
$ev[0].Exception | Should -BeOfType System.Management.Automation.PSInvalidOperationException
|
||||||
@ -59,12 +59,12 @@ Describe 'Testing of script internationalization' -Tags "CI" {
|
|||||||
|
|
||||||
It 'Import different file name is done correctly' {
|
It 'Import different file name is done correctly' {
|
||||||
|
|
||||||
import-localizedData mydata -filename foo
|
Import-LocalizedData mydata -FileName foo
|
||||||
|
|
||||||
$mydata.string1 | Should -BeExactly 'string1 from foo in en-US'
|
$mydata.string1 | Should -BeExactly 'string1 from foo in en-US'
|
||||||
$mydata.string2 | Should -BeExactly 'string2 from foo in en-US'
|
$mydata.string2 | Should -BeExactly 'string2 from foo in en-US'
|
||||||
|
|
||||||
import-localizedData mydata -filename foo -uiculture fr-FR
|
Import-LocalizedData mydata -FileName foo -UICulture fr-FR
|
||||||
|
|
||||||
$mydata.string1 | Should -BeExactly 'string1 from foo in fr-FR'
|
$mydata.string1 | Should -BeExactly 'string1 from foo in fr-FR'
|
||||||
$mydata.string2 | Should -BeExactly 'string2 from foo in fr-FR'
|
$mydata.string2 | Should -BeExactly 'string2 from foo in fr-FR'
|
||||||
@ -72,12 +72,12 @@ Describe 'Testing of script internationalization' -Tags "CI" {
|
|||||||
|
|
||||||
It 'Import different file base is done correctly' {
|
It 'Import different file base is done correctly' {
|
||||||
|
|
||||||
import-localizedData mydata -basedirectory "${dir}\newbase"
|
Import-LocalizedData mydata -BaseDirectory "${dir}\newbase"
|
||||||
|
|
||||||
$mydata.string1 | Should -BeExactly 'string1 for en-US under newbase'
|
$mydata.string1 | Should -BeExactly 'string1 for en-US under newbase'
|
||||||
$mydata.string2 | Should -BeExactly 'string2 for en-US under newbase'
|
$mydata.string2 | Should -BeExactly 'string2 for en-US under newbase'
|
||||||
|
|
||||||
import-localizedData mydata -basedirectory "${dir}\newbase" -uiculture fr-FR
|
Import-LocalizedData mydata -BaseDirectory "${dir}\newbase" -UICulture fr-FR
|
||||||
|
|
||||||
$mydata.string1 | Should -BeExactly 'string1 for fr-FR under newbase'
|
$mydata.string1 | Should -BeExactly 'string1 for fr-FR under newbase'
|
||||||
$mydata.string2 | Should -BeExactly 'string2 for fr-FR under newbase'
|
$mydata.string2 | Should -BeExactly 'string2 for fr-FR under newbase'
|
||||||
@ -85,12 +85,12 @@ Describe 'Testing of script internationalization' -Tags "CI" {
|
|||||||
|
|
||||||
It 'Import different file base and file name' {
|
It 'Import different file base and file name' {
|
||||||
|
|
||||||
import-localizedData mydata -basedirectory "${dir}\newbase" -filename foo
|
Import-LocalizedData mydata -BaseDirectory "${dir}\newbase" -FileName foo
|
||||||
|
|
||||||
$mydata.string1 | Should -BeExactly 'string1 for en-US from foo under newbase'
|
$mydata.string1 | Should -BeExactly 'string1 for en-US from foo under newbase'
|
||||||
$mydata.string2 | Should -BeExactly 'string2 for en-US from foo under newbase'
|
$mydata.string2 | Should -BeExactly 'string2 for en-US from foo under newbase'
|
||||||
|
|
||||||
import-localizedData mydata -basedirectory "${dir}\newbase" -filename foo -uiculture fr-FR
|
Import-LocalizedData mydata -BaseDirectory "${dir}\newbase" -FileName foo -UICulture fr-FR
|
||||||
|
|
||||||
$mydata.string1 | Should -BeExactly 'string1 for fr-FR from foo under newbase'
|
$mydata.string1 | Should -BeExactly 'string1 for fr-FR from foo under newbase'
|
||||||
$mydata.string2 | Should -BeExactly 'string2 for fr-FR from foo under newbase'
|
$mydata.string2 | Should -BeExactly 'string2 for fr-FR from foo under newbase'
|
||||||
@ -98,7 +98,7 @@ Describe 'Testing of script internationalization' -Tags "CI" {
|
|||||||
|
|
||||||
It "Import variable that doesn't exist" {
|
It "Import variable that doesn't exist" {
|
||||||
|
|
||||||
import-localizedData mydata2
|
Import-LocalizedData mydata2
|
||||||
|
|
||||||
$mydata2.string1 | Should -BeExactly 'string1 for en-US'
|
$mydata2.string1 | Should -BeExactly 'string1 for en-US'
|
||||||
$mydata2.string2 | Should -BeExactly 'string2 for en-US'
|
$mydata2.string2 | Should -BeExactly 'string2 for en-US'
|
||||||
@ -109,7 +109,7 @@ Describe 'Testing of script internationalization' -Tags "CI" {
|
|||||||
$script:exception = $null
|
$script:exception = $null
|
||||||
& {
|
& {
|
||||||
trap {$script:exception = $_ ; continue }
|
trap {$script:exception = $_ ; continue }
|
||||||
import-localizedData mydata -filename bad
|
Import-LocalizedData mydata -FileName bad
|
||||||
}
|
}
|
||||||
|
|
||||||
$script:exception.exception | Should -Not -BeNullOrEmpty
|
$script:exception.exception | Should -Not -BeNullOrEmpty
|
||||||
@ -118,7 +118,7 @@ Describe 'Testing of script internationalization' -Tags "CI" {
|
|||||||
|
|
||||||
It 'Import if psd1 file is done correctly' {
|
It 'Import if psd1 file is done correctly' {
|
||||||
|
|
||||||
import-localizedData mydata -filename if
|
Import-LocalizedData mydata -FileName if
|
||||||
|
|
||||||
if ($PSCulture -eq 'en-US')
|
if ($PSCulture -eq 'en-US')
|
||||||
{
|
{
|
||||||
@ -143,13 +143,13 @@ Describe 'Testing of script internationalization' -Tags "CI" {
|
|||||||
$script:exception = $null
|
$script:exception = $null
|
||||||
& {
|
& {
|
||||||
trap {$script:exception = $_.Exception ; continue }
|
trap {$script:exception = $_.Exception ; continue }
|
||||||
invoke-expression $cmd
|
Invoke-Expression $cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
$exception | Should -Match $Expected
|
$exception | Should -Match $Expected
|
||||||
}
|
}
|
||||||
|
|
||||||
it 'Check alternate syntax that also supports complex variable names' {
|
It 'Check alternate syntax that also supports complex variable names' {
|
||||||
|
|
||||||
& {
|
& {
|
||||||
$script:mydata = data { 123 }
|
$script:mydata = data { 123 }
|
||||||
@ -159,22 +159,22 @@ Describe 'Testing of script internationalization' -Tags "CI" {
|
|||||||
$mydata = data { 456 }
|
$mydata = data { 456 }
|
||||||
& {
|
& {
|
||||||
# This import should not clobber the one at script scope
|
# This import should not clobber the one at script scope
|
||||||
import-localizedData mydata -uiculture en-US
|
Import-LocalizedData mydata -UICulture en-US
|
||||||
}
|
}
|
||||||
$mydata | Should -Be 456
|
$mydata | Should -Be 456
|
||||||
|
|
||||||
& {
|
& {
|
||||||
# This import should clobber the one at script scope
|
# This import should clobber the one at script scope
|
||||||
import-localizedData script:mydata -uiculture en-US
|
Import-LocalizedData script:mydata -UICulture en-US
|
||||||
}
|
}
|
||||||
$script:mydata.string1 | Should -BeExactly 'string1 for en-US'
|
$script:mydata.string1 | Should -BeExactly 'string1 for en-US'
|
||||||
}
|
}
|
||||||
|
|
||||||
It 'Check fallback to current directory plus -SupportedCommand parameter is done correctly' {
|
It 'Check fallback to current directory plus -SupportedCommand parameter is done correctly' {
|
||||||
|
|
||||||
new-alias MyConvertFrom-StringData ConvertFrom-StringData
|
New-Alias MyConvertFrom-StringData ConvertFrom-StringData
|
||||||
|
|
||||||
import-localizeddata local:mydata -uiculture fr-ca -filename I18n.Tests_fallback.psd1 -SupportedCommand MyConvertFrom-StringData
|
Import-LocalizedData local:mydata -UICulture fr-ca -FileName I18n.Tests_fallback.psd1 -SupportedCommand MyConvertFrom-StringData
|
||||||
$mydata[0].string1 | Should -BeExactly 'fallback string1 for en-US'
|
$mydata[0].string1 | Should -BeExactly 'fallback string1 for en-US'
|
||||||
$mydata[1] | Should -Be 42
|
$mydata[1] | Should -Be 42
|
||||||
}
|
}
|
||||||
|
@ -130,8 +130,8 @@ Describe 'Line endings' -Tags "CI" {
|
|||||||
# wrap the content in the specified begin and end quoting characters.
|
# wrap the content in the specified begin and end quoting characters.
|
||||||
$content = "$($Begin)$($expected)$($End)"
|
$content = "$($Begin)$($expected)$($End)"
|
||||||
# BUG: Set-Content is failing on linux if the file does not exit.
|
# BUG: Set-Content is failing on linux if the file does not exit.
|
||||||
$null = New-item -path TESTDRIVE:$fileName -force
|
$null = New-Item -Path TESTDRIVE:$fileName -Force
|
||||||
$content | Set-content -NoNewline -Encoding ascii -Path TESTDRIVE:\$fileName
|
$content | Set-Content -NoNewline -Encoding ascii -Path TESTDRIVE:\$fileName
|
||||||
$actual = &( "TESTDRIVE:\$fileName")
|
$actual = &( "TESTDRIVE:\$fileName")
|
||||||
|
|
||||||
# $actual should be the content string ($expected) without the begin and end quoting characters.
|
# $actual should be the content string ($expected) without the begin and end quoting characters.
|
||||||
|
@ -14,7 +14,7 @@ Describe "NativeLinuxCommands" -tags "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
It "Should find Application grep" {
|
It "Should find Application grep" {
|
||||||
(get-command grep).CommandType | Should -Be Application
|
(Get-Command grep).CommandType | Should -Be Application
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Should pipe to grep and get result" {
|
It "Should pipe to grep and get result" {
|
||||||
@ -22,7 +22,7 @@ Describe "NativeLinuxCommands" -tags "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
It "Should find Application touch" {
|
It "Should find Application touch" {
|
||||||
(get-command touch).CommandType | Should -Be Application
|
(Get-Command touch).CommandType | Should -Be Application
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Should not redirect standard input if native command is the first command in pipeline (1)" {
|
It "Should not redirect standard input if native command is the first command in pipeline (1)" {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# Licensed under the MIT License.
|
# Licensed under the MIT License.
|
||||||
Describe 'Test for cmdlet to support Ordered Attribute on hash literal nodes' -Tags "CI" {
|
Describe 'Test for cmdlet to support Ordered Attribute on hash literal nodes' -Tags "CI" {
|
||||||
It 'New-Object - Property Parameter Must take IDictionary' {
|
It 'New-Object - Property Parameter Must take IDictionary' {
|
||||||
$a = new-object psobject -property ([ordered]@{one=1;two=2})
|
$a = New-Object psobject -Property ([ordered]@{one=1;two=2})
|
||||||
$a | Should -Not -BeNullOrEmpty
|
$a | Should -Not -BeNullOrEmpty
|
||||||
$a.one | Should -Be 1
|
$a.one | Should -Be 1
|
||||||
}
|
}
|
||||||
@ -26,7 +26,7 @@ Describe 'Test for cmdlet to support Ordered Attribute on hash literal nodes' -T
|
|||||||
</helpItems>
|
</helpItems>
|
||||||
'@
|
'@
|
||||||
|
|
||||||
{ $script:a = select-xml -content $helpXml -xpath "//command:name" -namespace (
|
{ $script:a = Select-Xml -Content $helpXml -XPath "//command:name" -Namespace (
|
||||||
[ordered]@{command="http://schemas.microsoft.com/maml/dev/command/2004/10";
|
[ordered]@{command="http://schemas.microsoft.com/maml/dev/command/2004/10";
|
||||||
maml="http://schemas.microsoft.com/maml/2004/10";
|
maml="http://schemas.microsoft.com/maml/2004/10";
|
||||||
dev="http://schemas.microsoft.com/maml/dev/2004/10"}) } | Should -Not -Throw
|
dev="http://schemas.microsoft.com/maml/dev/2004/10"}) } | Should -Not -Throw
|
||||||
@ -64,7 +64,7 @@ Describe 'Test for cmdlet to support Ordered Attribute on hash literal nodes' -T
|
|||||||
|
|
||||||
$script:a = $null
|
$script:a = $null
|
||||||
|
|
||||||
{$script:a = Get-ChildItem | select-object -property Name, (
|
{$script:a = Get-ChildItem | Select-Object -Property Name, (
|
||||||
[ordered]@{Name="IsDirectory";
|
[ordered]@{Name="IsDirectory";
|
||||||
Expression ={$_.PSIsContainer}})} | Should -Not -Throw
|
Expression ={$_.PSIsContainer}})} | Should -Not -Throw
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ Describe "Tests OutVariable only" -Tags "CI" {
|
|||||||
param()
|
param()
|
||||||
|
|
||||||
"bar"
|
"bar"
|
||||||
get-foo1 -outVariable script:a
|
get-foo1 -OutVariable script:a
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ Describe "Tests OutVariable only" -Tags "CI" {
|
|||||||
|
|
||||||
It 'Nested OutVariable' {
|
It 'Nested OutVariable' {
|
||||||
|
|
||||||
get-bar -outVariable b > $null
|
get-bar -OutVariable b > $null
|
||||||
$script:a | Should -BeExactly 'foo'
|
$script:a | Should -BeExactly 'foo'
|
||||||
$b | Should -BeExactly @("bar", "foo")
|
$b | Should -BeExactly @("bar", "foo")
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ Describe "Test ErrorVariable only" -Tags "CI" {
|
|||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param()
|
param()
|
||||||
|
|
||||||
write-error "foo"
|
Write-Error "foo"
|
||||||
}
|
}
|
||||||
|
|
||||||
function get-foo2
|
function get-foo2
|
||||||
@ -100,8 +100,8 @@ Describe "Test ErrorVariable only" -Tags "CI" {
|
|||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param()
|
param()
|
||||||
|
|
||||||
write-error "bar"
|
Write-Error "bar"
|
||||||
get-foo1 -errorVariable script:a
|
get-foo1 -ErrorVariable script:a
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,10 +141,10 @@ Describe "Test ErrorVariable only" -Tags "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
It 'Appending ErrorVariable Case 2: $PSCmdlet.writeerror' {
|
It 'Appending ErrorVariable Case 2: $PSCmdlet.writeerror' {
|
||||||
write-error "foo" -errorVariable script:foo 2> $null
|
Write-Error "foo" -ErrorVariable script:foo 2> $null
|
||||||
$a = 'a','b'
|
$a = 'a','b'
|
||||||
|
|
||||||
get-foo2 -errorVariable +a 2> $null
|
get-foo2 -ErrorVariable +a 2> $null
|
||||||
|
|
||||||
$a.count | Should -Be 3
|
$a.count | Should -Be 3
|
||||||
$a| ForEach-Object {$_.ToString()} | Should -BeExactly @('a', 'b', 'foo')
|
$a| ForEach-Object {$_.ToString()} | Should -BeExactly @('a', 'b', 'foo')
|
||||||
@ -152,7 +152,7 @@ Describe "Test ErrorVariable only" -Tags "CI" {
|
|||||||
|
|
||||||
It 'Nested ErrorVariable' {
|
It 'Nested ErrorVariable' {
|
||||||
|
|
||||||
get-bar -errorVariable b 2> $null
|
get-bar -ErrorVariable b 2> $null
|
||||||
|
|
||||||
$script:a | Should -BeExactly 'foo'
|
$script:a | Should -BeExactly 'foo'
|
||||||
$b | Should -BeExactly @("bar","foo")
|
$b | Should -BeExactly @("bar","foo")
|
||||||
@ -160,7 +160,7 @@ Describe "Test ErrorVariable only" -Tags "CI" {
|
|||||||
|
|
||||||
It 'Nested ErrorVariable with redirection' {
|
It 'Nested ErrorVariable with redirection' {
|
||||||
|
|
||||||
get-bar -errorVariable b 2>&1 > $null
|
get-bar -ErrorVariable b 2>&1 > $null
|
||||||
|
|
||||||
$script:a | Should -BeExactly 'foo'
|
$script:a | Should -BeExactly 'foo'
|
||||||
$b | Should -BeExactly @("bar", "foo")
|
$b | Should -BeExactly @("bar", "foo")
|
||||||
@ -176,8 +176,8 @@ Describe "Update both OutVariable and ErrorVariable" -Tags "CI" {
|
|||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param()
|
param()
|
||||||
|
|
||||||
write-output "foo-output"
|
Write-Output "foo-output"
|
||||||
write-error "foo-error"
|
Write-Error "foo-error"
|
||||||
}
|
}
|
||||||
|
|
||||||
function get-foo1
|
function get-foo1
|
||||||
@ -185,7 +185,7 @@ Describe "Update both OutVariable and ErrorVariable" -Tags "CI" {
|
|||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param()
|
param()
|
||||||
|
|
||||||
write-error "foo"
|
Write-Error "foo"
|
||||||
}
|
}
|
||||||
|
|
||||||
function get-foo2
|
function get-foo2
|
||||||
@ -201,8 +201,8 @@ Describe "Update both OutVariable and ErrorVariable" -Tags "CI" {
|
|||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param()
|
param()
|
||||||
|
|
||||||
write-error "bar"
|
Write-Error "bar"
|
||||||
get-foo1 -errorVariable script:a
|
get-foo1 -ErrorVariable script:a
|
||||||
}
|
}
|
||||||
|
|
||||||
function get-foo3
|
function get-foo3
|
||||||
@ -211,8 +211,8 @@ Describe "Update both OutVariable and ErrorVariable" -Tags "CI" {
|
|||||||
param()
|
param()
|
||||||
|
|
||||||
"foo-output-0"
|
"foo-output-0"
|
||||||
write-output "foo-output-1"
|
Write-Output "foo-output-1"
|
||||||
write-error "foo-error"
|
Write-Error "foo-error"
|
||||||
}
|
}
|
||||||
|
|
||||||
function get-bar2
|
function get-bar2
|
||||||
@ -221,15 +221,15 @@ Describe "Update both OutVariable and ErrorVariable" -Tags "CI" {
|
|||||||
param()
|
param()
|
||||||
|
|
||||||
"bar-output-0"
|
"bar-output-0"
|
||||||
write-output "bar-output-1"
|
Write-Output "bar-output-1"
|
||||||
write-error "bar-error"
|
Write-Error "bar-error"
|
||||||
get-foo3 -OutVariable script:foo_out -errorVariable script:foo_err
|
get-foo3 -OutVariable script:foo_out -ErrorVariable script:foo_err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
It 'Update OutVariable and ErrorVariable' {
|
It 'Update OutVariable and ErrorVariable' {
|
||||||
|
|
||||||
get-foo3 -OutVariable out -errorVariable err 2> $null > $null
|
get-foo3 -OutVariable out -ErrorVariable err 2> $null > $null
|
||||||
|
|
||||||
$out | Should -BeExactly @("foo-output-0", "foo-output-1")
|
$out | Should -BeExactly @("foo-output-0", "foo-output-1")
|
||||||
$err | Should -BeExactly "foo-error"
|
$err | Should -BeExactly "foo-error"
|
||||||
@ -237,7 +237,7 @@ Describe "Update both OutVariable and ErrorVariable" -Tags "CI" {
|
|||||||
|
|
||||||
It 'Update OutVariable and ErrorVariable' {
|
It 'Update OutVariable and ErrorVariable' {
|
||||||
|
|
||||||
get-bar2 -OutVariable script:bar_out -errorVariable script:bar_err 2> $null > $null
|
get-bar2 -OutVariable script:bar_out -ErrorVariable script:bar_err 2> $null > $null
|
||||||
|
|
||||||
$foo_out | Should -BeExactly @("foo-output-0", "foo-output-1")
|
$foo_out | Should -BeExactly @("foo-output-0", "foo-output-1")
|
||||||
$foo_err | Should -BeExactly 'foo-error'
|
$foo_err | Should -BeExactly 'foo-error'
|
||||||
@ -252,7 +252,7 @@ Describe "Update both OutVariable and ErrorVariable" -Tags "CI" {
|
|||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param()
|
param()
|
||||||
|
|
||||||
write-error "foo-error"
|
Write-Error "foo-error"
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -262,7 +262,7 @@ Describe "Update both OutVariable and ErrorVariable" -Tags "CI" {
|
|||||||
{}
|
{}
|
||||||
}
|
}
|
||||||
|
|
||||||
get-foo4 -errorVariable err 2> $null
|
get-foo4 -ErrorVariable err 2> $null
|
||||||
|
|
||||||
$err | Should -BeExactly @("foo-error", "foo-exception")
|
$err | Should -BeExactly @("foo-error", "foo-exception")
|
||||||
}
|
}
|
||||||
@ -275,8 +275,8 @@ Describe "Update both OutVariable and ErrorVariable" -Tags "CI" {
|
|||||||
|
|
||||||
process
|
process
|
||||||
{
|
{
|
||||||
write-output $foo
|
Write-Output $foo
|
||||||
write-error $foo
|
Write-Error $foo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,7 +293,7 @@ Describe "Update both OutVariable and ErrorVariable" -Tags "CI" {
|
|||||||
Context 'Error variable in multi-command pipeline (with native cmdlet)' {
|
Context 'Error variable in multi-command pipeline (with native cmdlet)' {
|
||||||
|
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
(get-foo -ErrorVariable foo_err | get-item -ErrorVariable get_item_err ) 2>&1 > $null
|
(get-foo -ErrorVariable foo_err | Get-Item -ErrorVariable get_item_err ) 2>&1 > $null
|
||||||
}
|
}
|
||||||
|
|
||||||
It '$foo_err should be "foo-error"' {
|
It '$foo_err should be "foo-error"' {
|
||||||
@ -314,12 +314,12 @@ Describe "Update both OutVariable and ErrorVariable" -Tags "CI" {
|
|||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param([Parameter(ValueFromPipeline = $true)][string] $i)
|
param([Parameter(ValueFromPipeline = $true)][string] $i)
|
||||||
|
|
||||||
write-error 'bar-error'
|
Write-Error 'bar-error'
|
||||||
write-output 'bar-output'
|
Write-Output 'bar-output'
|
||||||
get-foo
|
get-foo
|
||||||
}
|
}
|
||||||
|
|
||||||
(get-foo -errorVariable foo_err | get-bar3 -errorVariable bar_err) 2>&1 > $null
|
(get-foo -ErrorVariable foo_err | get-bar3 -ErrorVariable bar_err) 2>&1 > $null
|
||||||
|
|
||||||
$foo_err | Should -BeExactly 'foo-error'
|
$foo_err | Should -BeExactly 'foo-error'
|
||||||
$bar_err | Should -BeExactly @("bar-error", "foo-error")
|
$bar_err | Should -BeExactly @("bar-error", "foo-error")
|
||||||
@ -332,8 +332,8 @@ Describe "Update both OutVariable and ErrorVariable" -Tags "CI" {
|
|||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param([Parameter(ValueFromPipeline = $true)][string] $i)
|
param([Parameter(ValueFromPipeline = $true)][string] $i)
|
||||||
|
|
||||||
write-error "foo-error"
|
Write-Error "foo-error"
|
||||||
write-output $i
|
Write-Output $i
|
||||||
}
|
}
|
||||||
|
|
||||||
function get-bar4
|
function get-bar4
|
||||||
@ -341,11 +341,11 @@ Describe "Update both OutVariable and ErrorVariable" -Tags "CI" {
|
|||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param([Parameter(ValueFromPipeline = $true)][string] $i)
|
param([Parameter(ValueFromPipeline = $true)][string] $i)
|
||||||
|
|
||||||
write-error "bar-error"
|
Write-Error "bar-error"
|
||||||
get-foo6 "foo-output" -errorVariable script:foo_err1 | get-foo6 -errorVariable script:foo_err2
|
get-foo6 "foo-output" -ErrorVariable script:foo_err1 | get-foo6 -ErrorVariable script:foo_err2
|
||||||
}
|
}
|
||||||
|
|
||||||
get-bar4 -errorVariable script:bar_err 2>&1 > $null
|
get-bar4 -ErrorVariable script:bar_err 2>&1 > $null
|
||||||
|
|
||||||
$script:foo_err1 | Should -BeExactly "foo-error"
|
$script:foo_err1 | Should -BeExactly "foo-error"
|
||||||
$script:foo_err2 | Should -BeExactly "foo-error"
|
$script:foo_err2 | Should -BeExactly "foo-error"
|
||||||
@ -359,7 +359,7 @@ Describe "Update both OutVariable and ErrorVariable" -Tags "CI" {
|
|||||||
param([Parameter(ValueFromPipeline = $true)][string] $output)
|
param([Parameter(ValueFromPipeline = $true)][string] $output)
|
||||||
|
|
||||||
$output
|
$output
|
||||||
write-error "foo-error"
|
Write-Error "foo-error"
|
||||||
}
|
}
|
||||||
|
|
||||||
function get-bar5
|
function get-bar5
|
||||||
@ -368,7 +368,7 @@ Describe "Update both OutVariable and ErrorVariable" -Tags "CI" {
|
|||||||
param()
|
param()
|
||||||
|
|
||||||
"bar-output"
|
"bar-output"
|
||||||
write-error "bar-error"
|
Write-Error "bar-error"
|
||||||
get-foo7 "foo-output" -ErrorVariable script:foo_err1 -ov script:foo_out1 | get-foo7 -ErrorVariable script:foo_err2 -ov script:foo_out2
|
get-foo7 "foo-output" -ErrorVariable script:foo_err1 -ov script:foo_out1 | get-foo7 -ErrorVariable script:foo_err2 -ov script:foo_out2
|
||||||
get-foo7 "foo-output" -ErrorVariable script:foo_err3 -ov script:foo_out3 | get-foo7 -ErrorVariable script:foo_err4 -ov script:foo_out4
|
get-foo7 "foo-output" -ErrorVariable script:foo_err3 -ov script:foo_out3 | get-foo7 -ErrorVariable script:foo_err4 -ov script:foo_out4
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ Describe "Tests for parameter binding" -Tags "CI" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$b = 1..10 | select-object @{name='foo'; expression={$_ * 10}} | get-foo
|
$b = 1..10 | Select-Object @{name='foo'; expression={$_ * 10}} | get-foo
|
||||||
$b -join ',' | Should -BeExactly '10,20,30,40,50,60,70,80,90,100'
|
$b -join ',' | Should -BeExactly '10,20,30,40,50,60,70,80,90,100'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -451,12 +451,12 @@ Describe "Tests for parameter binding" -Tags "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#known issue 2069
|
#known issue 2069
|
||||||
It 'Some conversions should be attempted before trying to encode a collection' -skip:$IsCoreCLR {
|
It 'Some conversions should be attempted before trying to encode a collection' -Skip:$IsCoreCLR {
|
||||||
try {
|
try {
|
||||||
$null = [Test.Language.ParameterBinding.MyClass]
|
$null = [Test.Language.ParameterBinding.MyClass]
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
add-type -PassThru -TypeDefinition @'
|
Add-Type -PassThru -TypeDefinition @'
|
||||||
using System.Management.Automation;
|
using System.Management.Automation;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
@ -486,7 +486,7 @@ Describe "Tests for parameter binding" -Tags "CI" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'@ | ForEach-Object {$_.assembly} | Import-module
|
'@ | ForEach-Object {$_.assembly} | Import-Module
|
||||||
}
|
}
|
||||||
|
|
||||||
Get-TestCmdlet -MyParameter @{ a = 42 } | Should -BeExactly 'hashtable'
|
Get-TestCmdlet -MyParameter @{ a = 42 } | Should -BeExactly 'hashtable'
|
||||||
|
@ -134,44 +134,44 @@ Describe 'get-help HelpFunc1' -Tags "Feature" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Context 'Get-Help helpFunc1' {
|
Context 'Get-Help helpFunc1' {
|
||||||
$x = get-help helpFunc1
|
$x = Get-Help helpFunc1
|
||||||
TestHelpFunc1 $x
|
TestHelpFunc1 $x
|
||||||
}
|
}
|
||||||
|
|
||||||
Context 'Get-Help dynamicHelpFunc1' {
|
Context 'Get-Help dynamicHelpFunc1' {
|
||||||
$x = get-help dynamicHelpFunc1
|
$x = Get-Help dynamicHelpFunc1
|
||||||
TestHelpFunc1 $x
|
TestHelpFunc1 $x
|
||||||
}
|
}
|
||||||
|
|
||||||
Context 'get-help helpFunc1 -component blah' {
|
Context 'get-help helpFunc1 -component blah' {
|
||||||
$x = get-help helpFunc1 -component blah -ErrorAction SilentlyContinue -ErrorVariable e
|
$x = Get-Help helpFunc1 -Component blah -ErrorAction SilentlyContinue -ErrorVariable e
|
||||||
TestHelpError $x $e 'HelpNotFound,Microsoft.PowerShell.Commands.GetHelpCommand'
|
TestHelpError $x $e 'HelpNotFound,Microsoft.PowerShell.Commands.GetHelpCommand'
|
||||||
}
|
}
|
||||||
|
|
||||||
Context 'get-help helpFunc1 -component Something' {
|
Context 'get-help helpFunc1 -component Something' {
|
||||||
$x = get-help helpFunc1 -component Something -ErrorAction SilentlyContinue -ErrorVariable e
|
$x = Get-Help helpFunc1 -Component Something -ErrorAction SilentlyContinue -ErrorVariable e
|
||||||
TestHelpFunc1 $x
|
TestHelpFunc1 $x
|
||||||
It '$e should be empty' { $e.Count | Should -Be 0 }
|
It '$e should be empty' { $e.Count | Should -Be 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
Context 'get-help helpFunc1 -role blah' {
|
Context 'get-help helpFunc1 -role blah' {
|
||||||
$x = get-help helpFunc1 -component blah -ErrorAction SilentlyContinue -ErrorVariable e
|
$x = Get-Help helpFunc1 -Component blah -ErrorAction SilentlyContinue -ErrorVariable e
|
||||||
TestHelpError $x $e 'HelpNotFound,Microsoft.PowerShell.Commands.GetHelpCommand'
|
TestHelpError $x $e 'HelpNotFound,Microsoft.PowerShell.Commands.GetHelpCommand'
|
||||||
}
|
}
|
||||||
|
|
||||||
Context 'get-help helpFunc1 -role CrazyUser' {
|
Context 'get-help helpFunc1 -role CrazyUser' {
|
||||||
$x = get-help helpFunc1 -role CrazyUser -ErrorAction SilentlyContinue -ErrorVariable e
|
$x = Get-Help helpFunc1 -Role CrazyUser -ErrorAction SilentlyContinue -ErrorVariable e
|
||||||
TestHelpFunc1 $x
|
TestHelpFunc1 $x
|
||||||
It '$e should be empty' { $e.Count | Should -Be 0 }
|
It '$e should be empty' { $e.Count | Should -Be 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
Context '$x = get-help helpFunc1 -functionality blah' {
|
Context '$x = get-help helpFunc1 -functionality blah' {
|
||||||
$x = get-help helpFunc1 -functionality blah -ErrorAction SilentlyContinue -ErrorVariable e
|
$x = Get-Help helpFunc1 -Functionality blah -ErrorAction SilentlyContinue -ErrorVariable e
|
||||||
TestHelpError $x $e 'HelpNotFound,Microsoft.PowerShell.Commands.GetHelpCommand'
|
TestHelpError $x $e 'HelpNotFound,Microsoft.PowerShell.Commands.GetHelpCommand'
|
||||||
}
|
}
|
||||||
|
|
||||||
Context '$x = get-help helpFunc1 -functionality Useless' {
|
Context '$x = get-help helpFunc1 -functionality Useless' {
|
||||||
$x = get-help helpFunc1 -functionality Useless -ErrorAction SilentlyContinue -ErrorVariable e
|
$x = Get-Help helpFunc1 -Functionality Useless -ErrorAction SilentlyContinue -ErrorVariable e
|
||||||
TestHelpFunc1 $x
|
TestHelpFunc1 $x
|
||||||
It '$e should be empty' { $e.Count | Should -Be 0 }
|
It '$e should be empty' { $e.Count | Should -Be 0 }
|
||||||
}
|
}
|
||||||
@ -187,7 +187,7 @@ Describe 'get-help file' -Tags "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AfterAll {
|
AfterAll {
|
||||||
remove-item $tmpfile -Force -ErrorAction silentlycontinue
|
Remove-Item $tmpfile -Force -ErrorAction silentlycontinue
|
||||||
}
|
}
|
||||||
|
|
||||||
Context 'get-help file1' {
|
Context 'get-help file1' {
|
||||||
@ -202,7 +202,7 @@ Describe 'get-help file' -Tags "CI" {
|
|||||||
get-help foo
|
get-help foo
|
||||||
'@ > $tmpfile
|
'@ > $tmpfile
|
||||||
|
|
||||||
$x = get-help $tmpfile
|
$x = Get-Help $tmpfile
|
||||||
It '$x should not be $null' { $x | Should -Not -BeNullOrEmpty }
|
It '$x should not be $null' { $x | Should -Not -BeNullOrEmpty }
|
||||||
$x = & $tmpfile
|
$x = & $tmpfile
|
||||||
It '$x.Synopsis' { $x.Synopsis | Should -BeExactly 'Function help, not script help' }
|
It '$x.Synopsis' { $x.Synopsis | Should -BeExactly 'Function help, not script help' }
|
||||||
@ -223,7 +223,7 @@ Describe 'get-help file' -Tags "CI" {
|
|||||||
get-help foo
|
get-help foo
|
||||||
'@ > $tmpfile
|
'@ > $tmpfile
|
||||||
|
|
||||||
$x = get-help $tmpfile
|
$x = Get-Help $tmpfile
|
||||||
It '$x.Synopsis' { $x.Synopsis | Should -BeExactly 'Script help, not function help' }
|
It '$x.Synopsis' { $x.Synopsis | Should -BeExactly 'Script help, not function help' }
|
||||||
$x = & $tmpfile
|
$x = & $tmpfile
|
||||||
It '$x should not be $null' { $x | Should -Not -BeNullOrEmpty }
|
It '$x should not be $null' { $x | Should -Not -BeNullOrEmpty }
|
||||||
@ -240,7 +240,7 @@ Describe 'get-help other tests' -Tags "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AfterAll {
|
AfterAll {
|
||||||
remove-item $tempFile -Force -ErrorAction silentlycontinue
|
Remove-Item $tempFile -Force -ErrorAction silentlycontinue
|
||||||
}
|
}
|
||||||
|
|
||||||
Context 'get-help missingHelp' {
|
Context 'get-help missingHelp' {
|
||||||
@ -253,7 +253,7 @@ Describe 'get-help other tests' -Tags "CI" {
|
|||||||
|
|
||||||
|
|
||||||
function missingHelp { param($abc) }
|
function missingHelp { param($abc) }
|
||||||
$x = get-help missingHelp
|
$x = Get-Help missingHelp
|
||||||
It '$x should not be $null' { $x | Should -Not -BeNullOrEmpty }
|
It '$x should not be $null' { $x | Should -Not -BeNullOrEmpty }
|
||||||
It '$x.Synopsis' { $x.Synopsis.Trim() | Should -BeExactly 'missingHelp [[-abc] <Object>]' }
|
It '$x.Synopsis' { $x.Synopsis.Trim() | Should -BeExactly 'missingHelp [[-abc] <Object>]' }
|
||||||
}
|
}
|
||||||
@ -267,7 +267,7 @@ Describe 'get-help other tests' -Tags "CI" {
|
|||||||
|
|
||||||
function helpFunc2 { param($abc) }
|
function helpFunc2 { param($abc) }
|
||||||
|
|
||||||
$x = get-help helpFunc2
|
$x = Get-Help helpFunc2
|
||||||
It '$x should not be $null' { $x | Should -Not -BeNullOrEmpty }
|
It '$x should not be $null' { $x | Should -Not -BeNullOrEmpty }
|
||||||
It '$x.Synopsis' { $x.Synopsis.Trim() | Should -BeExactly 'This help block goes on helpFunc2' }
|
It '$x.Synopsis' { $x.Synopsis.Trim() | Should -BeExactly 'This help block goes on helpFunc2' }
|
||||||
}
|
}
|
||||||
@ -289,7 +289,7 @@ Describe 'get-help other tests' -Tags "CI" {
|
|||||||
"@
|
"@
|
||||||
|
|
||||||
Set-Content $tempFile $script
|
Set-Content $tempFile $script
|
||||||
$x = get-help $tempFile
|
$x = Get-Help $tempFile
|
||||||
It '$x.Synopsis' { $x.Synopsis | Should -BeExactly "This is script help" }
|
It '$x.Synopsis' { $x.Synopsis | Should -BeExactly "This is script help" }
|
||||||
|
|
||||||
$x = & $tempFile
|
$x = & $tempFile
|
||||||
@ -313,7 +313,7 @@ Describe 'get-help other tests' -Tags "CI" {
|
|||||||
"@
|
"@
|
||||||
|
|
||||||
Set-Content $tempFile $script
|
Set-Content $tempFile $script
|
||||||
$x = get-help $tempFile
|
$x = Get-Help $tempFile
|
||||||
It $x.Synopsis { $x.Synopsis | Should -BeExactly "This is script help" }
|
It $x.Synopsis { $x.Synopsis | Should -BeExactly "This is script help" }
|
||||||
|
|
||||||
$x = & $tempFile
|
$x = & $tempFile
|
||||||
@ -348,7 +348,7 @@ Describe 'get-help other tests' -Tags "CI" {
|
|||||||
'@
|
'@
|
||||||
|
|
||||||
Set-Content $tempFile $script
|
Set-Content $tempFile $script
|
||||||
$x = get-help $tempFile
|
$x = Get-Help $tempFile
|
||||||
|
|
||||||
It '$x.Synopsis' { $x.Synopsis | Should -BeExactly "Changes Admin passwords across all KDE servers." }
|
It '$x.Synopsis' { $x.Synopsis | Should -BeExactly "Changes Admin passwords across all KDE servers." }
|
||||||
It '$x.parameters.parameter[0].required' { $x.parameters.parameter[0].required | Should -BeTrue}
|
It '$x.parameters.parameter[0].required' { $x.parameters.parameter[0].required | Should -BeTrue}
|
||||||
@ -393,7 +393,7 @@ Describe 'get-help other tests' -Tags "CI" {
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
$x = get-help helpFunc4
|
$x = Get-Help helpFunc4
|
||||||
$x.Synopsis | Should -BeExactly ""
|
$x.Synopsis | Should -BeExactly ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,7 +403,7 @@ Describe 'get-help other tests' -Tags "CI" {
|
|||||||
{
|
{
|
||||||
# .EXTERNALHELP scriptHelp.Tests.xml
|
# .EXTERNALHELP scriptHelp.Tests.xml
|
||||||
}
|
}
|
||||||
$x = get-help helpFunc5
|
$x = Get-Help helpFunc5
|
||||||
It '$x should not be $null' { $x | Should -Not -BeNullOrEmpty }
|
It '$x should not be $null' { $x | Should -Not -BeNullOrEmpty }
|
||||||
It '$x.Synopsis' { $x.Synopsis | Should -BeExactly "A useless function, really." }
|
It '$x.Synopsis' { $x.Synopsis | Should -BeExactly "A useless function, really." }
|
||||||
}
|
}
|
||||||
@ -415,7 +415,7 @@ Describe 'get-help other tests' -Tags "CI" {
|
|||||||
}
|
}
|
||||||
if ($PSUICulture -ieq "en-us")
|
if ($PSUICulture -ieq "en-us")
|
||||||
{
|
{
|
||||||
$x = get-help helpFunc6
|
$x = Get-Help helpFunc6
|
||||||
It '$x should not be $null' { $x | Should -Not -BeNullOrEmpty }
|
It '$x should not be $null' { $x | Should -Not -BeNullOrEmpty }
|
||||||
It '$x.Synopsis' { $x.Synopsis | Should -BeExactly "Useless. Really, trust me on this one." }
|
It '$x.Synopsis' { $x.Synopsis | Should -BeExactly "Useless. Really, trust me on this one." }
|
||||||
}
|
}
|
||||||
@ -428,7 +428,7 @@ Describe 'get-help other tests' -Tags "CI" {
|
|||||||
}
|
}
|
||||||
if ($PSUICulture -ieq "en-us")
|
if ($PSUICulture -ieq "en-us")
|
||||||
{
|
{
|
||||||
$x = get-help helpFunc6
|
$x = Get-Help helpFunc6
|
||||||
It '$x should not be $null' { $x | Should -Not -BeNullOrEmpty }
|
It '$x should not be $null' { $x | Should -Not -BeNullOrEmpty }
|
||||||
It '$x.Synopsis' { $x.Synopsis | Should -BeExactly "Useless in newbase. Really, trust me on this one." }
|
It '$x.Synopsis' { $x.Synopsis | Should -BeExactly "Useless in newbase. Really, trust me on this one." }
|
||||||
}
|
}
|
||||||
@ -446,9 +446,9 @@ Describe 'get-help other tests' -Tags "CI" {
|
|||||||
It '$x.Category' { $x.Category | Should -BeExactly 'Cmdlet' }
|
It '$x.Category' { $x.Category | Should -BeExactly 'Cmdlet' }
|
||||||
|
|
||||||
# Make sure help is a function, or the test would fail
|
# Make sure help is a function, or the test would fail
|
||||||
if ($null -ne (get-command -type Function help))
|
if ($null -ne (Get-Command -type Function help))
|
||||||
{
|
{
|
||||||
if ((get-content function:help) -Match "FORWARDHELP")
|
if ((Get-Content function:help) -Match "FORWARDHELP")
|
||||||
{
|
{
|
||||||
$x = Get-Help help
|
$x = Get-Help help
|
||||||
It '$x.Name' { $x.Name | Should -BeExactly 'Get-Help' }
|
It '$x.Name' { $x.Name | Should -BeExactly 'Get-Help' }
|
||||||
@ -466,7 +466,7 @@ Describe 'get-help other tests' -Tags "CI" {
|
|||||||
function helpFunc8
|
function helpFunc8
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
get-help helpFunc8
|
Get-Help helpFunc8
|
||||||
}
|
}
|
||||||
|
|
||||||
$x = Get-Help func8
|
$x = Get-Help func8
|
||||||
@ -486,7 +486,7 @@ Describe 'get-help other tests' -Tags "CI" {
|
|||||||
function func9
|
function func9
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
get-help func9
|
Get-Help func9
|
||||||
}
|
}
|
||||||
$x = Get-Help helpFunc9
|
$x = Get-Help helpFunc9
|
||||||
It 'help is on the outer functon' { $x.Synopsis | Should -BeExactly 'Help on helpFunc9, not func9' }
|
It 'help is on the outer functon' { $x.Synopsis | Should -BeExactly 'Help on helpFunc9, not func9' }
|
||||||
@ -503,7 +503,7 @@ Describe 'get-help other tests' -Tags "CI" {
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
$x = get-help helpFunc10
|
$x = Get-Help helpFunc10
|
||||||
$x.Synopsis | Should -BeExactly 'Help on helpFunc10'
|
$x.Synopsis | Should -BeExactly 'Help on helpFunc10'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,7 +539,7 @@ Describe 'get-help other tests' -Tags "CI" {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
$x = get-help helpFunc11 -det
|
$x = Get-Help helpFunc11 -det
|
||||||
$x.Parameters.parameter | ForEach-Object {
|
$x.Parameters.parameter | ForEach-Object {
|
||||||
It '$_.description' { $_.description[0].text | Should -Match "^$($_.Name)\s+help" }
|
It '$_.description' { $_.description[0].text | Should -Match "^$($_.Name)\s+help" }
|
||||||
}
|
}
|
||||||
@ -573,8 +573,8 @@ Describe 'get-help other tests' -Tags "CI" {
|
|||||||
Adds .txt to bar
|
Adds .txt to bar
|
||||||
#>
|
#>
|
||||||
}
|
}
|
||||||
$x = get-help helpFunc12
|
$x = Get-Help helpFunc12
|
||||||
It '$x.syntax' { ($x.syntax | Out-String -width 250) | Should -Match "helpFunc12 \[-Name] <String> \[\[-Extension] <String>] \[\[-NoType] <Object>] \[-ASwitch] \[\[-AnEnum] \{Alias.*All}] \[<CommonParameters>]" }
|
It '$x.syntax' { ($x.syntax | Out-String -Width 250) | Should -Match "helpFunc12 \[-Name] <String> \[\[-Extension] <String>] \[\[-NoType] <Object>] \[-ASwitch] \[\[-AnEnum] \{Alias.*All}] \[<CommonParameters>]" }
|
||||||
It '$x.syntax.syntaxItem.parameter[3].position' { $x.syntax.syntaxItem.parameter[3].position | Should -BeExactly 'named' }
|
It '$x.syntax.syntaxItem.parameter[3].position' { $x.syntax.syntaxItem.parameter[3].position | Should -BeExactly 'named' }
|
||||||
It '$x.syntax.syntaxItem.parameter[3].parameterValue' { $x.syntax.syntaxItem.parameter[3].parameterValue | Should -BeNullOrEmpty }
|
It '$x.syntax.syntaxItem.parameter[3].parameterValue' { $x.syntax.syntaxItem.parameter[3].parameterValue | Should -BeNullOrEmpty }
|
||||||
It '$x.parameters.parameter[3].parameterValue' { $x.parameters.parameter[3].parameterValue | Should -Not -BeNullOrEmpty }
|
It '$x.parameters.parameter[3].parameterValue' { $x.parameters.parameter[3].parameterValue | Should -Not -BeNullOrEmpty }
|
||||||
@ -607,7 +607,7 @@ Describe 'get-help other tests' -Tags "CI" {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
$x = get-help helpFunc13
|
$x = Get-Help helpFunc13
|
||||||
|
|
||||||
It '$x.Parameters.parameter[0].globbing' { $x.Parameters.parameter[0].globbing | Should -BeExactly 'true' }
|
It '$x.Parameters.parameter[0].globbing' { $x.Parameters.parameter[0].globbing | Should -BeExactly 'true' }
|
||||||
It '$x.Parameters.parameter[1].defaultValue' { $x.Parameters.parameter[1].defaultValue | Should -BeExactly '42' }
|
It '$x.Parameters.parameter[1].defaultValue' { $x.Parameters.parameter[1].defaultValue | Should -BeExactly '42' }
|
||||||
@ -664,7 +664,7 @@ Describe 'get-help other tests' -Tags "CI" {
|
|||||||
param()
|
param()
|
||||||
}
|
}
|
||||||
|
|
||||||
$x = get-help foo
|
$x = Get-Help foo
|
||||||
It '$x.examples.example[0].introduction[0].text' { $x.examples.example[0].introduction[0].text | Should -BeExactly "PS > " }
|
It '$x.examples.example[0].introduction[0].text' { $x.examples.example[0].introduction[0].text | Should -BeExactly "PS > " }
|
||||||
It '$x.examples.example[0].code' { $x.examples.example[0].code | Should -BeExactly "`$a = Get-Service`n`$a | group Status" }
|
It '$x.examples.example[0].code' { $x.examples.example[0].code | Should -BeExactly "`$a = Get-Service`n`$a | group Status" }
|
||||||
It '$x.examples.example[0].remarks[0].text' { $x.examples.example[0].remarks[0].text | Should -BeNullOrEmpty }
|
It '$x.examples.example[0].remarks[0].text' { $x.examples.example[0].remarks[0].text | Should -BeNullOrEmpty }
|
||||||
|
@ -346,7 +346,7 @@ Describe "Import-Module from CompatiblePSEditions-checked paths" -Tag "CI" {
|
|||||||
(Invoke-Command -Session $s {Get-Location}).Path | Should -BeExactly $PWD.Path
|
(Invoke-Command -Session $s {Get-Location}).Path | Should -BeExactly $PWD.Path
|
||||||
|
|
||||||
# after WinCompat cleanup local $PWD changes should not cause errors
|
# after WinCompat cleanup local $PWD changes should not cause errors
|
||||||
Remove-module $ModuleName -Force
|
Remove-Module $ModuleName -Force
|
||||||
|
|
||||||
Pop-Location
|
Pop-Location
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ Describe "Enter-PSHostProcess tests" -Tag Feature {
|
|||||||
|
|
||||||
# If opening the runspace fails, then print out the trace with the callstack
|
# If opening the runspace fails, then print out the trace with the callstack
|
||||||
Wait-UntilTrue { $rs.RunspaceStateInfo.State -eq [System.Management.Automation.Runspaces.RunspaceState]::Opened } |
|
Wait-UntilTrue { $rs.RunspaceStateInfo.State -eq [System.Management.Automation.Runspaces.RunspaceState]::Opened } |
|
||||||
Should -BeTrue -Because (get-content $splat.FilePath -Raw)
|
Should -BeTrue -Because (Get-Content $splat.FilePath -Raw)
|
||||||
|
|
||||||
$ps = [powershell]::Create()
|
$ps = [powershell]::Create()
|
||||||
$ps.Runspace = $rs
|
$ps.Runspace = $rs
|
||||||
|
@ -245,7 +245,7 @@ Describe "Get-Command Tests" -Tags "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
It "verify if get the proper dynamic parameter type skipped by issue #1430" -Pending {
|
It "verify if get the proper dynamic parameter type skipped by issue #1430" -Pending {
|
||||||
$results = Get-Command TestGetCommand-DynamicParametersDCR -TestToRun returngenericparameter -parametertype System.Diagnostics.Process
|
$results = Get-Command TestGetCommand-DynamicParametersDCR -TestToRun returngenericparameter -ParameterType System.Diagnostics.Process
|
||||||
VerifyParameterType -cmdlet $results[0] -parameterName "TypedValue" -parameterType System.Diagnostics.Process
|
VerifyParameterType -cmdlet $results[0] -parameterName "TypedValue" -parameterType System.Diagnostics.Process
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ Describe "History cmdlet test cases" -Tags "CI" {
|
|||||||
EndExecutionTime = $end
|
EndExecutionTime = $end
|
||||||
}
|
}
|
||||||
$history | Add-History
|
$history | Add-History
|
||||||
$h = Get-History -count 1
|
$h = Get-History -Count 1
|
||||||
$h.Duration | Should -Be $duration
|
$h.Duration | Should -Be $duration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ Describe "Import-Module with ScriptsToProcess" -Tags "CI" {
|
|||||||
|
|
||||||
AfterEach {
|
AfterEach {
|
||||||
$m = @('module1','module2','script1','script2')
|
$m = @('module1','module2','script1','script2')
|
||||||
remove-module $m -Force -ErrorAction SilentlyContinue
|
Remove-Module $m -Force -ErrorAction SilentlyContinue
|
||||||
Remove-Item out.txt -Force -ErrorAction SilentlyContinue
|
Remove-Item out.txt -Force -ErrorAction SilentlyContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ Describe "Import-Module for Binary Modules" -Tags 'CI' {
|
|||||||
try {
|
try {
|
||||||
$TestModulePath = Join-Path $TESTDRIVE "System.$extension"
|
$TestModulePath = Join-Path $TESTDRIVE "System.$extension"
|
||||||
$job = Start-Job -ScriptBlock {
|
$job = Start-Job -ScriptBlock {
|
||||||
$module = Import-Module $using:TestModulePath -Passthru;
|
$module = Import-Module $using:TestModulePath -PassThru;
|
||||||
$module.ImplementingAssembly.Location;
|
$module.ImplementingAssembly.Location;
|
||||||
Test-BinaryModuleCmdlet1
|
Test-BinaryModuleCmdlet1
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,8 @@ Describe "Job Cmdlet Tests" -Tag "CI" {
|
|||||||
{ Get-Job $j -ErrorAction Stop } | Should -Throw -ErrorId "JobWithSpecifiedNameNotFound,Microsoft.PowerShell.Commands.GetJobCommand"
|
{ Get-Job $j -ErrorAction Stop } | Should -Throw -ErrorId "JobWithSpecifiedNameNotFound,Microsoft.PowerShell.Commands.GetJobCommand"
|
||||||
}
|
}
|
||||||
It "Receive-Job can retrieve job results" {
|
It "Receive-Job can retrieve job results" {
|
||||||
Wait-Job -Timeout 60 -id $j.id | Should -Not -BeNullOrEmpty
|
Wait-Job -Timeout 60 -Id $j.id | Should -Not -BeNullOrEmpty
|
||||||
receive-job -id $j.id | Should -Be 2
|
Receive-Job -Id $j.id | Should -Be 2
|
||||||
}
|
}
|
||||||
It "-RunAs32 not supported from 64-bit pwsh" -Skip:(-not [System.Environment]::Is64BitProcess) {
|
It "-RunAs32 not supported from 64-bit pwsh" -Skip:(-not [System.Environment]::Is64BitProcess) {
|
||||||
{ Start-Job -ScriptBlock {} -RunAs32 } | Should -Throw -ErrorId "RunAs32NotSupported,Microsoft.PowerShell.Commands.StartJobCommand"
|
{ Start-Job -ScriptBlock {} -RunAs32 } | Should -Throw -ErrorId "RunAs32NotSupported,Microsoft.PowerShell.Commands.StartJobCommand"
|
||||||
@ -44,7 +44,7 @@ Describe "Job Cmdlet Tests" -Tag "CI" {
|
|||||||
It "Start-Job accepts arguments" {
|
It "Start-Job accepts arguments" {
|
||||||
$sb = { Write-Output $args[1]; Write-Output $args[0] }
|
$sb = { Write-Output $args[1]; Write-Output $args[0] }
|
||||||
$j = Start-Job -ScriptBlock $sb -ArgumentList "$TestDrive", 42
|
$j = Start-Job -ScriptBlock $sb -ArgumentList "$TestDrive", 42
|
||||||
Wait-job -Timeout (5 * 60) $j | Should -Be $j
|
Wait-Job -Timeout (5 * 60) $j | Should -Be $j
|
||||||
$r = Receive-Job $j
|
$r = Receive-Job $j
|
||||||
$r -Join "," | Should -Be "42,$TestDrive"
|
$r -Join "," | Should -Be "42,$TestDrive"
|
||||||
}
|
}
|
||||||
@ -150,7 +150,7 @@ Describe "Job Cmdlet Tests" -Tag "CI" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Describe "Debug-job test" -tag "Feature" {
|
Describe "Debug-job test" -Tag "Feature" {
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
$rs = [runspacefactory]::CreateRunspace()
|
$rs = [runspacefactory]::CreateRunspace()
|
||||||
$rs.Open()
|
$rs.Open()
|
||||||
@ -165,7 +165,7 @@ Describe "Debug-job test" -tag "Feature" {
|
|||||||
}
|
}
|
||||||
# we check this via implication.
|
# we check this via implication.
|
||||||
# if we're debugging a job, then the debugger will have a callstack
|
# if we're debugging a job, then the debugger will have a callstack
|
||||||
It "Debug-Job will break into debugger" -pending {
|
It "Debug-Job will break into debugger" -Pending {
|
||||||
$ps.AddScript('$job = start-job { 1..300 | ForEach-Object { Start-Sleep 1 } }').Invoke()
|
$ps.AddScript('$job = start-job { 1..300 | ForEach-Object { Start-Sleep 1 } }').Invoke()
|
||||||
$ps.Commands.Clear()
|
$ps.Commands.Clear()
|
||||||
$ps.Runspace.Debugger.GetCallStack() | Should -BeNullOrEmpty
|
$ps.Runspace.Debugger.GetCallStack() | Should -BeNullOrEmpty
|
||||||
@ -178,7 +178,7 @@ Describe "Debug-job test" -tag "Feature" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Describe "Ampersand background test" -tag "CI","Slow" {
|
Describe "Ampersand background test" -Tag "CI","Slow" {
|
||||||
Context "Simple background job" {
|
Context "Simple background job" {
|
||||||
AfterEach {
|
AfterEach {
|
||||||
Get-Job | Remove-Job -Force
|
Get-Job | Remove-Job -Force
|
||||||
@ -194,7 +194,7 @@ Describe "Ampersand background test" -tag "CI","Slow" {
|
|||||||
}
|
}
|
||||||
It "doesn't cause error when variable is missing" {
|
It "doesn't cause error when variable is missing" {
|
||||||
Remove-Item variable:name -ErrorAction Ignore
|
Remove-Item variable:name -ErrorAction Ignore
|
||||||
$j = write-output "Hi $name" &
|
$j = Write-Output "Hi $name" &
|
||||||
Receive-Job $j -Wait | Should -BeExactly "Hi "
|
Receive-Job $j -Wait | Should -BeExactly "Hi "
|
||||||
}
|
}
|
||||||
It "Copies variables to the child process" {
|
It "Copies variables to the child process" {
|
||||||
@ -215,7 +215,7 @@ Describe "Ampersand background test" -tag "CI","Slow" {
|
|||||||
$PID | Should -Not -BeExactly $cpid
|
$PID | Should -Not -BeExactly $cpid
|
||||||
}
|
}
|
||||||
It "starts in the current directory" {
|
It "starts in the current directory" {
|
||||||
$j = Get-Location | Foreach-Object -MemberName Path &
|
$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" {
|
It "Test that output redirection is done in the background job" {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Copyright (c) Microsoft Corporation.
|
# Copyright (c) Microsoft Corporation.
|
||||||
# Licensed under the MIT License.
|
# Licensed under the MIT License.
|
||||||
Describe "Out-Default Tests" -tag CI {
|
Describe "Out-Default Tests" -Tag CI {
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
# due to https://github.com/PowerShell/PowerShell/issues/3405, `Out-Default -Transcript` emits output to pipeline
|
# due to https://github.com/PowerShell/PowerShell/issues/3405, `Out-Default -Transcript` emits output to pipeline
|
||||||
# as running in Pester effectively wraps everything in parenthesis, workaround is to use another powershell
|
# as running in Pester effectively wraps everything in parenthesis, workaround is to use another powershell
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Copyright (c) Microsoft Corporation.
|
# Copyright (c) Microsoft Corporation.
|
||||||
# Licensed under the MIT License.
|
# Licensed under the MIT License.
|
||||||
Describe "Out-Host Tests" -tag CI {
|
Describe "Out-Host Tests" -Tag CI {
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
$th = New-TestHost
|
$th = New-TestHost
|
||||||
$rs = [runspacefactory]::Createrunspace($th)
|
$rs = [runspacefactory]::Createrunspace($th)
|
||||||
|
@ -34,15 +34,15 @@ Describe "Tests Get-Command with relative paths and wildcards" -Tag "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
It "Test wildcard with relative directory path" {
|
It "Test wildcard with relative directory path" {
|
||||||
push-location $TestDrive
|
Push-Location $TestDrive
|
||||||
$result = Get-Command -Name .\WildCardCommandA*
|
$result = Get-Command -Name .\WildCardCommandA*
|
||||||
pop-location
|
Pop-Location
|
||||||
$result | Should -Not -BeNullOrEmpty
|
$result | Should -Not -BeNullOrEmpty
|
||||||
$result | Should -Be WildCardCommandA.exe
|
$result | Should -Be WildCardCommandA.exe
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Test with PowerShell wildcard and relative path" {
|
It "Test with PowerShell wildcard and relative path" {
|
||||||
push-location $TestDrive
|
Push-Location $TestDrive
|
||||||
|
|
||||||
# This should use the wildcard to find WildCardCommandA.exe
|
# This should use the wildcard to find WildCardCommandA.exe
|
||||||
$result = Get-Command -Name .\WildCardCommand[A].exe
|
$result = Get-Command -Name .\WildCardCommand[A].exe
|
||||||
@ -59,7 +59,7 @@ Describe "Tests Get-Command with relative paths and wildcards" -Tag "CI" {
|
|||||||
|
|
||||||
It "Get-Command -ShowCommandInfo property field test" {
|
It "Get-Command -ShowCommandInfo property field test" {
|
||||||
$properties = ($commandInfo | Get-Member -MemberType NoteProperty)
|
$properties = ($commandInfo | Get-Member -MemberType NoteProperty)
|
||||||
$propertiesAsString = $properties.name | out-string
|
$propertiesAsString = $properties.name | Out-String
|
||||||
$propertiesAsString | Should -MatchExactly 'CommandType'
|
$propertiesAsString | Should -MatchExactly 'CommandType'
|
||||||
$propertiesAsString | Should -MatchExactly 'Definition'
|
$propertiesAsString | Should -MatchExactly 'Definition'
|
||||||
$propertiesAsString | Should -MatchExactly 'Module'
|
$propertiesAsString | Should -MatchExactly 'Module'
|
||||||
@ -86,7 +86,7 @@ Describe "Tests Get-Command with relative paths and wildcards" -Tag "CI" {
|
|||||||
|
|
||||||
It "Get-Command -ShowCommandInfo ParameterSets property field test" {
|
It "Get-Command -ShowCommandInfo ParameterSets property field test" {
|
||||||
$properties = ($commandInfo.ParameterSets[0] | Get-Member -MemberType NoteProperty)
|
$properties = ($commandInfo.ParameterSets[0] | Get-Member -MemberType NoteProperty)
|
||||||
$propertiesAsString = $properties.name | out-string
|
$propertiesAsString = $properties.name | Out-String
|
||||||
$propertiesAsString | Should -MatchExactly 'IsDefault'
|
$propertiesAsString | Should -MatchExactly 'IsDefault'
|
||||||
$propertiesAsString | Should -MatchExactly 'Name'
|
$propertiesAsString | Should -MatchExactly 'Name'
|
||||||
$propertiesAsString | Should -MatchExactly 'Parameters'
|
$propertiesAsString | Should -MatchExactly 'Parameters'
|
||||||
@ -94,7 +94,7 @@ Describe "Tests Get-Command with relative paths and wildcards" -Tag "CI" {
|
|||||||
|
|
||||||
It "Get-Command -ShowCommandInfo Parameters property field test" {
|
It "Get-Command -ShowCommandInfo Parameters property field test" {
|
||||||
$properties = ($commandInfo.ParameterSets[0].Parameters | Get-Member -MemberType NoteProperty)
|
$properties = ($commandInfo.ParameterSets[0].Parameters | Get-Member -MemberType NoteProperty)
|
||||||
$propertiesAsString = $properties.name | out-string
|
$propertiesAsString = $properties.name | Out-String
|
||||||
$propertiesAsString | Should -MatchExactly 'HasParameterSet'
|
$propertiesAsString | Should -MatchExactly 'HasParameterSet'
|
||||||
$propertiesAsString | Should -MatchExactly 'IsMandatory'
|
$propertiesAsString | Should -MatchExactly 'IsMandatory'
|
||||||
$propertiesAsString | Should -MatchExactly 'Name'
|
$propertiesAsString | Should -MatchExactly 'Name'
|
||||||
|
@ -9,7 +9,7 @@ Describe "Remote import-module tests" -Tags 'Feature','RequireAdminOnWindows' {
|
|||||||
$PSDefaultParameterValues["it:skip"] = $true
|
$PSDefaultParameterValues["it:skip"] = $true
|
||||||
} else {
|
} else {
|
||||||
$pssession = New-RemoteSession
|
$pssession = New-RemoteSession
|
||||||
Invoke-Command -Session $pssession -ScriptBlock { $env:PSModulePath += ";${using:testdrive}" }
|
Invoke-Command -Session $pssession -Scriptblock { $env:PSModulePath += ";${using:testdrive}" }
|
||||||
# pending https://github.com/PowerShell/PowerShell/issues/4819
|
# pending https://github.com/PowerShell/PowerShell/issues/4819
|
||||||
# $cimsession = New-RemoteSession -CimSession
|
# $cimsession = New-RemoteSession -CimSession
|
||||||
$null = New-Item -ItemType Directory -Path $modulePath
|
$null = New-Item -ItemType Directory -Path $modulePath
|
||||||
|
@ -51,7 +51,7 @@ Describe "Where-Object" -Tags "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
It 'Where-Object Prop -contains Value' {
|
It 'Where-Object Prop -contains Value' {
|
||||||
$Result = $Computers | Where-Object Drives -contains 'D'
|
$Result = $Computers | Where-Object Drives -Contains 'D'
|
||||||
$Result | Should -HaveCount 2
|
$Result | Should -HaveCount 2
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ Describe "Where-Object" -Tags "CI" {
|
|||||||
|
|
||||||
It 'Where-Object $Array -in Prop' {
|
It 'Where-Object $Array -in Prop' {
|
||||||
$Array = 'SPC-1234','BGP-5678'
|
$Array = 'SPC-1234','BGP-5678'
|
||||||
$Result = $Computers | Where-Object ComputerName -in $Array
|
$Result = $Computers | Where-Object ComputerName -In $Array
|
||||||
$Result | Should -HaveCount 2
|
$Result | Should -HaveCount 2
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ Describe "Where-Object" -Tags "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
It 'Where-Object Prop -ge 2' {
|
It 'Where-Object Prop -ge 2' {
|
||||||
$Result = $Computers | Where-Object NumberOfCores -ge 2
|
$Result = $Computers | Where-Object NumberOfCores -GE 2
|
||||||
$Result | Should -HaveCount 2
|
$Result | Should -HaveCount 2
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ Describe "Where-Object" -Tags "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
It 'Where-Object Prop -gt 2' {
|
It 'Where-Object Prop -gt 2' {
|
||||||
$Result = $Computers | Where-Object NumberOfCores -gt 2
|
$Result = $Computers | Where-Object NumberOfCores -GT 2
|
||||||
$Result | Should -HaveCount 1
|
$Result | Should -HaveCount 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ Describe "Where-Object" -Tags "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
It 'Where-Object Prop -le 2' {
|
It 'Where-Object Prop -le 2' {
|
||||||
$Result = $Computers | Where-Object NumberOfCores -le 2
|
$Result = $Computers | Where-Object NumberOfCores -LE 2
|
||||||
$Result | Should -HaveCount 2
|
$Result | Should -HaveCount 2
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ Describe "Where-Object" -Tags "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
It 'Where-Object Prop -lt 2' {
|
It 'Where-Object Prop -lt 2' {
|
||||||
$Result = $Computers | Where-Object NumberOfCores -lt 2
|
$Result = $Computers | Where-Object NumberOfCores -LT 2
|
||||||
$Result | Should -HaveCount 1
|
$Result | Should -HaveCount 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ Describe "Where-Object" -Tags "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
It 'Where-Object Prop -like Value' {
|
It 'Where-Object Prop -like Value' {
|
||||||
$Result = $Computers | Where-Object ComputerName -like 'MGC-9101'
|
$Result = $Computers | Where-Object ComputerName -Like 'MGC-9101'
|
||||||
$Result | Should -HaveCount 1
|
$Result | Should -HaveCount 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,13 +123,13 @@ Describe "Where-Object" -Tags "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
It 'Where-Object Prop -like Value' {
|
It 'Where-Object Prop -like Value' {
|
||||||
$Result = $Computers | Where-Object ComputerName -match '^MGC.+'
|
$Result = $Computers | Where-Object ComputerName -Match '^MGC.+'
|
||||||
$Result | Should -HaveCount 1
|
$Result | Should -HaveCount 1
|
||||||
}
|
}
|
||||||
|
|
||||||
It 'Where-Object should handle dynamic (DLR) objects' {
|
It 'Where-Object should handle dynamic (DLR) objects' {
|
||||||
$dynObj = [TestDynamic]::new()
|
$dynObj = [TestDynamic]::new()
|
||||||
$Result = $dynObj, $dynObj | Where-Object FooProp -eq 123
|
$Result = $dynObj, $dynObj | Where-Object FooProp -EQ 123
|
||||||
$Result | Should -HaveCount 2
|
$Result | Should -HaveCount 2
|
||||||
$Result[0] | Should -Be $dynObj
|
$Result[0] | Should -Be $dynObj
|
||||||
$Result[1] | Should -Be $dynObj
|
$Result[1] | Should -Be $dynObj
|
||||||
@ -137,7 +137,7 @@ Describe "Where-Object" -Tags "CI" {
|
|||||||
|
|
||||||
It 'Where-Object should handle dynamic (DLR) objects, even without property name hint' {
|
It 'Where-Object should handle dynamic (DLR) objects, even without property name hint' {
|
||||||
$dynObj = [TestDynamic]::new()
|
$dynObj = [TestDynamic]::new()
|
||||||
$Result = $dynObj, $dynObj | Where-Object HiddenProp -eq 789
|
$Result = $dynObj, $dynObj | Where-Object HiddenProp -EQ 789
|
||||||
$Result | Should -HaveCount 2
|
$Result | Should -HaveCount 2
|
||||||
$Result[0] | Should -Be $dynObj
|
$Result[0] | Should -Be $dynObj
|
||||||
$Result[1] | Should -Be $dynObj
|
$Result[1] | Should -Be $dynObj
|
||||||
|
@ -15,12 +15,12 @@ Describe 'Get-WinEvent' -Tags "CI" {
|
|||||||
}
|
}
|
||||||
Context "Get-WinEvent ListProvider parameter" {
|
Context "Get-WinEvent ListProvider parameter" {
|
||||||
It 'Get-WinEvent can list the providers' {
|
It 'Get-WinEvent can list the providers' {
|
||||||
$result = Get-WinEvent -listprovider * -erroraction ignore
|
$result = Get-WinEvent -ListProvider * -ErrorAction ignore
|
||||||
$result | Should -Not -BeNullOrEmpty
|
$result | Should -Not -BeNullOrEmpty
|
||||||
}
|
}
|
||||||
It 'Get-WinEvent can get a provider by name' {
|
It 'Get-WinEvent can get a provider by name' {
|
||||||
$providers = Get-WinEvent -listprovider MSI* -erroraction ignore
|
$providers = Get-WinEvent -ListProvider MSI* -ErrorAction ignore
|
||||||
$result = Get-WinEvent -listprovider ($providers[0].name)
|
$result = Get-WinEvent -ListProvider ($providers[0].name)
|
||||||
$result | Should -Not -BeNullOrEmpty
|
$result | Should -Not -BeNullOrEmpty
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,9 +30,9 @@ Describe 'Get-WinEvent' -Tags "CI" {
|
|||||||
BeforeAll {
|
BeforeAll {
|
||||||
if ( ! $IsWindows ) { return }
|
if ( ! $IsWindows ) { return }
|
||||||
$foundEvents = $false
|
$foundEvents = $false
|
||||||
$providers = Get-WinEvent -listprovider * -erroraction ignore
|
$providers = Get-WinEvent -ListProvider * -ErrorAction ignore
|
||||||
foreach($provider in $providers) {
|
foreach($provider in $providers) {
|
||||||
$events = Get-WinEvent -provider $provider.name -erroraction ignore
|
$events = Get-WinEvent -provider $provider.name -ErrorAction ignore
|
||||||
if ( $events.Count -gt 2 ) {
|
if ( $events.Count -gt 2 ) {
|
||||||
$providerForTests = $provider
|
$providerForTests = $provider
|
||||||
$foundEvents = $true
|
$foundEvents = $true
|
||||||
@ -48,17 +48,17 @@ Describe 'Get-WinEvent' -Tags "CI" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
It 'Get-WinEvent can get events via logname' {
|
It 'Get-WinEvent can get events via logname' {
|
||||||
$results = get-winevent -logname $providerForTests.LogLinks.LogName -MaxEvents 10
|
$results = Get-WinEvent -LogName $providerForTests.LogLinks.LogName -MaxEvents 10
|
||||||
$results | Should -Not -BeNullOrEmpty
|
$results | Should -Not -BeNullOrEmpty
|
||||||
}
|
}
|
||||||
It 'Throw if count of lognames exceeds Windows API limit' {
|
It 'Throw if count of lognames exceeds Windows API limit' {
|
||||||
if ([System.Environment]::OSVersion.Version.Major -ge 10) {
|
if ([System.Environment]::OSVersion.Version.Major -ge 10) {
|
||||||
{ get-winevent -logname * } | Should -Throw -ErrorId "LogCountLimitExceeded,Microsoft.PowerShell.Commands.GetWinEventCommand"
|
{ Get-WinEvent -LogName * } | Should -Throw -ErrorId "LogCountLimitExceeded,Microsoft.PowerShell.Commands.GetWinEventCommand"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
It 'Get-WinEvent can use the simplest of filters' {
|
It 'Get-WinEvent can use the simplest of filters' {
|
||||||
$filter = @{ ProviderName = $providerForTests.Name }
|
$filter = @{ ProviderName = $providerForTests.Name }
|
||||||
$testEvents = Get-WinEvent -filterhashtable $filter
|
$testEvents = Get-WinEvent -FilterHashtable $filter
|
||||||
|
|
||||||
$testEventDict = [System.Collections.Generic.Dictionary[int, System.Diagnostics.Eventing.Reader.EventLogRecord]]::new()
|
$testEventDict = [System.Collections.Generic.Dictionary[int, System.Diagnostics.Eventing.Reader.EventLogRecord]]::new()
|
||||||
foreach ($te in $testEvents)
|
foreach ($te in $testEvents)
|
||||||
@ -78,21 +78,21 @@ Describe 'Get-WinEvent' -Tags "CI" {
|
|||||||
}
|
}
|
||||||
It 'Get-WinEvent can use a filter which includes two items' {
|
It 'Get-WinEvent can use a filter which includes two items' {
|
||||||
$filter = @{ ProviderName = $providerForTests.Name; Id = $events[0].Id}
|
$filter = @{ ProviderName = $providerForTests.Name; Id = $events[0].Id}
|
||||||
$results = Get-WinEvent -filterHashtable $filter
|
$results = Get-WinEvent -FilterHashtable $filter
|
||||||
$results | Should -Not -BeNullOrEmpty
|
$results | Should -Not -BeNullOrEmpty
|
||||||
}
|
}
|
||||||
It 'Get-WinEvent can retrieve event via XmlQuery' {
|
It 'Get-WinEvent can retrieve event via XmlQuery' {
|
||||||
$level = $events[0].Level
|
$level = $events[0].Level
|
||||||
$logname = $providerForTests.loglinks.logname
|
$logname = $providerForTests.loglinks.logname
|
||||||
$filter = "<QueryList><Query><Select Path='${logname}'>*[System[Level=${level}]]</Select></Query></QueryList>"
|
$filter = "<QueryList><Query><Select Path='${logname}'>*[System[Level=${level}]]</Select></Query></QueryList>"
|
||||||
$results = Get-WinEvent -filterXml $filter -max 3
|
$results = Get-WinEvent -FilterXml $filter -max 3
|
||||||
$results | Should -Not -BeNullOrEmpty
|
$results | Should -Not -BeNullOrEmpty
|
||||||
}
|
}
|
||||||
It 'Get-WinEvent can retrieve event via XPath' {
|
It 'Get-WinEvent can retrieve event via XPath' {
|
||||||
$level = $events[0].Level
|
$level = $events[0].Level
|
||||||
$logname = $providerForTests.loglinks.logname
|
$logname = $providerForTests.loglinks.logname
|
||||||
$xpathFilter = "*[System[Level=$level]]"
|
$xpathFilter = "*[System[Level=$level]]"
|
||||||
$results = Get-WinEvent -logname $logname -filterXPath $xpathFilter -max 3
|
$results = Get-WinEvent -LogName $logname -FilterXPath $xpathFilter -max 3
|
||||||
$results | Should -Not -BeNullOrEmpty
|
$results | Should -Not -BeNullOrEmpty
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ Describe 'Get-WinEvent' -Tags "CI" {
|
|||||||
# the provided log file has been edited to remove MS PII, so we must use -ErrorAction silentlycontinue
|
# the provided log file has been edited to remove MS PII, so we must use -ErrorAction silentlycontinue
|
||||||
$eventLogFile = [io.path]::Combine($PSScriptRoot, "assets", "Saved-Events.evtx")
|
$eventLogFile = [io.path]::Combine($PSScriptRoot, "assets", "Saved-Events.evtx")
|
||||||
$filter = @{ path = "$eventLogFile"; Param2 = "Windows x64"}
|
$filter = @{ path = "$eventLogFile"; Param2 = "Windows x64"}
|
||||||
$results = Get-WinEvent -filterHashtable $filter -ErrorAction silentlycontinue
|
$results = Get-WinEvent -FilterHashtable $filter -ErrorAction silentlycontinue
|
||||||
@($results).Count | Should -Be 1
|
@($results).Count | Should -Be 1
|
||||||
$results.RecordId | Should -Be 10
|
$results.RecordId | Should -Be 10
|
||||||
}
|
}
|
||||||
@ -121,7 +121,7 @@ Describe 'Get-WinEvent' -Tags "CI" {
|
|||||||
# the provided log file has been edited to remove MS PII, so we must use -ErrorAction silentlycontinue
|
# the provided log file has been edited to remove MS PII, so we must use -ErrorAction silentlycontinue
|
||||||
$eventLogFile = [io.path]::Combine($PSScriptRoot, "assets", "Saved-Events.evtx")
|
$eventLogFile = [io.path]::Combine($PSScriptRoot, "assets", "Saved-Events.evtx")
|
||||||
$filter = @{ path = "$eventLogFile"; DriverName = "Remote Desktop Easy Print", "Microsoft enhanced Point and Print compatibility driver" }
|
$filter = @{ path = "$eventLogFile"; DriverName = "Remote Desktop Easy Print", "Microsoft enhanced Point and Print compatibility driver" }
|
||||||
$results = Get-WinEvent -filterHashtable $filter -ErrorAction silentlycontinue
|
$results = Get-WinEvent -FilterHashtable $filter -ErrorAction silentlycontinue
|
||||||
@($results).Count | Should -Be 2
|
@($results).Count | Should -Be 2
|
||||||
($results.RecordId -contains 9) | Should -BeTrue
|
($results.RecordId -contains 9) | Should -BeTrue
|
||||||
($results.RecordId -contains 11) | Should -BeTrue
|
($results.RecordId -contains 11) | Should -BeTrue
|
||||||
@ -131,7 +131,7 @@ Describe 'Get-WinEvent' -Tags "CI" {
|
|||||||
# the provided log file has been edited to remove MS PII, so we must use -ErrorAction silentlycontinue
|
# the provided log file has been edited to remove MS PII, so we must use -ErrorAction silentlycontinue
|
||||||
$eventLogFile = [io.path]::Combine($PSScriptRoot, "assets", "Saved-Events.evtx")
|
$eventLogFile = [io.path]::Combine($PSScriptRoot, "assets", "Saved-Events.evtx")
|
||||||
$filter = @{ path = "$eventLogFile"; PackageAware="Not package aware"; DriverName = "Remote Desktop Easy Print", "Microsoft enhanced Point and Print compatibility driver" }
|
$filter = @{ path = "$eventLogFile"; PackageAware="Not package aware"; DriverName = "Remote Desktop Easy Print", "Microsoft enhanced Point and Print compatibility driver" }
|
||||||
$results = Get-WinEvent -filterHashtable $filter -ErrorAction silentlycontinue
|
$results = Get-WinEvent -FilterHashtable $filter -ErrorAction silentlycontinue
|
||||||
@($results).Count | Should -Be 2
|
@($results).Count | Should -Be 2
|
||||||
($results.RecordId -contains 9) | Should -BeTrue
|
($results.RecordId -contains 9) | Should -BeTrue
|
||||||
($results.RecordId -contains 11) | Should -BeTrue
|
($results.RecordId -contains 11) | Should -BeTrue
|
||||||
@ -141,7 +141,7 @@ Describe 'Get-WinEvent' -Tags "CI" {
|
|||||||
# the provided log file has been edited to remove MS PII, so we must use -ErrorAction silentlycontinue
|
# the provided log file has been edited to remove MS PII, so we must use -ErrorAction silentlycontinue
|
||||||
$eventLogFile = [io.path]::Combine($PSScriptRoot, "assets", "Saved-Events.evtx")
|
$eventLogFile = [io.path]::Combine($PSScriptRoot, "assets", "Saved-Events.evtx")
|
||||||
$filter = "*/UserData/*/Param2='Windows x64'"
|
$filter = "*/UserData/*/Param2='Windows x64'"
|
||||||
$results = Get-WinEvent -path $eventLogFile -filterXPath $filter -ErrorAction silentlycontinue
|
$results = Get-WinEvent -Path $eventLogFile -FilterXPath $filter -ErrorAction silentlycontinue
|
||||||
@($results).Count | Should -Be 1
|
@($results).Count | Should -Be 1
|
||||||
$results.RecordId | Should -Be 10
|
$results.RecordId | Should -Be 10
|
||||||
}
|
}
|
||||||
@ -152,9 +152,9 @@ Describe 'Get-WinEvent' -Tags "CI" {
|
|||||||
# the provided log file has been edited to remove MS PII, so we must use -ErrorAction silentlycontinue
|
# the provided log file has been edited to remove MS PII, so we must use -ErrorAction silentlycontinue
|
||||||
$eventLogFile = [io.path]::Combine($PSScriptRoot, "assets", "Saved-Events.evtx")
|
$eventLogFile = [io.path]::Combine($PSScriptRoot, "assets", "Saved-Events.evtx")
|
||||||
$filter = @{ path = "$eventLogFile"}
|
$filter = @{ path = "$eventLogFile"}
|
||||||
$results = Get-WinEvent -filterHashtable $filter -ErrorAction silentlycontinue
|
$results = Get-WinEvent -FilterHashtable $filter -ErrorAction silentlycontinue
|
||||||
$filterSuppress = @{ path = "$eventLogFile"; SuppressHashFilter=@{Id=370}}
|
$filterSuppress = @{ path = "$eventLogFile"; SuppressHashFilter=@{Id=370}}
|
||||||
$resultsSuppress = Get-WinEvent -filterHashtable $filterSuppress -ErrorAction silentlycontinue
|
$resultsSuppress = Get-WinEvent -FilterHashtable $filterSuppress -ErrorAction silentlycontinue
|
||||||
@($results).Count | Should -Be 3
|
@($results).Count | Should -Be 3
|
||||||
@($resultsSuppress).Count | Should -Be 2
|
@($resultsSuppress).Count | Should -Be 2
|
||||||
}
|
}
|
||||||
@ -163,9 +163,9 @@ Describe 'Get-WinEvent' -Tags "CI" {
|
|||||||
# the provided log file has been edited to remove MS PII, so we must use -ErrorAction silentlycontinue
|
# the provided log file has been edited to remove MS PII, so we must use -ErrorAction silentlycontinue
|
||||||
$eventLogFile = [io.path]::Combine($PSScriptRoot, "assets", "Saved-Events.evtx")
|
$eventLogFile = [io.path]::Combine($PSScriptRoot, "assets", "Saved-Events.evtx")
|
||||||
$filter = @{ path = "$eventLogFile"}
|
$filter = @{ path = "$eventLogFile"}
|
||||||
$results = Get-WinEvent -filterHashtable $filter -ErrorAction silentlycontinue
|
$results = Get-WinEvent -FilterHashtable $filter -ErrorAction silentlycontinue
|
||||||
$filterSuppress = @{ path = "$eventLogFile"; SuppressHashFilter=@{Param2 = "Windows x64"}}
|
$filterSuppress = @{ path = "$eventLogFile"; SuppressHashFilter=@{Param2 = "Windows x64"}}
|
||||||
$resultsSuppress = Get-WinEvent -filterHashtable $filterSuppress -ErrorAction silentlycontinue
|
$resultsSuppress = Get-WinEvent -FilterHashtable $filterSuppress -ErrorAction silentlycontinue
|
||||||
@($results).Count | Should -Be 3
|
@($results).Count | Should -Be 3
|
||||||
@($resultsSuppress).Count | Should -Be 2
|
@($resultsSuppress).Count | Should -Be 2
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ Describe 'New-WinEvent' -Tags "CI" {
|
|||||||
It 'Simple New-WinEvent without any payload' {
|
It 'Simple New-WinEvent without any payload' {
|
||||||
New-WinEvent -ProviderName $ProviderName -Id $SimpleEventId -Version 1
|
New-WinEvent -ProviderName $ProviderName -Id $SimpleEventId -Version 1
|
||||||
$filter = @{ ProviderName = $ProviderName; Id = $SimpleEventId}
|
$filter = @{ ProviderName = $ProviderName; Id = $SimpleEventId}
|
||||||
(Get-WinEvent -filterHashtable $filter).Count | Should -BeGreaterThan 0
|
(Get-WinEvent -FilterHashtable $filter).Count | Should -BeGreaterThan 0
|
||||||
}
|
}
|
||||||
|
|
||||||
It 'No provider found error' {
|
It 'No provider found error' {
|
||||||
@ -42,7 +42,7 @@ Describe 'New-WinEvent' -Tags "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
It 'PayloadMismatch error' {
|
It 'PayloadMismatch error' {
|
||||||
$logPath = join-path $TestDrive 'testlog1.txt'
|
$logPath = Join-Path $TestDrive 'testlog1.txt'
|
||||||
# this will print the warning with expected event template to the file
|
# this will print the warning with expected event template to the file
|
||||||
New-WinEvent -ProviderName $ProviderName -Id $ComplexEventId *> $logPath
|
New-WinEvent -ProviderName $ProviderName -Id $ComplexEventId *> $logPath
|
||||||
Get-Content $logPath -Raw | Should -Match 'data name="FragmentPayload"'
|
Get-Content $logPath -Raw | Should -Match 'data name="FragmentPayload"'
|
||||||
|
@ -222,7 +222,7 @@ try {
|
|||||||
|
|
||||||
It "Errors on adding nonexistent user to group" {
|
It "Errors on adding nonexistent user to group" {
|
||||||
$sb = {
|
$sb = {
|
||||||
Add-LocalGroupMember -name TestGroup1 -Member TestNonexistentUser1
|
Add-LocalGroupMember -Name TestGroup1 -Member TestNonexistentUser1
|
||||||
}
|
}
|
||||||
VerifyFailingTest $sb "PrincipalNotFound,Microsoft.PowerShell.Commands.AddLocalGroupMemberCommand"
|
VerifyFailingTest $sb "PrincipalNotFound,Microsoft.PowerShell.Commands.AddLocalGroupMemberCommand"
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
Set-Variable dateInFuture -option Constant -value "12/12/2036 09:00"
|
Set-Variable dateInFuture -Option Constant -Value "12/12/2036 09:00"
|
||||||
Set-Variable dateInPast -option Constant -value "12/12/2010 09:00"
|
Set-Variable dateInPast -Option Constant -Value "12/12/2010 09:00"
|
||||||
Set-Variable dateInvalid -option Constant -value "12/12/2016 25:00"
|
Set-Variable dateInvalid -Option Constant -Value "12/12/2016 25:00"
|
||||||
|
|
||||||
function RemoveTestUsers
|
function RemoveTestUsers
|
||||||
{
|
{
|
||||||
@ -66,7 +66,7 @@ try {
|
|||||||
Describe "Verify Expected LocalUser Aliases are present" -Tags @('CI', 'RequireAdminOnWindows') {
|
Describe "Verify Expected LocalUser Aliases are present" -Tags @('CI', 'RequireAdminOnWindows') {
|
||||||
|
|
||||||
It "Test command presence" {
|
It "Test command presence" {
|
||||||
$result = get-alias | ForEach-Object { if ($_.Source -eq "Microsoft.PowerShell.LocalAccounts") {$_}}
|
$result = Get-Alias | ForEach-Object { if ($_.Source -eq "Microsoft.PowerShell.LocalAccounts") {$_}}
|
||||||
|
|
||||||
$result.Name -contains "algm" | Should -BeTrue
|
$result.Name -contains "algm" | Should -BeTrue
|
||||||
$result.Name -contains "dlu" | Should -BeTrue
|
$result.Name -contains "dlu" | Should -BeTrue
|
||||||
@ -328,7 +328,7 @@ try {
|
|||||||
|
|
||||||
It "Errors when Password is an empty string" {
|
It "Errors when Password is an empty string" {
|
||||||
$sb = {
|
$sb = {
|
||||||
New-LocalUser TestUserNew1 -Password (ConvertTo-SecureString "" -Asplaintext -Force)
|
New-LocalUser TestUserNew1 -Password (ConvertTo-SecureString "" -AsPlainText -Force)
|
||||||
}
|
}
|
||||||
VerifyFailingTest $sb "ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.ConvertToSecureStringCommand"
|
VerifyFailingTest $sb "ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.ConvertToSecureStringCommand"
|
||||||
}
|
}
|
||||||
@ -375,7 +375,7 @@ try {
|
|||||||
|
|
||||||
It "Can set PasswordNeverExpires to create a user with null for PasswordExpires date" {
|
It "Can set PasswordNeverExpires to create a user with null for PasswordExpires date" {
|
||||||
#[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="Demo/doc/test secret.")]
|
#[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="Demo/doc/test secret.")]
|
||||||
$result = New-LocalUser TestUserNew1 -Password (ConvertTo-SecureString "p@ssw0rd" -Asplaintext -Force) -PasswordNeverExpires
|
$result = New-LocalUser TestUserNew1 -Password (ConvertTo-SecureString "p@ssw0rd" -AsPlainText -Force) -PasswordNeverExpires
|
||||||
|
|
||||||
$result.Name | Should -BeExactly TestUserNew1
|
$result.Name | Should -BeExactly TestUserNew1
|
||||||
$result.PasswordExpires | Should -BeNullOrEmpty
|
$result.PasswordExpires | Should -BeNullOrEmpty
|
||||||
@ -750,21 +750,21 @@ try {
|
|||||||
|
|
||||||
It "Errors when Password is an empty string" {
|
It "Errors when Password is an empty string" {
|
||||||
$sb = {
|
$sb = {
|
||||||
Set-LocalUser -Name TestUserSet1 -Password (ConvertTo-SecureString "" -Asplaintext -Force)
|
Set-LocalUser -Name TestUserSet1 -Password (ConvertTo-SecureString "" -AsPlainText -Force)
|
||||||
}
|
}
|
||||||
VerifyFailingTest $sb "ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.ConvertToSecureStringCommand"
|
VerifyFailingTest $sb "ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.ConvertToSecureStringCommand"
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Errors when Password is null" {
|
It "Errors when Password is null" {
|
||||||
$sb = {
|
$sb = {
|
||||||
Set-LocalUser -Name TestUserSet1 -Password (ConvertTo-SecureString $null -Asplaintext -Force)
|
Set-LocalUser -Name TestUserSet1 -Password (ConvertTo-SecureString $null -AsPlainText -Force)
|
||||||
}
|
}
|
||||||
VerifyFailingTest $sb "ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ConvertToSecureStringCommand"
|
VerifyFailingTest $sb "ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ConvertToSecureStringCommand"
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Can set Password value at max 256" {
|
It "Can set Password value at max 256" {
|
||||||
#[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="Demo/doc/test secret.")]
|
#[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="Demo/doc/test secret.")]
|
||||||
Set-LocalUser -Name TestUserSet1 -Password (ConvertTo-SecureString ("123@"+"A"*252) -asplaintext -Force)
|
Set-LocalUser -Name TestUserSet1 -Password (ConvertTo-SecureString ("123@"+"A"*252) -AsPlainText -Force)
|
||||||
$result = Get-LocalUser -Name TestUserSet1
|
$result = Get-LocalUser -Name TestUserSet1
|
||||||
|
|
||||||
$result.Name | Should -BeExactly TestUserSet1
|
$result.Name | Should -BeExactly TestUserSet1
|
||||||
@ -775,14 +775,14 @@ try {
|
|||||||
|
|
||||||
It "Errors when Password over max 257" {
|
It "Errors when Password over max 257" {
|
||||||
$sb = {
|
$sb = {
|
||||||
Set-LocalUser -Name TestUserSet1 -Password (ConvertTo-SecureString ("A"*257) -asplaintext -Force) -ErrorAction Stop
|
Set-LocalUser -Name TestUserSet1 -Password (ConvertTo-SecureString ("A"*257) -AsPlainText -Force) -ErrorAction Stop
|
||||||
}
|
}
|
||||||
VerifyFailingTest $sb "InvalidPassword,Microsoft.PowerShell.Commands.SetLocalUserCommand"
|
VerifyFailingTest $sb "InvalidPassword,Microsoft.PowerShell.Commands.SetLocalUserCommand"
|
||||||
}
|
}
|
||||||
|
|
||||||
It 'Can use PasswordNeverExpires:$true to null a PasswordExpires date' {
|
It 'Can use PasswordNeverExpires:$true to null a PasswordExpires date' {
|
||||||
#[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="Demo/doc/test secret.")]
|
#[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="Demo/doc/test secret.")]
|
||||||
$user = New-LocalUser TestUserSet2 -Password (ConvertTo-SecureString "p@ssw0rd" -Asplaintext -Force)
|
$user = New-LocalUser TestUserSet2 -Password (ConvertTo-SecureString "p@ssw0rd" -AsPlainText -Force)
|
||||||
$user | Set-LocalUser -PasswordNeverExpires:$true
|
$user | Set-LocalUser -PasswordNeverExpires:$true
|
||||||
$result = Get-LocalUser TestUserSet2
|
$result = Get-LocalUser TestUserSet2
|
||||||
|
|
||||||
@ -792,7 +792,7 @@ try {
|
|||||||
|
|
||||||
It 'Can use PasswordNeverExpires:$false to activate a PasswordExpires date' {
|
It 'Can use PasswordNeverExpires:$false to activate a PasswordExpires date' {
|
||||||
#[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="Demo/doc/test secret.")]
|
#[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="Demo/doc/test secret.")]
|
||||||
$user = New-LocalUser TestUserSet2 -Password (ConvertTo-SecureString "p@ssw0rd" -Asplaintext -Force) -PasswordNeverExpires
|
$user = New-LocalUser TestUserSet2 -Password (ConvertTo-SecureString "p@ssw0rd" -AsPlainText -Force) -PasswordNeverExpires
|
||||||
$user | Set-LocalUser -PasswordNeverExpires:$false
|
$user | Set-LocalUser -PasswordNeverExpires:$false
|
||||||
$result = Get-LocalUser TestUserSet2
|
$result = Get-LocalUser TestUserSet2
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ Describe "Extended Alias Provider Tests" -Tags "Feature" {
|
|||||||
|
|
||||||
It "Verifying Whatif" {
|
It "Verifying Whatif" {
|
||||||
$before = (Get-Item -Path "Alias:\${testAliasName}").Definition
|
$before = (Get-Item -Path "Alias:\${testAliasName}").Definition
|
||||||
Set-Item -Path "Alias:\${testAliasName}" -Value "Get-Location" -Whatif
|
Set-Item -Path "Alias:\${testAliasName}" -Value "Get-Location" -WhatIf
|
||||||
$after = (Get-Item -Path "Alias:\${testAliasName}").Definition
|
$after = (Get-Item -Path "Alias:\${testAliasName}").Definition
|
||||||
$after | Should -BeExactly $before # Definition should not have changed
|
$after | Should -BeExactly $before # Definition should not have changed
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ Describe "Clear-Content cmdlet tests" -Tags "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# we could suppress the WhatIf output here if we use the testhost, but it's not necessary
|
# we could suppress the WhatIf output here if we use the testhost, but it's not necessary
|
||||||
It "The filesystem provider supports should process" -skip:(!$IsWindows) {
|
It "The filesystem provider supports should process" -Skip:(!$IsWindows) {
|
||||||
Clear-Content -Path TestDrive:\$file2 -WhatIf
|
Clear-Content -Path TestDrive:\$file2 -WhatIf
|
||||||
"TestDrive:\$file2" | Should -FileContentMatch "This is content"
|
"TestDrive:\$file2" | Should -FileContentMatch "This is content"
|
||||||
}
|
}
|
||||||
@ -75,7 +75,7 @@ Describe "Clear-Content cmdlet tests" -Tags "CI" {
|
|||||||
$cci.SupportsShouldProcess | Should -BeTrue
|
$cci.SupportsShouldProcess | Should -BeTrue
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Alternate streams should be cleared with clear-content" -skip:(!$IsWindows) {
|
It "Alternate streams should be cleared with clear-content" -Skip:(!$IsWindows) {
|
||||||
# make sure that the content is correct
|
# make sure that the content is correct
|
||||||
# this is here rather than BeforeAll because only windows can write to an alternate stream
|
# this is here rather than BeforeAll because only windows can write to an alternate stream
|
||||||
Set-Content -Path "TestDrive:/$file3" -Stream $streamName -Value $streamContent
|
Set-Content -Path "TestDrive:/$file3" -Stream $streamName -Value $streamContent
|
||||||
|
@ -14,7 +14,7 @@ Describe "Clear-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') {
|
|||||||
It "should be able to Clear-EventLog" -Pending:($true) {
|
It "should be able to Clear-EventLog" -Pending:($true) {
|
||||||
Remove-EventLog -LogName TestLog -ErrorAction Ignore
|
Remove-EventLog -LogName TestLog -ErrorAction Ignore
|
||||||
{ New-EventLog -LogName TestLog -Source TestSource -ErrorAction Stop } | Should -Not -Throw
|
{ 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
|
{ Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventId 1 -ErrorAction Stop } | Should -Not -Throw
|
||||||
{ Get-EventLog -LogName TestLog } | Should -Not -Throw
|
{ Get-EventLog -LogName TestLog } | Should -Not -Throw
|
||||||
$result = Get-EventLog -LogName TestLog
|
$result = Get-EventLog -LogName TestLog
|
||||||
$result.Count | Should -Be 1
|
$result.Count | Should -Be 1
|
||||||
|
@ -84,11 +84,11 @@ Describe "Control Service cmdlet tests" -Tags "Feature","RequireAdminOnWindows"
|
|||||||
@{script={Stop-Service dcomlaunch -ErrorAction Stop};errorid="ServiceHasDependentServices,Microsoft.PowerShell.Commands.StopServiceCommand"},
|
@{script={Stop-Service dcomlaunch -ErrorAction Stop};errorid="ServiceHasDependentServices,Microsoft.PowerShell.Commands.StopServiceCommand"},
|
||||||
@{script={Suspend-Service winrm -ErrorAction Stop};errorid="CouldNotSuspendServiceNotSupported,Microsoft.PowerShell.Commands.SuspendServiceCommand"},
|
@{script={Suspend-Service winrm -ErrorAction Stop};errorid="CouldNotSuspendServiceNotSupported,Microsoft.PowerShell.Commands.SuspendServiceCommand"},
|
||||||
@{script={Resume-Service winrm -ErrorAction Stop};errorid="CouldNotResumeServiceNotSupported,Microsoft.PowerShell.Commands.ResumeServiceCommand"},
|
@{script={Resume-Service winrm -ErrorAction Stop};errorid="CouldNotResumeServiceNotSupported,Microsoft.PowerShell.Commands.ResumeServiceCommand"},
|
||||||
@{script={Stop-Service $(new-guid) -ErrorAction Stop};errorid="NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.StopServiceCommand"},
|
@{script={Stop-Service $(New-Guid) -ErrorAction Stop};errorid="NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.StopServiceCommand"},
|
||||||
@{script={Start-Service $(new-guid) -ErrorAction Stop};errorid="NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.StartServiceCommand"},
|
@{script={Start-Service $(New-Guid) -ErrorAction Stop};errorid="NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.StartServiceCommand"},
|
||||||
@{script={Resume-Service $(new-guid) -ErrorAction Stop};errorid="NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.ResumeServiceCommand"},
|
@{script={Resume-Service $(New-Guid) -ErrorAction Stop};errorid="NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.ResumeServiceCommand"},
|
||||||
@{script={Suspend-Service $(new-guid) -ErrorAction Stop};errorid="NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.SuspendServiceCommand"},
|
@{script={Suspend-Service $(New-Guid) -ErrorAction Stop};errorid="NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.SuspendServiceCommand"},
|
||||||
@{script={Restart-Service $(new-guid) -ErrorAction Stop};errorid="NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.RestartServiceCommand"}
|
@{script={Restart-Service $(New-Guid) -ErrorAction Stop};errorid="NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.RestartServiceCommand"}
|
||||||
) {
|
) {
|
||||||
param($script,$errorid)
|
param($script,$errorid)
|
||||||
{ & $script } | Should -Throw -ErrorId $errorid
|
{ & $script } | Should -Throw -ErrorId $errorid
|
||||||
|
@ -550,7 +550,7 @@ Describe "Validate Copy-Item Remotely" -Tags "CI" {
|
|||||||
BeforeAll {
|
BeforeAll {
|
||||||
# Create test file.
|
# Create test file.
|
||||||
$testFilePath = Join-Path "TestDrive:" "testfile.txt"
|
$testFilePath = Join-Path "TestDrive:" "testfile.txt"
|
||||||
if (test-path $testFilePath)
|
if (Test-Path $testFilePath)
|
||||||
{
|
{
|
||||||
Remove-Item $testFilePath -Force -ErrorAction SilentlyContinue
|
Remove-Item $testFilePath -Force -ErrorAction SilentlyContinue
|
||||||
}
|
}
|
||||||
|
@ -703,8 +703,8 @@ Describe "Hard link and symbolic link tests" -Tags "CI", "RequireAdminOnWindows"
|
|||||||
$link = Join-Path $TestDrive "sym-to-folder"
|
$link = Join-Path $TestDrive "sym-to-folder"
|
||||||
New-Item -ItemType Directory -Path $folder > $null
|
New-Item -ItemType Directory -Path $folder > $null
|
||||||
New-Item -ItemType File -Path $file -Value "some content" > $null
|
New-Item -ItemType File -Path $file -Value "some content" > $null
|
||||||
New-Item -ItemType SymbolicLink -Path $link -value $folder > $null
|
New-Item -ItemType SymbolicLink -Path $link -Value $folder > $null
|
||||||
$childA = Get-Childitem $folder
|
$childA = Get-ChildItem $folder
|
||||||
Remove-Item -Path $link -Recurse
|
Remove-Item -Path $link -Recurse
|
||||||
$childB = Get-ChildItem $folder
|
$childB = Get-ChildItem $folder
|
||||||
$childB.Count | Should -Be 1
|
$childB.Count | Should -Be 1
|
||||||
@ -983,7 +983,7 @@ Describe "Extended FileSystem Item/Content Cmdlet Provider Tests" -Tags "Feature
|
|||||||
}
|
}
|
||||||
|
|
||||||
It "Verify Filter" {
|
It "Verify Filter" {
|
||||||
$result = Get-Item -Path "TestDrive:\*" -filter "*2.txt"
|
$result = Get-Item -Path "TestDrive:\*" -Filter "*2.txt"
|
||||||
$result.Name | Should -BeExactly $testFile2
|
$result.Name | Should -BeExactly $testFile2
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1085,7 +1085,7 @@ Describe "Extended FileSystem Item/Content Cmdlet Provider Tests" -Tags "Feature
|
|||||||
}
|
}
|
||||||
|
|
||||||
It "Verify Include and Exclude Intersection" {
|
It "Verify Include and Exclude Intersection" {
|
||||||
Remove-Item "TestDrive:\*" -Include "*.txt" -exclude "*2*"
|
Remove-Item "TestDrive:\*" -Include "*.txt" -Exclude "*2*"
|
||||||
$file1 = Get-Item $testFile -ErrorAction SilentlyContinue
|
$file1 = Get-Item $testFile -ErrorAction SilentlyContinue
|
||||||
$file2 = Get-Item $testFile2 -ErrorAction SilentlyContinue
|
$file2 = Get-Item $testFile2 -ErrorAction SilentlyContinue
|
||||||
$file1 | Should -BeNullOrEmpty
|
$file1 | Should -BeNullOrEmpty
|
||||||
|
@ -83,7 +83,7 @@ Describe "Get-ChildItem" -Tags "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
It "Should have all the proper fields and be populated" {
|
It "Should have all the proper fields and be populated" {
|
||||||
$var = Get-Childitem .
|
$var = Get-ChildItem .
|
||||||
|
|
||||||
$var.Name.Length | Should -BeGreaterThan 0
|
$var.Name.Length | Should -BeGreaterThan 0
|
||||||
$var.Mode.Length | Should -BeGreaterThan 0
|
$var.Mode.Length | Should -BeGreaterThan 0
|
||||||
@ -92,7 +92,7 @@ Describe "Get-ChildItem" -Tags "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
It "Should have mode property populated for protected files on Windows" -Skip:(!$IsWindows) {
|
It "Should have mode property populated for protected files on Windows" -Skip:(!$IsWindows) {
|
||||||
$files = Get-Childitem -Force ~\NT*
|
$files = Get-ChildItem -Force ~\NT*
|
||||||
$files.Count | Should -BeGreaterThan 0
|
$files.Count | Should -BeGreaterThan 0
|
||||||
foreach ($file in $files)
|
foreach ($file in $files)
|
||||||
{
|
{
|
||||||
@ -110,14 +110,14 @@ Describe "Get-ChildItem" -Tags "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
It "Should list hidden files as well when 'Force' parameter is used" {
|
It "Should list hidden files as well when 'Force' parameter is used" {
|
||||||
$files = Get-ChildItem -path $TestDrive -Force
|
$files = Get-ChildItem -Path $TestDrive -Force
|
||||||
$files | Should -Not -BeNullOrEmpty
|
$files | Should -Not -BeNullOrEmpty
|
||||||
$files.Count | Should -Be 6
|
$files.Count | Should -Be 6
|
||||||
$files.Name.Contains($item_F) | Should -BeTrue
|
$files.Name.Contains($item_F) | Should -BeTrue
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Should list only hidden files when 'Hidden' parameter is used" {
|
It "Should list only hidden files when 'Hidden' parameter is used" {
|
||||||
$files = Get-ChildItem -path $TestDrive -Hidden
|
$files = Get-ChildItem -Path $TestDrive -Hidden
|
||||||
$files | Should -Not -BeNullOrEmpty
|
$files | Should -Not -BeNullOrEmpty
|
||||||
$files.Count | Should -Be 1
|
$files.Count | Should -Be 1
|
||||||
$files[0].Name | Should -BeExactly $item_F
|
$files[0].Name | Should -BeExactly $item_F
|
||||||
@ -170,7 +170,7 @@ Describe "Get-ChildItem" -Tags "CI" {
|
|||||||
# VSTS machines don't have a page file
|
# VSTS machines don't have a page file
|
||||||
It "Should give .sys file if the fullpath is specified with hidden and force parameter" -Pending {
|
It "Should give .sys file if the fullpath is specified with hidden and force parameter" -Pending {
|
||||||
# Don't remove!!! It is special test for hidden and opened file with exclusive lock.
|
# Don't remove!!! It is special test for hidden and opened file with exclusive lock.
|
||||||
$file = Get-ChildItem -path "$env:SystemDrive\\pagefile.sys" -Hidden
|
$file = Get-ChildItem -Path "$env:SystemDrive\\pagefile.sys" -Hidden
|
||||||
$file | Should -Not -Be $null
|
$file | Should -Not -Be $null
|
||||||
$file.Count | Should -Be 1
|
$file.Count | Should -Be 1
|
||||||
$file.Name | Should -Be "pagefile.sys"
|
$file.Name | Should -Be "pagefile.sys"
|
||||||
@ -217,7 +217,7 @@ Describe "Get-ChildItem" -Tags "CI" {
|
|||||||
$env:__FOODBAR = 'food'
|
$env:__FOODBAR = 'food'
|
||||||
$env:__foodbar = 'bar'
|
$env:__foodbar = 'bar'
|
||||||
|
|
||||||
$foodbar = Get-Childitem env: | Where-Object {$_.Name -eq '__foodbar'}
|
$foodbar = Get-ChildItem env: | Where-Object {$_.Name -eq '__foodbar'}
|
||||||
$count = if ($IsWindows) { 1 } else { 2 }
|
$count = if ($IsWindows) { 1 } else { 2 }
|
||||||
($foodbar | Measure-Object).Count | Should -Be $count
|
($foodbar | Measure-Object).Count | Should -Be $count
|
||||||
}
|
}
|
||||||
|
@ -472,7 +472,7 @@ public static extern int LCIDToLocaleName(uint localeID, System.Text.StringBuild
|
|||||||
{
|
{
|
||||||
$hal = $null
|
$hal = $null
|
||||||
$systemDirectory = Get-CimClassPropVal Win32_OperatingSystem SystemDirectory
|
$systemDirectory = Get-CimClassPropVal Win32_OperatingSystem SystemDirectory
|
||||||
$halPath = Join-Path -path $systemDirectory -ChildPath "hal.dll"
|
$halPath = Join-Path -Path $systemDirectory -ChildPath "hal.dll"
|
||||||
$query = 'SELECT * FROM CIM_DataFile Where Name="C:\WINDOWS\system32\hal.dll"'
|
$query = 'SELECT * FROM CIM_DataFile Where Name="C:\WINDOWS\system32\hal.dll"'
|
||||||
$query = $query -replace '\\','\\'
|
$query = $query -replace '\\','\\'
|
||||||
$instance = Get-CimInstance -Query $query
|
$instance = Get-CimInstance -Query $query
|
||||||
@ -1049,7 +1049,7 @@ try {
|
|||||||
$ObservedList = $ComputerInformation.$property
|
$ObservedList = $ComputerInformation.$property
|
||||||
$ExpectedList = $Expected.$property
|
$ExpectedList = $Expected.$property
|
||||||
$SpecialPropertyList = ($ObservedList)[0].psobject.properties.name
|
$SpecialPropertyList = ($ObservedList)[0].psobject.properties.name
|
||||||
Compare-Object $ObservedList $ExpectedList -property $SpecialPropertyList | Should -BeNullOrEmpty
|
Compare-Object $ObservedList $ExpectedList -Property $SpecialPropertyList | Should -BeNullOrEmpty
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -28,7 +28,7 @@ Describe "Get-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') {
|
|||||||
$logs.Count | Should -BeGreaterThan 3
|
$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=Get-EventLog -LogName Application -Newest 100 -ErrorAction Stop } | Should -Not -Throw
|
||||||
$result | Should -Not -BeNullOrEmpty
|
$result | Should -Not -BeNullOrEmpty
|
||||||
$result.Length | Should -BeLessThan 100
|
$result.Length | Should -BeLessThan 100
|
||||||
$result[0] | Should -BeOfType EventLogEntry
|
$result[0] | Should -BeOfType EventLogEntry
|
||||||
@ -37,7 +37,7 @@ Describe "Get-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') {
|
|||||||
{ Get-EventLog -LogName System -List -ErrorAction Stop } | Should -Throw -ErrorId "AmbiguousParameterSet,Microsoft.PowerShell.Commands.GetEventLogCommand"
|
{ 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=Get-EventLog -LogName * -ErrorAction Stop } | Should -Not -Throw
|
||||||
$result | Should -Not -BeNullOrEmpty
|
$result | Should -Not -BeNullOrEmpty
|
||||||
$result | Should -BeExactly "Security"
|
$result | Should -BeExactly "Security"
|
||||||
$result.Count | Should -BeGreaterThan 3
|
$result.Count | Should -BeGreaterThan 3
|
||||||
|
@ -60,7 +60,7 @@ Describe "Get-HotFix Tests" -Tag CI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
It "Get-Hotfix can accept ComputerName via pipeline" {
|
It "Get-Hotfix can accept ComputerName via pipeline" {
|
||||||
{ [PSCustomObject]@{ComputerName = 'UnavailableComputer'} | Get-HotFix } | Should -Throw -ErrorID 'Microsoft.PowerShell.Commands.GetHotFixCommand'
|
{ [PSCustomObject]@{ComputerName = 'UnavailableComputer'} | Get-HotFix } | Should -Throw -ErrorId 'Microsoft.PowerShell.Commands.GetHotFixCommand'
|
||||||
[PSCustomObject]@{ComputerName = 'localhost'} | Get-HotFix | Should -Not -BeNullOrEmpty
|
[PSCustomObject]@{ComputerName = 'localhost'} | Get-HotFix | Should -Not -BeNullOrEmpty
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,13 +31,13 @@ Describe "Get-Item" -Tags "CI" {
|
|||||||
$null = New-Item -type file "$TESTDRIVE/file[abc].txt"
|
$null = New-Item -type file "$TESTDRIVE/file[abc].txt"
|
||||||
$null = New-Item -type file "$TESTDRIVE/filea.txt"
|
$null = New-Item -type file "$TESTDRIVE/filea.txt"
|
||||||
# if literalpath is not correct we would see filea.txt
|
# if literalpath is not correct we would see filea.txt
|
||||||
$item = Get-Item -literalpath "$TESTDRIVE/file[abc].txt"
|
$item = Get-Item -LiteralPath "$TESTDRIVE/file[abc].txt"
|
||||||
@($item).Count | Should -Be 1
|
@($item).Count | Should -Be 1
|
||||||
$item.Name | Should -BeExactly 'file[abc].txt'
|
$item.Name | Should -BeExactly 'file[abc].txt'
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Should have mode flags set" {
|
It "Should have mode flags set" {
|
||||||
Get-ChildItem $PSScriptRoot | foreach-object { $_.Mode | Should -Not -BeNullOrEmpty }
|
Get-ChildItem $PSScriptRoot | ForEach-Object { $_.Mode | Should -Not -BeNullOrEmpty }
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Should not return the item unless force is used if hidden" {
|
It "Should not return the item unless force is used if hidden" {
|
||||||
@ -48,11 +48,11 @@ Describe "Get-Item" -Tags "CI" {
|
|||||||
}
|
}
|
||||||
${result} = Get-Item "${hiddenFile}" -ErrorAction SilentlyContinue
|
${result} = Get-Item "${hiddenFile}" -ErrorAction SilentlyContinue
|
||||||
${result} | Should -BeNullOrEmpty
|
${result} | Should -BeNullOrEmpty
|
||||||
${result} = Get-Item -force "${hiddenFile}" -ErrorAction SilentlyContinue
|
${result} = Get-Item -Force "${hiddenFile}" -ErrorAction SilentlyContinue
|
||||||
${result}.FullName | Should -BeExactly ${item}.FullName
|
${result}.FullName | Should -BeExactly ${item}.FullName
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Should get properties for special reparse points" -skip:$skipNotWindows {
|
It "Should get properties for special reparse points" -Skip:$skipNotWindows {
|
||||||
$result = Get-Item -Path $HOME/Cookies -Force
|
$result = Get-Item -Path $HOME/Cookies -Force
|
||||||
$result.LinkType | Should -BeExactly "Junction"
|
$result.LinkType | Should -BeExactly "Junction"
|
||||||
$result.Target | Should -Not -BeNullOrEmpty
|
$result.Target | Should -Not -BeNullOrEmpty
|
||||||
@ -89,7 +89,7 @@ Describe "Get-Item" -Tags "CI" {
|
|||||||
$result.Name | Should -BeExactly "file2.txt"
|
$result.Name | Should -BeExactly "file2.txt"
|
||||||
}
|
}
|
||||||
It "Should respect combinations of filter, include, and exclude" {
|
It "Should respect combinations of filter, include, and exclude" {
|
||||||
$result = get-item "${testBaseDir}/*" -filter *.txt -include "file[12].txt" -exclude file2.txt
|
$result = Get-Item "${testBaseDir}/*" -Filter *.txt -Include "file[12].txt" -Exclude file2.txt
|
||||||
($result).Count | Should -Be 1
|
($result).Count | Should -Be 1
|
||||||
$result.Name | Should -BeExactly "file1.txt"
|
$result.Name | Should -BeExactly "file1.txt"
|
||||||
}
|
}
|
||||||
@ -114,10 +114,10 @@ Describe "Get-Item" -Tags "CI" {
|
|||||||
$altStreamPath = "$TESTDRIVE/altStream.txt"
|
$altStreamPath = "$TESTDRIVE/altStream.txt"
|
||||||
$stringData = "test data"
|
$stringData = "test data"
|
||||||
$streamName = "test"
|
$streamName = "test"
|
||||||
$item = new-item -type file $altStreamPath
|
$item = New-Item -type file $altStreamPath
|
||||||
Set-Content -path $altStreamPath -Stream $streamName -Value $stringData
|
Set-Content -Path $altStreamPath -Stream $streamName -Value $stringData
|
||||||
}
|
}
|
||||||
It "Should find an alternate stream if present" -skip:$skipNotWindows {
|
It "Should find an alternate stream if present" -Skip:$skipNotWindows {
|
||||||
$result = Get-Item $altStreamPath -Stream $streamName
|
$result = Get-Item $altStreamPath -Stream $streamName
|
||||||
$result.Length | Should -Be ($stringData.Length + [Environment]::NewLine.Length)
|
$result.Length | Should -Be ($stringData.Length + [Environment]::NewLine.Length)
|
||||||
$result.Stream | Should -Be $streamName
|
$result.Stream | Should -Be $streamName
|
||||||
@ -125,13 +125,13 @@ Describe "Get-Item" -Tags "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Context "Registry Provider" {
|
Context "Registry Provider" {
|
||||||
It "Can retrieve an item from registry" -skip:$skipNotWindows {
|
It "Can retrieve an item from registry" -Skip:$skipNotWindows {
|
||||||
${result} = Get-Item HKLM:/Software
|
${result} = Get-Item HKLM:/Software
|
||||||
${result} | Should -BeOfType Microsoft.Win32.RegistryKey
|
${result} | Should -BeOfType Microsoft.Win32.RegistryKey
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Context "Environment provider" -tag "CI" {
|
Context "Environment provider" -Tag "CI" {
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
$env:testvar="b"
|
$env:testvar="b"
|
||||||
$env:testVar="a"
|
$env:testVar="a"
|
||||||
@ -143,7 +143,7 @@ Describe "Get-Item" -Tags "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
It "get-item testVar" {
|
It "get-item testVar" {
|
||||||
(get-item env:\testVar).Value | Should -BeExactly "a"
|
(Get-Item env:\testVar).Value | Should -BeExactly "a"
|
||||||
}
|
}
|
||||||
|
|
||||||
It "get-item is case-sensitive/insensitive as appropriate" {
|
It "get-item is case-sensitive/insensitive as appropriate" {
|
||||||
@ -153,7 +153,7 @@ Describe "Get-Item" -Tags "CI" {
|
|||||||
$expectedValue = "a"
|
$expectedValue = "a"
|
||||||
}
|
}
|
||||||
|
|
||||||
(get-item env:\testvar).Value | Should -BeExactly $expectedValue
|
(Get-Item env:\testvar).Value | Should -BeExactly $expectedValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -165,7 +165,7 @@ Describe "Get-Item environment provider on Windows with accidental case-variant
|
|||||||
AfterAll {
|
AfterAll {
|
||||||
$env:testVar = $null
|
$env:testVar = $null
|
||||||
}
|
}
|
||||||
It "Reports the effective value among accidental case-variant duplicates on Windows" -skip:$skipNotWindows {
|
It "Reports the effective value among accidental case-variant duplicates on Windows" -Skip:$skipNotWindows {
|
||||||
if (-not (Get-Command -ErrorAction Ignore node.exe)) {
|
if (-not (Get-Command -ErrorAction Ignore node.exe)) {
|
||||||
Write-Warning "Test skipped, because prerequisite Node.js is not installed."
|
Write-Warning "Test skipped, because prerequisite Node.js is not installed."
|
||||||
} else {
|
} else {
|
||||||
|
@ -7,7 +7,7 @@ Describe "Get-Location" -Tags "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AfterEach {
|
AfterEach {
|
||||||
Pop-location
|
Pop-Location
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Should list the output of the current working directory" {
|
It "Should list the output of the current working directory" {
|
||||||
|
@ -50,7 +50,7 @@ Describe "Get-Process" -Tags "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
It "Should have not empty Name flags set for Get-Process object" -Pending:$IsMacOS {
|
It "Should have not empty Name flags set for Get-Process object" -Pending:$IsMacOS {
|
||||||
$ps | foreach-object { $_.Name | Should -Not -BeNullOrEmpty }
|
$ps | ForEach-Object { $_.Name | Should -Not -BeNullOrEmpty }
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Should throw an error for non existing process id." {
|
It "Should throw an error for non existing process id." {
|
||||||
@ -59,7 +59,7 @@ Describe "Get-Process" -Tags "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
It "Should throw an exception when process id is null." {
|
It "Should throw an exception when process id is null." {
|
||||||
{ Get-Process -id $null } | Should -Throw -ErrorId "ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetProcessCommand"
|
{ Get-Process -Id $null } | Should -Throw -ErrorId "ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetProcessCommand"
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Should throw an exception when -InputObject parameter is null." {
|
It "Should throw an exception when -InputObject parameter is null." {
|
||||||
@ -118,12 +118,12 @@ Describe "Get-Process Formatting" -Tags "Feature" {
|
|||||||
|
|
||||||
Describe "Process Parent property" -Tags "CI" {
|
Describe "Process Parent property" -Tags "CI" {
|
||||||
It "Has Parent process property" {
|
It "Has Parent process property" {
|
||||||
$powershellexe = (get-process -id $PID).mainmodule.filename
|
$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" {
|
It "Has valid parent process ID property" {
|
||||||
$powershellexe = (get-process -id $PID).mainmodule.filename
|
$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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,10 +55,10 @@ Describe "Get-Service cmdlet tests" -Tags "CI" {
|
|||||||
@{ script = { Get-Service -DisplayName Net* } ; expected = { Get-Service | Where-Object { $_.DisplayName -like 'Net*' } } },
|
@{ script = { Get-Service -DisplayName Net* } ; expected = { Get-Service | Where-Object { $_.DisplayName -like 'Net*' } } },
|
||||||
@{ script = { Get-Service -Include Net* -Exclude *logon } ; expected = { Get-Service | Where-Object { $_.Name -match '^net.*?(?<!logon)$' } } }
|
@{ script = { Get-Service -Include Net* -Exclude *logon } ; expected = { Get-Service | Where-Object { $_.Name -match '^net.*?(?<!logon)$' } } }
|
||||||
@{ script = { Get-Service -Name Net* | Get-Service } ; expected = { Get-Service -Name Net* } },
|
@{ script = { Get-Service -Name Net* | Get-Service } ; expected = { Get-Service -Name Net* } },
|
||||||
@{ script = { Get-Service -Name "$(new-guid)*" } ; expected = $null },
|
@{ script = { Get-Service -Name "$(New-Guid)*" } ; expected = $null },
|
||||||
@{ script = { Get-Service -DisplayName "$(new-guid)*" } ; expected = $null },
|
@{ script = { Get-Service -DisplayName "$(New-Guid)*" } ; expected = $null },
|
||||||
@{ script = { Get-Service -DependentServices -Name winmgmt }; expected = { (Get-Service -Name winmgmt).DependentServices } },
|
@{ script = { Get-Service -DependentServices -Name winmgmt }; expected = { (Get-Service -Name winmgmt).DependentServices } },
|
||||||
@{ script = { Get-Service -RequiredServices -Name winmgmt } ; expected = { (Get-Service -name winmgmt).RequiredServices } }
|
@{ script = { Get-Service -RequiredServices -Name winmgmt } ; expected = { (Get-Service -Name winmgmt).RequiredServices } }
|
||||||
) {
|
) {
|
||||||
param($script, $expected)
|
param($script, $expected)
|
||||||
$services = & $script
|
$services = & $script
|
||||||
@ -66,16 +66,16 @@ Describe "Get-Service cmdlet tests" -Tags "CI" {
|
|||||||
$servicesCheck = & $expected
|
$servicesCheck = & $expected
|
||||||
}
|
}
|
||||||
if ($servicesCheck -ne $null) {
|
if ($servicesCheck -ne $null) {
|
||||||
Compare-object $services $servicesCheck | Out-String | Should -BeNullOrEmpty
|
Compare-Object $services $servicesCheck | Out-String | Should -BeNullOrEmpty
|
||||||
} else {
|
} else {
|
||||||
$services | Should -BeNullOrEmpty
|
$services | Should -BeNullOrEmpty
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Get-Service fails for non-existing service using '<script>'" -TestCases @(
|
It "Get-Service fails for non-existing service using '<script>'" -TestCases @(
|
||||||
@{ script = { Get-Service -Name (new-guid) -ErrorAction Stop} ;
|
@{ script = { Get-Service -Name (New-Guid) -ErrorAction Stop} ;
|
||||||
ErrorId = "NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.GetServiceCommand" },
|
ErrorId = "NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.GetServiceCommand" },
|
||||||
@{ script = { Get-Service -DisplayName (new-guid) -ErrorAction Stop};
|
@{ script = { Get-Service -DisplayName (New-Guid) -ErrorAction Stop};
|
||||||
ErrorId = "NoServiceFoundForGivenDisplayName,Microsoft.PowerShell.Commands.GetServiceCommand" }
|
ErrorId = "NoServiceFoundForGivenDisplayName,Microsoft.PowerShell.Commands.GetServiceCommand" }
|
||||||
) {
|
) {
|
||||||
param($script,$errorid)
|
param($script,$errorid)
|
||||||
|
@ -2,20 +2,20 @@
|
|||||||
# Licensed under the MIT License.
|
# Licensed under the MIT License.
|
||||||
Describe "Simple ItemProperty Tests" -Tag "CI" {
|
Describe "Simple ItemProperty Tests" -Tag "CI" {
|
||||||
It "Can retrieve the PropertyValue with Get-ItemPropertyValue" {
|
It "Can retrieve the PropertyValue with Get-ItemPropertyValue" {
|
||||||
Get-ItemPropertyValue -path $TESTDRIVE -Name Attributes | Should -Be "Directory"
|
Get-ItemPropertyValue -Path $TESTDRIVE -Name Attributes | Should -Be "Directory"
|
||||||
}
|
}
|
||||||
It "Can clear the PropertyValue with Clear-ItemProperty" {
|
It "Can clear the PropertyValue with Clear-ItemProperty" {
|
||||||
setup -f file1.txt
|
Setup -f file1.txt
|
||||||
Set-ItemProperty $TESTDRIVE/file1.txt -Name Attributes -Value ReadOnly
|
Set-ItemProperty $TESTDRIVE/file1.txt -Name Attributes -Value ReadOnly
|
||||||
Get-ItemPropertyValue -path $TESTDRIVE/file1.txt -Name Attributes | Should -Match "ReadOnly"
|
Get-ItemPropertyValue -Path $TESTDRIVE/file1.txt -Name Attributes | Should -Match "ReadOnly"
|
||||||
Clear-ItemProperty $TESTDRIVE/file1.txt -Name Attributes
|
Clear-ItemProperty $TESTDRIVE/file1.txt -Name Attributes
|
||||||
Get-ItemPropertyValue -path $TESTDRIVE/file1.txt -Name Attributes | Should -Not -Match "ReadOnly"
|
Get-ItemPropertyValue -Path $TESTDRIVE/file1.txt -Name Attributes | Should -Not -Match "ReadOnly"
|
||||||
}
|
}
|
||||||
# these cmdlets are targeted at the windows registry, and don't have an linux equivalent
|
# these cmdlets are targeted at the windows registry, and don't have an linux equivalent
|
||||||
Context "Registry targeted cmdlets" {
|
Context "Registry targeted cmdlets" {
|
||||||
It "Copy ItemProperty" -pending { }
|
It "Copy ItemProperty" -Pending { }
|
||||||
It "Move ItemProperty" -pending { }
|
It "Move ItemProperty" -Pending { }
|
||||||
It "New ItemProperty" -pending { }
|
It "New ItemProperty" -Pending { }
|
||||||
It "Rename ItemProperty" -pending { }
|
It "Rename ItemProperty" -Pending { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,20 +10,20 @@ Describe "Join-Path cmdlet tests" -Tags "CI" {
|
|||||||
}
|
}
|
||||||
It "should output multiple paths when called with multiple -Path targets" {
|
It "should output multiple paths when called with multiple -Path targets" {
|
||||||
Setup -Dir SubDir1
|
Setup -Dir SubDir1
|
||||||
(Join-Path -Path TestDrive:,$TestDrive -ChildPath "SubDir1" -resolve).Length | Should -Be 2
|
(Join-Path -Path TestDrive:,$TestDrive -ChildPath "SubDir1" -Resolve).Length | Should -Be 2
|
||||||
}
|
}
|
||||||
It "should throw 'DriveNotFound' when called with -Resolve and drive does not exist" {
|
It "should throw 'DriveNotFound' when called with -Resolve and drive does not exist" {
|
||||||
{ Join-Path bogusdrive:\\somedir otherdir -resolve -ErrorAction Stop; Throw "Previous statement unexpectedly succeeded..." } |
|
{ Join-Path bogusdrive:\\somedir otherdir -Resolve -ErrorAction Stop; Throw "Previous statement unexpectedly succeeded..." } |
|
||||||
Should -Throw -ErrorId "DriveNotFound,Microsoft.PowerShell.Commands.JoinPathCommand"
|
Should -Throw -ErrorId "DriveNotFound,Microsoft.PowerShell.Commands.JoinPathCommand"
|
||||||
}
|
}
|
||||||
It "should throw 'PathNotFound' when called with -Resolve and item does not exist" {
|
It "should throw 'PathNotFound' when called with -Resolve and item does not exist" {
|
||||||
{ Join-Path "Bogus" "Path" -resolve -ErrorAction Stop; Throw "Previous statement unexpectedly succeeded..." } |
|
{ Join-Path "Bogus" "Path" -Resolve -ErrorAction Stop; Throw "Previous statement unexpectedly succeeded..." } |
|
||||||
Should -Throw -ErrorId "PathNotFound,Microsoft.PowerShell.Commands.JoinPathCommand"
|
Should -Throw -ErrorId "PathNotFound,Microsoft.PowerShell.Commands.JoinPathCommand"
|
||||||
}
|
}
|
||||||
#[BugId(BugDatabase.WindowsOutOfBandReleases, 905237)] Note: Result should be the same on non-Windows platforms too
|
#[BugId(BugDatabase.WindowsOutOfBandReleases, 905237)] Note: Result should be the same on non-Windows platforms too
|
||||||
It "should return one object when called with a Windows FileSystem::Redirector" {
|
It "should return one object when called with a Windows FileSystem::Redirector" {
|
||||||
set-location ("env:"+$SepChar)
|
Set-Location ("env:"+$SepChar)
|
||||||
$result=join-path FileSystem::windir system32
|
$result=Join-Path FileSystem::windir system32
|
||||||
$result.Count | Should -Be 1
|
$result.Count | Should -Be 1
|
||||||
$result | Should -BeExactly ("FileSystem::windir"+$SepChar+"system32")
|
$result | Should -BeExactly ("FileSystem::windir"+$SepChar+"system32")
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
Describe "Move-Item tests" -Tag "CI" {
|
Describe "Move-Item tests" -Tag "CI" {
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
$content = "This is content"
|
$content = "This is content"
|
||||||
Setup -f originalfile.txt -content "This is content"
|
Setup -f originalfile.txt -Content "This is content"
|
||||||
$source = "$TESTDRIVE/originalfile.txt"
|
$source = "$TESTDRIVE/originalfile.txt"
|
||||||
$target = "$TESTDRIVE/ItemWhichHasBeenMoved.txt"
|
$target = "$TESTDRIVE/ItemWhichHasBeenMoved.txt"
|
||||||
Setup -f [orig-file].txt -content "This is not content"
|
Setup -f [orig-file].txt -Content "This is not content"
|
||||||
$sourceSp = "$TestDrive/``[orig-file``].txt"
|
$sourceSp = "$TestDrive/``[orig-file``].txt"
|
||||||
$targetSpName = "$TestDrive/ItemWhichHasBeen[Moved].txt"
|
$targetSpName = "$TestDrive/ItemWhichHasBeen[Moved].txt"
|
||||||
$targetSp = "$TestDrive/ItemWhichHasBeen``[Moved``].txt"
|
$targetSp = "$TestDrive/ItemWhichHasBeen``[Moved``].txt"
|
||||||
|
@ -20,34 +20,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
|
{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
|
{Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventId 1 -ErrorAction Stop} | Should -Not -Throw
|
||||||
$result=Get-EventLog -LogName TestLog
|
$result=Get-EventLog -LogName TestLog
|
||||||
$result.Count | Should -Be 1
|
$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
|
{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
|
{Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventId 1 -ErrorAction Stop} | Should -Not -Throw
|
||||||
$result=Get-EventLog -LogName TestLog
|
$result=Get-EventLog -LogName TestLog
|
||||||
$result.Count | Should -Be 1
|
$result.Count | Should -Be 1
|
||||||
$result.EventID | 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
|
{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
|
{Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventId 2 -ErrorAction Stop} | Should -Not -Throw
|
||||||
$result=Get-EventLog -LogName TestLog
|
$result=Get-EventLog -LogName TestLog
|
||||||
$result.Count | Should -Be 1
|
$result.Count | Should -Be 1
|
||||||
$result.EventID | Should -Be 2
|
$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
|
{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
|
{Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventId 3 -ErrorAction Stop} | Should -Not -Throw
|
||||||
$result=Get-EventLog -LogName TestLog
|
$result=Get-EventLog -LogName TestLog
|
||||||
$result.Count | Should -Be 1
|
$result.Count | Should -Be 1
|
||||||
$result.EventID | Should -Be 3
|
$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
|
{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
|
{Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventId 4 -ErrorAction Stop} | Should -Not -Throw
|
||||||
$result=Get-EventLog -LogName TestLog
|
$result=Get-EventLog -LogName TestLog
|
||||||
$result.Count | Should -Be 1
|
$result.Count | Should -Be 1
|
||||||
$result.EventID | Should -Be 4
|
$result.EventID | Should -Be 4
|
||||||
|
@ -17,11 +17,11 @@ Describe "Tests for New-PSDrive cmdlet." -Tag "CI","RequireAdminOnWindows" {
|
|||||||
{ New-PSDrive -Name $PSDriveName -PSProvider FileSystem -Root $RemoteShare -Persist -ErrorAction Stop } | Should -Not -Throw
|
{ New-PSDrive -Name $PSDriveName -PSProvider FileSystem -Root $RemoteShare -Persist -ErrorAction Stop } | Should -Not -Throw
|
||||||
}
|
}
|
||||||
|
|
||||||
it "Should throw exception if root is not a remote share." -Skip:(-not $IsWindows) {
|
It "Should throw exception if root is not a remote share." -Skip:(-not $IsWindows) {
|
||||||
{ New-PSDrive -Name $PSDriveName -PSProvider FileSystem -Root "TestDrive:\" -Persist -ErrorAction Stop } | Should -Throw -ErrorId 'DriveRootNotNetworkPath'
|
{ New-PSDrive -Name $PSDriveName -PSProvider FileSystem -Root "TestDrive:\" -Persist -ErrorAction Stop } | Should -Throw -ErrorId 'DriveRootNotNetworkPath'
|
||||||
}
|
}
|
||||||
|
|
||||||
it "Should throw exception if PSDrive is not a drive letter supported by operating system." -Skip:(-not $IsWindows) {
|
It "Should throw exception if PSDrive is not a drive letter supported by operating system." -Skip:(-not $IsWindows) {
|
||||||
$PSDriveName = 'AB'
|
$PSDriveName = 'AB'
|
||||||
{ New-PSDrive -Name $PSDriveName -PSProvider FileSystem -Root $RemoteShare -Persist -ErrorAction Stop } | Should -Throw -ErrorId 'DriveNameNotSupportedForPersistence'
|
{ New-PSDrive -Name $PSDriveName -PSProvider FileSystem -Root $RemoteShare -Persist -ErrorAction Stop } | Should -Throw -ErrorId 'DriveNameNotSupportedForPersistence'
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ Describe "Basic Registry Provider Tests" -Tags @("CI", "RequireAdminOnWindows")
|
|||||||
|
|
||||||
It "Verify Rename-Item" {
|
It "Verify Rename-Item" {
|
||||||
$existBefore = Test-Path $testKey
|
$existBefore = Test-Path $testKey
|
||||||
$renamedKey = Rename-Item -path $testKey -NewName "RenamedKey" -PassThru
|
$renamedKey = Rename-Item -Path $testKey -NewName "RenamedKey" -PassThru
|
||||||
$existAfter = Test-Path $testKey
|
$existAfter = Test-Path $testKey
|
||||||
$existBefore | Should -BeTrue
|
$existBefore | Should -BeTrue
|
||||||
$existAfter | Should -BeFalse
|
$existAfter | Should -BeFalse
|
||||||
@ -260,13 +260,13 @@ Describe "Extended Registry Provider Tests" -Tags @("Feature", "RequireAdminOnWi
|
|||||||
}
|
}
|
||||||
|
|
||||||
It "Verify Confirm can be bypassed" {
|
It "Verify Confirm can be bypassed" {
|
||||||
$result = New-ItemProperty -Path $testKey -Name $testPropertyName -Value $testPropertyValue -force -Confirm:$false
|
$result = New-ItemProperty -Path $testKey -Name $testPropertyName -Value $testPropertyValue -Force -Confirm:$false
|
||||||
$result."$testPropertyName" | Should -Be $testPropertyValue
|
$result."$testPropertyName" | Should -Be $testPropertyValue
|
||||||
$result.PSChildName | Should -BeExactly $testKey
|
$result.PSChildName | Should -BeExactly $testKey
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Verify WhatIf" {
|
It "Verify WhatIf" {
|
||||||
$result = New-ItemProperty -Path $testKey -Name $testPropertyName -Value $testPropertyValue -whatif
|
$result = New-ItemProperty -Path $testKey -Name $testPropertyName -Value $testPropertyValue -WhatIf
|
||||||
$result | Should -BeNullOrEmpty
|
$result | Should -BeNullOrEmpty
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,19 +16,19 @@ Describe "New-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') {
|
|||||||
if ($IsNotSkipped) {
|
if ($IsNotSkipped) {
|
||||||
Remove-EventLog -LogName TestLog -ErrorAction Ignore
|
Remove-EventLog -LogName TestLog -ErrorAction Ignore
|
||||||
{New-EventLog -LogName TestLog -Source TestSource -ErrorAction Stop} | Should -Not -Throw
|
{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
|
{Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventId 1 -ErrorAction Stop} | Should -Not -Throw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#CmdLet is NYI - change to -Skip:($NonWinAdmin) when implemented
|
#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
|
{ 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"
|
{ 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"
|
{ Get-EventLog -LogName TestLog -ErrorAction Stop } | Should -Throw -ErrorId "System.InvalidOperationException,Microsoft.PowerShell.Commands.GetEventLogCommand"
|
||||||
}
|
}
|
||||||
#CmdLet is NYI - change to -Skip:($NonWinAdmin) when implemented
|
#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
|
{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"
|
{ 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"
|
{ Get-EventLog -LogName TestLog -ErrorAction Stop; } | Should -Throw -ErrorId "System.InvalidOperationException,Microsoft.PowerShell.Commands.GetEventLogCommand"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,9 +75,9 @@ Describe "Remove-Item" -Tags "CI" {
|
|||||||
# Delete the specific string
|
# Delete the specific string
|
||||||
Remove-Item (Join-Path -Path $testpath -ChildPath "*") -Include file*.txt
|
Remove-Item (Join-Path -Path $testpath -ChildPath "*") -Include file*.txt
|
||||||
# validate that the string under test was deleted, and the nonmatching strings still exist
|
# validate that the string under test was deleted, and the nonmatching strings still exist
|
||||||
Test-path (Join-Path -Path $testpath -ChildPath file1.txt) | Should -BeFalse
|
Test-Path (Join-Path -Path $testpath -ChildPath file1.txt) | Should -BeFalse
|
||||||
Test-path (Join-Path -Path $testpath -ChildPath file2.txt) | Should -BeFalse
|
Test-Path (Join-Path -Path $testpath -ChildPath file2.txt) | Should -BeFalse
|
||||||
Test-path (Join-Path -Path $testpath -ChildPath file3.txt) | Should -BeFalse
|
Test-Path (Join-Path -Path $testpath -ChildPath file3.txt) | Should -BeFalse
|
||||||
Test-Path $testfilepath | Should -BeTrue
|
Test-Path $testfilepath | Should -BeTrue
|
||||||
|
|
||||||
# Delete the non-matching strings
|
# Delete the non-matching strings
|
||||||
@ -131,7 +131,7 @@ Describe "Remove-Item" -Tags "CI" {
|
|||||||
New-Item -Name $testfile -Path $testsubdirectory -ItemType "file" -Value "lorem ipsum"
|
New-Item -Name $testfile -Path $testsubdirectory -ItemType "file" -Value "lorem ipsum"
|
||||||
|
|
||||||
$complexDirectory = Join-Path -Path $testsubdirectory -ChildPath $testfile
|
$complexDirectory = Join-Path -Path $testsubdirectory -ChildPath $testfile
|
||||||
test-path $complexDirectory | Should -BeTrue
|
Test-Path $complexDirectory | Should -BeTrue
|
||||||
|
|
||||||
{ Remove-Item $testdirectory -Recurse} | Should -Not -Throw
|
{ Remove-Item $testdirectory -Recurse} | Should -Not -Throw
|
||||||
|
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
# Licensed under the MIT License.
|
# Licensed under the MIT License.
|
||||||
Describe "Rename-Item tests" -Tag "CI" {
|
Describe "Rename-Item tests" -Tag "CI" {
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
Setup -f originalFile.txt -content "This is content"
|
Setup -f originalFile.txt -Content "This is content"
|
||||||
$source = "$TESTDRIVE/originalFile.txt"
|
$source = "$TESTDRIVE/originalFile.txt"
|
||||||
$target = "$TESTDRIVE/ItemWhichHasBeenRenamed.txt"
|
$target = "$TESTDRIVE/ItemWhichHasBeenRenamed.txt"
|
||||||
Setup -f [orig-file].txt -content "This is not content"
|
Setup -f [orig-file].txt -Content "This is not content"
|
||||||
$sourceSp = "$TestDrive/``[orig-file``].txt"
|
$sourceSp = "$TestDrive/``[orig-file``].txt"
|
||||||
$targetSpName = "ItemWhichHasBeen[Renamed].txt"
|
$targetSpName = "ItemWhichHasBeen[Renamed].txt"
|
||||||
$targetSp = "$TestDrive/ItemWhichHasBeen``[Renamed``].txt"
|
$targetSp = "$TestDrive/ItemWhichHasBeen``[Renamed``].txt"
|
||||||
@ -14,8 +14,8 @@ Describe "Rename-Item tests" -Tag "CI" {
|
|||||||
}
|
}
|
||||||
It "Rename-Item will rename a file" {
|
It "Rename-Item will rename a file" {
|
||||||
Rename-Item $source $target
|
Rename-Item $source $target
|
||||||
test-path $source | Should -BeFalse
|
Test-Path $source | Should -BeFalse
|
||||||
test-path $target | Should -BeTrue
|
Test-Path $target | Should -BeTrue
|
||||||
"$target" | Should -FileContentMatchExactly "This is content"
|
"$target" | Should -FileContentMatchExactly "This is content"
|
||||||
}
|
}
|
||||||
It "Rename-Item will rename a file when path contains special char" {
|
It "Rename-Item will rename a file when path contains special char" {
|
||||||
@ -31,7 +31,7 @@ Describe "Rename-Item tests" -Tag "CI" {
|
|||||||
$oldSp = "$wdSp/$oldSpBName"
|
$oldSp = "$wdSp/$oldSpBName"
|
||||||
$newSpName = "[renamed]file.txt"
|
$newSpName = "[renamed]file.txt"
|
||||||
$newSp = "$wdSp/``[renamed``]file.txt"
|
$newSp = "$wdSp/``[renamed``]file.txt"
|
||||||
In $wdSp -Execute {
|
In $wdSp -execute {
|
||||||
$null = New-Item -Name $oldSpName -ItemType File -Value $content -Force
|
$null = New-Item -Name $oldSpName -ItemType File -Value $content -Force
|
||||||
Rename-Item -Path $oldSpBName $newSpName
|
Rename-Item -Path $oldSpBName $newSpName
|
||||||
}
|
}
|
||||||
@ -46,7 +46,7 @@ Describe "Rename-Item tests" -Tag "CI" {
|
|||||||
$oldSp = "$wdSp/$oldSpBName"
|
$oldSp = "$wdSp/$oldSpBName"
|
||||||
$newSpName = "[renamed]file2.txt"
|
$newSpName = "[renamed]file2.txt"
|
||||||
$newSp = "$wdSp/``[renamed``]file2.txt"
|
$newSp = "$wdSp/``[renamed``]file2.txt"
|
||||||
In $wdSp -Execute {
|
In $wdSp -execute {
|
||||||
$null = New-Item -Name $oldSpName -ItemType File -Value $content -Force
|
$null = New-Item -Name $oldSpName -ItemType File -Value $content -Force
|
||||||
Rename-Item -LiteralPath $oldSpName $newSpName
|
Rename-Item -LiteralPath $oldSpName $newSpName
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ try
|
|||||||
}
|
}
|
||||||
|
|
||||||
It "Should not support timeout on Unix" -Skip:($IsWindows) {
|
It "Should not support timeout on Unix" -Skip:($IsWindows) {
|
||||||
{ Restart-Computer -timeout 3 -ErrorAction Stop } | Should -Throw -ErrorId "NamedParameterNotFound,Microsoft.PowerShell.Commands.RestartComputerCommand"
|
{ Restart-Computer -Timeout 3 -ErrorAction Stop } | Should -Throw -ErrorId "NamedParameterNotFound,Microsoft.PowerShell.Commands.RestartComputerCommand"
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Should not support Delay on Unix" -Skip:($IsWindows) {
|
It "Should not support Delay on Unix" -Skip:($IsWindows) {
|
||||||
@ -90,12 +90,12 @@ try
|
|||||||
|
|
||||||
It "Should not support timeout on localhost" -Skip:(!$IsWindows) {
|
It "Should not support timeout on localhost" -Skip:(!$IsWindows) {
|
||||||
Set-TesthookResult -testhookName $restartTesthookResultName -value $defaultResultValue
|
Set-TesthookResult -testhookName $restartTesthookResultName -value $defaultResultValue
|
||||||
{ Restart-Computer -timeout 3 -ErrorAction Stop } | Should -Throw -ErrorId "RestartComputerInvalidParameter,Microsoft.PowerShell.Commands.RestartComputerCommand"
|
{ Restart-Computer -Timeout 3 -ErrorAction Stop } | Should -Throw -ErrorId "RestartComputerInvalidParameter,Microsoft.PowerShell.Commands.RestartComputerCommand"
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Should not support timeout on localhost" -Skip:(!$IsWindows) {
|
It "Should not support timeout on localhost" -Skip:(!$IsWindows) {
|
||||||
Set-TesthookResult -testhookName $restartTesthookResultName -value $defaultResultValue
|
Set-TesthookResult -testhookName $restartTesthookResultName -value $defaultResultValue
|
||||||
{ Restart-Computer -timeout 3 -ErrorAction Stop } | Should -Throw -ErrorId "RestartComputerInvalidParameter,Microsoft.PowerShell.Commands.RestartComputerCommand"
|
{ Restart-Computer -Timeout 3 -ErrorAction Stop } | Should -Throw -ErrorId "RestartComputerInvalidParameter,Microsoft.PowerShell.Commands.RestartComputerCommand"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ Describe "Set-Content cmdlet tests" -Tags "CI" {
|
|||||||
It "should throw 'ParameterArgumentValidationErrorNullNotAllowed' when -Path is `$()" {
|
It "should throw 'ParameterArgumentValidationErrorNullNotAllowed' when -Path is `$()" {
|
||||||
{ Set-Content -Path $() -Value "ShouldNotWorkBecausePathIsInvalid" -ErrorAction Stop } | Should -Throw -ErrorId "ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.SetContentCommand"
|
{ Set-Content -Path $() -Value "ShouldNotWorkBecausePathIsInvalid" -ErrorAction Stop } | Should -Throw -ErrorId "ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.SetContentCommand"
|
||||||
}
|
}
|
||||||
It "should throw 'PSNotSupportedException' when you Set-Content to an unsupported provider" -skip:$skipRegistry {
|
It "should throw 'PSNotSupportedException' when you Set-Content to an unsupported provider" -Skip:$skipRegistry {
|
||||||
{ Set-Content -Path HKLM:\\software\\microsoft -Value "ShouldNotWorkBecausePathIsUnsupported" -ErrorAction Stop } | Should -Throw -ErrorId "NotSupported,Microsoft.PowerShell.Commands.SetContentCommand"
|
{ Set-Content -Path HKLM:\\software\\microsoft -Value "ShouldNotWorkBecausePathIsUnsupported" -ErrorAction Stop } | Should -Throw -ErrorId "NotSupported,Microsoft.PowerShell.Commands.SetContentCommand"
|
||||||
}
|
}
|
||||||
#[BugId(BugDatabase.WindowsOutOfBandReleases, 9058182)]
|
#[BugId(BugDatabase.WindowsOutOfBandReleases, 9058182)]
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
# Copyright (c) Microsoft Corporation.
|
# Copyright (c) Microsoft Corporation.
|
||||||
# Licensed under the MIT License.
|
# Licensed under the MIT License.
|
||||||
Describe "Set-Item" -Tag "CI" {
|
Describe "Set-Item" -Tag "CI" {
|
||||||
$testCases = @{ Path = "variable:SetItemTestCase"; Value = "TestData"; Validate = { $SetItemTestCase | Should -Be "TestData" }; Reset = {remove-item variable:SetItemTestCase} },
|
$testCases = @{ Path = "variable:SetItemTestCase"; Value = "TestData"; Validate = { $SetItemTestCase | Should -Be "TestData" }; Reset = {Remove-Item variable:SetItemTestCase} },
|
||||||
@{ Path = "alias:SetItemTestCase"; Value = "Get-Alias"; Validate = { (Get-Alias SetItemTestCase).Definition | Should -Be "Get-Alias"}; Reset = { remove-item alias:SetItemTestCase } },
|
@{ Path = "alias:SetItemTestCase"; Value = "Get-Alias"; Validate = { (Get-Alias SetItemTestCase).Definition | Should -Be "Get-Alias"}; Reset = { Remove-Item alias:SetItemTestCase } },
|
||||||
@{ Path = "function:SetItemTestCase"; Value = { 1 }; Validate = { SetItemTestCase | Should -Be 1 }; Reset = { remove-item function:SetItemTestCase } },
|
@{ Path = "function:SetItemTestCase"; Value = { 1 }; Validate = { SetItemTestCase | Should -Be 1 }; Reset = { Remove-Item function:SetItemTestCase } },
|
||||||
@{ Path = "env:SetItemTestCase"; Value = { 1 }; Validate = { $env:SetItemTestCase | Should -Be 1 }; Reset = { remove-item env:SetItemTestCase } }
|
@{ Path = "env:SetItemTestCase"; Value = { 1 }; Validate = { $env:SetItemTestCase | Should -Be 1 }; Reset = { Remove-Item env:SetItemTestCase } }
|
||||||
|
|
||||||
It "Set-Item should be able to handle <Path>" -TestCase $testCases {
|
It "Set-Item should be able to handle <Path>" -TestCase $testCases {
|
||||||
param ( $Path, $Value, $Validate, $Reset )
|
param ( $Path, $Value, $Validate, $Reset )
|
||||||
Set-item -path $path -Value $value
|
Set-Item -Path $path -Value $value
|
||||||
try {
|
try {
|
||||||
& $Validate
|
& $Validate
|
||||||
}
|
}
|
||||||
|
@ -80,14 +80,14 @@ Describe "Start-Process" -Tag "Feature","RequireAdminOnWindows" {
|
|||||||
|
|
||||||
It "Should handle stdout redirection without error" {
|
It "Should handle stdout redirection without error" {
|
||||||
$process = Start-Process ping -ArgumentList $pingParam -Wait -RedirectStandardOutput $tempFile @extraArgs
|
$process = Start-Process ping -ArgumentList $pingParam -Wait -RedirectStandardOutput $tempFile @extraArgs
|
||||||
$dirEntry = get-childitem $tempFile
|
$dirEntry = Get-ChildItem $tempFile
|
||||||
$dirEntry.Length | Should -BeGreaterThan 0
|
$dirEntry.Length | Should -BeGreaterThan 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Marking this test 'pending' to unblock daily builds. Filed issue : https://github.com/PowerShell/PowerShell/issues/2396
|
# Marking this test 'pending' to unblock daily builds. Filed issue : https://github.com/PowerShell/PowerShell/issues/2396
|
||||||
It "Should handle stdin redirection without error" -Pending {
|
It "Should handle stdin redirection without error" -Pending {
|
||||||
$process = Start-Process sort -Wait -RedirectStandardOutput $tempFile -RedirectStandardInput $assetsFile @extraArgs
|
$process = Start-Process sort -Wait -RedirectStandardOutput $tempFile -RedirectStandardInput $assetsFile @extraArgs
|
||||||
$dirEntry = get-childitem $tempFile
|
$dirEntry = Get-ChildItem $tempFile
|
||||||
$dirEntry.Length | Should -BeGreaterThan 0
|
$dirEntry.Length | Should -BeGreaterThan 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ Describe "Test-Connection" -tags "CI" {
|
|||||||
$pingResults.Count | Should -Be 4
|
$pingResults.Count | Should -Be 4
|
||||||
|
|
||||||
$result = $pingResults |
|
$result = $pingResults |
|
||||||
Where-Object Status -eq 'Success' |
|
Where-Object Status -EQ 'Success' |
|
||||||
Select-Object -First 1
|
Select-Object -First 1
|
||||||
|
|
||||||
$result | Should -BeOfType Microsoft.PowerShell.Commands.TestConnectionCommand+PingStatus
|
$result | Should -BeOfType Microsoft.PowerShell.Commands.TestConnectionCommand+PingStatus
|
||||||
@ -118,7 +118,7 @@ Describe "Test-Connection" -tags "CI" {
|
|||||||
# be a lack of or inconsistent support for IPv6 in CI environments.
|
# be a lack of or inconsistent support for IPv6 in CI environments.
|
||||||
It "Allows us to Force IPv6" -Pending {
|
It "Allows us to Force IPv6" -Pending {
|
||||||
$result = Test-Connection $targetName -IPv6 -Count 4 |
|
$result = Test-Connection $targetName -IPv6 -Count 4 |
|
||||||
Where-Object Status -eq Success |
|
Where-Object Status -EQ Success |
|
||||||
Select-Object -First 1
|
Select-Object -First 1
|
||||||
|
|
||||||
$result.Address | Should -BeExactly $targetAddressIPv6
|
$result.Address | Should -BeExactly $targetAddressIPv6
|
||||||
@ -127,7 +127,7 @@ Describe "Test-Connection" -tags "CI" {
|
|||||||
|
|
||||||
It 'can convert IPv6 addresses to IPv4 with -IPv4 parameter' -Pending {
|
It 'can convert IPv6 addresses to IPv4 with -IPv4 parameter' -Pending {
|
||||||
$result = Test-Connection '2001:4860:4860::8888' -IPv4 -Count 4 |
|
$result = Test-Connection '2001:4860:4860::8888' -IPv4 -Count 4 |
|
||||||
Where-Object Status -eq Success |
|
Where-Object Status -EQ Success |
|
||||||
Select-Object -First 1
|
Select-Object -First 1
|
||||||
# Google's DNS can resolve to either address.
|
# Google's DNS can resolve to either address.
|
||||||
$result.Address.IPAddressToString | Should -BeIn @('8.8.8.8', '8.8.4.4')
|
$result.Address.IPAddressToString | Should -BeIn @('8.8.8.8', '8.8.4.4')
|
||||||
@ -136,7 +136,7 @@ Describe "Test-Connection" -tags "CI" {
|
|||||||
|
|
||||||
It 'can convert IPv4 addresses to IPv6 with -IPv6 parameter' -Pending {
|
It 'can convert IPv4 addresses to IPv6 with -IPv6 parameter' -Pending {
|
||||||
$result = Test-Connection '8.8.8.8' -IPv6 -Count 4 |
|
$result = Test-Connection '8.8.8.8' -IPv6 -Count 4 |
|
||||||
Where-Object Status -eq Success |
|
Where-Object Status -EQ Success |
|
||||||
Select-Object -First 1
|
Select-Object -First 1
|
||||||
# Google's DNS can resolve to either address.
|
# Google's DNS can resolve to either address.
|
||||||
$result.Address.IPAddressToString | Should -BeIn @('2001:4860:4860::8888', '2001:4860:4860::8844')
|
$result.Address.IPAddressToString | Should -BeIn @('2001:4860:4860::8888', '2001:4860:4860::8844')
|
||||||
|
@ -3,12 +3,12 @@
|
|||||||
Describe "Test-Path" -Tags "CI" {
|
Describe "Test-Path" -Tags "CI" {
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
$testdirectory = $TestDrive
|
$testdirectory = $TestDrive
|
||||||
$testfilename = New-Item -path $testdirectory -Name testfile.txt -ItemType file -Value 1 -force
|
$testfilename = New-Item -Path $testdirectory -Name testfile.txt -ItemType file -Value 1 -Force
|
||||||
|
|
||||||
# populate with additional files
|
# populate with additional files
|
||||||
New-Item -Path $testdirectory -Name datestfile -value 1 -ItemType file | Out-Null
|
New-Item -Path $testdirectory -Name datestfile -Value 1 -ItemType file | Out-Null
|
||||||
New-Item -Path $testdirectory -Name gatestfile -value 1 -ItemType file | Out-Null
|
New-Item -Path $testdirectory -Name gatestfile -Value 1 -ItemType file | Out-Null
|
||||||
New-Item -Path $testdirectory -Name usr -value 1 -ItemType directory | Out-Null
|
New-Item -Path $testdirectory -Name usr -Value 1 -ItemType directory | Out-Null
|
||||||
|
|
||||||
$nonExistentDir = Join-Path -Path (Join-Path -Path $testdirectory -ChildPath usr) -ChildPath bin
|
$nonExistentDir = Join-Path -Path (Join-Path -Path $testdirectory -ChildPath usr) -ChildPath bin
|
||||||
$nonExistentPath = Join-Path -Path (Join-Path -Path (Join-Path -Path $testdirectory -ChildPath usr) -ChildPath bin) -ChildPath error
|
$nonExistentPath = Join-Path -Path (Join-Path -Path (Join-Path -Path $testdirectory -ChildPath usr) -ChildPath bin) -ChildPath error
|
||||||
|
@ -143,7 +143,7 @@ try {
|
|||||||
}
|
}
|
||||||
AfterAll {
|
AfterAll {
|
||||||
if ($IsWindows) {
|
if ($IsWindows) {
|
||||||
Set-TimeZone -ID $originalTimeZoneId
|
Set-TimeZone -Id $originalTimeZoneId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,7 +172,7 @@ try {
|
|||||||
}
|
}
|
||||||
AfterAll {
|
AfterAll {
|
||||||
if ($IsWindows) {
|
if ($IsWindows) {
|
||||||
Set-TimeZone -ID $originalTimeZoneId
|
Set-TimeZone -Id $originalTimeZoneId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ Describe "UnixFileSystem additions" -Tag "CI" {
|
|||||||
|
|
||||||
It "The UnixStat property should be the correct type" {
|
It "The UnixStat property should be the correct type" {
|
||||||
$expected = "System.Management.Automation.Platform+Unix+CommonStat"
|
$expected = "System.Management.Automation.Platform+Unix+CommonStat"
|
||||||
$i = (get-item /).psobject.properties['UnixStat'].TypeNameOfValue
|
$i = (Get-Item /).psobject.properties['UnixStat'].TypeNameOfValue
|
||||||
$i | Should -Be $expected
|
$i | Should -Be $expected
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
# Copyright (c) Microsoft Corporation.
|
# Copyright (c) Microsoft Corporation.
|
||||||
# Licensed under the MIT License.
|
# Licensed under the MIT License.
|
||||||
Describe "Acl cmdlets are available and operate properly" -Tag CI {
|
Describe "Acl cmdlets are available and operate properly" -Tag CI {
|
||||||
It "Get-Acl returns an ACL object" -pending:(!$IsWindows) {
|
It "Get-Acl returns an ACL object" -Pending:(!$IsWindows) {
|
||||||
$ACL = get-acl $TESTDRIVE
|
$ACL = Get-Acl $TESTDRIVE
|
||||||
$ACL | Should -BeOfType System.Security.AccessControl.DirectorySecurity
|
$ACL | Should -BeOfType System.Security.AccessControl.DirectorySecurity
|
||||||
}
|
}
|
||||||
It "Set-Acl can set the ACL of a directory" -pending {
|
It "Set-Acl can set the ACL of a directory" -Pending {
|
||||||
Setup -d testdir
|
Setup -d testdir
|
||||||
$directory = "$TESTDRIVE/testdir"
|
$directory = "$TESTDRIVE/testdir"
|
||||||
$acl = get-acl $directory
|
$acl = Get-Acl $directory
|
||||||
$accessRule = [System.Security.AccessControl.FileSystemAccessRule]::New("Everyone","FullControl","ContainerInherit,ObjectInherit","None","Allow")
|
$accessRule = [System.Security.AccessControl.FileSystemAccessRule]::New("Everyone","FullControl","ContainerInherit,ObjectInherit","None","Allow")
|
||||||
$acl.AddAccessRule($accessRule)
|
$acl.AddAccessRule($accessRule)
|
||||||
{ $acl | Set-Acl $directory } | Should -Not -Throw
|
{ $acl | Set-Acl $directory } | Should -Not -Throw
|
||||||
|
|
||||||
$newacl = get-acl $directory
|
$newacl = Get-Acl $directory
|
||||||
$newrule = $newacl.Access | Where-Object { $accessrule.FileSystemRights -eq $_.FileSystemRights -and $accessrule.AccessControlType -eq $_.AccessControlType -and $accessrule.IdentityReference -eq $_.IdentityReference }
|
$newrule = $newacl.Access | Where-Object { $accessrule.FileSystemRights -eq $_.FileSystemRights -and $accessrule.AccessControlType -eq $_.AccessControlType -and $accessrule.IdentityReference -eq $_.IdentityReference }
|
||||||
$newrule | Should -Not -BeNullOrEmpty
|
$newrule | Should -Not -BeNullOrEmpty
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ Describe "Certificate Provider tests" -Tags "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Context "Get-Item tests" {
|
Context "Get-Item tests" {
|
||||||
it "Should be able to get a certificate store, path: <path>" -TestCases $testLocations {
|
It "Should be able to get a certificate store, path: <path>" -TestCases $testLocations {
|
||||||
param([string] $path)
|
param([string] $path)
|
||||||
$expectedResolvedPath = Resolve-Path -LiteralPath $path
|
$expectedResolvedPath = Resolve-Path -LiteralPath $path
|
||||||
$result = Get-Item -LiteralPath $path
|
$result = Get-Item -LiteralPath $path
|
||||||
@ -55,24 +55,24 @@ Describe "Certificate Provider tests" -Tags "CI" {
|
|||||||
$resolvedPath.ProviderPath.TrimStart('\') | Should -Be $expectedResolvedPath.ProviderPath.TrimStart('\')
|
$resolvedPath.ProviderPath.TrimStart('\') | Should -Be $expectedResolvedPath.ProviderPath.TrimStart('\')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
it "Should return two items at the root of the provider" {
|
It "Should return two items at the root of the provider" {
|
||||||
(Get-Item -Path cert:\*).Count | Should -Be 2
|
(Get-Item -Path cert:\*).Count | Should -Be 2
|
||||||
}
|
}
|
||||||
it "Should be able to get multiple items explictly" {
|
It "Should be able to get multiple items explictly" {
|
||||||
(get-item cert:\LocalMachine , cert:\CurrentUser).Count | Should -Be 2
|
(Get-Item cert:\LocalMachine , cert:\CurrentUser).Count | Should -Be 2
|
||||||
}
|
}
|
||||||
it "Should return PathNotFound when getting a non-existant certificate store" {
|
It "Should return PathNotFound when getting a non-existant certificate store" {
|
||||||
{Get-Item cert:\IDONTEXIST -ErrorAction Stop} | Should -Throw -ErrorId "PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand"
|
{Get-Item cert:\IDONTEXIST -ErrorAction Stop} | Should -Throw -ErrorId "PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand"
|
||||||
}
|
}
|
||||||
it "Should return PathNotFound when getting a non-existant certificate" {
|
It "Should return PathNotFound when getting a non-existant certificate" {
|
||||||
{Get-Item cert:\currentuser\my\IDONTEXIST -ErrorAction Stop} | Should -Throw -ErrorId "PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand"
|
{Get-Item cert:\currentuser\my\IDONTEXIST -ErrorAction Stop} | Should -Throw -ErrorId "PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Context "Get-ChildItem tests"{
|
Context "Get-ChildItem tests"{
|
||||||
it "should be able to get a container using a wildcard" {
|
It "should be able to get a container using a wildcard" {
|
||||||
(Get-ChildItem Cert:\CurrentUser\M?).PSPath | Should -Be 'Microsoft.PowerShell.Security\Certificate::CurrentUser\My'
|
(Get-ChildItem Cert:\CurrentUser\M?).PSPath | Should -Be 'Microsoft.PowerShell.Security\Certificate::CurrentUser\My'
|
||||||
}
|
}
|
||||||
it "Should return two items at the root of the provider" {
|
It "Should return two items at the root of the provider" {
|
||||||
(Get-ChildItem -Path cert:\).Count | Should -Be 2
|
(Get-ChildItem -Path cert:\).Count | Should -Be 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,49 +106,49 @@ Describe "Certificate Provider tests" -Tags "Feature" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Context "Get-Item tests" {
|
Context "Get-Item tests" {
|
||||||
it "Should be able to get certifate by path: <path>" -TestCases $currentUserMyLocations {
|
It "Should be able to get certifate by path: <path>" -TestCases $currentUserMyLocations {
|
||||||
param([string] $path)
|
param([string] $path)
|
||||||
$expectedThumbprint = (Get-GoodCertificateObject).Thumbprint
|
$expectedThumbprint = (Get-GoodCertificateObject).Thumbprint
|
||||||
$leafPath = Join-Path -Path $path -ChildPath $expectedThumbprint
|
$leafPath = Join-Path -Path $path -ChildPath $expectedThumbprint
|
||||||
$cert = (Get-item -LiteralPath $leafPath)
|
$cert = (Get-Item -LiteralPath $leafPath)
|
||||||
$cert | Should -Not -Be null
|
$cert | Should -Not -Be null
|
||||||
$cert.Thumbprint | Should -Be $expectedThumbprint
|
$cert.Thumbprint | Should -Be $expectedThumbprint
|
||||||
}
|
}
|
||||||
it "Should be able to get DnsNameList of certifate by path: <path>" -TestCases $currentUserMyLocations {
|
It "Should be able to get DnsNameList of certifate by path: <path>" -TestCases $currentUserMyLocations {
|
||||||
param([string] $path)
|
param([string] $path)
|
||||||
$expectedThumbprint = (Get-GoodCertificateObject).Thumbprint
|
$expectedThumbprint = (Get-GoodCertificateObject).Thumbprint
|
||||||
$expectedName = (Get-GoodCertificateObject).DnsNameList[0].Unicode
|
$expectedName = (Get-GoodCertificateObject).DnsNameList[0].Unicode
|
||||||
$expectedEncodedName = (Get-GoodCertificateObject).DnsNameList[0].Punycode
|
$expectedEncodedName = (Get-GoodCertificateObject).DnsNameList[0].Punycode
|
||||||
$leafPath = Join-Path -Path $path -ChildPath $expectedThumbprint
|
$leafPath = Join-Path -Path $path -ChildPath $expectedThumbprint
|
||||||
$cert = (Get-item -LiteralPath $leafPath)
|
$cert = (Get-Item -LiteralPath $leafPath)
|
||||||
$cert | Should -Not -Be null
|
$cert | Should -Not -Be null
|
||||||
$cert.DnsNameList | Should -Not -Be null
|
$cert.DnsNameList | Should -Not -Be null
|
||||||
$cert.DnsNameList.Count | Should -Be 1
|
$cert.DnsNameList.Count | Should -Be 1
|
||||||
$cert.DnsNameList[0].Unicode | Should -Be $expectedName
|
$cert.DnsNameList[0].Unicode | Should -Be $expectedName
|
||||||
$cert.DnsNameList[0].Punycode | Should -Be $expectedEncodedName
|
$cert.DnsNameList[0].Punycode | Should -Be $expectedEncodedName
|
||||||
}
|
}
|
||||||
it "Should be able to get DNSNameList of certifate by path: <path>" -TestCases $currentUserMyLocations {
|
It "Should be able to get DNSNameList of certifate by path: <path>" -TestCases $currentUserMyLocations {
|
||||||
param([string] $path)
|
param([string] $path)
|
||||||
$expectedThumbprint = (Get-GoodCertificateObject).Thumbprint
|
$expectedThumbprint = (Get-GoodCertificateObject).Thumbprint
|
||||||
$expectedOid = (Get-GoodCertificateObject).EnhancedKeyUsageList[0].ObjectId
|
$expectedOid = (Get-GoodCertificateObject).EnhancedKeyUsageList[0].ObjectId
|
||||||
$leafPath = Join-Path -Path $path -ChildPath $expectedThumbprint
|
$leafPath = Join-Path -Path $path -ChildPath $expectedThumbprint
|
||||||
$cert = (Get-item -LiteralPath $leafPath)
|
$cert = (Get-Item -LiteralPath $leafPath)
|
||||||
$cert | Should -Not -Be null
|
$cert | Should -Not -Be null
|
||||||
$cert.EnhancedKeyUsageList | Should -Not -Be null
|
$cert.EnhancedKeyUsageList | Should -Not -Be null
|
||||||
$cert.EnhancedKeyUsageList.Count | Should -Be 1
|
$cert.EnhancedKeyUsageList.Count | Should -Be 1
|
||||||
$cert.EnhancedKeyUsageList[0].ObjectId.Length | Should -Not -Be 0
|
$cert.EnhancedKeyUsageList[0].ObjectId.Length | Should -Not -Be 0
|
||||||
$cert.EnhancedKeyUsageList[0].ObjectId | Should -Be $expectedOid
|
$cert.EnhancedKeyUsageList[0].ObjectId | Should -Be $expectedOid
|
||||||
}
|
}
|
||||||
it "Should filter to codesign certificates" {
|
It "Should filter to codesign certificates" {
|
||||||
$allCerts = get-item cert:\CurrentUser\My\*
|
$allCerts = Get-Item cert:\CurrentUser\My\*
|
||||||
$codeSignCerts = get-item cert:\CurrentUser\My\* -CodeSigningCert
|
$codeSignCerts = Get-Item cert:\CurrentUser\My\* -CodeSigningCert
|
||||||
$codeSignCerts | Should -Not -Be null
|
$codeSignCerts | Should -Not -Be null
|
||||||
$allCerts | Should -Not -Be null
|
$allCerts | Should -Not -Be null
|
||||||
$nonCodeSignCertCount = $allCerts.Count - $codeSignCerts.Count
|
$nonCodeSignCertCount = $allCerts.Count - $codeSignCerts.Count
|
||||||
$nonCodeSignCertCount | Should -Not -Be 0
|
$nonCodeSignCertCount | Should -Not -Be 0
|
||||||
}
|
}
|
||||||
it "Should be able to exclude by thumbprint" {
|
It "Should be able to exclude by thumbprint" {
|
||||||
$allCerts = get-item cert:\CurrentUser\My\*
|
$allCerts = Get-Item cert:\CurrentUser\My\*
|
||||||
$testThumbprint = (Get-GoodCertificateObject).Thumbprint
|
$testThumbprint = (Get-GoodCertificateObject).Thumbprint
|
||||||
$allCertsExceptOne = (Get-Item "cert:\currentuser\my\*" -Exclude $testThumbprint)
|
$allCertsExceptOne = (Get-Item "cert:\currentuser\my\*" -Exclude $testThumbprint)
|
||||||
$allCerts | Should -Not -Be null
|
$allCerts | Should -Not -Be null
|
||||||
@ -158,9 +158,9 @@ Describe "Certificate Provider tests" -Tags "Feature" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Context "Get-ChildItem tests"{
|
Context "Get-ChildItem tests"{
|
||||||
it "Should filter to codesign certificates" {
|
It "Should filter to codesign certificates" {
|
||||||
$allCerts = get-ChildItem cert:\CurrentUser\My
|
$allCerts = Get-ChildItem cert:\CurrentUser\My
|
||||||
$codeSignCerts = get-ChildItem cert:\CurrentUser\My -CodeSigningCert
|
$codeSignCerts = Get-ChildItem cert:\CurrentUser\My -CodeSigningCert
|
||||||
$codeSignCerts | Should -Not -Be null
|
$codeSignCerts | Should -Not -Be null
|
||||||
$allCerts | Should -Not -Be null
|
$allCerts | Should -Not -Be null
|
||||||
$nonCodeSignCertCount = $allCerts.Count - $codeSignCerts.Count
|
$nonCodeSignCertCount = $allCerts.Count - $codeSignCerts.Count
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) Microsoft Corporation.
|
# Copyright (c) Microsoft Corporation.
|
||||||
# Licensed under the MIT License.
|
# Licensed under the MIT License.
|
||||||
|
|
||||||
using namespace System.Security.Cryptography.X509Certificates
|
using namespace System.Security.Cryptography.X509Certificates
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user