-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
There are a number of tests in the PowerShell test suite that depend on a file asset in a way that depends on the specific bytes of the file. These tests fail on platforms that somehow differ from the expected encodings. For example, my Git configuration converts LF line endings to CRLF locally on Windows when checking out (and converts back on check-in), which is the default Git configuration on Windows, but because of this and Windows introducing a BOM, my file hashes come out differently.
I've made a small list of the tests I see failing on my machine because of this:
- Get-FileHash tests depend on file encoding -- CRLF/BOM breaks it
- A Get-Process test depends on having a process with the name "notepad"
- Write-Error ErrorRecord tests seem to be affected (get 11 and not the expected 4)
- Get-PSSessionConfiguration assumes there is only a single PSSessionConfiguration on the machine
- NativeStreams testing using the
$longtextlike in the Write-Error tests have a similar outcome
There might be a couple more tests like this too (I will update if I find any).
For the string/encoding-dependent tests, my suggestion is to use byte streams directly instead.
Steps to reproduce
cd $powershellBuildDir
Import-Module ./build.psm1
cd ./test/powershell/Modules/Microsoft.PowerShell.Utility
Start-PSPester Get-FileHash.Tests.ps1Expected behavior
Get-FileHash tests pass.
Actual behavior
Hashes all come out differently
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 6.0.1
PSEdition Core
GitCommitId v6.0.1-261-g71cb49a99d00ae4257e63f6564fd122325b64a48
OS Microsoft Windows 10.0.16299
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
