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

add test for remove environment

parent 1fbc5d7d
Branches
No related tags found
1 merge request!57Try remove cmd
Pipeline #371721 failed
......@@ -15,6 +15,7 @@ import time
from pathlib import Path
from typing import List, Tuple, Union
import re
import shutil
# If 'rich' is available ("pip install rich" or "apt-get install python3-rich"),
# then use coloured output, otherwise proceed as before
......@@ -984,9 +985,20 @@ def remove_environment(release, package_sets, target_dir):
msg = (
f"Removing release {release} with package_sets {package_sets} from {target_dir}"
)
logging.info(msg)
raise NotImplementedError(msg)
logging.warning(msg)
if toolchains == "NONE":
logging.warning(
"Please specify toolchains to remove, or 'ALL' to remove all toolchains"
)
sys.exit(1)
if "ALL" in toolchains:
# we need to remove the entire release folder
logging.info(
f"Removing release {mpsd_release} from {root_dir}"
"do you want to continue? [y/n]"
)
if not force or input().lower() == "y":
shutil.rmtree(root_dir / mpsd_release)
def start_new_environment(release, from_release, target_dir):
"""Start new MPSD software environment version."""
......
......@@ -464,6 +464,8 @@ def create_fake_environment(tmp_path, mpsd_release, expected_toolchain_map=None)
toolchain_lua_file.touch()
return expected_toolchain_map
def test_environment_status(tmp_path):
"""Test that the environment status is correct."""
toolchain_map = mod.environment_status("fake-release", tmp_path)
......@@ -477,6 +479,28 @@ def test_environment_status(tmp_path):
assert set(toolchain_map[microarch]) == set(expected_toolchain_map[microarch])
def test_remove_environment(tmp_path):
"""Test that the remove_environment works as expected."""
mpsd_release = "dev-23a"
# create a fake environment
create_fake_environment(tmp_path, mpsd_release)
# check that the environment status is correct
toolchain_map = mod.environment_status(mpsd_release, tmp_path)
assert toolchain_map is not None
# test removal without arguments (should sys.exit(1))
create_fake_environment(tmp_path, mpsd_release)
with pytest.raises(SystemExit):
mod.remove_environment(mpsd_release, tmp_path, force=True)
# test removal of the complete environment
mod.remove_environment(mpsd_release, tmp_path, ["ALL"])
toolchain_map = mod.environment_status(mpsd_release, tmp_path)
assert toolchain_map is None
# test removal of a single toolchain
def test_interface(tmp_path):
"""Test other things (not implemented yet)."""
pass
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment