Skip to content

Commit f099af0

Browse files
luke-gruberpeterzhu2118
authored andcommitted
tmp commit for test_all_ractors_multi_ractor
1 parent e089a26 commit f099af0

6 files changed

Lines changed: 37 additions & 13 deletions

File tree

test/ruby/test_assignment.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ def []=(i, a); 42; end
316316
end
317317

318318
def test_yield
319+
omit "lots of undefs" unless main_ractor?
319320
def f; yield(nil); end; f {|a| assert_nil(a)}; undef f
320321
def f; yield(1); end; f {|a| assert_equal(1, a)}; undef f
321322
def f; yield([]); end; f {|a| assert_equal([], a)}; undef f
@@ -372,6 +373,7 @@ def f; yield(*[*[1,2]]); end; f {|a,b,*c| assert_equal([1,2,[]], [a,b,c])}; unde
372373
end
373374

374375
def test_return
376+
omit "lots of undefs" unless main_ractor?
375377
def r; return; end; a = r(); assert_nil(a); undef r
376378
def r; return nil; end; a = r(); assert_nil(a); undef r
377379
def r; return 1; end; a = r(); assert_equal(1, a); undef r
@@ -556,6 +558,7 @@ def test_break
556558
end
557559

558560
def test_next
561+
omit "lots of undefs" unless main_ractor?
559562
def r(val); a = yield(); assert_equal(val, a); end
560563
r(nil){next}
561564
r(nil){next nil}

test/ruby/test_bignum.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ def test_bignum
7474
x = fact(40)
7575
assert_equal(x, x)
7676
assert_equal(x, fact(40))
77-
assert_operator(x, :<, $x+2)
78-
assert_operator(x, :>, $x-2)
77+
assert_operator(x, :<, x+2)
78+
assert_operator(x, :>, x-2)
7979
assert_equal(815915283247897734345611269596115894272000000000, x)
8080
assert_not_equal(815915283247897734345611269596115894272000000001, x)
8181
assert_equal(815915283247897734345611269596115894272000000001, x+1)

test/ruby/test_dir.rb

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ def test_rewind
9797
end
9898

9999
def test_class_chdir
100+
omit "not ractor safe" unless main_ractor?
100101
pwd = Dir.pwd
101102
setup_envs
102103

@@ -129,13 +130,14 @@ def test_class_chdir
129130

130131
ensure
131132
begin
132-
Dir.chdir(pwd)
133+
Dir.chdir(pwd) if pwd
133134
rescue
134135
abort("cannot return the original directory: #{ pwd }")
135136
end
136137
end
137138

138139
def test_instance_chdir
140+
omit "not ractor safe" unless main_ractor?
139141
pwd = Dir.pwd
140142
dir = Dir.new(pwd)
141143
root_dir = Dir.new(@root)
@@ -194,15 +196,16 @@ def Warning.warn(message)
194196
assert_equal(42, ret)
195197
ensure
196198
begin
197-
assert_equal(0, dir.chdir)
199+
assert_equal(0, dir.chdir) if dir
198200
rescue
199201
abort("cannot return the original directory: #{ pwd }")
200202
end
201-
dir.close
202-
root_dir.close
203+
dir&.close
204+
root_dir&.close
203205
end
204206

205207
def test_chdir_conflict
208+
omit "not ractor safe" unless main_ractor?
206209
pwd = Dir.pwd
207210
q = Thread::Queue.new
208211
t = Thread.new do
@@ -279,6 +282,7 @@ def test_glob
279282
end
280283

281284
def test_glob_recursive
285+
omit "not ractor safe" unless main_ractor?
282286
bug6977 = '[ruby-core:47418]'
283287
bug8006 = '[ruby-core:53108] [Bug #8006]'
284288
Dir.chdir(@root) do
@@ -308,6 +312,7 @@ def test_glob_recursive
308312
end
309313

310314
def test_glob_recursive_directory
315+
omit "not ractor safe" unless main_ractor?
311316
Dir.chdir(@root) do
312317
['d', 'e'].each do |path|
313318
FileUtils.mkdir_p("c/#{path}/a/b/c")
@@ -325,6 +330,7 @@ def test_glob_recursive_directory
325330
end
326331

