summaryrefslogtreecommitdiff
path: root/test/ruby
AgeCommit message (Collapse)Author
2023-07-12Add comment to testPeter Zhu
Add comment for 7299c8c0f165247853fac2fe337e7c2678e653c9.
2023-07-12Revert previous commit [ci skip]Nobuyoshi Nakada
This reverts commit 074bf01e13db1ac0407786a3bc1b85c13135fd36, "Test `Comparable#clamp` with inverse arguments as well as a Range". The test is already in another method.
2023-07-12Test `Comparable#clamp` with inverse arguments as well as a RangeNobuyoshi Nakada
2023-07-11Try to fix flaky GC testPeter Zhu
assert_not_nil could allocate objects which may trigger the major GC, so don't run the assertions until the major GC has been ran. Notes: Merged: https://github.com/ruby/ruby/pull/8055
2023-07-10Fix autosplat conditions to handle ruby2_keywords caseJeremy Evans
Autosplat should not occur if there are two arguments but second argument is an array containing a ruby2_keywords splat. Only autosplat if a single argument to be yielded to the block, and there is no splatted flagged keyword hash passed. Fixes [Bug #19759] Notes: Merged: https://github.com/ruby/ruby/pull/8039 Merged-By: jeremyevans <code@jeremyevans.net>
2023-07-10Use `File::NULL` instead of hard coded null device namesNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/8050
2023-07-09[Bug #19763] Raise same message exception for regexpNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/8045
2023-06-30Handle unterminated unicode escapes in regexpsJeremy Evans
This fixes an infinite loop possible after ec3542229b29ec93062e9d90e877ea29d3c19472. For \u{} escapes in regexps, skip validation in the parser, and rely on the regexp code to handle validation. This is necessary so that invalid unicode escapes in comments in extended regexps are allowed. Fixes [Bug #19750] Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> Notes: Merged: https://github.com/ruby/ruby/pull/8003 Merged-By: jeremyevans <code@jeremyevans.net>
2023-06-29Fix memory leak in Hash#replacePeter Zhu
Hash#replace can leak memory if the receiver has an ST table. Notes: Merged: https://github.com/ruby/ruby/pull/8001
2023-06-29Add memory leak test for allocating ST hashesPeter Zhu
Test for commit f0d08d11dcd404f3146c0d71d6ff743bbc6e7193.
2023-06-28[Bug #19748] Fix out-of-bound access in `String#byteindex`Nobuyoshi Nakada
2023-06-28[Bug #19746] `String#index` with regexp should clear `$~` unless matchedNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/7988
2023-06-28Assert `$~` after `String#index` familyNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/7988
2023-06-28Use the same capacities for memory leak testsNobuyoshi Nakada
2023-06-24Do not have Enumeratory::Lazy#zip mark result as packedJeremy Evans
Fixes [Bug #19569] Notes: Merged: https://github.com/ruby/ruby/pull/7967
2023-06-23Skip test on Solaris SPARCPeter Zhu
This test fails on Solaris SPARC with the following error and I can't figure out why: TestGCCompact#test_moving_hashes_down_size_pools Expected 499 to be >= 500.
2023-06-22[Bug #19743] All but EOF can be read again after push-backNobuyoshi Nakada
2023-06-20[Bug #19736] Recover after unterminated interpolationNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/7963
2023-06-20Adjust indent [ci skip]Nobuyoshi Nakada
2023-06-17Remove no longer used variableNobuyoshi Nakada
2023-06-17Split the bmethod proc test to avoid redefinitionNobuyoshi Nakada
2023-06-13Add tests to `String#byteslice` memory allocation behaviour. (#1909)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-06-12When alloc size is too large, only allocate structMatt Valentine-House
Notes: Merged: https://github.com/ruby/ruby/pull/7933
2023-06-06YJIT: Avoid identity-based known-class guards for IO objects (#7911)Alan Wu
`IO#reopen` is very special in that it is able to change the class and singleton class of IO instances. In its presence, it is not correct to assume that IO instances has a stable class/singleton class and guard by comparing identity. Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2023-06-06Revert debugging code in test_gc_compact.rbPeter Zhu
2023-06-05Revert "Revert "Fix cvar caching when class is cloned""eileencodes
This reverts commit 10621f7cb9a0c70e568f89cce47a02e878af6778. This was reverted because the gc integrity build started failing. We have figured out a fix so I'm reopening the PR. Original commit message: Fix cvar caching when class is cloned The class variable cache that was added in ruby#4544 changed the behavior of class variables on cloned classes. As reported when a class is cloned AND a class variable was set, and the class variable was read from the original class, reading a class variable from the cloned class would return the value from the original class. This was happening because the IC (inline cache) is stored on the ISEQ which is shared between the original and cloned class, therefore they share the cache too. To fix this we are now storing the `cref` in the cache so that we can check if it's equal to the current `cref`. If it's different we don't want to read from the cache. If it's the same we do. Cloned classes don't share the same cref with their original class. This will need to be backported to 3.1 in addition to 3.2 since the bug exists in both versions. We also added a marking function which was missing. Fixes [Bug #19379] Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org> Notes: Merged: https://github.com/ruby/ruby/pull/7900
2023-06-03Attrset name is not allowed as an attributeNobuyoshi Nakada
2023-06-02Stabilize test_latest_gc_info_need_major_byJean Boussier
Fix: ``` 1) Failure: TestGc#test_latest_gc_info_need_major_by [/home/runner/work/ruby/ruby/src/test/ruby/test_gc.rb:266]: <nil> expected to not be nil. ``` `GC.stat(:major_gc_count)` can be bumped while `GC.latest_gc_info(:need_major_by)` is still nil. Notes: Merged: https://github.com/ruby/ruby/pull/7895
2023-06-01Revert "Fix cvar caching when class is cloned"Aaron Patterson
This reverts commit 77d1b082470790c17c24a2f406b4fec5d522636b.
2023-06-01Fix cvar caching when class is clonedeileencodes
The class variable cache that was added in https://github.com/ruby/ruby/pull/4544 changed the behavior of class variables on cloned classes. As reported when a class is cloned AND a class variable was set, and the class variable was read from the original class, reading a class variable from the cloned class would return the value from the original class. This was happening because the IC (inline cache) is stored on the ISEQ which is shared between the original and cloned class, therefore they share the cache too. To fix this we are now storing the `cref` in the cache so that we can check if it's equal to the current `cref`. If it's different we don't want to read from the cache. If it's the same we do. Cloned classes don't share the same cref with their original class. This will need to be backported to 3.1 in addition to 3.2 since the bug exists in both versions. We also added a marking function which was missing. Fixes [Bug #19379] Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org> Notes: Merged: https://github.com/ruby/ruby/pull/7265
2023-05-31More debug code to GC compaction testPeter Zhu
2023-05-31Add debug code to GC compaction testPeter Zhu
This test is flaky on some CI systems.
2023-05-27Improve `read`/`write`/`pread`/`pwrite` consistency. (#7860)Samuel Williams
* Documentation consistency. * Improve consistency of `pread`/`pwrite` implementation when given length. * Remove HAVE_PREAD / HAVE_PWRITE - it is no longer optional. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-05-26Remvoe very high timeout on test_race_gets_and_closeKJ Tsanaktsidis
This test should be fixed and fast now because the closing thread sleeps appropriately waiting for the file descriptor to be unused. Notes: Merged: https://github.com/ruby/ruby/pull/7865
2023-05-26Remove excessive timeout on test_wait_exception for FreeBSDKJ Tsanaktsidis
This should now be fixed by the previous commit. Notes: Merged: https://github.com/ruby/ruby/pull/7864
2023-05-25Don't immediately promote children of old objectsPeter Zhu
[Feature #19678] References from an old object to a write barrier protected young object will not immediately promote the young object. Instead, the young object will age just like any other object, meaning that it has to survive three collections before being promoted to the old generation. References from an old object to a write barrier unprotected object will place the parent object in the remember set for marking during minor collections. This allows the child object to be reclaimed in minor collections at the cost of increased time for minor collections. On one of [Shopify's highest traffic Ruby apps, Storefront Renderer](https://shopify.engineering/how-shopify-reduced-storefront-response-times-rewrite), we saw significant improvements after deploying this feature in production. We compare the GC time and response time of web workers that have the original behaviour (non-experimental group) and this new behaviour (experimental group). We see that with this feature we spend significantly less time in the GC, 0.81x on average, 0.88x on p99, and 0.45x on p99.9. This translates to improvements in average response time (0.96x) and p99 response time (0.92x). Notes: Merged: https://github.com/ruby/ruby/pull/7821
2023-05-24Add REMEMBERED_WB_UNPROTECTED_OBJECTS_LIMIT_RATIOPeter Zhu
[Feature #19571] This commit adds the environment variable `RUBY_GC_HEAP_REMEMBERED_WB_UNPROTECTED_OBJECTS_LIMIT_RATIO` which is used to calculate the `remembered_wb_unprotected_objects_limit` using a ratio of `old_objects`. This should improve performance by reducing major GC because, in a major GC, we mark all of the old objects, so we should have more uncollectible WB unprotected objects before starting a major GC. The default has been set to 0.01 (1% of old objects). On one of [Shopify's highest traffic Ruby apps, Storefront Renderer](https://shopify.engineering/how-shopify-reduced-storefront-response-times-rewrite), we saw significant improvements after deploying this patch in production. In the graphs below, we have the `tuned` group which uses `RUBY_GC_HEAP_REMEMBERED_WB_UNPROTECTED_OBJECTS_LIMIT_RATIO=0.01` (the default value), and an `untuned` group, which turns this feature off with `RUBY_GC_HEAP_REMEMBERED_WB_UNPROTECTED_OBJECTS_LIMIT_RATIO=0`. We see that the tuned group spends significantly less time in GC, on average 0.67x of the time compared to the untuned group and 0.49x for p99. We see this improvement in GC time translate to improvements in response times. The average response time is now 0.96x of the time compared to the untuned group and 0.86x for p99. https://user-images.githubusercontent.com/15860699/229559078-e23e8ce4-5f1f-4a2f-b5ef-5769f92b8c70.png Notes: Merged: https://github.com/ruby/ruby/pull/7577
2023-05-24Improvements to `IO::Buffer` `read`/`write`/`pread`/`pwrite`. (#7826)Samuel Williams
- Fix IO::Buffer `read`/`write` to use a minimum length. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-05-23Fix crash when replacing ST hash with AR hashPeter Zhu
With VWA, AR hashes are much larger than ST hashes. Hash#replace attempts to directly copy the contents of AR hashes into ST hashes so there will be memory corruption caused by writing past the end of memory. This commit changes it so that if a ST hash is being replaced with an AR hash it will insert each element into the ST hash. Notes: Merged: https://github.com/ruby/ruby/pull/7846
2023-05-22Ensure producer threads do not start running earlyCharles Oliver Nutter
This test caused issues occasionally on JRuby because it's possible for a producer thread to run to completion before the status checks begin. This results in Thread#status returning false and the =~ call triggering a warning (3.1) or error (3.2) and either emitting thousands of deprecation warnings or failing outright. The patch here introduces a mutex that remains locked until all producer threads are seen to have started. The lock is then released and the test proceeds. This prevents any producers from running to completion, which in turn prevents consumers running to completion, avoiding the warnings or error calling =~ on false. This patch also modifies the status checks to to_s the thread status, preventing any prematurely terminated threads from triggering similar deprecation warnings or missing method errors when =~ is called on nil. Notes: Merged: https://github.com/ruby/ruby/pull/7830
2023-05-22Revert "Apply timeout-scale to test_thr_kill." (#7838)Jun Aruga
This reverts commit bbbec4b87c1e66909f5bee9acd3e460b8c1ad663. Because the commit is a bug. The `apply_timeout_scale` to scale the timeout is called 2 times in the process. The `test/ruby/test_thread_queue.rb#test_thr_kill` is calling `EnvUtil.apply_timeout_scale`, and calling `tool/lib/core_assertions.rb#assert_normal_exit`. calling `tool/lib/envutil.rb#invoke_ruby` (`EnvUtil.invoke_ruby`) calling the `apply_timeout_scale`. ``` $ make test-all V=1 TESTS="-v test/ruby/test_thread_queue.rb -n TestThreadQueue#test_thr_kill --timeout-scale=2" ``` Notes: Merged-By: junaruga
2023-05-22Fix mutation on shared strings. (#7837)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-05-22Allow the match cache optimization for atomic groups (#7804)TSUYUSATO Kitsune
Notes: Merged-By: makenowjust <make.just.on@gmail.com>
2023-05-22Don't leak pipes. (#7820)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-05-20Set rlimit_nproc to 64 instead of 128 on OpenBSD for spawn_too_long_path testsJeremy Evans
This significantly reduces testing time, and may allow the test to pass before timeout in CI.
2023-05-17Move ar_hint to ar_table_structPeter Zhu
This allows Hashes with ST tables to fit int he 80 byte size pool. Notes: Merged: https://github.com/ruby/ruby/pull/7742
2023-05-17Implement Hash AR tables on VWAPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/7742
2023-05-15Unskip the test skipped in #4173 (#7809)KJ Tsanaktsidis
This test was skipped 12 years ago because it was flaky on FreeBSD and OpenBSD. Since then, Ruby's SIGCHLD handling has been substantially re-written (mostly by Eric Wong @normalperson in 44fc3d08). These tests now in fact pass reliably on Ruby master on FreeBSD 13.2 and OpenBSD 7.3. I stress-tested the test_wait_and_sigchild test on my laptop by running four copies of the test in a loop on a 8-core VM; both by itself and also as part of the whole test_process.rb file. I did not see any failures. Let's unskip the test and close [#4173] out. I'll keep an eye out on Ruby CI for any flakes in this file on BSD after this gets merged, but if we don't see any I'm going to assume 44fc3d08 or related changes around that time accidently fixed this bug. It's also probably important to unskip this test so that if another attempt at removing the special SIGCHLD handling is made (like was reverted in https://github.com/ruby/ruby/pull/7517), we get signal if that breaks on FreeBSD/OpenBSD. [Fixes #4173] Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-05-14[Bug #19025] Numbered parameter names are always local variablesNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/7810
2023-05-10Prevent warning: assigned but unused variableYusuke Endoh
http://rubyci.s3.amazonaws.com/debian10/ruby-master/log/20230510T123003Z.log.html.gz ``` /home/chkbuild/chkbuild/tmp/build/20230510T123003Z/ruby/test/objspace/test_objspace.rb:224: warning: assigned but unused variable - c4 /home/chkbuild/chkbuild/tmp/build/20230510T123003Z/ruby/test/ruby/test_class.rb:362: warning: assigned but unused variable - e /home/chkbuild/chkbuild/tmp/build/20230510T123003Z/ruby/test/ruby/test_process.rb:2602: warning: assigned but unused variable - parent_pid ```