From 53f4c6eb6b57408a8b3cad412373db534a13ca1f Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sun, 3 Jun 2018 08:17:53 -0600 Subject: fix for #511 order of dependencies (#655) --- src/rlx_depsolver.erl | 5 ++-- src/rlx_release.erl | 2 +- test/rlx_depsolver_tests.erl | 70 ++++++++++++++++++++++---------------------- 3 files changed, 38 insertions(+), 39 deletions(-) diff --git a/src/rlx_depsolver.erl b/src/rlx_depsolver.erl index 9e34a2c..8a0f632 100644 --- a/src/rlx_depsolver.erl +++ b/src/rlx_depsolver.erl @@ -484,8 +484,7 @@ add_constraint(SrcPkg, SrcVsn, PkgsConstraints, PkgConstraint) -> {value, {PkgName, Constraints0}} -> Constraints0 end, - [{PkgName, [{PkgConstraint, {SrcPkg, SrcVsn}} | Constraints1]} - | lists:keydelete(PkgName, 1, PkgsConstraints)]. + lists:keydelete(PkgName, 1, PkgsConstraints)++[{PkgName, [{PkgConstraint, {SrcPkg, SrcVsn}} | Constraints1]}]. %% @doc %% Extend the currently active constraints correctly for the given constraints. @@ -625,7 +624,7 @@ pkgs(DepGraph, Visited, Pkg, Constraints, OtherPkgs, PathInd) -> F = fun (Vsn) -> Deps = get_dep_constraints(DepGraph, Pkg, Vsn), UConstraints = extend_constraints(Pkg, Vsn, Constraints, Deps), - DepPkgs =[dep_pkg(Dep) || Dep <- Deps], + DepPkgs = [dep_pkg(Dep) || Dep <- Deps], NewVisited = [{Pkg, Vsn} | Visited], Res = all_pkgs(DepGraph, NewVisited, DepPkgs ++ OtherPkgs, UConstraints, PathInd), Res diff --git a/src/rlx_release.erl b/src/rlx_release.erl index f2a1c35..a183043 100644 --- a/src/rlx_release.erl +++ b/src/rlx_release.erl @@ -384,7 +384,7 @@ parse_goal1(Release = #release_t{annotations=Annots, goals=Goals}, AppName -> {ok, Release#release_t{annotations=ec_dictionary:add(AppName, NewAnnots, Annots), - goals = [Constraint | Goals]}} + goals = Goals++[Constraint]}} end. -spec parse_constraint(application_constraint()) -> diff --git a/test/rlx_depsolver_tests.erl b/test/rlx_depsolver_tests.erl index 7cbe831..206bad4 100644 --- a/test/rlx_depsolver_tests.erl +++ b/test/rlx_depsolver_tests.erl @@ -42,9 +42,9 @@ first_test() -> case rlx_depsolver:solve(Dom0, [{app1, "0.1"}]) of - {ok,[{app3,{{0,3},{[],[]}}}, + {ok,[{app1,{{0,1},{[],[]}}}, {app2,{{0,2},{[],[<<"build">>,33]}}}, - {app1,{{0,1},{[],[]}}}]} -> + {app3,{{0,3},{[],[]}}}]} -> ok; E -> erlang:throw({invalid_result, E}) @@ -71,10 +71,10 @@ second_test() -> X = rlx_depsolver:solve(Dom0, [{app1, "0.1"}, {app2, "0.3"}]), - ?assertMatch({ok, [{app3,{{0,3},{[],[]}}}, - {app2,{{0,3},{[],[]}}}, + ?assertMatch({ok, [{app1,{{0,1},{[],[]}}}, {app4,{{0,2},{[],[]}}}, - {app1,{{0,1},{[],[]}}}]}, + {app2,{{0,3},{[],[]}}}, + {app3,{{0,3},{[],[]}}}]}, X). third_test() -> @@ -107,19 +107,19 @@ third_test() -> {"2.0.0", []}, {"6.0.0", []}]}]), - ?assertMatch({ok, [{app5,{{6,0,0},{[],[]}}}, - {app3,{{0,1,3},{[],[]}}}, - {app4,{{6,0,0},{[],[]}}}, + ?assertMatch({ok, [{app1,{{3,0},{[],[]}}}, {app2,{{3,0},{[],[]}}}, - {app1,{{3,0},{[],[]}}}]}, + {app4,{{6,0,0},{[],[]}}}, + {app3,{{0,1,3},{[],[]}}}, + {app5,{{6,0,0},{[],[]}}}]}, rlx_depsolver:solve(Dom0, [{app1, "3.0"}])), - ?assertMatch({ok, [{app5,{{6,0,0},{[],[]}}}, - {app3,{{0,1,3},{[],[]}}}, - {app4,{{6,0,0},{[],[]}}}, + ?assertMatch({ok, [{app1,{{3,0},{[],[]}}}, {app2,{{3,0},{[],[]}}}, - {app1,{{3,0},{[],[]}}}]}, + {app4,{{6,0,0},{[],[]}}}, + {app3,{{0,1,3},{[],[]}}}, + {app5,{{6,0,0},{[],[]}}}]}, rlx_depsolver:solve(Dom0, [app1])). fail_test() -> @@ -176,18 +176,18 @@ conflicting_passing_test() -> {"2.0.0", []}, {"6.0.0", []}]}]), - ?assertMatch({ok, [{app5,{{2,0,0},{[],[]}}}, - {app3,{{0,1,3},{[],[]}}}, - {app4,{{5,0,0},{[],[]}}}, + ?assertMatch({ok, [{app1,{{3,0},{[],[]}}}, {app2,{{3,0},{[],[]}}}, - {app1,{{3,0},{[],[]}}}]}, + {app4,{{5,0,0},{[],[]}}}, + {app3,{{0,1,3},{[],[]}}}, + {app5,{{2,0,0},{[],[]}}}]}, rlx_depsolver:solve(Dom0, [{app1, "3.0"}])), - ?assertMatch({ok, [{app5,{{2,0,0},{[],[]}}}, - {app3,{{0,1,3},{[],[]}}}, - {app4,{{5,0,0},{[],[]}}}, + ?assertMatch({ok, [{app1,{{3,0},{[],[]}}}, {app2,{{3,0},{[],[]}}}, - {app1,{{3,0},{[],[]}}}]}, + {app4,{{5,0,0},{[],[]}}}, + {app3,{{0,1,3},{[],[]}}}, + {app5,{{2,0,0},{[],[]}}}]}, rlx_depsolver:solve(Dom0, [app1, app2, app5])). @@ -196,7 +196,7 @@ circular_dependencies_test() -> Dom0 = rlx_depsolver:add_packages(rlx_depsolver:new_graph(), [{app1, [{"0.1.0", [app2]}]}, {app2, [{"0.0.1", [app1]}]}]), - ?assertMatch({ok, [{app1,{{0,1,0},{[],[]}}},{app2,{{0,0,1},{[],[]}}}]}, + ?assertMatch({ok, [{app2,{{0,0,1},{[],[]}}},{app1,{{0,1,0},{[],[]}}}]}, rlx_depsolver:solve(Dom0, [{app1, "0.1.0"}])). conflicting_failing_test() -> @@ -217,12 +217,12 @@ conflicting_failing_test() -> Ret = rlx_depsolver:solve(Dom0, [app1, app3]), _ = rlx_depsolver:format_error(Ret), ?assertMatch({error, - [{[{[app1], + [{[{[app3], + [{app3,{{0,1,0},{[],[]}}},[[{app5,{{6,0,0},{[],[]}}}]]]}, + {[app1], [{app1,{{3,0},{[],[]}}}, - [[{app4,{{5,0,0},{[],[]}}}], - [{app2,{{0,0,1},{[],[]}}},[[{app4,{{5,0,0},{[],[]}}}]]]]]}, - {[app3], - [{app3,{{0,1,0},{[],[]}}},[[{app5,{{6,0,0},{[],[]}}}]]]}], + [[{app2,{{0,0,1},{[],[]}}},[[{app4,{{5,0,0},{[],[]}}}]]], + [{app4,{{5,0,0},{[],[]}}}]]]}], [{{app4,{{5,0,0},{[],[]}}},[{app5,{{2,0,0},{[],[]}}}]}, {{app1,{{3,0},{[],[]}}},[{app5,{{2,0,0},{[],[]}},'='}]}]}]}, Ret). @@ -259,11 +259,11 @@ pessimistic_major_minor_patch_test() -> {"0.3.0", []}, {"2.0.0", []}, {"6.0.0", []}]}]), - ?assertMatch({ok, [{app5,{{6,0,0},{[],[]}}}, - {app3,{{0,1,3},{[],[]}}}, - {app4,{{6,0,0},{[],[]}}}, + ?assertMatch({ok, [{app1,{{3,0},{[],[]}}}, {app2,{{2,1,5},{[],[]}}}, - {app1,{{3,0},{[],[]}}}]}, + {app4,{{6,0,0},{[],[]}}}, + {app3,{{0,1,3},{[],[]}}}, + {app5,{{6,0,0},{[],[]}}}]}, rlx_depsolver:solve(Dom0, [{app1, "3.0"}])). pessimistic_major_minor_test() -> @@ -297,11 +297,11 @@ pessimistic_major_minor_test() -> {"0.3.0", []}, {"2.0.0", []}, {"6.0.0", []}]}]), - ?assertMatch({ok, [{app5,{{6,0,0},{[],[]}}}, - {app3,{{0,1,3},{[],[]}}}, - {app4,{{6,0,0},{[],[]}}}, + ?assertMatch({ok, [{app1,{{3,0},{[],[]}}}, {app2,{{2,2},{[],[]}}}, - {app1,{{3,0},{[],[]}}}]}, + {app4,{{6,0,0},{[],[]}}}, + {app3,{{0,1,3},{[],[]}}}, + {app5,{{6,0,0},{[],[]}}}]}, rlx_depsolver:solve(Dom0, [{app1, "3.0"}])). filter_versions_test() -> -- cgit v1.2.3