summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <gamblin2@llnl.gov>2022-05-16 02:36:41 -0700
committerGitHub <noreply@github.com>2022-05-16 11:36:41 +0200
commit0fdc3bf4202d3c7e953a2dba74009460fb6761d1 (patch)
tree68c11e9ad8dcefc29b6666c0adb0285e351c1b8e /lib
parent8b34cabb16fcf80beb58c56cb133636713f09278 (diff)
downloadspack-0fdc3bf4202d3c7e953a2dba74009460fb6761d1.tar.gz
spack-0fdc3bf4202d3c7e953a2dba74009460fb6761d1.tar.bz2
spack-0fdc3bf4202d3c7e953a2dba74009460fb6761d1.tar.xz
spack-0fdc3bf4202d3c7e953a2dba74009460fb6761d1.zip
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/graph.py8
-rw-r--r--lib/spack/spack/test/graph.py2
2 files changed, 6 insertions, 4 deletions
diff --git a/lib/spack/spack/graph.py b/lib/spack/spack/graph.py
index 502e5534eb..d1e95c6f52 100644
--- a/lib/spack/spack/graph.py
+++ b/lib/spack/spack/graph.py
@@ -493,9 +493,11 @@ class AsciiGraph(object):
# 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:
diff --git a/lib/spack/spack/test/graph.py b/lib/spack/spack/test/graph.py
index 185f1375a2..f3a7db1ea0 100644
--- a/lib/spack/spack/test/graph.py
+++ b/lib/spack/spack/test/graph.py
@@ -104,7 +104,7 @@ o | mpich
/
o dyninst
|\
-o | libdwarf
+| o libdwarf
|/
o libelf
'''