---
id: TASK-4.2
title: Add Busted tests for compile_commands.json symlink behavior
status: Done
assignee:
  - codex
created_date: '2026-01-30 09:02'
updated_date: '2026-01-30 09:14'
labels:
  - tests
  - build
  - profiles
  - lsp
  - compile-commands
dependencies:
  - TASK-4.1
references:
  - spec/
parent_task_id: TASK-4
---

## Description

<!-- SECTION:DESCRIPTION:BEGIN -->
Add or update tests to cover the compile_commands.json symlink logic for build profiles, including presence, absence, and command exclusions.
<!-- SECTION:DESCRIPTION:END -->

## Acceptance Criteria
<!-- AC:BEGIN -->
- [x] #1 Tests cover creation of the root/build compile_commands.json symlink when build profiles are configured.
- [x] #2 Tests cover idempotent behavior when the symlink already exists.
- [x] #3 Tests cover no-op behavior when build profiles are not configured and for excluded commands (init/boards/runners/profiles).
<!-- AC:END -->

## Implementation Plan

<!-- SECTION:PLAN:BEGIN -->
- Locate existing Busted specs around profiles/CLI dispatch to place new coverage (likely under spec/api_spec/ or similar).
- Add tests that stub lfs/os.execute or use a temp directory to verify:
  - With profiles configured, running a non-excluded command triggers creation of build/compile_commands.json symlink to build/<default_profile>/compile_commands.json.
  - If the symlink already exists, it is not recreated/removed (idempotent).
  - With no profiles configured, or with excluded commands (init/boards/runners/profiles), no link creation occurs.
- Keep tests isolated and aligned with existing stubbing patterns in spec/.
<!-- SECTION:PLAN:END -->

## Implementation Notes

<!-- SECTION:NOTES:BEGIN -->
Plan approved by user on 2026-01-30.

Added Busted coverage in `spec/zync_spec.lua` for compile_commands.json symlink creation, idempotency, and excluded/no-profile cases.
<!-- SECTION:NOTES:END -->
