Skip to content

Commit

Permalink
Change around lib_dir handling to retain error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
PragTob committed May 25, 2024
1 parent d599e84 commit 7cacf5b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions lib/benchee/system.ex
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,13 @@ defmodule Benchee.System do

# just made public for easy testing purposes
@doc false
def all_protocols_consolidated?(lib_dir_fun \\ &lib_dir/2) do
case lib_dir_fun.(:elixir, :ebin) do
def all_protocols_consolidated?(lib_dir_fun \\ &:code.lib_dir/1) do
case lib_dir_fun.(:elixir) do
# do we get a good old erlang charlist?
path when is_list(path) ->
[path]
ebin_path = Path.join(path, "ebin")

[ebin_path]
|> Protocol.extract_protocols()
|> Enum.all?(&Protocol.consolidated?/1)

Expand All @@ -271,8 +273,6 @@ defmodule Benchee.System do
true
end
end

defp lib_dir(app, subdir), do: Path.join(:code.lib_dir(app), subdir)
end

defimpl DeepMerge.Resolver, for: Benchee.System do
Expand Down
2 changes: 1 addition & 1 deletion test/benchee/system_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ defmodule Benchee.SystemTest do
end

test "when it borks out it warns and defaults to true, see #384" do
fake_lib_dir = fn _, _ -> {:error, :bad_name} end
fake_lib_dir = fn _ -> {:error, :bad_name} end

warning =
capture_io(fn ->
Expand Down

0 comments on commit 7cacf5b

Please sign in to comment.