diff --git a/scripts/check_kernel_freshness.py b/scripts/check_kernel_freshness.py index 403a724c..1e806b31 100644 --- a/scripts/check_kernel_freshness.py +++ b/scripts/check_kernel_freshness.py @@ -256,7 +256,7 @@ def _format_freshness_report(results: list[dict], skipped_kernels: list[str]) -> items = [] for result in sorted_results: - items.append(f"• {result['source_url']}: upstream is {result['days_behind']} days newer") + items.append(f"• {result['kernel_dir']} ({result['source_url']}): upstream is {result['days_behind']} days newer") report = f"{heading}\n\n" + "\n".join(items) diff --git a/scripts/test_kernel_freshness_lookup.py b/scripts/test_kernel_freshness_lookup.py index 640d2416..c2a0c03d 100644 --- a/scripts/test_kernel_freshness_lookup.py +++ b/scripts/test_kernel_freshness_lookup.py @@ -1,4 +1,5 @@ import sys +from datetime import datetime from pathlib import Path from check_kernel_freshness import KERNEL_SOURCE_MAPPING @@ -66,11 +67,48 @@ def test_kernel_mapping_completeness(root_path: Path) -> bool: return all_passed +def test_freshness_report_includes_kernel_dir() -> bool: + """Verify that _format_freshness_report includes kernel_dir in each line. + + Regression test for: multiple kernels sharing the same source_url would + produce duplicate, unactionable alert lines with no local directory name. + """ + from datetime import timezone + from check_kernel_freshness import _format_freshness_report + + shared_url = "https://github.com/Dao-AILab/flash-attention" + now = datetime.now(tz=timezone.utc) + results = [ + {"kernel_dir": "flash-attn2", "source_url": shared_url, "days_behind": 12, + "upstream_date": now, "local_date": now}, + {"kernel_dir": "flash-attn3", "source_url": shared_url, "days_behind": 5, + "upstream_date": now, "local_date": now}, + ] + + report = _format_freshness_report(results, skipped_kernels=[]) + + all_passed = True + for result in results: + if result["kernel_dir"] not in report: + print(f"❌ ERROR: '{result['kernel_dir']}' not found in freshness report") + all_passed = False + + if all_passed: + print("✅ _format_freshness_report correctly includes kernel_dir in each report line") + + return all_passed + + def main() -> int: root_path = Path(__file__).parent.parent.resolve() print(f"Testing kernel mapping in: {root_path}\n") - if test_kernel_mapping_completeness(root_path): + results = [ + test_kernel_mapping_completeness(root_path), + test_freshness_report_includes_kernel_dir(), + ] + + if all(results): print("\n✅ All tests passed!") return 0 else: