summaryrefslogtreecommitdiff
path: root/lib/spack/spack/test/cmd/mark.py
blob: ff8283aa9f6b5bd64d42a1fbbf721f51162cf2c3 (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
62
63
64
65
66
67
68
# Copyright 2013-2021 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

import spack.store
from spack.main import SpackCommand, SpackCommandError

gc = SpackCommand('gc')
mark = SpackCommand('mark')
install = SpackCommand('install')
uninstall = SpackCommand('uninstall')


@pytest.mark.db
def test_mark_mode_required(mutable_database):
    with pytest.raises(SystemExit):
        mark('-a')


@pytest.mark.db
def test_mark_spec_required(mutable_database):
    with pytest.raises(SpackCommandError):
        mark('-i')


@pytest.mark.db
def test_mark_all_explicit(mutable_database):
    mark('-e', '-a')
    gc('-y')
    all_specs = spack.store.layout.all_specs()
    assert len(all_specs) == 15


@pytest.mark.db
def test_mark_all_implicit(mutable_database):
    mark('-i', '-a')
    gc('-y')
    all_specs = spack.store.layout.all_specs()
    assert len(all_specs) == 0


@pytest.mark.db
def test_mark_one_explicit(mutable_database):
    mark('-e', 'libelf')
    uninstall('-y', '-a', 'mpileaks')
    gc('-y')
    all_specs = spack.store.layout.all_specs()
    assert len(all_specs) == 3


@pytest.mark.db
def test_mark_one_implicit(mutable_database):
    mark('-i', 'externaltest')
    gc('-y')
    all_specs = spack.store.layout.all_specs()
    assert len(all_specs) == 14


@pytest.mark.db
def test_mark_all_implicit_then_explicit(mutable_database):
    mark('-i', '-a')
    mark('-e', '-a')
    gc('-y')
    all_specs = spack.store.layout.all_specs()
    assert len(all_specs) == 15