Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elixir 1.15 #512

Merged
merged 5 commits into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,29 @@ jobs:
- '1.12.3'
- '1.13.4'
- '1.14.3'
- '1.15.4'
otp:
- '23.3'
- '24.3'
- '25.3'
- '26.0'

exclude:
- elixir: '1.12.3'
otp: '25.3'

- elixir: '1.12.3'
otp: '26.0'

- elixir: '1.13.4'
otp: '26.0'

- elixir: '1.14.3'
otp: '26.0'

- elixir: '1.15.4'
otp: '23.3'

steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down Expand Up @@ -87,7 +101,7 @@ jobs:
MIX_ENV: prod

- name: Check source code formatting
if: ${{ matrix.elixir > '1.12.0' }}
if: ${{ matrix.elixir > '1.15.0' }}
run: mix format --check-formatted

- name: Get results in short format
Expand Down
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
elixir 1.14.3-otp-25
erlang 25.2.2
elixir 1.15.4-otp-26
erlang 26.0.2
4 changes: 2 additions & 2 deletions lib/dialyxir/plt.ex
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ defmodule Dialyxir.Plt do
end

defp app_info(app) do
app_file = Atom.to_charlist(app) ++ '.app'
app_file = Atom.to_charlist(app) ++ ~c".app"

case :code.where_is_file(app_file) do
:non_existing ->
Expand Down Expand Up @@ -111,7 +111,7 @@ defmodule Dialyxir.Plt do
end

defp resolve_module(module, beams) do
beam = Atom.to_charlist(module) ++ '.beam'
beam = Atom.to_charlist(module) ++ ~c".beam"

case :code.where_is_file(beam) do
path when is_list(path) ->
Expand Down
38 changes: 22 additions & 16 deletions lib/mix/tasks/dialyzer.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule Mix.Tasks.Dialyzer do

Check warning on line 1 in lib/mix/tasks/dialyzer.ex

View workflow job for this annotation

GitHub Actions / Elixir 1.15.4 / OTP 25.3

redefining module Mix.Tasks.Dialyzer (current version loaded from /home/runner/.mix/archives/dialyxir-1.3.0/dialyxir-1.3.0/ebin/Elixir.Mix.Tasks.Dialyzer.beam)

Check warning on line 1 in lib/mix/tasks/dialyzer.ex

View workflow job for this annotation

GitHub Actions / Elixir 1.15.4 / OTP 26.0

redefining module Mix.Tasks.Dialyzer (current version loaded from /home/runner/.mix/archives/dialyxir-1.3.0/dialyxir-1.3.0/ebin/Elixir.Mix.Tasks.Dialyzer.beam)

Check warning on line 1 in lib/mix/tasks/dialyzer.ex

View workflow job for this annotation

GitHub Actions / Elixir 1.15.4 / OTP 24.3

redefining module Mix.Tasks.Dialyzer (current version loaded from /home/runner/.mix/archives/dialyxir-1.3.0/dialyxir-1.3.0/ebin/Elixir.Mix.Tasks.Dialyzer.beam)
@shortdoc "Runs dialyzer with default or project-defined flags."

