From 2aa618b9fbf20673a5c3e0395613dd572d0d5708 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20L=C3=A9vesque?= Date: Sun, 21 Feb 2021 10:24:03 -0500 Subject: [PATCH 1/2] fix: No longer expect "do" on test declaration line --- .../providers/code_lens/test.ex | 2 +- .../test/providers/code_lens/test_test.exs | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/apps/language_server/lib/language_server/providers/code_lens/test.ex b/apps/language_server/lib/language_server/providers/code_lens/test.ex index 475463c75..72130dbb1 100644 --- a/apps/language_server/lib/language_server/providers/code_lens/test.ex +++ b/apps/language_server/lib/language_server/providers/code_lens/test.ex @@ -93,7 +93,7 @@ defmodule ElixirLS.LanguageServer.Providers.CodeLens.Test do end) %{"name" => test_name} = - ~r/^\s*test "(?.*)"(,.*)? do/ + ~r/^\s*test "(?.*)"(,.*)?/ |> Regex.named_captures(Enum.at(source_lines, line - 1)) %TestBlock{name: test_name, describe: describe, line: line} diff --git a/apps/language_server/test/providers/code_lens/test_test.exs b/apps/language_server/test/providers/code_lens/test_test.exs index bbb3f803f..81ffc3dc4 100644 --- a/apps/language_server/test/providers/code_lens/test_test.exs +++ b/apps/language_server/test/providers/code_lens/test_test.exs @@ -327,6 +327,29 @@ defmodule ElixirLS.LanguageServer.Providers.CodeLens.TestTest do end end + test "returns lenses for tests with multiline context parameters" do + text = """ + defmodule MyModule do + use ExUnit.Case + + test "test1", %{ + } do + end + end + """ + + uri = "file:///project/file.ex" + + {:ok, lenses} = CodeLens.Test.code_lens(uri, text) + + assert Enum.member?( + lenses, + build_code_lens(3, :test, maybe_convert_path_separators("/project/file.ex"), %{ + "testName" => "test1" + }) + ) + end + defp build_code_lens(line, target, file_path, args) do arguments = %{ From 1d83705745e74b1792fd4e59f523322dfaf5dce6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20L=C3=A9vesque?= Date: Wed, 24 Feb 2021 19:42:02 -0500 Subject: [PATCH 2/2] test: Fix failing test and remove unused function clause --- .../lib/language_server/providers/code_lens/test.ex | 2 -- apps/language_server/test/providers/code_lens/test_test.exs | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/language_server/lib/language_server/providers/code_lens/test.ex b/apps/language_server/lib/language_server/providers/code_lens/test.ex index 72130dbb1..27d891552 100644 --- a/apps/language_server/lib/language_server/providers/code_lens/test.ex +++ b/apps/language_server/lib/language_server/providers/code_lens/test.ex @@ -48,8 +48,6 @@ defmodule ElixirLS.LanguageServer.Providers.CodeLens.Test do end end - def code_lens(_uri, _text), do: {:ok, []} - defp get_test_lenses(test_blocks, file_path, project_dir) do args = fn block -> %{ diff --git a/apps/language_server/test/providers/code_lens/test_test.exs b/apps/language_server/test/providers/code_lens/test_test.exs index 81ffc3dc4..4938e8aa4 100644 --- a/apps/language_server/test/providers/code_lens/test_test.exs +++ b/apps/language_server/test/providers/code_lens/test_test.exs @@ -340,7 +340,7 @@ defmodule ElixirLS.LanguageServer.Providers.CodeLens.TestTest do uri = "file:///project/file.ex" - {:ok, lenses} = CodeLens.Test.code_lens(uri, text) + {:ok, lenses} = CodeLens.Test.code_lens(uri, text, @project_dir) assert Enum.member?( lenses,