rspec-interactive 0.9.7 → 0.9.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19e7c3fad7abad85f3523490ddfcfd3d6091e042d99fd940c6a9a19991e7dc06
4
- data.tar.gz: 02d25e506765d4f0c40b8b3e64ae751f6da34e06af9e845830bdc05071fc8112
3
+ metadata.gz: 895c315e10777f7d94c8efdf005129bb532463b31d764af1ddd079692b3e0e62
4
+ data.tar.gz: 264d523cfc32ffab312ef3d9323611c05f00d851d755d5cf53735680eac0ce4a
5
5
  SHA512:
6
- metadata.gz: 89b49ff9d0e888b8304e0c70a2fded4dd780381750fed960af5f282246accc6ae6d52eb71c5402d2be31bfb9a827c64e04cffcb7f4935d12d97e3d632843a8bf
7
- data.tar.gz: 36320560582c44d1459e0590aa469f56e70b5411d8c3c88a499ca9f46c5075163aa3778869f65bb5cfd85dc3fc7dd196fff65c87733b5b0057352353583215c6
6
+ metadata.gz: 47ca24fe9e49e7ea070c62b3786d72232cb52eabc2faac4777b913099c515a4cb9a0eaeb2515ab204637c344824461fcfdc6e3a460082ca1384bf57d2e04e773
7
+ data.tar.gz: f7d35eb450b116bb275eac5eaf729d37af936464e18ce9015d3bea953b6204517212299c923eb9e114182b120df3ad3868112be716bd9bd20d6de2c2c8c6326d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-interactive (0.9.6)
4
+ rspec-interactive (0.9.7)
5
5
  listen
6
6
  pry
7
7
  rspec-core
@@ -17,6 +17,13 @@ module RSpec
17
17
  @client.print(str.to_s + "\n")
18
18
  end
19
19
 
20
+ def flush
21
+ end
22
+
23
+ def closed?
24
+ @client.closed?
25
+ end
26
+
20
27
  def string
21
28
  @output
22
29
  end
@@ -1,52 +1,13 @@
1
1
  module RSpec
2
2
  module Interactive
3
3
  class Stdio
4
- def self.capture2(stdout:, stderr:)
4
+ def self.capture(stdout:, stderr:)
5
5
  old_stdout, old_stderr = $stdout, $stderr
6
6
  $stdout, $stderr = stdout, stderr
7
7
  yield
8
8
  ensure
9
9
  $stdout, $stderr = old_stdout, old_stderr
10
10
  end
11
-
12
- def self.capture(stdout:, stderr:)
13
- raise ArgumentError, 'missing block' unless block_given?
14
-
15
- old_stdout, old_stderr = STDOUT.dup, STDERR.dup
16
-
17
- IO.pipe do |stdout_read, stdout_write|
18
- IO.pipe do |stderr_read, stderr_write|
19
- STDOUT.reopen(stdout_write)
20
- STDERR.reopen(stderr_write)
21
-
22
- stdout_write.close
23
- stderr_write.close
24
-
25
- stdout_thread = Thread.new do
26
- while line = stdout_read.gets do
27
- stdout.print(line)
28
- end
29
- end
30
-
31
- stderr_thread = Thread.new do
32
- while line = stderr_read.gets do
33
- stderr.print(line)
34
- end
35
- end
36
-
37
- begin
38
- yield
39
- ensure
40
- # TODO: should the threads be killed here?
41
- STDOUT.reopen old_stdout
42
- STDERR.reopen old_stderr
43
- end
44
-
45
- stdout_thread.join
46
- stderr_thread.join
47
- end
48
- end
49
- end
50
11
  end
51
12
  end
52
13
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module Interactive
5
- VERSION = "0.9.7"
5
+ VERSION = "0.9.8"
6
6
  end
7
7
  end
@@ -61,9 +61,6 @@ module RSpec
61
61
  configure_pry
62
62
 
63
63
  @startup_thread = Thread.start do
64
- @config_cache.record_configuration { @configuration.configure_rspec.call }
65
- start_file_watcher
66
-
67
64
  if server
68
65
  @server_thread = Thread.start do
69
66
  server = TCPServer.new port
@@ -76,11 +73,15 @@ module RSpec
76
73
  end
77
74
  end
78
75
  end
76
+
77
+ @config_cache.record_configuration { @configuration.configure_rspec.call }
78
+ start_file_watcher
79
79
  end
80
80
 
81
81
  Pry.start
82
82
  @listener.stop if @listener
83
83
  @server_thread.exit if @server_thread
84
+ @startup_thread.exit if @startup_thread
84
85
  0
85
86
  end
86
87
 
@@ -177,40 +178,52 @@ module RSpec
177
178
  end
178
179
 
179
180
  def self.rspec(args)
180
- @runner = RSpec::Interactive::Runner.new(parse_args(args))
181
+ @command_mutex.synchronize do
182
+ begin
183
+ @runner = RSpec::Interactive::Runner.new(parse_args(args))
181
184
 
182
- refresh
185
+ refresh
183
186
 
184
- # Stop saving history in case a new Pry session is started for debugging.
185
- Pry.config.history_save = false
187
+ # Stop saving history in case a new Pry session is started for debugging.
188
+ Pry.config.history_save = false
186
189
 
