From 301fd250e078d0d51b1fdddf298c0e6615b189fb Mon Sep 17 00:00:00 2001 From: dstroch Date: Sun, 15 Jan 2023 14:17:27 +0100 Subject: [PATCH 01/11] Add test to invoke onigumo from CLI --- test/onigumo_cli_test.exs | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 test/onigumo_cli_test.exs diff --git a/test/onigumo_cli_test.exs b/test/onigumo_cli_test.exs new file mode 100644 index 0000000..536455f --- /dev/null +++ b/test/onigumo_cli_test.exs @@ -0,0 +1,11 @@ +defmodule OnigumoCLITest do + use ExUnit.Case + + + describe("Onigumo.CLI.main/1") do + test("run Onigumo.CLI.main") do + Onigumo.CLI.main(["arg1"]) + end + end +end + From 84364526033e3fc113a428bbaf99ba16c21c92f2 Mon Sep 17 00:00:00 2001 From: dstroch Date: Sat, 20 May 2023 19:00:58 +0200 Subject: [PATCH 02/11] Move private function body and prepare_response - These functions was moved because we need them in more tests then just one --- mix.exs | 7 ++++++- test/onigumo_downloader_test.exs | 29 +++++++++-------------------- test/support/http_test_util.ex | 13 +++++++++++++ 3 files changed, 28 insertions(+), 21 deletions(-) create mode 100644 test/support/http_test_util.ex diff --git a/mix.exs b/mix.exs index 77e7906..8cc9d4b 100644 --- a/mix.exs +++ b/mix.exs @@ -8,7 +8,8 @@ defmodule Onigumo.MixProject do elixir: "~> 1.10", start_permanent: Mix.env() == :prod, deps: deps(), - escript: escript() + escript: escript(), + elixirc_paths: elixirc_paths(Mix.env()), ] end @@ -37,4 +38,8 @@ defmodule Onigumo.MixProject do main_module: Onigumo.CLI ] end + + defp elixirc_paths(:test), do: ["lib", "test/support"] + defp elixirc_paths(_), do: [ "lib" ] + end diff --git a/test/onigumo_downloader_test.exs b/test/onigumo_downloader_test.exs index 8d04baf..2639984 100644 --- a/test/onigumo_downloader_test.exs +++ b/test/onigumo_downloader_test.exs @@ -14,7 +14,7 @@ defmodule OnigumoDownloaderTest do @tag :tmp_dir test("run Downloader", %{tmp_dir: tmp_dir}) do expect(HTTPoisonMock, :start, fn -> nil end) - expect(HTTPoisonMock, :get!, length(@urls), &prepare_response/1) + expect(HTTPoisonMock, :get!, length(@urls), &HttpTestUtil.prepare_response/1) input_path_env = Application.get_env(:onigumo, :input_path) input_path_tmp = Path.join(tmp_dir, input_path_env) @@ -30,7 +30,7 @@ defmodule OnigumoDownloaderTest do describe("Onigumo.Downloader.create_download_stream/1") do @tag :tmp_dir test("download URLs from the input file with a created stream", %{tmp_dir: tmp_dir}) do - expect(HTTPoisonMock, :get!, length(@urls), &prepare_response/1) + expect(HTTPoisonMock, :get!, length(@urls), &HttpTestUtil.prepare_response/1) input_path_env = Application.get_env(:onigumo, :input_path) input_path_tmp = Path.join(tmp_dir, input_path_env) @@ -46,7 +46,7 @@ defmodule OnigumoDownloaderTest do describe("Onigumo.Downloader.download_url/2") do @tag :tmp_dir test("download a URL", %{tmp_dir: tmp_dir}) do - expect(HTTPoisonMock, :get!, &prepare_response/1) + expect(HTTPoisonMock, :get!, &HttpTestUtil.prepare_response/1) input_url = Enum.at(@urls, 0) Onigumo.Downloader.download_url(input_url, tmp_dir) @@ -54,18 +54,18 @@ defmodule OnigumoDownloaderTest do output_file_name = Onigumo.Downloader.create_file_name(input_url) output_path = Path.join(tmp_dir, output_file_name) read_output = File.read!(output_path) - expected_output = body(input_url) + expected_output = HttpTestUtil.body(input_url) assert(read_output == expected_output) end end describe("Onigumo.Downloader.get_url/1") do test("get response by HTTP request") do - expect(HTTPoisonMock, :get!, &prepare_response/1) + expect(HTTPoisonMock, :get!, &HttpTestUtil.prepare_response/1) url = Enum.at(@urls, 0) get_response = Onigumo.Downloader.get_url(url) - expected_response = prepare_response(url) + expected_response = HttpTestUtil.prepare_response(url) assert(get_response == expected_response) end end @@ -73,9 +73,9 @@ defmodule OnigumoDownloaderTest do describe("Onigumo.Downloader.get_body/1") do test("extract body from URL response") do url = Enum.at(@urls, 0) - response = prepare_response(url) + response = HttpTestUtil.prepare_response(url) get_body = Onigumo.Downloader.get_body(response) - expected_body = body(url) + expected_body = HttpTestUtil.body(url) assert(get_body == expected_body) end end @@ -121,27 +121,16 @@ defmodule OnigumoDownloaderTest do end end - defp prepare_response(url) do - %HTTPoison.Response{ - status_code: 200, - body: body(url) - } - end - defp prepare_input(urls) do Enum.map(urls, &(&1 <> "\n")) |> Enum.join() end - defp body(url) do - "Body from: #{url}\n" - end - defp assert_downloaded(url, tmp_dir) do file_name = Onigumo.Downloader.create_file_name(url) output_path = Path.join(tmp_dir, file_name) read_output = File.read!(output_path) - expected_output = body(url) + expected_output = HttpTestUtil.body(url) assert(read_output == expected_output) end end diff --git a/test/support/http_test_util.ex b/test/support/http_test_util.ex new file mode 100644 index 0000000..01628c2 --- /dev/null +++ b/test/support/http_test_util.ex @@ -0,0 +1,13 @@ +defmodule HttpTestUtil do + + def prepare_response(url) do + %HTTPoison.Response{ + status_code: 200, + body: body(url) + } + end + + def body(url) do + "Body from: #{url}\n" + end +end From e807364585d0641680254c1f2f79cf43bc6acb36 Mon Sep 17 00:00:00 2001 From: dstroch Date: Sat, 20 May 2023 19:08:07 +0200 Subject: [PATCH 03/11] Rename file from http_util to http - when we move the file to folder support util in name is extra. The mean of util is include in folder name support --- test/support/{http_test_util.ex => http.ex} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/support/{http_test_util.ex => http.ex} (100%) diff --git a/test/support/http_test_util.ex b/test/support/http.ex similarity index 100% rename from test/support/http_test_util.ex rename to test/support/http.ex From 16ead5368bdc49e2af992366dc50762773e4309d Mon Sep 17 00:00:00 2001 From: dstroch Date: Sat, 20 May 2023 19:50:49 +0200 Subject: [PATCH 04/11] Rename module HttpTestUtil to HttpSupport --- test/onigumo_downloader_test.exs | 18 +++++++++--------- test/support/http.ex | 3 ++- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/test/onigumo_downloader_test.exs b/test/onigumo_downloader_test.exs index 2639984..59fb11b 100644 --- a/test/onigumo_downloader_test.exs +++ b/test/onigumo_downloader_test.exs @@ -14,7 +14,7 @@ defmodule OnigumoDownloaderTest do @tag :tmp_dir test("run Downloader", %{tmp_dir: tmp_dir}) do expect(HTTPoisonMock, :start, fn -> nil end) - expect(HTTPoisonMock, :get!, length(@urls), &HttpTestUtil.prepare_response/1) + expect(HTTPoisonMock, :get!, length(@urls), &HttpSupport.prepare_response/1) input_path_env = Application.get_env(:onigumo, :input_path) input_path_tmp = Path.join(tmp_dir, input_path_env) @@ -30,7 +30,7 @@ defmodule OnigumoDownloaderTest do describe("Onigumo.Downloader.create_download_stream/1") do @tag :tmp_dir test("download URLs from the input file with a created stream", %{tmp_dir: tmp_dir}) do - expect(HTTPoisonMock, :get!, length(@urls), &HttpTestUtil.prepare_response/1) + expect(HTTPoisonMock, :get!, length(@urls), &HttpSupport.prepare_response/1) input_path_env = Application.get_env(:onigumo, :input_path) input_path_tmp = Path.join(tmp_dir, input_path_env) @@ -46,7 +46,7 @@ defmodule OnigumoDownloaderTest do describe("Onigumo.Downloader.download_url/2") do @tag :tmp_dir test("download a URL", %{tmp_dir: tmp_dir}) do - expect(HTTPoisonMock, :get!, &HttpTestUtil.prepare_response/1) + expect(HTTPoisonMock, :get!, &HttpSupport.prepare_response/1) input_url = Enum.at(@urls, 0) Onigumo.Downloader.download_url(input_url, tmp_dir) @@ -54,18 +54,18 @@ defmodule OnigumoDownloaderTest do output_file_name = Onigumo.Downloader.create_file_name(input_url) output_path = Path.join(tmp_dir, output_file_name) read_output = File.read!(output_path) - expected_output = HttpTestUtil.body(input_url) + expected_output = HttpSupport.body(input_url) assert(read_output == expected_output) end end describe("Onigumo.Downloader.get_url/1") do test("get response by HTTP request") do - expect(HTTPoisonMock, :get!, &HttpTestUtil.prepare_response/1) + expect(HTTPoisonMock, :get!, &HttpSupport.prepare_response/1) url = Enum.at(@urls, 0) get_response = Onigumo.Downloader.get_url(url) - expected_response = HttpTestUtil.prepare_response(url) + expected_response = HttpSupport.prepare_response(url) assert(get_response == expected_response) end end @@ -73,9 +73,9 @@ defmodule OnigumoDownloaderTest do describe("Onigumo.Downloader.get_body/1") do test("extract body from URL response") do url = Enum.at(@urls, 0) - response = HttpTestUtil.prepare_response(url) + response = HttpSupport.prepare_response(url) get_body = Onigumo.Downloader.get_body(response) - expected_body = HttpTestUtil.body(url) + expected_body = HttpSupport.body(url) assert(get_body == expected_body) end end @@ -130,7 +130,7 @@ defmodule OnigumoDownloaderTest do file_name = Onigumo.Downloader.create_file_name(url) output_path = Path.join(tmp_dir, file_name) read_output = File.read!(output_path) - expected_output = HttpTestUtil.body(url) + expected_output = HttpSupport.body(url) assert(read_output == expected_output) end end diff --git a/test/support/http.ex b/test/support/http.ex index 01628c2..0f49c1d 100644 --- a/test/support/http.ex +++ b/test/support/http.ex @@ -1,4 +1,4 @@ -defmodule HttpTestUtil do +defmodule HttpSupport do def prepare_response(url) do %HTTPoison.Response{ @@ -10,4 +10,5 @@ defmodule HttpTestUtil do def body(url) do "Body from: #{url}\n" end + end From b083ba72f2ca75355662d2d5de33d56ba41013ec Mon Sep 17 00:00:00 2001 From: dstroch Date: Sat, 20 May 2023 19:51:36 +0200 Subject: [PATCH 05/11] Move prepare input func to support --- test/onigumo_downloader_test.exs | 11 +++-------- test/support/input.ex | 8 ++++++++ 2 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 test/support/input.ex diff --git a/test/onigumo_downloader_test.exs b/test/onigumo_downloader_test.exs index 59fb11b..f8c2033 100644 --- a/test/onigumo_downloader_test.exs +++ b/test/onigumo_downloader_test.exs @@ -18,7 +18,7 @@ defmodule OnigumoDownloaderTest do input_path_env = Application.get_env(:onigumo, :input_path) input_path_tmp = Path.join(tmp_dir, input_path_env) - input_file_content = prepare_input(@urls) + input_file_content = InputSupport.prepare(@urls) File.write!(input_path_tmp, input_file_content) Onigumo.Downloader.main(tmp_dir) @@ -34,7 +34,7 @@ defmodule OnigumoDownloaderTest do input_path_env = Application.get_env(:onigumo, :input_path) input_path_tmp = Path.join(tmp_dir, input_path_env) - input_file_content = prepare_input(@urls) + input_file_content = InputSupport.prepare(@urls) File.write!(input_path_tmp, input_file_content) Onigumo.Downloader.create_download_stream(tmp_dir) |> Stream.run() @@ -101,7 +101,7 @@ defmodule OnigumoDownloaderTest do input_path_env = Application.get_env(:onigumo, :input_path) input_path_tmp = Path.join(tmp_dir, input_path_env) - input_file_content = prepare_input(input_urls) + input_file_content = InputSupport.prepare(input_urls) File.write!(input_path_tmp, input_file_content) loaded_urls = Onigumo.Downloader.load_urls(tmp_dir) |> Enum.to_list() @@ -121,11 +121,6 @@ defmodule OnigumoDownloaderTest do end end - defp prepare_input(urls) do - Enum.map(urls, &(&1 <> "\n")) - |> Enum.join() - end - defp assert_downloaded(url, tmp_dir) do file_name = Onigumo.Downloader.create_file_name(url) output_path = Path.join(tmp_dir, file_name) diff --git a/test/support/input.ex b/test/support/input.ex new file mode 100644 index 0000000..84d92c4 --- /dev/null +++ b/test/support/input.ex @@ -0,0 +1,8 @@ +defmodule InputSupport do + + def prepare(urls) do + Enum.map(urls, &(&1 <> "\n")) + |> Enum.join() + end + +end From 71262f7b9efe7ae744cb1eb01210444280638213 Mon Sep 17 00:00:00 2001 From: dstroch Date: Sat, 20 May 2023 19:54:15 +0200 Subject: [PATCH 06/11] Test CLI with input for 'Downloader' --- test/onigumo_cli_test.exs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/test/onigumo_cli_test.exs b/test/onigumo_cli_test.exs index 536455f..f8e8a23 100644 --- a/test/onigumo_cli_test.exs +++ b/test/onigumo_cli_test.exs @@ -1,11 +1,26 @@ defmodule OnigumoCLITest do use ExUnit.Case + import Mox + @urls [ + "http://onigumo.local/hello.html", + "http://onigumo.local/bye.html" + ] describe("Onigumo.CLI.main/1") do - test("run Onigumo.CLI.main") do - Onigumo.CLI.main(["arg1"]) + @tag :tmp_dir + test("run Onigumo.CLI.main", %{tmp_dir: tmp_dir}) do + expect(HTTPoisonMock, :start, fn -> nil end) + expect(HTTPoisonMock, :get!, length(@urls), &HttpSupport.prepare_response/1) + + input_path_env = Application.get_env(:onigumo, :input_path) + input_path_tmp = Path.join(tmp_dir, input_path_env) + input_file_content = InputSupport.prepare(@urls) + File.write!(input_path_tmp, input_file_content) + File.cd(tmp_dir) + Onigumo.CLI.main(["Downloader"]) end end + end From fc5380f902c2ba6a0341111de8b6cbbc5fd7f54c Mon Sep 17 00:00:00 2001 From: dstroch Date: Tue, 23 May 2023 11:54:13 +0200 Subject: [PATCH 07/11] Format the code with mix --- mix.exs | 5 ++--- test/onigumo_cli_test.exs | 2 -- test/support/http.ex | 2 -- test/support/input.ex | 2 -- 4 files changed, 2 insertions(+), 9 deletions(-) diff --git a/mix.exs b/mix.exs index 8cc9d4b..a2239b2 100644 --- a/mix.exs +++ b/mix.exs @@ -9,7 +9,7 @@ defmodule Onigumo.MixProject do start_permanent: Mix.env() == :prod, deps: deps(), escript: escript(), - elixirc_paths: elixirc_paths(Mix.env()), + elixirc_paths: elixirc_paths(Mix.env()) ] end @@ -40,6 +40,5 @@ defmodule Onigumo.MixProject do end defp elixirc_paths(:test), do: ["lib", "test/support"] - defp elixirc_paths(_), do: [ "lib" ] - + defp elixirc_paths(_), do: ["lib"] end diff --git a/test/onigumo_cli_test.exs b/test/onigumo_cli_test.exs index f8e8a23..5cc2a17 100644 --- a/test/onigumo_cli_test.exs +++ b/test/onigumo_cli_test.exs @@ -21,6 +21,4 @@ defmodule OnigumoCLITest do Onigumo.CLI.main(["Downloader"]) end end - end - diff --git a/test/support/http.ex b/test/support/http.ex index 0f49c1d..c2e0821 100644 --- a/test/support/http.ex +++ b/test/support/http.ex @@ -1,5 +1,4 @@ defmodule HttpSupport do - def prepare_response(url) do %HTTPoison.Response{ status_code: 200, @@ -10,5 +9,4 @@ defmodule HttpSupport do def body(url) do "Body from: #{url}\n" end - end diff --git a/test/support/input.ex b/test/support/input.ex index 84d92c4..155a3bb 100644 --- a/test/support/input.ex +++ b/test/support/input.ex @@ -1,8 +1,6 @@ defmodule InputSupport do - def prepare(urls) do Enum.map(urls, &(&1 <> "\n")) |> Enum.join() end - end From 6b380c7a1cb0c0de33c77e5ce385fe422e0df680 Mon Sep 17 00:00:00 2001 From: dstroch Date: Sat, 29 Jul 2023 20:30:03 +0200 Subject: [PATCH 08/11] Remove prepare in the name of support functions --- test/onigumo_cli_test.exs | 4 ++-- test/onigumo_downloader_test.exs | 18 +++++++++--------- test/support/http.ex | 2 +- test/support/input.ex | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/test/onigumo_cli_test.exs b/test/onigumo_cli_test.exs index 5cc2a17..56db75a 100644 --- a/test/onigumo_cli_test.exs +++ b/test/onigumo_cli_test.exs @@ -11,11 +11,11 @@ defmodule OnigumoCLITest do @tag :tmp_dir test("run Onigumo.CLI.main", %{tmp_dir: tmp_dir}) do expect(HTTPoisonMock, :start, fn -> nil end) - expect(HTTPoisonMock, :get!, length(@urls), &HttpSupport.prepare_response/1) + expect(HTTPoisonMock, :get!, length(@urls), &HttpSupport.response/1) input_path_env = Application.get_env(:onigumo, :input_path) input_path_tmp = Path.join(tmp_dir, input_path_env) - input_file_content = InputSupport.prepare(@urls) + input_file_content = InputSupport.url_list(@urls) File.write!(input_path_tmp, input_file_content) File.cd(tmp_dir) Onigumo.CLI.main(["Downloader"]) diff --git a/test/onigumo_downloader_test.exs b/test/onigumo_downloader_test.exs index f8c2033..abc334a 100644 --- a/test/onigumo_downloader_test.exs +++ b/test/onigumo_downloader_test.exs @@ -14,11 +14,11 @@ defmodule OnigumoDownloaderTest do @tag :tmp_dir test("run Downloader", %{tmp_dir: tmp_dir}) do expect(HTTPoisonMock, :start, fn -> nil end) - expect(HTTPoisonMock, :get!, length(@urls), &HttpSupport.prepare_response/1) + expect(HTTPoisonMock, :get!, length(@urls), &HttpSupport.response/1) input_path_env = Application.get_env(:onigumo, :input_path) input_path_tmp = Path.join(tmp_dir, input_path_env) - input_file_content = InputSupport.prepare(@urls) + input_file_content = InputSupport.url_list(@urls) File.write!(input_path_tmp, input_file_content) Onigumo.Downloader.main(tmp_dir) @@ -30,11 +30,11 @@ defmodule OnigumoDownloaderTest do describe("Onigumo.Downloader.create_download_stream/1") do @tag :tmp_dir test("download URLs from the input file with a created stream", %{tmp_dir: tmp_dir}) do - expect(HTTPoisonMock, :get!, length(@urls), &HttpSupport.prepare_response/1) + expect(HTTPoisonMock, :get!, length(@urls), &HttpSupport.response/1) input_path_env = Application.get_env(:onigumo, :input_path) input_path_tmp = Path.join(tmp_dir, input_path_env) - input_file_content = InputSupport.prepare(@urls) + input_file_content = InputSupport.url_list(@urls) File.write!(input_path_tmp, input_file_content) Onigumo.Downloader.create_download_stream(tmp_dir) |> Stream.run() @@ -46,7 +46,7 @@ defmodule OnigumoDownloaderTest do describe("Onigumo.Downloader.download_url/2") do @tag :tmp_dir test("download a URL", %{tmp_dir: tmp_dir}) do - expect(HTTPoisonMock, :get!, &HttpSupport.prepare_response/1) + expect(HTTPoisonMock, :get!, &HttpSupport.response/1) input_url = Enum.at(@urls, 0) Onigumo.Downloader.download_url(input_url, tmp_dir) @@ -61,11 +61,11 @@ defmodule OnigumoDownloaderTest do describe("Onigumo.Downloader.get_url/1") do test("get response by HTTP request") do - expect(HTTPoisonMock, :get!, &HttpSupport.prepare_response/1) + expect(HTTPoisonMock, :get!, &HttpSupport.response/1) url = Enum.at(@urls, 0) get_response = Onigumo.Downloader.get_url(url) - expected_response = HttpSupport.prepare_response(url) + expected_response = HttpSupport.response(url) assert(get_response == expected_response) end end @@ -73,7 +73,7 @@ defmodule OnigumoDownloaderTest do describe("Onigumo.Downloader.get_body/1") do test("extract body from URL response") do url = Enum.at(@urls, 0) - response = HttpSupport.prepare_response(url) + response = HttpSupport.response(url) get_body = Onigumo.Downloader.get_body(response) expected_body = HttpSupport.body(url) assert(get_body == expected_body) @@ -101,7 +101,7 @@ defmodule OnigumoDownloaderTest do input_path_env = Application.get_env(:onigumo, :input_path) input_path_tmp = Path.join(tmp_dir, input_path_env) - input_file_content = InputSupport.prepare(input_urls) + input_file_content = InputSupport.url_list(input_urls) File.write!(input_path_tmp, input_file_content) loaded_urls = Onigumo.Downloader.load_urls(tmp_dir) |> Enum.to_list() diff --git a/test/support/http.ex b/test/support/http.ex index c2e0821..6a0b61c 100644 --- a/test/support/http.ex +++ b/test/support/http.ex @@ -1,5 +1,5 @@ defmodule HttpSupport do - def prepare_response(url) do + def response(url) do %HTTPoison.Response{ status_code: 200, body: body(url) diff --git a/test/support/input.ex b/test/support/input.ex index 155a3bb..a73a4fa 100644 --- a/test/support/input.ex +++ b/test/support/input.ex @@ -1,5 +1,5 @@ defmodule InputSupport do - def prepare(urls) do + def url_list(urls) do Enum.map(urls, &(&1 <> "\n")) |> Enum.join() end From 0a1a093d025a427f95c63d424974c0fc1cc29f3f Mon Sep 17 00:00:00 2001 From: dstroch Date: Sun, 1 Oct 2023 19:33:27 +0200 Subject: [PATCH 09/11] Load default elixirc_paths, then add extra paths to default --- mix.exs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mix.exs b/mix.exs index a2239b2..0acdce5 100644 --- a/mix.exs +++ b/mix.exs @@ -39,6 +39,10 @@ defmodule Onigumo.MixProject do ] end - defp elixirc_paths(:test), do: ["lib", "test/support"] - defp elixirc_paths(_), do: ["lib"] + defp elixirc_paths(:test), do: elixirc_paths_default() ++ ["test/support"] + + defp elixirc_paths(_), do: elixirc_paths_default() + + defp elixirc_paths_default(), do: Mix.Project.config()[:elixirc_paths] + end From 39583f79b2bd7c9cda712f35eba306177884deb3 Mon Sep 17 00:00:00 2001 From: dstroch Date: Sun, 1 Oct 2023 20:24:43 +0200 Subject: [PATCH 10/11] Fix formatting --- mix.exs | 1 - 1 file changed, 1 deletion(-) diff --git a/mix.exs b/mix.exs index 0acdce5..687fa2f 100644 --- a/mix.exs +++ b/mix.exs @@ -44,5 +44,4 @@ defmodule Onigumo.MixProject do defp elixirc_paths(_), do: elixirc_paths_default() defp elixirc_paths_default(), do: Mix.Project.config()[:elixirc_paths] - end From 63d2f1230ae394b4b5db18b644d894475d180766 Mon Sep 17 00:00:00 2001 From: dstroch Date: Sun, 1 Oct 2023 20:30:21 +0200 Subject: [PATCH 11/11] Reduce calling Mix.env() to just once --- mix.exs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mix.exs b/mix.exs index 687fa2f..2e64791 100644 --- a/mix.exs +++ b/mix.exs @@ -2,14 +2,16 @@ defmodule Onigumo.MixProject do use Mix.Project def project do + env = Mix.env() + [ app: :onigumo, version: "0.1.0", elixir: "~> 1.10", - start_permanent: Mix.env() == :prod, + start_permanent: env == :prod, deps: deps(), escript: escript(), - elixirc_paths: elixirc_paths(Mix.env()) + elixirc_paths: elixirc_paths(env) ] end