#428

zero test: tests reaching std.* outside std.testing fail with "unknown function: <label>"

Openguygrigsbyopened 4mo ago

zero test fails any test whose call chain touches std.* outside std.testing, reporting the test's display label as an unknown function. The workaround documented in the bundled testing skill (recreate coverage with addTest) does not help, because the trigger is not custom test bodies. It is stdlib calls reachable from the test.

Repro

zero init --template cli t
cat >> t/src/lib.0 <<'EOF'
test "span len" {
    expect std.mem.len(std.mem.span("abc")) == 3
}
EOF
zero test t

Output:

zero test unknown function: span len

zero test --json shows the suite runs (template test passes) and only this test fails; stderr carries the message, testBackend is direct-program-graph.

What does and does not trigger it

Each case verified in a fresh zero init --template cli project:

test reachesresult
std.testing.equalBytes("zero", "zero")ok
local helper with String param, no stdlib callsok
std.mem.len(std.mem.span("abc")) directly in test bodyunknown function: <label>
same call inside a local helper the test callsunknown function: <label>
same, with use std.mem added to the moduleunknown function: <label>
test placed in main.0 instead of lib.0unknown function: <label>
test generated via zero patch --op addTest calling a helper that uses std.memunknown function: <label>

So the failure follows stdlib linkage in the test harness, not test authorship. addTestBody vs addTest vs handwritten test blocks makes no difference.

Why the documented workaround misdiagnoses this

The bundled testing skill says:

If zero test reports an unknown function for a display label, do not rename the label to chase runner internals. Delete the malformed custom test and recreate simple pure coverage with addTest, or use behavior smoke checks for effectful paths.

The same skill also recommends std.testing helpers in test bodies, and std.testing works. But addTest coverage of any helper that touches std.mem, std.str, etc. still fails, so the prescription only works for tests that avoid the stdlib entirely. For a language whose stdlib is span-centric that excludes most real logic (anything needing std.mem.len on a Span<u8>).

Environment

  • zero 0.3.4 (build 5b3a90a), installed via zerolang.ai/install.sh
  • darwin-arm64 (macOS 15, Apple Silicon)

Happy to provide the four probe projects or run candidate fixes against them.

Activity

0

No activity yet.