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

update tests to incorporate new cmd_log_file

parent e890b612
No related branches found
No related tags found
2 merge requests!37Update log names and variable names,!29Restructure log location
Pipeline #370215 failed
...@@ -164,13 +164,13 @@ def test_setup_log_cmd(tmp_path): ...@@ -164,13 +164,13 @@ def test_setup_log_cmd(tmp_path):
Check that logs/install-software-environment.log is updated when the module is run Check that logs/install-software-environment.log is updated when the module is run
""" """
log_file = "install.log" cmd_log_file = mod.config_vars['cmd_log_file']
script_dir = tmp_path / "test_prepare_env" script_dir = tmp_path / "test_prepare_env"
mpsd_release_to_test = "dev-23a" mpsd_release_to_test = "dev-23a"
release_base_dir = script_dir / mpsd_release_to_test release_base_dir = script_dir / mpsd_release_to_test
if os.path.exists(release_base_dir / log_file): if os.path.exists(release_base_dir / cmd_log_file):
initial_bytes = os.path.getsize(log_file) initial_bytes = os.path.getsize(cmd_log_file)
else: else:
initial_bytes = 0 initial_bytes = 0
...@@ -179,11 +179,11 @@ def test_setup_log_cmd(tmp_path): ...@@ -179,11 +179,11 @@ def test_setup_log_cmd(tmp_path):
mod.prepare_environment(mpsd_release=mpsd_release_to_test, script_dir=(script_dir)) mod.prepare_environment(mpsd_release=mpsd_release_to_test, script_dir=(script_dir))
# check that logs/install-software-environment.log is updated # check that logs/install-software-environment.log is updated
assert os.path.exists(release_base_dir / log_file) assert os.path.exists(release_base_dir / cmd_log_file)
assert os.path.getsize(release_base_dir / log_file) > initial_bytes assert os.path.getsize(release_base_dir / cmd_log_file) > initial_bytes
# Check that the log file has "Spack environments branch: dev-23a " in the last line # Check that the log file has "Spack environments branch: dev-23a " in the last line
with open(release_base_dir / log_file, "r") as f: with open(release_base_dir / cmd_log_file, "r") as f:
last_line = f.readlines()[-1] last_line = f.readlines()[-1]
assert "Spack environments branch: dev-23a " in last_line assert "Spack environments branch: dev-23a " in last_line
...@@ -227,6 +227,7 @@ def test_install_environment_zlib(): ...@@ -227,6 +227,7 @@ def test_install_environment_zlib():
script_dir.mkdir(exist_ok=True, parents=True) script_dir.mkdir(exist_ok=True, parents=True)
mpsd_release_to_test = "dev-23a" mpsd_release_to_test = "dev-23a"
toolchain_to_test = "global_generic" toolchain_to_test = "global_generic"
cmd_log_file = mod.config_vars['cmd_log_file']
mpsd_microarch = mod.get_native_microarchitecture() mpsd_microarch = mod.get_native_microarchitecture()
release_base_dir = script_dir / mpsd_release_to_test release_base_dir = script_dir / mpsd_release_to_test
create_mock_git_repository(target_directory=script_dir, create_directory=False) create_mock_git_repository(target_directory=script_dir, create_directory=False)
...@@ -301,11 +302,11 @@ def test_install_environment_zlib(): ...@@ -301,11 +302,11 @@ def test_install_environment_zlib():
os.path.basename(build_log) os.path.basename(build_log)
# assert that install log files exists # assert that install log files exists
assert os.path.exists(release_base_dir / "install.log") assert os.path.exists(release_base_dir / cmd_log_file)
# assert that the build log is written to the install log file # assert that the build log is written to the install log file
os.path.basename(build_log) os.path.basename(build_log)
with open(release_base_dir / "install.log", "r") as f: with open(release_base_dir / cmd_log_file, "r") as f:
lines = f.read() lines = f.read()
assert ( assert (
f"installing {toolchain_to_test} and logging at {str(build_log)}" in lines f"installing {toolchain_to_test} and logging at {str(build_log)}" in lines
......
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