✓
Passing This code compiles and runs correctly.
Code
// Pins that the STDLIB DEFAULT build steps actually run — not merely that
// overriding them works.
//
// 310_033 already covers `[default]` precedence and dependency ordering, but it
// overrides compile_backend, build AND run with echoes. Every script it executes
// is its own, so it is structurally incapable of noticing that a default step is
// broken. Two defects hid there for exactly that reason:
//
// 1. `[default, depends_on(compile_backend)]` used `,` where annotations
// separate on `|`, so the dependency was DROPPED — silently, until PARSE007
// started refusing that spelling.
// 2. The default `build` step ran `./zig-out/bin/main` while phase 1 emits
// `./zig-out/bin/backend`.
//
// And a third, which is why this test was pinned red rather than merely failing:
// build steps inherited koruc's INVOCATION directory instead of the OUTPUT
// directory, so the stdlib's own output-dir-relative defaults only worked when
// you happened to invoke koruc from the output directory. Run from the repo root
// — which is how the harness runs — phase 1 could not find `build_backend.zig`:
//
// error: failed to check cache: 'build_backend.zig' file_hash FileNotFound
// error: BuildStepFailed
//
// This test overrides ONLY `run`, so `build` and `compile_backend` are the
// stdlib's own scripts, and `run` depends on `build` — a failure anywhere in the
// chain means `run` never fires. post.sh then checks each step's own artifact
// individually, so a regression names which link broke rather than just "output".
import std/build
import std/io
// Writes a file rather than echoing: the harness drives the two compilation
// passes itself (regression_lib.sh:737) and does not capture koruc's stdout, so
// an echo to the terminal is unobservable to any assertion. The path is bare
// because a build step's working directory IS the output directory.
[depends_on(build)] std/build:step(name: "run") {
echo "default chain reached run" > chain.log
}
std/io:print.blk {
unreachable unless the defaults ran
}
Actual
unreachable unless the defaults ran
Expected output
unreachable unless the defaults ran
Flows
flow ~step click a branch to expand · @labels scroll to their anchor
step (name: "run", source: echo "default chain reached run" > chain.log)
flow ~print.blk click a branch to expand · @labels scroll to their anchor
print.blk (source: unreachable unless the defaults ran)
Test Configuration
MUST_RUN
Post-validation Script:
#!/bin/bash
# Each default build step is pinned on its own named artifact, so a regression
# names the link that broke instead of collapsing to a single "output" mismatch.
#
# Runs with cwd = the test directory (regression_lib.sh cd's here), which is also
# the output directory the steps ran in — the same basis, deliberately.
fail() {
echo "FAIL: $1"
exit 1
}
# Step 2 of 3 — the stdlib's own `build`: `./zig-out/bin/backend backend_tmp`.
# `backend_tmp` is that script's own output name, so nothing else in the harness
# produces it. This is the step that ran the wrong binary name (`main`) and,
# separately, lost its depends_on to a comma.
#
# This ALSO proves step 1, `compile_backend`, ran — transitively and soundly: the
# script above cannot execute unless `zig build --build-file build_backend.zig`
# already produced `zig-out/bin/backend`. That path is deliberately NOT asserted
# directly, because `zig-out/` is transient here — the harness clears it between
# its own compilation phases, so a direct check passes or fails on harness
# bookkeeping rather than on whether the step ran.
[[ -f backend_tmp ]] || fail "default build did not produce backend_tmp (so compile_backend or build did not run)"
# Step 3 of 3 — this test's `run`, which depends on `build`. Reaching it at all
# means the whole default chain succeeded, in order.
[[ -f chain.log ]] || fail "run step never executed — chain.log not found"
ACTUAL=$(cat chain.log)
EXPECTED="default chain reached run"
if [[ "$ACTUAL" != "$EXPECTED" ]]; then
rm -f chain.log
fail "chain.log mismatch: expected '$EXPECTED', got '$ACTUAL'"
fi
rm -f chain.log
echo "PASS: default chain ran compile_backend -> build -> run in the output directory"
exit 0