327332
def test_glob_starts_with_brace
333+
omit "not ractor safe" unless main_ractor?
328334
Dir.chdir(@root) do
329335
bug15649 = '[ruby-core:91728] [Bug #15649]'
330336
assert_equal(["#{@root}/a", "#{@root}/b"],
@@ -333,6 +339,7 @@ def test_glob_starts_with_brace
333339
end
334340

335341
def test_glob_recursive_with_brace
342+
omit "not ractor safe" unless main_ractor?
336343
Dir.chdir(@root) do
337344
bug19042 = '[ruby-core:110220] [Bug #19042]'
338345
%w"c/dir_a c/dir_b c/dir_b/dir".each do |d|
@@ -347,6 +354,7 @@ def test_glob_recursive_with_brace
347354
end
348355

349356
def test_glob_order
357+
omit "not ractor safe" unless main_ractor?
350358
Dir.chdir(@root) do
351359
assert_equal(["#{@root}/a", "#{@root}/b"], Dir.glob("#{@root}/[ba]"))
352360
assert_equal(["#{@root}/b", "#{@root}/a"], Dir.glob(%W"#{@root}/b #{@root}/a"))
@@ -376,6 +384,7 @@ def test_glob_too_may_open_files
376384
end
377385

378386
def test_glob_base
387+
omit "not ractor safe (Dir.chdir)" unless main_ractor?
379388
files = %w[a/foo.c c/bar.c]
380389
files.each {|n| File.write(File.join(@root, n), "")}
381390
Dir.mkdir(File.join(@root, "a/dir"))
@@ -416,6 +425,7 @@ def test_glob_base
416425
end
417426

418427
def test_glob_base_dir
428+
omit "not ractor safe" unless main_ractor?
419429
files = %w[a/foo.c c/bar.c]
420430
files.each {|n| File.write(File.join(@root, n), "")}
421431
Dir.mkdir(File.join(@root, "a/dir"))
@@ -438,6 +448,7 @@ def test_glob_base_dir
438448
end
439449

440450
def test_glob_ignore_casefold_invalid_encoding
451+
omit "not ractor safe" unless main_ractor?
441452
bug14456 = "[ruby-core:85448]"
442453
filename = "\u00AAa123".encode('ISO-8859-1')
443454
File.write(File.join(@root, filename), "")
@@ -555,6 +566,7 @@ def test_glob_metachar
555566
end
556567

557568
def test_glob_cases
569+
omit "not ractor safe (Dir.chdir)" unless main_ractor?
558570
feature5994 = "[ruby-core:42469] [Feature #5994]"
559571
feature5994 << "\nDir.glob should return the filename with actual cases on the filesystem"
560572
Dir.chdir(File.join(@root, "a")) do
@@ -659,6 +671,7 @@ def test_children_long_name
659671
end
660672

661673
def test_home
674+
omit "not ractor safe" unless main_ractor?
662675
setup_envs
663676

664677
ENV["HOME"] = @nodir
@@ -690,6 +703,7 @@ def test_home_utf8
690703
end
691704

692705
def test_symlinks_not_resolved
706+
omit "not ractors safe (Dir.chdir)" unless main_ractor?
693707
Dir.mktmpdir do |dirname|
694708
Dir.chdir(dirname) do
695709
begin
@@ -718,6 +732,7 @@ def test_fileno
718732
end
719733

720734
def test_for_fd
735+
omit "not ractor safe" unless main_ractor?
721736
if Dir.respond_to? :for_fd
722737
begin
723738
new_dir = Dir.new('..')

test/ruby/test_fiber.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ def test_prohibit_resume_to_transferring_fiber
395395

396396
def test_fork_from_fiber
397397
omit 'fork not supported' unless Process.respond_to?(:fork)
398+
omit "maybe fork not supported unless main ractor" unless main_ractor?
398399
pid = nil
399400
bug5700 = '[ruby-core:41456]'
400401
assert_nothing_raised(bug5700) do

test/ruby/test_proc.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,12 @@ def test_hash_equal
172172

173173
assert_equal p1.hash, p2.hash
174174

175-
# symbol backed proc
176-
p1 = :hello.to_proc
177-
p2 = :hello.to_proc
178-
179-
assert_equal p1.hash, p2.hash
175+
if main_ractor?
176+
# symbol backed proc
177+
p1 = :hello.to_proc
178+
p2 = :hello.to_proc
179+
assert_equal p1.hash, p2.hash
180+
end
180181
end
181182

182183
def test_hash_uniqueness

tool/lib/test/unit.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,7 +1716,7 @@ def _run_suite suite, type
17161716
self.assertion_count = 0
17171717
self.test_count = 0
17181718
rs = run_tests_inside_ractors_num.times.map do
1719-
r = Ractor.new(inst, self) do |instance, runner|
1719+
Ractor.new(inst, self) do |instance, runner|
17201720
res = instance.run runner
17211721
testcase_copyable_ivars = {:@_assertions => true, :@__passed__ => true, :@__name__ => true}
17221722
runner_copyable_ivars = {:@report => true, :@failures => true, :@errors => true, :@skips => true, :@assertion_count => true, :@test_count => true}
@@ -1849,7 +1849,11 @@ def _run args = []
18491849
self.options.merge! args
18501850

18511851
puts "Run options: #{help}"
1852-
puts "\nNOTE: Running tests inside ractors" if ENV["RUBY_TESTS_WITH_RACTORS"]
1852+
ractors_num = ENV["RUBY_TESTS_WITH_RACTORS"].to_i
1853+
1854+
if ractors_num > 0
1855+
puts "\nNOTE: Running tests inside ractors (each test method inside #{ractors_num} ractors)"
1856+
end
18531857

18541858
self.class.plugins.each do |plugin|
18551859
send plugin

0 commit comments

Comments
 (0)