From 10de12c7d0ac3d169dced5ea07898087cfd22b50 Mon Sep 17 00:00:00 2001 From: Daniel G Travieso Date: Fri, 8 Oct 2021 03:50:05 -0300 Subject: add hash field to spec on find --json and assert in test its there (#26443) Co-authored-by: Daniel Travieso --- lib/spack/spack/cmd/__init__.py | 14 ++++++++------ lib/spack/spack/test/cmd/find.py | 1 + 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 -- cgit v1.2.3-70-g09d2