Skip to content

Commit a6b6c05

Browse files
yraparticlaudeillsilin
authored
[CK][CK_TILE] Fix CTest parsing to handle all test number formats (ROCm#5880)
## Motivation Fix a bug in the smart-build --ctest-only filter that was incorrectly excluding tests with numbers less than 100. ## Technical Details The issue was caused by CTest formatting test numbers with variable spacing based on the number of digits: - "Test `#1`: name (3 spaces for tests 1-9)" - "Test `ROCm#79`: name (2 spaces for tests 10-99)" - "Test `ROCm#100`: name (1 space for tests 100+)" The previous code used `line.strip().startswith("Test #")` which only matched tests with a single space (i.e., test numbers >= 100). This caused tests like ck_tile_unit_sequence (Test ROCm#79) to be excluded from smart-build test selection, resulting in CTest failures when the binary wasn't built. Solution: Replace string matching with a regex pattern that handles all spacing variations: r'^\s*Test\s+#\d+:\s*(.+)$' ## Test Plan Tested with test numbers from 1 to 12345. ## Test Result - Before: 48 tests selected (only tests ROCm#100+) - After: 146 tests selected (all CTest-registered tests) ## Submission Checklist - [x ] Look over the contributing guidelines at https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Illia Silin <98187287+illsilin@users.noreply.github.com>
1 parent 56daab1 commit a6b6c05

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

projects/composablekernel/script/dependency-parser/src/selective_test_filter.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import subprocess
3030
import json
3131
import os
32+
import re
3233

3334

3435
def get_changed_files(ref1, ref2, project: str = None):
@@ -110,12 +111,18 @@ def get_ctest_registered_tests(build_dir=None):
110111
return None
111112

112113
tests = set()
114+
# CTest formats test numbers with variable spacing:
115+
# Test #1: name (3 spaces for 1-9)
116+
# Test #10: name (2 spaces for 10-99)
117+
# Test #100: name (1 space for 100+)
118+
# Use regex to match all formats
119+
test_pattern = re.compile(r'^\s*Test\s+#\d+:\s*(.+)$')
120+
113121
for line in result.stdout.splitlines():
114-
if line.strip().startswith("Test #"):
115-
parts = line.split(":", 1)
116-
if len(parts) == 2:
117-
test_name = parts[1].strip()
118-
tests.add(test_name)
122+
match = test_pattern.match(line)
123+
if match:
124+
test_name = match.group(1).strip()
125+
tests.add(test_name)
119126

120127
return tests
121128
except (subprocess.TimeoutExpired, FileNotFoundError, Exception):

0 commit comments

Comments
 (0)