diff --git a/tests/test_mpsd_software.py b/tests/test_mpsd_software.py index a6b281b64a70911b13f693608e08c5ae7afc920a..2540608b1e479c3d309a1cbf5a2b9abdb179e67b 100644 --- a/tests/test_mpsd_software.py +++ b/tests/test_mpsd_software.py @@ -257,7 +257,7 @@ def test_install_environment_zlib(): with open( package_set_src_dir / "global_generic" / "global_packages.list", "w" ) as f: - f.write("zlib@1.2.13 \n") + f.write("zlib@1.2.13 \nzstd@1.5.2\n") # add zlib to whitelist of module creation file by replacing anaconda3%gcc@10.2.1 # with zlib@1.2.13 @@ -791,6 +791,49 @@ def test_remove_package_sets(tmp_path, simple_toolchain): ) +def test_remove_global_package_sets(): + """Test removal of global package_sets via spack.""" + root_dir = Path("/tmp/test_global_generic") + if not root_dir.exists(): + # we need the sample spack instance with global_generic + # this is already done in test_install_environment_zlib + # so we just need to call it + test_install_environment_zlib() + # check that zlib and zstd are installed + spack_dir = root_dir / "dev-23a" / mod.get_native_microarchitecture() / "spack" + source_spack = ( + f"export SPACK_DIR={spack_dir} &&" + f'. {spack_dir / "share" / "spack" / "setup-env.sh"}' + ) + # check that zlib is installed + # location commands exits with non zero if not installed thus + # breaking failing test + mod.run(f"{source_spack} && spack location -i zlib", shell=True, check=True) + # check that zstd is installed + mod.run(f"{source_spack} && spack location -i zstd", shell=True, check=True) + + # remove global_generic + mod.remove_environment( + mpsd_release="dev-23a", + root_dir=root_dir, + package_sets=["global_generic"], + force_remove=True, + ) + # check that zstd@1.5 is not installed + # we are here flipping the exit code to check that it is not installed + mod.run( + f"{source_spack} && (spack location -i zstd && exit 1 || exit 0 )", + shell=True, + check=True, + ) + # check that zlib is not installed + mod.run( + f"{source_spack} && (spack location -i zlib && exit 1 || exit 0 )", + shell=True, + check=True, + ) + + def test_interface(tmp_path): """Test other things (not implemented yet).""" pass