Tests (especially Get-FileHash) depend on machine-specific details #6413
Description
Activity
- addedWG-Maintainers-Buildspecific to affecting the buildspecific to affecting the build
on Mar 19, 2018 - addedIssue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the product
on Apr 6, 2018 microsoft-github-policy-service commented
on Nov 16, 2023 ContributorMore actionsThis issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commented
on Nov 16, 2023 ContributorMore actionsThis issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
- addedResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or more
on Nov 16, 2023 microsoft-github-policy-service commented
on Nov 16, 2023 ContributorMore actionsThis issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commented
on Nov 23, 2023 ContributorMore actionsThis issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.
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:
$longtextlike in the Write-Error tests have a similar outcomeThere 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
Expected behavior
Get-FileHash tests pass.
Actual behavior
Hashes all come out differently
Environment data