Skip to content

Commit 643364e

Browse files
luke-gruberpeterzhu2118
authored andcommitted
test_all_ractors: fix some JSON tests
1 parent 986fd32 commit 643364e

4 files changed

Lines changed: 17 additions & 10 deletions

File tree

test/json/json_common_interface_test.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ def o.to_s
118118
end
119119

120120
def test_load
121+
pend "Tempfile" if non_main_ractor?
121122
assert_equal @hash, JSON.load(@json)
122123
tempfile = Tempfile.open('@json')
123124
tempfile.write @json
@@ -129,7 +130,7 @@ def test_load
129130
assert_equal nil, JSON.load(nil)
130131
assert_equal nil, JSON.load('')
131132
ensure
132-
tempfile.close!
133+
tempfile&.close!
133134
end
134135

135136
def test_load_with_proc

test/json/json_fixtures_test.rb

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,23 @@ class JSONFixturesTest < Test::Unit::TestCase
77

88
passed.each do |f|
99
name = File.basename(f).gsub(".", "_")
10-
source = File.read(f)
11-
define_method("test_#{name}") do
12-
assert JSON.parse(source), "Did not pass for fixture '#{File.basename(f)}': #{source.inspect}"
10+
class_eval <<-RUBY, __FILE__, __LINE__+1
11+
def test_#{name}
12+
assert JSON.parse(File.read(#{f.inspect})), "Did not pass for fixture '#{File.basename(f)}': \#{File.read(#{f.inspect})}"
1313
end
14+
RUBY
1415
end
1516

1617
failed.each do |f|
1718
name = File.basename(f).gsub(".", "_")
18-
source = File.read(f)
19-
define_method("test_#{name}") do
20-
assert_raise(JSON::ParserError, JSON::NestingError,
21-
"Did not fail for fixture '#{name}': #{source.inspect}") do
22-
JSON.parse(source)
19+
class_eval <<-RUBY, __FILE__, __LINE__+1
20+
def test_#{name}
21+
source = File.read(#{f.inspect})
22+
assert_raise(JSON::ParserError, JSON::NestingError,
23+
"Did not fail for fixture '#{name}': \#{source.inspect}") do
24+
JSON.parse(source)
25+
end
2326
end
24-
end
27+
RUBY
2528
end
2629
end

test/ruby/test_beginendblock.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ def test_errinfo_at_exit
165165

166166
if defined?(fork)
167167
def test_internal_errinfo_at_exit
168+
omit "at_exit handlers cannot use ractor-local objects" if non_main_ractor?
168169
# TODO: use other than break-in-fork to throw an internal
169170
# error info.
170171
error, pid, status = IO.pipe do |r, w|

test/ruby/test_exception.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ def test_uncaught_throw
244244
end
245245

246246
def test_catch_throw_in_require
247+
pend "Tempfile"
247248
bug7185 = '[ruby-dev:46234]'
248249
Tempfile.create(["dep", ".rb"]) {|t|
249250
t.puts("throw :extdep, 42")
@@ -253,6 +254,7 @@ def test_catch_throw_in_require
253254
end
254255

255256
def test_catch_throw_in_require_cant_be_rescued
257+
pend "Tempfile"
256258
bug18562 = '[ruby-core:107403]'
257259
Tempfile.create(["dep", ".rb"]) {|t|
258260
t.puts("throw :extdep, 42")

0 commit comments

Comments
 (0)