@moduledoc """
Expand Down Expand Up @@ -339,28 +339,34 @@
end
end

defp check_dialyzer do
if not Code.ensure_loaded?(:dialyzer) do
error("""
DEPENDENCY MISSING
------------------------
If you are reading this message, then Elixir and Erlang are installed but the
Erlang Dialyzer is not available. Probably this is because you installed Erlang
with your OS package manager and the Dialyzer package is separate.
if Version.match?(System.version(), ">= 1.15.0") do
defp check_dialyzer do
Mix.ensure_application!(:dialyzer)
end
else
defp check_dialyzer do
if not Code.ensure_loaded?(:dialyzer) do
error("""
DEPENDENCY MISSING
------------------------
If you are reading this message, then Elixir and Erlang are installed but the
Erlang Dialyzer is not available. Probably this is because you installed Erlang
with your OS package manager and the Dialyzer package is separate.

On Debian/Ubuntu:
On Debian/Ubuntu:

`apt-get install erlang-dialyzer`
`apt-get install erlang-dialyzer`

Fedora:
Fedora:

`yum install erlang-dialyzer`
`yum install erlang-dialyzer`

Arch and Homebrew include Dialyzer in their base erlang packages. Please report a Github
issue to add or correct distribution-specific information.
""")
Arch and Homebrew include Dialyzer in their base erlang packages. Please report a Github
issue to add or correct distribution-specific information.
""")

:erlang.halt(3)
:erlang.halt(3)
end
end
end

Expand Down
28 changes: 14 additions & 14 deletions test/dialyxir/formatter_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ defmodule Dialyxir.FormatterTest do
describe "exs ignore" do
test "evaluates an ignore file and ignores warnings matching the pattern" do
warnings = [
{:warn_return_no_exit, {'lib/short_description.ex', 17},
{:warn_return_no_exit, {~c"lib/short_description.ex", 17},
{:no_return, [:only_normal, :format_long, 1]}},
{:warn_return_no_exit, {'lib/file/warning_type.ex', 18},
{:warn_return_no_exit, {~c"lib/file/warning_type.ex", 18},
{:no_return, [:only_normal, :format_long, 1]}},
{:warn_return_no_exit, {'lib/file/warning_type/line.ex', 19},
{:warn_return_no_exit, {~c"lib/file/warning_type/line.ex", 19},
{:no_return, [:only_normal, :format_long, 1]}}
]

Expand All @@ -35,11 +35,11 @@ defmodule Dialyxir.FormatterTest do

test "evaluates an ignore file of the form {file, short_description} and ignores warnings matching the pattern" do
warnings = [
{:warn_return_no_exit, {'lib/poorly_written_code.ex', 10},
{:warn_return_no_exit, {~c"lib/poorly_written_code.ex", 10},
{:no_return, [:only_normal, :do_a_thing, 1]}},
{:warn_return_no_exit, {'lib/poorly_written_code.ex', 20},
{:warn_return_no_exit, {~c"lib/poorly_written_code.ex", 20},
{:no_return, [:only_normal, :do_something_else, 2]}},
{:warn_return_no_exit, {'lib/poorly_written_code.ex', 30},
{:warn_return_no_exit, {~c"lib/poorly_written_code.ex", 30},
{:no_return, [:only_normal, :do_many_things, 3]}}
]

Expand All @@ -53,7 +53,7 @@ defmodule Dialyxir.FormatterTest do

test "does not filter lines not matching the pattern" do
warning =
{:warn_return_no_exit, {'a/different_file.ex', 17},
{:warn_return_no_exit, {~c"a/different_file.ex", 17},
{:no_return, [:only_normal, :format_long, 1]}}

in_project(:ignore, fn ->
Expand All @@ -66,7 +66,7 @@ defmodule Dialyxir.FormatterTest do

test "can filter by regex" do
warning =
{:warn_return_no_exit, {'a/regex_file.ex', 17},
{:warn_return_no_exit, {~c"a/regex_file.ex", 17},
{:no_return, [:only_normal, :format_long, 1]}}

in_project(:ignore, fn ->
Expand All @@ -79,7 +79,7 @@ defmodule Dialyxir.FormatterTest do

test "lists unnecessary skips as warnings if ignoring exit status" do
warning =
{:warn_return_no_exit, {'a/regex_file.ex', 17},
{:warn_return_no_exit, {~c"a/regex_file.ex", 17},
{:no_return, [:only_normal, :format_long, 1]}}

filter_args = [{:ignore_exit_status, true}]
Expand All @@ -94,7 +94,7 @@ defmodule Dialyxir.FormatterTest do

test "error on unnecessary skips without ignore_exit_status" do
warning =
{:warn_return_no_exit, {'a/regex_file.ex', 17},
{:warn_return_no_exit, {~c"a/regex_file.ex", 17},
{:no_return, [:only_normal, :format_long, 1]}}

filter_args = [{:ignore_exit_status, false}]
Expand All @@ -109,7 +109,7 @@ defmodule Dialyxir.FormatterTest do

test "overwrite ':list_unused_filters_present'" do
warning =
{:warn_return_no_exit, {'a/regex_file.ex', 17},
{:warn_return_no_exit, {~c"a/regex_file.ex", 17},
{:no_return, [:only_normal, :format_long, 1]}}

filter_args = [{:list_unused_filters, false}]
Expand All @@ -126,7 +126,7 @@ defmodule Dialyxir.FormatterTest do
describe "simple string ignore" do
test "evaluates an ignore file and ignores warnings matching the pattern" do
warning =
{:warn_matching, {'a/file.ex', 17}, {:pattern_match, ['pattern \'ok\'', '\'error\'']}}
{:warn_matching, {~c"a/file.ex", 17}, {:pattern_match, [~c"pattern 'ok'", ~c"'error'"]}}

in_project(:ignore_string, fn ->
assert Formatter.format_and_filter([warning], Project, [], :dialyzer) ==
Expand All @@ -137,9 +137,9 @@ defmodule Dialyxir.FormatterTest do

test "listing unused filter behaves the same for different formats" do
warnings = [
{:warn_return_no_exit, {'a/regex_file.ex', 17},
{:warn_return_no_exit, {~c"a/regex_file.ex", 17},
{:no_return, [:only_normal, :format_long, 1]}},
{:warn_return_no_exit, {'a/another-file.ex', 18}, {:unknown_type, {:M, :F, :A}}}
{:warn_return_no_exit, {~c"a/another-file.ex", 18}, {:unknown_type, {:M, :F, :A}}}
]

expected_warning = "a/another-file.ex:18"
Expand Down
8 changes: 6 additions & 2 deletions test/dialyxir/project_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ defmodule Dialyxir.ProjectTest do
import ExUnit.CaptureIO, only: [capture_io: 1, capture_io: 2]

defp in_project(app, f) when is_atom(app) do
Mix.Project.in_project(app, "test/fixtures/#{Atom.to_string(app)}", fn _ -> f.() end)
in_project(app, "test/fixtures/#{Atom.to_string(app)}", f)
end

defp in_project(apps, f) when is_list(apps) do
path = Enum.map_join(apps, "/", &Atom.to_string/1)
app = List.last(apps)
Mix.Project.in_project(app, "test/fixtures/#{path}", fn _ -> f.() end)
in_project(app, "test/fixtures/#{path}", f)
end

defp in_project(app, path, f) do
Mix.Project.in_project(app, path, fn _ -> f.() end)
end

test "Default Project PLT File in _build dir" do
Expand Down
7 changes: 6 additions & 1 deletion test/fixtures/alt_core_path/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ defmodule AltCorePath.Mixfile do
use Mix.Project

def project do
[app: :alt_core_path, version: "1.0.0", dialyzer: [plt_core_path: "_build"]]
[
app: :alt_core_path,
prune_code_paths: false,
version: "1.0.0",
dialyzer: [plt_core_path: "_build"]
]
end
end
7 changes: 6 additions & 1 deletion test/fixtures/alt_local_path/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ defmodule AltLocalPath.Mixfile do
use Mix.Project

def project do
[app: :alt_local_path, version: "1.0.0", dialyzer: [plt_local_path: "dialyzer"]]
[
app: :alt_local_path,
prune_code_paths: false,
version: "1.0.0",
dialyzer: [plt_local_path: "dialyzer"]
]
end
end
2 changes: 1 addition & 1 deletion test/fixtures/default_apps/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defmodule DefaultApps.Mixfile do
use Mix.Project

def project do
[app: :default_apps, version: "0.1.0", deps: deps()]
[app: :default_apps, prune_code_paths: false, version: "0.1.0", deps: deps()]
end

def application do
Expand Down
8 changes: 7 additions & 1 deletion test/fixtures/direct_apps/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ defmodule DirectApps.Mixfile do
use Mix.Project

def project do
[app: :direct_apps, version: "0.1.0", deps: deps(), dialyzer: [plt_add_deps: :apps_direct]]
[
app: :direct_apps,
prune_code_paths: false,
version: "0.1.0",
deps: deps(),
dialyzer: [plt_add_deps: :apps_direct]
]
end

def application do
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/ignore/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ defmodule Ignore.Mixfile do
[
app: :ignore,
version: "0.1.0",
prune_code_paths: false,
dialyzer: [
ignore_warnings: "ignore_test.exs",
list_unused_filters: true
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/ignore_apps/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ defmodule IgnoreApps.Mixfile do
[
app: :ignore_apps,
version: "0.1.0",
prune_code_paths: false,
deps: deps(),
dialyzer: [
plt_ignore_apps: [:logger]
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/ignore_strict/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ defmodule IgnoreStrict.Mixfile do
[
app: :ignore_strict,
version: "0.1.0",
prune_code_paths: false,
dialyzer: [
ignore_warnings: "ignore_strict_test.exs",
list_unused_filters: true
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/ignore_string/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ defmodule IgnoreString.Mixfile do
[
app: :ignore_string,
version: "0.1.0",
prune_code_paths: false,
dialyzer: [
ignore_warnings: "dialyzer.ignore-warnings",
list_unused_filters: true
Expand Down
7 changes: 6 additions & 1 deletion test/fixtures/local_plt/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ defmodule LocalPlt.Mixfile do
use Mix.Project

def project do
[app: :local_plt, version: "1.0.0", dialyzer: [plt_file: "local.plt"]]
[
app: :local_plt,
prune_code_paths: false,
version: "1.0.0",
dialyzer: [plt_file: "local.plt"]
]
end
end
7 changes: 6 additions & 1 deletion test/fixtures/local_plt_no_warn/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ defmodule LocalPltNoWarn.Mixfile do
use Mix.Project

def project do
[app: :local_plt_no_warn, version: "1.0.0", dialyzer: [plt_file: {:no_warn, "local.plt"}]]
[
app: :local_plt_no_warn,
prune_code_paths: false,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prune_cod_paths is a workaround for apps that aren't specifying all their runtime dependencies. Could add dialyzer to extra_applications instead? I don't think prune_code_paths is what we want to recommend people do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's Dialyxir that gets pruned, and I haven't been able to find a way to prevent Elixir from pruning it. Halfway through the tests all the Dialixir modules are gone. I've tried extra_applications, and setting it as a dep. Only thing I've found to work is to setting that flag.

This could break in the future, so it would be nice to find a better solution, but I haven't figured out why Mix.Project.in_project would cause the dialixir code paths to be pruned in the first place.

version: "1.0.0",
dialyzer: [plt_file: {:no_warn, "local.plt"}]
]
end
end
1 change: 1 addition & 0 deletions test/fixtures/no_lockfile/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ defmodule NoLockfile.Mixfile do
def project do
[
app: :no_lockfile,
prune_code_paths: false,
version: "1.0.0"
]
end
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/no_umbrella/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ defmodule NoUmbrella.Mixfile do
def project do
[
app: :no_umbrella,
prune_code_paths: false,
version: "0.1.0",
lockfile: "../mix.lock",
elixir: "~> 1.3",
Expand Down
7 changes: 6 additions & 1 deletion test/fixtures/nonexistent_deps/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ defmodule NonexistentDeps.Mixfile do
use Mix.Project

def project do
[app: :nonexistent_deps, version: "0.1.0", deps: deps()]
[
app: :nonexistent_deps,
prune_code_paths: false,
version: "0.1.0",
deps: deps()
]
end

def application do
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/plt_add_deps_deprecations/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ defmodule PltAddDepsDeprecations.Mixfile do
def project do
[
app: :plt_add_deps_deprecations,
prune_code_paths: false,
version: "0.1.0",
dialyzer: [
plt_add_deps: true
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/umbrella/apps/first_one/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ defmodule FirstOne.Mixfile do
def project do
[
app: :first_one,
prune_code_paths: false,
version: "0.1.0",
build_path: "../../_build",
config_path: "../../config/config.exs",
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/umbrella/apps/second_one/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ defmodule SecondOne.Mixfile do
def project do
[
app: :second_one,
prune_code_paths: false,
version: "0.1.0",
build_path: "../../_build",
config_path: "../../config/config.exs",
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/umbrella/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ defmodule Umbrella.Mixfile do
def project do
[
apps_path: "apps",
prune_code_paths: false,
build_embedded: Mix.env() == :prod,
start_permanent: Mix.env() == :prod,
deps: []
Expand Down
Loading
Loading