GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Make Measure-Object property test independent of the filesystem by rjmholt · Pull Request #15879 · PowerShell/PowerShell

Conversation

@rjmholt

@rjmholt Rob Holt (rjmholt) commented Aug 5, 2021

Copy link
Copy Markdown
Collaborator

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

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • Make sure all .h, .cpp, .cs, .ps1 and .psm1 files have the correct copyright header
  • This PR is ready to merge and is not Work in Progress.
    • If the PR is work in progress, please add the prefix WIP: or [ WIP ] to the beginning of the title (the WIP bot will keep its status check at Pending while the prefix is present) and remove the prefix when the PR is ready.
  • Breaking changes
    • None
    • OR
    • Experimental feature(s) needed
      • Experimental feature name(s):
  • User-facing changes
    • Not Applicable
    • OR
    • Documentation needed
      • Issue filed:
  • Testing - New and feature
    • N/A or can only be tested interactively
    • OR
    • Make sure you've added a new test if existing tests do not effectively test the code changed
  • Tooling
    • I have considered the user experience from a tooling perspective and don't believe tooling will be impacted.
    • OR
    • I have considered the user experience from a tooling perspective and opened an issue in the relevant tool repository. This may include:
      • Impact on PowerShell Editor Services which is used in the PowerShell extension for VSCode
        (which runs in a different PS Host).
        • Issue filed:
      • Impact on Completions (both in the console and in editors) - one of PowerShell's most powerful features.
        • Issue filed:
      • Impact on PSScriptAnalyzer (which provides linting & formatting in the editor extensions).
        • Issue filed:
      • Impact on EditorSyntax (which provides syntax highlighting with in VSCode, GitHub, and many other editors).
        • Issue filed:

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rjmholt
Make Measure-Object property test only look for files
3c8e20b
@rjmholt Rob Holt (rjmholt) added the CL-Test Indicates that a PR should be marked as a test change in the Change Log label Aug 5, 2021
@ghost ghost assigned Travis Plunk (TravisEz13) Aug 5, 2021
@rjmholt
Rob Holt (rjmholt) enabled auto-merge (squash) August 5, 2021 17:39
iSazonov
Ilya (iSazonov) reviewed Aug 5, 2021
View reviewed changes
Comment thread test/powershell/Modules/Microsoft.PowerShell.Utility/Measure-Object.Tests.ps1 Resolved

Uh oh!

There was an error while loading. Please reload this page.

@rjmholt
Rob Holt (rjmholt) disabled auto-merge August 5, 2021 18:53
@rjmholt
Rob Holt (rjmholt) marked this pull request as draft August 5, 2021 18:53
@rjmholt Rob Holt (rjmholt) added the WG-Cmdlets-Utility label Aug 5, 2021
@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Aug 6, 2021

Copy link
Copy Markdown
Member

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?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov

Ilya (iSazonov) commented Aug 7, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

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 c:\temp\.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Aug 7, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

I see, this doesn't repro on macOS. Got a repro on my Windows machine. I think Measure-Object shouldn't fail here and should ignore it.

iSazonov reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov

Ilya (iSazonov) commented Aug 7, 2021

Copy link
Copy Markdown
Collaborator

I don't understand the design:

PowerShell/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Measure-Object.cs

Lines 820 to 827 in a4181ab

Statistics stat = _statistics[propertyName];
if (stat.count == 0 && Property != null)
{
// Why are there two different ids for this error?
string errorId = (IsMeasuringGeneric) ? "GenericMeasurePropertyNotFound" : "TextMeasurePropertyNotFound";
WritePropertyNotFoundError(propertyName, errorId);
continue;
}

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Aug 7, 2021

Copy link
Copy Markdown
Member

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?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov

Ilya (iSazonov) commented Aug 7, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

It seems my bad. DirectoryInfo hasn't Length property. FileInfo has.

The PR is correct.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

SteveL-MSFT
Steve Lee (SteveL-MSFT) previously requested changes Aug 7, 2021
View reviewed changes
Comment thread test/powershell/Modules/Microsoft.PowerShell.Utility/Measure-Object.Tests.ps1 Resolved

Uh oh!

There was an error while loading. Please reload this page.

@ghost ghost added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Aug 7, 2021
@rjmholt
Make measure object tests completely standalone
5c2e74d
@ghost ghost removed the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Aug 9, 2021
@rjmholt
Fix test
472ac72
@rjmholt
Rob Holt (rjmholt) marked this pull request as ready for review August 9, 2021 20:36
@rjmholt Rob Holt (rjmholt) changed the title Make Measure-Object property test only look for files Make Measure-Object property test independent of the filesystem Aug 9, 2021
@rjmholt
Rob Holt (rjmholt) requested review from Steve Lee (SteveL-MSFT) and Ilya (iSazonov) August 9, 2021 20:37
PaulHigin
Paul Higinbotham (PaulHigin) approved these changes Aug 9, 2021
View reviewed changes

@PaulHigin Paul Higinbotham (PaulHigin) left a comment

Copy link
Copy Markdown
Contributor

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
adityapatwardhan
Aditya Patwardhan (adityapatwardhan) approved these changes Aug 9, 2021
View reviewed changes
@rjmholt
Rob Holt (rjmholt) dismissed Steve Lee (SteveL-MSFT)’s stale review August 9, 2021 22:26

Addressed the filesystem dependency issue

@rjmholt
Rob Holt (rjmholt) merged commit 2f5150f into PowerShell:master Aug 9, 2021
@rjmholt
Rob Holt (rjmholt) deleted the fix-measureobject-test branch August 9, 2021 22:27
@ghost

Deleted user (ghost) commented Aug 23, 2021

Copy link
Copy Markdown

🎉v7.2.0-preview.9 has been released which incorporates this pull request.:tada:

Handy links:

  • Release Notes
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ghost

Deleted user (ghost) commented Sep 28, 2021

Copy link
Copy Markdown

🎉v7.2.0-preview.10 has been released which incorporates this pull request.:tada:

Handy links:

  • Release Notes
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kilasuit Ryan Yates (kilasuit) added WG-Cmdlets general cmdlet issues and removed WG-Cmdlets-Utility labels Jul 17, 2026
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
@rjmholt
Make Measure-Object property test independent of the filesystem (Powe…
15f9452
…rShell#15879)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@adityapatwardhan Aditya Patwardhan (adityapatwardhan) adityapatwardhan approved these changes
@SteveL-MSFT Steve Lee (SteveL-MSFT) Awaiting requested review from SteveL-MSFT
@iSazonov Ilya (iSazonov) Awaiting requested review from iSazonov
+1 more reviewer
@PaulHigin Paul Higinbotham (PaulHigin) PaulHigin approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@TravisEz13 Travis Plunk (TravisEz13)

Labels

CL-Test Indicates that a PR should be marked as a test change in the Change Log WG-Cmdlets general cmdlet issues

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@rjmholt @SteveL-MSFT @iSazonov @adityapatwardhan @PaulHigin @kilasuit @TravisEz13
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.