Skip to content

Commit d38a189

Browse files
author
José Valim
committed
Do not use protocols while consolidating
This avoids a race condition in tests. Signed-off-by: José Valim <[email protected]>
1 parent 2b33809 commit d38a189

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/mix/lib/mix/tasks/compile.protocols.ex

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,10 @@ defmodule Mix.Tasks.Compile.Protocols do
145145

146146
case Protocol.consolidate(protocol, impls) do
147147
{:ok, binary} ->
148-
File.write!(Path.join(output, "#{protocol}.beam"), binary)
148+
File.write!(Path.join(output, "#{Atom.to_string(protocol)}.beam"), binary)
149149

150150
if opts[:verbose] do
151-
Mix.shell().info("Consolidated #{inspect(protocol)}")
151+
Mix.shell().info("Consolidated #{inspect_protocol(protocol)}")
152152
end
153153

154154
# If we remove a dependency and we have implemented one of its
@@ -161,11 +161,17 @@ defmodule Mix.Tasks.Compile.Protocols do
161161
remove_consolidated(protocol, output)
162162

163163
if opts[:verbose] do
164-
Mix.shell().info("Unavailable #{inspect(protocol)}")
164+
Mix.shell().info("Unavailable #{inspect_protocol(protocol)}")
165165
end
166166
end
167167
end
168168

169+
# We cannot use the inspect protocol while consolidating
170+
# since inspect may not be available.
171+
defp inspect_protocol(protocol) do
172+
Code.Identifier.inspect_as_atom(protocol)
173+
end
174+
169175
defp reload(module) do
170176
:code.purge(module)
171177
:code.delete(module)
@@ -227,6 +233,6 @@ defmodule Mix.Tasks.Compile.Protocols do
227233
end
228234

229235
defp remove_consolidated(protocol, output) do
230-
File.rm(Path.join(output, "#{protocol}.beam"))
236+
File.rm(Path.join(output, "#{Atom.to_string(protocol)}.beam"))
231237
end
232238
end

0 commit comments

Comments
 (0)