From edd488109fe8a95ec8674886905fe503fc0f9108 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Thu, 22 Jun 2023 08:59:04 -0700 Subject: [PATCH] Sync ruby/yarp with sync_default_gems --- test/yarp/parse_test.rb | 16 ++-------------- yarp/extension.c | 1 - 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/test/yarp/parse_test.rb b/test/yarp/parse_test.rb index 098ce7b3fc..33f78bda8c 100644 --- a/test/yarp/parse_test.rb +++ b/test/yarp/parse_test.rb @@ -3,19 +3,6 @@ require "yarp_test_helper" class ParseTest < Test::Unit::TestCase - # Because we're reading the snapshots from disk, we need to make sure that - # they're encoded as UTF-8. When certain settings are present this might not - # always be the case (e.g., LANG=C or -Eascii-8bit). So here we force the - # default external encoding for the duration of the test. - def setup - @previous_default_external = Encoding.default_external - Encoding.default_external = Encoding::UTF_8 - end - - def teardown - Encoding.default_external = @previous_default_external - end - def test_Ruby_3_2_plus assert_operator RUBY_VERSION, :>=, "3.2.0", "ParseTest requires Ruby 3.2+" end @@ -34,6 +21,7 @@ class ParseTest < Test::Unit::TestCase # and the line breaks based on the length of the path. def normalize_printed(printed) printed + .b .gsub( /SourceFileNode \s* \(\s* (\d+\.\.\.\d+) \s*\) \s* @@ -87,7 +75,7 @@ class ParseTest < Test::Unit::TestCase assert_empty result.errors, value if File.exist?(snapshot) - normalized = normalize_printed(File.read(snapshot)) + normalized = normalize_printed(File.binread(snapshot)) # If the snapshot file exists, but the printed value does not match the # snapshot, then update the snapshot file. diff --git a/yarp/extension.c b/yarp/extension.c index 9574916f1a..2cec9814b1 100644 --- a/yarp/extension.c +++ b/yarp/extension.c @@ -72,7 +72,6 @@ source_file_load(source_t *source, VALUE filepath) { #ifdef HAVE_MMAP if (!source->size) { - close(fd); source->source = ""; return 0; }