Skip to content

go_test

Compiled Go test package with exact filtering, normalized results, native event records, and optional coverage.

The target accepts every common Go attribute, the link attributes from go_binary, and these test-specific attributes:

AttributeTypeDefaultDescription
argslist<string>[]Arguments passed to the compiled test binary
test_envmap<string, string>{}Test environment values
env_inheritlist<string>[]Host environment names inherited by the runner
rundirstringemptyPackage-relative working directory for the test binary
labelslist<string>[]Labels exposed through generic test discovery
timeout_msintemptyOptional test timeout in milliseconds
cover_packageslist<string>[]Import path patterns included in coverage instrumentation
fail_fastboolfalseStop after the first failing test
shortboolfalseRequest Go short test mode
countint0Run selected tests this many times when greater than zero
parallelint0Maximum tests run concurrently inside the test binary
shufflestringemptyon, off, or a shuffle seed

Dependency Edges

The target accepts the normal deps, embed, and cdeps roles. Its target_under_test role accepts go_package and composes the Buck2-compatible library or binary sources into the test package.

Providers, Capabilities, and Outputs

The target emits go_package and once_test_info.

CapabilityOutput groupsRequires
buildbinarynone
testdefault, test_results, logs, coveragebinary

The test action writes test_results.json, go-test.log, and native_results.jsonl under .once/out/<target>/test/. With coverage enabled, it also writes coverage.out and records it in the normalized artifacts map. Benchmarks are discovered as skipped units during a normal test run and can be selected exactly later. Test execution requires the host operating system and architecture.

Released under an open-source license.