Skip to content

Commit

Permalink
Merge pull request #4691 from jedwards4b/fix/memlog_no_baseline
Browse files Browse the repository at this point in the history
do not report memcomp if no baseline exists
  • Loading branch information
jedwards4b authored Oct 10, 2024
2 parents 62a9b17 + 68cb6b6 commit 4de5fc2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CIME/baselines/performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 != ""]

Expand Down
3 changes: 3 additions & 0 deletions CIME/tests/test_unit_baselines_performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import gzip
import tempfile
import unittest
import os
from unittest import mock
from pathlib import Path

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 4de5fc2

Please sign in to comment.