summaryrefslogtreecommitdiff
path: root/spec
Commit message (Collapse)AuthorAgeFilesLines
* fix wording of spec description [ci skip]Martin Dürst2023-05-131-1/+1
|
* [Bug #19597] Freeze script nameNobuyoshi Nakada2023-05-101-2/+4
|
* Merge https://github.com/rubygems/rubygems/pull/6655 manually.Hiroshi SHIBATA2023-05-101-7/+35
|
* Relax regexp for console assertionHiroshi SHIBATA2023-05-092-2/+2
|
* marshal.c: shallow freeze user objectsJean Boussier2023-04-261-9/+7
| | | | | | When `freeze: true` argument is passed. [Bug #19427]
* Update to ruby/spec@7f6ca5bBenoit Daloze2023-04-252-1/+2
|
* Workaround CRuby adding x86_64-linux-fake in $LOADED_FEATURESBenoit Daloze2023-04-251-1/+5
|
* Update to ruby/spec@7f69c86Benoit Daloze2023-04-2599-183/+2316
|
* Update to ruby/mspec@1d8cf64Benoit Daloze2023-04-256-80/+3
|
* [ruby/syntax_suggest] Clean up outputschneems2023-04-253-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I previously left a comment stating I didn't know why a certain method existed. In investigating the code in `CaptureCodeContext#capture_before_after_kws` I found that it was added as to give a slightly less noisy output. The docs for AroundBlockScan#capture_neighbor_context only describe keywords as being a primary concern. I modified that code to only include lines that are keywords or ends. This reduces the output noise even more. This allows me to remove that `start_at_next_line` method. One weird side effect of the prior logic is it would cause this code to produce this output: ``` class OH def hello def hai end end ``` ``` 1 class OH > 2 def hello 4 def hai 5 end 6 end ``` But this code to produce this output: ``` class OH def hello def hai end end ``` ``` 1 class OH > 2 def hello 4 end 5 end ``` Note the missing `def hai`. The only difference between them is that space. With this change, they're now both consistent. https://github.com/ruby/syntax_suggest/commit/4a54767a3e
* [ruby/syntax_suggest] standardrb --fix-unsafely spec/spec_helper.rbHiroshi SHIBATA2023-04-251-1/+1
| | | | https://github.com/ruby/syntax_suggest/commit/6e266b3b2b
* Allow anonymous memberless StructJeremy Evans2023-04-241-0/+14
| | | | | | | Previously, named memberless Structs were allowed, but anonymous memberless Structs were not. Fixes [Bug #19416]
* Check the precision of `getrusage` at runtimeNobuyoshi Nakada2023-04-231-1/+11
|
* Fix a guard of `Process.times`Nobuyoshi Nakada2023-04-221-8/+5
| | | | | | `GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID` clock uses `getrusage` always if available as the name states. That is if it is implemented `getrusage` is available, regardless microseconds in its results.
* Fix an example of `Process.times`Nobuyoshi Nakada2023-04-221-1/+1
| | | | | | | | Prior to commit 5806c54447439f2ba22892e4045e78dd80f96f0c, it was "at least one result with precision beyond milliseconds (with none-zero microseconds) should exist"; after this commit, "at least one result should have zero microseconds". This chance is lower than the previous condition.
* Skip when unix socket path is too longNobuyoshi Nakada2023-04-211-1/+3
| | | | | Eventually the path directly under "/tmp" is complained by `rm_r` in spec/mspec/lib/mspec/helpers/fs.rb.
* [rubygems/rubygems] Revert "Bundler::YAMLSerializer.load couldn't raise ↵Hiroshi SHIBATA2023-04-201-0/+23
| | | | | | | | error when invalid yaml was provided" This reverts commit https://github.com/rubygems/rubygems/commit/cfcfde04c783. https://github.com/rubygems/rubygems/commit/ac21ae7083
* Use ASCII-compatible encoding for testsNobuyoshi Nakada2023-04-202-0/+0
| | | | | | Since these files are written in a wide character encoding, stop at first NUL byte and are actually empty. ASCII-incompatible encodings have never been supported as source encoding.
* [rubygems/rubygems] Bundler::YAMLSerializer.load couldn't raise error when ↵Hiroshi SHIBATA2023-04-191-23/+0
| | | | | | invalid yaml was provided https://github.com/rubygems/rubygems/commit/cfcfde04c7
* MatchData#named_captures: add optional symbolize_names keyword (#6952)Vladimir Dementyev2023-04-191-0/+12
|
* Add spec for `Warning[:performance]`Jean Boussier2023-04-171-0/+7
| | | | [Feature #19538]
* Implement ObjectSpace::WeakMap#delete and ObjectSpace::WeakKeyMap#deleteJean Boussier2023-04-152-0/+70
| | | | | | [Feature #19561] It's useful to be able to remove references from weak maps.
* * append newline at EOF. [ci skip]git2023-04-151-1/+1
|
* Add specs for ObjectSpace::WeakKeyMapJean Boussier2023-04-155-0/+161
| | | | [Feature #18498]
* Revert "Add specs for ObjectSpace::WeakKeyMap"Jean Boussier2023-04-145-151/+0
| | | | This reverts commit fce8f9f24e4903784266fc9694f86ddd930d6141.
* Add specs for ObjectSpace::WeakKeyMapJean Boussier2023-04-145-0/+151
| | | | [Feature #18498]
* [Bug #19533] Add spec of infinite range inclusionNobuyoshi Nakada2023-04-141-0/+6
|
* Removed file that is part of d89cc317c642848008f5b17a82196d25ddcdf124Hiroshi SHIBATA2023-04-111-16/+0
|
* [rubygems/rubygems] Remove one fallback to full indexes on big gemfilesDavid Rodríguez2023-04-074-32/+8
| | | | | | | | | | | | | | | | | | | If Gemfile has a lot of dependencies, we have an optimization that uses the full index in that case, assuming it's going to be faster. I think this is an old optimization that predates compact index API times, I believe we no longer need it these days. Also, since a few releases ago we check for circular dependencies when resolving by looping through all versions of each name and removing those that have circular dependencies that would trip up the resolver. This loop becomes actually very slow when full indexes are used because to find dependencies of a gemspec, we need to explicitly fetch the marshaled gemspec (`gemspec.rz` endpoint) for it, so the optimization has the opposite effect of making things very slow. https://github.com/rubygems/rubygems/commit/2f46289bd3
* [Bug #19584] Register global variables before assignmentNobuyoshi Nakada2023-04-071-3/+3
|
* Load only SyntaxSuggest::VERSION for version checkHiroshi SHIBATA2023-04-061-1/+1
|
* v1.0.4schneems2023-04-061-0/+34
|
* v1.0.3schneems2023-04-061-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | Fix a CI error and add a test to ensure we're testing the current version: ``` Run bundle exec rake test bundler: failed to load command: rake (/home/runner/work/syntax_suggest/syntax_suggest/vendor/bundle/ruby/3.2.0/bin/rake) /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/runtime.rb:309:in `check_for_activated_spec!': You have already activated syntax_suggest 1.0.2, but your Gemfile requires syntax_suggest 1.0.3. Since syntax_suggest is a default gem, you can either remove your dependency on it or try updating to a newer version of bundler that supports syntax_suggest as a default gem. (Gem::LoadError) from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/runtime.rb:25:in `block in setup' from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/spec_set.rb:138:in `each' from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/spec_set.rb:138:in `each' from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/runtime.rb:24:in `map' from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/runtime.rb:24:in `setup' from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler.rb:151:in `setup' from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/setup.rb:20:in `block in <top (required)>' from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/ui/shell.rb:136:in `with_level' from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/ui/shell.rb:88:in `silence' from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/setup.rb:20:in `<top (required)>' from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/cli/exec.rb:56:in `require_relative' from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/cli/exec.rb:56:in `kernel_load' from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/cli/exec.rb:23:in `run' from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/cli.rb:483:in `exec' from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run' ```
* [ruby/syntax_suggest] Rollback comment indentation behaviorschneems2023-04-062-4/+3
| | | | | | Originally I fixed https://github.com/ruby/syntax_suggest/pull/177 by making the process of comment removal indentation aware. The next commit is the more general fix and means we don't need to carry that additional logic/overhead. Also: Update syntax via linter
* [ruby/syntax_suggest] Add comments and refactor AroundBlockScan methodsschneems2023-04-062-54/+2
| | | | https://github.com/ruby/syntax_suggest/commit/cecd12292c
* [ruby/syntax_suggest] Fix sibling bug to #177schneems2023-04-064-3/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While #177 is reported as being caused by a comment, the underlying behavior is a problem due to the newline that we generated (from a comment). The prior commit fixed that problem by preserving whitespace before the comment. That guarantees that a block will form there from the frontier before it will be expanded there via a "neighbors" method. Since empty lines are valid ruby code, it will be hidden and be safe. ## Problem setup This failure mode is not fixed by the prior commit, because the indentation is 0. To provide good results, we must make the algorithm less greedy. One heuristic/signal to follow is developer added newlines. If a developer puts a newline between code, it's more likely they're unrelated. For example: ``` port = rand(1000...9999) stub_request(:any, "localhost:#{port}") query = Cutlass::FunctionQuery.new( port: port ).call expect(WebMock).to have_requested(:post, "localhost:#{port}"). with(body: "{}") ``` This code is split into three chunks by the developer. Each are likely (but not guaranteed) to be intended to stand on their own (in terms of syntax). This behavior is good for scanning neighbors (same indent or higher) within a method, but bad for parsing neighbors across methods. ## Problem Code is expanded to capture all neighbors, and then it decreases indent level which allows it to capture surrounding scope (think moving from within the method to also capturing the `def/end` definition. Once the indentation level has been increased, we go back to scanning neighbors, but now neighbors also contain keywords. For example: ``` 1 def bark 2 3 end 4 5 def sit 6 end ``` In this case if lines 4, 5, and 6 are in a block when it tries to expand neighbors it will expand up. If it stops after line 2 or 3 it may cause problems since there's a valid kw/end pair, but the block will be checked without it. TLDR; It's good to stop scanning code after hitting a newline when you're in a method...it causes a problem scanning code between methods when everything inside of one of the methods is an empty line. In this case it grabs the end on line 3 and since the problem was an extra end, the program now compiles correctly. It incorrectly assumes that the block it captured was causing the problem. ## Extra bit of context One other technical detail is that after we've decided to stop scanning code for a new neighbor block expansion, we look around the block and grab any empty newlines. Basically adding empty newlines before of after a code block do not affect the parsing of that block. ## The fix Since we know that this problem only happens when there's a newline inside of a method and we know this particular failure mode is due to having an invalid block (capturing an extra end, but not it's keyword) we have all the metadata we need to detect this scenario and correct it. We know that the next line above our block must be code or empty (since we grabbed extra newlines). Same for code below it. We can count all the keywords and ends in the block. If they are balanced, it's likely (but not guaranteed) we formed the block correctly. If they're imbalanced, look above or below (depending on the nature of the imbalance), check to see if adding that line would balance the count. This concept of balance and "leaning" comes from work in https://github.com/ruby/syntax_suggest/pull/152 and has proven useful, but not been formally introduced into the main branch. ## Outcome Adding this extra check introduced no regressions and fixed the test case. It might be possible there's a mirror or similar problem that we're not handling. That will come out in time. It might also be possible that this causes a worse case in some code not under test. That too would come out in time. One other possible concern to adding logic in this area (which is a hot codepath), is performance. This extra count check will be performed for every block. In general the two most helpful performance strategies I've found are reducing total number of blocks (therefore reducing overall N internal iterations) and making better matches (the parser to determine if a close block is valid or not is a major bottleneck. If we can split valid code into valid blocks, then it's only evaluated by the parser once, where as invalid code must be continuously re-checked by the parser until it becomes valid, or is determined to be the cause of the core problem. This extra logic should very rarely result in a change, but when it does it should tend to produce slightly larger blocks (by one line) and more accurate blocks. Informally it seems to have no impact on performance: `` This branch: DEBUG_DISPLAY=1 bundle exec rspec spec/ --format=failures 3.01s user 1.62s system 113% cpu 4.076 total ``` ``` On main: DEBUG_DISPLAY=1 bundle exec rspec spec/ --format=failures 3.02s user 1.64s system 113% cpu 4.098 total ``` https://github.com/ruby/syntax_suggest/commit/13739c6946
* [ruby/syntax_suggest] Preserve whitespace in front of commentsschneems2023-04-064-21/+52
| | | | | | When removing comments I previously replaced them with a newline. This loses some context and may affect the order of the indent search which in turn affects the final result. By preserving whitespace in front of the comment, we preserve the "natural" indentation order of the line while also allowing the parser/lexer to see and join naturally consecutive (method chain) lines. close https://github.com/ruby/syntax_suggest/pull/177
* [rubygems/rubygems] Fix resolver hangs when dealing with an incomplete lockfileDavid Rodríguez2023-04-061-0/+23
| | | | | | | | | | | | | | | | While working on locking multiple platforms by default, I got an infinite resolution loop in one of our resolver specs. The culprit ended up being that when dealing with lockfile specs with incomplete dependencies (spec appears in lockfile, but its dependencies don't), those specs were not being properly expired and that tripped up resolution. The issue for some reason only manifests when dealing with multiple lockfile platforms, that's why it only manifested when working on locking multiple platforms by default. https://github.com/rubygems/rubygems/commit/4ca72913bb
* Revert "Fix transient heap mode"Aaron Patterson2023-04-041-11/+0
| | | | | | | | This reverts commit 87253d047ce35e7836b6f97edbb4f819879a3b25. Revert "Implement `Process.warmup`" This reverts commit ba6ccd871442f55080bffd53e33678c0726787d2.
* Implement `Process.warmup`Jean Boussier2023-04-041-0/+11
| | | | | | | | | | | | [Feature #18885] For now, the optimizations performed are: - Run a major GC - Compact the heap - Promote all surviving objects to oldgen Other optimizations may follow.
* [rubygems/rubygems] Onboard Rubocop Naming/MemoizedInstanceVariableName rule ↵Josef Šimánek2023-03-281-5/+5
| | | | | | to Bundler. https://github.com/rubygems/rubygems/commit/d768be0c65
* [rubygems/rubygems] Fix installing plugins in frozen modeDavid Rodríguez2023-03-281-0/+7
| | | | | | Plugins don't use a lockfile, so ignore frozen related settings. https://github.com/rubygems/rubygems/commit/f17a3bb81f
* [rubygems/rubygems] Fix incorrect removal of "ruby" platform from lockfileDavid Rodríguez2023-03-281-0/+50
| | | | | | | | | | | | When dependencies have changed, we'll be re-resolving, and we can't really know whether the resolution will be valid or invalid for the Ruby platform, so skip the removal in that case. The fix worked, but made some other specs fail, and surfaced that the `@dependencies_changed` attribute was actually being incorrect set when explicitly unlocking. Fixed that with an early return. https://github.com/rubygems/rubygems/commit/20d8f5e5d9
* [rubygems/rubygems] Fix unnecessary downgrade of top level dependency when ↵David Rodríguez2023-03-281-0/+83
| | | | | | | | | | | | | | | | | | | | | | | unlocking Bundler is very conservative by default, trying to preserve versions from the lockfile as possible, and never downgrading them. However, when it runs into a resolution error, it still tries to find a valid resolution. This fallback behavior was too "brute-force" though, completely unrestricting any gem found in the resolution conflict, and that could lead to direct dependencies being downgraded in some edge cases. Instead, unlock things a bit more carefully: * First try unlocking fully pinned indirect dependencies, but leave a lower bound requirement in place to prevent downgrades. * Then try unlocking any fully pinned dependency, also leaving a lower bound requirement in place. * Finally completely unrestrict dependencies if nothing else worked. https://github.com/rubygems/rubygems/commit/7f55ed8302
* [rubygems/rubygems] Rewrite GemVersionPromoter specsMichael Siegfried2023-03-281-124/+111
| | | | | | | | | | | | | | | Add tests for pre, move more of the setup into a helper method, and restructure tests. There seem to be five considerations for these tests (level, pre, strict, locked, and whether the current version is a prerelease version, though the last one overlaps with pre and didn't seem to behave how I expected under test). Rather than write out the 16 (/32 if the last consideration is real) combinations, I wrote most with independent tests for each value. The existing combined tests were maintained (level vs strict) because these seem the most interrelated. https://github.com/rubygems/rubygems/commit/74c23a91b2
* Raise ArgumentError if IO.read is provided negative offsetJeremy Evans2023-03-241-3/+12
| | | | Fixes [Bug #19380]
* Add Dir.fchdirJeremy Evans2023-03-241-0/+78
| | | | | | | | | | | | This is useful for passing directory file descriptors over UNIX sockets or to child processes to avoid TOCTOU vulnerabilities. The implementation follows the Dir.chdir code. This will raise NotImplementedError on platforms not supporting both fchdir and dirfd. Implements [Feature #19347]
* Change Hash#compact to keep default values and compare_by_identity flagJeremy Evans2023-03-241-0/+24
| | | | | | | | | The documentation states it returns a copy of self with nil value entries removed. However, the previous behavior was creating a plain new hash with non-nil values copied into it. This change aligns the behavior with the documentation. Fixes [Bug #19113]
* Copy compare_by_identity flag for empty hashes in Hash.ruby2_keywords_hashJeremy Evans2023-03-241-0/+24
| | | | | | | This was already copied for non-empty hashes. As Hash.ruby2_keywords_hash copies default values, it should also copy the compare_by_identity flag. Partially Fixes [Bug #19113]
* Do not copy compare_by_identity flag for non-empty hashes in Hash.[]Jeremy Evans2023-03-241-0/+18
| | | | | | | | It wasn't copied for empty hashes, and Hash.[] doesn't copy the default value, so copying the compare_by_identity flag does not make sense. Partially Fixes [Bug #19113]