summaryrefslogtreecommitdiff
path: root/lib/spack/spack/test/cmd/fetch.py
blob: 19c5d33585ead5603632824b75f364fd41a1173b (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
# 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

import spack.environment as ev
from spack.main import SpackCommand, SpackCommandError

# everything here uses the mock_env_path
pytestmark = pytest.mark.usefixtures("mutable_mock_env_path", "config", "mutable_mock_repo")


@pytest.mark.disable_clean_stage_check
def test_fetch_in_env(tmpdir, mock_archive, mock_stage, mock_fetch, install_mockery):
    SpackCommand("env")("create", "test")
    with ev.read("test"):
        SpackCommand("add")("python")
        with pytest.raises(SpackCommandError):
            SpackCommand("fetch")()
        SpackCommand("concretize")()
        SpackCommand("fetch")()


@pytest.mark.disable_clean_stage_check
def test_fetch_single_spec(tmpdir, mock_archive, mock_stage, mock_fetch, install_mockery):
    SpackCommand("fetch")("mpileaks")


@pytest.mark.disable_clean_stage_check
def test_fetch_multiple_specs(tmpdir, mock_archive, mock_stage, mock_fetch, install_mockery):
    SpackCommand("fetch")("mpileaks", "gcc@3.0", "python")


def test_fetch_no_argument():
    with pytest.raises(SpackCommandError):
        SpackCommand("fetch")()