tests: rename builtin_mock to "mock_packages" for clarity.

- rename `builtin_mock` and `refresh_builtin_mock` to the more clear
  `mock_packages` and `mutable_mock_packages`
This commit is contained in:
Todd Gamblin 2018-04-28 22:48:26 -07:00 committed by scheibelp
parent d1903f3bf3
commit 2a09b627c9
33 changed files with 117 additions and 121 deletions

View File

@ -30,7 +30,7 @@
from spack.spec import Spec from spack.spec import Spec
def test_cmake_std_args(config, builtin_mock): def test_cmake_std_args(config, mock_packages):
# Call the function on a CMakePackage instance # Call the function on a CMakePackage instance
s = Spec('cmake-client') s = Spec('cmake-client')
s.concretize() s.concretize()
@ -44,7 +44,7 @@ def test_cmake_std_args(config, builtin_mock):
assert get_std_cmake_args(pkg) assert get_std_cmake_args(pkg)
@pytest.mark.usefixtures('config', 'builtin_mock') @pytest.mark.usefixtures('config', 'mock_packages')
class TestAutotoolsPackage(object): class TestAutotoolsPackage(object):
def test_with_or_without(self): def test_with_or_without(self):

View File

@ -38,7 +38,7 @@
blame = SpackCommand('blame') blame = SpackCommand('blame')
def test_blame_by_modtime(builtin_mock): def test_blame_by_modtime(mock_packages):
"""Sanity check the blame command to make sure it works.""" """Sanity check the blame command to make sure it works."""
out = blame('--time', 'mpich') out = blame('--time', 'mpich')
assert 'LAST_COMMIT' in out assert 'LAST_COMMIT' in out
@ -46,7 +46,7 @@ def test_blame_by_modtime(builtin_mock):
assert 'EMAIL' in out assert 'EMAIL' in out
def test_blame_by_percent(builtin_mock): def test_blame_by_percent(mock_packages):
"""Sanity check the blame command to make sure it works.""" """Sanity check the blame command to make sure it works."""
out = blame('--percent', 'mpich') out = blame('--percent', 'mpich')
assert 'LAST_COMMIT' in out assert 'LAST_COMMIT' in out
@ -54,7 +54,7 @@ def test_blame_by_percent(builtin_mock):
assert 'EMAIL' in out assert 'EMAIL' in out
def test_blame_file(builtin_mock): def test_blame_file(mock_packages):
"""Sanity check the blame command to make sure it works.""" """Sanity check the blame command to make sure it works."""
with working_dir(spack.paths.prefix): with working_dir(spack.paths.prefix):
out = blame('bin/spack') out = blame('bin/spack')
@ -63,7 +63,7 @@ def test_blame_file(builtin_mock):
assert 'EMAIL' in out assert 'EMAIL' in out
def test_blame_by_git(builtin_mock, capfd): def test_blame_by_git(mock_packages, capfd):
"""Sanity check the blame command to make sure it works.""" """Sanity check the blame command to make sure it works."""
with capfd.disabled(): with capfd.disabled():
out = blame('--git', 'mpich') out = blame('--git', 'mpich')

View File

@ -50,7 +50,7 @@ def __call__(self, *args, **kwargs):
@pytest.mark.usefixtures( @pytest.mark.usefixtures(
'builtin_mock', 'config', 'mock_calls_for_clean' 'mock_packages', 'config', 'mock_calls_for_clean'
) )
@pytest.mark.parametrize('command_line,counters', [ @pytest.mark.parametrize('command_line,counters', [
('mpileaks', [1, 0, 0, 0]), ('mpileaks', [1, 0, 0, 0]),

View File

@ -37,14 +37,14 @@
mpi_deps = ['fake'] mpi_deps = ['fake']
def test_immediate_dependencies(builtin_mock): def test_immediate_dependencies(mock_packages):
out = dependencies('mpileaks') out = dependencies('mpileaks')
actual = set(re.split(r'\s+', out.strip())) actual = set(re.split(r'\s+', out.strip()))
expected = set(['callpath'] + mpis) expected = set(['callpath'] + mpis)
assert expected == actual assert expected == actual
def test_transitive_dependencies(builtin_mock): def test_transitive_dependencies(mock_packages):
out = dependencies('--transitive', 'mpileaks') out = dependencies('--transitive', 'mpileaks')
actual = set(re.split(r'\s+', out.strip())) actual = set(re.split(r'\s+', out.strip()))
expected = set( expected = set(
@ -53,7 +53,7 @@ def test_transitive_dependencies(builtin_mock):
@pytest.mark.db @pytest.mark.db
def test_immediate_installed_dependencies(builtin_mock, database): def test_immediate_installed_dependencies(mock_packages, database):
with color_when(False): with color_when(False):
out = dependencies('--installed', 'mpileaks^mpich') out = dependencies('--installed', 'mpileaks^mpich')
@ -67,7 +67,7 @@ def test_immediate_installed_dependencies(builtin_mock, database):
@pytest.mark.db @pytest.mark.db
def test_transitive_installed_dependencies(builtin_mock, database): def test_transitive_installed_dependencies(mock_packages, database):
with color_when(False): with color_when(False):
out = dependencies('--installed', '--transitive', 'mpileaks^zmpi') out = dependencies('--installed', '--transitive', 'mpileaks^zmpi')

View File

@ -34,14 +34,14 @@
dependents = SpackCommand('dependents') dependents = SpackCommand('dependents')
def test_immediate_dependents(builtin_mock): def test_immediate_dependents(mock_packages):
out = dependents('libelf') out = dependents('libelf')
actual = set(re.split(r'\s+', out.strip())) actual = set(re.split(r'\s+', out.strip()))
assert actual == set(['dyninst', 'libdwarf', assert actual == set(['dyninst', 'libdwarf',
'patch-a-dependency', 'patch-several-dependencies']) 'patch-a-dependency', 'patch-several-dependencies'])
def test_transitive_dependents(builtin_mock): def test_transitive_dependents(mock_packages):
out = dependents('--transitive', 'libelf') out = dependents('--transitive', 'libelf')
actual = set(re.split(r'\s+', out.strip())) actual = set(re.split(r'\s+', out.strip()))
assert actual == set( assert actual == set(
@ -51,7 +51,7 @@ def test_transitive_dependents(builtin_mock):
@pytest.mark.db @pytest.mark.db
def test_immediate_installed_dependents(builtin_mock, database): def test_immediate_installed_dependents(mock_packages, database):
with color_when(False): with color_when(False):
out = dependents('--installed', 'libelf') out = dependents('--installed', 'libelf')
@ -68,7 +68,7 @@ def test_immediate_installed_dependents(builtin_mock, database):
@pytest.mark.db @pytest.mark.db
def test_transitive_installed_dependents(builtin_mock, database): def test_transitive_installed_dependents(mock_packages, database):
with color_when(False): with color_when(False):
out = dependents('--installed', '--transitive', 'fake') out = dependents('--installed', '--transitive', 'fake')

View File

@ -31,35 +31,35 @@
@pytest.mark.db @pytest.mark.db
@pytest.mark.usefixtures('builtin_mock', 'database') @pytest.mark.usefixtures('mock_packages', 'database')
def test_graph_ascii(): def test_graph_ascii():
"""Tests spack graph --ascii""" """Tests spack graph --ascii"""
graph('--ascii', 'dt-diamond') graph('--ascii', 'dt-diamond')
@pytest.mark.db @pytest.mark.db
@pytest.mark.usefixtures('builtin_mock', 'database') @pytest.mark.usefixtures('mock_packages', 'database')
def test_graph_dot(): def test_graph_dot():
"""Tests spack graph --dot""" """Tests spack graph --dot"""
graph('--dot', 'dt-diamond') graph('--dot', 'dt-diamond')
@pytest.mark.db @pytest.mark.db
@pytest.mark.usefixtures('builtin_mock', 'database') @pytest.mark.usefixtures('mock_packages', 'database')
def test_graph_normalize(): def test_graph_normalize():
"""Tests spack graph --normalize""" """Tests spack graph --normalize"""
graph('--normalize', 'dt-diamond') graph('--normalize', 'dt-diamond')
@pytest.mark.db @pytest.mark.db
@pytest.mark.usefixtures('builtin_mock', 'database') @pytest.mark.usefixtures('mock_packages', 'database')
def test_graph_static(): def test_graph_static():
"""Tests spack graph --static""" """Tests spack graph --static"""
graph('--static', 'dt-diamond') graph('--static', 'dt-diamond')
@pytest.mark.db @pytest.mark.db
@pytest.mark.usefixtures('builtin_mock', 'database') @pytest.mark.usefixtures('mock_packages', 'database')
def test_graph_installed(): def test_graph_installed():
"""Tests spack graph --installed""" """Tests spack graph --installed"""
@ -70,7 +70,7 @@ def test_graph_installed():
@pytest.mark.db @pytest.mark.db
@pytest.mark.usefixtures('builtin_mock', 'database') @pytest.mark.usefixtures('mock_packages', 'database')
def test_graph_deptype(): def test_graph_deptype():
"""Tests spack graph --deptype""" """Tests spack graph --deptype"""
graph('--deptype', 'all', 'dt-diamond') graph('--deptype', 'all', 'dt-diamond')

View File

@ -59,7 +59,7 @@ def noop(*args, **kwargs):
def test_install_package_and_dependency( def test_install_package_and_dependency(
tmpdir, builtin_mock, mock_archive, mock_fetch, config, tmpdir, mock_packages, mock_archive, mock_fetch, config,
install_mockery): install_mockery):
with tmpdir.as_cwd(): with tmpdir.as_cwd():
@ -76,7 +76,7 @@ def test_install_package_and_dependency(
@pytest.mark.disable_clean_stage_check @pytest.mark.disable_clean_stage_check
def test_install_runtests_notests(monkeypatch, builtin_mock, install_mockery): def test_install_runtests_notests(monkeypatch, mock_packages, install_mockery):
def check(pkg): def check(pkg):
assert not pkg.run_tests assert not pkg.run_tests
monkeypatch.setattr(spack.package.PackageBase, 'unit_test_check', check) monkeypatch.setattr(spack.package.PackageBase, 'unit_test_check', check)
@ -84,7 +84,7 @@ def check(pkg):
@pytest.mark.disable_clean_stage_check @pytest.mark.disable_clean_stage_check
def test_install_runtests_root(monkeypatch, builtin_mock, install_mockery): def test_install_runtests_root(monkeypatch, mock_packages, install_mockery):
def check(pkg): def check(pkg):
assert pkg.run_tests == (pkg.name == 'dttop') assert pkg.run_tests == (pkg.name == 'dttop')
@ -93,7 +93,7 @@ def check(pkg):
@pytest.mark.disable_clean_stage_check @pytest.mark.disable_clean_stage_check
def test_install_runtests_all(monkeypatch, builtin_mock, install_mockery): def test_install_runtests_all(monkeypatch, mock_packages, install_mockery):
def check(pkg): def check(pkg):
assert pkg.run_tests assert pkg.run_tests
@ -103,7 +103,7 @@ def check(pkg):
def test_install_package_already_installed( def test_install_package_already_installed(
tmpdir, builtin_mock, mock_archive, mock_fetch, config, tmpdir, mock_packages, mock_archive, mock_fetch, config,
install_mockery): install_mockery):
with tmpdir.as_cwd(): with tmpdir.as_cwd():
@ -153,7 +153,7 @@ def test_package_output(tmpdir, capsys, install_mockery, mock_fetch):
@pytest.mark.disable_clean_stage_check @pytest.mark.disable_clean_stage_check
def test_install_output_on_build_error(builtin_mock, mock_archive, mock_fetch, def test_install_output_on_build_error(mock_packages, mock_archive, mock_fetch,
config, install_mockery, capfd): config, install_mockery, capfd):
# capfd interferes with Spack's capturing # capfd interferes with Spack's capturing
with capfd.disabled(): with capfd.disabled():
@ -165,7 +165,7 @@ def test_install_output_on_build_error(builtin_mock, mock_archive, mock_fetch,
@pytest.mark.disable_clean_stage_check @pytest.mark.disable_clean_stage_check
def test_install_output_on_python_error(builtin_mock, mock_archive, mock_fetch, def test_install_output_on_python_error(mock_packages, mock_archive, mock_fetch,
config, install_mockery): config, install_mockery):
out = install('failing-build', fail_on_error=False) out = install('failing-build', fail_on_error=False)
assert isinstance(install.error, spack.build_environment.ChildError) assert isinstance(install.error, spack.build_environment.ChildError)
@ -175,7 +175,7 @@ def test_install_output_on_python_error(builtin_mock, mock_archive, mock_fetch,
@pytest.mark.disable_clean_stage_check @pytest.mark.disable_clean_stage_check
def test_install_with_source( def test_install_with_source(
builtin_mock, mock_archive, mock_fetch, config, install_mockery): mock_packages, mock_archive, mock_fetch, config, install_mockery):
"""Verify that source has been copied into place.""" """Verify that source has been copied into place."""
install('--source', '--keep-stage', 'trivial-install-test-package') install('--source', '--keep-stage', 'trivial-install-test-package')
spec = Spec('trivial-install-test-package').concretized() spec = Spec('trivial-install-test-package').concretized()
@ -186,7 +186,7 @@ def test_install_with_source(
@pytest.mark.disable_clean_stage_check @pytest.mark.disable_clean_stage_check
def test_show_log_on_error(builtin_mock, mock_archive, mock_fetch, def test_show_log_on_error(mock_packages, mock_archive, mock_fetch,
config, install_mockery, capfd): config, install_mockery, capfd):
"""Make sure --show-log-on-error works.""" """Make sure --show-log-on-error works."""
with capfd.disabled(): with capfd.disabled():
@ -202,7 +202,7 @@ def test_show_log_on_error(builtin_mock, mock_archive, mock_fetch,
def test_install_overwrite( def test_install_overwrite(
builtin_mock, mock_archive, mock_fetch, config, install_mockery mock_packages, mock_archive, mock_fetch, config, install_mockery
): ):
# It's not possible to overwrite something that is not yet installed # It's not possible to overwrite something that is not yet installed
with pytest.raises(AssertionError): with pytest.raises(AssertionError):
@ -237,7 +237,7 @@ def test_install_overwrite(
@pytest.mark.usefixtures( @pytest.mark.usefixtures(
'builtin_mock', 'mock_archive', 'mock_fetch', 'config', 'install_mockery', 'mock_packages', 'mock_archive', 'mock_fetch', 'config', 'install_mockery',
) )
def test_install_conflicts(conflict_spec): def test_install_conflicts(conflict_spec):
# Make sure that spec with conflicts raises a SpackError # Make sure that spec with conflicts raises a SpackError
@ -246,7 +246,7 @@ def test_install_conflicts(conflict_spec):
@pytest.mark.usefixtures( @pytest.mark.usefixtures(
'builtin_mock', 'mock_archive', 'mock_fetch', 'config', 'install_mockery', 'mock_packages', 'mock_archive', 'mock_fetch', 'config', 'install_mockery',
) )
def test_install_invalid_spec(invalid_spec): def test_install_invalid_spec(invalid_spec):
# Make sure that invalid specs raise a SpackError # Make sure that invalid specs raise a SpackError
@ -284,7 +284,7 @@ def test_install_from_file(spec, concretize, error_code, tmpdir):
@pytest.mark.disable_clean_stage_check @pytest.mark.disable_clean_stage_check
@pytest.mark.usefixtures( @pytest.mark.usefixtures(
'builtin_mock', 'mock_archive', 'mock_fetch', 'config', 'install_mockery' 'mock_packages', 'mock_archive', 'mock_fetch', 'config', 'install_mockery'
) )
@pytest.mark.parametrize('exc_typename,msg', [ @pytest.mark.parametrize('exc_typename,msg', [
('RuntimeError', 'something weird happened'), ('RuntimeError', 'something weird happened'),
@ -317,7 +317,7 @@ def test_junit_output_with_failures(tmpdir, exc_typename, msg):
@pytest.mark.disable_clean_stage_check @pytest.mark.disable_clean_stage_check
@pytest.mark.usefixtures( @pytest.mark.usefixtures(
'builtin_mock', 'mock_archive', 'mock_fetch', 'config', 'install_mockery' 'mock_packages', 'mock_archive', 'mock_fetch', 'config', 'install_mockery'
) )
@pytest.mark.parametrize('exc_typename,msg', [ @pytest.mark.parametrize('exc_typename,msg', [
('RuntimeError', 'something weird happened'), ('RuntimeError', 'something weird happened'),
@ -379,10 +379,8 @@ def test_install_mix_cli_and_files(clispecs, filespecs, tmpdir):
assert install.returncode == 0 assert install.returncode == 0
@pytest.mark.usefixtures( def test_extra_files_are_archived(mock_packages, mock_archive, mock_fetch,
'builtin_mock', 'mock_archive', 'mock_fetch', 'config', 'install_mockery' config, install_mockery):
)
def test_extra_files_are_archived():
s = Spec('archive-files') s = Spec('archive-files')
s.concretize() s.concretize()

View File

@ -63,7 +63,7 @@ def mock_compiler_dir(tmpdir):
return str(tmpdir) return str(tmpdir)
@pytest.mark.usefixtures('config', 'builtin_mock') @pytest.mark.usefixtures('config', 'mock_packages')
class TestCompilerCommand(object): class TestCompilerCommand(object):
def test_compiler_remove(self): def test_compiler_remove(self):

View File

@ -34,7 +34,7 @@
@pytest.mark.parametrize('cmd', ['hardlink', 'symlink', 'hard', 'add']) @pytest.mark.parametrize('cmd', ['hardlink', 'symlink', 'hard', 'add'])
def test_view_link_type( def test_view_link_type(
tmpdir, builtin_mock, mock_archive, mock_fetch, config, tmpdir, mock_packages, mock_archive, mock_fetch, config,
install_mockery, cmd): install_mockery, cmd):
install('libdwarf') install('libdwarf')
viewpath = str(tmpdir.mkdir('view_{0}'.format(cmd))) viewpath = str(tmpdir.mkdir('view_{0}'.format(cmd)))
@ -45,7 +45,7 @@ def test_view_link_type(
def test_view_external( def test_view_external(
tmpdir, builtin_mock, mock_archive, mock_fetch, config, tmpdir, mock_packages, mock_archive, mock_fetch, config,
install_mockery): install_mockery):
install('externaltool') install('externaltool')
viewpath = str(tmpdir.mkdir('view')) viewpath = str(tmpdir.mkdir('view'))
@ -54,7 +54,7 @@ def test_view_external(
def test_view_extension( def test_view_extension(
tmpdir, builtin_mock, mock_archive, mock_fetch, config, tmpdir, mock_packages, mock_archive, mock_fetch, config,
install_mockery): install_mockery):
install('extendee') install('extendee')
install('extension1@1.0') install('extension1@1.0')
@ -80,7 +80,7 @@ def test_view_extension(
def test_view_extension_remove( def test_view_extension_remove(
tmpdir, builtin_mock, mock_archive, mock_fetch, config, tmpdir, mock_packages, mock_archive, mock_fetch, config,
install_mockery): install_mockery):
install('extendee') install('extendee')
install('extension1@1.0') install('extension1@1.0')
@ -99,7 +99,7 @@ def test_view_extension_remove(
def test_view_extension_conflict( def test_view_extension_conflict(
tmpdir, builtin_mock, mock_archive, mock_fetch, config, tmpdir, mock_packages, mock_archive, mock_fetch, config,
install_mockery): install_mockery):
install('extendee') install('extendee')
install('extension1@1.0') install('extension1@1.0')
@ -111,7 +111,7 @@ def test_view_extension_conflict(
def test_view_extension_conflict_ignored( def test_view_extension_conflict_ignored(
tmpdir, builtin_mock, mock_archive, mock_fetch, config, tmpdir, mock_packages, mock_archive, mock_fetch, config,
install_mockery): install_mockery):
install('extendee') install('extendee')
install('extension1@1.0') install('extension1@1.0')
@ -124,7 +124,7 @@ def test_view_extension_conflict_ignored(
def test_view_extension_global_activation( def test_view_extension_global_activation(
tmpdir, builtin_mock, mock_archive, mock_fetch, config, tmpdir, mock_packages, mock_archive, mock_fetch, config,
install_mockery): install_mockery):
install('extendee') install('extendee')
install('extension1@1.0') install('extension1@1.0')
@ -153,7 +153,7 @@ def test_view_extension_global_activation(
def test_view_extendee_with_global_activations( def test_view_extendee_with_global_activations(
tmpdir, builtin_mock, mock_archive, mock_fetch, config, tmpdir, mock_packages, mock_archive, mock_fetch, config,
install_mockery): install_mockery):
install('extendee') install('extendee')
install('extension1@1.0') install('extension1@1.0')

View File

@ -97,7 +97,7 @@ def spec(request):
return request.param return request.param
@pytest.mark.usefixtures('config', 'builtin_mock') @pytest.mark.usefixtures('config', 'mock_packages')
class TestConcretize(object): class TestConcretize(object):
def test_concretize(self, spec): def test_concretize(self, spec):
check_concretize(spec) check_concretize(spec)
@ -255,7 +255,7 @@ def test_concretize_two_virtuals(self):
Spec('hypre').concretize() Spec('hypre').concretize()
def test_concretize_two_virtuals_with_one_bound( def test_concretize_two_virtuals_with_one_bound(
self, refresh_builtin_mock self, mutable_mock_packages
): ):
"""Test a package with multiple virtual dependencies and one preset.""" """Test a package with multiple virtual dependencies and one preset."""
Spec('hypre ^openblas').concretize() Spec('hypre ^openblas').concretize()

View File

@ -61,7 +61,7 @@ def assert_variant_values(spec, **variants):
assert concrete.variants[variant].value == value assert concrete.variants[variant].value == value
@pytest.mark.usefixtures('concretize_scope', 'builtin_mock') @pytest.mark.usefixtures('concretize_scope', 'mock_packages')
class TestConcretizePreferences(object): class TestConcretizePreferences(object):
def test_preferred_variants(self): def test_preferred_variants(self):
"""Test preferred variants are applied correctly """Test preferred variants are applied correctly
@ -77,7 +77,7 @@ def test_preferred_variants(self):
'mpileaks', debug=True, opt=True, shared=False, static=False 'mpileaks', debug=True, opt=True, shared=False, static=False
) )
def test_preferred_compilers(self, refresh_builtin_mock): def test_preferred_compilers(self, mutable_mock_packages):
"""Test preferred compilers are applied correctly """Test preferred compilers are applied correctly
""" """
update_packages('mpileaks', 'compiler', ['clang@3.3']) update_packages('mpileaks', 'compiler', ['clang@3.3'])

View File

@ -177,23 +177,21 @@ def repo_path():
@pytest.fixture(scope='module') @pytest.fixture(scope='module')
def builtin_mock(repo_path): def mock_packages(repo_path):
"""Uses the 'builtin.mock' repository instead of 'builtin'""" """Use the 'builtin.mock' repository instead of 'builtin'"""
mock_repo = copy.deepcopy(repo_path) mock_repo = copy.deepcopy(repo_path)
spack.repo.swap(mock_repo) spack.repo.swap(mock_repo)
BuiltinMock = collections.namedtuple('BuiltinMock', ['real', 'mock']) yield
# Confusing, but we swapped above
yield BuiltinMock(real=mock_repo, mock=spack.repo)
spack.repo.swap(mock_repo) spack.repo.swap(mock_repo)
@pytest.fixture() @pytest.fixture(scope='function')
def refresh_builtin_mock(builtin_mock, repo_path): def mutable_mock_packages(mock_packages, repo_path):
"""Refreshes the state of spack.repo""" """Function-scoped mock packages, for tests that need to modify them."""
# Get back the real repository
mock_repo = copy.deepcopy(repo_path) mock_repo = copy.deepcopy(repo_path)
spack.repo.swap(mock_repo) spack.repo.swap(mock_repo)
return builtin_mock yield
spack.repo.swap(mock_repo)
@pytest.fixture(scope='session') @pytest.fixture(scope='session')
@ -262,7 +260,7 @@ def config(configuration_dir):
@pytest.fixture(scope='module') @pytest.fixture(scope='module')
def database(tmpdir_factory, builtin_mock, config): def database(tmpdir_factory, mock_packages, config):
"""Creates a mock database with some packages installed note that """Creates a mock database with some packages installed note that
the ref count for dyninst here will be 3, as it's recycled the ref count for dyninst here will be 3, as it's recycled
across each install. across each install.
@ -366,7 +364,7 @@ def refresh_db_on_exit(database):
@pytest.fixture() @pytest.fixture()
def install_mockery(tmpdir, config, builtin_mock): def install_mockery(tmpdir, config, mock_packages):
"""Hooks a fake install directory, DB, and stage directory into Spack.""" """Hooks a fake install directory, DB, and stage directory into Spack."""
layout = spack.store.layout layout = spack.store.layout
extensions = spack.store.extensions extensions = spack.store.extensions

View File

@ -96,7 +96,7 @@ def test_yaml_directory_layout_parameters(
def test_read_and_write_spec( def test_read_and_write_spec(
layout_and_dir, config, builtin_mock layout_and_dir, config, mock_packages
): ):
"""This goes through each package in spack and creates a directory for """This goes through each package in spack and creates a directory for
it. It then ensures that the spec for the directory's it. It then ensures that the spec for the directory's
@ -174,7 +174,7 @@ def test_read_and_write_spec(
def test_handle_unknown_package( def test_handle_unknown_package(
layout_and_dir, config, builtin_mock layout_and_dir, config, mock_packages
): ):
"""This test ensures that spack can at least do *some* """This test ensures that spack can at least do *some*
operations with packages that are installed but that it operations with packages that are installed but that it
@ -227,7 +227,7 @@ def test_handle_unknown_package(
spack.repo.swap(mock_db) spack.repo.swap(mock_db)
def test_find(layout_and_dir, config, builtin_mock): def test_find(layout_and_dir, config, mock_packages):
"""Test that finding specs within an install layout works.""" """Test that finding specs within an install layout works."""
layout, _ = layout_and_dir layout, _ = layout_and_dir
packages = list(spack.repo.all_packages())[:max_packages] packages = list(spack.repo.all_packages())[:max_packages]

View File

@ -74,7 +74,7 @@ def test_fetch(type_of_test,
secure, secure,
mock_git_repository, mock_git_repository,
config, config,
refresh_builtin_mock, mutable_mock_packages,
git_version): git_version):
"""Tries to: """Tries to:

View File

@ -28,7 +28,7 @@
from spack.graph import AsciiGraph, topological_sort, graph_dot from spack.graph import AsciiGraph, topological_sort, graph_dot
def test_topo_sort(builtin_mock): def test_topo_sort(mock_packages):
"""Test topo sort gives correct order.""" """Test topo sort gives correct order."""
s = Spec('mpileaks').normalized() s = Spec('mpileaks').normalized()
@ -51,7 +51,7 @@ def test_topo_sort(builtin_mock):
assert topo.index('libdwarf') < topo.index('libelf') assert topo.index('libdwarf') < topo.index('libelf')
def test_static_graph_mpileaks(builtin_mock): def test_static_graph_mpileaks(mock_packages):
"""Test a static spack graph for a simple package.""" """Test a static spack graph for a simple package."""
s = Spec('mpileaks').normalized() s = Spec('mpileaks').normalized()
@ -75,7 +75,7 @@ def test_static_graph_mpileaks(builtin_mock):
assert ' "dyninst" -> "libelf"\n' in dot assert ' "dyninst" -> "libelf"\n' in dot
def test_dynamic_dot_graph_mpileaks(builtin_mock): def test_dynamic_dot_graph_mpileaks(mock_packages):
"""Test dynamically graphing the mpileaks package.""" """Test dynamically graphing the mpileaks package."""
s = Spec('mpileaks').normalized() s = Spec('mpileaks').normalized()
@ -111,7 +111,7 @@ def test_dynamic_dot_graph_mpileaks(builtin_mock):
assert ' "%s" -> "%s"\n' % (dyninst_hash, libelf_hash) in dot assert ' "%s" -> "%s"\n' % (dyninst_hash, libelf_hash) in dot
def test_ascii_graph_mpileaks(builtin_mock): def test_ascii_graph_mpileaks(mock_packages):
"""Test dynamically graphing the mpileaks package.""" """Test dynamically graphing the mpileaks package."""
s = Spec('mpileaks').normalized() s = Spec('mpileaks').normalized()

View File

@ -46,7 +46,7 @@ def test_fetch(
secure, secure,
mock_hg_repository, mock_hg_repository,
config, config,
refresh_builtin_mock mutable_mock_packages
): ):
"""Tries to: """Tries to:

View File

@ -132,7 +132,7 @@ def test_dont_add_patches_to_installed_package(install_mockery, mock_fetch):
def test_installed_dependency_request_conflicts( def test_installed_dependency_request_conflicts(
install_mockery, mock_fetch, refresh_builtin_mock): install_mockery, mock_fetch, mutable_mock_packages):
dependency = Spec('dependency-install') dependency = Spec('dependency-install')
dependency.concretize() dependency.concretize()
dependency.package.do_install() dependency.package.do_install()

View File

@ -112,7 +112,7 @@ def check_mirror():
assert all(l in exclude for l in dcmp.left_only) assert all(l in exclude for l in dcmp.left_only)
@pytest.mark.usefixtures('config', 'refresh_builtin_mock') @pytest.mark.usefixtures('config', 'mutable_mock_packages')
class TestMirror(object): class TestMirror(object):
def test_url_mirror(self, mock_archive): def test_url_mirror(self, mock_archive):
set_up_package('trivial-install-test-package', mock_archive, 'url') set_up_package('trivial-install-test-package', mock_archive, 'url')

View File

@ -30,7 +30,7 @@
writer_cls = spack.modules.dotkit.DotkitModulefileWriter writer_cls = spack.modules.dotkit.DotkitModulefileWriter
@pytest.mark.usefixtures('config', 'builtin_mock') @pytest.mark.usefixtures('config', 'mock_packages')
class TestDotkit(object): class TestDotkit(object):
def test_dotkit(self, modulefile_content, patch_configuration): def test_dotkit(self, modulefile_content, patch_configuration):

View File

@ -52,7 +52,7 @@ def provider(request):
return request.param return request.param
@pytest.mark.usefixtures('config', 'builtin_mock',) @pytest.mark.usefixtures('config', 'mock_packages',)
class TestLmod(object): class TestLmod(object):
def test_file_layout( def test_file_layout(

View File

@ -36,7 +36,7 @@
writer_cls = spack.modules.tcl.TclModulefileWriter writer_cls = spack.modules.tcl.TclModulefileWriter
@pytest.mark.usefixtures('config', 'builtin_mock') @pytest.mark.usefixtures('config', 'mock_packages')
class TestTcl(object): class TestTcl(object):
def test_simple_case(self, modulefile_content, patch_configuration): def test_simple_case(self, modulefile_content, patch_configuration):

View File

@ -28,13 +28,13 @@
from spack.multimethod import NoSuchMethodError from spack.multimethod import NoSuchMethodError
def test_no_version_match(builtin_mock): def test_no_version_match(mock_packages):
pkg = spack.repo.get('multimethod@2.0') pkg = spack.repo.get('multimethod@2.0')
with pytest.raises(NoSuchMethodError): with pytest.raises(NoSuchMethodError):
pkg.no_version_2() pkg.no_version_2()
def test_one_version_match(builtin_mock): def test_one_version_match(mock_packages):
pkg = spack.repo.get('multimethod@1.0') pkg = spack.repo.get('multimethod@1.0')
assert pkg.no_version_2() == 1 assert pkg.no_version_2() == 1
@ -45,7 +45,7 @@ def test_one_version_match(builtin_mock):
assert pkg.no_version_2() == 4 assert pkg.no_version_2() == 4
def test_version_overlap(builtin_mock): def test_version_overlap(mock_packages):
pkg = spack.repo.get('multimethod@2.0') pkg = spack.repo.get('multimethod@2.0')
assert pkg.version_overlap() == 1 assert pkg.version_overlap() == 1
@ -53,7 +53,7 @@ def test_version_overlap(builtin_mock):
assert pkg.version_overlap() == 2 assert pkg.version_overlap() == 2
def test_mpi_version(builtin_mock): def test_mpi_version(mock_packages):
pkg = spack.repo.get('multimethod^mpich@3.0.4') pkg = spack.repo.get('multimethod^mpich@3.0.4')
assert pkg.mpi_version() == 3 assert pkg.mpi_version() == 3
@ -64,7 +64,7 @@ def test_mpi_version(builtin_mock):
assert pkg.mpi_version() == 1 assert pkg.mpi_version() == 1
def test_undefined_mpi_version(builtin_mock): def test_undefined_mpi_version(mock_packages):
pkg = spack.repo.get('multimethod^mpich@0.4') pkg = spack.repo.get('multimethod^mpich@0.4')
assert pkg.mpi_version() == 1 assert pkg.mpi_version() == 1
@ -72,7 +72,7 @@ def test_undefined_mpi_version(builtin_mock):
assert pkg.mpi_version() == 1 assert pkg.mpi_version() == 1
def test_default_works(builtin_mock): def test_default_works(mock_packages):
pkg = spack.repo.get('multimethod%gcc') pkg = spack.repo.get('multimethod%gcc')
assert pkg.has_a_default() == 'gcc' assert pkg.has_a_default() == 'gcc'
@ -83,7 +83,7 @@ def test_default_works(builtin_mock):
assert pkg.has_a_default() == 'default' assert pkg.has_a_default() == 'default'
def test_target_match(builtin_mock): def test_target_match(mock_packages):
platform = spack.architecture.platform() platform = spack.architecture.platform()
targets = list(platform.targets.values()) targets = list(platform.targets.values())
for target in targets[:-1]: for target in targets[:-1]:
@ -98,7 +98,7 @@ def test_target_match(builtin_mock):
pkg.different_by_target() pkg.different_by_target()
def test_dependency_match(builtin_mock): def test_dependency_match(mock_packages):
pkg = spack.repo.get('multimethod^zmpi') pkg = spack.repo.get('multimethod^zmpi')
assert pkg.different_by_dep() == 'zmpi' assert pkg.different_by_dep() == 'zmpi'
@ -111,7 +111,7 @@ def test_dependency_match(builtin_mock):
assert pkg.different_by_dep() == 'mpich' assert pkg.different_by_dep() == 'mpich'
def test_virtual_dep_match(builtin_mock): def test_virtual_dep_match(mock_packages):
pkg = spack.repo.get('multimethod^mpich2') pkg = spack.repo.get('multimethod^mpich2')
assert pkg.different_by_virtual_dep() == 2 assert pkg.different_by_virtual_dep() == 2
@ -119,7 +119,7 @@ def test_virtual_dep_match(builtin_mock):
assert pkg.different_by_virtual_dep() == 1 assert pkg.different_by_virtual_dep() == 1
def test_multimethod_with_base_class(builtin_mock): def test_multimethod_with_base_class(mock_packages):
pkg = spack.repo.get('multimethod@3') pkg = spack.repo.get('multimethod@3')
assert pkg.base_method() == "subclass_method" assert pkg.base_method() == "subclass_method"

View File

@ -107,14 +107,14 @@ def spec_and_expected(request):
return spec, Spec.from_literal(d) return spec, Spec.from_literal(d)
def test_normalize(spec_and_expected, config, builtin_mock): def test_normalize(spec_and_expected, config, mock_packages):
spec, expected = spec_and_expected spec, expected = spec_and_expected
spec = Spec(spec) spec = Spec(spec)
spec.normalize() spec.normalize()
assert spec.eq_dag(expected, deptypes=False) assert spec.eq_dag(expected, deptypes=False)
def test_default_variant(config, builtin_mock): def test_default_variant(config, mock_packages):
spec = Spec('optional-dep-test-3') spec = Spec('optional-dep-test-3')
spec.concretize() spec.concretize()
assert 'a' in spec assert 'a' in spec

View File

@ -26,17 +26,17 @@
from spack.spec import Spec from spack.spec import Spec
def test_hash(tmpdir, builtin_mock, config): def test_hash(tmpdir, mock_packages, config):
package_hash("hash-test1@1.2") package_hash("hash-test1@1.2")
def test_different_variants(tmpdir, builtin_mock, config): def test_different_variants(tmpdir, mock_packages, config):
spec1 = Spec("hash-test1@1.2 +variantx") spec1 = Spec("hash-test1@1.2 +variantx")
spec2 = Spec("hash-test1@1.2 +varianty") spec2 = Spec("hash-test1@1.2 +varianty")
assert package_hash(spec1) == package_hash(spec2) assert package_hash(spec1) == package_hash(spec2)
def test_all_same_but_name(tmpdir, builtin_mock, config): def test_all_same_but_name(tmpdir, mock_packages, config):
spec1 = Spec("hash-test1@1.2") spec1 = Spec("hash-test1@1.2")
spec2 = Spec("hash-test2@1.2") spec2 = Spec("hash-test2@1.2")
compare_sans_name(True, spec1, spec2) compare_sans_name(True, spec1, spec2)
@ -46,7 +46,7 @@ def test_all_same_but_name(tmpdir, builtin_mock, config):
compare_sans_name(True, spec1, spec2) compare_sans_name(True, spec1, spec2)
def test_all_same_but_archive_hash(tmpdir, builtin_mock, config): def test_all_same_but_archive_hash(tmpdir, mock_packages, config):
""" """
Archive hash is not intended to be reflected in Package hash. Archive hash is not intended to be reflected in Package hash.
""" """
@ -55,19 +55,19 @@ def test_all_same_but_archive_hash(tmpdir, builtin_mock, config):
compare_sans_name(True, spec1, spec2) compare_sans_name(True, spec1, spec2)
def test_all_same_but_patch_contents(tmpdir, builtin_mock, config): def test_all_same_but_patch_contents(tmpdir, mock_packages, config):
spec1 = Spec("hash-test1@1.1") spec1 = Spec("hash-test1@1.1")
spec2 = Spec("hash-test2@1.1") spec2 = Spec("hash-test2@1.1")
compare_sans_name(True, spec1, spec2) compare_sans_name(True, spec1, spec2)
def test_all_same_but_patches_to_apply(tmpdir, builtin_mock, config): def test_all_same_but_patches_to_apply(tmpdir, mock_packages, config):
spec1 = Spec("hash-test1@1.4") spec1 = Spec("hash-test1@1.4")
spec2 = Spec("hash-test2@1.4") spec2 = Spec("hash-test2@1.4")
compare_sans_name(True, spec1, spec2) compare_sans_name(True, spec1, spec2)
def test_all_same_but_install(tmpdir, builtin_mock, config): def test_all_same_but_install(tmpdir, mock_packages, config):
spec1 = Spec("hash-test1@1.5") spec1 = Spec("hash-test1@1.5")
spec2 = Spec("hash-test2@1.5") spec2 = Spec("hash-test2@1.5")
compare_sans_name(False, spec1, spec2) compare_sans_name(False, spec1, spec2)

View File

@ -34,7 +34,7 @@
from spack.util.package_hash import package_content from spack.util.package_hash import package_content
@pytest.mark.usefixtures('config', 'builtin_mock') @pytest.mark.usefixtures('config', 'mock_packages')
class TestPackage(object): class TestPackage(object):
def test_load_package(self): def test_load_package(self):
spack.repo.get('mpich') spack.repo.get('mpich')

View File

@ -93,7 +93,7 @@ def test_url_patch(mock_stage, filename, sha256, archive_sha256):
assert filecmp.cmp('foo.txt', 'foo-expected.txt') assert filecmp.cmp('foo.txt', 'foo-expected.txt')
def test_patch_in_spec(builtin_mock, config): def test_patch_in_spec(mock_packages, config):
"""Test whether patches in a package appear in the spec.""" """Test whether patches in a package appear in the spec."""
spec = Spec('patch') spec = Spec('patch')
spec.concretize() spec.concretize()
@ -108,7 +108,7 @@ def test_patch_in_spec(builtin_mock, config):
spec.variants['patches'].value) spec.variants['patches'].value)
def test_patched_dependency(builtin_mock, config): def test_patched_dependency(mock_packages, config):
"""Test whether patched dependencies work.""" """Test whether patched dependencies work."""
spec = Spec('patch-a-dependency') spec = Spec('patch-a-dependency')
spec.concretize() spec.concretize()
@ -119,7 +119,7 @@ def test_patched_dependency(builtin_mock, config):
spec['libelf'].variants['patches'].value) spec['libelf'].variants['patches'].value)
def test_multiple_patched_dependencies(builtin_mock, config): def test_multiple_patched_dependencies(mock_packages, config):
"""Test whether multiple patched dependencies work.""" """Test whether multiple patched dependencies work."""
spec = Spec('patch-several-dependencies') spec = Spec('patch-several-dependencies')
spec.concretize() spec.concretize()
@ -138,7 +138,7 @@ def test_multiple_patched_dependencies(builtin_mock, config):
spec['fake'].variants['patches'].value) spec['fake'].variants['patches'].value)
def test_conditional_patched_dependencies(builtin_mock, config): def test_conditional_patched_dependencies(mock_packages, config):
"""Test whether conditional patched dependencies work.""" """Test whether conditional patched dependencies work."""
spec = Spec('patch-several-dependencies @1.0') spec = Spec('patch-several-dependencies @1.0')
spec.concretize() spec.concretize()
@ -166,7 +166,7 @@ def test_conditional_patched_dependencies(builtin_mock, config):
spec['fake'].variants['patches'].value) spec['fake'].variants['patches'].value)
def test_conditional_patched_deps_with_conditions(builtin_mock, config): def test_conditional_patched_deps_with_conditions(mock_packages, config):
"""Test whether conditional patched dependencies with conditions work.""" """Test whether conditional patched dependencies with conditions work."""
spec = Spec('patch-several-dependencies @1.0 ^libdwarf@20111030') spec = Spec('patch-several-dependencies @1.0 ^libdwarf@20111030')
spec.concretize() spec.concretize()

View File

@ -44,7 +44,7 @@
from spack.spec import Spec from spack.spec import Spec
def test_yaml_round_trip(builtin_mock): def test_yaml_round_trip(mock_packages):
p = ProviderIndex(spack.repo.all_package_names()) p = ProviderIndex(spack.repo.all_package_names())
ostream = StringIO() ostream = StringIO()
@ -56,7 +56,7 @@ def test_yaml_round_trip(builtin_mock):
assert p == q assert p == q
def test_providers_for_simple(builtin_mock): def test_providers_for_simple(mock_packages):
p = ProviderIndex(spack.repo.all_package_names()) p = ProviderIndex(spack.repo.all_package_names())
blas_providers = p.providers_for('blas') blas_providers = p.providers_for('blas')
@ -69,7 +69,7 @@ def test_providers_for_simple(builtin_mock):
assert Spec('openblas-with-lapack') in lapack_providers assert Spec('openblas-with-lapack') in lapack_providers
def test_mpi_providers(builtin_mock): def test_mpi_providers(mock_packages):
p = ProviderIndex(spack.repo.all_package_names()) p = ProviderIndex(spack.repo.all_package_names())
mpi_2_providers = p.providers_for('mpi@2') mpi_2_providers = p.providers_for('mpi@2')
@ -82,13 +82,13 @@ def test_mpi_providers(builtin_mock):
assert Spec('zmpi') in mpi_3_providers assert Spec('zmpi') in mpi_3_providers
def test_equal(builtin_mock): def test_equal(mock_packages):
p = ProviderIndex(spack.repo.all_package_names()) p = ProviderIndex(spack.repo.all_package_names())
q = ProviderIndex(spack.repo.all_package_names()) q = ProviderIndex(spack.repo.all_package_names())
assert p == q assert p == q
def test_copy(builtin_mock): def test_copy(mock_packages):
p = ProviderIndex(spack.repo.all_package_names()) p = ProviderIndex(spack.repo.all_package_names())
q = p.copy() q = p.copy()
assert p == q assert p == q

View File

@ -108,7 +108,7 @@ def test_test_deptype():
spack.repo = saved_repo spack.repo = saved_repo
@pytest.mark.usefixtures('refresh_builtin_mock') @pytest.mark.usefixtures('mutable_mock_packages')
class TestSpecDag(object): class TestSpecDag(object):
def test_conflicting_package_constraints(self, set_dependency): def test_conflicting_package_constraints(self, set_dependency):

View File

@ -101,7 +101,7 @@ def check_invalid_constraint(spec, constraint):
spec.constrain(constraint) spec.constrain(constraint)
@pytest.mark.usefixtures('config', 'builtin_mock') @pytest.mark.usefixtures('config', 'mock_packages')
class TestSpecSematics(object): class TestSpecSematics(object):
"""This tests satisfies(), constrain() and other semantic operations """This tests satisfies(), constrain() and other semantic operations
on specs. on specs.

View File

@ -46,13 +46,13 @@ def test_simple_spec():
check_yaml_round_trip(spec) check_yaml_round_trip(spec)
def test_normal_spec(builtin_mock): def test_normal_spec(mock_packages):
spec = Spec('mpileaks+debug~opt') spec = Spec('mpileaks+debug~opt')
spec.normalize() spec.normalize()
check_yaml_round_trip(spec) check_yaml_round_trip(spec)
def test_external_spec(config, builtin_mock): def test_external_spec(config, mock_packages):
spec = Spec('externaltool') spec = Spec('externaltool')
spec.concretize() spec.concretize()
check_yaml_round_trip(spec) check_yaml_round_trip(spec)
@ -62,13 +62,13 @@ def test_external_spec(config, builtin_mock):
check_yaml_round_trip(spec) check_yaml_round_trip(spec)
def test_ambiguous_version_spec(builtin_mock): def test_ambiguous_version_spec(mock_packages):
spec = Spec('mpileaks@1.0:5.0,6.1,7.3+debug~opt') spec = Spec('mpileaks@1.0:5.0,6.1,7.3+debug~opt')
spec.normalize() spec.normalize()
check_yaml_round_trip(spec) check_yaml_round_trip(spec)
def test_concrete_spec(config, builtin_mock): def test_concrete_spec(config, mock_packages):
spec = Spec('mpileaks+debug~opt') spec = Spec('mpileaks+debug~opt')
spec.concretize() spec.concretize()
check_yaml_round_trip(spec) check_yaml_round_trip(spec)
@ -80,7 +80,7 @@ def test_yaml_multivalue():
check_yaml_round_trip(spec) check_yaml_round_trip(spec)
def test_yaml_subdag(config, builtin_mock): def test_yaml_subdag(config, mock_packages):
spec = Spec('mpileaks^mpich+debug') spec = Spec('mpileaks^mpich+debug')
spec.concretize() spec.concretize()
yaml_spec = Spec.from_yaml(spec.to_yaml()) yaml_spec = Spec.from_yaml(spec.to_yaml())
@ -89,7 +89,7 @@ def test_yaml_subdag(config, builtin_mock):
assert spec[dep].eq_dag(yaml_spec[dep]) assert spec[dep].eq_dag(yaml_spec[dep])
def test_using_ordered_dict(builtin_mock): def test_using_ordered_dict(mock_packages):
""" Checks that dicts are ordered """ Checks that dicts are ordered
Necessary to make sure that dag_hash is stable across python Necessary to make sure that dag_hash is stable across python
@ -122,7 +122,7 @@ def descend_and_check(iterable, level=0):
def test_ordered_read_not_required_for_consistent_dag_hash( def test_ordered_read_not_required_for_consistent_dag_hash(
config, builtin_mock config, mock_packages
): ):
"""Make sure ordered serialization isn't required to preserve hashes. """Make sure ordered serialization isn't required to preserve hashes.

View File

@ -199,7 +199,7 @@ def __call__(self):
return _Mock() return _Mock()
@pytest.mark.usefixtures('builtin_mock') @pytest.mark.usefixtures('mock_packages')
class TestStage(object): class TestStage(object):
stage_name = 'spack-test-stage' stage_name = 'spack-test-stage'

View File

@ -46,7 +46,7 @@ def test_fetch(
secure, secure,
mock_svn_repository, mock_svn_repository,
config, config,
refresh_builtin_mock mutable_mock_packages
): ):
"""Tries to: """Tries to:

View File

@ -46,7 +46,7 @@ def test_fetch(
secure, secure,
checksum_type, checksum_type,
config, config,
refresh_builtin_mock mutable_mock_packages
): ):
"""Fetch an archive and make sure we can checksum it.""" """Fetch an archive and make sure we can checksum it."""
mock_archive.url mock_archive.url
@ -81,7 +81,7 @@ def test_fetch(
assert 'echo Building...' in contents assert 'echo Building...' in contents
def test_from_list_url(builtin_mock, config): def test_from_list_url(mock_packages, config):
pkg = spack.repo.get('url-list-test') pkg = spack.repo.get('url-list-test')
for ver_str in ['0.0.0', '1.0.0', '2.0.0', for ver_str in ['0.0.0', '1.0.0', '2.0.0',
'3.0', '4.5', '2.0.0b2', '3.0', '4.5', '2.0.0b2',