From 6f6a4cdfd793abb6e5748a26dcbdddf61490ffbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Barri=C3=A9?= Date: Mon, 15 Sep 2025 16:26:43 +0200 Subject: [PATCH] Better handle missing ostruct In the Ruby test suite, this test class is causing trouble because ostruct is not available. Having an autoload for JSON::GenericObject but causing it not to define the constant causes a warning. See 0dc1cd407e7775610f2bcaef6c1282369867f91c and caa5d8cdd7483647013af5e3d1701b0ed3ec8785 in ruby. We can skip defining the test class entirely instead when ostruct is not available. --- test/json/json_generic_object_test.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/json/json_generic_object_test.rb b/test/json/json_generic_object_test.rb index 333da704..57e3bf3c 100644 --- a/test/json/json_generic_object_test.rb +++ b/test/json/json_generic_object_test.rb @@ -1,8 +1,14 @@ # frozen_string_literal: true require_relative 'test_helper' -class JSONGenericObjectTest < Test::Unit::TestCase +# ostruct is required to test JSON::GenericObject +begin + require "ostruct" +rescue LoadError + return +end +class JSONGenericObjectTest < Test::Unit::TestCase def setup if defined?(JSON::GenericObject) @go = JSON::GenericObject[ :a => 1, :b => 2 ]