Source code for spack.test.cmd.tags

# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

import spack.main
import spack.repo
import spack.spec

tags = spack.main.SpackCommand("tags")

[docs]def test_tags_bad_options(): out = tags("-a", "tag1", fail_on_error=False) assert "option OR provide" in out
[docs]def test_tags_no_installed(install_mockery, mock_fetch): out = tags("-i") assert "No installed" in out
[docs]def test_tags_invalid_tag(mock_packages): out = tags("nosuchtag") assert "None" in out
[docs]def test_tags_all_mock_tags(mock_packages): out = tags() for tag in ["tag1", "tag2", "tag3"]: assert tag in out
[docs]def test_tags_all_mock_tag_packages(mock_packages): out = tags("-a") for pkg in ["mpich\n", "mpich2\n"]: assert pkg in out
[docs]def test_tags_no_tags(monkeypatch): class tag_path: tag_index = dict() monkeypatch.setattr(spack.repo, "path", tag_path) out = tags() assert "No tagged" in out
[docs]def test_tags_installed(install_mockery, mock_fetch): s = spack.spec.Spec("mpich").concretized() s.package.do_install() out = tags("-i") for tag in ["tag1", "tag2"]: assert tag in out out = tags("-i", "tag1") assert "mpich" in out out = tags("-i", "tag3") assert "No installed" in out