@@ -257,6 +257,41 @@ defmodule Mix.Tasks.Compile.ElixirTest do
257257 end )
258258 end
259259
260+ test "does recompile a file restored after a compile error (and .beam file were deleted)" do
261+ in_fixture ( "no_mixfile" , fn ->
262+ assert Mix.Tasks.Compile.Elixir . run ( [ "--verbose" ] ) == { :ok , [ ] }
263+ assert_received { :mix_shell , :info , [ "Compiled lib/a.ex" ] }
264+ assert_received { :mix_shell , :info , [ "Compiled lib/b.ex" ] }
265+
266+ Mix . shell ( ) . flush
267+ purge ( [ A , B ] )
268+
269+ # Compile with error
270+ original_content = File . read! ( "lib/b.ex" )
271+ File . write! ( "lib/b.ex" , "this will not compile" )
272+
273+ assert capture_io ( fn ->
274+ { :error , _ } = Mix.Tasks.Compile.Elixir . run ( [ "--verbose" ] )
275+ end ) =~ "Compilation error in file lib/b.ex"
276+
277+ assert_received { :mix_shell , :info , [ "Compiling 1 file (.ex)" ] }
278+
279+ # Revert change
280+ File . write! ( "lib/b.ex" , original_content )
281+ future = { { 2038 , 1 , 1 } , { 0 , 0 , 0 } }
282+ File . touch! ( "lib/b.ex" , future )
283+
284+ Mix.Tasks.Compile.Elixir . run ( [ "--verbose" ] )
285+
286+ message =
287+ "warning: mtime (modified time) for \" lib/b.ex\" was set to the future, resetting to now"
288+
289+ assert_received { :mix_shell , :error , [ ^ message ] }
290+ assert_received { :mix_shell , :info , [ "Compiled lib/b.ex" ] }
291+ refute_received { :mix_shell , :info , [ "Compiled lib/a.ex" ] }
292+ end )
293+ end
294+
260295 test "compiles size changed files" do
261296 in_fixture ( "no_mixfile" , fn ->
262297 past = { { 2010 , 1 , 1 } , { 0 , 0 , 0 } }
0 commit comments