Skip to content

Commit 406edcb

Browse files
committed
Use rebar from project root directory
1 parent 6c813a1 commit 406edcb

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

lib/mix/lib/mix/shell/process.ex

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ defmodule Mix.Shell.Process do
1818
@behavior Mix.Shell
1919

2020
@doc """
21-
Flush all :mix_shell messages from the current process.
21+
Flush all :mix_shell and :mix_shell_input messages from the current process.
2222
If a callback is given, it is invoked for each received message.
2323
2424
## Examples
@@ -31,6 +31,9 @@ defmodule Mix.Shell.Process do
3131
{ :mix_shell, _, _ } = message ->
3232
callback.(message)
3333
flush(callback)
34+
{ :mix_shell_input, _, _ } = message ->
35+
callback.(message)
36+
flush(callback)
3437
after
3538
0 -> :done
3639
end

lib/mix/test/mix/rebar_test.exs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,32 @@ defmodule Mix.RebarTest do
3030
test "parse rebar dependencies" do
3131
Mix.Project.push(RebarAsDep)
3232

33-
in_tmp "parse rebar dependencies", fn ->
34-
deps = Mix.Deps.all
35-
assert Enum.find(deps, match?(Mix.Dep[app: :rebar_dep], &1))
33+
deps = Mix.Deps.all
34+
assert Enum.find(deps, match?(Mix.Dep[app: :rebar_dep], &1))
3635

37-
assert Enum.find(deps, fn dep ->
38-
Mix.Dep[app: app, opts: opts] = dep
39-
if app == :git_rebar do
40-
assert Enum.find(opts, match?({:git, "../git_rebar"}, &1))
41-
assert Enum.find(opts, match?({:ref, "master"}, &1))
42-
true
43-
end
44-
end)
45-
end
36+
assert Enum.find(deps, fn dep ->
37+
Mix.Dep[app: app, opts: opts] = dep
38+
if app == :git_rebar do
39+
assert Enum.find(opts, match?({:git, "../git_rebar"}, &1))
40+
assert Enum.find(opts, match?({:ref, "master"}, &1))
41+
true
42+
end
43+
end)
4644
after
4745
Mix.Project.pop
4846
end
4947

5048
test "get and compile dependencies for rebar" do
49+
# Use rebar from project root
50+
System.put_env("MIX_HOME", MixTest.Case.elixir_root)
51+
5152
Mix.Project.push(RebarAsDep)
5253

5354
in_tmp "dependencies for rebar", fn ->
54-
Mix.Tasks.Deps.Get.run []
55+
Mix.Tasks.Deps.Get.run ["--no-compile"]
5556
assert_received { :mix_shell, :info, ["* Getting git_rebar [git: \"../git_rebar\"]"] }
5657

57-
Mix.Tasks.Compile.run []
58+
Mix.Tasks.Deps.Compile.run []
5859
assert_received { :mix_shell, :info, ["* Compiling git_rebar"] }
5960
assert_received { :mix_shell, :info, ["* Compiling rebar_dep"] }
6061
assert :git_rebar.any_function == :ok

lib/mix/test/test_helper.exs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ defmodule MixTest.Case do
2727
System.cmd "#{elixir_executable} #{mix_executable} #{args}"
2828
end
2929

30+
def elixir_root do
31+
Path.expand("../../..", __DIR__)
32+
end
33+
3034
def mix_executable do
3135
Path.expand("../../../bin/mix", __DIR__)
3236
end

0 commit comments

Comments
 (0)