@@ -509,6 +509,77 @@ defmodule Mix.DepTest do
509
509
end )
510
510
end
511
511
512
+ test "nested deps with optional matching" do
513
+ Process . put ( :custom_deps_git_repo_opts , optional: true )
514
+
515
+ # deps_repo brings git_repo but it is optional
516
+ deps = [
517
+ { :deps_repo , "0.1.0" , path: "custom/deps_repo" } ,
518
+ { :git_repo , "0.1.0" , git: MixTest.Case . fixture_path ( "git_repo" ) }
519
+ ]
520
+
521
+ with_deps ( deps , fn ->
522
+ in_fixture ( "deps_status" , fn ->
523
+ File . mkdir_p! ( "custom/deps_repo/lib" )
524
+
525
+ File . write! ( "custom/deps_repo/lib/a.ex" , """
526
+ # Check that the child dependency is top_level and optional
527
+ [%Mix.Dep{app: :git_repo, top_level: true, opts: opts}] = Mix.Dep.cached()
528
+ true = Keyword.fetch!(opts, :optional)
529
+ """ )
530
+
531
+ Mix.Tasks.Deps.Get . run ( [ ] )
532
+ Mix.Tasks.Deps.Compile . run ( [ ] )
533
+ end )
534
+ end )
535
+ end
536
+
537
+ test "nested deps with runtime override on parent" do
538
+ Process . put ( :custom_deps_git_repo_opts , runtime: false )
539
+
540
+ deps = [
541
+ { :deps_repo , "0.1.0" , path: "custom/deps_repo" } ,
542
+ { :git_repo , "0.1.0" , git: MixTest.Case . fixture_path ( "git_repo" ) }
543
+ ]
544
+
545
+ with_deps ( deps , fn ->
546
+ in_fixture ( "deps_status" , fn ->
547
+ File . mkdir_p! ( "custom/deps_repo/lib" )
548
+
549
+ File . write! ( "custom/deps_repo/lib/a.ex" , """
550
+ # Check that the child dependency is top_level and optional
551
+ [%Mix.Dep{app: :git_repo, top_level: true, opts: opts}] = Mix.Dep.cached()
552
+ false = Keyword.fetch!(opts, :runtime)
553
+ """ )
554
+
555
+ Mix.Tasks.Deps.Get . run ( [ ] )
556
+ Mix.Tasks.Deps.Compile . run ( [ ] )
557
+ end )
558
+ end )
559
+ end
560
+
561
+ test "nested deps with runtime override on child" do
562
+ deps = [
563
+ { :deps_repo , "0.1.0" , path: "custom/deps_repo" } ,
564
+ { :git_repo , "0.1.0" , git: MixTest.Case . fixture_path ( "git_repo" ) , runtime: false }
565
+ ]
566
+
567
+ with_deps ( deps , fn ->
568
+ in_fixture ( "deps_status" , fn ->
569
+ File . mkdir_p! ( "custom/deps_repo/lib" )
570
+
571
+ File . write! ( "custom/deps_repo/lib/a.ex" , """
572
+ # Check that the child dependency is top_level and optional
573
+ [%Mix.Dep{app: :git_repo, top_level: true, opts: opts}] = Mix.Dep.cached()
574
+ false = Keyword.has_key?(opts, :runtime)
575
+ """ )
576
+
577
+ Mix.Tasks.Deps.Get . run ( [ ] )
578
+ Mix.Tasks.Deps.Compile . run ( [ ] )
579
+ end )
580
+ end )
581
+ end
582
+
512
583
test "nested deps with overrides" do
513
584
# deps_repo brings git_repo but it is overriden
514
585
deps = [
0 commit comments