Skip to content

Conversation

@ianks
Copy link
Collaborator

@ianks ianks commented Dec 14, 2025

Summary

  • Fix undefined behavior in protect(): Panics inside protect() were trying to unwind through an extern "C" FFI boundary, causing process abort with no readable output. Added catch_unwind to catch panics before they cross the FFI boundary, then re-throw them after rb_protect returns.

  • Ergonomic improvements for test helpers:

    • Implement Display and Error traits for RubyException, allowing use with ? operator
    • Add Result support to #[ruby_test] macro so tests can return Result<(), E>
    • Add GcStressGuard for RAII-style scoped GC stress testing
    • Fix RUST_BACKTRACE check to support "full" in addition to "1"

Breaking Changes

Version bumped from 0.2.2 to 0.3.0 due to API additions and behavioral changes.

Panics inside protect() were trying to unwind through an extern "C" FFI
boundary, causing undefined behavior and process abort with no readable
output. Added catch_unwind inside ffi_closure to catch panics before
they cross the FFI boundary, then re-throw them after rb_protect returns.

This ensures panics are properly propagated with readable error messages
instead of causing silent process aborts.
This allows RubyException to be used with the ? operator and converted
to Box<dyn Error>, making it more ergonomic to use in Result-returning
functions.
Tests can now return Result<(), E> and use the ? operator for more
ergonomic error handling. The macro detects Result return types and
properly propagates both Ruby exceptions and Rust errors.
Changed the check to also support "full" in addition to "1" for
displaying Ruby exception backtraces.
Added a new public struct that enables GC stress mode and restores the
previous value when dropped. Refactored with_gc_stress to use it,
ensuring GC stress is properly restored even when panics occur.
Bumped both rb-sys-test-helpers and rb-sys-test-helpers-macros from
0.2.2 to 0.3.0 to reflect the new features and breaking changes.
Removed the shellHook that automatically exec'd zsh, allowing users to
use their preferred shell.
@ianks ianks force-pushed the test-helpers-0.3.0 branch from 7625fcb to 5520111 Compare December 14, 2025 05:48
@ianks ianks changed the title Release rb-sys-test-helpers 0.3.0 New features for rb-sys-test-helpers 0.3.0 Dec 14, 2025
@ianks ianks merged commit 761c06d into main Dec 14, 2025
61 checks passed
@ianks ianks deleted the test-helpers-0.3.0 branch December 14, 2025 06:13
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.

2 participants