diff options
author | José Valim <jose.valim@gmail.com> | 2018-12-01 18:12:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-01 18:12:01 +0100 |
commit | 7d969b975a9cac04d191ac6de32a5152c303a427 (patch) | |
tree | 063b8fb6846c6b129e85defb37c6425a9d19e62a | |
parent | 1c502f9f4d277a3016d99f6892bf69130b417196 (diff) | |
download | elixir-7d969b975a9cac04d191ac6de32a5152c303a427.tar.gz |
Consider :only from deps in compile.app (#8441)
Closes #8225.
-rw-r--r-- | lib/mix/lib/mix/tasks/compile.app.ex | 9 | ||||
-rw-r--r-- | lib/mix/test/mix/dep_test.exs | 26 |
2 files changed, 30 insertions, 5 deletions
diff --git a/lib/mix/lib/mix/tasks/compile.app.ex b/lib/mix/lib/mix/tasks/compile.app.ex index e1c542e10..c8f93d737 100644 --- a/lib/mix/lib/mix/tasks/compile.app.ex +++ b/lib/mix/lib/mix/tasks/compile.app.ex @@ -337,7 +337,14 @@ defmodule Mix.Tasks.Compile.App do defp runtime_dep?(_), do: true defp runtime_opts?(opts) do - Keyword.get(opts, :runtime, true) and Keyword.get(opts, :app, true) + Keyword.get(opts, :runtime, true) and Keyword.get(opts, :app, true) and matching_only?(opts) + end + + defp matching_only?(opts) do + case Keyword.fetch(opts, :only) do + {:ok, value} -> Mix.env() in List.wrap(value) + :error -> true + end end defp normalize_apps(apps, extra, config) do diff --git a/lib/mix/test/mix/dep_test.exs b/lib/mix/test/mix/dep_test.exs index fbdb014ad..4cbba9cbb 100644 --- a/lib/mix/test/mix/dep_test.exs +++ b/lib/mix/test/mix/dep_test.exs @@ -752,11 +752,9 @@ defmodule Mix.DepTest do test "converges and diverges when only is not specified" do Process.put(:custom_deps_git_repo_opts, only: :test) - # Pass nil environment to mimic behaviour in umbrellas - # where the children are loaded without an environment. deps = [ - {:abc_repo, "0.1.0", path: "custom/abc_repo", env: nil}, - {:deps_repo, "0.1.0", path: "custom/deps_repo", env: nil} + {:abc_repo, "0.1.0", path: "custom/abc_repo", from_umbrella: true}, + {:deps_repo, "0.1.0", path: "custom/deps_repo", from_umbrella: true} ] with_deps(deps, fn -> @@ -847,5 +845,25 @@ defmodule Mix.DepTest do end) end) end + + test "considers only from current app on nested deps" do + Process.put(:custom_deps_git_repo_opts, only: :other) + + deps = [ + {:deps_repo, "0.1.0", path: "custom/deps_repo", from_umbrella: true}, + {:git_repo, "0.1.0", git: MixTest.Case.fixture_path("git_repo"), from_umbrella: true} + ] + + with_deps(deps, fn -> + in_fixture("deps_status", fn -> + Mix.Tasks.Deps.Compile.run([]) + + {:ok, [{:application, :deps_repo, opts}]} = + :file.consult("_build/dev/lib/deps_repo/ebin/deps_repo.app") + + assert :git_repo not in Keyword.get(opts, :applications) + end) + end) + end end end |