[sdk/kde-builder] /: refactor: Unwrap _compare_debug_order() function

Andrew Shark <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 8338c2905908fad444b5127325b67f7c312dc24c by Andrew Shark.
Committed on 31/07/2026 at 23:12.
Pushed by ashark into branch 'master'.

refactor: Unwrap _compare_debug_order() function

M  +1    -1    kde_builder_lib/application.py
M  +105  -103  kde_builder_lib/debug_order_hints.py
M  +70   -70   tests/unit/debug-hints/test_compare-debug-order.py

https://invent.kde.org/sdk/kde-builder/-/commit/8338c2905908fad444b5127325b67f7c312dc24c

diff --git a/kde_builder_lib/application.py b/kde_builder_lib/application.py
index ec787955..71edc6da 100644
--- a/kde_builder_lib/application.py
+++ b/kde_builder_lib/application.py
@@ -1055,7 +1055,7 @@ class Application:
         # this feature is meant for 5 out of 65
 
         if num_suggested_modules > top:
-            sorted_for_debug = DebugOrderHints.sort_failures_in_debug_order(module_graph, extra_debug_info, actual_failures)
+            sorted_for_debug = DebugOrderHints(module_graph, extra_debug_info).sort_failures_in_debug_order(actual_failures)
 
             logger_app.info(f"\nThe following top {top} may be the most important to fix to " +
                             "get the build to work, listed in order of 'probably most " +
diff --git a/kde_builder_lib/debug_order_hints.py b/kde_builder_lib/debug_order_hints.py
index d641340d..2052954a 100644
--- a/kde_builder_lib/debug_order_hints.py
+++ b/kde_builder_lib/debug_order_hints.py
@@ -25,6 +25,10 @@ class DebugOrderHints:
     missing dependency).
     """
 
+    def __init__(self, module_graph: dict, extra_debug_info: dict):
+        self.module_graph = module_graph
+        self.extra_debug_info = extra_debug_info
+
     @staticmethod
     def _get_phase_score(phase: str) -> int:
         """
@@ -52,108 +56,106 @@ class DebugOrderHints:
             return 1
         return 0
 
