bugfix: use deterministic edge order for spack graph (#30681)

Previously we sorted by hash values for `spack graph`, but changing hashes can make the
test brittle and the node order seem nondeterministic to users.

- [x] Sort nodes in `spack graph` by the default edge order, which takes into account
      parent and child names as well as dependency types.
- [x] Update ASCII test output for new order.
This commit is contained in:
Todd Gamblin 2022-05-16 02:36:41 -07:00 committed by GitHub
parent 8b34cabb16
commit 0fdc3bf420
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View file

@ -493,9 +493,11 @@ def write(self, spec, color=None, out=None):
# Replace node with its dependencies
self._frontier.pop(i)
deps = node.dependencies(deptype=self.deptype)
if deps:
deps = sorted((d.dag_hash() for d in deps), reverse=True)
edges = sorted(
node.edges_to_dependencies(deptype=self.deptype), reverse=True
)
if edges:
deps = [e.spec.dag_hash() for e in edges]
self._connect_deps(i, deps, "new-deps") # anywhere.
elif self._frontier:

View file

@ -104,7 +104,7 @@ def test_ascii_graph_mpileaks(config, mock_packages, monkeypatch):
/
o dyninst
|\
o | libdwarf
| o libdwarf
|/
o libelf
'''