mirror of
https://github.com/PowerShell/PowerShell.git
synced 2024-11-28 04:13:31 +08:00
Fix errors on CoreCLR Windows port
This commit is contained in:
parent
bdffd103d9
commit
6ce53af354
@ -24,12 +24,13 @@
|
||||
if ($isWindows)
|
||||
{
|
||||
$expected = "\Users\" + $ENV:USERNAME
|
||||
$ENV:HOMEPATH | Should Be $expected
|
||||
}
|
||||
else
|
||||
{
|
||||
$expected = /bin/bash -c "cd ~ && pwd"
|
||||
}
|
||||
$ENV:HOME | Should Be $expected
|
||||
}
|
||||
}
|
||||
|
||||
It "Should be able to set the environment variables" {
|
||||
|
@ -1,12 +1,12 @@
|
||||
Describe "Get-FileHash" {
|
||||
New-Variable testDocument -Value (Join-Path -Path (Join-Path $PSScriptRoot -ChildPath assets) -ChildPath testablescript.ps1) -Scope Global -Force
|
||||
# The MACTripleDES and RIPEMD160 algorithms are unsupported at the moment
|
||||
New-Variable testDocument -Value (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath assets) -ChildPath testablescript.ps1) -Scope Global -Force
|
||||
# The MACTripleDES and RIPEMD160 algorithms are unsupported on Linux
|
||||
$algorithms = @{"SHA1" ="01B865D143E07ECC875AB0EFC0A4429387FD0CF7";
|
||||
"SHA256" = "4A6DA9F1C0827143BB19FC4B0F2A8057BC1DF55F6D1F62FA3B917BA458E8F570";
|
||||
"SHA384" = "656215B6A07011E625206F43E57873F49AD7B36DFCABB70F6CDCE2303D7A603E55D052774D26F339A6D80A264340CB8C";
|
||||
"SHA512" = "C688C33027D89ACAC920545471C8053D8F64A54E21D0415F1E03766DDCDA215420E74FAFD1DC399864C6B6B5723A3358BD337339906797A39090B02229BF31FE";
|
||||
"MD5" = "7B09811D1631C9FD46B39D1D35522F0A";
|
||||
}
|
||||
}
|
||||
|
||||
Context "Cmdlet result tests" {
|
||||
It "Should default to correct hash algorithm" {
|
||||
@ -28,7 +28,7 @@
|
||||
It "Should list the path of the file under test" {
|
||||
$result = Get-FileHash $testDocument
|
||||
|
||||
$result.Path | Should Match (Join-Path assets -ChildPath testablescript.ps1)
|
||||
$result.Path | Should Be $testDocument
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ Describe "Get-Item" {
|
||||
|
||||
It "Should return the name of the current working directory when a dot is used" {
|
||||
(Get-Item $here).GetType().BaseType | Should Be 'System.IO.FileSystemInfo'
|
||||
(Get-Item $here).Name | Should Be 'powershell'
|
||||
(Get-Item $here).Name | Should Be (Split-Path $here -Leaf)
|
||||
}
|
||||
|
||||
It "Should return the proper Name and BaseType for directory objects vs file system objects" {
|
||||
|
@ -3,7 +3,8 @@ Describe "Get-RunspaceDebug" {
|
||||
Context "Check return types of RunspaceDebug" {
|
||||
|
||||
It "Should return Microsoft.Powershell.Commands.PSRunspaceDebug as the return type" {
|
||||
(Get-RunspaceDebug).GetType() | Should Be Microsoft.Powershell.Commands.PSRunspaceDebug
|
||||
$rs = Get-RunspaceDebug
|
||||
$rs[0].GetType().Name | Should Be PSRunspaceDebug
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -126,7 +126,7 @@
|
||||
}
|
||||
|
||||
Context "String tests" {
|
||||
$nl = [Environment]::NewLine
|
||||
$nl = [Environment]::NewLine
|
||||
|
||||
$testString = "HAD I the heavens’ embroidered cloths,$nl Enwrought with golden and silver light,$nl The blue and the dim and the dark cloths$nl Of night and light and the half light,$nl I would spread the cloths under your feet:$nl But I, being poor, have only my dreams;$nl I have spread my dreams under your feet;$nl Tread softly because you tread on my dreams."
|
||||
|
||||
@ -145,7 +145,7 @@
|
||||
}
|
||||
|
||||
It "Should be able to count the number of lines in a string" {
|
||||
$expectedLength = $testString.Split($nl).length
|
||||
$expectedLength = $testString.Split($nl, [System.StringSplitOptions]::RemoveEmptyEntries).length
|
||||
$actualLength = $testString | Measure-Object -Line
|
||||
|
||||
$actualLength.Lines | Should Be $expectedLength
|
||||
|
@ -157,7 +157,7 @@
|
||||
|
||||
$relativePath = Join-Path -Path $testDirectory -ChildPath ".."
|
||||
$relativePath = Join-Path -Path $relativePath -ChildPath ".."
|
||||
$relativePath = Join-Path -Path $relativePath -ChildPath $testDirectory
|
||||
$relativePath = Join-Path -Path $relativePath -ChildPath (Split-Path $testDirectory -NoQualifier)
|
||||
$relativePath = Join-Path -Path $relativePath -ChildPath testfile1.txt
|
||||
Select-String third $relativePath | Should Match $expected
|
||||
}
|
||||
|
@ -8,25 +8,31 @@ Describe "Set-PSBreakpoint" {
|
||||
|
||||
It "Should be able to set a psbreakpoint on a line" {
|
||||
$lineNumber = 1
|
||||
$(Set-PSBreakpoint -Line $lineNumber -Script $testScript).Line | Should Be $lineNumber
|
||||
$brk = Set-PSBreakpoint -Line $lineNumber -Script $testScript
|
||||
$brk.Line | Should Be $lineNumber
|
||||
Remove-PSBreakPoint -Id $brk.Id
|
||||
}
|
||||
|
||||
It "Should throw when a string is entered for a line number" {
|
||||
{
|
||||
$lineNumber = "one"
|
||||
$(Set-PSBreakpoint -Line $lineNumber -Script $testScript).Line
|
||||
Set-PSBreakpoint -Line $lineNumber -Script $testScript
|
||||
|
||||
} | Should Throw
|
||||
}
|
||||
|
||||
It "Should be able to set a psbreakpoint on a Command" {
|
||||
$command = "theCommand"
|
||||
$(Set-PSBreakpoint -Command $command -Script $testScript).Command | Should Be $command
|
||||
$brk = Set-PSBreakpoint -Command $command -Script $testScript
|
||||
$brk.Command | Should Be $command
|
||||
Remove-PSBreakPoint -Id $brk.Id
|
||||
}
|
||||
|
||||
It "Should be able to set a psbreakpoint on a variable" {
|
||||
$var = "theVariable"
|
||||
$(Set-PSBreakpoint -Command $var -Script $testScript).Command | Should Be $var
|
||||
$brk = Set-PSBreakpoint -Command $var -Script $testScript
|
||||
$brk.Command | Should Be $var
|
||||
Remove-PSBreakPoint -Id $brk.Id
|
||||
}
|
||||
|
||||
# clean up after ourselves
|
||||
|
@ -1,7 +1,7 @@
|
||||
Function IsWindows
|
||||
{
|
||||
$pingCommand = Get-Command -CommandType Application ping
|
||||
if ($pingCommand.Definition.IndexOf("\\") -ne -1)
|
||||
if ($pingCommand.Definition.IndexOf("\") -ne -1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ Describe "Wait-Event" {
|
||||
# raised because it is fake
|
||||
Wait-Event -Timeout 1 -SourceIdentifier "FakeEvent"
|
||||
$stopwatch.Stop()
|
||||
$stopwatch.ElapsedMilliseconds | Should BeGreaterThan 1000
|
||||
$stopwatch.ElapsedMilliseconds | Should BeGreaterThan 999
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user