Skip to content

Commit e3b9597

Browse files
committed
Remove warning capture; more trouble than worth
1 parent 2a171da commit e3b9597

File tree

4 files changed

+3
-141
lines changed

4 files changed

+3
-141
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ Style/EachWithObject:
9898
Style/GuardClause:
9999
Exclude:
100100
- 'lib/active_model/serializer.rb'
101-
- 'test/capture_warnings.rb'
102101

103102
# Offense count: 12
104103
# Cop supports --auto-correct.

.travis.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ cache:
1616
- vendor/bundle
1717

1818
script:
19-
- env CAPTURE_STDERR=${CAPTURE_STDERR:-false} bundle exec rake ci
19+
- bundle exec rake ci
2020

2121
env:
2222
- "RAILS_VERSION=4.0"
@@ -31,8 +31,6 @@ matrix:
3131
- rvm: 2.1
3232
env: RAILS_VERSION=master
3333
include:
34-
- rvm: 2.2
35-
env: CAPTURE_STDERR=true
3634
- rvm: jruby-9.0.4.0
3735
env: JRUBY_OPTS='-Xcompat.version=2.0 --server -Xcompile.invokedynamic=false -Xcli.debug=true --debug'
3836
allow_failures:

test/capture_warnings.rb

Lines changed: 0 additions & 77 deletions
This file was deleted.

test/test_helper.rb

Lines changed: 2 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -20,47 +20,28 @@
2020
require 'fileutils'
2121
FileUtils.mkdir_p(File.expand_path('../../tmp/cache', __FILE__))
2222

23-
# https://github.com/seattlerb/minitest/blob/master/lib/minitest/autorun.rb
2423
gem 'minitest'
2524
begin
2625
require 'minitest'
2726
rescue LoadError
2827
# Minitest 4
29-
require 'minitest/unit'
30-
require 'minitest/spec'
31-
require 'minitest/mock'
28+
require 'minitest/autorun'
3229
$minitest_version = 4
33-
# Minitest 4
3430
# https://github.com/seattlerb/minitest/blob/644a52fd0/lib/minitest/autorun.rb
3531
# https://github.com/seattlerb/minitest/blob/644a52fd0/lib/minitest/unit.rb#L768-L787
3632
# Ensure backward compatibility with Minitest 4
3733
Minitest = MiniTest unless defined?(Minitest)
3834
Minitest::Test = MiniTest::Unit::TestCase
39-
minitest_run = ->(argv) { MiniTest::Unit.new.run(argv) }
4035
else
4136
# Minitest 5
37+
require 'minitest/autorun'
4238
$minitest_version = 5
43-
# Minitest 5
4439
# https://github.com/seattlerb/minitest/blob/e21fdda9d/lib/minitest/autorun.rb
4540
# https://github.com/seattlerb/minitest/blob/e21fdda9d/lib/minitest.rb#L45-L59
46-
require 'minitest/spec'
47-
require 'minitest/mock'
48-
minitest_run = ->(argv) { Minitest.run(argv) }
4941
end
5042
require 'minitest/reporters'
5143
Minitest::Reporters.use!
5244

53-
# If there's no failure info, try disabling capturing stderr:
54-
# `env CAPTURE_STDERR=false rake`
55-
# This is way easier than writing a Minitest plugin
56-
# for 4.x and 5.x.
57-
if ENV['CAPTURE_STDERR'] !~ /false|1/i
58-
require 'capture_warnings'
59-
minitest_run = CaptureWarnings.new(_fail_build = true).execute!(minitest_run)
60-
else
61-
$VERBOSE = true
62-
end
63-
6445
require 'active_model_serializers'
6546
require 'active_model/serializer/railtie'
6647

@@ -82,42 +63,3 @@
8263
$action_controller_logger = ActiveModelSerializers.logger
8364
ActiveModelSerializers.logger = Logger.new(IO::NULL)
8465
end
85-
86-
# From:
87-
# https://github.com/seattlerb/minitest/blob/644a52fd0/lib/minitest/unit.rb#L768-L787
88-
# https://github.com/seattlerb/minitest/blob/e21fdda9d/lib/minitest.rb#L45-L59
89-
# But we've replaced `at_exit` with `END` called before the 'at_exit' hook.
90-
class MiniTestHack
91-
def self.autorun(minitest_run)
92-
# don't run if there was a non-exit exception
93-
return if $! and not ($!.kind_of? SystemExit and $!.success?)
94-
95-
# Original Comment:
96-
# the order here is important. The at_exit handler must be
97-
# installed before anyone else gets a chance to install their
98-
# own, that way we can be assured that our exit will be last
99-
# to run (at_exit stacks).
100-
#
101-
# Now:
102-
# The after_run blocks now only run on SigEXIT, which is fine.
103-
exit_code = nil
104-
105-
trap('EXIT') do
106-
if $minitest_version == 5
107-
@@after_run.reverse_each(&:call)
108-
else
109-
@@after_tests.reverse_each(&:call)
110-
end
111-
112-
exit exit_code || false
113-
end
114-
115-
exit_code = minitest_run.call(ARGV)
116-
end
117-
end
118-
# Run MiniTest in `END`, so that it finishes before `at_exit` fires,
119-
# which guarantees we can run code after MiniTest finishes
120-
# via an `at_exit` block.
121-
# This is in service of silencing non-app warnings during test run,
122-
# and leaves us with the warnings in our app.
123-
END { MiniTestHack.autorun(minitest_run) }

0 commit comments

Comments
 (0)