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 != ""] diff --git a/CIME/tests/test_unit_baselines_performance.py b/CIME/tests/test_unit_baselines_performance.py index 1564541ba9a..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 @@ -139,6 +140,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: