Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bring back test timeouts #741

Merged
merged 1 commit into from Dec 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions spec/rails_spec.rb
@@ -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
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