summaryrefslogtreecommitdiff
path: root/test/ruby
AgeCommit message (Collapse)Author
2024-04-12[Bug #20423] Disallow anonymous block within argument forwardingNobuyoshi Nakada
2024-04-11compile.c: use rb_enc_interned_str to reduce allocationsJean Boussier
The `rb_fstring(rb_enc_str_new())` pattern is inneficient because: - It passes a mutable string to `rb_fstring` so if it has to be interned it will first be duped. - It an equivalent interned string already exists, we allocated the string for nothing. With `rb_enc_interned_str` we either directly get the pre-existing string with 0 allocations, or efficiently directly intern the one we create without first duping it.
2024-04-11[Bug #20417] Block local variables do not need to warn about unusedNobuyoshi Nakada
2024-04-10[Misc #18984] Raise TypeError from Range#size if the range is not iterableKouhei Yanagita
2024-04-06[Feature #20329] Separate additional flags from main dump optionsNobuyoshi Nakada
Additional flags are comma separated list preceeded by `-` or `+`. Before: ```sh $ ruby --dump=insns+without_opt ``` After: ```sh $ ruby --dump=insns-opt,-optimize ``` At the same time, `parsetree_with_comment` is split to `parsetree` option and additional `comment` flag. Before: ```sh $ ruby --dump=parsetree_with_comment ``` After: ```sh $ ruby --dump=parsetree,+comment ``` Also flags can be separate `--dump`. ```sh $ ruby --dump=parsetree --dump=+comment --dump=+error_tolerant ``` Ineffective flags are ignored silently. ```sh $ ruby --dump=parsetree --dump=+comment --dump=+error_tolerant ```
2024-04-05[Bug #20342] Consider wrapped load in `main` methodsNobuyoshi Nakada
2024-04-04Update `ARGF.write` interfaceNobuyoshi Nakada
2024-04-04Refine test_argf.rbNobuyoshi Nakada
- Make `make_tempfile` to take data to write, `binmode:` flag, and a block. - Use `make_tempfile` instead of `make_tempfile0`. - Use `File.binwrite`.
2024-04-04Separate SCRIPT_LINES__ from ast.cHASUMI Hitoshi
This patch suggests relocating the code dealing with `SCRIPT_LINES__` from ast.c to ruby_parser.c. ## Background - I guess `AbstractSyntaxTree.of` method used to use `SCRIPT_LINES__` internally for some reason before - However, now it appears `SCRIPT_LINES__` is no longer used meaningfully by the method - As evidence of this, (and as my patch shows,) removing the function call of `rb_script_lines_for()` from `ast_s_of()` does not affect the result of `test/ruby/test_ast.rb` Given the above, I think two possibilities can be considered: - (A) `AbstractSyntaxTree.of` has not needed `SCRIPT_LINES__` already (I pick this) - (B) We lack a test case of `AbstractSyntaxTree.of` that needs to use `SCRIPT_LINES__` ## Besides, The current implementation causes strange behavior: ```console ruby -e"SCRIPT_LINES__ = {__FILE__ => []}; puts RubyVM::AbstractSyntaxTree.of(->{ 1 + 2 }, keep_script_lines: true).script_lines" => `-e:1:in '<main>': undefined method 'script_lines' for nil (NoMethodError)` ``` I think this is a bug because `AbstractSyntaxTree.of` is not supposed to return `nil` even in this case. This happens due to the ast.c's dependence on `SCRIPT_LINES__`. And at the end of the `ast_s_of()`, `node_find()` can not find the target child node obviously because it doesn't make sense to look for a corresponding node made from the parameter of `AbstractSyntaxTree.of` in the AST tree made from the value of `{__FILE__ => []}` ## Solution Since I think it's good enough `SCRIPT_LINES__` to be only referred by ruby.c, I chose the possibility "(A)" and wrote this patch which moves `rb_script_lines_for()` from ast.c to ruby_parser.c. So as the result: - `ast_s_of()` function no longer look up `SCRIPT_LINES__` - Even so, this patched code passes the existing tests - The strange behavior above no longer happens (I also added a test for it) Please correct me if I miss something🙏
2024-04-04Prevent a warningYusuke Endoh
``` [19889/25837] TestArgf#test_puts-e:1: warning: ARGF.class#write is outdated interface which accepts just one argument = 0.06 s ``` https://rubyci.s3.amazonaws.com/debian12/ruby-master/log/20240404T033003Z.log.html.gz
2024-04-04Prevent "method redefined" warningsYusuke Endoh
2024-04-04Prevent "assigned but unused variable" warningsYusuke Endoh
2024-04-04Prevent "ambiguous first argument" warningsYusuke Endoh
2024-04-04Extend timeout of TestRequire#test_require_with_public_method_missingYusuke Endoh
Launchable reported that this was the most "flaky" test. Perhaps the default timeout (10 seconds) is too tight for a test that uses `GC.stress = true`. I try to relax the limit.
2024-04-02[Feature #20331] Simplify parser warnings for hash keys duplication and when ↵yui-knk
clause duplication This commit simplifies warnings for hash keys duplication and when clause duplication, based on the discussion of https://bugs.ruby-lang.org/issues/20331. Warnings are reported only when strings are same to ohters.
2024-03-28Set ASAN_OPTIONS=disable_coredump=0 for test_execopts_rlimit testKJ Tsanaktsidis
By default, ASAN sets RLIMIT_CORE to zero, "to avoid dumping a 16T+ core file" on 64 bit systems. These tests are just asserting on the expected value of RLIMIT_CORE, not actually dumping core files, so it's fine to disable that behaviour of ASAN for this test.
2024-03-28Disable ASAN handle_segv in test_rubyoptions.rbKJ Tsanaktsidis
ASAN registers a sigsegv handler and causes extra output to be emitted that these tests are not expecting.
2024-03-27[PRISM] Match style for invalid encoding errorKevin Newton
2024-03-27Add array/hash implicit allocation testsJeremy Evans
These are designed to prevent allocation regressions (commits that increase the number of implicitly allocated arrays and hashes). We have already had three commits in the last couple weeks to fix allocation regressions: * 15dc3aaa311b32203d8ffb414bcf9b8e55ce5691 * aceee71c35e0b387691836e756b4e008efd84cf1 * c38878494377c94f2425a81e598260ea944ef7f3 This test suite should hopefully allow us to find such regressions in CI before commit, to avoid committing future allocation regressions. This uses assert_separately around each set of tests. Doing it for each individual check was too slow. Failures are gathered and reported at the end of the the suite as a single assertion, with the message describing all failures.
2024-03-27Revert "skip `test_gc_stress_at_startup`"Peter Zhu
This reverts commit 3680981c7b71df8c3a426164787ccefe5296bb25.
2024-03-27[DOC] remove repetitive words in commentscrazeteam
Signed-off-by: crazeteam <lilujing@outlook.com>
2024-03-27Don't clear pending interrupts in the parent process. (#10365)Samuel Williams
2024-03-26[Bug #20392] Block arguments duplication check at `super`Nobuyoshi Nakada
2024-03-26skip `test_gc_stress_at_startup`Koichi Sasada
(maybe) from 9cf754b the test fails on some environments: https://rubyci.s3.amazonaws.com/icc-x64/ruby-master/log/20240325T200004Z.fail.html.gz ``` 1) Failure: TestGc#test_gc_stress_at_startup [/home/chkbuild/chkbuild/tmp/build/20240325T200004Z/ruby/test/ruby/test_gc.rb:771]: [Bug #15784] pid 1087168 killed by SIGSEGV (signal 11) (core dumped). 1. [3/3] Assertion for "success?" | Expected #<Process::Status: pid 1087168 SIGSEGV (signal 11) (core dumped)> to be success?. ``` https://rubyci.s3.amazonaws.com/freebsd14/ruby-master/log/20240325T203002Z.fail.html.gz https://rubyci.s3.amazonaws.com/osx1200arm-no-yjit/ruby-master/log/20240325T195003Z.fail.html.gz https://rubyci.s3.amazonaws.com/s390x/ruby-master/log/20240325T210003Z.fail.html.gz ... so just skipt it until it works.
2024-03-25[Bug #20389] Chilled string cannot be a shared rootNobuyoshi Nakada
2024-03-24Use dedicated methods to abortNobuyoshi Nakada
When `RUBY_DEBUG` is set, accessing a class in an invalid object will cause a breakpoint trap instead of a segfault on some implementations.
2024-03-24Move `-test-/fatal/rb_fatal` to `-test-/fatal`Nobuyoshi Nakada
2024-03-23Ignore method chains succeeding `git ls-files`Nobuyoshi Nakada
2024-03-22Do not apply anon_rest optimization when passed array uses keyword-flagged hashJeremy Evans
The optimization sets args->rest_dupped to avoid allocating an array, but this is not safe if the splat array ends in a keyword flagged hash. Unset args->rest_dupped in this case. Fixes [Bug #20388]
2024-03-22[Feature #20275] Remove extra backtrace entries for rescue and ensureBenoit Daloze
2024-03-21Fix unexpected node bug for `shareable_constant_value: literal`yui-knk
[Bug #20339] [Bug #20341] `const_decl_path` changes the value of `NODE **dest`, LHS of an assignment, with `NODE_LIT` created by `const_decl_path`. `shareable_literal_constant` calls `const_decl_path` via `ensure_shareable_node` multiple times if RHS of an assignment is array or hash. This means `NODE **dest` argument of `const_decl_path` can be `NODE_LIT` from the second time then causes `[BUG] unexpected node: NODE_LIT` in `rb_node_const_decl_val`. This commit change to not update `NODE **dest` in `const_decl_path` to fix the issue.
2024-03-20Avoid deprecation warnings in TestStringJean Boussier
2024-03-19Implement chilled stringsÉtienne Barrié
[Feature #20205] As a path toward enabling frozen string literals by default in the future, this commit introduce "chilled strings". From a user perspective chilled strings pretend to be frozen, but on the first attempt to mutate them, they lose their frozen status and emit a warning rather than to raise a `FrozenError`. Implementation wise, `rb_compile_option_struct.frozen_string_literal` is no longer a boolean but a tri-state of `enabled/disabled/unset`. When code is compiled with frozen string literals neither explictly enabled or disabled, string literals are compiled with a new `putchilledstring` instruction. This instruction is identical to `putstring` except it marks the String with the `STR_CHILLED (FL_USER3)` and `FL_FREEZE` flags. Chilled strings have the `FL_FREEZE` flag as to minimize the need to check for chilled strings across the codebase, and to improve compatibility with C extensions. Notes: - `String#freeze`: clears the chilled flag. - `String#-@`: acts as if the string was mutable. - `String#+@`: acts as if the string was mutable. - `String#clone`: copies the chilled flag. Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
2024-03-17[Bug #20218] Reject keyword arguments in indexNobuyoshi Nakada
2024-03-17[Bug #19918] Reject block passing in indexNobuyoshi Nakada
2024-03-16Prefer the simple read/write `File` singleton methodsNobuyoshi Nakada
2024-03-16Prefer the simple read/write `File` singleton methodsNobuyoshi Nakada
2024-03-15Cover all warning categories by using `Warning.categories`Nobuyoshi Nakada
2024-03-15Test deprecation warning with `$;`Nobuyoshi Nakada
2024-03-14Ensure test suite is compatible with --frozen-string-literalJean Boussier
As preparation for https://bugs.ruby-lang.org/issues/20205 making sure the test suite is compatible with frozen string literals is making things easier.
2024-03-14`Exception#set_backtrace` accept arrays of `Backtrace::Location`Jean Boussier
[Feature #13557] Setting the backtrace with an array of strings is lossy. The resulting exception will return nil on `#backtrace_locations`. By accepting an array of `Backtrace::Location` instance, we can rebuild a `Backtrace` instance and have a fully functioning Exception. Co-Authored-By: Étienne Barrié <etienne.barrie@gmail.com>
2024-03-14[Feature #20244] Issue a single `Warning.warn` callNobuyoshi Nakada
Make the entire series of message lines a multiline string so that the `Warning.warn` hook can receive them in a single call.
2024-03-14[Feature #20244] Show the conflicting another chdir blockNobuyoshi Nakada
2024-03-14[Feature #20293] Add `Warning.categories`Nobuyoshi Nakada
2024-03-14[Bug #20307] Fix `Hash#update` to make frozen copy of string keysNobuyoshi Nakada
2024-03-14Chomp last punctuations from descriptions for `-h`Nobuyoshi Nakada
The following parts will not be shown for `-h` option. And not to reach 80 columns. Some terminal emulators (Windows command prompt at least) wrap the cursor to the next line when reaching the rightmost column, before exceeding.
2024-03-13Make special const and too complex shapes before T_OBJECT shapesPeter Zhu
2024-03-13Don't create per size pool shapes for non-T_OBJECTPeter Zhu
2024-03-12Skip a flaky GC.compact test for YJITTakashi Kokubun
This test has failed without YJIT too: https://rubyci.s3.amazonaws.com/debian11/ruby-master/log/20240301T063003Z.fail.html.gz However, it somehow fails more often on "YJIT Ubuntu / check RUSTC='rustc +1.58.0'" job. Nobody is actively looking into this issue, and it's most likely not a YJIT-specific issue, so let me silence this false positive until we start working on this.
2024-03-12Check what actually needs to be checkedTakashi Kokubun
RubyVM::YJIT is conditionally defined, depending on --enable-yjit. However, RubyVM::YJIT.enabled? is always defined as long as RubyVM::YJIT is defined, so it seems weird to check RubyVM::YJIT.enabled? instead of RubyVM::YJIT.