From 7d89a95028404a58b632023b81c6f92221bfc3b4 Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Fri, 8 Oct 2021 19:41:47 +0200 Subject: 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 :( --- lib/spack/spack/test/cmd/ci.py | 19 ++++++++++++------- lib/spack/spack/test/conftest.py | 8 ++++++++ 2 files changed, 20 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/test/cmd/ci.py b/lib/spack/spack/test/cmd/ci.py index 3feef4443f..36e7b3d81d 100644 --- a/lib/spack/spack/test/cmd/ci.py +++ b/lib/spack/spack/test/cmd/ci.py @@ -118,7 +118,8 @@ and then 'd', 'b', and 'a' to be put in the next three stages, respectively. 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 @@ spack: 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 @@ spack: 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 @@ spack: 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 @@ spack: 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 @@ spack: 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 @@ spack: 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')) diff --git a/lib/spack/spack/test/conftest.py b/lib/spack/spack/test/conftest.py index 2d52449fbe..17086dbdc0 100644 --- a/lib/spack/spack/test/conftest.py +++ b/lib/spack/spack/test/conftest.py @@ -22,6 +22,7 @@ import pytest 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) -- cgit v1.2.3-60-g2f50