From 4ac0a2309d927aaefe58234a69feb454eebc7948 Mon Sep 17 00:00:00 2001 From: adrianciu <adrian.ciu@codemart.ro> Date: Wed, 5 Feb 2025 21:32:38 +0200 Subject: [PATCH] esd-spack-installation: added clean up after each test --- README.md | 1 + esd/tests/spack_from_scratch_test.py | 32 ++++++++++++++-------------- esd/tests/spack_install_test.py | 10 ++++----- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 62e00c68..86ab9c2f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ # ~~Yashchiki~~Koutakia For now, this repository provides helpers for the EBRAINS container image build flow. +The lowest spack version which should be used with this library is v0.22.0 diff --git a/esd/tests/spack_from_scratch_test.py b/esd/tests/spack_from_scratch_test.py index cca0d2e9..3cdbc327 100644 --- a/esd/tests/spack_from_scratch_test.py +++ b/esd/tests/spack_from_scratch_test.py @@ -12,24 +12,24 @@ def test_spack_repo_exists_1(): assert spack_manager.spack_repo_exists('ebrains-spack-builds') == False -def test_spack_repo_exists_2(): - install_dir = Path('./install').resolve() +def test_spack_repo_exists_2(tmp_path): + install_dir = tmp_path env = SpackModel('ebrains-spack-builds', install_dir) spack_manager = SpackManagerScratch(env=env) with pytest.raises(NoSpackEnvironmentException): spack_manager.spack_repo_exists(env.env_name) -# def test_spack_repo_exists_3(): -# install_dir = Path('./install').resolve() -# env = SpackModel('ebrains-spack-builds', install_dir) -# spack_manager = SpackManagerScratch(env=env) -# spack_manager.setup_spack_env() -# assert spack_manager.spack_repo_exists(env.env_name) == False +def test_spack_repo_exists_3(tmp_path): + install_dir = tmp_path + env = SpackModel('ebrains-spack-builds', install_dir) + spack_manager = SpackManagerScratch(env=env) + spack_manager.setup_spack_env() + assert spack_manager.spack_repo_exists(env.env_name) == False -def test_spack_from_scratch_setup_1(): - install_dir = Path('./install').resolve() +def test_spack_from_scratch_setup_1(tmp_path): + install_dir = tmp_path env = SpackModel('ebrains-spack-builds', install_dir, 'https://gitlab.ebrains.eu/ri/tech-hub/platform/esd/ebrains-spack-builds.git', ) spack_manager = SpackManagerScratch(env=env, repos=[env], system_name='ebrainslab') @@ -37,8 +37,8 @@ def test_spack_from_scratch_setup_1(): assert spack_manager.spack_repo_exists(env.env_name) == True -def test_spack_from_scratch_setup_2(): - install_dir = Path('./install').resolve() +def test_spack_from_scratch_setup_2(tmp_path): + install_dir = tmp_path env = SpackModel('ebrains-spack-builds', install_dir, 'https://gitlab.ebrains.eu/ri/tech-hub/platform/esd/ebrains-spack-builds.git', ) repo = env @@ -47,8 +47,8 @@ def test_spack_from_scratch_setup_2(): assert spack_manager.spack_repo_exists(env.env_name) == True -def test_spack_from_scratch_setup_3(): - install_dir = Path('./install').resolve() +def test_spack_from_scratch_setup_3(tmp_path): + install_dir = tmp_path env = SpackModel('new_env1', install_dir) repo = env spack_manager = SpackManagerScratch(env=env, repos=[repo, repo], system_name='ebrainslab') @@ -56,8 +56,8 @@ def test_spack_from_scratch_setup_3(): spack_manager.setup_spack_env() -def test_spack_from_scratch_setup_4(): - install_dir = Path('./install').resolve() +def test_spack_from_scratch_setup_4(tmp_path ): + install_dir = tmp_path env = SpackModel('new_env2', install_dir) spack_manager = SpackManagerScratch(env=env) spack_manager.setup_spack_env() diff --git a/esd/tests/spack_install_test.py b/esd/tests/spack_install_test.py index 34f68323..50e94044 100644 --- a/esd/tests/spack_install_test.py +++ b/esd/tests/spack_install_test.py @@ -4,18 +4,18 @@ from esd.spack_manager.factory.SpackManagerBuildCache import SpackManagerBuildCa from esd.spack_manager.factory.SpackManagerScratch import SpackManagerScratch +SPACK_VERSION = "0.22.0" + # we need this test to run first so that spack is installed only once @pytest.mark.run(order=1) def test_spack_install_scratch(): spack_manager = SpackManagerScratch() - spack_manager.install_spack(spack_version="v0.21.1") + spack_manager.install_spack(spack_version=f'v{SPACK_VERSION}') installed_spack_version = spack_manager.get_spack_installed_version() - required_version = "0.21.1" - assert required_version == installed_spack_version + assert SPACK_VERSION == installed_spack_version def test_spack_install_buildcache(): spack_manager = SpackManagerBuildCache() installed_spack_version = spack_manager.get_spack_installed_version() - required_version = "0.21.1" - assert required_version == installed_spack_version + assert SPACK_VERSION == installed_spack_version -- GitLab