File tree 2 files changed +34
-1
lines changed
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
191
191
192
192
@ impl true
193
193
def run ( args ) do
194
- { opts , args } = OptionParser . parse! ( args , strict: @ switches )
195
194
Mix.Task . run ( "compile" , args )
196
195
Mix.Task . reenable ( "xref" )
197
196
197
+ { opts , args } = OptionParser . parse! ( args , strict: @ switches )
198
+
198
199
case args do
199
200
[ "callers" , callee ] ->
200
201
callers ( callee , opts )
Original file line number Diff line number Diff line change @@ -587,6 +587,38 @@ defmodule Mix.Tasks.XrefTest do
587
587
end )
588
588
end
589
589
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
+
590
622
defp assert_graph ( opts \\ [ ] , expected ) do
591
623
in_fixture ( "no_mixfile" , fn ->
592
624
File . write! ( "lib/a.ex" , """
You can’t perform that action at this time.
0 commit comments