Skip to content

Commit 031bcb3

Browse files
zahclaude
andcommitted
test(support): add requireBinary fixture-assertion helper
Foundation for the Test-Fixtures-In-Build-Graph campaign (M1): a shared helper that asserts a graph-built fixture binary exists (with a fail-fast diagnostic naming the path and the build-graph edge that produces it) instead of compiling it at test runtime. Test code will use this to consume build/bin/repro and the other fixtures the graph builds, replacing the per-test `proc compileNim` shell-outs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 4d9d99c commit 031bcb3

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

libs/repro_test_support/src/repro_test_support.nim

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,27 @@ proc ctInterposeSrcPath*(repoRoot: string): string =
315315
return vendored
316316
""
317317

318+
type MissingTestFixtureError* = object of CatchableError
319+
320+
proc requireBinary*(path, edgeName: string): string {.discardable.} =
321+
## Test-Fixtures-In-Build-Graph: assert that a graph-built fixture binary
322+
## already exists, instead of compiling it at test runtime. Returns ``path``
323+
## on success; raises ``MissingTestFixtureError`` with a fail-fast diagnostic
324+
## (the expected path + the build-graph edge that produces it) otherwise.
325+
##
326+
## Fixtures (the ``repro`` binary, the monitor shim, fixture providers, …)
327+
## are built by ``repro build test`` as graph edges and are cached across
328+
## runs; test code must depend on them and assert their presence here, never
329+
## invoke a compiler. This replaces the per-test ``proc compileNim`` shell-outs
330+
## (see ``Test-Fixtures-In-Build-Graph.md``).
331+
if not fileExists(path):
332+
raise newException(MissingTestFixtureError,
333+
"required test fixture binary not found: " & path & "\n" &
334+
" it is produced by build-graph edge '" & edgeName & "'.\n" &
335+
" run `repro build test` (which builds the fixture) before this test, " &
336+
"or declare that edge as a dependency of this test's execute edge.")
337+
path
338+
318339
proc fsSnoopWrapperSource*(repoRoot, cacheKey: string): string =
319340
## Executable-Consolidation M1 deleted the standalone
320341
## ``apps/repro-fs-snoop/repro_fs_snoop.nim`` entry point: the internal

0 commit comments

Comments
 (0)