diff --git a/CIME/simple_compare.py b/CIME/simple_compare.py index 515457af017..f1292778157 100644 --- a/CIME/simple_compare.py +++ b/CIME/simple_compare.py @@ -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: diff --git a/CIME/tests/test_simple_compare.py b/CIME/tests/test_simple_compare.py new file mode 100644 index 00000000000..fb045da4976 --- /dev/null +++ b/CIME/tests/test_simple_compare.py @@ -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}" + )