/lib/mix/test/mix/tasks/compile.erlang_test.exs
Elixir | 63 lines | 51 code | 12 blank | 0 comment | 6 complexity | 81b55774ad48352827e71196c9d054a1 MD5 | raw file
Possible License(s): Apache-2.0
- Code.require_file "../../test_helper.exs", __DIR__
- defmodule Mix.Tasks.Compile.ErlangTest do
- use MixTest.Case
- import ExUnit.CaptureIO
- setup do
- Mix.Project.push MixTest.Case.Sample
- :ok
- end
- teardown do
- Mix.Project.pop
- :ok
- end
- test "compilation continues if one file fails to compile" do
- in_fixture "compile_erlang", fn ->
- File.write!("src/zzz.erl", """)
- -module(zzz).
- def zzz(), do: b
- """
- assert_raise CompileError, fn ->
- capture_io fn ->
- Mix.Tasks.Compile.Erlang.run []
- end
- end
- assert File.regular?("_build/shared/lib/sample/ebin/b.beam")
- assert File.regular?("_build/shared/lib/sample/ebin/c.beam")
- end
- end
- test "compiles src/b.erl and src/c.erl" do
- in_fixture "compile_erlang", fn ->
- assert Mix.Tasks.Compile.Erlang.run([]) == :ok
- assert_received { :mix_shell, :info, ["Compiled src/b.erl"] }
- assert_received { :mix_shell, :info, ["Compiled src/c.erl"] }
- assert File.regular?("_build/shared/lib/sample/ebin/b.beam")
- assert File.regular?("_build/shared/lib/sample/ebin/c.beam")
- assert Mix.Tasks.Compile.Erlang.run([]) == :noop
- refute_received { :mix_shell, :info, ["Compiled src/b.erl"] }
- assert Mix.Tasks.Compile.Erlang.run(["--force"]) == :ok
- assert_received { :mix_shell, :info, ["Compiled src/b.erl"] }
- assert_received { :mix_shell, :info, ["Compiled src/c.erl"] }
- end
- end
- test "removes old artifact files" do
- in_fixture "compile_erlang", fn ->
- assert Mix.Tasks.Compile.Erlang.run([]) == :ok
- assert File.regular?("_build/shared/lib/sample/ebin/b.beam")
- File.rm!("src/b.erl")
- assert Mix.Tasks.Compile.Erlang.run([]) == :ok
- refute File.regular?("_build/shared/lib/sample/ebin/b.beam")
- end
- end
- end