summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/cmd/__init__.py14
-rw-r--r--lib/spack/spack/test/cmd/find.py1
2 files changed, 9 insertions, 6 deletions
diff --git a/lib/spack/spack/cmd/__init__.py b/lib/spack/spack/cmd/__init__.py
index 8e81f61c73..501a668b7c 100644
--- a/lib/spack/spack/cmd/__init__.py
+++ b/lib/spack/spack/cmd/__init__.py
@@ -259,17 +259,19 @@ def display_specs_as_json(specs, deps=False):
seen = set()
records = []
for spec in specs:
- if spec.dag_hash() in seen:
+ dag_hash = spec.dag_hash()
+ if dag_hash in seen:
continue
- seen.add(spec.dag_hash())
- records.append(spec.to_node_dict())
+ records.append(spec.node_dict_with_hashes())
+ seen.add(dag_hash)
if deps:
for dep in spec.traverse():
- if dep.dag_hash() in seen:
+ dep_dag_hash = dep.dag_hash()
+ if dep_dag_hash in seen:
continue
- seen.add(dep.dag_hash())
- records.append(dep.to_node_dict())
+ records.append(dep.node_dict_with_hashes())
+ seen.add(dep_dag_hash)
sjson.dump(records, sys.stdout)
diff --git a/lib/spack/spack/test/cmd/find.py b/lib/spack/spack/test/cmd/find.py
index ad20224677..e895a10169 100644
--- a/lib/spack/spack/test/cmd/find.py
+++ b/lib/spack/spack/test/cmd/find.py
@@ -128,6 +128,7 @@ def test_namespaces_shown_correctly(database):
def _check_json_output(spec_list):
assert len(spec_list) == 3
assert all(spec["name"] == "mpileaks" for spec in spec_list)
+ assert all(spec["hash"] for spec in spec_list)
deps = [spec["dependencies"] for spec in spec_list]
assert sum(["zmpi" in [node["name"] for d in deps for node in d]]) == 1