Skip to content
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

Broken output when non-json lines occur #25

Closed
Davincible opened this issue Nov 4, 2022 · 4 comments · May be fixed by #27
Closed

Broken output when non-json lines occur #25

Davincible opened this issue Nov 4, 2022 · 4 comments · May be fixed by #27

Comments

@Davincible
Copy link
Contributor

The go test -json package has a tendency to include non-json output in some cases. For example when one (distant) sub-package doesn't compile. As a result of this, if I have one not-compiling file in my whole project, non of my tests will report as passing, even though they pass, and the log output will not be parsed.

The problematic code is here;

local ok, parsed = pcall(vim.json.decode, line, { luanil = { object = true } })
if not ok then
log = vim.tbl_map(function(l)
return highlight_output(l)
end, lines)
return tests, log
end

It happens because it now returns prematurely when one line has no valid json. We can either ignore the line here, or try to include it as is.

How do you want to handle this scenario? I can implement a fix

@Davincible
Copy link
Contributor Author

Any general build message is not logged out as json, but should still be included in the output. E.g. import cycle

@akinsho
Copy link
Collaborator

akinsho commented Nov 4, 2022

@Davincible do you have a solution in mind. FWIW AFAIK most go testing explodes if there is any error in the package so I view it not working with invalid code as normal. I wouldn't expect it to partially run since I don't think go supports that, happy to be corrected if there is a non overly complex way to do that.

Essentially, if there is no valid json then you can't really call any of the parsing functions since they expect json. I guess you'd need some other mechanism to pass the output string to neotest's output. Happy to review a PR 🤷🏿

@Bacbia3696
Copy link
Contributor

Bacbia3696 commented Feb 26, 2023

I have the same issue, that when I run test, it show some warning so that neotest-go can not parse because it's invalid json,
should we add option '2>/dev/null' to the command execute unit test ?
This will show the warning:
go test ./x/distributionx/... -run TestKeeperTestSuite/TestAllocateTokens -v -json

cgo-gcc-prolog:217:2: warning: 'FSEventStreamScheduleWithRunLoop' is deprecated: first deprecated in macOS 13.0 - Use FSEventStreamSetDispatchQueue instead. [-Wdeprecated-declarations]
/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/FSEvents.framework/Headers/FSEvents.h:1138:1: note: 'FSEventStreamScheduleWithRunLoop' has been explicitly marked deprecated here

But this will work fine:
go test ./x/distributionx/... -run TestKeeperTestSuite/TestAllocateTokens -v -json 2>/dev/null
I am on Mac, and I don't know how to make it work on Window.

@fredrikaverpil
Copy link

I believe this can be closed as this got merged: #54

@akinsho akinsho closed this as completed Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants