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 — Increase code coverage of Get-ChildItem on file system. by jeffbi · Pull Request #4342 · PowerShell/PowerShell

Conversation

@jeffbi

@jeffbi jeffbi commented Jul 25, 2017

Copy link
Copy Markdown

Addresses part of #4148.

Using the -Name parameter on Get-ChildItem exercises a part of the file system provider code not previously covered by tests.

Sorry, something went wrong.

Uh oh!

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

All reactions
Jeff Bienstadt
Increase code coverage of Get-ChildItem on file system.
95626fa
@msftclas Microsoft Contribution License Agreements (msftclas) added the cla-already-signed label Jul 25, 2017
dantraMSFT
Dan Travison (dantraMSFT) suggested changes Jul 25, 2017
View reviewed changes
Comment thread test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 Outdated

It "Verity Get-ChildItem can get the name of a specified item." {
$fileName = Get-ChildItem $testFile -Name
$fileName | Should BeExactly $fileName

@dantraMSFT Dan Travison (dantraMSFT) Jul 25, 2017

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.

This compares to itself.
I suggest calling Get-ChildItem twice, once with -Name to get the name string and once without to get the fileinfo. The test would look something like the following:
$filename | Should BeExactly $fileInfo.Name

Sorry, something went wrong.

Uh oh!

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

All reactions

@jeffbi jeffbi Jul 25, 2017

Copy link
Copy Markdown
Author

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.

Yikes! Bad typo on my part. That should have been $filename | Should BeExactly $testFile. Is making that change sufficient, or would you prefer the dual-call method?

Sorry, something went wrong.

Uh oh!

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

All reactions
@dantraMSFT

Dan Travison (dantraMSFT) commented Jul 25, 2017

Copy link
Copy Markdown
Contributor

You're better off comparing the returned value against the name property since, I believe, that's the intent.

All reactions

Sorry, something went wrong.

Uh oh!

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

@jeffbi

jeffbi commented Jul 25, 2017

Copy link
Copy Markdown
Author

Well, the intent was to check that I got the item I asked for, which is why I was comparing against $testFile. But I'll go ahead with your recommendation.

All reactions

Sorry, something went wrong.

Uh oh!

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

Jeff Bienstadt
Changes per code review.
ff4a24b
dantraMSFT
Dan Travison (dantraMSFT) approved these changes Jul 26, 2017
View reviewed changes
@dantraMSFT

Dan Travison (dantraMSFT) commented Jul 26, 2017

Copy link
Copy Markdown
Contributor

Sorry jeffbi; I should have been clearer. When I said the intent of -Name, I mean the intent is to return the Name property of the FileInfo object.
The current implementation of FileInfo 'does' preserve the file name as it was passed in; however, since it's not documented explicitly, I avoid depending on it.
Additionally, I would expect the test to succeed with other values, such as .\filename.txt, ./filename.txt, and /etc/filename.txt
I hope that clarifies my feedback.

All reactions

Sorry, something went wrong.

Uh oh!

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

@daxian-dbw Dongbo Wang (daxian-dbw) assigned Aditya Patwardhan (adityapatwardhan) Jul 28, 2017
@adityapatwardhan
Fixed typo
dd67917
@adityapatwardhan
Aditya Patwardhan (adityapatwardhan) merged commit 10a27b8 into PowerShell:master Aug 1, 2017
@jeffbi
jeffbi deleted the tests-4148-gci branch August 1, 2017 20:27
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
jeffbi @adityapatwardhan
Increase code coverage of Get-ChildItem on file system. (PowerShell#4342
7fecb2a
)

* Increase code coverage of Get-ChildItem on file system.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@dantraMSFT Dan Travison (dantraMSFT) dantraMSFT approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

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

Assignees

@adityapatwardhan Aditya Patwardhan (adityapatwardhan)

Labels

None yet

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.

4 participants

@jeffbi @dantraMSFT @msftclas @adityapatwardhan
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.