From 4b262d8835508ceb07fb930a972f67b4ebe21d6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sun, 22 Dec 2024 16:04:58 +0100 Subject: [PATCH] More coverage around source on parallel compiler --- .../elixir/kernel/parallel_compiler_test.exs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/elixir/test/elixir/kernel/parallel_compiler_test.exs b/lib/elixir/test/elixir/kernel/parallel_compiler_test.exs index 99daa5cff5..d06ab8ec06 100644 --- a/lib/elixir/test/elixir/kernel/parallel_compiler_test.exs +++ b/lib/elixir/test/elixir/kernel/parallel_compiler_test.exs @@ -515,6 +515,31 @@ defmodule Kernel.ParallelCompilerTest do end) end + test "gets both source and file on @file annotations" do + File.mkdir_p!(tmp_path()) + + [a] = + write_tmp( + "file_source", + a: """ + defmodule FileAttr do + @file "unknown.foo.bar" + def fun, do: (unused = :ok) + end + """ + ) + + capture_io(:stderr, fn -> + assert {:ok, [FileAttr], %{compile_warnings: [%{source: ^a, file: file, message: _}]}} = + compile([a]) + + assert String.ends_with?(file, "unknown.foo.bar") + assert Path.type(file) == :absolute + end) + after + purge([FileAttr]) + end + test "gets correct line number for UndefinedFunctionError" do File.mkdir_p!(tmp_path())