-    @staticmethod
-    def _make_comparison_func(module_graph, extra_debug_info):
-        def _compare_debug_order(a, b):
-            # comparison results uses:
-            # -1 if a < b
-            # 0 if a == b
-            # 1 if a > b
-
-            name_a = a.name
-            name_b = b.name
-
-            # Enforce a strict dependency ordering.
-            # The case where both are true should never happen, since that would
-            # amount to a cycle, and cycle detection is supposed to have been
-            # performed beforehand.
-            #
-            # Assumption: if A depends on B, and B is broken then a failure to build
-            # A is probably due to lacking a working B.
-
-            b_depends_on_a = module_graph[name_a]["votes"].get(name_b, 0)
-            a_depends_on_b = module_graph[name_b]["votes"].get(name_a, 0)
-            order = -1 if b_depends_on_a else (1 if a_depends_on_b else 0)
-
-            if order:
-                return order
-
-            # TODO we could tag explicitly selected modules from command line?
-            # If we do so, then the user is probably more interested in debugging
-            # those first, rather than "unrelated" noise from modules pulled in due
-            # to possibly overly broad dependency declarations. In that case we
-            # should sort explicitly tagged modules next highest, after dependency
-            # ordering.
-
-            # Assuming no dependency resolution, next favour possible root causes as
-            # may be inferred from the dependency tree.
-            #
-            # Assumption: there may be certain "popular" modules which rely on a
-            # failed module. Those should probably not be considered as "interesting"
-            # as root cause failures in less popuplar dependency trees. This is
-            # essentially a mitigation against noise introduced from raw "popularity"
-            # contests (see below).
-
-            is_root_a = len(module_graph[name_a]["deps"]) == 0
-            is_root_b = len(module_graph[name_b]["deps"]) == 0
-
-            if is_root_a and not is_root_b:
-                return -1
-            if is_root_b and not is_root_a:
-                return 1
-
-            # Next sort by "popularity": the item with the most votes (back edges) is
-            # depended on the most.
-            #
-            # Assumption: it is probably a good idea to debug that one earlier.
-            # This would point the user to fixing the most heavily used dependencies
-            # first before investing time in more "exotic" modules
-
-            vote_a = len(module_graph[name_a]["votes"])
-            vote_b = len(module_graph[name_b]["votes"])
-            votes = vote_b - vote_a
-
-            if votes:
-                return votes
-
-            # Try and see if there is something "interesting" that might e.g. indicate
-            # issues with the system itself, preventing a successful build.
-
-            phase_a = DebugOrderHints._get_phase_score(extra_debug_info["phases"].get(name_a, ""))
-            phase_b = DebugOrderHints._get_phase_score(extra_debug_info["phases"].get(name_b, ""))
-            phase = (phase_b > phase_a) - (phase_b < phase_a)
-
-            if phase:
-                return phase
-
-            # Assumption: persistently failing modules do not prompt the user
-            # to act and therefore these are likely not that interesting.
-            # Conversely *new* failures are.
-            #
-            # If we get this wrong the user will likely be on the case anyway:
-            # someone does not need prodding if they have been working on it
-            # for the past X builds or so already.
-
-            fail_count_a = a.get_persistent_option("failure-count")
-            fail_count_b = b.get_persistent_option("failure-count")
-            fail_count = (fail_count_a or 0) - (fail_count_b or 0)
-
-            if fail_count:
-                return fail_count
-
-            # If there is no good reason to prefer one module over another,
-            # simply sort by name to get a reproducible order.
-            # That simplifies autotesting and/or reproducible builds.
-            # (The items to sort are supplied as a dict so the order of keys is by
-            # definition not guaranteed.)
-
-            name = (name_a > name_b) - (name_a < name_b)
-
-            return name
-
-        return _compare_debug_order
+    def _compare_debug_order(self, a, b):
+        module_graph = self.module_graph
+        extra_debug_info = self.extra_debug_info
+
+        # comparison results uses:
+        # -1 if a < b
+        # 0 if a == b
+        # 1 if a > b
+
+        name_a = a.name
+        name_b = b.name
+
+        # Enforce a strict dependency ordering.
+        # The case where both are true should never happen, since that would
+        # amount to a cycle, and cycle detection is supposed to have been
+        # performed beforehand.
+        #
+        # Assumption: if A depends on B, and B is broken then a failure to build
+        # A is probably due to lacking a working B.
+
+        b_depends_on_a = module_graph[name_a]["votes"].get(name_b, 0)
+        a_depends_on_b = module_graph[name_b]["votes"].get(name_a, 0)
+        order = -1 if b_depends_on_a else (1 if a_depends_on_b else 0)
+
+        if order:
+            return order
+
+        # TODO we could tag explicitly selected modules from command line?
+        # If we do so, then the user is probably more interested in debugging
+        # those first, rather than "unrelated" noise from modules pulled in due
+        # to possibly overly broad dependency declarations. In that case we
+        # should sort explicitly tagged modules next highest, after dependency
+        # ordering.
+
+        # Assuming no dependency resolution, next favour possible root causes as
+        # may be inferred from the dependency tree.
+        #
+        # Assumption: there may be certain "popular" modules which rely on a
+        # failed module. Those should probably not be considered as "interesting"
+        # as root cause failures in less popuplar dependency trees. This is
+        # essentially a mitigation against noise introduced from raw "popularity"
+        # contests (see below).
+
+        is_root_a = len(module_graph[name_a]["deps"]) == 0
+        is_root_b = len(module_graph[name_b]["deps"]) == 0
+
+        if is_root_a and not is_root_b:
+            return -1
+        if is_root_b and not is_root_a:
+            return 1
 
