@@ -172,20 +172,27 @@ defmodule Mix.Tasks.Compile.ElixirTest do
172
172
173
173
defmodule SourcePathsProject do
174
174
def project do
175
- [ app: :source_paths , elixirc_paths: [ "web" , "lib" ] ]
175
+ [ app: :source_paths , elixirc_paths: [ "web" , "lib" , "lib/foo" ] ]
176
176
end
177
177
end
178
178
179
179
test "use custom source paths" do
180
180
Mix.Project . push SourcePathsProject
181
181
182
182
in_fixture "no_mixfile" , fn ->
183
+ File . mkdir_p! "web"
184
+ File . write! "web/ab.ex" , """
185
+ defmodule AB, do: :ok
186
+ """
187
+
183
188
# Nothing to compile with the custom source paths
184
189
assert Mix.Tasks.Compile.Elixir . run ( [ "--elixirc-paths" , "web" ] )
190
+ assert_received { :mix_shell , :info , [ "Compiled web/ab.ex" ] }
185
191
refute_received { :mix_shell , :info , [ "Compiled lib/a.ex" ] }
186
192
187
193
assert Mix.Tasks.Compile.Elixir . run ( [ "--elixirc-paths" , "lib" ] )
188
194
assert_received { :mix_shell , :info , [ "Compiled lib/a.ex" ] }
195
+ refute_received { :mix_shell , :info , [ "Compiled web/ab.ex" ] }
189
196
190
197
# Compiling just web does not remove lib artifacts
191
198
assert Mix.Tasks.Compile.Elixir . run ( [ "--elixirc-paths" , "web" ] )
@@ -195,4 +202,32 @@ defmodule Mix.Tasks.Compile.ElixirTest do
195
202
refute_received { :mix_shell , :info , [ "Compiled lib/a.ex" ] }
196
203
end
197
204
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
198
233
end
0 commit comments