You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Save the following to t.Tests.ps1 and invoke with ./t.Tests.ps1:
Describe "Get-Content -Raw test" {
BeforeAll {
Push-Location TestDrive:/$lfTextUnterminated="a`nb"$lfText="a`nb`n"$crlfTextUnterminated="a`r`nb"$crlfText="a`r`nb`r`n"Set-Content-Encoding Ascii -NoNewline 'lf.txt'-value $lfTextSet-Content-Encoding Ascii -NoNewline 'crlf.txt'-value $crlfTextSet-Content-Encoding Ascii -NoNewline 'lf-nt.txt'-value $lfTextUnterminatedSet-Content-Encoding Ascii -NoNewline 'crlf-nt.txt'-value $crlfTextUnterminated
}
It "Reads LF-terminated files in full." {
Get-Content-Raw 'lf.txt'| Should BeExactly $lfText
}
It "Reads CRLF-terminated files in full." {
Get-Content-Raw 'crlf.txt'| Should BeExactly $crlfText
}
It "Reads LF-separated files without trailing newline in full." {
Get-Content-Raw 'lf-nt.txt'| Should BeExactly $lfTextUnterminated
}
It "Reads CRLF-separated files without trailing newline in full." {
Get-Content-Raw 'crlf-nt.txt'| Should BeExactly $crlfTextUnterminated
}
AfterAll {
Remove-Item-LiteralPath 'lf.txt','lf-nt.txt','crlf.txt','crlf-nt.txt'Pop-Location
}
}
Expected behavior
All tests should pass.
Actual behavior
The files ending in an LF character are read without that last character.
Note that Windows Powershell is not affected.
...
[-] Reads LF-terminated files in full. 47ms
Expected string length 4 but was 3. Strings differ at index 3.
Expected: {a\nb\n}
But was: {a\nb}
---------------^
at line: 18 in /Users/mklement/Desktop/pg/t.Tests.ps1
18: Get-Content -Raw 'lf.txt' | Should BeExactly $lfText
[-] Reads CRLF-terminated files in full. 20ms
Expected string length 6 but was 5. Strings differ at index 5.
Expected: {a\r\nb\r\n}
But was: {a\r\nb\r}
-------------------^
at line: 21 in /Users/mklement/Desktop/pg/t.Tests.ps1
21: Get-Content -Raw 'crlf.txt' | Should BeExactly $crlfText
...
Environment data
PowerShell Core v6.0.0-beta.7 on macOS 10.12.6
PowerShell Core v6.0.0-beta.7 on Ubuntu 16.04.3 LTS
PowerShell Core v6.0.0-beta.7 on Microsoft Windows 10 Pro (64-bit; v10.0.15063)
Steps to reproduce
Save the following to
t.Tests.ps1and invoke with./t.Tests.ps1:Expected behavior
All tests should pass.
Actual behavior
The files ending in an LF character are read without that last character.
Note that Windows Powershell is not affected.
Environment data