MCPcopy Create free account
hub / github.com/FastLED/FastLED / _find_aggregator_matches

Function _find_aggregator_matches

ci/util/smart_selector.py:333–394  ·  view source on GitHub ↗

Search inside aggregator test .cpp files for #include lines matching query. Aggregator files (e.g., tests/fl/codec.cpp) include sub-test headers like "codec/gif.hpp". When the user searches for "gif", this finds codec.cpp as the parent aggregator containing gif tests. Args:

(
    query: str, all_matches: list[TestMatch], project_dir: Path
)

Source from the content-addressed store, hash-verified

331
332
333def _find_aggregator_matches(
334 query: str, all_matches: list[TestMatch], project_dir: Path
335) -> list[TestMatch]:
336 """Search inside aggregator test .cpp files for #include lines matching query.
337
338 Aggregator files (e.g., tests/fl/codec.cpp) include sub-test headers like
339 "codec/gif.hpp". When the user searches for "gif", this finds codec.cpp as
340 the parent aggregator containing gif tests.
341
342 Args:
343 query: Search query (e.g., "gif")
344 all_matches: All discovered test/example matches
345 project_dir: Project root directory
346
347 Returns:
348 List of TestMatch objects for aggregator files containing matching includes
349 """
350 query_lower = query.lower()
351 results: list[TestMatch] = []
352
353 for match in all_matches:
354 if match.type != "unit_test":
355 continue
356 filepath = project_dir / match.path
357 if not filepath.exists() or not filepath.suffix == ".cpp":
358 continue
359 try:
360 content = filepath.read_text(encoding="utf-8", errors="replace")
361 except OSError:
362 continue
363 # Look for #include lines containing the query
364 for line in content.splitlines():
365 stripped = line.strip()
366 if stripped.startswith("#include") and query_lower in stripped.lower():
367 # Found a matching include — score based on how specific the match is
368 include_path = stripped.split('"')[1] if '"' in stripped else ""
369 include_name = (
370 include_path.rsplit("/", 1)[-1].rsplit(".", 1)[0]
371 if include_path
372 else ""
373 )
374 # If query ends with .hpp, extract the full filename with extension for scoring
375 include_filename = (
376 include_path.rsplit("/", 1)[-1] if include_path else ""
377 )
378 score_target = (
379 include_filename if query_lower.endswith(".hpp") else include_name
380 )
381 score, _ = _fuzzy_score(query, score_target)
382 if score > 0:
383 results.append(
384 TestMatch(
385 name=match.name,
386 path=match.path,
387 type=match.type,
388 score=score,
389 length=len(match.name),
390 )

Callers 1

smart_selectFunction · 0.85

Calls 3

_fuzzy_scoreFunction · 0.85
TestMatchClass · 0.85
appendMethod · 0.45

Tested by

no test coverage detected