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 — Add a generic file watcher function in HelpersCommon.psm1 by daxian-dbw · Pull Request #4775 · PowerShell/PowerShell

Conversation

@daxian-dbw

@daxian-dbw Dongbo Wang (daxian-dbw) commented Sep 7, 2017

Copy link
Copy Markdown
Member

Fix #4524

Add a generic file watcher function in HelpersCommon.psm1 and update some tests to use the Wait-FileToBePresent.

Sorry, something went wrong.

Uh oh!

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

All reactions
Dongbo Wang (daxian-dbw) added 3 commits September 7, 2017 08:51
@daxian-dbw
[Feature] Add a generic file watcher function in HelpersCommon.psm1
0dc1fbb
@daxian-dbw
[Feature] Expose 'Wait-FileToBePresent' from HelpersCommon module
cde1fbb
@daxian-dbw
[Feature] Fix a test failure
7a9e3c6
@daxian-dbw
Dongbo Wang (daxian-dbw) requested a review from Travis Plunk (TravisEz13) September 7, 2017 21:33
@daxian-dbw
Dongbo Wang (daxian-dbw) requested a review from Aditya Patwardhan (adityapatwardhan) as a code owner September 7, 2017 21:33
@daxian-dbw
Dongbo Wang (daxian-dbw) removed the request for review from Aditya Patwardhan (adityapatwardhan) September 7, 2017 21:33
@daxian-dbw Dongbo Wang (daxian-dbw) assigned Travis Plunk (TravisEz13) Sep 7, 2017
@msftclas Microsoft Contribution License Agreements (msftclas) added the cla-not-required label Sep 7, 2017
iSazonov
Ilya (iSazonov) reviewed Sep 9, 2017
View reviewed changes
Comment thread test/tools/Modules/HelpersCommon/HelpersCommon.psm1

# Loop until the script block evaluates to true
while (-not ($sb.Invoke())) {
# If the timeout period has passed, return false

@iSazonov Ilya (iSazonov) Sep 9, 2017

Copy link
Copy Markdown
Collaborator

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.

Interesting, make sense to enhance Invoke() to support timeout?

Sorry, something went wrong.

Uh oh!

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

All reactions

@daxian-dbw Dongbo Wang (daxian-dbw) Sep 11, 2017 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member 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.

You can do async invocation via powershell API, though the experience is not optimal.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread test/tools/Modules/HelpersCommon/HelpersCommon.psm1 Outdated
$startTime = [DateTime]::Now

# Loop until the file is present
while (-not (Test-Path $File)) {

@iSazonov Ilya (iSazonov) Sep 9, 2017

Copy link
Copy Markdown
Collaborator

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.

Maybe use Wait-UntilTrue? We duplicate code here.

Sorry, something went wrong.

Uh oh!

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

All reactions

@daxian-dbw Dongbo Wang (daxian-dbw) Sep 11, 2017

Copy link
Copy Markdown
Member 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.

Good point. I will change it.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread test/powershell/Language/Scripting/NativeExecution/NativeCommandProcessor.Tests.ps1 Outdated
while (((Get-Date) - $startTime).TotalSeconds -lt 10 -and (-not (Test-Path "$HOME/nativeCommandProcessor.Success"))) {
Start-Sleep -Milliseconds 100
}
Wait-FileToBePresent -File "$HOME/nativeCommandProcessor.Success" -TimeoutInSeconds 10 -IntervalInMilliseconds 100 > $null

@iSazonov Ilya (iSazonov) Sep 9, 2017

Copy link
Copy Markdown
Collaborator

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.

Every use we add ">$null" - so maybe do this internally in Wait-FileToBePresent ? If we need we could add -Passthrou
And why not use Out-Null? It is optimized for pipelines.

Sorry, something went wrong.

Uh oh!

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

All reactions

@daxian-dbw Dongbo Wang (daxian-dbw) Sep 11, 2017 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member 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.

Will change to ignore output in Wait-FileToBePresent. -PassThru can be added when there is a need coming up.

As for Out-Null, I think the optimization was to make Out-Null same as > $null when it's the last command in a pipeline, namely writing to null pipe directly without going through the cmdlet.

Sorry, something went wrong.

Uh oh!

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

All reactions
@daxian-dbw
[Feature] Address comments
d9a4102
@daxian-dbw

Dongbo Wang (daxian-dbw) commented Sep 11, 2017

Copy link
Copy Markdown
Member Author

The failure in AppVeyor is a known issue. It's fixed by #4806

All reactions

Sorry, something went wrong.

Uh oh!

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

iSazonov
Ilya (iSazonov) approved these changes Sep 12, 2017
View reviewed changes
@daxian-dbw
Merge branch 'master' into filewatcher
dd61070
@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit c06ffc4 into PowerShell:master Sep 12, 2017
@daxian-dbw
Dongbo Wang (daxian-dbw) deleted the filewatcher branch September 12, 2017 20:05
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
@daxian-dbw
Add a generic file watcher function in HelpersCommon.psm1 (PowerShell…
00ef7d3
…#4775)

Add a generic file watcher function in HelpersCommon.psm1 and update some tests to use the `Wait-FileToBePresent`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@iSazonov Ilya (iSazonov) iSazonov approved these changes
@TravisEz13 Travis Plunk (TravisEz13) Awaiting requested review from TravisEz13

Uh oh!

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

Assignees

@TravisEz13 Travis Plunk (TravisEz13)

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

@daxian-dbw @iSazonov @msftclas @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.