[ruby/yarp] Set default external encoding for parse tests
https://github.com/ruby/yarp/commit/e757fde3ed
This commit is contained in:
parent
2beb14506f
commit
010b8a29dc
@ -3,6 +3,19 @@
|
|||||||
require "yarp_test_helper"
|
require "yarp_test_helper"
|
||||||
|
|
||||||
class ParseTest < Test::Unit::TestCase
|
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
|
def test_Ruby_3_2_plus
|
||||||
assert_operator RUBY_VERSION, :>=, "3.2.0", "ParseTest requires Ruby 3.2+"
|
assert_operator RUBY_VERSION, :>=, "3.2.0", "ParseTest requires Ruby 3.2+"
|
||||||
end
|
end
|
||||||
@ -48,24 +61,6 @@ class ParseTest < Test::Unit::TestCase
|
|||||||
assert_equal filepath, find_source_file_node(parsed_result.value).filepath
|
assert_equal filepath, find_source_file_node(parsed_result.value).filepath
|
||||||
end
|
end
|
||||||
|
|
||||||
# We have some files that are failing on other systems because of default
|
|
||||||
# encoding. We'll fix these ASAP.
|
|
||||||
FAILING = %w[
|
|
||||||
seattlerb/bug202.txt
|
|
||||||
seattlerb/dsym_esc_to_sym.txt
|
|
||||||
seattlerb/heredoc_bad_oct_escape.txt
|
|
||||||
seattlerb/magic_encoding_comment.txt
|
|
||||||
seattlerb/read_escape_unicode_curlies.txt
|
|
||||||
seattlerb/read_escape_unicode_h4.txt
|
|
||||||
seattlerb/regexp_escape_extended.txt
|
|
||||||
seattlerb/regexp_unicode_curlies.txt
|
|
||||||
seattlerb/str_evstr_escape.txt
|
|
||||||
seattlerb/str_lit_concat_bad_encodings.txt
|
|
||||||
symbols.txt
|
|
||||||
whitequark/bug_ascii_8bit_in_literal.txt
|
|
||||||
whitequark/dedenting_heredoc.txt
|
|
||||||
]
|
|
||||||
|
|
||||||
Dir[File.expand_path("fixtures/**/*.txt", __dir__)].each do |filepath|
|
Dir[File.expand_path("fixtures/**/*.txt", __dir__)].each do |filepath|
|
||||||
relative = filepath.delete_prefix("#{File.expand_path("fixtures", __dir__)}/")
|
relative = filepath.delete_prefix("#{File.expand_path("fixtures", __dir__)}/")
|
||||||
next if known_failures.include?(relative)
|
next if known_failures.include?(relative)
|
||||||
@ -75,12 +70,6 @@ class ParseTest < Test::Unit::TestCase
|
|||||||
FileUtils.mkdir_p(directory) unless File.directory?(directory)
|
FileUtils.mkdir_p(directory) unless File.directory?(directory)
|
||||||
|
|
||||||
define_method "test_filepath_#{filepath}" do
|
define_method "test_filepath_#{filepath}" do
|
||||||
if (ENV.key?("RUBYCI_NICKNAME") || ENV["RUBY_DEBUG"] =~ /ci/) && FAILING.include?(relative)
|
|
||||||
# http://rubyci.s3.amazonaws.com/solaris10-gcc/ruby-master/log/20230621T190004Z.fail.html.gz
|
|
||||||
# http://ci.rvm.jp/results/trunk-yjit@ruby-sp2-docker/4612202
|
|
||||||
omit "Not working on RubyCI and ci.rvm.jp"
|
|
||||||
end
|
|
||||||
|
|
||||||
# First, read the source from the filepath. Use binmode to avoid converting CRLF on Windows,
|
# First, read the source from the filepath. Use binmode to avoid converting CRLF on Windows,
|
||||||
# and explicitly set the external encoding to UTF-8 to override the binmode default.
|
# and explicitly set the external encoding to UTF-8 to override the binmode default.
|
||||||
source = File.read(filepath, binmode: true, external_encoding: Encoding::UTF_8)
|
source = File.read(filepath, binmode: true, external_encoding: Encoding::UTF_8)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user