Skip to content

Commit 6c3d0c3

Browse files
committed
Test that a failed download surfaces its real error
1 parent 797546d commit 6c3d0c3

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

test/mix/tasks/compile.make_test.exs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,29 @@ defmodule Mix.Tasks.Compile.ElixirMakeTest do
421421
end)
422422
end
423423

424+
test "surfaces the download error instead of a misleading file-not-found" do
425+
in_fixture(fn ->
426+
File.mkdir!("priv")
427+
428+
File.write("Makefile", """
429+
all:
430+
\t@touch priv/my_app
431+
""")
432+
433+
with_project_config(
434+
[
435+
make_precompiler: {:nif, MyApp.Precompiler},
436+
make_precompiler_url: "https://example.com/@{artefact_filename}",
437+
make_precompiler_downloader: MyApp.FailingDownloader
438+
],
439+
fn ->
440+
System.put_env("ELIXIR_MAKE_CACHE_DIR", "./cache")
441+
assert capture_io(:stderr, fn -> run([]) end) =~ "download boom"
442+
end
443+
)
444+
end)
445+
end
446+
424447
defp in_fixture(fun) do
425448
File.cd!(@fixture_project, fun)
426449
end
@@ -440,3 +463,10 @@ defmodule MyApp.Downloader do
440463
File.read(path)
441464
end
442465
end
466+
467+
defmodule MyApp.FailingDownloader do
468+
@behaviour ElixirMake.Downloader
469+
470+
@impl true
471+
def download(_url), do: {:error, "download boom"}
472+
end

0 commit comments

Comments
 (0)