Skip to content
Snippets Groups Projects
Commit 0564eb6d authored by Ashwin Kumar Karnad's avatar Ashwin Kumar Karnad
Browse files

Merge branch 'split-installation-tests' into 'force-checking-of-error-code'

split one test into three

See merge request mpsd-cs/mpsd-software-environments!17
parents 38fa0d2c e6514ae5
No related branches found
No related tags found
3 merge requests!19Move linux-debian11 into main,!17split one test into three,!9force `subprocess.run` to check return code is 0
Pipeline #368582 passed
...@@ -77,6 +77,7 @@ style: ...@@ -77,6 +77,7 @@ style:
- *prepare_style - *prepare_style
- black --version - black --version
- ruff --version - ruff --version
- pydocstyle --version
- ruff . - ruff .
- black --check --diff . - black --check --diff .
- pydocstyle mpsd-software-environment.py - pydocstyle mpsd-software-environment.py
......
...@@ -54,10 +54,10 @@ class os_chdir: ...@@ -54,10 +54,10 @@ class os_chdir:
def run(*args, counter=[0], **kwargs): def run(*args, counter=[0], **kwargs):
""" """
Call subprocess.run and print logging data. Run a subprocess and log the call.
Conveniene function to call `subprocess.run(*args, **kwargs)` Convenience function to call `subprocess.run` and provide some metadata
and provide some metadata about the call. about the call.
Parameters Parameters
---------- ----------
......
...@@ -147,20 +147,19 @@ def test_setup_log_cmd(tmp_path): ...@@ -147,20 +147,19 @@ def test_setup_log_cmd(tmp_path):
assert "Spack environments branch: dev-23a " in last_line assert "Spack environments branch: dev-23a " in last_line
def test_install_environment(tmp_path): def test_install_environment_wrong_toolchain(tmp_path):
"""Test the installation of a toolchain. """Test exception is raised for non-existing toolchain."""
# Expect an Exception when wrong toolchains are provided
This is a long test, its handy to test this with print statements printed to
stdout, use:
pytest -s
Expect an Exception when wrong toolchains are provided
"""
with pytest.raises(Exception): with pytest.raises(Exception):
mod.install_environment( mod.install_environment(
mpsd_release="dev-23a", mpsd_release="dev-23a",
toolchains=["wrong-toolchain"], toolchains=["wrong-toolchain"],
script_dir=(tmp_path), script_dir=(tmp_path),
) )
def test_install_environment_wrong_mpsd_release(tmp_path):
"""Test exception is raised for non-existing mpsd release."""
# Expect an Exception when wrong mpsd_release is provided (part of # Expect an Exception when wrong mpsd_release is provided (part of
# prepare_environment) # prepare_environment)
with pytest.raises(Exception): with pytest.raises(Exception):
...@@ -169,11 +168,18 @@ def test_install_environment(tmp_path): ...@@ -169,11 +168,18 @@ def test_install_environment(tmp_path):
toolchains=["foss2021a-mpi"], toolchains=["foss2021a-mpi"],
script_dir=(tmp_path), script_dir=(tmp_path),
) )
# prepare a test of global generic with only zlib to test the installation
# prepare dev-23a release
# script_dir = tmp_path / "test_global_generic" def test_install_environment_zlib():
# for actaual installation avoid tmp_path as the lenght of the path is too long """Test installation of toolchain."""
# and spack complains # Prepare a test installation of global generic
# with only zlib to test the installation
# This is a long test,
# its handy to test this with print statements printed to
# stdout, use:
# pytest -s
# for this installation avoid tmp_path as
# the length of the path becomes too long and spack complains
script_dir = Path("/tmp/test_global_generic") script_dir = Path("/tmp/test_global_generic")
if script_dir.exists(): if script_dir.exists():
shutil.rmtree(script_dir) shutil.rmtree(script_dir)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment