mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-10-06 19:46:00 +08:00
Don't emit diagnostic for module compilation error (#2000)
This commit is contained in:
parent
9a8a252bb9
commit
1443c472ce
2 changed files with 29 additions and 5 deletions
|
@ -829,12 +829,10 @@ defmodule Livebook.Runtime.Evaluator do
|
|||
defp extra_diagnostic?(%SyntaxError{}), do: true
|
||||
defp extra_diagnostic?(%TokenMissingError{}), do: true
|
||||
|
||||
defp extra_diagnostic?(%CompileError{
|
||||
description: "cannot compile file (errors have been logged)"
|
||||
}),
|
||||
do: false
|
||||
defp extra_diagnostic?(%CompileError{description: description}) do
|
||||
not String.contains?(description, "(errors have been logged)")
|
||||
end
|
||||
|
||||
defp extra_diagnostic?(%CompileError{}), do: true
|
||||
defp extra_diagnostic?(_error), do: false
|
||||
|
||||
defp identifier_dependencies(context, tracer_info, prev_context) do
|
||||
|
|
|
@ -217,6 +217,32 @@ defmodule Livebook.Runtime.EvaluatorTest do
|
|||
}}
|
||||
end
|
||||
|
||||
test "returns additional metadata when there is a module compilation error", %{
|
||||
evaluator: evaluator
|
||||
} do
|
||||
code = """
|
||||
defmodule Livebook.Runtime.EvaluatorTest.Invalid do
|
||||
x
|
||||
end
|
||||
"""
|
||||
|
||||
Evaluator.evaluate_code(evaluator, :elixir, code, :code_1, [], file: "file.ex")
|
||||
|
||||
assert_receive {:runtime_evaluation_response, :code_1,
|
||||
{:error,
|
||||
"\e[31m** (CompileError) file.ex: cannot compile module Livebook.Runtime.EvaluatorTest.Invalid " <>
|
||||
"(errors have been logged)\e[0m" <> _, :other},
|
||||
%{
|
||||
code_markers: [
|
||||
%{
|
||||
line: 2,
|
||||
description: ~s/undefined variable "x"/,
|
||||
severity: :error
|
||||
}
|
||||
]
|
||||
}}
|
||||
end
|
||||
|
||||
test "ignores code errors when they happen in the actual evaluation", %{evaluator: evaluator} do
|
||||
code = """
|
||||
Code.eval_string("x")
|
||||
|
|
Loading…
Add table
Reference in a new issue