187
- # RSpec::Interactive-specific RSpec configuration
188
- RSpec.configure do |config|
189
- config.error_stream = @error_stream
190
- config.output_stream = @output_stream
191
- config.start_time = RSpec::Core::Time.now
192
- end
190
+ # RSpec::Interactive-specific RSpec configuration
191
+ RSpec.configure do |config|
192
+ config.error_stream = @error_stream
193
+ config.output_stream = @output_stream
194
+ config.start_time = RSpec::Core::Time.now
195
+ end
193
196
 
194
- # Run.
195
- @runner.run
196
- ensure
197
- @runner = nil
197
+ # Run.
198
+ @runner.run
199
+ ensure
200
+ @runner = nil
198
201
 
199
- # Reenable history
200
- Pry.config.history_save = true
202
+ # Reenable history
203
+ Pry.config.history_save = true
201
204
 
202
- # Reset
203
- RSpec.clear_examples
204
- RSpec.reset
205
- @config_cache.replay_configuration
205
+ # Reset
206
+ RSpec.clear_examples
207
+ RSpec.reset
208
+ @config_cache.replay_configuration
209
+ end
210
+ end
206
211
  end
207
212
 
208
213
  def self.rspec_for_server(client, args)
209
214
  @command_mutex.synchronize do
210
- output = ClientOutput.new(client)
211
215
  disable_pry = ENV['DISABLE_PRY']
216
+ output = ClientOutput.new(client)
217
+
218
+ ENV['TEAMCITY_RAKE_RUNNER_DEBUG_OUTPUT_CAPTURER_ENABLED'] = 'false'
219
+ Rake::TeamCity::RunnerCommon.class_variable_set(:@@original_stdout, output)
220
+
221
+ Stdio.capture(
222
+ stdout: output,
223
+ stderr: output) do
224
+
225
+ await_startup(output: output)
212
226
 
213
- Stdio.capture(stdout: output, stderr: output) do
214
227
  # Prevent the debugger from being used. The server isn't interactive.
215
228
  ENV['DISABLE_PRY'] = 'true'
216
229
 
@@ -220,8 +233,8 @@ module RSpec
220
233
 
221
234
  # RSpec::Interactive-specific RSpec configuration
222
235
  RSpec.configure do |config|
223
- config.error_stream = @error_stream
224
- config.output_stream = @output_stream
236
+ config.error_stream = output
237
+ config.output_stream = output
225
238
  config.start_time = RSpec::Core::Time.now
226
239
  end
227
240
 
@@ -238,13 +251,17 @@ module RSpec
238
251
 
239
252
  # Run.
240
253
  @runner.run
254
+ rescue Errno::EPIPE => e
255
+ # Don't care.
241
256
  ensure
242
- @runner = nil
243
257
  ENV['DISABLE_PRY'] = disable_pry
258
+ @runner = nil
244
259
 
245
260
  # Reset
246
261
  RSpec.clear_examples
247
262
  RSpec.reset
263
+
264
+ await_startup(output: output)
248
265
  @config_cache.replay_configuration
249
266
  end
250
267
  end
@@ -259,22 +276,26 @@ module RSpec
259
276
  end
260
277
 
261
278
  def self.eval(line, options, &block)
262
- if line.nil? || Thread.current.thread_variable_get('holding_lock')
263
- yield
264
- else
265
- @command_mutex.synchronize do
266
- Thread.current.thread_variable_set('holding_lock', true)
267
- if @startup_thread
268
- if @startup_thread.alive?
269
- @output_stream.puts 'waiting for configure_rspec...'
270
- end
271
- @startup_thread.join
272
- @startup_thread = nil
273
- end
274
- yield
275
- ensure
276
- Thread.current.thread_variable_set('holding_lock', false)
279
+ return yield if line.nil? # EOF
280
+ return yield if line.empty? # blank line
281
+
282
+ begin
283
+ await_startup
284
+ rescue Interrupt
285
+ @output_stream.puts
286
+ return true
287
+ end
288
+
289
+ yield
290
+ end
291
+
292
+ def self.await_startup(output: @output_stream)
293
+ if @startup_thread
294
+ if @startup_thread.alive?
295
+ output.puts 'waiting for configure_rspec...'
277
296
  end
297
+ @startup_thread.join
298
+ @startup_thread = nil
278
299
  end
279
300
  end
280
301
  end
@@ -24,8 +24,12 @@ parser = OptionParser.new do |opts|
24
24
  end.parse
25
25
 
26
26
  server = TCPSocket.open(@options[:host], @options[:port])
27
- server.puts ARGV.map{ |arg| Shellwords.escape arg }.join(' ')
28
- while response = server.gets do
29
- puts response
27
+ begin
28
+ server.puts ARGV.map{ |arg| Shellwords.escape arg }.join(' ')
29
+ server.close_write
30
+ while response = server.gets do
31
+ puts response
32
+ end
33
+ ensure
34
+ server.close
30
35
  end
31
- server.close
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-interactive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
4
+ version: 0.9.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Dower
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-26 00:00:00.000000000 Z
11
+ date: 2022-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-core