-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Make Measure-Object property test independent of the filesystem #15879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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: PowerShell/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Measure-Object.cs Lines 820 to 827 in a4181ab
|
|
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
PaulHigin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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).