-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Don't wrap stderr as ErrorRecord #5190
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1032,10 +1032,8 @@ private void ProcessOutputRecord(ProcessOutputObject outputValue) | |
|
|
||
| if (outputValue.Stream == MinishellStream.Error) | ||
| { | ||
| ErrorRecord record = outputValue.Data as ErrorRecord; | ||
| Dbg.Assert(record != null, "ProcessReader should ensure that data is ErrorRecord"); | ||
| record.SetInvocationInfo(this.Command.MyInvocation); | ||
| this.commandRuntime._WriteErrorSkipAllowCheck(record, isNativeError: true); | ||
| // write stderr as string instead of as ErrorRecord | ||
| this.commandRuntime._WriteErrorSkipAllowCheck(outputValue.Data); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, |
||
| } | ||
| else if (outputValue.Stream == MinishellStream.Output) | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,24 +102,19 @@ Describe "ConsoleHost unit tests" -tags "Feature" { | |
| } | ||
| } | ||
|
|
||
| It "Verify Validate Dollar Error Populated should throw exception" { | ||
| $origEA = $ErrorActionPreference | ||
| $ErrorActionPreference = "Stop" | ||
| try | ||
| { | ||
| $a = 1,2,3 | ||
| $a | & $powershell -noprofile -command { wgwg-wrwrhqwrhrh35h3h3} | ||
| Throw "Test execution should not reach here!" | ||
| } | ||
| catch | ||
| { | ||
| $_.ToString() | Should Match "wgwg-wrwrhqwrhrh35h3h3" | ||
| $_.FullyQualifiedErrorId | Should Be "CommandNotFoundException" | ||
| } | ||
| finally | ||
| { | ||
| $ErrorActionPreference = $origEA | ||
| } | ||
| It "Verify Validate Dollar Error Populated should be in stderr" { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we also have a test for stream redirection to output?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can add that |
||
| $stderrFile = "$testdrive\stderr.txt" | ||
| & $powershell -noprofile -command { wgwg-wrwrhqwrhrh35h3h3 } 2> $stderrFile | ||
| $stderrFile | Should Exist | ||
| $stderr = Get-Content $stderrFile -Raw | ||
| $stderr | Should Match "wgwg-wrwrhqwrhrh35h3h3" | ||
| $stderr | Should Match "CommandNotFoundException" | ||
| } | ||
|
|
||
| It "Verify Validate Dollar Error Populated should be in stderr redirected to stdout" { | ||
| $err = & $powershell -noprofile -command { wgwg-wrwrhqwrhrh35h3h3 } 2>&1 | ||
| $err.Exception.Message | Should Match "wgwg-wrwrhqwrhrh35h3h3" | ||
| $err.FullyQualifiedErrorId | Should BeExactly "CommandNotFoundException" | ||
| } | ||
|
|
||
| It "Verify Validate Output Format As Text Explicitly Child Single Shell should works" { | ||
|
|
||
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 name this
WriteNativeCommandErrorSkipAllowCheckinstead?