PageRenderTime 37ms CodeModel.GetById 10ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/mix/test/mix/tasks/compile.erlang_test.exs

https://github.com/vanstee/elixir
Elixir | 63 lines | 51 code | 12 blank | 0 comment | 6 complexity | 81b55774ad48352827e71196c9d054a1 MD5 | raw file
Possible License(s): Apache-2.0
  1. Code.require_file "../../test_helper.exs", __DIR__
  2. defmodule Mix.Tasks.Compile.ErlangTest do
  3. use MixTest.Case
  4. import ExUnit.CaptureIO
  5. setup do
  6. Mix.Project.push MixTest.Case.Sample
  7. :ok
  8. end
  9. teardown do
  10. Mix.Project.pop
  11. :ok
  12. end
  13. test "compilation continues if one file fails to compile" do
  14. in_fixture "compile_erlang", fn ->
  15. File.write!("src/zzz.erl", """)
  16. -module(zzz).
  17. def zzz(), do: b
  18. """
  19. assert_raise CompileError, fn ->
  20. capture_io fn ->
  21. Mix.Tasks.Compile.Erlang.run []
  22. end
  23. end
  24. assert File.regular?("_build/shared/lib/sample/ebin/b.beam")
  25. assert File.regular?("_build/shared/lib/sample/ebin/c.beam")
  26. end
  27. end
  28. test "compiles src/b.erl and src/c.erl" do
  29. in_fixture "compile_erlang", fn ->
  30. assert Mix.Tasks.Compile.Erlang.run([]) == :ok
  31. assert_received { :mix_shell, :info, ["Compiled src/b.erl"] }
  32. assert_received { :mix_shell, :info, ["Compiled src/c.erl"] }
  33. assert File.regular?("_build/shared/lib/sample/ebin/b.beam")
  34. assert File.regular?("_build/shared/lib/sample/ebin/c.beam")
  35. assert Mix.Tasks.Compile.Erlang.run([]) == :noop
  36. refute_received { :mix_shell, :info, ["Compiled src/b.erl"] }
  37. assert Mix.Tasks.Compile.Erlang.run(["--force"]) == :ok
  38. assert_received { :mix_shell, :info, ["Compiled src/b.erl"] }
  39. assert_received { :mix_shell, :info, ["Compiled src/c.erl"] }
  40. end
  41. end
  42. test "removes old artifact files" do
  43. in_fixture "compile_erlang", fn ->
  44. assert Mix.Tasks.Compile.Erlang.run([]) == :ok
  45. assert File.regular?("_build/shared/lib/sample/ebin/b.beam")
  46. File.rm!("src/b.erl")
  47. assert Mix.Tasks.Compile.Erlang.run([]) == :ok
  48. refute File.regular?("_build/shared/lib/sample/ebin/b.beam")
  49. end
  50. end
  51. end