Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ Describe 'ValidateSet support a dynamically generated set' -Tag "CI" {
}
'@

$cls = Add-Type -TypeDefinition $a -PassThru | select -First 1
$cls = Add-Type -TypeDefinition $a -PassThru | Select-Object -First 1
$testModule = Import-Module $cls.Assembly -PassThru
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ Describe "Exception error position" -Tags "CI" {
static f1() { [MSFT_3090412]::bar = 42 }
static f2() { throw "an error in f2" }
static f3() { "".Substring(0, 10) }
static f4() { dir nosuchfile -ErrorAction Stop }
static f4() { Get-ChildItem nosuchfile -ErrorAction Stop }
}

It "Setting a property that doesn't exist" {
Expand All @@ -251,7 +251,7 @@ Describe "Exception error position" -Tags "CI" {

It "Terminating error" {
$e = { [MSFT_3090412]::f4() } | Should -Throw -PassThru -ErrorId 'PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand'
$e.InvocationInfo.Line | Should -Match ([regex]::Escape('dir nosuchfile -ErrorAction Stop'))
$e.InvocationInfo.Line | Should -Match ([regex]::Escape('Get-ChildItem nosuchfile -ErrorAction Stop'))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Describe "File redirection mixed with Out-Null" -Tags CI {
"some text" > $TestDrive\out.txt | Out-Null
Get-Content $TestDrive\out.txt | Should -BeExactly "some text"

echo "some more text" > $TestDrive\out.txt | Out-Null
Write-Output "some more text" > $TestDrive\out.txt | Out-Null
Get-Content $TestDrive\out.txt | Should -BeExactly "some more text"
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/powershell/Language/Parser/UsingAssembly.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Describe "Using assembly" -Tags "CI" {

try
{
pushd $PSScriptRoot
Push-Location $PSScriptRoot
$guid = [Guid]::NewGuid()

Add-Type -OutputAssembly $PSScriptRoot\UsingAssemblyTest$guid.dll -TypeDefinition @"
Expand Down Expand Up @@ -102,6 +102,6 @@ public class ABC {}
finally
{
Remove-Item .\UsingAssemblyTest$guid.dll
popd
Pop-Location
}
}
2 changes: 1 addition & 1 deletion test/powershell/Language/Parser/UsingNamespace.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Describe "Using Namespace" -Tags "CI" {
}

foo | Should -Be OK
$cmdInfo = gcm foo
$cmdInfo = Get-Commmand foo
$cmdInfo.ScriptBlock.Attributes[0] | Should -Be System.Diagnostics.DebuggerStepThroughAttribute
$cmdInfo.Parameters['a'].Attributes[1] | Should -Be System.Runtime.CompilerServices.CompilerGeneratedAttribute
$cmdInfo.Parameters['b'].Attributes[1] | Should -Be System.Runtime.CompilerServices.CompilerGeneratedAttribute
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Describe "Breakpoints set on custom FileSystem provider files should work" -Tags
#
# Verify that the breakpoint is hit when using the provider
#
pushd tmpTestA1:\
Push-Location tmpTestA1:\
$breakpoint = set-psbreakpoint .\$scriptName 1 -action { continue }
& .\$scriptName

Expand All @@ -42,7 +42,7 @@ Describe "Breakpoints set on custom FileSystem provider files should work" -Tags
}
finally
{
popd
Pop-Location

if ($null -ne $breakpoint) { $breakpoint | remove-psbreakpoint }
if (Test-Path $scriptFullName) { Remove-Item $scriptFullName -Force }
Expand Down Expand Up @@ -89,7 +89,7 @@ Describe "Tests line breakpoints on dot-sourced files" -Tags "CI" {
#
# Set the breakpoint and verify it is hit
#
$breakpoint = sbp $scriptFile 17 -action { continue; }
$breakpoint = Set-PsBreakpoint $scriptFile 17 -action { continue; }

& $scriptFile

Expand Down Expand Up @@ -137,8 +137,8 @@ Describe "Function calls clear debugger cache too early" -Tags "CI" {
#
# Set the breakpoints and verify they are hit
#
$breakpoint1 = sbp $scriptFile 7 -action { continue; }
$breakpoint2 = sbp $scriptFile 9 -action { continue; }
$breakpoint1 = Set-PsBreakpoint $scriptFile 7 -action { continue; }
$breakpoint2 = Set-PsBreakpoint $scriptFile 9 -action { continue; }

& $scriptFile

Expand Down Expand Up @@ -180,7 +180,7 @@ Describe "Line breakpoints on commands in multi-line pipelines" -Tags "CI" {
get-unique
'@

$breakpoints = sbp $script 1,2,3 -action { continue }
$breakpoints = Set-PsBreakpoint $script 1,2,3 -action { continue }

$null = & $script

Expand All @@ -201,7 +201,7 @@ Describe "Line breakpoints on commands in multi-line pipelines" -Tags "CI" {
if ($null -ne $breakpoints) { $breakpoints | remove-psbreakpoint }
if (Test-Path $script)
{
del $script -Force
Remove-Item $script -Force
}
}

Expand All @@ -218,7 +218,7 @@ Describe "Line breakpoints on commands in multi-line pipelines" -Tags "CI" {
$f = $a.GetFile($scriptPath1)
$scriptPath2 = $f.ShortPath

$breakpoints = sbp $scriptPath2 1,2,3 -action { continue }
$breakpoints = Set-PsBreakpoint $scriptPath2 1,2,3 -action { continue }
$null = & $scriptPath2
}

Expand Down Expand Up @@ -290,7 +290,7 @@ Describe "Unit tests for various script breakpoints" -Tags "CI" {
#
# Ensure there are no breakpoints at start of test
#
gbp | rbp
Get-PsBreakpoint | Remove-PsBreakpoint

#
# Create a couple of scripts
Expand All @@ -304,16 +304,16 @@ Describe "Unit tests for various script breakpoints" -Tags "CI" {
#
# Set several breakpoints of different types
#
$line1 = sbp $scriptFile1 1
$line2 = sbp $scriptFile2 2
$line1 = Set-PsBreakpoint $scriptFile1 1
$line2 = Set-PsBreakpoint $scriptFile2 2

$cmd1 = sbp -c command1 -s $scriptFile1
$cmd2 = sbp -c command2 -s $scriptFile2
$cmd3 = sbp -c command3
$cmd1 = Set-PsBreakpoint -c command1 -s $scriptFile1
$cmd2 = Set-PsBreakpoint -c command2 -s $scriptFile2
$cmd3 = Set-PsBreakpoint -c command3

$var1 = sbp -v variable1 -s $scriptFile1
$var2 = sbp -v variable2 -s $scriptFile2
$var3 = sbp -v variable3
$var1 = Set-PsBreakpoint -v variable1 -s $scriptFile1
$var2 = Set-PsBreakpoint -v variable2 -s $scriptFile2
$var3 = Set-PsBreakpoint -v variable3

#
# The default parameter set must return all breakpoints
Expand Down Expand Up @@ -344,9 +344,9 @@ Describe "Unit tests for various script breakpoints" -Tags "CI" {
$directoryName = [System.IO.Path]::GetDirectoryName($scriptFile1)
$fileName = [System.IO.Path]::GetFileName($scriptFile1)

pushd $directoryName
Push-Location $directoryName
Verify { get-psbreakpoint -script $fileName } $line1,$cmd1,$var1
popd
Pop-Location

#
# Query by Type
Expand Down Expand Up @@ -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
#
$breakpoint1 = sbp $scriptFile 4 -action { continue; }
$breakpoint2 = sbp $scriptFile 9 -action { continue; }
$breakpoint3 = sbp $scriptFile 24 -action { continue; }
$breakpoint1 = Set-PsBreakpoint $scriptFile 4 -action { continue; }
$breakpoint2 = Set-PsBreakpoint $scriptFile 9 -action { continue; }
$breakpoint3 = Set-PsBreakpoint $scriptFile 24 -action { continue; }

. $scriptFile

Expand Down Expand Up @@ -547,10 +547,10 @@ Describe "Unit tests for line breakpoints on modules" -Tags "CI" {
#
# Set a couple of line breakpoints on the module and verify that they are hit
#
$breakpoint1 = sbp $moduleFile 4 -action { continue }
$breakpoint2 = sbp $moduleFile 9 -action { continue }
$breakpoint3 = sbp $moduleFile 24 -Action { continue }
$breakpoint4 = sbp $moduleFile 25 -Action { continue }
$breakpoint1 = Set-PsBreakpoint $moduleFile 4 -action { continue }
$breakpoint2 = Set-PsBreakpoint $moduleFile 9 -action { continue }
$breakpoint3 = Set-PsBreakpoint $moduleFile 24 -Action { continue }
$breakpoint4 = Set-PsBreakpoint $moduleFile 25 -Action { continue }

ModuleFunction1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Describe "Tests Debugger GetCallStack() on runspaces when attached to a WinRM ho
$count = 0
while (($hostRS.RunspaceAvailability -ne 'Available') -and ($count++ -lt 60))
{
sleep -Milliseconds 500
Start-Sleep -Milliseconds 500
}
It "Verifies that the attached-to host runspace is available" {
($hostRS.RunspaceAvailability -eq 'Available') | Should -BeTrue
Expand Down
2 changes: 1 addition & 1 deletion test/powershell/Language/Scripting/LineEndings.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Describe 'Line endings' -Tags "CI" {

# wrap the content in the specified begin and end quoting characters.
$content = "$($Begin)$($expected)$($End)"
$actual = iex $content
$actual = Invoke-Expression $content

# $actual should be the content string ($expected) without the begin and end quoting characters.
$actual | Should -BeExactly $expected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Describe "Native streams behavior with PowerShell" -Tags 'CI' {
}

It 'uses ErrorRecord object to return stderr output' {
($out | measure).Count | Should -BeGreaterThan 1
($out | Measure-Object).Count | Should -BeGreaterThan 1

$out[0] | Should -BeOfType 'System.Management.Automation.ErrorRecord'
$out[0].FullyQualifiedErrorId | Should -Be 'NativeCommandError'
Expand All @@ -36,7 +36,7 @@ Describe "Native streams behavior with PowerShell" -Tags 'CI' {
}

It 'uses correct exception messages for error stream' {
($out | measure).Count | Should -Be 9
($out | Measure-Object).Count | Should -Be 9
$out[0].Exception.Message | Should -BeExactly 'foo'
$out[1].Exception.Message | Should -BeExactly ''
$out[2].Exception.Message | Should -BeExactly 'bar'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Describe 'Test for cmdlet to support Ordered Attribute on hash literal nodes' -T

$script:a = $null

{$script:a = dir | select-object -property Name, (
{$script:a = Get-ChildItem | select-object -property Name, (
[ordered]@{Name="IsDirectory";
Expression ={$_.PSIsContainer}})} | Should -Not -Throw

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ Describe "Debug-job test" -tag "Feature" {
# we check this via implication.
# if we're debugging a job, then the debugger will have a callstack
It "Debug-Job will break into debugger" -pending {
$ps.AddScript('$job = start-job { 1..300 | ForEach-Object { sleep 1 } }').Invoke()
$ps.AddScript('$job = start-job { 1..300 | ForEach-Object { Start-Sleep 1 } }').Invoke()
$ps.Commands.Clear()
$ps.Runspace.Debugger.GetCallStack() | Should -BeNullOrEmpty
Start-Sleep 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ function CompareCounterSets
for ($i = 1; $i -lt $setA.Length; $i++)
{
$setA[$i].CounterSamples.Length | Should -Be $setB[$i].CounterSamples.Length
$samplesA = ($setA[$i].CounterSamples | sort -Property Path)
$samplesB = ($setB[$i].CounterSamples | sort -Property Path)
$samplesA = ($setA[$i].CounterSamples | Sort-Object -Property Path)
$samplesB = ($setB[$i].CounterSamples | Sort-Object -Property Path)
(DateTimesAreEqualish $setA[$i].TimeStamp $setB[$i].TimeStamp) | Should -BeTrue
for ($j = 0; $j -lt $samplesA.Length; $j++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ Describe "Get-ChildItem" -Tags "CI" {

$foobar = Get-Childitem env: | Where-Object {$_.Name -eq '__foobar'}
$count = if ($IsWindows) { 1 } else { 2 }
($foobar | measure).Count | Should -Be $count
($foobar | Measure-Object).Count | Should -Be $count
}
catch
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ try {
$computerInformation = Get-ComputerInfoForTest
$propertyNames = Get-PropertyNamesForComputerInfoTest
$Expected = New-ExpectedComputerInfo $propertyNames
$testCases = $propertyNames | %{ @{ "Property" = $_ } }
$testCases = $propertyNames | ForEach-Object { @{ "Property" = $_ } }
}

#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
Describe "Get-Location" -Tags "CI" {
$currentDirectory=[System.IO.Directory]::GetCurrentDirectory()
BeforeEach {
pushd $currentDirectory
Push-Location $currentDirectory
}

AfterEach {
popd
Pop-location
}

It "Should list the output of the current working directory" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Describe "Test-Push-Location" -Tags "CI" {
New-Variable -Name startDirectory -Value $(Get-Location).Path -Scope Global -Force

BeforeEach { cd $startDirectory }
BeforeEach { Set-Location $startDirectory }

It "Should be called without error" {
{ Push-Location } | Should -Not -Throw
Expand Down Expand Up @@ -41,7 +41,7 @@ Describe "Test-Push-Location" -Tags "CI" {
pushd ..
$aliasDirectory = $(Get-Location).Path

cd $startDirectory
Set-Location $startDirectory
Push-Location ..
$cmdletDirectory = $(Get-Location).Path

Expand All @@ -53,5 +53,5 @@ Describe "Test-Push-Location" -Tags "CI" {
}

# final cleanup
cd $startDirectory
Set-Location $startDirectory
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ try

$EICAR_STRING_B64 = "awZ8EmMWc3JjaAdvY2lrBgcbY20aBHBwGgROF3Z6cHJhHmBncn13cmF3HnJ9Z3plemFmYB5ndmBnHnV6f3YSF3sYexk= "
$bytes = [System.Convert]::FromBase64String($EICAR_STRING_B64)
$EICAR_STRING = -join ($bytes | % { [char]($_ -bxor 0x33) })
$EICAR_STRING = -join ($bytes | ForeEach-Object { [char]($_ -bxor 0x33) })
{ Invoke-Expression -Command "echo '$EICAR_STRING'" } |
Should -Throw -ErrorId "ScriptContainedMaliciousContent,Microsoft.PowerShell.Commands.InvokeExpressionCommand"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ try
"@
$command += @'
$null = help NestedFn1 2>$null;
$result = Get-Command NestedFn1 2>$null;
$result = Get-Command NestedFn1 2>$null;
return ($result -ne $null)
'@
$isCommandAccessible = powershell.exe -noprofile -nologo -c $command
Expand Down Expand Up @@ -140,7 +140,7 @@ try

$mod = Import-Module -Name $moduleFilePath -Force -PassThru

# Running module function TestRestrictedSession should throw a 'script not allowed' error
# Running module function TestRestrictedSession should throw a 'script not allowed' error
# because it runs in a 'no language' session.
try
{
Expand Down Expand Up @@ -667,7 +667,7 @@ try
{
$ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage"

$result = @(TabExpansion2 '(1234 -as [IntPtr]).' 20 | % CompletionMatches | ? CompletionText -Match Pointer)
$result = @(TabExpansion2 '(1234 -as [IntPtr]).' 20 | ForEach-Object CompletionMatches | Where-Object CompletionText -Match Pointer)
}
finally
{
Expand Down Expand Up @@ -977,7 +977,7 @@ try
$ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage"
Invoke-LanguageModeTestingSupportCmdlet -SetLockdownMode

$results = $sb | Start-ThreadJob -ScriptBlock { $input | foreach { & $_ } } | Wait-Job | Receive-Job
$results = $sb | Start-ThreadJob -ScriptBlock { $input | ForEach-Object { & $_ } } | Wait-Job | Receive-Job
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ a,b,c
It "Should be able to have multiple columns" {
$actualData = $testColumns | ConvertFrom-Csv

$actualLength = $($( $actualData | gm) | Where-Object {$_.MemberType -eq "NoteProperty" }).Length
$actualLength = $($( $actualData | Get-Member) | Where-Object {$_.MemberType -eq "NoteProperty" }).Length

$actualLength | Should -Be 3
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Describe "Group-Object" -Tags "CI" {

It "User's scenario should work (see issue #6933 for link to stackoverflow question)" {
# Sort numbers into two groups even succeeded, odd failed.
$result = 1..9 | foreach {[PSCustomObject]@{ErrorMessage = if ($_ % 2) {'SomeError'} else {''}}} |
$result = 1..9 | ForEach-Object {[PSCustomObject]@{ErrorMessage = if ($_ % 2) {'SomeError'} else {''}}} |
Group-Object -Property {if ($_.ErrorMessage) {'Failed'} else {'Successful'}} -AsHashTable

$result['Failed'].ErrorMessage.Count | Should -Be 5
Expand Down
Loading