Fix leaky spack.binary_distribution.binary_index in tests (#26609)

* Fix issues with leaky binary index across tests

* More rigorous binary_index reset as now other tests are failing :(
This commit is contained in:
Harmen Stoppels 2021-10-08 19:41:47 +02:00 committed by GitHub
parent 32b35e1a78
commit 7d89a95028
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 7 deletions

View File

@ -118,7 +118,8 @@ def test_specs_staging(config):
def test_ci_generate_with_env(tmpdir, mutable_mock_env_path,
install_mockery, mock_packages, project_dir_env):
install_mockery, mock_packages, project_dir_env,
mock_binary_index):
"""Make sure we can get a .gitlab-ci.yml from an environment file
which has the gitlab-ci, cdash, and mirrors sections."""
project_dir_env(tmpdir.strpath)
@ -343,7 +344,8 @@ def test_ci_generate_bootstrap_artifacts_buildcache(tmpdir,
def test_ci_generate_with_env_missing_section(tmpdir, mutable_mock_env_path,
install_mockery,
mock_packages, project_dir_env):
mock_packages, project_dir_env,
mock_binary_index):
"""Make sure we get a reasonable message if we omit gitlab-ci section"""
project_dir_env(tmpdir.strpath)
filename = str(tmpdir.join('spack.yaml'))
@ -368,7 +370,8 @@ def test_ci_generate_with_env_missing_section(tmpdir, mutable_mock_env_path,
def test_ci_generate_with_cdash_token(tmpdir, mutable_mock_env_path,
install_mockery,
mock_packages, project_dir_env):
mock_packages, project_dir_env,
mock_binary_index):
"""Make sure we it doesn't break if we configure cdash"""
project_dir_env(tmpdir.strpath)
filename = str(tmpdir.join('spack.yaml'))
@ -424,7 +427,7 @@ def test_ci_generate_with_cdash_token(tmpdir, mutable_mock_env_path,
def test_ci_generate_with_custom_scripts(tmpdir, mutable_mock_env_path,
install_mockery,
mock_packages, monkeypatch,
project_dir_env):
project_dir_env, mock_binary_index):
"""Test use of user-provided scripts"""
project_dir_env(tmpdir.strpath)
filename = str(tmpdir.join('spack.yaml'))
@ -676,7 +679,8 @@ def test_ci_generate_with_external_pkg(tmpdir, mutable_mock_env_path,
def test_ci_rebuild(tmpdir, mutable_mock_env_path,
install_mockery, mock_packages, monkeypatch,
mock_gnupghome, mock_fetch, project_dir_env):
mock_gnupghome, mock_fetch, project_dir_env,
mock_binary_index):
project_dir_env(tmpdir.strpath)
working_dir = tmpdir.join('working_dir')
@ -834,7 +838,7 @@ def mystrip(s):
def test_ci_nothing_to_rebuild(tmpdir, mutable_mock_env_path,
install_mockery, mock_packages, monkeypatch,
mock_fetch, project_dir_env):
mock_fetch, project_dir_env, mock_binary_index):
project_dir_env(tmpdir.strpath)
working_dir = tmpdir.join('working_dir')
@ -1461,7 +1465,8 @@ def fake_get_mirrors_for_spec(spec=None, full_hash_match=False,
def test_ci_subcommands_without_mirror(tmpdir, mutable_mock_env_path,
mock_packages,
install_mockery, project_dir_env):
install_mockery, project_dir_env,
mock_binary_index):
"""Make sure we catch if there is not a mirror and report an error"""
project_dir_env(tmpdir.strpath)
filename = str(tmpdir.join('spack.yaml'))

View File

@ -22,6 +22,7 @@
import archspec.cpu.microarchitecture
import archspec.cpu.schema
import llnl.util.lang
from llnl.util.filesystem import mkdirp, remove_linked_tree, working_dir
import spack.binary_distribution
@ -1524,3 +1525,10 @@ def mock_test_stage(mutable_config, tmpdir):
mutable_config.set('config:test_stage', tmp_stage)
yield tmp_stage
@pytest.fixture(autouse=True)
def brand_new_binary_cache():
yield
spack.binary_distribution.binary_index = llnl.util.lang.Singleton(
spack.binary_distribution._binary_index)