-    @staticmethod
-    def sort_failures_in_debug_order(module_graph, extra_debug_info, failures: list[Module]) -> list[Module]:
-        prioritised = sorted(failures, key=cmp_to_key(DebugOrderHints._make_comparison_func(module_graph, extra_debug_info)))
+        # Next sort by "popularity": the item with the most votes (back edges) is
+        # depended on the most.
+        #
+        # Assumption: it is probably a good idea to debug that one earlier.
+        # This would point the user to fixing the most heavily used dependencies
+        # first before investing time in more "exotic" modules
+
+        vote_a = len(module_graph[name_a]["votes"])
+        vote_b = len(module_graph[name_b]["votes"])
+        votes = vote_b - vote_a
+
+        if votes:
+            return votes
+
+        # Try and see if there is something "interesting" that might e.g. indicate
+        # issues with the system itself, preventing a successful build.
+
+        phase_a = DebugOrderHints._get_phase_score(extra_debug_info["phases"].get(name_a, ""))
+        phase_b = DebugOrderHints._get_phase_score(extra_debug_info["phases"].get(name_b, ""))
+        phase = (phase_b > phase_a) - (phase_b < phase_a)
+
+        if phase:
+            return phase
+
+        # Assumption: persistently failing modules do not prompt the user
+        # to act and therefore these are likely not that interesting.
+        # Conversely *new* failures are.
+        #
+        # If we get this wrong the user will likely be on the case anyway:
+        # someone does not need prodding if they have been working on it
+        # for the past X builds or so already.
+
+        fail_count_a = a.get_persistent_option("failure-count")
+        fail_count_b = b.get_persistent_option("failure-count")
+        fail_count = (fail_count_a or 0) - (fail_count_b or 0)
+
+        if fail_count:
+            return fail_count
+
+        # If there is no good reason to prefer one module over another,
+        # simply sort by name to get a reproducible order.
+        # That simplifies autotesting and/or reproducible builds.
+        # (The items to sort are supplied as a dict so the order of keys is by
+        # definition not guaranteed.)
+
+        name = (name_a > name_b) - (name_a < name_b)
+
+        return name
+
+    def sort_failures_in_debug_order(self, failures: list[Module]) -> list[Module]:
+        prioritised = sorted(failures, key=cmp_to_key(self._compare_debug_order))
         return prioritised
diff --git a/tests/unit/debug-hints/test_compare-debug-order.py b/tests/unit/debug-hints/test_compare-debug-order.py
index 22335c84..61d6784d 100644
--- a/tests/unit/debug-hints/test_compare-debug-order.py
+++ b/tests/unit/debug-hints/test_compare-debug-order.py
@@ -80,35 +80,35 @@ def test_debug_order(mock_module):
         }
     }
 
