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

add test_create_log_file_names

parent d00a2826
No related branches found
No related tags found
1 merge request!29Restructure log location
......@@ -38,11 +38,11 @@ config_vars = {
"cmd_log_file": "install.log",
# Placeholder installer log file name, placed at mpsd_microarch/logs
"installer_log_template": Template(
"${mpsd_release}_${mpsd_microarch}_${date}_{action}.log"
"${mpsd_release}_${mpsd_microarch}_${date}_${action}.log"
),
# Placeholder build log file name, placed at mpsd_microarch/logs
"build_log_template": Template(
"${mpsd_release}_${mpsd_microarch}_${date}_${toolchain}_{action}.log"
"${mpsd_release}_${mpsd_microarch}_${date}_${toolchain}_${action}.log"
),
"metadata_tag_open": "!<meta>",
"metadata_tag_close": "</meta>!",
......
......@@ -6,6 +6,8 @@ import shutil
import subprocess
from pathlib import Path
import logging
import datetime
import pytest
mod = importlib.import_module("mpsd-software-environment")
......@@ -353,6 +355,49 @@ def test_metadata_logging(tmp_path):
assert len(read_dict) == len(keys)
def test_create_log_file_names():
"""Test that the log file names are created correctly."""
create_log_file_names = mod.create_log_file_names
mpsd_release = "dev-23a"
mpsd_microarch = "sandybridge"
date = datetime.datetime.now().replace(microsecond=0).isoformat()
action = "install"
toolchain = "foss2021a"
# test for correct action and toolchain
installer_log_file, build_log_file = create_log_file_names(
mpsd_microarch=mpsd_microarch,
mpsd_release=mpsd_release,
date=date,
action=action,
toolchain=toolchain,
)
assert installer_log_file == f"{mpsd_release}_{mpsd_microarch}_{date}_{action}.log"
assert (
build_log_file
== f"{mpsd_release}_{mpsd_microarch}_{date}_{toolchain}_{action}.log"
)
# test no build log file for incorrect action
installer_log_file, build_log_file = create_log_file_names(
mpsd_microarch=mpsd_microarch,
mpsd_release=mpsd_release,
date=date,
action="status",
toolchain=toolchain,
)
assert installer_log_file == f"{mpsd_release}_{mpsd_microarch}_{date}_status.log"
assert build_log_file == None
# test no build log file for incorrect toolchain
installer_log_file, build_log_file = create_log_file_names(
mpsd_microarch=mpsd_microarch,
mpsd_release=mpsd_release,
date=date,
action="reinstall",
toolchain=None,
)
assert installer_log_file == f"{mpsd_release}_{mpsd_microarch}_{date}_reinstall.log"
assert build_log_file == None
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.
Finish editing this message first!
Please register or to comment