Commit Graph

8084 Commits

Author SHA1 Message Date
Jean Boussier a707072ffa Implicitly assert no exception is raised in block assertions 2019-10-07 11:01:24 +02:00
Kasper Timm Hansen cb823c1244
Merge pull request #37100 from jonathanhefner/fix-irb-tab-completion-warning
Fix IRB deprecation warning on tab-completion
2019-10-07 03:03:35 +02:00
Kasper Timm Hansen eca6c273fe
[ci skip] switch eg. to proper e.g. 2019-10-07 02:18:36 +02:00
Daniel Ritz f3260272f2 fix(fork-tracker): Only patch fork if it's supported
Some tests are currently wrapped with
  `if Process.respond_to?(:fork)`
but they're still executed on JRuby. The problem is that ForkTracker
unconditionally patches `#fork` so `Process` does indeed
`respond_to? :fork`.

Fix it by installing the patch conditionally with the same check.
2019-10-06 23:41:37 +02:00
Juanjo Bazán b24190807d update https urls [ci skip] 2019-10-03 11:01:32 +02:00
Brandon Medenwald 6229c2b223 Redis cache store: fail gracefully when max clients reached 2019-10-01 13:24:22 -04:00
Rafael Mendonça França 57ae917e9d Remove any precision problem by comparing the float values
Rational values are move precise than float values so when comparing
rationals values may be off by a few units that are hard to assert
equality. Let's make sure we are comparing the float value with float
values.
2019-09-30 23:20:22 -04:00
John Hawthorn 4484db4094 Fix fraction float assertions in time_ext_test
These failed previously because decimals floats don't make perfect
decimal numbers and Rational represents them exactly (either as decimal
or the inexact float value).

This changes the asserts to match that value.
2019-09-30 15:51:15 -07:00
Rafael Mendonça França d96a715859 Decrease the precision of the sec_fraction in the tests
We were using picoseconds as precision but some Ruby implementations
only support up to nanoseconds. Since that much precision was not needed
to test the feature I decreased the precision.
2019-09-30 18:19:48 -04:00
Étienne Barrié 7ca163d8c3 Also override Kernel#fork 2019-09-30 17:05:37 -04:00
Étienne Barrié f223c795e8 Keep Object#fork private 2019-09-30 17:05:37 -04:00
Jean Boussier 78b9580e5f Introduce a callback for forked children
We hook into Kernel#fork and Process#fork, when they are invoked
we can trigger all the registered callbacks.

There is also a `check!` method that can be called to very cheaply
detect if the process was forked.
2019-09-30 12:04:59 +02:00
Rafael Mendonça França b0b2ae8b8d Skip test is all Ruby implementations that don't support fork 2019-09-26 18:27:00 -04:00
Benoit Daloze 207974e04e Use String#+@ before mutating the result of Symbol#to_s
* String#+@ is available since Ruby 2.3.
* See the upstream Ruby change making Symbol#to_s return a frozen String
  for efficiency: https://github.com/ruby/ruby/pull/2437
2019-09-26 10:24:17 +02:00
George Claghorn 75a53297c7
Add ActionController::Base.log_at
Allow setting a different log level per request.
2019-09-24 13:47:34 -04:00
Akira Matsuda 491ab85207 Unify rotate method definitions to take keyword arguments 2019-09-24 13:48:14 +09:00
Carlos Antonio da Silva 6001af630f Merge changelogs about `Range` support improvements [ci skip] 2019-09-20 19:03:35 -03:00
Carlos Antonio da Silva 7cc10576e9
Merge pull request #37178 from pond/fix-boundless-range-extensions
Fix issues with ActiveSupport Range extensions on boundless Ranges

Closes #37177
2019-09-20 18:59:34 -03:00
Akira Matsuda 0fa8c0a1d9 Reduce Array allocations 2019-09-18 14:56:28 +09:00
Rafael França a1b6c1669f
Merge pull request #37210 from jonhyman/feature-fix-36956-rebased
Fixes #36956 by dup'ing the value and entry object returned from MemoryStore.
2019-09-16 13:30:01 -04:00
Jonathan Hyman 948c3c8bd5 Fixes #36956 by dup'ing the value and entry object returned from MemoryStore. 2019-09-16 08:37:59 -04:00
Andrew Hodgkinson a7d0916410 Fix issues with ActiveSupport Range extensions on boundless Ranges
Address complaints by CodeClimate