-    assert DebugOrderHints._make_comparison_func(graph1, extra_debug_info1)(c1, c1) == 0, "Comparing the same modules should always yield the same relative position"
-    assert DebugOrderHints._make_comparison_func(graph1, extra_debug_info1)(c1, d1) == -1, "No dependency relation ship, root causes, same popularity: the \"newest\" failure (lower count) should be sorted first"
-    assert DebugOrderHints._make_comparison_func(graph1, extra_debug_info1)(c1, e1) == 1, "No dependency relation ship, root causes: the higher popularity should be sorted first"
-    assert DebugOrderHints._make_comparison_func(graph1, extra_debug_info1)(c1, b1) == -1, "No dependency relation ship: the root cause should be sorted first"
-    assert DebugOrderHints._make_comparison_func(graph1, extra_debug_info1)(c1, a1) == -1, "No dependency relation ship: the root cause should be sorted first"
-
-    assert DebugOrderHints._make_comparison_func(graph1, extra_debug_info1)(d1, c1) == 1, "No dependency relation ship, root causes, same popularity: the \"newest\" failure (lower count) should be sorted first"
-    assert DebugOrderHints._make_comparison_func(graph1, extra_debug_info1)(d1, d1) == 0, "Comparing the same modules should always yield the same relative position"
-    assert DebugOrderHints._make_comparison_func(graph1, extra_debug_info1)(d1, e1) == 1, "No dependency relation ship, root causes: the higher popularity should be sorted first"
-    assert DebugOrderHints._make_comparison_func(graph1, extra_debug_info1)(d1, b1) == -1, "No dependency relation ship: the root cause should be sorted first"
-    assert DebugOrderHints._make_comparison_func(graph1, extra_debug_info1)(d1, a1) == -1, "No dependency relation ship: the root cause should be sorted first"
-
-    assert DebugOrderHints._make_comparison_func(graph1, extra_debug_info1)(e1, c1) == -1, "No dependency relation ship, root causes: the higher popularity should be sorted first"
-    assert DebugOrderHints._make_comparison_func(graph1, extra_debug_info1)(e1, d1) == -1, "No dependency relation ship, root causes: the higher popularity should be sorted first"
-    assert DebugOrderHints._make_comparison_func(graph1, extra_debug_info1)(e1, e1) == 0, "Comparing the same modules should always yield the same relative position"
-    assert DebugOrderHints._make_comparison_func(graph1, extra_debug_info1)(e1, b1) == -1, "No dependency relation ship: the root cause should be sorted first"
-    assert DebugOrderHints._make_comparison_func(graph1, extra_debug_info1)(e1, a1) == -1, "Dependencies should be sorted before dependent modules"
-
-    assert DebugOrderHints._make_comparison_func(graph1, extra_debug_info1)(b1, c1) == 1, "No dependency relation ship: the root cause should be sorted first"
-    assert DebugOrderHints._make_comparison_func(graph1, extra_debug_info1)(b1, d1) == 1, "No dependency relation ship: the root cause should be sorted first"
-    assert DebugOrderHints._make_comparison_func(graph1, extra_debug_info1)(b1, e1) == 1, "No dependency relation ship: the root cause should be sorted first"
-    assert DebugOrderHints._make_comparison_func(graph1, extra_debug_info1)(b1, b1) == 0, "Comparing the same modules should always yield the same relative position"
-    assert DebugOrderHints._make_comparison_func(graph1, extra_debug_info1)(b1, a1) == -1, "Dependencies should be sorted before dependent modules"
-
-    assert DebugOrderHints._make_comparison_func(graph1, extra_debug_info1)(a1, c1) == 1, "No dependency relation ship: the root cause should be sorted first"
-    assert DebugOrderHints._make_comparison_func(graph1, extra_debug_info1)(a1, d1) == 1, "No dependency relation ship: the root cause should be sorted first"
-    assert DebugOrderHints._make_comparison_func(graph1, extra_debug_info1)(a1, e1) == 1, "Dependencies should be sorted before dependent modules"
-    assert DebugOrderHints._make_comparison_func(graph1, extra_debug_info1)(a1, b1) == 1, "Dependencies should be sorted before dependent modules"
-    assert DebugOrderHints._make_comparison_func(graph1, extra_debug_info1)(a1, a1) == 0, "Comparing the same modules should always yield the same relative position"
+    assert DebugOrderHints(graph1, extra_debug_info1)._compare_debug_order(c1, c1) == 0, "Comparing the same modules should always yield the same relative position"
+    assert DebugOrderHints(graph1, extra_debug_info1)._compare_debug_order(c1, d1) == -1, "No dependency relation ship, root causes, same popularity: the \"newest\" failure (lower count) should be sorted first"
+    assert DebugOrderHints(graph1, extra_debug_info1)._compare_debug_order(c1, e1) == 1, "No dependency relation ship, root causes: the higher popularity should be sorted first"
+    assert DebugOrderHints(graph1, extra_debug_info1)._compare_debug_order(c1, b1) == -1, "No dependency relation ship: the root cause should be sorted first"
+    assert DebugOrderHints(graph1, extra_debug_info1)._compare_debug_order(c1, a1) == -1, "No dependency relation ship: the root cause should be sorted first"
+
+    assert DebugOrderHints(graph1, extra_debug_info1)._compare_debug_order(d1, c1) == 1, "No dependency relation ship, root causes, same popularity: the \"newest\" failure (lower count) should be sorted first"
+    assert DebugOrderHints(graph1, extra_debug_info1)._compare_debug_order(d1, d1) == 0, "Comparing the same modules should always yield the same relative position"
+    assert DebugOrderHints(graph1, extra_debug_info1)._compare_debug_order(d1, e1) == 1, "No dependency relation ship, root causes: the higher popularity should be sorted first"
+    assert DebugOrderHints(graph1, extra_debug_info1)._compare_debug_order(d1, b1) == -1, "No dependency relation ship: the root cause should be sorted first"
+    assert DebugOrderHints(graph1, extra_debug_info1)._compare_debug_order(d1, a1) == -1, "No dependency relation ship: the root cause should be sorted first"
+
+    assert DebugOrderHints(graph1, extra_debug_info1)._compare_debug_order(e1, c1) == -1, "No dependency relation ship, root causes: the higher popularity should be sorted first"
+    assert DebugOrderHints(graph1, extra_debug_info1)._compare_debug_order(e1, d1) == -1, "No dependency relation ship, root causes: the higher popularity should be sorted first"
+    assert DebugOrderHints(graph1, extra_debug_info1)._compare_debug_order(e1, e1) == 0, "Comparing the same modules should always yield the same relative position"
+    assert DebugOrderHints(graph1, extra_debug_info1)._compare_debug_order(e1, b1) == -1, "No dependency relation ship: the root cause should be sorted first"
+    assert DebugOrderHints(graph1, extra_debug_info1)._compare_debug_order(e1, a1) == -1, "Dependencies should be sorted before dependent modules"
+
+    assert DebugOrderHints(graph1, extra_debug_info1)._compare_debug_order(b1, c1) == 1, "No dependency relation ship: the root cause should be sorted first"
+    assert DebugOrderHints(graph1, extra_debug_info1)._compare_debug_order(b1, d1) == 1, "No dependency relation ship: the root cause should be sorted first"
+    assert DebugOrderHints(graph1, extra_debug_info1)._compare_debug_order(b1, e1) == 1, "No dependency relation ship: the root cause should be sorted first"
+    assert DebugOrderHints(graph1, extra_debug_info1)._compare_debug_order(b1, b1) == 0, "Comparing the same modules should always yield the same relative position"
+    assert DebugOrderHints(graph1, extra_debug_info1)._compare_debug_order(b1, a1) == -1, "Dependencies should be sorted before dependent modules"
+
+    assert DebugOrderHints(graph1, extra_debug_info1)._compare_debug_order(a1, c1) == 1, "No dependency relation ship: the root cause should be sorted first"
+    assert DebugOrderHints(graph1, extra_debug_info1)._compare_debug_order(a1, d1) == 1, "No dependency relation ship: the root cause should be sorted first"
+    assert DebugOrderHints(graph1, extra_debug_info1)._compare_debug_order(a1, e1) == 1, "Dependencies should be sorted before dependent modules"
+    assert DebugOrderHints(graph1, extra_debug_info1)._compare_debug_order(a1, b1) == 1, "Dependencies should be sorted before dependent modules"
+    assert DebugOrderHints(graph1, extra_debug_info1)._compare_debug_order(a1, a1) == 0, "Comparing the same modules should always yield the same relative position"
 
     # test: ordering of modules that fail in different phases
     p_b1 = Module("build1", 0)
