@@ -172,20 +172,27 @@ defmodule Mix.Tasks.Compile.ElixirTest do
172172
173173 defmodule SourcePathsProject do
174174 def project do
175- [ app: :source_paths , elixirc_paths: [ "web" , "lib" ] ]
175+ [ app: :source_paths , elixirc_paths: [ "web" , "lib" , "lib/foo" ] ]
176176 end
177177 end
178178
179179 test "use custom source paths" do
180180 Mix.Project . push SourcePathsProject
181181
182182 in_fixture "no_mixfile" , fn ->
183+ File . mkdir_p! "web"
184+ File . write! "web/ab.ex" , """
185+ defmodule AB, do: :ok
186+ """
187+
183188 # Nothing to compile with the custom source paths
184189 assert Mix.Tasks.Compile.Elixir . run ( [ "--elixirc-paths" , "web" ] )
190+ assert_received { :mix_shell , :info , [ "Compiled web/ab.ex" ] }
185191 refute_received { :mix_shell , :info , [ "Compiled lib/a.ex" ] }
186192
187193 assert Mix.Tasks.Compile.Elixir . run ( [ "--elixirc-paths" , "lib" ] )
188194 assert_received { :mix_shell , :info , [ "Compiled lib/a.ex" ] }
195+ refute_received { :mix_shell , :info , [ "Compiled web/ab.ex" ] }
189196
190197 # Compiling just web does not remove lib artifacts
191198 assert Mix.Tasks.Compile.Elixir . run ( [ "--elixirc-paths" , "web" ] )
@@ -195,4 +202,32 @@ defmodule Mix.Tasks.Compile.ElixirTest do
195202 refute_received { :mix_shell , :info , [ "Compiled lib/a.ex" ] }
196203 end
197204 end
205+
206+ test "use custom source paths in subdirs" do
207+ Mix.Project . push SourcePathsProject
208+
209+ in_fixture "no_mixfile" , fn ->
210+ File . mkdir_p! "lib/foo"
211+ File . write! "lib/foo/ab.ex" , """
212+ defmodule AB, do: :ok
213+ """
214+
215+ # Nested file (and nested file only) is compiled just once
216+ assert Mix.Tasks.Compile.Elixir . run ( [ "--elixirc-paths" , "lib/foo" ] )
217+ assert_received { :mix_shell , :info , [ "Compiled lib/foo/ab.ex" ] }
218+ refute_received { :mix_shell , :info , [ "Compiled lib/a.ex" ] }
219+ refute_received { :mix_shell , :info , [ "Compiled lib/foo/ab.ex" ] }
220+
221+ assert Mix.Tasks.Compile.Elixir . run ( [ "--elixirc-paths" , "lib" ] )
222+ assert_received { :mix_shell , :info , [ "Compiled lib/a.ex" ] }
223+ refute_received { :mix_shell , :info , [ "Compiled lib/foo/ab.ex" ] }
224+
225+ # Compiling just lib/foo does not remove lib artifacts
226+ assert Mix.Tasks.Compile.Elixir . run ( [ "--elixirc-paths" , "lib/foo" ] )
227+ refute_received { :mix_shell , :info , [ "Compiled lib/a.ex" ] }
228+
229+ assert Mix.Tasks.Compile.Elixir . run ( [ "--elixirc-paths" , "lib" ] )
230+ refute_received { :mix_shell , :info , [ "Compiled lib/a.ex" ] }
231+ end
232+ end
198233end
0 commit comments