Address review feedback
2019-09-16 10:03:04 +12:00
George Claghorn d41e282a94 Prefer assert_not_includes 2019-09-13 13:56:12 -04:00
George Claghorn ffc8475db8
Fix setting a more verbose thread-local log level
We prepend a check against the thread-local level to Logger#add, but because it proceeds to check against the thread-global level, only setting a quieter thread-local level works. The quietest of the two wins. Fix by reimplementing #add entirely.

It's unfortunate to have to do this, but I've already patched upstream Logger to prefer the level instance method over the @level instance variable, so we'll be able to avoid touching #add at all in the future. See https://github.com/ruby/logger/pull/41.
2019-09-13 13:54:18 -04:00
Akira Matsuda 9e4ff29f74 No need to dup before double-splatting a Hash 2019-09-13 20:20:28 +09:00
Akira Matsuda cd31e113c0 Use keyword arguments instead of last parameter Hash
this would eliminate warnings when calling keyworded method,
and this still works with methods taking last parameter Hash
2019-09-13 19:22:05 +09:00
Akira Matsuda 154b7ffd97 Tests for OptionMerger with keyword arguments 2019-09-13 18:11:22 +09:00
Akira Matsuda 95a8be46ea require open-uri where opening URI 2019-09-13 17:22:16 +09:00
Akira Matsuda 9845cd6338 Separate keyword arguments from parameters 2019-09-13 16:21:32 +09:00
Akira Matsuda af45834139 nil.try accepts keyword arguments (and does nothing with them) 2019-09-09 22:48:22 +09:00
Sébastien Puyet 179a5b8770 Fix folders update watcher with no folders to watch (#36163)
* boot when there is folders to watch

* raise argument error when paths are empty

* add space between curly braces

* Revert "add space between curly braces"

This reverts commit 90cff20c87.

* Revert "raise argument error when paths are empty"

This reverts commit 349adff0f5.

* stop lazy loading listem gem

* back with any?

* require listen gem at top of the file

* improve

* remove scope resolution operator
2019-09-09 13:50:01 +02:00
Ryuta Kamizono bfacd45be0
Merge pull request #36460 from aldhsu/fix-endless-range-include
Fix endless range include
2019-09-09 13:14:03 +09:00
Allen Hsu d45a7f1e6a Support calling include? on beginless and endless ranges.
- Fixes https://github.com/rails/rails/issues/36451
2019-09-09 09:23:21 +10:00
Akira Matsuda 91712c5080 Fix Class#new + keyword arguments warnings 2019-09-09 01:02:39 +09:00
Akira Matsuda af99f45b58 Revert "Class#new also separates keyword arguments and optional hash"
This reverts commit 72c1aa21c1.

This causes CI fails on Ruby < 2.7
2019-09-08 09:44:47 +09:00
Akira Matsuda 72c1aa21c1 Class#new also separates keyword arguments and optional hash 2019-09-08 08:58:01 +09:00
Akira Matsuda 57bdfefaa4 else + ternary => elsif + else for clarity 2019-09-07 10:11:20 +09:00
Rafael França 0434e5ba23
Merge pull request #37105 from Shopify/optimize-module-delegate
Optimize Module#delegate to no longer be linear
2019-09-05 14:13:14 -04:00
Jean Boussier 0dde6ab960 Optimize Module#delegate to no longer be linear
The previous implementation is pretty much linear.
Delegating 10 methods is 10 times slower than delegating 1 method.

```
     old_delegate(1)     27.299k (± 2.7%) i/s -    138.216k in   5.066863s
     old_delegate(2)     14.372k (± 2.5%) i/s -     72.879k in   5.074092s
     old_delegate(3)      9.434k (± 7.3%) i/s -     47.750k in   5.092412s
     old_delegate(4)      6.771k (±10.4%) i/s -     33.810k in   5.060218s
     old_delegate(5)      5.733k (± 4.4%) i/s -     28.861k in   5.044486s
```

Beside a few micro-optimizations, this patch mostly try to call `module_eval`
only once, because it has a significant fixed cost every time it's called.

By concatening the method definitions to together, we gain performance when
multiple methods are delegated at once:

```
     new_delegate(1)     28.531k (± 2.6%) i/s -    143.052k in   5.017356s
     new_delegate(2)     16.751k (± 2.4%) i/s -     85.072k in   5.081371s
     new_delegate(3)     12.021k (± 3.0%) i/s -     61.048k in   5.083224s
     new_delegate(4)      9.433k (± 3.1%) i/s -     47.944k in   5.087528s
     new_delegate(5)      7.745k (± 3.0%) i/s -     38.849k in   5.020850s
```

Which is respectively 5%, 16%, 27%, 39% and 35% improvements.
2019-09-05 19:20:32 +02:00
Edouard CHIN 2c3d0eca27 Autoload the `AS::SecureCompareRotator` class:
- In 123bcf5faa I forgot to autoload that class which means
  requiring "activesupport/all" doesn't autoload it.
2019-09-05 13:13:09 +02:00
Akira Matsuda 3f27aa8cdf These `options` are not defined as keyword arguments
Fixes Ruby 2.6 warnings
2019-09-05 19:03:02 +09:00
Akira Matsuda c8e7f3ca7b Unify delete_multi_entries method signatute
or it warns on Ruby 2.6
2019-09-05 19:03:02 +09:00
y-yagi 58df38818a
Merge pull request #37114 from iainbeeston/patch-1
Don't use Process#clock_gettime CLOCK_PROCESS_CPUTIME_ID on Solaris
2019-09-05 11:47:24 +09:00
Iain Beeston b5fafb5caf Don't use `Process#clock_gettime(CLOCK_PROCESS_CPUTIME_ID)` on Solaris
Solaris returns `true` for `defined?(Process::CLOCK_PROCESS_CPUTIME_ID)` but calling `Process.clock_gettime(Process::CLOCK_PROCESS_CPUTIME_ID)` raises `Errno::EINVAL: Invalid argument - clock_gettime` when `ActiveSupport::Notifications::Event.now_cpu` is called.
2019-09-04 10:15:39 +01:00
Akira Matsuda 2c528dd446 Merging options donesn't have to be synchronized 2019-09-04 12:45:27 +09:00
Ryuta Kamizono 0770c025bd Do not enforce no braces for hash argument
Non-kwargs parameters should be to be braced for https://github.com/ruby/ruby/pull/2395.
See https://bugs.ruby-lang.org/issues/14183 for details.

`Style/BracesAroundHashParameters` cop conflicts with that.

This removes `Style/BracesAroundHashParameters` cop and auto-correct to
following changes.

d94263f...5665fb5
2019-09-04 08:49:36 +09:00
Jonathan Hefner 5c80059c33 Fix IRB deprecation warning on tab-completion
IRB invokes `#hash` (via a call to `Hash#include?`) and
`#instance_methods` on each object in `ObjectSpace.each_object(Module)`
when performing tab-completion on chain of method calls.  This patch
prevents a deprecation warning from being printed when any of those
objects are a `ActiveSupport::Deprecation::DeprecatedConstantProxy`.

Fixes #37097.
2019-09-03 17:16:29 -05:00
Akira Matsuda 3cfd6d1d44 Introduce keyword arguments for some AS::Cache methods
since RedisCacheStore#write_entry takes kwargs, we needed to kwargsify all these methods
in order to eliminate Ruby 2.7 warnings.

It's a little bit bigger patch than I expected, but it doesn't warn on Ruby 3,
and it doesn't introduce any incompatibility on loder rubies, so it may not be a bad thing anyway.
2019-09-03 17:48:40 +09:00
Akira Matsuda 81230c610f Unify the API with Messages::Rotator::Verifier#verify that takes kwargs 2019-09-03 17:48:40 +09:00
Akira Matsuda 575d4d1348 subscribe block doesn't take keyword arguments 2019-09-03 17:48:40 +09:00