fix(tests): anchor example reads to DUNE_SOURCEROOT (#37) #52

Merged
toph merged 1 commit from worktree-fix-example-path-anchor into main 2026-07-03 18:57:29 +00:00
Owner

Closes #37.

test_e2e, test_golden, and test_eval read examples/ through the cwd-relative ../../../examples, which escapes the build sandbox into a shared parent directory. Run from an in-repo worktree, that resolves to the main checkout's examples/ — the phantom bisect-a.bel: unexpected character failures from #35 were stale syntax bleeding in from the other checkout.

Fix

Anchor to the absolute source root of the current build context via DUNE_SOURCEROOT (dune sets it for runtest/exec), falling back to the old relative path when a test binary is run bare. This also lets test_eval drop its Sys.argv.(0) build-dir derivation.

Verification

  • dune runtest green (all suites).
  • Ran the built test_e2e.exe from an unrelated cwd (/tmp): bogus DUNE_SOURCEROOT → tests fail (examples not found); correct DUNE_SOURCEROOT → all 26 pass. Proves the anchor is cwd-independent and keyed to the build context, not the shared parent.

Follow-up to #35.

Closes #37. `test_e2e`, `test_golden`, and `test_eval` read `examples/` through the cwd-relative `../../../examples`, which escapes the build sandbox into a shared parent directory. Run from an in-repo worktree, that resolves to the **main checkout's** `examples/` — the phantom `bisect-a.bel: unexpected character` failures from #35 were stale syntax bleeding in from the other checkout. ## Fix Anchor to the absolute source root of the *current* build context via `DUNE_SOURCEROOT` (dune sets it for `runtest`/`exec`), falling back to the old relative path when a test binary is run bare. This also lets `test_eval` drop its `Sys.argv.(0)` build-dir derivation. ## Verification - `dune runtest` green (all suites). - Ran the built `test_e2e.exe` from an unrelated cwd (`/tmp`): bogus `DUNE_SOURCEROOT` → tests fail (examples not found); correct `DUNE_SOURCEROOT` → all 26 pass. Proves the anchor is cwd-independent and keyed to the build context, not the shared parent. Follow-up to #35.
test_e2e, test_golden, and test_eval read examples/ via the cwd-relative
`../../../examples`, which escapes the build sandbox into a shared parent.
From an in-repo worktree that resolves to the *main* checkout's examples,
producing phantom failures (stale syntax from the other checkout).

Anchor to the absolute source root of the current build context via
DUNE_SOURCEROOT (set by dune for runtest/exec), falling back to the old
relative path when the binary is run bare. This also lets test_eval drop
its Sys.argv.(0) build-dir derivation.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C5LXwg9wwrkTdbHi9dT4C4
toph merged commit 15cd828412 into main 2026-07-03 18:57:29 +00:00
toph deleted branch worktree-fix-example-path-anchor 2026-07-03 18:57:29 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
toph/beloch!52
No description provided.