From de2adebf6a2804040491a745e809ca20dab57da8 Mon Sep 17 00:00:00 2001 From: Michael Levy Date: Mon, 13 Apr 2026 14:55:08 -0600 Subject: [PATCH 1/6] Fix regular expression used in NLCOMP test Need to capture cases when action is .G., .C., or .GC.; existing regex only caught the first two --- CIME/simple_compare.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CIME/simple_compare.py b/CIME/simple_compare.py index 515457af017..138114e2e8b 100644 --- a/CIME/simple_compare.py +++ b/CIME/simple_compare.py @@ -12,7 +12,7 @@ def _normalize_string_value(value, case): """ # 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]|GC)[.]([^./\s]+)".format(case)) value = case_re.sub("{}.ACTION.TESTID".format(case), value) if "/" in value: From 2ea4efefb97d45af0c45323cb8858993e180245e Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Tue, 14 Apr 2026 08:06:29 -0600 Subject: [PATCH 2/6] add doctests --- CIME/simple_compare.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CIME/simple_compare.py b/CIME/simple_compare.py index 138114e2e8b..0f1a4ea88b2 100644 --- a/CIME/simple_compare.py +++ b/CIME/simple_compare.py @@ -9,6 +9,14 @@ 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: From b81606ea7169187080d0924969680e83fe4a68c6 Mon Sep 17 00:00:00 2001 From: Michael Levy Date: Tue, 14 Apr 2026 08:21:32 -0600 Subject: [PATCH 3/6] Fix regular expression and add unit test CIME/tests/test_simple_compare.py only tests _normalize_string_value; I verified that the test failed with the bad regular expression and passes with the modifications in this PR --- CIME/simple_compare.py | 2 +- CIME/tests/test_simple_compare.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 CIME/tests/test_simple_compare.py diff --git a/CIME/simple_compare.py b/CIME/simple_compare.py index 0f1a4ea88b2..f1292778157 100644 --- a/CIME/simple_compare.py +++ b/CIME/simple_compare.py @@ -20,7 +20,7 @@ def _normalize_string_value(value, case): """ # Any occurance of case must be normalized because test-ids might not match if case is not None: - case_re = re.compile(r"{}[.]([GC]|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..d450d73fa4f --- /dev/null +++ b/CIME/tests/test_simple_compare.py @@ -0,0 +1,11 @@ +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" + for action in ['G', 'C', 'GC']: + assert(_normalize_string_value(f"{test}.{action}.{testid}", test) == f"{test}.ACTION.TESTID") From 3700d301aa262da5a8063ac3ab9994e4f81bcac4 Mon Sep 17 00:00:00 2001 From: Michael Levy Date: Tue, 14 Apr 2026 08:26:40 -0600 Subject: [PATCH 4/6] Updates from black via pre-commit --- CIME/tests/test_simple_compare.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CIME/tests/test_simple_compare.py b/CIME/tests/test_simple_compare.py index d450d73fa4f..3e2145a0a24 100644 --- a/CIME/tests/test_simple_compare.py +++ b/CIME/tests/test_simple_compare.py @@ -7,5 +7,8 @@ class TestSimpleCompare(unittest.TestCase): def test_normalize_string_values(self): test = "test.grid.compset.mach_compiler" testid = "19991231_235959_abcdef" - for action in ['G', 'C', 'GC']: - assert(_normalize_string_value(f"{test}.{action}.{testid}", test) == f"{test}.ACTION.TESTID") + for action in ["G", "C", "GC"]: + assert ( + _normalize_string_value(f"{test}.{action}.{testid}", test) + == f"{test}.ACTION.TESTID" + ) From e77fe0bcee06ed8fa0c24011a8e28984aa5f1411 Mon Sep 17 00:00:00 2001 From: Michael Levy Date: Tue, 14 Apr 2026 08:28:46 -0600 Subject: [PATCH 5/6] Add a few more unit tests Test a few cases where we expect _normalize_string_value() to return the original string --- CIME/tests/test_simple_compare.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CIME/tests/test_simple_compare.py b/CIME/tests/test_simple_compare.py index 3e2145a0a24..469d2d20fa5 100644 --- a/CIME/tests/test_simple_compare.py +++ b/CIME/tests/test_simple_compare.py @@ -12,3 +12,8 @@ def test_normalize_string_values(self): _normalize_string_value(f"{test}.{action}.{testid}", test) == f"{test}.ACTION.TESTID" ) + for action in ["GG", "CC", "CG"]: + assert ( + _normalize_string_value(f"{test}.{action}.{testid}", test) + == f"{test}.{action}.{testid}" + ) From c19d517cb6f881d96d0cd272cbfa1d0b03105610 Mon Sep 17 00:00:00 2001 From: Michael Levy Date: Tue, 14 Apr 2026 08:30:09 -0600 Subject: [PATCH 6/6] Add a couple short comments to new test module --- CIME/tests/test_simple_compare.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CIME/tests/test_simple_compare.py b/CIME/tests/test_simple_compare.py index 469d2d20fa5..fb045da4976 100644 --- a/CIME/tests/test_simple_compare.py +++ b/CIME/tests/test_simple_compare.py @@ -7,11 +7,15 @@ 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)