# 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 pytest
import spack.environment as ev
from spack.main import SpackCommand
# everything here uses the mock_env_path
pytestmark = pytest.mark.usefixtures(
'mutable_mock_env_path', 'config', 'mutable_mock_repo')
env = SpackCommand('env')
add = SpackCommand('add')
concretize = SpackCommand('concretize')
unification_strategies = [False, True, 'when_possible']
[docs]@pytest.mark.parametrize('unify', unification_strategies)
def test_concretize_all_test_dependencies(unify):
"""Check all test dependencies are concretized."""
env('create', 'test')
with ev.read('test') as e:
e.unify = unify
add('depb')
concretize('--test', 'all')
assert e.matching_spec('test-dependency')
[docs]@pytest.mark.parametrize('unify', unification_strategies)
def test_concretize_root_test_dependencies_not_recursive(unify):
"""Check that test dependencies are not concretized recursively."""
env('create', 'test')
with ev.read('test') as e:
e.unify = unify
add('depb')
concretize('--test', 'root')
assert e.matching_spec('test-dependency') is None
[docs]@pytest.mark.parametrize('unify', unification_strategies)
def test_concretize_root_test_dependencies_are_concretized(unify):
"""Check that root test dependencies are concretized."""
env('create', 'test')
with ev.read('test') as e:
e.unify = unify
add('a')
add('b')
concretize('--test', 'root')
assert e.matching_spec('test-dependency')