Skip to content

Commit bc8c4ee

Browse files
committed
Put timeout logic on the integration tests
1 parent 7b8b1f8 commit bc8c4ee

File tree

2 files changed

+8
-21
lines changed

2 files changed

+8
-21
lines changed

spec/octocatalog-diff/integration/integration_helper.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,14 @@ def self.integration(options = {})
125125
$stdout = stdout_strio
126126

127127
# Run the OctocatalogDiff::Cli.cli and validate output format.
128-
result = begin
129-
timeout(120, Timeout::Error) { OctocatalogDiff::Cli.cli(argv, logger, options) }
130-
rescue Timeout::Error => e
131-
OpenStruct.new(exitcode: 255, exception: e, diffs: [], to: nil, from: nil)
128+
result = nil
129+
3.times do
130+
begin
131+
result = timeout(120, Timeout::Error) { OctocatalogDiff::Cli.cli(argv, logger, options) }
132+
rescue Timeout::Error => e
133+
warn "Warning: #{e.class} #{e.message}"
134+
end
135+
break if result
132136
end
133137

134138
if result.is_a?(Integer)

spec/octocatalog-diff/tests/spec_helper.rb

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,6 @@
3232
config.display_try_failure_messages = true
3333
end
3434

35-
# We should not have any individual tests that take more than 10 seconds, so
36-
# set the timeout here to reap any that get stuck. Hopefully this will prevent
37-
# jobs from intermittently timing out on travis CI.
38-
# Inspired by https://github.com/basho/innertube/blob/master/spec/support/timeout.rb
39-
RSpec.configure do |config|
40-
config.around(:each) do |example|
41-
time = example.metadata[:timeout] || 10
42-
begin
43-
timeout(time, Timeout::Error) do
44-
example.run
45-
end
46-
rescue Timeout::Error => e
47-
example.send :set_exception, e
48-
end
49-
end
50-
end
51-
5235
module OctocatalogDiff
5336
class Spec
5437
# Set up a logger that is usable across parent and child forks.

0 commit comments

Comments
 (0)