summaryrefslogtreecommitdiff
path: root/lib/spack/spack/test/cmd/graph.py
blob: 079b1a53e2adc52eab3a5b0f78ce7d8bc67aac09 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Copyright 2013-2023 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 pytest

from spack.main import SpackCommand, SpackCommandError

graph = SpackCommand("graph")


@pytest.mark.db
@pytest.mark.usefixtures("mock_packages", "database")
def test_graph_ascii():
    """Tests spack graph --ascii"""
    graph("--ascii", "dt-diamond")


@pytest.mark.db
@pytest.mark.usefixtures("mock_packages", "database")
def test_graph_dot():
    """Tests spack graph --dot"""
    graph("--dot", "dt-diamond")


@pytest.mark.db
@pytest.mark.usefixtures("mock_packages", "database")
def test_graph_static():
    """Tests spack graph --static"""
    graph("--static", "dt-diamond")


@pytest.mark.db
@pytest.mark.usefixtures("mock_packages", "database")
def test_graph_installed():
    """Tests spack graph --installed"""

    graph("--installed")

    with pytest.raises(SpackCommandError):
        graph("--installed", "dt-diamond")


@pytest.mark.db
@pytest.mark.usefixtures("mock_packages", "database")
def test_graph_deptype():
    """Tests spack graph --deptype"""
    graph("--deptype", "all", "dt-diamond")


def test_graph_no_specs():
    """Tests spack graph with no arguments"""

    with pytest.raises(SpackCommandError):
        graph()