From 3b02671cb2cd921a664a5821ce620693bd7f283c Mon Sep 17 00:00:00 2001 From: Yuri Pereira Constante Date: Fri, 24 May 2024 00:26:58 -0300 Subject: [PATCH 1/2] Generate cover HTML files in parallel --- lib/mix/lib/mix/tasks/test.coverage.ex | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/mix/lib/mix/tasks/test.coverage.ex b/lib/mix/lib/mix/tasks/test.coverage.ex index 6e43c14fd27..418e485303d 100644 --- a/lib/mix/lib/mix/tasks/test.coverage.ex +++ b/lib/mix/lib/mix/tasks/test.coverage.ex @@ -288,9 +288,17 @@ defmodule Mix.Tasks.Test.Coverage do output = Keyword.get(opts, :output, "cover") File.mkdir_p!(output) - for mod <- modules do - {:ok, _} = :cover.analyse_to_file(mod, ~c"#{output}/#{mod}.html", [:html]) - end + modules + |> Enum.map(fn mod -> + :cover.async_analyse_to_file(mod, ~c"#{output}/#{mod}.html", [:html]) + end) + |> Enum.map(&Process.monitor/1) + |> Enum.each(fn ref -> + receive do + {:DOWN, ^ref, :process, _pid, _reason} -> + :ok + end + end) Mix.shell().info("Generated HTML coverage results in #{inspect(output)} directory") end From 003c26acac9e2ac0951a7b8106776c3c512fdbbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 24 May 2024 20:21:18 +0200 Subject: [PATCH 2/2] Update lib/mix/lib/mix/tasks/test.coverage.ex --- lib/mix/lib/mix/tasks/test.coverage.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/mix/lib/mix/tasks/test.coverage.ex b/lib/mix/lib/mix/tasks/test.coverage.ex index 418e485303d..4d86d6ddddb 100644 --- a/lib/mix/lib/mix/tasks/test.coverage.ex +++ b/lib/mix/lib/mix/tasks/test.coverage.ex @@ -290,9 +290,9 @@ defmodule Mix.Tasks.Test.Coverage do modules |> Enum.map(fn mod -> - :cover.async_analyse_to_file(mod, ~c"#{output}/#{mod}.html", [:html]) + pid = :cover.async_analyse_to_file(mod, ~c"#{output}/#{mod}.html", [:html]) + Process.monitor(pid) end) - |> Enum.map(&Process.monitor/1) |> Enum.each(fn ref -> receive do {:DOWN, ^ref, :process, _pid, _reason} ->