Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions scripts/test_to_stage_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def _load_tests_file(path: str) -> List[str]:


# Regex to parse Jenkins stage configurations from Groovy files
# Matches patterns like: "Stage-Name": ["platform", "yaml_file", split_id, split_count, gpu_count]
# Matches patterns like: "Stage-Name": ["platform", "yaml_file", split_id, split_count, gpu_count, node_count, runWithSbatch]
#
# Pattern breakdown:
# "(?P<stage>[^"]+)" - Captures stage name in quotes (group 'stage')
Expand All @@ -56,10 +56,12 @@ def _load_tests_file(path: str) -> List[str]:
# "[^"]+" - Matches platform string in quotes (ignored)
# ,\s* - Matches comma with optional whitespace
# "(?P<yml>[^"]+)" - Captures yaml filename in quotes (group 'yml')
# (?:,\s*\d+)* - Matches zero or more comma-separated numbers (split_id, split_count, gpu_count)
# (?:,\s*(?:\d+|true|false))* - Matches zero or more comma-separated numbers or
# booleans (split_id, split_count, gpu_count, node_count, runWithSbatch)
# \s*\] - Matches closing bracket with optional whitespace
_STAGE_RE = re.compile(
r'"(?P<stage>[^"]+)"\s*:\s*\["[^"]+",\s*"(?P<yml>[^"]+)"(?:,\s*\d+)*\s*\]')
r'"(?P<stage>[^"]+)"\s*:\s*\["[^"]+",\s*"(?P<yml>[^"]+)"(?:,\s*(?:\d+|true|false))*\s*\]'
)


def _extract_terms(entry):
Expand All @@ -85,6 +87,8 @@ def _parse_stage_mapping(path):
yaml_to_stages = defaultdict(list)
with open(path, 'r') as f:
for line in f:
if line.lstrip().startswith('//'):
continue
m = _STAGE_RE.search(line)
if m:
stage = m.group('stage')
Expand Down
11 changes: 9 additions & 2 deletions tests/unittest/tools/test_test_to_stage_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,15 @@ def test_backend_filtering_consistency(stage_query):
f"at least one stage containing '{backend.upper()}', " \
f"but got stages: {stages}"

# Check that test does NOT map to stages of other backends
other_backends = all_backends - {backend}
# Check that test does NOT map to stages of backends it is not
# declared under (tests may legitimately be listed under several
# backends across test-db files).
declared_backends = {
b.strip()
for _, _, b in stage_query.test_map[test_name]
if b and b.strip()
}
other_backends = all_backends - declared_backends
for stage in stages:
stage_upper = stage.upper()
for other_backend in other_backends:
Expand Down
Loading