From 48b241e53fdb68c0ad115bcd23a43b310cc18db1 Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Wed, 16 Aug 2023 21:12:44 -0400 Subject: [PATCH] [ruby/yarp] Fix errors on locals test caused by LANG=C https://github.com/ruby/yarp/commit/8fae286bc9 --- test/yarp/locals_test.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/yarp/locals_test.rb b/test/yarp/locals_test.rb index d6b3120f62..4d9cea94a8 100644 --- a/test/yarp/locals_test.rb +++ b/test/yarp/locals_test.rb @@ -77,6 +77,15 @@ class LocalsTest < Test::Unit::TestCase define_method("test_#{relative}") { assert_locals(filepath) } end + def setup + @previous_default_external = Encoding.default_external + ignore_warnings { Encoding.default_external = Encoding::UTF_8 } + end + + def teardown + ignore_warnings { Encoding.default_external = @previous_default_external } + end + private def assert_locals(filepath) @@ -87,4 +96,12 @@ class LocalsTest < Test::Unit::TestCase assert_equal(expected, actual) end + + def ignore_warnings + previous_verbosity = $VERBOSE + $VERBOSE = nil + yield + ensure + $VERBOSE = previous_verbosity + end end