diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index af91fa7d11c489ed3e42ba0f8c73fdd411e3f284..1ad39094f161660f238a7ecd312166adb88001b2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -77,6 +77,7 @@ style: - *prepare_style - black --version - ruff --version + - pydocstyle --version - ruff . - black --check --diff . - pydocstyle mpsd-software-environment.py diff --git a/mpsd-software-environment.py b/mpsd-software-environment.py index a88b5bd5651d81fae9e466ed875e71bbb8f9b7fe..59a831b65c3f46b0eb1935bb1e690dc46da633a4 100755 --- a/mpsd-software-environment.py +++ b/mpsd-software-environment.py @@ -54,10 +54,10 @@ class os_chdir: 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)` - and provide some metadata about the call. + Convenience function to call `subprocess.run` and provide some metadata + about the call. Parameters ---------- diff --git a/tests.py b/tests.py index d2bf60c98c721bdc0f73fe5e81db5cddece835fa..319e13cde23d794f5e422a60d1c1edbaca362960 100644 --- a/tests.py +++ b/tests.py @@ -147,20 +147,19 @@ def test_setup_log_cmd(tmp_path): assert "Spack environments branch: dev-23a " in last_line -def test_install_environment(tmp_path): - """Test the installation of a toolchain. - - 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 - """ +def test_install_environment_wrong_toolchain(tmp_path): + """Test exception is raised for non-existing toolchain.""" + # Expect an Exception when wrong toolchains are provided with pytest.raises(Exception): mod.install_environment( mpsd_release="dev-23a", toolchains=["wrong-toolchain"], 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 # prepare_environment) with pytest.raises(Exception): @@ -169,11 +168,18 @@ def test_install_environment(tmp_path): toolchains=["foss2021a-mpi"], 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" - # for actaual installation avoid tmp_path as the lenght of the path is too long - # and spack complains + + +def test_install_environment_zlib(): + """Test installation of toolchain.""" + # 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") if script_dir.exists(): shutil.rmtree(script_dir)