diff --git a/crates/rb-sys-test-helpers/src/ruby_test_executor.rs b/crates/rb-sys-test-helpers/src/ruby_test_executor.rs index 94de39e3..ee718bb7 100644 --- a/crates/rb-sys-test-helpers/src/ruby_test_executor.rs +++ b/crates/rb-sys-test-helpers/src/ruby_test_executor.rs @@ -47,13 +47,15 @@ impl RubyTestExecutor { timeout: Duration::from_secs(10), }; - executor.run(|| { - static INIT: Once = Once::new(); + executor + .run(|| { + static INIT: Once = Once::new(); - INIT.call_once(|| unsafe { - setup_ruby_unguarded(); - }); - }); + INIT.call_once(|| unsafe { + setup_ruby_unguarded(); + }) + }) + .expect("Failed to setup Ruby"); executor } @@ -65,7 +67,7 @@ impl RubyTestExecutor { pub fn shutdown(&mut self) { self.set_test_timeout(Duration::from_secs(3)); - self.run(|| unsafe { + let _ = self.run(|| unsafe { cleanup_ruby(); }); diff --git a/crates/rb-sys-tests/Cargo.toml b/crates/rb-sys-tests/Cargo.toml index 5dd261a6..195531af 100644 --- a/crates/rb-sys-tests/Cargo.toml +++ b/crates/rb-sys-tests/Cargo.toml @@ -15,6 +15,7 @@ doc = false rb-sys = { path = "../rb-sys", features = [ "link-ruby", "stable-api-compiled-testing", + "rb-gc-guard", ] } rb-sys-env = { path = "../rb-sys-env" } rb-sys-test-helpers = { path = "../rb-sys-test-helpers" } diff --git a/crates/rb-sys/Cargo.toml b/crates/rb-sys/Cargo.toml index f98158b6..cd081c69 100644 --- a/crates/rb-sys/Cargo.toml +++ b/crates/rb-sys/Cargo.toml @@ -18,6 +18,7 @@ rb-sys-build = { version = "0.9.79", path = "../rb-sys-build" } [dev-dependencies] rb-sys = { path = ".", features = [ + "rb-gc-guard", "link-ruby", "stable-api-compiled-fallback", ] } @@ -37,6 +38,7 @@ stable-api-compiled-testing = [ ] # For testing the fallback in rb-sys (internal) stable-api-compiled-force = [] # Always use the compiled C API ruby-macros = ["stable-api"] # deprecated +rb-gc-guard = [] # Needs asm features Rust 1.59+ bindgen-rbimpls = ["rb-sys-build/bindgen-rbimpls"] bindgen-deprecated-types = ["rb-sys-build/bindgen-deprecated-types"] bindgen-layout-tests = ["rb-sys-build/bindgen-layout-tests"] diff --git a/crates/rb-sys/src/stable_api.rs b/crates/rb-sys/src/stable_api.rs index 045e6608..aef1dca0 100644 --- a/crates/rb-sys/src/stable_api.rs +++ b/crates/rb-sys/src/stable_api.rs @@ -150,7 +150,7 @@ pub const fn get_default() -> &'static api::Definition { /// Get the fallback stable API definition for the current Ruby version, which /// is compiled C code that is linked into to this crate. -#[cfg(all(stable_api_enable_compiled_mod))] +#[cfg(stable_api_enable_compiled_mod)] pub const fn get_compiled() -> &'static compiled::Definition { const COMPILED_API: compiled::Definition = compiled::Definition {}; &COMPILED_API