diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c9422e0d..27171b90 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: - run: rake compile - - run: rake test + - run: rake test JSON_COMPACT=1 - run: rake build @@ -78,4 +78,4 @@ jobs: - run: rake compile - - run: rake valgrind + - run: rake valgrind JSON_COMPACT=1 diff --git a/test/json/test_helper.rb b/test/json/test_helper.rb index 11bb8ba8..d849e28b 100644 --- a/test/json/test_helper.rb +++ b/test/json/test_helper.rb @@ -3,21 +3,23 @@ require 'json' require 'test/unit' -if GC.respond_to?(:verify_compaction_references) - # This method was added in Ruby 3.0.0. Calling it this way asks the GC to - # move objects around, helping to find object movement bugs. - begin - GC.verify_compaction_references(expand_heap: true, toward: :empty) - rescue NotImplementedError, ArgumentError - # Some platforms don't support compaction +if ENV["JSON_COMPACT"] + if GC.respond_to?(:verify_compaction_references) + # This method was added in Ruby 3.0.0. Calling it this way asks the GC to + # move objects around, helping to find object movement bugs. + begin + GC.verify_compaction_references(expand_heap: true, toward: :empty) + rescue NotImplementedError, ArgumentError + # Some platforms don't support compaction + end end -end -if GC.respond_to?(:auto_compact=) - begin - GC.auto_compact = true - rescue NotImplementedError - # Some platforms don't support compaction + if GC.respond_to?(:auto_compact=) + begin + GC.auto_compact = true + rescue NotImplementedError + # Some platforms don't support compaction + end end end