Skip to content

Commit c25554d

Browse files
committed
Change test-all suite to enable running each test in separate ractors.
This tests for ractor safety issues as well as concurrency issues. You can enable these tests with RUBY_TESTS_WITH_RACTORS=X when running `make test-all TESTS=test/ruby`. Running tests with ractors is currently only working for tests under the "test/ruby" directory. You should also use the `.excludes-ractor` excludes directory. For example: ``` EXCLUDES=test/.excludes-ractor RUBY_TESTS_WITH_RACTORS=3 TESTS=test/ruby make test-all ``` This will create 3 ractors for each test method, run the test method inside each ractor and then call `join` on the ractors. Then, it's ready to process the next test. The reason we do this instead of taking all the tests and dividing them between the number of ractors is: * We want to run each test under concurrency load to test whether or not it is safe under ractors. If it isn't safe, we know it's something to do with this specific test. * If we get a segfault or error, we know the error is coming from this test alone, not interactions with other tests. The disadvantage of this approach is: * It's slower than dividing the tests between the number of ractors running. * This might not uncover ractor scheduling issues that would show up when you have long-running ractors.
1 parent ba52af6 commit c25554d

File tree

169 files changed

+1785
-832
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+1785
-832
lines changed

ext/-test-/file/fs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ get_noatime_p(VALUE self, VALUE str)
105105
void
106106
Init_fs(VALUE module)
107107
{
108+
#ifdef HAVE_RB_EXT_RACTOR_SAFE
109+
rb_ext_ractor_safe(true);
110+
#endif
108111
VALUE fs = rb_define_module_under(module, "Fs");
109112
rb_define_module_function(fs, "fsname", get_fsname, 1);
110113
rb_define_module_function(fs, "noatime?", get_noatime_p, 1);

ext/-test-/integer/init.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
void
66
Init_integer(void)
77
{
8+
#ifdef HAVE_RB_EXT_RACTOR_SAFE
9+
rb_ext_ractor_safe(true);
10+
#endif
811
VALUE mBug = rb_define_module("Bug");
912
VALUE klass = rb_define_class_under(mBug, "Integer", rb_cObject);
1013
TEST_INIT_FUNCS(init);

ext/-test-/iter/break.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ iter_break_value(VALUE self, VALUE val)
1919
void
2020
Init_break(VALUE klass)
2121
{
22+
#ifdef HAVE_RB_EXT_RACTOR_SAFE
23+
// Mark this extension as Ractor-safe.
24+
rb_ext_ractor_safe(true);
25+
#endif
2226
VALUE breakable = rb_define_module_under(klass, "Breakable");
2327
rb_define_module_function(breakable, "iter_break", iter_break, 0);
2428
rb_define_module_function(breakable, "iter_break_value", iter_break_value, 1);

ext/-test-/iter/init.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
void
66
Init_iter(void)
77
{
8+
9+
#ifdef HAVE_RB_EXT_RACTOR_SAFE
10+
// Mark this extension as Ractor-safe.
11+
rb_ext_ractor_safe(true);
12+
#endif
813
VALUE mBug = rb_define_module("Bug");
914
VALUE klass = rb_define_module_under(mBug, "Iter");
1015
TEST_INIT_FUNCS(init);

ext/-test-/iter/yield.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ yield_block(int argc, VALUE *argv, VALUE self)
1010
void
1111
Init_yield(VALUE klass)
1212
{
13+
14+
#ifdef HAVE_RB_EXT_RACTOR_SAFE
15+
// Mark this extension as Ractor-safe.
16+
rb_ext_ractor_safe(true);
17+
#endif
1318
VALUE yield = rb_define_module_under(klass, "Yield");
1419

1520
rb_define_method(yield, "yield_block", yield_block, -1);

ext/-test-/rb_call_super_kw/rb_call_super_kw.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ rb_call_super_kw_m(int argc, VALUE *argv, VALUE self)
99
void
1010
Init_rb_call_super_kw(void)
1111
{
12+
#ifdef HAVE_RB_EXT_RACTOR_SAFE
13+
// Mark this extension as Ractor-safe.
14+
rb_ext_ractor_safe(true);
15+
#endif
1216
VALUE module = rb_define_module("Bug");
1317
module = rb_define_module_under(module, "RbCallSuperKw");
1418
rb_define_method(module, "m", rb_call_super_kw_m, -1);

ext/-test-/stack/stack.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ asan_p(VALUE klass)
3030
void
3131
Init_stack(VALUE klass)
3232
{
33+
#ifdef HAVE_RB_EXT_RACTOR_SAFE
34+
RB_EXT_RACTOR_SAFE(true);
35+
#endif
3336
rb_define_singleton_method(rb_cThread, "alloca_overflow", stack_alloca_overflow, 0);
3437
rb_define_singleton_method(rb_cThread, "asan?", asan_p, 0);
3538
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Prism::TestCompilePrism#test_repeated_proc_params../ruby/st.c:2621: Assertion Failed: set_rebuild_table_with:new_tab->num_entries == tab->num_entries
2+
exclude(/^test_/, "FIXME: bug. Skip all tests for now")
3+
4+
exclude(/^test_GlobalVariable/, "global variables")
5+
exclude(:test_ClassVariableTargetNode, "class variables")
6+
exclude(:test_ClassVariableAndWriteNode, "class variables")
7+
exclude(:test_ClassVariableOperatorWriteNode, "class variables")
8+
exclude(:test_ClassVariableOrWriteNode, "class variables")
9+
exclude(:test_ClassVariableWriteNode, "class variables")
10+
exclude(:test_ConstantWriteNode, "global side effects")
11+
exclude(:test_InstanceVariableTargetNode, "class ivars")
12+
exclude(:test_InstanceVariableReadNode, "class ivars")
13+
exclude(:test_InstanceVariableWriteNode, "class ivars")
14+
exclude(:test_EmbeddedVariableNode, "class ivars")
15+
exclude(:test_InterpolatedMatchLastLineNode, "global variables")
16+
exclude(:test_InterpolatedRegularExpressionNode, "global variables")
17+
exclude(:test_InterpolatedStringNode, "global variables")
18+
exclude(:test_InterpolatedSymbolNode, "global variables")
19+
exclude(:test_AliasGlobalVariableNode, "global variables")
20+
exclude(:test_ClassVariableReadNode, "class variables")
21+
exclude(:test_ForNode_gvar, "gvars")
22+
exclude(:test_PostExecutionNode_set_ivar, "set ivar of main")
23+
exclude(:test_PinnedVariableNode_ractor_unsafe, "ractor incompatible")
24+
exclude(:test_DefinedNode_ractor_unsafe, "ractor incompatible")
25+
exclude(:test_ConstantPathOrWriteNode_ractor_unsafe, "ractor incompatible")
26+
exclude(:test_ConstantPathOperatorWriteNode_ractor_unsafe, "ractor incompatible")
27+
exclude(:test_IfNode_ractor_unsafe, "gvars")

test/.excludes-ractor/RubyVM.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
exclude(:test_of_proc_and_method, "ractor incompatible")
2+
exclude(:test_parse_file_raises_syntax_error, "ractor incompatible")

test/.excludes-ractor/TestAlias.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
exclude(:test_alias_class_method_added, "class ivars")
2+
exclude(:test_alias_module_method_added, "module ivars")

0 commit comments

Comments
 (0)