Make Measure-Object property test independent of the filesystem#15879
Make Measure-Object property test independent of the filesystem#15879rjmholt merged 3 commits intoPowerShell:masterfrom
Conversation
test/powershell/Modules/Microsoft.PowerShell.Utility/Measure-Object.Tests.ps1
Outdated
Show resolved
Hide resolved
|
Is this a race condition between getting the count of objects and than using measure-object? I'm not able to repro this with even an empty sub-folder? |
|
I can reproduce: PS> $(Get-ChildItem C:\temp\ | Measure-Object -Property Length).Count
Measure-Object: Cannot process argument because the value of argument "Property" is not valid. Change the value of the "Property" argument and run the operation again.
0
PS > Get-ChildItem C:\temp\ -Recurse
Directory: C:\temp
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 12.05.2021 17:22 52293_original
My current folder is not |
|
I see, this doesn't repro on macOS. Got a repro on my Windows machine. I think |
|
I don't understand the design: |
|
It looks like the design is to only return that error which is effectively terminating if the result is 0 and the property doesn't match. So if you have a folder that ONLY has an empty folder, then this will fail, but if it has any files it should succeed (which still doesn't make sense to me why the test fails unless it's a race condition). Is there a repro where there are other items in the folder other than a single empty folder? |
|
It seems my bad. DirectoryInfo hasn't Length property. FileInfo has. The PR is correct. |
test/powershell/Modules/Microsoft.PowerShell.Utility/Measure-Object.Tests.ps1
Outdated
Show resolved
Hide resolved
Addressed the filesystem dependency issue
|
🎉 Handy links: |
|
🎉 Handy links: |
PR Summary
Fixes a recent CI failure where the expected and actual results of this test disagree because there's a directory in the
$TestDrive.PR Context
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.(which runs in a different PS Host).