Commit Graph

20 Commits

Author SHA1 Message Date
Hartley McGuire
8f6ee6487f
Fix skips in Active Support
The change to serialization mirrors the test just below it that also
uses a conditional for the assertion instead of a skip. The conditional
is necessary because memcached entries are not strings.

The class_serial test should not run on Ruby 3.2+ because class_serial
was replaced with Object Shapes. The class_serial value in RubyVM.stat
was removed in ruby/ruby@13bd617ea6
2023-11-30 11:11:22 -05:00
Akira Matsuda
60ffaac2e9
RubyVM class serial is no longer available in Ruby 3.2
since ruby/ruby@13bd617ea6
2022-12-15 15:45:27 +09:00
Jean Boussier
a6dbfcdc23 Rails.error.report now marks errors as reported to avoid reporting them twice
This is done by setting a special instance variable on the exception.

Another implementation could be to use an `ObjectSpace::WeakMap` as
a weak reference set, but I figured 3rd party error reporting libraries
may want to inspect wether the error was reported.
2022-09-26 17:58:08 +02:00
Jean Boussier
115be62709 Wrap rails runner in executor
The main reason is to automatically report uncaught exceptions
since `rails runner` is often used for cron tasks and such.
2022-06-10 14:16:49 +02:00
Jean Boussier
c9a2bc284c Error reporting API: Add a source attribute
Ref: https://github.com/rails/rails/pull/43625#issuecomment-1109595539

Some users may not be interested by some internal errors.
By providing a `source` attribute we allow to easilly filter
these errors out.
2022-05-05 10:57:21 +02:00
Matthew Draper
e4140140af Warm-up to avoid autoloads interfering with class serial 2022-02-22 21:00:16 +10:30
Jean Boussier
8cbc19d86b Rails standardized error reporting interface
Fix: https://github.com/rails/rails/issues/43472

The reporter is held by the executor, but the `Rails` module provides a
nicer `Rails.error` shortcut.

For ease of use, two block based specialized methods are exposed.

`handle`, which swallow errors and forward them to the subscribers:

```ruby
Rails.error.handle do
  1 + '1' # raises TypeError
end
1 + 1 # This will be executed
```

`record`, which forward the errors to the subscribes but let it
continue rewinding the call stack:

```ruby
Rails.error.record do
  1 + '1' # raises TypeError
end
1 + 1 # This won't be executed.
```

For cases where the blocked based API isn't suitable, the lower level
`report` method can be used:

```ruby
Rails.error.report(error, handled: true / false)
```
2021-11-16 13:34:53 +01:00
Michael Grosser
203998c916
allow running each test with pure ruby path/to/test.rb
also:
 - makes test dependencies obvious
 - makes tests runnable from within subfolders
2019-12-18 08:49:19 -06:00
Rafael Mendonça França
f679933daa
Change the empty block style to have space inside of the block 2018-09-25 13:19:35 -04:00
Koichi ITO
ac717d65a3 [Active Support] rubocop -a --only Layout/EmptyLineAfterMagicComment 2017-07-11 13:12:32 +09:00
Kir Shatrov
72950568dd Use frozen-string-literal in ActiveSupport 2017-07-09 15:08:29 +03:00
Matthew Draper
87b3e226d6 Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"
This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing
changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
2017-07-02 02:15:17 +09:30
Kir Shatrov
cfade1ec7e Enforce frozen string in Rubocop 2017-07-01 02:11:03 +03:00
Akira Matsuda
e8ba0c0f21 "Use assert_nil if expecting nil. This will fail in minitest 6." 2016-12-25 02:29:52 +09:00
Charles Oliver Nutter
9531e69f99 Skip test that depends on RubyVM when it is not available (JRuby). 2016-10-21 14:36:51 -05:00
Matthew Draper
e8b36e7711 Avoid bumping the class serial when invoking executor 2016-10-03 13:35:51 +10:30
Rafael Mendonça França
55f9b8129a
Add three new rubocop rules
Style/SpaceBeforeBlockBraces
Style/SpaceInsideBlockBraces
Style/SpaceInsideHashLiteralBraces

Fix all violations in the repository.
2016-08-16 04:30:11 -03:00
Xavier Noria
a731125f12 applies new string literal convention in activesupport/test
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 18:10:53 +02:00
Matthew Draper
291a098c11 Directly support stateful executor hooks
Also, make sure to call the +complete+ hooks if +run+ fails.
2016-04-05 06:57:01 +09:30
Matthew Draper
d3c9d808e3 Publish AS::Executor and AS::Reloader APIs
These should allow external code to run blocks of user code to do
"work", at a similar unit size to a web request, without needing to get
intimate with ActionDipatch.
2016-03-02 02:14:20 +10:30