@@ -1816,7 +1816,7 @@ class KeepSorted(ComplianceTest):
1816
1816
1817
1817
MARKER = "zephyr-keep-sorted"
1818
1818
1819
- def block_check_sorted (self , block_data , * , regex , strip ):
1819
+ def block_check_sorted (self , block_data , * , regex , strip , fold ):
1820
1820
def _test_indent (txt : str ):
1821
1821
return txt .startswith ((" " , "\t " ))
1822
1822
@@ -1842,9 +1842,10 @@ def _test_indent(txt: str):
1842
1842
if strip is not None :
1843
1843
line = line .strip (strip )
1844
1844
1845
- # Fold back indented lines after the current one
1846
- for cont in takewhile (_test_indent , lines [idx + 1 :]):
1847
- line += cont .strip ()
1845
+ if fold :
1846
+ # Fold back indented lines after the current one
1847
+ for cont in takewhile (_test_indent , lines [idx + 1 :]):
1848
+ line += cont .strip ()
1848
1849
1849
1850
if line < last :
1850
1851
return idx
@@ -1866,9 +1867,11 @@ def check_file(self, file, fp):
1866
1867
stop_marker = f"{ self .MARKER } -stop"
1867
1868
regex_marker = r"re\((.+)\)"
1868
1869
strip_marker = r"strip\((.+)\)"
1870
+ nofold_marker = "nofold"
1869
1871
start_line = 0
1870
1872
regex = None
1871
1873
strip = None
1874
+ fold = True
1872
1875
1873
1876
for line_num , line in enumerate (fp .readlines (), start = 1 ):
1874
1877
if start_marker in line :
@@ -1886,14 +1889,16 @@ def check_file(self, file, fp):
1886
1889
1887
1890
match = re .search (strip_marker , line )
1888
1891
strip = match .group (1 ) if match else None
1892
+
1893
+ fold = nofold_marker not in line
1889
1894
elif stop_marker in line :
1890
1895
if not in_block :
1891
1896
desc = f"{ stop_marker } without { start_marker } "
1892
1897
self .fmtd_failure ("error" , "KeepSorted" , file , line_num ,
1893
1898
desc = desc )
1894
1899
in_block = False
1895
1900
1896
- idx = self .block_check_sorted (block_data , regex = regex , strip = strip )
1901
+ idx = self .block_check_sorted (block_data , regex = regex , strip = strip , fold = fold )
1897
1902
if idx >= 0 :
1898
1903
desc = f"sorted block has out-of-order line at { start_line + idx } "
1899
1904
self .fmtd_failure ("error" , "KeepSorted" , file , line_num ,
0 commit comments