Skip to content

Commit

Permalink
bring back test timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
grosser committed Dec 18, 2019
1 parent d6872cf commit d1400f6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions spec/rails_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require 'spec_helper'

describe 'rails' do
let(:test_timeout) { 600 } # this can take very long on fresh bundle ...

def sh(command, options={})
result = ''
IO.popen(options.fetch(:environment, {}), command, err: [:child, :out]) do |io|
Expand All @@ -10,6 +12,7 @@ def sh(command, options={})
result
end

# TODO: rails 6
%w(rails51 rails52).each do |rails|
it "can create and run #{rails}" do
if RUBY_PLATFORM == "java"
Expand Down
9 changes: 9 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ def setup_runtime_log
end
end

TestTookTooLong = Class.new(Timeout::Error)

RSpec.configure do |config|
config.filter_run :focus => true
config.run_all_when_everything_filtered = true
Expand All @@ -188,6 +190,13 @@ def setup_runtime_log

config.raise_errors_for_deprecations!

# sometimes stuff hangs -> do not hang everything
# NOTE: the timeout error can sometimes swallow errors, comment it out if you run into trouble
config.include(Module.new {def test_timeout;30;end })
config.around do |example|
Timeout.timeout(test_timeout, TestTookTooLong, &example)
end

config.after do
ENV.delete "PARALLEL_TEST_GROUPS"
ENV.delete "PARALLEL_TEST_PROCESSORS"
Expand Down

0 comments on commit d1400f6

Please sign in to comment.