summaryrefslogtreecommitdiff
path: root/lib/spack/spack/test/cmd/graph.py
blob: 06900cb0aca8c3865913c9a1d669bcf89b34f92e (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
57
58
59
60
61
# 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 sys

import pytest

from spack.main import SpackCommand, SpackCommandError

graph = SpackCommand('graph')

pytestmark = pytest.mark.skipif(sys.platform == "win32",
                                reason="does not run on windows")


@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()