feat: implement odin_test rule with shared compilation helper#10
Merged
Conversation
- Add odin_test rule: compiles @(test)-annotated Odin sources using 'odin build -build-mode:test', producing a test binary that Bazel's test runner executes (compile at build-time, run at test-time) - Refactor: extract compile_odin_binary() shared helper in common.bzl to eliminate duplication between odin_binary and odin_test - Move OdinLibraryInfo provider to common.bzl to avoid circular deps (library.bzl <-> common.bzl cycle) - Inject ODIN_TEST_FANCY=false by default (CI-friendly, no ANSI escape codes); user can override via defines attr - Test runner config (threads, filtering, memory, etc.) exposed via the defines attr as compile-time constants - Add e2e smoke test: tests/smoke_test.odin exercises arithmetic, string ops, and library imports with @(test) procedures - CI: change 'bazel build' to 'bazel test' in smoke step so odin_test targets are actually executed in the matrix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the
odin_testBazel rule for running Odin's built-in test framework (@(test)-annotated procedures) within Bazel's test infrastructure.Design
odin build -build-mode:testto compile a test binary at build time (cacheable, hermetic)rules_go(go_test) andrules_rust(rust_test)ODIN_TEST_FANCY=falseby default for CI-friendly output (no ANSI escape codes)definesattr (compile-time constants in Odin)Refactoring
Extracts
compile_odin_binary()shared helper incommon.bzlto eliminate code duplication betweenodin_binaryandodin_test. MovesOdinLibraryInfoprovider tocommon.bzlto resolve a circular dependency.Changes
odin/private/common.bzl—OdinLibraryInfo+compile_odin_binary()shared helperodin/private/binary.bzl— Refactored to use shared helperodin/private/library.bzl— ImportsOdinLibraryInfofromcommon.bzlodin/private/test.bzl— New:odin_testrule implementationodin/defs.bzl— Re-exportsodin_testandOdinLibraryInfoe2e/smoke/tests/smoke_test.odin— New: example test (3@(test)procedures)e2e/smoke/BUILD.bazel— Addsodin_testtarget with library deps.github/workflows/check.yaml—bazel build→bazel testin smoke stepREADME.md— Documentsodin_testrule and test runner definesVerification
bazel build //...(ruleset root): PASSESbazel test //...(e2e/smoke):smoke_test PASSED in 0.7sbazel run //:hello(e2e/smoke): binary still works correctlypre-commit run --all-files: all checks pass@change-validator: APPROVED WITH CONCERNS (docs addressed, no blockers)Checklist