From b46b018390672773e8fd706349cf6259bece7b88 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Tue, 8 Oct 2024 16:19:47 -0600 Subject: [PATCH 1/3] do not report memcomp if no baseline exists --- CIME/baselines/performance.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CIME/baselines/performance.py b/CIME/baselines/performance.py index 55092f397e2..67c19dbd43f 100644 --- a/CIME/baselines/performance.py +++ b/CIME/baselines/performance.py @@ -431,6 +431,8 @@ def read_baseline_file(baseline_file): str Value stored in baseline file without comments. """ + if not os.path.exists(baseline_file): + return "\nNO file {} found".format(baseline_file) with open(baseline_file) as fd: lines = [x.strip() for x in fd.readlines() if not x.startswith("#") and x != ""] From 21e146e8d58367bee881ec5de1fec61c21ba0efc Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Wed, 9 Oct 2024 13:24:14 -0600 Subject: [PATCH 2/3] fix issue in unit test by creating file first --- CIME/tests/test_unit_baselines_performance.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CIME/tests/test_unit_baselines_performance.py b/CIME/tests/test_unit_baselines_performance.py index 1564541ba9a..77615502b38 100644 --- a/CIME/tests/test_unit_baselines_performance.py +++ b/CIME/tests/test_unit_baselines_performance.py @@ -139,6 +139,8 @@ def test_read_baseline_file_multi_line(self): assert baseline == "sha:1df0 date:2023 1000.0\nsha:3b05 date:2023 2000.0" def test_read_baseline_file_content(self): + if not os.path.exists("/tmp/cpl-mem.log"): + os.mknod("/tmp/cpl-mem.log") with mock.patch( "builtins.open", mock.mock_open(read_data="sha:1df0 date:2023 1000.0") ) as mock_file: From 68cb6b607f4745d3f6e0308f248db37db6b07186 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Wed, 9 Oct 2024 13:30:24 -0600 Subject: [PATCH 3/3] fix issue in unit test by creating file first --- CIME/tests/test_unit_baselines_performance.py | 1 + 1 file changed, 1 insertion(+) diff --git a/CIME/tests/test_unit_baselines_performance.py b/CIME/tests/test_unit_baselines_performance.py index 77615502b38..ed6b2c0a085 100644 --- a/CIME/tests/test_unit_baselines_performance.py +++ b/CIME/tests/test_unit_baselines_performance.py @@ -3,6 +3,7 @@ import gzip import tempfile import unittest +import os from unittest import mock from pathlib import Path