---
id: TASK-9.2
title: Add tests for pre-run rebuild and --norebuild behavior
status: Done
assignee:
  - '@codex'
created_date: '2026-02-04 09:46'
updated_date: '2026-02-04 10:38'
labels: []
dependencies: []
references:
  - spec/api_spec/manager_spec.lua
parent_task_id: TASK-9
---

## Description

<!-- SECTION:DESCRIPTION:BEGIN -->
Extend Busted specs to cover the new pre-run rebuild behavior when executing the simulator binary directly, the `--norebuild/-n` opt-out, and the unchanged fallback to `ninja run`.
<!-- SECTION:DESCRIPTION:END -->

## Acceptance Criteria
<!-- AC:BEGIN -->
- [x] #1 Tests cover that direct simulator-binary execution triggers a build before run by default.
- [x] #2 Tests cover that `--norebuild/-n` skips the pre-run build when executing the simulator binary.
- [x] #3 Tests cover that fallback to `ninja run` remains unchanged (no added build step).
<!-- AC:END -->

## Implementation Plan

<!-- SECTION:PLAN:BEGIN -->
1. Add/adjust specs in `spec/api_spec/manager_spec.lua` to assert `Manager.build` is called before executing the simulator binary when `zephyr/zephyr.exe` exists.
2. Add a spec case where `config.norebuild = true` and assert `Manager.build` is not called while the simulator binary still runs.
3. Add a spec case for missing simulator binary asserting `Manager.build` is not called and `ninja run` is executed (fallback unchanged).
<!-- SECTION:PLAN:END -->

## Implementation Notes

<!-- SECTION:NOTES:BEGIN -->
Updated manager specs to assert pre-run build for zephyr binary execution, no build on norebuild, and no build on ninja-run fallback.

Ran `busted spec/api_spec/manager_spec.lua` (25/0/0/0).
<!-- SECTION:NOTES:END -->
