Skip to content

Commit 14bd4b5

Browse files
committed
Streamline loader code and tests
1 parent 0f00cb0 commit 14bd4b5

File tree

2 files changed

+19
-42
lines changed

2 files changed

+19
-42
lines changed

lib/mix/lib/mix/dep/loader.ex

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,9 @@ defmodule Mix.Dep.Loader do
177177

178178
bin_app = Atom.to_string(app)
179179

180-
dest = Path.join(Mix.Project.deps_path(), bin_app)
181-
build = Path.join([Mix.Project.build_path(), "lib", bin_app])
180+
config = Mix.Project.config()
181+
dest = Path.join(Mix.Project.deps_path(config), bin_app)
182+
build = Path.join([Mix.Project.build_path(config), "lib", bin_app])
182183

183184
opts =
184185
opts
@@ -202,9 +203,7 @@ defmodule Mix.Dep.Loader do
202203
)
203204
end
204205

205-
project_app = Mix.Project.config()[:app]
206-
207-
if project_app && project_app == app do
206+
if config[:app] == app do
208207
Mix.shell().error(
209208
"warning: the application name #{inspect(app)} is the same as one of its dependencies"
210209
)

lib/mix/test/mix/tasks/deps_test.exs

Lines changed: 15 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -870,45 +870,31 @@ defmodule Mix.Tasks.DepsTest do
870870
Application.delete_env(:raw_repo, :compile_env, persistent: true)
871871
end
872872

873-
defmodule NonCompilingDeps do
874-
def project do
875-
[
876-
app: :raw_sample,
877-
version: "0.1.0",
873+
test "does not compile deps that have explicit option" do
874+
in_fixture("deps_status", fn ->
875+
Mix.ProjectStack.post_config(
878876
deps: [
879877
{:git_repo, "0.1.0", git: MixTest.Case.fixture_path("git_repo"), compile: false}
880878
]
881-
]
882-
end
883-
end
884-
885-
test "does not compile deps that have explicit option" do
886-
in_fixture("deps_status", fn ->
887-
Mix.Project.push(NonCompilingDeps)
879+
)
888880

881+
Mix.Project.push(MixTest.Case.Sample)
889882
Mix.Tasks.Deps.Compile.run([])
890883
refute_received {:mix_shell, :info, ["==> git_repo"]}
891884
end)
892885
end
893886

894-
defmodule DupDeps do
895-
def project do
896-
[
897-
app: :raw_sample,
898-
version: "0.1.0",
887+
test "warns and converges duplicated deps at the same level" do
888+
in_fixture("deps_status", fn ->
889+
Mix.ProjectStack.post_config(
899890
deps: [
900891
# Simulate dependencies gathered together from umbrella
901892
{:ok, "0.1.0", path: "deps/ok"},
902893
{:ok, "0.1.0", path: "deps/ok"}
903894
]
904-
]
905-
end
906-
end
907-
908-
test "warns and converges duplicated deps at the same level" do
909-
in_fixture("deps_status", fn ->
910-
Mix.Project.push(DupDeps)
895+
)
911896

897+
Mix.Project.push(MixTest.Case.Sample)
912898
Mix.Tasks.Deps.run([])
913899

914900
msg =
@@ -922,22 +908,14 @@ defmodule Mix.Tasks.DepsTest do
922908
end)
923909
end
924910

925-
defmodule AppNameClashesWithDep do
926-
def project do
927-
[
928-
app: :ok,
929-
version: "0.1.0",
930-
deps: [
931-
{:ok, "0.1.0", path: "deps/ok"}
932-
]
933-
]
934-
end
935-
end
936-
937911
test "warns when project app name matches a dependency" do
938912
in_fixture("deps_status", fn ->
939-
Mix.Project.push(AppNameClashesWithDep)
913+
Mix.ProjectStack.post_config(
914+
app: :ok,
915+
deps: [{:ok, "0.1.0", path: "deps/ok"}]
916+
)
940917

918+
Mix.Project.push(MixTest.Case.Sample)
941919
Mix.Tasks.Deps.Get.run([])
942920

943921
msg =

0 commit comments

Comments
 (0)