Skip to content

Commit 51cfec5

Browse files
authored
Merge pull request #4964 from mnlevy1981/fix_nlcomp
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
2 parents a69c166 + c19d517 commit 51cfec5

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

CIME/simple_compare.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,18 @@ def _normalize_string_value(value, case):
99
Some of the strings are inherently prone to diffs, like file
1010
paths, etc. This function attempts to normalize that data so that
1111
it will not cause diffs.
12+
>>> _normalize_string_value("ERS.TL319_t232.G1850MARBL_JRA.derecho_intel.G.20260410_135953_nhg5ae","ERS.TL319_t232.G1850MARBL_JRA.derecho_intel")
13+
'ERS.TL319_t232.G1850MARBL_JRA.derecho_intel.ACTION.TESTID'
14+
>>> _normalize_string_value("ERS.TL319_t232.G1850MARBL_JRA.derecho_intel.GC.20260410_135953_nhg5ae","ERS.TL319_t232.G1850MARBL_JRA.derecho_intel")
15+
'ERS.TL319_t232.G1850MARBL_JRA.derecho_intel.ACTION.TESTID'
16+
>>> _normalize_string_value("ERS.TL319_t232.G1850MARBL_JRA.derecho_intel.C.20260410_135953_nhg5ae","ERS.TL319_t232.G1850MARBL_JRA.derecho_intel")
17+
'ERS.TL319_t232.G1850MARBL_JRA.derecho_intel.ACTION.TESTID'
18+
>>> _normalize_string_value("ERS.TL319_t232.G1850MARBL_JRA.derecho_intel.GG.20260410_135953_nhg5ae","ERS.TL319_t232.G1850MARBL_JRA.derecho_intel")
19+
'ERS.TL319_t232.G1850MARBL_JRA.derecho_intel.GG.20260410_135953_nhg5ae'
1220
"""
1321
# Any occurance of case must be normalized because test-ids might not match
1422
if case is not None:
15-
case_re = re.compile(r"{}[.]([GC])[.]([^./\s]+)".format(case))
23+
case_re = re.compile(r"{}[.](GC?|C)[.]([^./\s]+)".format(case))
1624
value = case_re.sub("{}.ACTION.TESTID".format(case), value)
1725

1826
if "/" in value:

CIME/tests/test_simple_compare.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import unittest
2+
3+
from CIME.simple_compare import _normalize_string_value
4+
5+
6+
class TestSimpleCompare(unittest.TestCase):
7+
def test_normalize_string_values(self):
8+
test = "test.grid.compset.mach_compiler"
9+
testid = "19991231_235959_abcdef"
10+
11+
# Test cases where _normalize_string_value() will normalize test
12+
for action in ["G", "C", "GC"]:
13+
assert (
14+
_normalize_string_value(f"{test}.{action}.{testid}", test)
15+
== f"{test}.ACTION.TESTID"
16+
)
17+
18+
# Test cases where _normalize_string_value() will not change test
19+
for action in ["GG", "CC", "CG"]:
20+
assert (
21+
_normalize_string_value(f"{test}.{action}.{testid}", test)
22+
== f"{test}.{action}.{testid}"
23+
)

0 commit comments

Comments
 (0)