selective-ruby-core 0.2.10 → 0.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9f6dbb5b565e9daa33dd9734e130efafcbb431372ee74eafc3b1e61356b94f2a
4
- data.tar.gz: 9a4252a640d2a396d6d8b6cde0817566c9940ff569bceeb049260a062f6b9e73
3
+ metadata.gz: f410f920d6ebee58d8bd5baa92a50b85acde8ea3b4bd6d22591df39d7fd2d037
4
+ data.tar.gz: 6139327221ff4aa47f187ab663ac60c8854f97629981ed3f6d34dc2b12c37a0a
5
5
  SHA512:
6
- metadata.gz: 5db64c1685e6c52cf3bca4d08c27b5cc3461f2162b8e9d587fd87872c7f73012d96a14c2260d7b2e6650661e6a07163a0ed379aa6019459beb91591e4ea79dcb
7
- data.tar.gz: 4f0755272db64264a15727ce35a1d8a896953a0f192617d9b9eff0afbe46b3d8f7f1211e11de45cc4b9987e91d6b5092a6636024e6fefe1a240e585e63da2984
6
+ metadata.gz: 68b7dca7fd3b5388b94e0eb3218b3cbb5cffcb948a6f4110a84269c6b4ed062a40a1e282d9ecf6e101cc140732d0ecd561e34434f817f760442c7aeb76f385ba
7
+ data.tar.gz: 8765865c0b34d02ac2654620dcb597f56d4014e9df44eb2555917149d5526d2bdec9dbc9bea9a25026ed13a56220f29429f389105d3808747cb2ed99930db94a
@@ -29,15 +29,19 @@ module Selective
29
29
  @retries = 0
30
30
  end
31
31
 
32
+ # A lost connection is retried by looping here, not by calling start
33
+ # again from inside the rescue clause. Everything a reconnected runner
34
+ # does -- the rest of the run, the close, the framework's after_run
35
+ # hooks -- would otherwise run inside that clause, where `$!` is still
36
+ # the ConnectionLostError. SimpleCov's after_run hook reads that as the
37
+ # run having crashed and exits 1, so every CI shard whose connection
38
+ # dropped once failed with no failing test.
32
39
  def start(reconnect: false)
33
- @pipe = NamedPipe.new("/tmp/#{runner_id}_2", "/tmp/#{runner_id}_1")
34
- @transport_pid = spawn_transport_process(reconnect: reconnect)
40
+ loop do
41
+ break if connect_and_run(reconnect: reconnect)
35
42
 
36
- handle_termination_signals(transport_pid)
37
- wait_for_connectivity
38
- run_main_loop
39
- rescue ConnectionLostError
40
- retry!
43
+ reconnect = true
44
+ end
41
45
  rescue => e
42
46
  with_error_handling { raise e }
43
47
  end
@@ -106,7 +110,22 @@ module Selective
106
110
  end
107
111
  end
108
112
 
109
- def retry!
113
+ # One connection: true when the run finished on it, false when it was
114
+ # lost and the caller should reconnect.
115
+ def connect_and_run(reconnect:)
116
+ @pipe = NamedPipe.new("/tmp/#{runner_id}_2", "/tmp/#{runner_id}_1")
117
+ @transport_pid = spawn_transport_process(reconnect: reconnect)
118
+
119
+ handle_termination_signals(transport_pid)
120
+ wait_for_connectivity
121
+ run_main_loop
122
+ true
123
+ rescue ConnectionLostError
124
+ prepare_retry!
125
+ false
126
+ end
127
+
128
+ def prepare_retry!
110
129
  @retries += 1
111
130
 
112
131
  with_error_handling { raise "Too many retries" } if retries > 10
@@ -116,7 +135,6 @@ module Selective
116
135
  kill_transport
117
136
 
118
137
  pipe.reset!
119
- start(reconnect: true)
120
138
  end
121
139
 
122
140
  def write(data)
@@ -3,7 +3,7 @@
3
3
  module Selective
4
4
  module Ruby
5
5
  module Core
6
- VERSION = "0.2.10"
6
+ VERSION = "0.2.11"
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selective-ruby-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.10
4
+ version: 0.2.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Wood