summaryrefslogtreecommitdiff
path: root/test/ruby
AgeCommit message (Collapse)Author
2021-09-20Allow to include uninitialized modules [Bug #18177]Nobuyoshi Nakada
The module that is about to be included is considered initialized. Notes: Merged: https://github.com/ruby/ruby/pull/4868
2021-09-20Adjust test to set+get big values on all platforms and add MINGW-UCRTLars Kanis
Previously the test verified on MSWIN that huge values can not be stored in environment variables but that they can on others. IMHO the intention of the test should not change between platforms. Therefore this adjusts the test to have the same intention - that is to store a big value. This also fixes compatibility with MINGW-UCRT, which previously failed with: <Errno::EINVAL: Invalid argument - ruby_setenv(foo)> test/ruby/test_env.rb:512:in `[]=' test/ruby/test_env.rb:512:in `block in test_huge_value' Notes: Merged: https://github.com/ruby/ruby/pull/4599
2021-09-18Revert "Do not load file with same realpath twice when requiring"Jeremy Evans
This reverts commit ddb85c5d2bdf75a83eb163856508691a7436b446. This commit causes unexpected warnings in TestTranscode#test_loading_race occasionally in CI.
2021-09-18Do not load file with same realpath twice when requiringJeremy Evans
This fixes issues with paths being loaded twice in certain cases when symlinks are used. It took me multiple attempts to get this working. My original attempt tried to convert paths to realpaths before adding them to $LOADED_FEATURES. Unfortunately, this doesn't work well with the loaded feature index, which is based off load paths and not realpaths. While I was able to get require working, I'm fairly sure the loaded feature index was not being used as expected, which would have significant performance implications. Additionally, I was never able to get that approach working with autoload when autoloading a non-realpath file. It also broke some specs. This takes a more conservative approach. Directly before loading the file, if the file with the same realpath has been required, the loading of the file is skipped. The realpaths are stored as fstrings in a hidden hash. When rebuilding the loaded feature index, the hash of realpaths is also rebuilt. I'm guessing this makes rebuilding process slower, but I don think that is a hot path. In general, modifying loaded features is only done when reloading, and that tends to be in non-production environments. Change test_require_with_loaded_features_pop test to use 30 threads and 300 iterations, instead of 4 threads and 1000 iterations. I saw only sporadic failures with 4/1000, but consistent failures 30/300 threads. These failures were due to the fact that the concurrent deletions from $LOADED_FEATURES in other threads can result in rb_ary_entry returning nil when rebuilding the loaded features index. To avoid concurrency issues when rebuilding the loaded features index, the building of the index itself is left alone, and afterwards, a separate loop is done on a copy of the loaded feature snapshot in order to rebuild the realpaths hash. Fixes [Bug #17885] Notes: Merged: https://github.com/ruby/ruby/pull/4615
2021-09-18ast.c: AST.of against C method should return nil (as Ruby 2.6--3.0)Yusuke Endoh
2021-09-18ast.c: AST.of checks if a given method object is defined in CYusuke Endoh
[Bug #18178]
2021-09-17Removed Module.allocate [Bug #17048]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4858
2021-09-17Already initialized modules cannot be replaced [Bug #17048]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4858
2021-09-17[Feature #18172] Fix duplicate test nameNobuyoshi Nakada
2021-09-16[Feature #18172] Add MatchData#match_lengthNobuyoshi Nakada
The method to return the length of the matched substring corresponding to the given argument. Notes: Merged: https://github.com/ruby/ruby/pull/4851
2021-09-16[Feature #18172] Add MatchData#matchNobuyoshi Nakada
The method to return the single matched substring corresponding to the given argument. Notes: Merged: https://github.com/ruby/ruby/pull/4851
2021-09-16[Bug #18173] Update loaded_features_indexNobuyoshi Nakada
If $LOADED_FEATURES is changed in the just required file, also the index table needs to be updated before loaded_features_snapshot is reset. If the snapshot is reset without updating the table, the name of the added feature will not be found. Notes: Merged: https://github.com/ruby/ruby/pull/4849
2021-09-15Add test cases for constants and keywordsShugo Maeda
2021-09-15Marshal.load: do not call the proc until strings have their encodingJean Boussier
Ref: https://bugs.ruby-lang.org/issues/18141 Notes: Merged: https://github.com/ruby/ruby/pull/4797
2021-09-14Handle overwriting Object::ENV in spawnJeremy Evans
Instead of looking for Object::ENV (which can be overwritten), directly look for the envtbl variable. As that is static in hash.c, and the lookup code is in process.c, add a couple non-static functions that will return envtbl (or envtbl#to_hash). Fixes [Bug #18164] Notes: Merged: https://github.com/ruby/ruby/pull/4834
2021-09-13Use capture_output instead of capture_ioHiroshi SHIBATA
2021-09-13Adds mixed hash value and value omission testsBrandon Weaver
Introduces specification tests for mixed values and value omissions for Hashes and keyword arguments, such as `{ a:, b:, c: 3 }`. Notes: Merged: https://github.com/ruby/ruby/pull/4829
2021-09-12Preserve the encoding of the argument in IndexError [Bug #18160]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4822
2021-09-11Add documentation and tests for keyword argument value omissionShugo Maeda
[Feature #14579]
2021-09-11Another test for [Feature #14579]Nobuyoshi Nakada
The value of the dynamic key cannot be omitted for now.
2021-09-11Allow value omission in Hash literalsShugo Maeda
`{x:, y:}` is a syntax sugar of `{x: x, y: y}`.
2021-09-11Fixed inconsistent require order for assertions and core_assertionsHiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/4813
2021-09-11Use Test::Unit::Runner instead of MiniTest::UnitHiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/4813
2021-09-11Use CoreAssertions instead of AssertionsHiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/4813
2021-09-11Use MiniTestHiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/4813
2021-09-08[Bug #18154] Fix memory leak in String#initializePeter Zhu
String#initialize can leak memory when called on a string that is marked with STR_NOFREE because it does not unset the STR_NOFREE flag. Notes: Merged: https://github.com/ruby/ruby/pull/4814
2021-09-06Use Test::Unit::AssertionFailedError instead of MiniTest::Assertion for ↵Hiroshi SHIBATA
test-unit migration
2021-09-02Refined test [Bug #18140]Nobuyoshi Nakada
2021-09-02Test against the target classNobuyoshi Nakada
2021-09-02Guard array when appendingAaron Patterson
This prevents early collection of the array. The GC doesn't see the array on the stack when Ruby is compiled with optimizations enabled [ruby-core:105099] [Bug #18140]
2021-08-29Support tracing of attr_reader and attr_writerJeremy Evans
In vm_call_method_each_type, check for c_call and c_return events before dispatching to vm_call_ivar and vm_call_attrset. With this approach, the call cache will still dispatch directly to those functions, so this change will only decrease performance for the first (uncached) call, and even then, the performance decrease is very minimal. This approach requires that we clear the call caches when tracing is enabled or disabled. The approach currently switches all vm_call_ivar and vm_call_attrset call caches to vm_call_general any time tracing is enabled or disabled. So it could theoretically result in a slowdown for code that constantly enables or disables tracing. This approach does not handle targeted tracepoints, but from my testing, c_call and c_return events are not supported for targeted tracepoints, so that shouldn't matter. This includes a benchmark showing the performance decrease is minimal if detectable at all. Fixes [Bug #16383] Fixes [Bug #10470] Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com> Notes: Merged: https://github.com/ruby/ruby/pull/4767
2021-08-29Free previously used tables [Bug #18134]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4788
2021-08-29Add negative position tests [Bug #18138]Nobuyoshi Nakada
2021-08-29Add out of range tests for Array#slice!Nobuyoshi Nakada
2021-08-24Fix warnings in test_optimization.rbJeremy Evans
These were introduced in the test for tracing optimized methods added in 48c8df9e0eb295af06d593ce37ce1933c0ee1d90.
2021-08-22Fix Marshal.dump(closed_io) to raise TypeError and allow encoding on closed IOLars Kanis
Mashalling a closed IO object raised "closed stream (IOError)" before instead of TypeError. This changes IO#(in|ex)ternal_encoding to still return the encoding even if the underlying FD is closed. Fixes bug #18077 Notes: Merged: https://github.com/ruby/ruby/pull/4758
2021-08-21Allow tracing of optimized methodsJeremy Evans
This updates the trace instructions to directly dispatch to opt_send_without_block. So this should cause no slowdown in non-trace mode. To enable the tracing of the optimized methods, RUBY_EVENT_C_CALL and RUBY_EVENT_C_RETURN are added as events to the specialized instructions. Fixes [Bug #14870] Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com> Notes: Merged: https://github.com/ruby/ruby/pull/4739 Merged-By: jeremyevans <code@jeremyevans.net>
2021-08-20ast.c: Rename "save_script_lines" to "keep_script_lines"Yusuke Endoh
... as per ko1's preference. He is preparing to extend this feature to ISeq for his new debugger. He prefers "keep" to "save" for this wording. This API is internal and not included in any released version, so I change it in advance.
2021-08-20Module#ancestors should not return superclasses of refinementsShugo Maeda
[ruby-core:86949] [Bug #14744] Reported by Eregon (Benoit Daloze). Thanks!
2021-08-19Remove old warning aged nearly 8 yearsNobuyoshi Nakada
2021-08-19Allow omission of parentheses in one line pattern matching [Feature #16182]Kazuki Tsujimoto
2021-08-17Take into account data in emoji-variation-sequences.txt in tests.Martin Dürst
The emoji data in emoji-variation-sequences.txt was not used for in test/ruby/enc/test_emoji_breaks.rb, for unknown reasons. It turned out that the format of each of the emoji data/test files is slightly different, and that we didn't take into account that empty fields after a semicolon, as present in emoji-variation-sequences.txt, led to less fields than expected when using split. This addresses issue #18027.
2021-08-15Show verbose error messages when single pattern match failsKazuki Tsujimoto
[0] => [0, *, a] #=> [0] length mismatch (given 1, expected 2+) (NoMatchingPatternError) Ignore test failures of typeprof caused by this change for now.
2021-08-12Don't cancel JIT-ed code on TracePoint :classTakashi Kokubun
events get enabled
2021-08-12Print JIT cancel when all JIT-ed code is cancelledTakashi Kokubun
2021-08-10Assert for duplicated ARGF [Bug #18074]Nobuyoshi Nakada
2021-08-10Assert that each contents are read [Bug #18074]Nobuyoshi Nakada
2021-08-10add some lines to delete unused TracePointKoichi Sasada
`TracePoint.stat` returns the "to be deleted" TP numbers, and http://rubyci.s3.amazonaws.com/graviton2/ruby-master/log/20210810T030003Z.fail.html.gz shows there is a "to be deleted" TP. This patch uses only :line event and add some lines to allow MRI deletes "to be deleted" TPs.
2021-08-10Fix ARGF.read(length) short read [Bug #18074]Csaba Henk
Notes: Merged: https://github.com/ruby/ruby/pull/4727
2021-08-06Use Rational for Float#round with ndigits > 14Jeremy Evans
ndigits higher than 14 can result in values that are slightly too large due to floating point limitations. Converting to rational for the calculation and then back to float fixes these issues. Fixes [Bug #14635] Fixes [Bug #17183] Co-authored by: Yusuke Endoh <mame@ruby-lang.org> Notes: Merged: https://github.com/ruby/ruby/pull/4682