Save full test suite result for future fast-path. Called after a successful full unit-test suite run (all tests passed). Stores build-state gates so future runs can skip fingerprint + imports when nothing has changed. Also captures examples/ mtime so the 'bash test --cpp' ultra-earl
(
build_dir: Path, num_passed: int, num_tests: int, duration: float
)
| 509 | |
| 510 | |
| 511 | def save_full_run_result( |
| 512 | build_dir: Path, num_passed: int, num_tests: int, duration: float |
| 513 | ) -> None: |
| 514 | """Save full test suite result for future fast-path. |
| 515 | |
| 516 | Called after a successful full unit-test suite run (all tests passed). |
| 517 | Stores build-state gates so future runs can skip fingerprint + imports |
| 518 | when nothing has changed. Also captures examples/ mtime so the |
| 519 | 'bash test --cpp' ultra-early exit can correctly detect example changes. |
| 520 | """ |
| 521 | cache_file = get_full_run_cache_file(build_dir) |
| 522 | try: |
| 523 | build_ninja = build_dir / "build.ninja" |
| 524 | cwd = Path.cwd() |
| 525 | |
| 526 | # Compute meson.build max mtime |
| 527 | _meson_files = [ |
| 528 | cwd / "meson.build", |
| 529 | cwd / "tests" / "meson.build", |
| 530 | cwd / "ci" / "meson" / "native" / "meson.build", |
| 531 | cwd / "ci" / "meson" / "wasm" / "meson.build", |
| 532 | cwd / "examples" / "meson.build", |
| 533 | ] |
| 534 | _meson_max = 0.0 |
| 535 | for mf in _meson_files: |
| 536 | try: |
| 537 | _meson_max = max(_meson_max, mf.stat().st_mtime) |
| 538 | except OSError: |
| 539 | pass |
| 540 | |
| 541 | data = { |
| 542 | "result": "pass", |
| 543 | "num_passed": num_passed, |
| 544 | "num_tests": num_tests, |
| 545 | "duration": duration, |
| 546 | "build_ninja_mtime": ( |
| 547 | build_ninja.stat().st_mtime if build_ninja.exists() else 0.0 |
| 548 | ), |
| 549 | "src_max_file_mtime": _get_max_source_file_mtime(cwd / "src"), |
| 550 | "tests_max_file_mtime": _get_max_source_file_mtime(cwd / "tests"), |
| 551 | "examples_max_file_mtime": _get_max_source_file_mtime(cwd / "examples"), |
| 552 | "meson_max_file_mtime": _meson_max, |
| 553 | } |
| 554 | |
| 555 | with open(cache_file, "w", encoding="utf-8") as f: |
| 556 | json.dump(data, f) |
| 557 | |
| 558 | except (OSError, json.JSONDecodeError): |
| 559 | pass # Non-critical — next run will fall back to normal execution |