summaryrefslogtreecommitdiff
path: root/lib/spack/spack/test/conftest.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/spack/spack/test/conftest.py')
-rw-r--r--lib/spack/spack/test/conftest.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/spack/spack/test/conftest.py b/lib/spack/spack/test/conftest.py
index 938dd402b7..186e8a8c27 100644
--- a/lib/spack/spack/test/conftest.py
+++ b/lib/spack/spack/test/conftest.py
@@ -656,6 +656,36 @@ def mock_store(tmpdir_factory, mock_repo_path, mock_configuration,
@pytest.fixture(scope='function')
+def mutable_mock_store(tmpdir_factory, mock_repo_path, mock_configuration,
+ _store_dir_and_cache):
+ """Creates a read-only mock database with some packages installed note
+ that the ref count for dyninst here will be 3, as it's recycled
+ across each install.
+
+ This does not actually activate the store for use by Spack -- see the
+ ``database`` fixture for that.
+
+ """
+ store_path, store_cache = _store_dir_and_cache
+ store = spack.store.Store(str(store_path))
+
+ # If the cache does not exist populate the store and create it
+ if not os.path.exists(str(store_cache.join('.spack-db'))):
+ with use_configuration(mock_configuration):
+ with use_store(store):
+ with use_repo(mock_repo_path):
+ _populate(store.db)
+ store_path.copy(store_cache, mode=True, stat=True)
+
+ # Make the DB filesystem read-only to ensure we can't modify entries
+ store_path.join('.spack-db').chmod(mode=0o555, rec=1)
+
+ yield store
+
+ store_path.join('.spack-db').chmod(mode=0o755, rec=1)
+
+
+@pytest.fixture(scope='function')
def database(mock_store, mock_packages, config, monkeypatch):
"""This activates the mock store, packages, AND config."""
monkeypatch.setattr(spack.store, 'store', mock_store)