File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -191,10 +191,11 @@ defmodule Mix.Tasks.Xref do
191191
192192 @ impl true
193193 def run ( args ) do
194- { opts , args } = OptionParser . parse! ( args , strict: @ switches )
195194 Mix.Task . run ( "compile" , args )
196195 Mix.Task . reenable ( "xref" )
197196
197+ { opts , args } = OptionParser . parse! ( args , strict: @ switches )
198+
198199 case args do
199200 [ "callers" , callee ] ->
200201 callers ( callee , opts )
Original file line number Diff line number Diff line change @@ -587,6 +587,38 @@ defmodule Mix.Tasks.XrefTest do
587587 end )
588588 end
589589
590+ test "compiles project first by default" do
591+ in_fixture ( "no_mixfile" , fn ->
592+ File . write! ( "lib/a.ex" , """
593+ defmodule A do
594+ def a, do: :ok
595+ end
596+ """ )
597+
598+ Mix.Tasks.Xref . run ( [ "graph" ] )
599+
600+ assert "Compiling" <> _ = receive_until_no_messages ( [ ] )
601+ end )
602+ end
603+
604+ test "passes args over to compile task" do
605+ in_fixture ( "no_mixfile" , fn ->
606+ File . write! ( "lib/a.ex" , """
607+ defmodule A do
608+ def a, do: :ok
609+ end
610+ """ )
611+
612+ Mix.Task . run ( "compile" )
613+ Mix.Task . reenable ( "compile" )
614+ Mix . shell ( ) . flush ( )
615+
616+ Mix.Tasks.Xref . run ( [ "graph" , "--no-compile" ] )
617+
618+ refute String . starts_with? ( receive_until_no_messages ( [ ] ) , "Compiling" )
619+ end )
620+ end
621+
590622 defp assert_graph ( opts \\ [ ] , expected ) do
591623 in_fixture ( "no_mixfile" , fn ->
592624 File . write! ( "lib/a.ex" , """
You can’t perform that action at this time.
0 commit comments