Skip to content

Commit

Permalink
test/json/test_helper.rb: Do not add a relative path to $LOAD_PATH
Browse files Browse the repository at this point in the history
... 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.
  • Loading branch information
mame committed Mar 24, 2020
1 parent 13e9551 commit c565dfb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
6 changes: 3 additions & 3 deletions test/json/test_helper.rb
@@ -1,12 +1,12 @@
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

Expand Down
10 changes: 0 additions & 10 deletions test/ruby/test_m17n.rb
Expand Up @@ -311,16 +311,6 @@ def o.inspect
"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
Expand Down

0 comments on commit c565dfb

Please sign in to comment.