Fixing Linux\OSX compatibility issues

**Added -Pending:$flags for Linux and OSX to set-content and add-content
tests that expose dynamic variable file issues on these platforms
(https://github.com/PowerShell/PowerShell/issues/891)
**Handled platform-specific line-ending differences in Get-Content
-ReadLine - Tail tests
This commit is contained in:
Bryce Milton 2016-04-21 12:08:37 -07:00
parent 54efb3cb52
commit f6e0eee5d1
3 changed files with 12 additions and 9 deletions

View File

@ -11,11 +11,11 @@ Describe "Add-Content cmdlet tests" {
$result = get-content -path testdrive:\$file1
$result | Should BeExactly "ExpectedContent"
}
It "should Add-Content to testdrive:\dynamicfile.txt with dynamic parameters" {
It "should Add-Content to testdrive:\dynamicfile.txt with dynamic parameters" -Pending:($IsLinux -Or $IsOSX) {#https://github.com/PowerShell/PowerShell/issues/891
$result=add-content -path testdrive:\dynamicfile.txt -value "ExpectedContent" -passthru
$result| Should BeExactly "ExpectedContent"
}
It "should return expected string from testdrive:\dynamicfile.txt" {
It "should return expected string from testdrive:\dynamicfile.txt" -Pending:($IsLinux -Or $IsOSX) {#https://github.com/PowerShell/PowerShell/issues/891
$result = get-content -path testdrive:\dynamicfile.txt
$result | Should BeExactly "ExpectedContent"
}
@ -35,7 +35,7 @@ Describe "Add-Content cmdlet tests" {
#[DRT][BugId(BugDatabase.WindowsOutOfBandReleases, 906022)]
{add-content -path HKLM:\\software\\microsoft -value "ShouldNotWorkBecausePathIsUnsupported" -ea stop} | Should Throw "IContentCmdletProvider interface is not implemented"
}
It "should be able to pass multiple [string]`$objects to Add-Content through the pipeline to output a dynamic Path file" {
It "should be able to pass multiple [string]`$objects to Add-Content through the pipeline to output a dynamic Path file" -Pending:($IsLinux -Or $IsOSX) {#https://github.com/PowerShell/PowerShell/issues/891
#[DRT][BugId(BugDatabase.WindowsOutOfBandReleases, 9058182)]
"hello","world"|add-content testdrive:\dynamicfile2.txt
$result=get-content testdrive:\dynamicfile2.txt

View File

@ -120,12 +120,14 @@ Describe "Get-Content" {
$result=get-content -path $testPath -delimiter "," -tail 2
$result.Length | Should Be 2
$expected = "World3`r`nHello4,","World4`r`n"
if ($IsWindows) {$expected = "World3`r`nHello4,","World4`r`n"
} else {$expected = "World3`nHello4,","World4`n"}
for ($i = 0; $i -lt $result.Length ; $i++) { $result[$i] | Should BeExactly $expected[$i]}
$result=get-content -path $testPath -delimiter "o" -tail 3
$result.Length | Should Be 3
$expected = "rld3`r`nHello","4,Wo","rld4"
if ($IsWindows) {$expected = "rld3`r`nHello","4,Wo","rld4"
} else {$expected = "rld3`nHello","4,Wo","rld4"}
for ($i = 0; $i -lt $result.Length ; $i++) { $result[$i].Trim() | Should BeExactly $expected[$i]}
$result=get-content -path $testPath -encoding:Byte -tail 10
@ -138,7 +140,8 @@ Describe "Get-Content" {
set-content $testPath "Hello,llllWorlld","Hello2,llllWorlld2"
$result=get-content $testPath -delimiter "ll"
$result.Length | Should Be 9
$expected = "Hell","o,ll","ll","Worll","d`r`nHell","o2,ll","ll","Worll","d2`r`n"
if ($IsWindows) {$expected = "Hell","o,ll","ll","Worll","d`r`nHell","o2,ll","ll","Worll","d2`r`n"
} else {$expected = "Hell","o,ll","ll","Worll","d`nHell","o2,ll","ll","Worll","d2`n"}
for ($i = 0; $i -lt $result.Length ; $i++) { $result[$i] | Should BeExactly $expected[$i]}
}
}

View File

@ -11,11 +11,11 @@ Describe "Set-Content cmdlet tests" {
$result = get-content -path testdrive:\$file1
$result | Should BeExactly "ExpectedContent"
}
It "should Set-Content to testdrive:\dynamicfile.txt with dynamic parameters" {
It "should Set-Content to testdrive:\dynamicfile.txt with dynamic parameters" -Pending:($IsLinux -Or $IsOSX) {#https://github.com/PowerShell/PowerShell/issues/891
$result=set-content -path testdrive:\dynamicfile.txt -value "ExpectedContent" -passthru
$result| Should BeExactly "ExpectedContent"
}
It "should return expected string from testdrive:\dynamicfile.txt" {
It "should return expected string from testdrive:\dynamicfile.txt" -Pending:($IsLinux -Or $IsOSX) {#https://github.com/PowerShell/PowerShell/issues/891
$result = get-content -path testdrive:\dynamicfile.txt
$result | Should BeExactly "ExpectedContent"
}
@ -38,7 +38,7 @@ Describe "Set-Content cmdlet tests" {
#[DRT][BugId(BugDatabase.WindowsOutOfBandReleases, 906022)]
{set-content -path HKLM:\\software\\microsoft -value "ShouldNotWorkBecausePathIsUnsupported" -ea stop} | Should Throw "IContentCmdletProvider interface is not implemented"
}
It "should be able to pass multiple [string]`$objects to Set-Content through the pipeline to output a dynamic Path file" {
It "should be able to pass multiple [string]`$objects to Set-Content through the pipeline to output a dynamic Path file" -Pending:($IsLinux -Or $IsOSX) {#https://github.com/PowerShell/PowerShell/issues/891
#[DRT][BugId(BugDatabase.WindowsOutOfBandReleases, 9058182)]
"hello","world"|set-content testdrive:\dynamicfile2.txt
$result=get-content testdrive:\dynamicfile2.txt