Skip to content

test: add failure propagation e2e test for odin_test#11

Merged
clappingmonkey merged 1 commit into
mainfrom
feat/odin-test-negative
Jul 9, 2026
Merged

test: add failure propagation e2e test for odin_test#11
clappingmonkey merged 1 commit into
mainfrom
feat/odin-test-negative

Conversation

@clappingmonkey

Copy link
Copy Markdown
Owner

Summary

Adds a negative e2e test that validates odin_test correctly propagates non-zero exit codes from failing @(test) procedures to Bazel's test infrastructure.

Architecture

Follows the rules_rust pattern (one workspace per e2e scenario):

e2e/failure_propagation/
  MODULE.bazel              # separate workspace with local_path_override
  BUILD.bazel               # odin_test(manual) + sh_test
  tests_fail/
    failing_test.odin       # @(test) with intentional failure (1+1==3)
  check_exit_code.sh        # runs binary via runfiles, asserts exit != 0

How it works

  1. odin_test(name = "should_fail", tags = ["manual"]) — compiled but never auto-run by bazel test //...
  2. sh_test(name = "failure_propagation_test") — executes the binary directly (no Bazel-in-Bazel)
  3. Uses rlocationpath + runfiles.bash v3 for cross-platform binary path resolution
  4. Asserts the binary exits non-zero → PASS; exits zero → FAIL

Cross-platform

  • rules_shell v0.8.0 for sh_test (required since Bazel 9.x removed native sh_test)
  • @rules_shell//shell/runfiles for portable path resolution
  • Works on Linux, macOS, and Windows (GitHub Actions runners have Git Bash)

CI

Adds a new step to the test matrix: "Failure propagation test (e2e)" — runs bazel test //... in e2e/failure_propagation/ across all 4 OS × 3 Bazel combinations.

Verification

  • bazel test //... in e2e/failure_propagation: PASSED locally
  • pre-commit run --all-files: all checks pass
  • Root ruleset bazel build //...: unaffected (.bazelignore updated)

Checklist

  • Conventional commit title
  • Tests pass locally
  • Pre-commit hooks pass
  • Follows rules_rust e2e workspace pattern (separate workspace per scenario)

Validates that odin_test correctly propagates non-zero exit codes from
failing @(test) procedures to Bazel's test infrastructure.

Architecture (follows rules_rust pattern):
- Separate e2e workspace (e2e/failure_propagation/) with own MODULE.bazel
- odin_test target tagged 'manual' (intentionally failing: 1+1==3)
- sh_test executes the compiled binary directly via runfiles and asserts
  non-zero exit code (no Bazel-in-Bazel subprocess)
- Uses rules_shell + rlocationpath for cross-platform binary resolution

CI: adds failure_propagation step to the test matrix (4 OS × 3 Bazel).
@clappingmonkey clappingmonkey merged commit d36a3c6 into main Jul 9, 2026
14 checks passed
@clappingmonkey clappingmonkey deleted the feat/odin-test-negative branch July 9, 2026 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant