@@ -344,7 +344,15 @@ defmodule ExUnit.Callbacks do
344344 raise ArgumentError , "start_supervised/2 can only be invoked from the test process"
345345 end
346346
347- Supervisor . start_child ( sup , Supervisor . child_spec ( child_spec_or_module , opts ) )
347+ child_spec = Supervisor . child_spec ( child_spec_or_module , opts )
348+
349+ case Supervisor . start_child ( sup , child_spec ) do
350+ { :error , { :already_started , _pid } } ->
351+ { :error , { :duplicate_child_name , child_spec . id } }
352+
353+ other ->
354+ other
355+ end
348356 end
349357
350358 @ doc """
@@ -367,9 +375,13 @@ defmodule ExUnit.Callbacks do
367375 end
368376 end
369377
370- defp start_supervised_error ( { { :EXIT , reason } , _info } ) , do: Exception . format_exit ( reason )
371- defp start_supervised_error ( { reason , _info } ) , do: Exception . format_exit ( reason )
372- defp start_supervised_error ( reason ) , do: Exception . format_exit ( reason )
378+ defp start_supervised_error ( { { :EXIT , reason } , info } ) when is_tuple ( info ) ,
379+ do: Exception . format_exit ( reason )
380+
381+ defp start_supervised_error ( { reason , info } ) when is_tuple ( info ) ,
382+ do: Exception . format_exit ( reason )
383+
384+ defp start_supervised_error ( reason ) , do: Exception . format_exit ( { :start_spec , reason } )
373385
374386 @ doc """
375387 Stops a child process started via `start_supervised/2`.
0 commit comments