From bae459de2834e30977f464ee1be3a650c11a38a9 Mon Sep 17 00:00:00 2001 From: Eric Yu Date: Tue, 22 Aug 2017 12:18:38 -0500 Subject: [PATCH] policy.c: Fix solver_prune_to_highest_prio_per_name - Fixed logic so that all packages with the same name are pushed to the queue of packages to be pruned instead of just the first package with that name. - This fixes a bug where the best version of recommended and suggested packages were not being returned. - Added tests to check that this does fix the problem with recommended and suggested packages mentioned above. --- src/policy.c | 2 ++ .../recommendations/recommended_conflicts.t | 16 ++++++++++++++++ .../recommendations/recommended_multirepo.t | 19 +++++++++++++++++++ .../recommendations/recommended_oldversion.t | 15 +++++++++++++++ .../recommendations/recommended_targeted.t | 15 +++++++++++++++ .../recommendations/recommended_version.t | 15 +++++++++++++++ .../recommendations/suggested_conflicts.t | 16 ++++++++++++++++ .../recommendations/suggested_multirepo.t | 19 +++++++++++++++++++ .../recommendations/suggested_oldversion.t | 15 +++++++++++++++ .../recommendations/suggested_targeted.t | 15 +++++++++++++++ .../recommendations/suggested_version.t | 15 +++++++++++++++ 11 files changed, 162 insertions(+) create mode 100644 test/testcases/recommendations/recommended_conflicts.t create mode 100644 test/testcases/recommendations/recommended_multirepo.t create mode 100644 test/testcases/recommendations/recommended_oldversion.t create mode 100644 test/testcases/recommendations/recommended_targeted.t create mode 100644 test/testcases/recommendations/recommended_version.t create mode 100644 test/testcases/recommendations/suggested_conflicts.t create mode 100644 test/testcases/recommendations/suggested_multirepo.t create mode 100644 test/testcases/recommendations/suggested_oldversion.t create mode 100644 test/testcases/recommendations/suggested_targeted.t create mode 100644 test/testcases/recommendations/suggested_version.t diff --git a/src/policy.c b/src/policy.c index a6d34415..185561ed 100644 --- a/src/policy.c +++ b/src/policy.c @@ -210,6 +210,8 @@ solver_prune_to_highest_prio_per_name(Solver *solv, Queue *plist) queue_push(&pq, plist->elements[i]); name = pool->solvables[pq.elements[0]].name; } + else + queue_push(&pq, plist->elements[i]); } if (pq.count > 2) solver_prune_to_highest_prio(solv, &pq); diff --git a/test/testcases/recommendations/recommended_conflicts.t b/test/testcases/recommendations/recommended_conflicts.t new file mode 100644 index 00000000..2e28871d --- /dev/null +++ b/test/testcases/recommendations/recommended_conflicts.t @@ -0,0 +1,16 @@ +repo system 0 empty +repo available 0 testtags +#>=Pkg: A 1 1 noarch +#>=Rec: B +#>=Pkg: B 1 1 noarch +#>=Pkg: B 3 1 noarch +#>=Con: A +#>=Pkg: B 2 1 noarch +system i686 rpm system + +solverflags ignorerecommended +job install name A + +result transaction,recommended,problems +#>install A-1-1.noarch@available +#>recommended B-2-1.noarch@available \ No newline at end of file diff --git a/test/testcases/recommendations/recommended_multirepo.t b/test/testcases/recommendations/recommended_multirepo.t new file mode 100644 index 00000000..9fc60d01 --- /dev/null +++ b/test/testcases/recommendations/recommended_multirepo.t @@ -0,0 +1,19 @@ +repo system 0 empty +repo available 0 testtags +#>=Pkg: A 1 1 noarch +#>=Rec: B +#>=Pkg: B 1 1 noarch +#>=Pkg: B 3 1 noarch +#>=Pkg: B 2 1 noarch +repo other 0 testtags +#>=Pkg: B 4 1 noarch +#>=Pkg: B 6 1 noarch +#>=Pkg: B 5 1 noarch +system i686 rpm system + +solverflags ignorerecommended +job install name A + +result transaction,recommended,problems +#>install A-1-1.noarch@available +#>recommended B-6-1.noarch@other \ No newline at end of file diff --git a/test/testcases/recommendations/recommended_oldversion.t b/test/testcases/recommendations/recommended_oldversion.t new file mode 100644 index 00000000..f7a1a62d --- /dev/null +++ b/test/testcases/recommendations/recommended_oldversion.t @@ -0,0 +1,15 @@ +repo system 0 empty +repo available 0 testtags +#>=Pkg: A 1 1 noarch +#>=Rec: B < 3 +#>=Pkg: B 1 1 noarch +#>=Pkg: B 3 1 noarch +#>=Pkg: B 2 1 noarch +system i686 rpm system + +solverflags ignorerecommended +job install name A + +result transaction,recommended,problems +#>install A-1-1.noarch@available +#>recommended B-2-1.noarch@available \ No newline at end of file diff --git a/test/testcases/recommendations/recommended_targeted.t b/test/testcases/recommendations/recommended_targeted.t new file mode 100644 index 00000000..d5a0b159 --- /dev/null +++ b/test/testcases/recommendations/recommended_targeted.t @@ -0,0 +1,15 @@ +repo system 0 empty +repo available 0 testtags +#>=Pkg: A 1 1 noarch +#>=Rec: B = 2-1 +#>=Pkg: B 1 1 noarch +#>=Pkg: B 3 1 noarch +#>=Pkg: B 2 1 noarch +system i686 rpm system + +solverflags ignorerecommended +job install name A + +result transaction,recommended,problems +#>install A-1-1.noarch@available +#>recommended B-2-1.noarch@available \ No newline at end of file diff --git a/test/testcases/recommendations/recommended_version.t b/test/testcases/recommendations/recommended_version.t new file mode 100644 index 00000000..3a875139 --- /dev/null +++ b/test/testcases/recommendations/recommended_version.t @@ -0,0 +1,15 @@ +repo system 0 empty +repo available 0 testtags +#>=Pkg: A 1 1 noarch +#>=Rec: B +#>=Pkg: B 1 1 noarch +#>=Pkg: B 3 1 noarch +#>=Pkg: B 2 1 noarch +system i686 rpm system + +solverflags ignorerecommended +job install name A + +result transaction,recommended,problems +#>install A-1-1.noarch@available +#>recommended B-3-1.noarch@available \ No newline at end of file diff --git a/test/testcases/recommendations/suggested_conflicts.t b/test/testcases/recommendations/suggested_conflicts.t new file mode 100644 index 00000000..fa83413f --- /dev/null +++ b/test/testcases/recommendations/suggested_conflicts.t @@ -0,0 +1,16 @@ +repo system 0 empty +repo available 0 testtags +#>=Pkg: A 1 1 noarch +#>=Sug: B +#>=Pkg: B 1 1 noarch +#>=Pkg: B 3 1 noarch +#>=Con: A +#>=Pkg: B 2 1 noarch +system i686 rpm system + +solverflags ignorerecommended +job install name A + +result transaction,recommended,problems +#>install A-1-1.noarch@available +#>suggested B-2-1.noarch@available \ No newline at end of file diff --git a/test/testcases/recommendations/suggested_multirepo.t b/test/testcases/recommendations/suggested_multirepo.t new file mode 100644 index 00000000..db3ab4b2 --- /dev/null +++ b/test/testcases/recommendations/suggested_multirepo.t @@ -0,0 +1,19 @@ +repo system 0 empty +repo available 0 testtags +#>=Pkg: A 1 1 noarch +#>=Sug: B +#>=Pkg: B 1 1 noarch +#>=Pkg: B 3 1 noarch +#>=Pkg: B 2 1 noarch +repo other 0 testtags +#>=Pkg: B 4 1 noarch +#>=Pkg: B 6 1 noarch +#>=Pkg: B 5 1 noarch +system i686 rpm system + +solverflags ignorerecommended +job install name A + +result transaction,recommended,problems +#>install A-1-1.noarch@available +#>suggested B-6-1.noarch@other \ No newline at end of file diff --git a/test/testcases/recommendations/suggested_oldversion.t b/test/testcases/recommendations/suggested_oldversion.t new file mode 100644 index 00000000..ad08be1c --- /dev/null +++ b/test/testcases/recommendations/suggested_oldversion.t @@ -0,0 +1,15 @@ +repo system 0 empty +repo available 0 testtags +#>=Pkg: A 1 1 noarch +#>=Sug: B < 3 +#>=Pkg: B 1 1 noarch +#>=Pkg: B 3 1 noarch +#>=Pkg: B 2 1 noarch +system i686 rpm system + +solverflags ignorerecommended +job install name A + +result transaction,recommended,problems +#>install A-1-1.noarch@available +#>suggested B-2-1.noarch@available \ No newline at end of file diff --git a/test/testcases/recommendations/suggested_targeted.t b/test/testcases/recommendations/suggested_targeted.t new file mode 100644 index 00000000..5a9f1aa2 --- /dev/null +++ b/test/testcases/recommendations/suggested_targeted.t @@ -0,0 +1,15 @@ +repo system 0 empty +repo available 0 testtags +#>=Pkg: A 1 1 noarch +#>=Sug: B = 2-1 +#>=Pkg: B 1 1 noarch +#>=Pkg: B 3 1 noarch +#>=Pkg: B 2 1 noarch +system i686 rpm system + +solverflags ignorerecommended +job install name A + +result transaction,recommended,problems +#>install A-1-1.noarch@available +#>suggested B-2-1.noarch@available \ No newline at end of file diff --git a/test/testcases/recommendations/suggested_version.t b/test/testcases/recommendations/suggested_version.t new file mode 100644 index 00000000..27a3b538 --- /dev/null +++ b/test/testcases/recommendations/suggested_version.t @@ -0,0 +1,15 @@ +repo system 0 empty +repo available 0 testtags +#>=Pkg: A 1 1 noarch +#>=Sug: B +#>=Pkg: B 1 1 noarch +#>=Pkg: B 3 1 noarch +#>=Pkg: B 2 1 noarch +system i686 rpm system + +solverflags ignorerecommended +job install name A + +result transaction,recommended,problems +#>install A-1-1.noarch@available +#>suggested B-3-1.noarch@available \ No newline at end of file -- 2.47.2