summaryrefslogtreecommitdiff
path: root/test/ruby
AgeCommit message (Collapse)Author
2020-06-04Properly resolve refinements in defined? on private call [Bug #16932]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/3180
2020-06-04Properly resolve refinements in defined? on method call [Bug #16932]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/3180
2020-06-03Ensure origins for all included, prepended, and refined modulesJeremy Evans
This fixes various issues when a module is included in or prepended to a module or class, and then refined, or refined and then included or prepended to a module or class. Implement by renaming ensure_origin to rb_ensure_origin, making it non-static, and calling it when refining a module. Fix Module#initialize_copy to handle origins correctly. Previously, Module#initialize_copy did not handle origins correctly. For example, this code: ```ruby module B; end class A def b; 2 end prepend B end a = A.dup.new class A def b; 1 end end p a.b ``` Printed 1 instead of 2. This is because the super chain for a.singleton_class was: ``` a.singleton_class A.dup B(iclass) B(iclass origin) A(origin) # not A.dup(origin) ``` The B iclasses would not be modified, so the includer entry would be still be set to A and not A.dup. This modifies things so that if the class/module has an origin, all iclasses between the class/module and the origin are duplicated and have the correct includer entry set, and the correct origin is created. This requires other changes to make sure all tests still pass: * rb_undef_methods_from doesn't automatically handle classes with origins, so pass it the origin for Comparable when undefing methods in Complex. This fixed a failure in the Complex tests. * When adding a method, the method cache was not cleared correctly if klass has an origin. Clear the method cache for the klass before switching to the origin of klass. This fixed failures in the autoload tests related to overridding require, without breaking the optimization tests. Also clear the method cache for both the module and origin when removing a method. * Module#include? is fixed to skip origin iclasses. * Refinements are fixed to use the origin class of the module that has an origin. * RCLASS_REFINED_BY_ANY is removed as it was only used in a single place and is no longer needed. * Marshal#dump is fixed to skip iclass origins. * rb_method_entry_make is fixed to handled overridden optimized methods for modules that have origins. Fixes [Bug #16852] Notes: Merged: https://github.com/ruby/ruby/pull/3140
2020-06-02Fixed `defined?` against protected method callNobuyoshi Nakada
Protected methods are restricted to be called according to the class/module in where it is defined, not the actual receiver's class. [Bug #16931]
2020-06-02Split test_defined_methodNobuyoshi Nakada
2020-05-30test/ruby/test_process.rb: GID.from_name may raise Errno:ESRCHYusuke Endoh
getgrnam(3) says: ``` ERRORS 0 or ENOENT or ESRCH or EBADF or EPERM or ... The given name or gid was not found. ``` Process::GID.from_name raises an ArgumentError for 0, but Errno::ESRCH for ESRCH. Actually, WSL 2 raises Errno::ESRCH. This change accepts all exceptions above.
2020-05-26Test for [Feature #16832]Nobuyoshi Nakada
2020-05-26cause SEGV for the test.Koichi Sasada
21991e6ca5 enables `__builtin_assume()` for clang and it seems skip SEGV on rb_class_of() with unexpected value. This test expects a [BUG] output, so this patch causes [BUG] to show [BUG] message. https://github.com/ruby/ruby/runs/707088232?check_suite_focus=true#step:12:230 ``` 1) Failure: TestVMDump#test_darwin_invalid_access [/Users/runner/runners/2.262.1/work/ruby/ruby/src/test/ruby/test_vm_dump.rb:19]: pid 43128 exit 0. 1. [2/2] Assertion for "stderr" | Expected /^\[IMPORTANT\]/ to match "". ```
2020-05-22Fix origin iclass pointer for modulesJeremy Evans
If a module has an origin, and that module is included in another module or class, previously the iclass created for the module had an origin pointer to the module's origin instead of the iclass's origin. Setting the origin pointer correctly requires using a stack, since the origin iclass is not created until after the iclass itself. Use a hidden ruby array to implement that stack. Correctly assigning the origin pointers in the iclass caused a use-after-free in GC. If a module with an origin is included in a class, the iclass shares a method table with the module and the iclass origin shares a method table with module origin. Mark iclass origin with a flag that notes that even though the iclass is an origin, it shares a method table, so the method table should not be garbage collected. The shared method table will be garbage collected when the module origin is garbage collected. I've tested that this does not introduce a memory leak. This change caused a VM assertion failure, which was traced to callable method entries using the incorrect defined_class. Update rb_vm_check_redefinition_opt_method and find_defined_class_by_owner to treat iclass origins different than class origins to avoid this issue. This also includes a fix for Module#included_modules to skip iclasses with origins. Fixes [Bug #16736] Notes: Merged: https://github.com/ruby/ruby/pull/3136
2020-05-22Revert "Fix origin iclass pointer for modules"Jeremy Evans
This reverts commit c745a60634260ba2080d35af6fdeaaae86fe5193. This triggers a VM assertion. Reverting until the issue can be debugged.
2020-05-22Fix origin iclass pointer for modulesJeremy Evans
If a module has an origin, and that module is included in another module or class, previously the iclass created for the module had an origin pointer to the module's origin instead of the iclass's origin. Setting the origin pointer correctly requires using a stack, since the origin iclass is not created until after the iclass itself. Use a hidden ruby array to implement that stack. Correctly assigning the origin pointers in the iclass caused a use-after-free in GC. If a module with an origin is included in a class, the iclass shares a method table with the module and the iclass origin shares a method table with module origin. Mark iclass origin with a flag that notes that even though the iclass is an origin, it shares a method table, so the method table should not be garbage collected. The shared method table will be garbage collected when the module origin is garbage collected. I've tested that this does not introduce a memory leak. This also includes a fix for Module#included_modules to skip iclasses with origins. Fixes [Bug #16736] Notes: Merged: https://github.com/ruby/ruby/pull/2978
2020-05-22Run major GC three times to make sure the minor GC reasonYusuke Endoh
Same as 02705b27be207fce57bd0253251f81108c7ed57b http://ci.rvm.jp/results/trunk-random1@phosphorus-docker/2955433 ``` 1) TestGc#test_start_full_mark [/tmp/ruby/v3/src/trunk-random1/test/ruby/test_gc.rb:61]: Expected :oldmalloc to be nil. ```
2020-05-21test/ruby/test_optimization.rb: Proc creation test should count :T_DATAYusuke Endoh
instead of :TOTAL of ObjectSpace.count_objects. This test had failed very occasionally: https://rubyci.org/logs/rubyci.s3.amazonaws.com/centos8/ruby-master/log/20200521T033004Z.fail.html.gz ``` 1) Failure: TestRubyOptimization#test_block_parameter_should_not_create_objects [/home/chkbuild/chkbuild/tmp/build/20200521T033004Z/ruby/test/ruby/test_optimization.rb:713]: <0> expected but was <407>. ``` This test of lazy proc creation checks if no object is created during a method call. However, calling a method itself increases the count of objects because method cache is now an object (T_MEMO). The reason why this test rarely fails is because the test was buggy; it checked the count of :TOTAL, but :TOTAL count changes only when the GC heap is expanded. Creating one object rarely causes heap expansion. The test must have checked not only :TOTAL but also the count of :FREE. Instead, this change more directly checks :T_DATA. Note that a Proc object is T_DATA.
2020-05-17Removed useless implementation testsNobuyoshi Nakada
2020-05-17Removed PRNG implementation details from the testNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/3116
2020-05-15Fixed argument forwarding in reserved word method [Bug #16854]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/3112
2020-05-15fix for multi-run test.Koichi Sasada
TestAutoload#test_source_location can't run multiple test-run so that use assert_separately(). repro command: make yes-test-all TESTS='--repeat-count=50 ruby/test_autoload -n test_source_location' Notes: Merged: https://github.com/ruby/ruby/pull/3111
2020-05-14Endless method definition including `rescue` modifierNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/3108
2020-05-14Removed trailing spaces [ci skip]Nobuyoshi Nakada
2020-05-14Thread scheduler for light weight concurrency.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/3032 Merged-By: ioquatix <samuel@codeotaku.com>
2020-05-12numeric.c: optimize `float ** 2` case by fastpathYusuke Endoh
It would be a relatively frequent case. It is still slower than `float * float` because `*` has a dedicated VM instruction (opt_mult), though.
2020-05-11Remove the 65 size limit for name_err_mesg_to_strJean Boussier
This limit was introduced on Nov 20 1996 in 554b989ba1623b9f6a0b76f00824c83a23fbcbc1 Apparently to protect from a buffer overflow: * eval.c (f_missing): オブジェクトの文字列表現が長すぎる時バッファ を書き潰していた However I tested that path with very large strings and it works fine. Notes: Merged: https://github.com/ruby/ruby/pull/3090
2020-05-10Run rb_syswait on exec failureTakashi Kokubun
not only when !w but also when w == WAITPID_LOCK_ONLY. See also: f7c0cc36920a4ed14a3ab1ca6cfdf18ceff1e5d5 and a2264342063260d660b99872eaf5080f6ab08e81. We thought this change was an oversight in the latter commit. Without this change, the test fails like: $ make test-all TESTS="../test/ruby/test_process.rb -n test_exec_failure_leaves_no_child" RUN_OPTS="--jit" ... 1) Failure: TestProcess#test_exec_failure_leaves_no_child [/home/k0kubun/src/github.com/ruby/ruby/test/ruby/test_process.rb:2493]: Expected [[26799, #<Process::Status: pid 26799 exit 127>]] to be empty. Co-Authored-By: Yusuke Endoh <mame@ruby-lang.org>
2020-05-08Classes made from Struct should have default `new` singleton method.Marc-Andre Lafortune
[Bug #16465] [Bug #16801] [Fix GH-2795] [Fix GH-2944] [Fix GH-3045] [Fix GH-3093] Note: Backporting shouldn't modify object.h and instead can use struct_new_kw which is basically a duplicate implementation of rb_class_new_instance_pass_kw Co-authored-by: Yusuke Endoh <mame@ruby-lang.org> Co-authored-by: John Hawthorn <john@hawthorn.email> Co-authored-by: Adam Hess <HParker@github.com> Co-authored-by: Jose Cortinas <jacortinas@gmail.com> Co-authored-by: Jean Boussier <jean.boussier@gmail.com> Notes: Merged: https://github.com/ruby/ruby/pull/3093
2020-05-08Fix typo in test namePeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/3091
2020-05-08Fix a typo [ci skip]Kazuhiro NISHIYAMA
2020-05-07Suffixed memory leak tests as "memory_leak"Nobuyoshi Nakada
So that `TEST_EXCLUDES` option in common.mk works.
2020-05-07Cut down warm-up loops and gain main/warm-up ratioNobuyoshi Nakada
2020-05-03Test no .dSYM on macOSTakashi Kokubun
I think 9aa5fe1bf89db8cd215b24d8ddfb668714681b83 helps this issue too.
2020-05-03Skip pdb corruption on Visual Studio 2015 as wellTakashi Kokubun
It turned out that the pdb corruption happens on Visual Studio 2015 as well. https://ci.appveyor.com/project/ruby/ruby/builds/32602953/job/3gj43q18wqeiy729
2020-05-03Skip only .dSYM cleanup on macOSTakashi Kokubun
Fix https://github.com/ruby/ruby/runs/636020145 without skipping too many tests. It seems that .c -> .o with debug flags and .o -> .so without debug flags did not generate .dSYM but now .c -> .so with debug flags seems to generate a .dSYM directory. As --jit-debug should not be used by normal users, let me skip implementing the removal for now.
2020-05-01Skip MinGW TestJIT* and macOS TestJITDebug failuresTakashi Kokubun
caused by 818d6d33368a396d9cd3d1a34a84015a9e76c5c8, for now. I'll take a look at them tomorrow.
2020-05-01Deduplicate functions in compacted JIT codeTakashi Kokubun
to improve code locality. Using benchmark-driver/sinatra with 100 methods JIT-ed, [Before] 12149.97 rps 1.3M /tmp/_ruby_mjit_p31171u145.so [After] 12818.83 rps 260K /tmp/_ruby_mjit_p32155u145.so (VM is 13714.89 rps)
2020-04-30Switch test_unload_units_and_compaction on mswinTakashi Kokubun
because we support JIT compaction on it
2020-04-30Do not stop the world during JIT compactionTakashi Kokubun
Running C compiler for JIT compaction inside a critical section may lock main thread for a long time when it triggers GC. As I'm planning to increase this duration a bit, I'd like to make sure this doesn't stop the world. For now, I chose to give up unloading units when it's during JIT compaction, assuming other calls may unload them later.
2020-04-27Moved already resolved testNobuyoshi Nakada
Couldn't figure out failed/fixed versions.
2020-04-27test/ruby/test_fiber.rb (test_stack_size): re-enabled on s390xYusuke Endoh
Revert 9948addda67f4b7a6e3575f1eba9025f998811d2. It is now discussed in https://bugs.ruby-lang.org/issues/16814, and an assert is added with a217d3cedce3f5aa5c27a1ce6c72b65ec37da057. It would be good to give it a try.
2020-04-23Test for [Bug #16669]Nobuyoshi Nakada
2020-04-23Split test_definedNobuyoshi Nakada
2020-04-22Made parentheses mandatory in endless method defitionNobuyoshi Nakada
Even for empty argument list, not to be confusing with a writer method name. Notes: Merged: https://github.com/ruby/ruby/pull/3051
2020-04-22Disallow R-assign in endless defNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/3051
2020-04-22Revert "Allow simple R-assign in endless def"Nobuyoshi Nakada
This reverts commit 67bcac879a2e0ddfb4e7bbd7cb5e5401422de76a. Notes: Merged: https://github.com/ruby/ruby/pull/3051
2020-04-22test/ruby/test_fiber.rb: Skip the problematic test_stack_size on riscvYusuke Endoh
Since it is impossible to detect stack overflow of C functions robustly, the test is a bit unreasonable. https://rubyci.org/logs/rubyci.s3.amazonaws.com/debian-riscv64/ruby-master/log/20200421T120018Z.fail.html.gz
2020-04-21eval_error.c: default nil as "reverse" is now false [Feature #8661]Nobuyoshi Nakada
2020-04-21test/ruby/test_refinement.rb: extend the timeoutYusuke Endoh
https://rubyci.org/logs/rubyci.s3.amazonaws.com/debian-riscv64/ruby-master/log/20200420T083601Z.fail.html.gz
2020-04-19Skip TestRequire#test_loading_fifo_fd_leak on AndroidYusuke Endoh
The test fails due to unknown reason. Need to debug in future, but tentatively skipped.
2020-04-18Environment variable values are not case-insensitiveNobuyoshi Nakada
Only the names are case-sensitive. Notes: Merged: https://github.com/ruby/ruby/pull/3041
2020-04-18Compare environment variable names in those manor [Bug #16798]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/3040
2020-04-18Make sure newarraykwsplat accesses a correct indexTakashi Kokubun
on stack when local_stack_p is enabled. This fixes `RB_FL_TEST_RAW:"RB_FL_ABLE(obj)"` assertion failure on power_assert's test with JIT enabled.
2020-04-18Super TestJIT#setup to skip unsupported envsTakashi Kokubun
Slightly simplifying 8d6aa06620b316904fd10d0cab1b85e07f2fbf67