From 622fad97214897d835e1a8c3f3313024046ea1e1 Mon Sep 17 00:00:00 2001 From: Philip Ross Date: Tue, 22 Dec 2020 18:21:49 -0800 Subject: [PATCH 1/4] added tests for setting a local plt path --- test/dialyxir/project_test.exs | 8 +++++++- test/fixtures/alt_local_path/mix.exs | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/alt_local_path/mix.exs diff --git a/test/dialyxir/project_test.exs b/test/dialyxir/project_test.exs index 7d3d5cc9..03171b57 100644 --- a/test/dialyxir/project_test.exs +++ b/test/dialyxir/project_test.exs @@ -16,7 +16,13 @@ defmodule Dialyxir.ProjectTest do test "Default Project PLT File in _build dir" do in_project(:default_apps, fn -> - assert Regex.match?(~r/_build.*plt/, Project.plt_file()) + assert Regex.match?(~r/_build\/.*plt/, Project.plt_file()) + end) + end + + test "Can specify a different local PLT path" do + in_project(:alt_local_path, fn -> + assert Regex.match?(~r/dialyzer\/.*plt/, Project.plt_file()) end) end diff --git a/test/fixtures/alt_local_path/mix.exs b/test/fixtures/alt_local_path/mix.exs new file mode 100644 index 00000000..ec8fdd42 --- /dev/null +++ b/test/fixtures/alt_local_path/mix.exs @@ -0,0 +1,7 @@ +defmodule AltLocalPath.Mixfile do + use Mix.Project + + def project do + [app: :alt_local_path, version: "1.0.0", dialyzer: [plt_local_path: "dialyzer"]] + end +end From 69d1a3df956c4b34556190fb995ed52e35a12192 Mon Sep 17 00:00:00 2001 From: Philip Ross Date: Tue, 22 Dec 2020 18:01:38 -0800 Subject: [PATCH 2/4] added a config for setting the local path --- lib/dialyxir/project.ex | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/dialyxir/project.ex b/lib/dialyxir/project.ex index c91be440..0df5b5fd 100644 --- a/lib/dialyxir/project.ex +++ b/lib/dialyxir/project.ex @@ -258,9 +258,11 @@ defmodule Dialyxir.Project do defp core_path(), do: dialyzer_config()[:plt_core_path] || Mix.Utils.mix_home() defp local_plt(name) do - Path.join(Mix.Project.build_path(), "dialyxir_" <> name <> ".plt") + Path.join(local_path(), "dialyxir_" <> name <> ".plt") end + defp local_path(), do: dialyzer_config()[:plt_local_path] || Mix.Project.build_path() + defp default_paths() do reduce_umbrella_children([], fn paths -> [Mix.Project.compile_path() | paths] From e6870cebaa5222d5daa5f4a3ddb88165bd399471 Mon Sep 17 00:00:00 2001 From: Philip Ross Date: Wed, 23 Dec 2020 11:13:25 -0800 Subject: [PATCH 3/4] updated README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6f78cf3c..25da820f 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,7 @@ Running the mix task `dialyzer` by default builds several PLT files: * A project environment specific file in _build/env/dialyze_erlang-[OTP Version]_elixir-[Elixir Version]_deps-dev.plt The core files are simply copied to your project folder when you run `dialyxir` for the first time with a given version of Erlang and Elixir. By default, all -the modules in the project PLT are checked against your dependencies to be sure they are up to date. If you do not want to use MIX_HOME to store your core Erlang and Elixir files, you can provide a :plt_core_path key with a file path. You can specify a different location for the project PLT file with the :plt_file keyword - this is deprecated because people were using it with the old `dialyxir` to have project-specific PLTs, which are now the default. To silence the deprecation warning, specify this value as `plt_file: {:no_warn, "/myproject/mypltfile"}`. +the modules in the project PLT are checked against your dependencies to be sure they are up to date. If you do not want to use MIX_HOME to store your core Erlang and Elixir files, you can provide a :plt_core_path key with a file path. You can specify a different directory for the project PLT file with the :plt_local_path keyword. You can specify a different filename for the project PLT file with the :plt_file keyword - this is deprecated because people were using it with the old `dialyxir` to have project-specific PLTs, which are now the default. To silence the deprecation warning, specify this value as `plt_file: {:no_warn, "/myproject/mypltfile"}`. The core PLTs include a basic set of OTP applications, as well as all of the Elixir standard libraries. The apps included by default are `[ :erts, :kernel, :stdlib, :crypto]`. From 7fe6cb0c1d2d38231027f2b03c8e21fa3845708d Mon Sep 17 00:00:00 2001 From: Philip Ross Date: Wed, 23 Dec 2020 11:16:45 -0800 Subject: [PATCH 4/4] updated module docs --- lib/mix/tasks/dialyzer.ex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/mix/tasks/dialyzer.ex b/lib/mix/tasks/dialyzer.ex index 8c9223a4..1fbda507 100644 --- a/lib/mix/tasks/dialyzer.ex +++ b/lib/mix/tasks/dialyzer.ex @@ -83,6 +83,8 @@ defmodule Mix.Tasks.Dialyzer do * `dialyzer: :plt_file` - Deprecated - specify the plt file name to create and use - default is to create one in the project's current build environmnet (e.g. _build/dev/) specific to the Erlang/Elixir version used. Note that use of this key in version 0.4 or later will produce a deprecation warning - you can silence the warning by providing a pair with key :no_warn e.g. `plt_file: {:no_warn,"filename"}`. + * `dialyzer: :plt_local_path` - specify the plt directory name to create and use - default is the project's current build environmnet (e.g. _build/dev/). + * `dialyzer: :plt_core_path` - specify an alternative to MIX_HOME to use to store the Erlang and Elixir core files. * `dialyzer: :ignore_warnings` - specify file path to filter well-known warnings.