-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
feat: spike enabling test diagnostics #339
Conversation
To get this working initially, hard-codes compiles to run with mix_env == :test
Ideally this would be nice so that we can use next ls for "single files" like scripts
I'm not sure i am understanding the purpose of having those options. We aren't actually running the tests, just compiling those files. |
it doesn't seem like you are actually starting the runtime with MIX_ENV=test (unless you are doing that locally with the mix_env init option). I think it would be fine to, on save, send two compilation requests, one for the project as normal and one for the tests (potentially if you are saving a test file, we only trigger a compilation for the test, as the project code wouldn't be different, but it will be a noop any so might be quick enough). starting two runtimes i think might be a no go |
I am a little confused on what these questions mean, we would want diagnostics to get published to the editor. |
I can look into what this might look like; maybe just try to run
This was more a note to self, because the |
The difficulty I see with only having one runtime (with |
This was also more of a note to self; warnings are returned separately from errors and compile results by I posted in discord because I was excited to see an error in the editor. I do see that with this code, only the initial compile appears to generate diagnostics--there is definitely more work to do to ensure this is robust and reliable. |
c53cccb
to
ddcf26d
Compare
ddcf26d
to
6cdcd00
Compare
Spike code is working well for me in the next-ls repo now, and I have a passing integration test. I'll continue to verify while I work through the remaining todos. |
Looking more into the dev vs. test profile question, it seems like attempting to compile the tests with the dev profile is unlikely to work in many cases. I was previously testing locally with some code that set the runtime's mix env to I'm not familiar enough with the elixir ecosystem to be really confident in the suggestion, but my feeling is that most dev dependencies will be for mix tasks that generate documentation, lint, etc. or developer tools that can be used from iex and not part of the actual compiled codebase. It's possible using Apologies for some poor communication on this; I'm finally on the other side of fighting through a nasty head cold, and it was harder than I would like to think things through clearly. Hopefully what I've written above makes sense. |
And re: getting diagnostics on standalone exs files, that feels like a larger effort. I went to try to test it and discovered that the vim plugin only starts a workspace when it finds a mix file: https://github.com/elixir-tools/elixir-tools.nvim/blob/8f573b0b089567aa9c544b029000c97e715e5f58/lua/elixir/nextls/init.lua#L76. The runtime also depends heavily on mix commands. That would be a nice feature, but perhaps it can be delivered separately from surfacing test diagnostics in mix projects. |
5de54a8
to
c8edc6d
Compare
c8edc6d
to
de81e32
Compare
I cleaned up the code and went with the implementation that I think makes sense, where tests are only compiled if the user sets I tested this against the main branches of next-ls, ecto, phoenix, credo, and oban. Open to suggestions if you have thoughts on other repos that might be good to check. It works for next-ls, phoenix, and credo, but not for ecto and oban. In particular, the test helper files fail to load successfully in both ecto and oban. I'm going to do a bit of refactoring to ensure that non-test diagnostics are reported if test helpers fail to load as well as see if I can get to the bottom of what's going wrong in ecto and oban. |
Alright, I believe I understand what's going on with ecto and oban. In both cases, the Because there is no separation between requiring test helper code and starting test applications, I believe we'll need to start the mix application, like |
Why do you need to compile the test helper file? |
Because it can load modules that the tests depend on. For example, ecto tests rely on the test repo module loaded here. |
I think this might take some more hacking/thinking, so let's put a pause on this for now. I really appreciate the effort! We've learned a lot. |
No worries, I understand. This is more difficult and a bigger change than expected initially. Pushed up what I have, which works reliably and quickly on all repos above except ecto. This way if someone wants to pick it up in the future, the work is here. Documenting the remaining known bug at the moment: in ecto, there are some spurious warnings that seem related to a difference between It might also make sense to have running |
Compiles and returns compiler diagnostics for tests when
mix_env = "test"
is included in the next-ls init options. Should have no effect with the default "dev" mix_env.TODO
lib
when test helpers fail to load