[前][次][番号順一覧][スレッド一覧]

ruby-changes:60487

From: Yusuke <ko1@a...>
Date: Tue, 24 Mar 2020 10:56:12 +0900 (JST)
Subject: [ruby-changes:60487] c565dfb09a (master): test/json/test_helper.rb: Do not add a relative path to $LOAD_PATH

https://git.ruby-lang.org/ruby.git/commit/?id=c565dfb09a

From c565dfb09ad7d55fa671f65cea7088a914bf1931 Mon Sep 17 00:00:00 2001
From: Yusuke Endoh <mame@r...>
Date: Tue, 24 Mar 2020 10:45:52 +0900
Subject: test/json/test_helper.rb: Do not add a relative path to $LOAD_PATH

... because it conflicts with test/ruby/test_m17n.rb.

An exception `incompatible character encodings: UTF-8 and UTF-16BE`
occurs when:

* a non-existence relative path is added to $LOAD_PATH,
* ASCII-incompatible encoding is set to default_external, and
* some file is loaded.

```
$LOAD_PATH << "no_existing_dir"
Encoding.default_external = Encoding::UTF_16BE
load "dummy.rb" #=> incompatible character encodings: UTF-8 and UTF-16BE
```

This issue can be actually observed by a combination of out-of-place
build and the following command:

make test-all TESTS="json ruby/m17n -n test_object_inspect_external"

http://ci.rvm.jp/logfiles/brlog.trunk-test-random.20200322-221411

ASCII-incompatible default external encoding assumes that the cwd is the
encoding, and it is attempted to beconcatenated with a non-existence
relative LOAD_PATH UTF-8 string, which causes the exception.

This changeset avoids a relative path.

diff --git a/test/json/test_helper.rb b/test/json/test_helper.rb
index c5ec0fc..446c020 100644
--- a/test/json/test_helper.rb
+++ b/test/json/test_helper.rb
@@ -1,12 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/test/json/test_helper.rb#L1
 case ENV['JSON']
 when 'pure'
-  $:.unshift 'lib'
+  $:.unshift File.join(__dir__, '../lib')
   require 'json/pure'
 when 'ext'
-  $:.unshift 'ext', 'lib'
+  $:.unshift File.join(__dir__, '../ext'), File.join(__dir__, '../lib')
   require 'json/ext'
 else
-  $:.unshift 'ext', 'lib'
+  $:.unshift File.join(__dir__, '../ext'), File.join(__dir__, '../lib')
   require 'json'
 end
 
diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb
index fee3835..2c6dc3f 100644
--- a/test/ruby/test_m17n.rb
+++ b/test/ruby/test_m17n.rb
@@ -311,16 +311,6 @@ class TestM17N < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_m17n.rb#L311
       "abc".encode(Encoding.default_external)
     end
 
-    # debugging code for http://ci.rvm.jp/logfiles/brlog.trunk-test-random.20200322-221411
-    begin
-      "abc".encode(Encoding.default_external)
-    rescue Encoding::CompatibilityError
-      TracePoint.new(:raise) do |tp|
-        Process.kill(:SEGV, $$)
-      end.enable { "abc".encode(Encoding.default_external) }
-    end
-    # debugging code end
-
     assert_equal '[abc]', [o].inspect
 
     Encoding.default_external = Encoding::US_ASCII
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]