Skip to content

Commit

Permalink
add test case for publishDiagnostic with -1 line position
Browse files Browse the repository at this point in the history
  • Loading branch information
the-mikedavis committed May 23, 2022
1 parent ae40661 commit 5b0dabc
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
defmodule ElixirLS.LanguageServer.Fixtures.BuildErrors.ArgumentErrorInCompile do
# gives:
# (ArgumentError) each element in tuple list has to be a {function_name :: atom, arity :: 0..255} tuple, got: [hello: 0]
defoverridable [[hello: 0]]
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
defmodule ElixirLS.LanguageServer.Fixtures.ArgumentErrorInCompile.Mixfile do
use Mix.Project

def project do
[app: :els_argument_error_in_compile_test, version: "0.1.0"]
end

def application do
[]
end
end
25 changes: 24 additions & 1 deletion apps/language_server/test/server_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ defmodule ElixirLS.LanguageServer.ServerTest do
end

@tag :fixture
test "reports build diagnostics", %{server: server} do
test "reports CompileError in build diagnostics", %{server: server} do
in_fixture(__DIR__, "build_errors", fn ->
error_file = SourceFile.path_to_uri("lib/has_error.ex")

Expand All @@ -1046,6 +1046,29 @@ defmodule ElixirLS.LanguageServer.ServerTest do
end)
end

@tag :fixture
test "reports ArgumentError in build diagnostics", %{server: server} do
in_fixture(__DIR__, "argument_error_in_compile", fn ->
error_file = SourceFile.path_to_uri("lib/argument_error_in_compile.ex")

initialize(server)

assert_receive notification("textDocument/publishDiagnostics", %{
"uri" => ^error_file,
"diagnostics" => [
%{
"message" => "(ArgumentError) each element in tuple list has to be a {function_name :: atom, arity :: 0..255} tuple, got: [hello: 0]" <> _,
"range" => %{"end" => %{"line" => -1}, "start" => %{"line" => -1}},
"severity" => 1
}
]
}),
1000

wait_until_compiled(server)
end)
end

@tag :fixture
test "reports token missing error diagnostics", %{server: server} do
in_fixture(__DIR__, "token_missing_error", fn ->
Expand Down

0 comments on commit 5b0dabc

Please sign in to comment.