Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion CIME/simple_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@ def _normalize_string_value(value, case):
Some of the strings are inherently prone to diffs, like file
paths, etc. This function attempts to normalize that data so that
it will not cause diffs.
>>> _normalize_string_value("ERS.TL319_t232.G1850MARBL_JRA.derecho_intel.G.20260410_135953_nhg5ae","ERS.TL319_t232.G1850MARBL_JRA.derecho_intel")
'ERS.TL319_t232.G1850MARBL_JRA.derecho_intel.ACTION.TESTID'
>>> _normalize_string_value("ERS.TL319_t232.G1850MARBL_JRA.derecho_intel.GC.20260410_135953_nhg5ae","ERS.TL319_t232.G1850MARBL_JRA.derecho_intel")
'ERS.TL319_t232.G1850MARBL_JRA.derecho_intel.ACTION.TESTID'
>>> _normalize_string_value("ERS.TL319_t232.G1850MARBL_JRA.derecho_intel.C.20260410_135953_nhg5ae","ERS.TL319_t232.G1850MARBL_JRA.derecho_intel")
'ERS.TL319_t232.G1850MARBL_JRA.derecho_intel.ACTION.TESTID'
>>> _normalize_string_value("ERS.TL319_t232.G1850MARBL_JRA.derecho_intel.GG.20260410_135953_nhg5ae","ERS.TL319_t232.G1850MARBL_JRA.derecho_intel")
'ERS.TL319_t232.G1850MARBL_JRA.derecho_intel.GG.20260410_135953_nhg5ae'
"""
# Any occurance of case must be normalized because test-ids might not match
if case is not None:
case_re = re.compile(r"{}[.]([GC])[.]([^./\s]+)".format(case))
case_re = re.compile(r"{}[.](GC?|C)[.]([^./\s]+)".format(case))
value = case_re.sub("{}.ACTION.TESTID".format(case), value)

if "/" in value:
Expand Down
23 changes: 23 additions & 0 deletions CIME/tests/test_simple_compare.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import unittest

from CIME.simple_compare import _normalize_string_value


class TestSimpleCompare(unittest.TestCase):
def test_normalize_string_values(self):
test = "test.grid.compset.mach_compiler"
testid = "19991231_235959_abcdef"

# Test cases where _normalize_string_value() will normalize test
for action in ["G", "C", "GC"]:
assert (
_normalize_string_value(f"{test}.{action}.{testid}", test)
== f"{test}.ACTION.TESTID"
)

# Test cases where _normalize_string_value() will not change test
for action in ["GG", "CC", "CG"]:
assert (
_normalize_string_value(f"{test}.{action}.{testid}", test)
== f"{test}.{action}.{testid}"
)
Loading