@@ -162,44 +162,44 @@ def test_debug_order(mock_module):
         }
     }
 
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_b1, p_b1) == 0, "Comparing the same modules should always yield the same relative position"
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_b1, p_b2) == -1, "Same phase: sort by name for reproducibility"
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_b1, p_i) == 1, "Phase ordering: \"build\" should be sorted after \"install\""
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_b1, p_t) == 1, "Phase ordering: \"build\" should be sorted after \"test\""
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_b1, p_u) == -1, "Phase ordering: \"build\" should be sorted before \"update\""
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_b1, p_x) == -1, "Phase ordering: \"build\" should be sorted before unsupported phases"
-
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_b2, p_b1) == 1, "Same phase: sort by name for reproducibility"
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_b2, p_b2) == 0, "Comparing the same modules should always yield the same relative position"
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_b2, p_i) == 1, "Phase ordering: \"build\" should be sorted after \"install\""
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_b2, p_t) == 1, "Phase ordering: \"build\" should be sorted after \"test\""
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_b2, p_u) == -1, "Phase ordering: \"build\" should be sorted before \"update\""
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_b2, p_x) == -1, "Phase ordering: \"build\" should be sorted before unsupported phases"
-
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_i, p_b1) == -1, "Phase ordering: \"install\" should be sorted before \"build\""
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_i, p_b2) == -1, "Phase ordering: \"install\" should be sorted before \"build\""
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_i, p_i) == 0, "Comparing the same modules should always yield the same relative position"
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_i, p_t) == -1, "Phase ordering: \"install\" should be sorted before \"test\""
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_i, p_u) == -1, "Phase ordering: \"install\" should be sorted before \"update\""
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_i, p_x) == -1, "Phase ordering: \"install\" should be sorted before unsupported phases"
-
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_t, p_b1) == -1, "Phase ordering: \"test\" should be sorted before \"build\""
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_t, p_b2) == -1, "Phase ordering: \"test\" should be sorted before \"build\""
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_t, p_i) == 1, "Phase ordering: \"test\" should be sorted after \"install\""
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_t, p_t) == 0, "Comparing the same modules should always yield the same relative position"
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_t, p_u) == -1, "Phase ordering: \"test\" should be sorted before \"update\""
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_t, p_x) == -1, "Phase ordering: \"test\" should be sorted before unsupported phases"
-
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_u, p_b1) == 1, "Phase ordering: \"update\" should be sorted after \"build\""
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_u, p_b2) == 1, "Phase ordering: \"update\" should be sorted after \"build\""
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_u, p_i) == 1, "Phase ordering: \"update\" should be sorted after \"install\""
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_u, p_t) == 1, "Phase ordering: \"update\" should be sorted after \"test\""
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_u, p_u) == 0, "Comparing the same modules should always yield the same relative position"
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_u, p_x) == -1, "Phase ordering: \"update\" should be sorted before unsupported phases"
-
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_x, p_b1) == 1, "Phase ordering: unknown phases should be sorted after \"build\""
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_x, p_b2) == 1, "Phase ordering: unknown phases should be sorted after \"build\""
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_x, p_i) == 1, "Phase ordering: unknown phases should be sorted after \"install\""
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_x, p_t) == 1, "Phase ordering: unknown phases should be sorted after \"test\""
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_x, p_u) == 1, "Phase ordering: unknown phases should be sorted after \"update\""
-    assert DebugOrderHints._make_comparison_func(graph2, extra_debug_info2)(p_x, p_x) == 0, "Comparing the same modules should always yield the same relative position"
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_b1, p_b1) == 0, "Comparing the same modules should always yield the same relative position"
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_b1, p_b2) == -1, "Same phase: sort by name for reproducibility"
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_b1, p_i) == 1, "Phase ordering: \"build\" should be sorted after \"install\""
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_b1, p_t) == 1, "Phase ordering: \"build\" should be sorted after \"test\""
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_b1, p_u) == -1, "Phase ordering: \"build\" should be sorted before \"update\""
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_b1, p_x) == -1, "Phase ordering: \"build\" should be sorted before unsupported phases"
+
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_b2, p_b1) == 1, "Same phase: sort by name for reproducibility"
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_b2, p_b2) == 0, "Comparing the same modules should always yield the same relative position"
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_b2, p_i) == 1, "Phase ordering: \"build\" should be sorted after \"install\""
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_b2, p_t) == 1, "Phase ordering: \"build\" should be sorted after \"test\""
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_b2, p_u) == -1, "Phase ordering: \"build\" should be sorted before \"update\""
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_b2, p_x) == -1, "Phase ordering: \"build\" should be sorted before unsupported phases"
+
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_i, p_b1) == -1, "Phase ordering: \"install\" should be sorted before \"build\""
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_i, p_b2) == -1, "Phase ordering: \"install\" should be sorted before \"build\""
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_i, p_i) == 0, "Comparing the same modules should always yield the same relative position"
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_i, p_t) == -1, "Phase ordering: \"install\" should be sorted before \"test\""
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_i, p_u) == -1, "Phase ordering: \"install\" should be sorted before \"update\""
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_i, p_x) == -1, "Phase ordering: \"install\" should be sorted before unsupported phases"
+
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_t, p_b1) == -1, "Phase ordering: \"test\" should be sorted before \"build\""
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_t, p_b2) == -1, "Phase ordering: \"test\" should be sorted before \"build\""
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_t, p_i) == 1, "Phase ordering: \"test\" should be sorted after \"install\""
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_t, p_t) == 0, "Comparing the same modules should always yield the same relative position"
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_t, p_u) == -1, "Phase ordering: \"test\" should be sorted before \"update\""
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_t, p_x) == -1, "Phase ordering: \"test\" should be sorted before unsupported phases"
+
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_u, p_b1) == 1, "Phase ordering: \"update\" should be sorted after \"build\""
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_u, p_b2) == 1, "Phase ordering: \"update\" should be sorted after \"build\""
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_u, p_i) == 1, "Phase ordering: \"update\" should be sorted after \"install\""
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_u, p_t) == 1, "Phase ordering: \"update\" should be sorted after \"test\""
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_u, p_u) == 0, "Comparing the same modules should always yield the same relative position"
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_u, p_x) == -1, "Phase ordering: \"update\" should be sorted before unsupported phases"
+
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_x, p_b1) == 1, "Phase ordering: unknown phases should be sorted after \"build\""
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_x, p_b2) == 1, "Phase ordering: unknown phases should be sorted after \"build\""
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_x, p_i) == 1, "Phase ordering: unknown phases should be sorted after \"install\""
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_x, p_t) == 1, "Phase ordering: unknown phases should be sorted after \"test\""
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_x, p_u) == 1, "Phase ordering: unknown phases should be sorted after \"update\""
+    assert DebugOrderHints(graph2, extra_debug_info2)._compare_debug_order(p_x, p_x) == 0, "Comparing the same modules should always yield the same relative position"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.