diff options
author | Daniel G Travieso <danielgtravieso@gmail.com> | 2021-10-08 03:50:05 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-07 23:50:05 -0700 |
commit | 10de12c7d0ac3d169dced5ea07898087cfd22b50 (patch) | |
tree | b429cfb93656726abf256c9b276acf7ff87346fc | |
parent | 449a5832c8d6561f1bc75defd3fcfe527d887b5c (diff) | |
download | spack-10de12c7d0ac3d169dced5ea07898087cfd22b50.tar.gz spack-10de12c7d0ac3d169dced5ea07898087cfd22b50.tar.bz2 spack-10de12c7d0ac3d169dced5ea07898087cfd22b50.tar.xz spack-10de12c7d0ac3d169dced5ea07898087cfd22b50.zip |
add hash field to spec on find --json and assert in test its there (#26443)
Co-authored-by: Daniel Travieso <daniel@dgtravieso.com>
-rw-r--r-- | lib/spack/spack/cmd/__init__.py | 14 | ||||
-rw-r--r-- | 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 |