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

feature: report an error if -race is not working #169

Closed
2 tasks done
augbed opened this issue Aug 31, 2024 · 5 comments · Fixed by #176
Closed
2 tasks done

feature: report an error if -race is not working #169

augbed opened this issue Aug 31, 2024 · 5 comments · Fixed by #176
Labels
enhancement New feature or request

Comments

@augbed
Copy link
Contributor

augbed commented Aug 31, 2024

Did you check docs and existing issues?

Is your feature request related to a problem? Please describe.

Hey,

creating this feature request in case somebody will face the same in the future.

If cgo is not enabled/available then with default configuration tests will be skipped silently with not much help in the logs to narrow down the issue.

In my particular case I am using NixOS and did not had gcc package installed that's required for cgo to work. More about it: Using cgo on NixOS

To easily reproduce you can:

  • run CGO_ENABLED=0 nvim
  • try to run any test

anyways, thanks for your work on the plugin!

Describe the solution you'd like to see.

Race flag should probably not be enabled by default or at least return an error if it fails, currently the only issue that can be seen is exit code 2 in the debug logs.

Describe alternatives you've considered.

If race kept as default might be nice to have information about it in the readme that it might be the reason tests are failing silently.

Additional context

No response

@augbed augbed added the enhancement New feature or request label Aug 31, 2024
@fredrikaverpil
Copy link
Owner

I'll look into this, thank you!

I think just in general that if there's any error when attempting to run a test, there should be a more clear notification/log with the error.

About using -race, do you mean that cgo is required when running go test -race ./...?

@augbed
Copy link
Contributor Author

augbed commented Sep 3, 2024

Yes to use -race you must have cgo enabled and on non-Darwin systems have C compiler as per go docs

You can see an error message that cgo must be enabled if you do CGO_ENABLED=0 go test -race ./...

Also this is not strictly related to this issue, but error reporting in general can be improved. For example when trying to run a test that does not compile (syntax issue for example) it defaults to returning a generic tests were skipped message: Test(s) not associated (not found/executed): { "list_of_skipped_tests" } other neotest adapters usually mark those tests as failed and you can see the reason why it failed in the neotest output. In this case it would be nice to see the build error.

@fredrikaverpil
Copy link
Owner

Yes, 100% agreed. I've thought about this many times myself while using the plugin (I use it on a daily basis). But just to confirm then, this really isn't limited to -race and instead we can rename the issue into being more generic on simply becoming better at reporting when the test command itself returns a non-zero code?

@augbed
Copy link
Contributor Author

augbed commented Sep 6, 2024

Sure, I just noticed the -race thing first. I think if you were to output the text from go test to neotest ouptut on non-zero code and mark the test as failed it would solve all of the above.

@fredrikaverpil
Copy link
Owner

fredrikaverpil commented Sep 6, 2024

Ok, this was actually a little tricky... but if you have the time, please give #176 a try by defining the branch in the plugin options:

{
  "fredrikaverpil/neotest-golang",
  branch = "output-on-failure",
},
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants