Skip to content

[META] Issues with Run test Code Lense #438

@lukaszsamson

Description

@lukaszsamson

I played with the new code lense and found a few issues that will need to be sorted out before we can enable it by default.

use MyApp.Web.ConnCase

Edit: this happens when elixir-ls MIX_ENV is not set to test - in that case /test/support is not compiled and elixir_sense is unable to expand the case template macro.
IMO we should drop the imports check as it's too ureliable

  • module level run tests is often misplaced somewhere inside module code
  • run tests on dirty file should trigger save (or warn if that's not feasible)
  • umbrella behaviour is far from optimal - test is run for every app in umbrella
  • tests fail to run with
mix test
==> elixir_ls_utils
Excluding tags: [pending: true]


== Compilation error in file test/tmp/ElixirLS.LanguageServer.ServerTest/test returns code lenses for runnable tests/test/fixture_test.exs ==
** (CompileError) test/tmp/ElixirLS.LanguageServer.ServerTest/test returns code lenses for runnable tests/test/fixture_test.exs:1: cannot define module TestCodeLensTest because it is currently being defined in test/tmp/ElixirLS.LanguageServer.ServerTest/test does not return code lenses for runnable tests when test lenses settings is not set/test/fixture_test.exs:1
    (stdlib 3.13.2) erl_eval.erl:680: :erl_eval.do_apply/6
** (exit) 1
    (mix 1.12.0-dev) lib/mix/tasks/cmd.ex:64: Mix.Tasks.Cmd.run/1
    (mix 1.12.0-dev) lib/mix/task.ex:394: Mix.Task.run_task/3
    (mix 1.12.0-dev) lib/mix/project.ex:352: Mix.Project.in_project/4
    (elixir 1.12.0-dev) lib/file.ex:1554: File.cd!/2
    (mix 1.12.0-dev) lib/mix/task.ex:511: anonymous fn/4 in Mix.Task.recur/1
    (elixir 1.12.0-dev) lib/enum.ex:2270: Enum."-reduce/3-lists^foldl/2-0-"/3
    (mix 1.12.0-dev) lib/mix/task.ex:510: Mix.Task.recur/1
    (mix 1.12.0-dev) lib/mix/project_stack.ex:181: Mix.ProjectStack.recur/1
  • Crashes when test context spans more than 1 line
** (MatchError) no match of right hand side value: nil
    (language_server 0.6.2) lib/language_server/providers/code_lens/test.ex:93: anonymous fn/5 in ElixirLS.LanguageServer.Providers.CodeLens.Test.find_test_blocks/4
    (elixir 1.12.0-dev) lib/enum.ex:2270: Enum."-reduce/3-lists^foldl/2-0-"/3
    (language_server 0.6.2) lib/language_server/providers/code_lens/test.ex:81: ElixirLS.LanguageServer.Providers.CodeLens.Test.find_test_blocks/4
    (language_server 0.6.2) lib/language_server/providers/code_lens/test.ex:39: ElixirLS.LanguageServer.Providers.CodeLens.Test.code_lens/2
    (language_server 0.6.2) lib/language_server/server.ex:696: anonymous fn/3 in ElixirLS.LanguageServer.Server.handle_request/2
    (language_server 0.6.2) lib/language_server/server.ex:748: anonymous fn/3 in ElixirLS.LanguageServer.Server.handle_request_async/2

reproducible by a test with do on the next line like

test "some test", %{
} do
  end

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions