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

return toolchains after creating env and test them

parent b5e7c510
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"
......@@ -50,7 +50,7 @@ class os_chdir:
os.chdir(self.saved_dir)
def setup_log_cmd(shared_var, msg=None):
def setup_log_cmd(msg=None,*args, **kwargs):
# Create log directory if it doesn't exist
if not os.path.exists("logs"):
os.makedirs("logs")
......@@ -65,7 +65,18 @@ def setup_log_cmd(shared_var, msg=None):
f.write(msg + "\n")
else:
f.write("-" * 50 + "\n")
# Gather data to log
# call statement:
cmd_line = " ".join(sys.argv)
# script branch and commit hash
script_branch= subprocess.run(["git", "rev-parse", "--abbrev-ref", "HEAD"], stdout=subprocess.PIPE).stdout.decode().strip()
script_commit_hash = subprocess.run(["git", "rev-parse", "--short", "HEAD"], stdout=subprocess.PIPE ).stdout.decode().strip()
# spack-environments branch and commit hash from kwargs
spe_branch = kwargs.get("spe_branch", None)
spe_commit_hash = kwargs.get("spe_commit_hash", None)
# Write to log file
f.write(f"{datetime.datetime.now().isoformat()}, {cmd_line}\n")
f.write(
f"Software environment installer branch: {shared_var['script_branch']} (commit hash: {shared_var['script_commit_hash']})\n"
......@@ -112,8 +123,8 @@ def prepare_environment(mpsd_release, script_dir):
.strip()
)
available_toolchains = os.listdir("toolchains")
setup_log_cmd(shared_var)
return shared_var
setup_log_cmd(spe_branch=spe_branch, spe_commit_hash=spe_commit_hash)
return available_toolchains
def install_environment(
......
......@@ -35,7 +35,7 @@ def test_prepare_environment(tmp_path):
# check that the test directory does not exist
assert not script_dir.exists()
mod.prepare_environment(
result = mod.prepare_environment(
mpsd_release=mpsd_release_to_test, script_dir=str(script_dir)
)
# wait for 20 seconds for the git clone to finish
......@@ -55,6 +55,10 @@ def test_prepare_environment(tmp_path):
.split("\n")[0]
== f"* {mpsd_release_to_test}"
)
# check that result is a list and contains atleast ['global','foss2021a-mpi']
assert isinstance(result, list)
assert "global" in result
assert "foss2021a-mpi" in result
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