| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Sarith Sutha (@sarithsutha), |
Sorry, something went wrong.
|
|
||
| It "Should be able to use the whatif switch without error" { | ||
| { Start-Process $pingCommand -ArgumentList $pingParam -WhatIf } | Should Not Throw | ||
| } |
There was a problem hiding this comment.
Perhaps add a test that would normally perform an action and ensure that -WhatIf prevented the action?
For example, have a Start-Process command to write a string to a file and then test to ensure the file was not written to with -WhatIf is supplied.
Sorry, something went wrong.
There was a problem hiding this comment.
Maybe also a test that using the -PassThru switch, no object gets returned (which is also a good additional test that the command was not executed)?
It "returns null when using -WhatIf switch with `PassThru`" {
{ Start-Process $pingCommand -ArgumentList $pingParam -PassThru -WhatIf } | Should Be $null
}
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks for your suggestion Christoph Bergmeister (@bergmeister) . I've added the test that you described.
Sorry, something went wrong.
… from being performed.
|
Thanks for your suggestion Mark Kraus (@markekraus) . I've added that test. |
Sorry, something went wrong.
|
|
||
| It "Should be able to use the whatif switch without error" { | ||
| { Start-Process $pingCommand -ArgumentList $pingParam -WhatIf } | Should Not Throw | ||
| } |
There was a problem hiding this comment.
I think the test does not need - next do the check.
Sorry, something went wrong.
There was a problem hiding this comment.
I'm sorry, I did not get which - were you referring to.
Sorry, something went wrong.
There was a problem hiding this comment.
I meant next It block.
Sorry, something went wrong.
| It "Should be able to use the whatif switch without performing the actual action" { | ||
| $pingOutput = Join-Path $TestDrive "pingOutput.txt" | ||
| Start-Process -Wait $pingCommand -ArgumentList $pingParam -RedirectStandardOutput $pingOutput -WhatIf | ||
| Test-Path $pingOutput | Should Be $false |
There was a problem hiding this comment.
Maybe:
$pingOutput | Should Not Exist
Sorry, something went wrong.
| </data> | ||
| <data name="ProcessStartInfo" xml:space="preserve"> | ||
| <value>{0} {1}</value> | ||
| </data> |
There was a problem hiding this comment.
We re-use ProcessNameForConfirmation in Stop-Process and Debug-Process so I believe we can use the same in Start-process.
Sorry, something went wrong.
There was a problem hiding this comment.
The original request was to output the exact command being executed. By re-using the ProcessNameForConfirmation, the format of the output will be changed slightly, the arguments would appear in the parentheses. i.e. C:\WINDOWS\system32\PING.EXE (-n 2 localhost) instead of C:\WINDOWS\system32\PING.EXE -n 2 localhost.
If that is acceptable, I'm happy to make the change.
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks for clarify.
Closed.
Sorry, something went wrong.
|
|
||
| It "Should be able to use the whatif switch without performing the actual action" { | ||
| $pingOutput = Join-Path $TestDrive "pingOutput.txt" | ||
| Start-Process -Wait $pingCommand -ArgumentList $pingParam -RedirectStandardOutput $pingOutput -WhatIf |
There was a problem hiding this comment.
We can remove next It and do the check here.
Sorry, something went wrong.
| It "Should be able to use the -WhatIf switch without performing the actual action" { | ||
| $pingOutput = Join-Path $TestDrive "pingOutput.txt" | ||
| Start-Process -Wait $pingCommand -ArgumentList $pingParam -RedirectStandardOutput $pingOutput -WhatIf | ||
| { Start-Process -Wait $pingCommand -ArgumentList $pingParam -RedirectStandardOutput $pingOutput -WhatIf} | Should Not Throw |
There was a problem hiding this comment.
I believe -ErrorAction Stop is required or it will never actually throw.
Sorry, something went wrong.
There was a problem hiding this comment.
I agree.
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks Mark Kraus (@markekraus) for pointing this out. Not sure how I missed it.
Sorry, something went wrong.
There was a problem hiding this comment.
AppVeyor failed on other tests so the PR LGTM with one minor comment..
Sorry, something went wrong.
|
Thanks Ilya (@iSazonov) for reviewing and approving my changes. The minor comment is now incorporated. |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM
Sorry, something went wrong.
|
Dongbo Wang (@daxian-dbw) Could you please review and approve? |
Sorry, something went wrong.
| startInfo.WindowStyle = _windowstyle; | ||
| } | ||
|
|
||
| string targetMessage = StringUtil.Format(ProcessResources.ProcessStartInfo, startInfo.FileName, startInfo.Arguments.Trim()); |
There was a problem hiding this comment.
The resource string id ProcessStartInfo should be changed to StartProcessTarget.
Sorry, something went wrong.
There was a problem hiding this comment.
Dongbo Wang (@daxian-dbw) Renamed the resource string as suggested.
Sorry, something went wrong.
There was a problem hiding this comment.
Sarith Sutha (@sarithsutha) Thanks!
Sorry, something went wrong.
|
Sarith Sutha (@sarithsutha) Thanks for your contribution! |
Sorry, something went wrong.
* Add -WhatIf switch to Start-Process cmdlet * Add test for the -WhatIf switch * Added a test to ensure that using a whatif switch prevents the action from being performed. * Incorporated code review comments * merged two tests into one as suggested * Included the error action at the end of the cmdlet * Remove extra space before `StringUtil` and new line * Renamed the resource string id ProcessStartInfo to StartProcessTarget
| Back | FazBrowse Home | New Git URL |
Closes #4702
Add -WhatIf switch to Start-Process cmdlet