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

test prepare_environment

parent fe0d2dd2
No related branches found
No related tags found
2 merge requests!19Move linux-debian11 into main,!1Resolve "First draft for user interface for top level install command"
......@@ -24,58 +24,36 @@ def test_os_chdir(tmp_path):
assert os.getcwd() == initial_cwd
def test_prepare_env(tmp_path):
def test_prepare_environment(tmp_path):
# simulate running ./install-software-environment.py --release dev-23a --target-directory /tmp/test_prepare_env
# prepare_env is run when cmd is not specified, we can test cmd='prepare' and cmd=None to check both cases
script_dir = tmp_path / "test_prepare_env"
spack_environments = "spack-environments"
mpsd_release_to_test = "dev-23a"
release_base_dir = script_dir / mpsd_release_to_test
# check that the test directory does not exist
assert not (tmp_path / "test_prepare_env").exists()
assert not script_dir.exists()
run = mod.builder(
release="dev-23a",
cmd="prepare",
target_dir=str(tmp_path / "test_prepare_env"),
skip_build_cache=False,
)
run.run()
mod.prepare_environment(mpsd_release=mpsd_release_to_test, script_dir=str(script_dir))
# wait for 20 seconds for the git clone to finish
# time.sleep(20)
# check if the directory now is created
assert (tmp_path / "test_prepare_env").exists()
assert release_base_dir.exists()
# check for spack-environments directory
assert os.listdir(str(tmp_path / "test_prepare_env")) == ["spack-environments"]
# check if the git branch is correctl checked out
assert spack_environments in os.listdir(str(release_base_dir))
# check if the git branch is correctly checked out
assert (
subprocess.run(
f"cd {str(tmp_path / 'test_prepare_env/spack-environments')} && git branch",
f"cd {str(release_base_dir/spack_environments)} && git branch",
shell=True,
capture_output=True,
)
.stdout.decode("utf-8")
.split("\n")[0]
== "* dev-23a"
== f"* {mpsd_release_to_test}"
)
# make sure running the command again raises ValueError
with pytest.raises(ValueError):
run = mod.builder(
release="dev-23a",
cmd=None,
target_dir=str(tmp_path / "test_prepare_env"),
skip_build_cache=False,
)
run.run()
# check that ValueError is not raised if skip_dir_check is True
run = mod.builder(
release="dev-23a",
cmd=None,
target_dir=str(tmp_path / "test_prepare_env"),
skip_build_cache=False,
)
run.skip_dir_check = True
run.run()
# clean up the temporary directory
shutil.rmtree(str(tmp_path / "test_prepare_env"))
def test_setup_log_cmd(tmp_path):
......
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