-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
GoTest: Output original message on failure return code #676
Conversation
@@ -93,7 +93,7 @@ endfunction | |||
" it'll be closed. | |||
function! s:on_exit(job_id, data) | |||
let std_combined = self.stderr + self.stdout | |||
if empty(std_combined) | |||
if jobwait([a:job_id])[0] > 0 |
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.
jobwait(...)
is needed to get the return code of the job. Since it's called on_exit of the respective job, it should never block, so I didn't provide a timeout.
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 is a highly critical path as it's used by many applications. As I know relying on exit code might produce wrong results. I don't remember which subcommand or command, but there was a case where I wanted to get the output regardless of job id. Do we need to change it here ?
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 should make it equivalent to checking v:shell_error. But yes, if there are commands that specifically avoid checking v:shell_error, then using jobcontrol would yield unexpected FAILURE. Are there any? Only one I can think of off the top of my head is the linter, which refuses to use proper return codes in a silly philosophical protest.
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.
Ok, valid arguments. Right now we only use it for build
and test
. If there is anything wrong with any upstream app, we should fix it instead of.
Jobcontrol is only valid for neovim though, did you also test it with Vim? Or is this only valid for Neovim? |
https://github.com/fatih/vim-go/pull/676/files#diff-a3998a862a20bc1665a15c84f401349fR198 is the change for plain-Vim. It's exactly the same change as gorename had. As I mentioned, it dumps the full output unlike the neovim path which dumps just the first line. I have mixed feelings about that inconsistency, let me know how you feel about it. :) |
Btw, I've just pulled this and tried it on a very simple app, such as : package main
import (
"fmt"
)
func main() {
fmt.Println("fatih arslan")
} The output is: I've echoed it and it returns
|
Hm what version of neovim are you running? I'm on NVIM 0.1.1. |
Forgot to say which part I've echoed:
|
I have this too: NVIM 0.1.1 (compiled Dec 28 2015 16:18:38) |
HMMMMM strange, can't reproduce it on my end. Will dig around, let me know if you stumble on a better way. :) |
Ah :GoBuild does indeed reproduce, I was trying :GoTest. Hmm. |
Yeah, I was going to try :GoBuild and :GoTest, couldn't try :GoTest as :GoBuild just failed. |
Aha, a:data has the return code, so we don't need jobwait. Fixing. |
Can you rename the variable to |
When using jobcontrol, assume FAILED if return code is >0. Only prints the first line.
Fixed! Btw nice way to test a command error,
|
Great, indeed it works perfect :) Thanks!. Btw can you change the variable name? I think you missed it? If not I can do it later after merging :) Just let me know please |
GoTest: Output original message on failure return code
Thanks @shazow 👍 |
It's changed, I've been force-pushing into the same commit like a gentleman/savage (depending on your practices). :p |
Happy to help! 🍮 |
Yeah, I had the cache, didn't saw it 🤦 :) |
|
||
let self.state = "SUCCESS" | ||
" failed to parse errors, output the original content | ||
call go#util#EchoError(std_combined[0]) |
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 is causing errors when std_combined is empty.
When using jobcontrol, assume FAILED if return code is >0. Only prints the first line.
This one is a little messier than the GoRename fix. The non-jobcontrol semantics aren't identical, as it prints the entire output rather than just the first line (but it's more consistent with the GoRename fix).
Let me know if you'd like for me to change it to be consistent. The output on unexpected test failures is typically a panic/timeout, so it's quite big.