rspec-interactive 0.9.5 → 0.9.8

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: bfaebc90c8fc0856566eb671fb122248778540ce78832af3a4c7b8cc3e8374a2
4
- data.tar.gz: 476896ae26c3acf5fef26486ba7d3b5ee4caa2de220bb2c42b61f740989d6d92
3
+ metadata.gz: 895c315e10777f7d94c8efdf005129bb532463b31d764af1ddd079692b3e0e62
4
+ data.tar.gz: 264d523cfc32ffab312ef3d9323611c05f00d851d755d5cf53735680eac0ce4a
5
5
  SHA512:
6
- metadata.gz: 20746051789c2591c9e398e65e645b343c994b1cae438f5c509d107217298af9bbef9d0c12327f446ed47214a7800c3ed594acad929fc48873280f5aed380c36
7
- data.tar.gz: e844ef291294500ca6702a876662f03f6c20ec261a4864eb43dacca7d8b17fd29b995ea567ccbb3c0d9170c204e24902679b0ca4e24aa4e3925c86026ba5eca3
6
+ metadata.gz: 47ca24fe9e49e7ea070c62b3786d72232cb52eabc2faac4777b913099c515a4cb9a0eaeb2515ab204637c344824461fcfdc6e3a460082ca1384bf57d2e04e773
7
+ data.tar.gz: f7d35eb450b116bb275eac5eaf729d37af936464e18ce9015d3bea953b6204517212299c923eb9e114182b120df3ad3868112be716bd9bd20d6de2c2c8c6326d
data/.gitignore CHANGED
@@ -2,3 +2,5 @@ rspec-interactive-*.gem
2
2
  .rspec_interactive_history
3
3
  .rspec_interactive_config
4
4
  .idea
5
+ vendor
6
+ .bundle
data/Gemfile CHANGED
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- ruby '3.0.0'
4
-
5
3
  source "https://rubygems.org"
6
4
 
7
5
  gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-interactive (0.9.4)
4
+ rspec-interactive (0.9.7)
5
5
  listen
6
6
  pry
7
7
  rspec-core
@@ -13,6 +13,7 @@ GEM
13
13
  coderay (1.1.3)
14
14
  diff-lcs (1.4.4)
15
15
  ffi (1.15.5)
16
+ ffi (1.15.5-java)
16
17
  listen (3.7.1)
17
18
  rb-fsevent (~> 0.10, >= 0.10.3)
18
19
  rb-inotify (~> 0.9, >= 0.9.10)
@@ -20,6 +21,10 @@ GEM
20
21
  pry (0.14.1)
21
22
  coderay (~> 1.1)
22
23
  method_source (~> 1.0)
24
+ pry (0.14.1-java)
25
+ coderay (~> 1.1)
26
+ method_source (~> 1.0)
27
+ spoon (~> 0.0)
23
28
  rb-fsevent (0.11.1)
24
29
  rb-inotify (0.10.1)
25
30
  ffi (~> 1.0)
@@ -38,16 +43,16 @@ GEM
38
43
  rspec-support (3.9.4)
39
44
  rspec-teamcity (1.0.0)
40
45
  rspec (>= 2.99, >= 2.14.2, < 4)
46
+ spoon (0.0.6)
47
+ ffi
41
48
 
42
49
  PLATFORMS
50
+ universal-java-11
43
51
  x86_64-darwin-20
44
52
 
45
53
  DEPENDENCIES
46
54
  rspec-expectations
47
55
  rspec-interactive!
48
56
 
49
- RUBY VERSION
50
- ruby 3.0.0p0
51
-
52
57
  BUNDLED WITH
53
58
  2.2.17
@@ -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
@@ -4,7 +4,7 @@ class Pry
4
4
  alias_method :old_eval, :eval
5
5
 
6
6
  def eval(line, options = {})
7
- RSpec::Interactive.eval do
7
+ RSpec::Interactive.eval(line, options) do
8
8
  old_eval(line, options)
9
9
  end
10
10
  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.5"
5
+ VERSION = "0.9.8"
6
6
  end
7
7
  end
@@ -57,16 +57,10 @@ module RSpec
57
57
  load config_file if config_file
58
58
 
59
59
  check_rails
60
- trap_interrupt
60
+ maybe_trap_interrupt
61
61
  configure_pry
62
62
 
63
63
  @startup_thread = Thread.start do
64
- @startup_output = StringOutput.new
65
- Stdio.capture2(stdout: @startup_output, stderr: @startup_output) do
66
- @config_cache.record_configuration { @configuration.configure_rspec.call }
67
- start_file_watcher
68
- end
69
-
70
64
  if server
71
65
  @server_thread = Thread.start do
72
66
  server = TCPServer.new port
@@ -79,11 +73,15 @@ module RSpec
79
73
  end
80
74
  end
81
75
  end
76
+
77
+ @config_cache.record_configuration { @configuration.configure_rspec.call }
78
+ start_file_watcher
82
79
  end
83
80
 
84
81
  Pry.start
85
82
  @listener.stop if @listener
86
83
  @server_thread.exit if @server_thread
84
+ @startup_thread.exit if @startup_thread
87
85
  0
88
86
  end
89
87
 
@@ -95,7 +93,17 @@ module RSpec
95
93
  end
96
94
  end
97
95
 
98
- def self.trap_interrupt
96
+ def self.maybe_trap_interrupt
97
+ return unless RbConfig::CONFIG['ruby_install_name'] == 'jruby'
98
+
99
+ # When on JRuby, Pry traps interrupts and raises an Interrupt exception.
100
+ # Unfortunately, raising Interrupt is not enough when RSpec is running since it
101
+ # will only cause the current example to fail. We want to kill RSpec entirely
102
+ # if it is running so here we disable Pry's handling and rewrite it to include
103
+ # special handling for RSpec.
104
+
105
+ Pry.config.should_trap_interrupts = false
106
+
99
107
  trap('INT') do
100
108
  if @runner
101
109
  # We are on a different thread. There is a race here. Ignore nil.
@@ -119,9 +127,6 @@ module RSpec
119
127
  end
120
128
 
121
129
  def self.configure_pry
122
- # Prevent Pry from trapping too. It will break ctrl-c handling.
123
- Pry.config.should_trap_interrupts = false
124
-
125
130
  # Set up IO.
126
131
  Pry.config.input = Readline
127
132
  Pry.config.output = @output_stream
@@ -173,51 +178,63 @@ module RSpec
173
178
  end
174
179
 
175
180
  def self.rspec(args)
176
- @runner = RSpec::Interactive::Runner.new(parse_args(args))
181
+ @command_mutex.synchronize do
182
+ begin
183
+ @runner = RSpec::Interactive::Runner.new(parse_args(args))
177
184
 
178
- refresh
185
+ refresh
179
186
 
180
- # Stop saving history in case a new Pry session is started for debugging.
181
- 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
182
189
 
183
- # RSpec::Interactive-specific RSpec configuration
184
- RSpec.configure do |config|
185
- config.error_stream = @error_stream
186
- config.output_stream = @output_stream
187
- config.start_time = RSpec::Core::Time.now
188
- 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
189
196
 
190
- # Run.
191
- exit_code = @runner.run
192
- @runner = nil
197
+ # Run.
198
+ @runner.run
199
+ ensure
200
+ @runner = nil
193
201
 
194
- # Reenable history
195
- Pry.config.history_save = true
202
+ # Reenable history
203
+ Pry.config.history_save = true
196
204
 
197
- # Reset
198
- RSpec.clear_examples
199
- RSpec.reset
200
- @config_cache.replay_configuration
201
- ensure
202
- @runner = nil
205
+ # Reset
206
+ RSpec.clear_examples
207
+ RSpec.reset
208
+ @config_cache.replay_configuration
209
+ end
210
+ end
203
211
  end
204
212
 
205
213
  def self.rspec_for_server(client, args)
206
214
  @command_mutex.synchronize do
207
- # Prevent the debugger from being used. The server isn't interactive.
208
215
  disable_pry = ENV['DISABLE_PRY']
209
- ENV['DISABLE_PRY'] = 'true'
210
-
211
216
  output = ClientOutput.new(client)
212
- Stdio.capture(stdout: output, stderr: output) do
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)
226
+
227
+ # Prevent the debugger from being used. The server isn't interactive.
228
+ ENV['DISABLE_PRY'] = 'true'
229
+
213
230
  @runner = RSpec::Interactive::Runner.new(parse_args(args))
214
231
 
215
232
  refresh
216
233
 
217
234
  # RSpec::Interactive-specific RSpec configuration
218
235
  RSpec.configure do |config|
219
- config.error_stream = @error_stream
220
- config.output_stream = @output_stream
236
+ config.error_stream = output
237
+ config.output_stream = output
221
238
  config.start_time = RSpec::Core::Time.now
222
239
  end
223
240
 
@@ -233,15 +250,20 @@ module RSpec
233
250
  RSpec.configuration.formatter = Spec::Runner::Formatter::TeamcityFormatter
234
251
 
235
252
  # Run.
236
- exit_code = @runner.run
253
+ @runner.run
254
+ rescue Errno::EPIPE => e
255
+ # Don't care.
256
+ ensure
257
+ ENV['DISABLE_PRY'] = disable_pry
258
+ @runner = nil
237
259
 
238
260
  # Reset
239
261
  RSpec.clear_examples
240
262
  RSpec.reset
263
+
264
+ await_startup(output: output)
241
265
  @config_cache.replay_configuration
242
266
  end
243
- ensure
244
- ENV['DISABLE_PRY'] = disable_pry
245
267
  end
246
268
  end
247
269
 
@@ -253,27 +275,27 @@ module RSpec
253
275
  end
254
276
  end
255
277
 
256
- def self.eval(&block)
257
- if Thread.current.thread_variable_get('holding_lock')
258
- yield
259
- else
260
- @command_mutex.synchronize do
261
- Thread.current.thread_variable_set('holding_lock', true)
262
- if @startup_thread
263
- if @startup_thread.alive?
264
- @output_stream.puts 'waiting for configure_rspec...'
265
- end
266
- @startup_thread.join
267
- @startup_thread = nil
268
- unless @startup_output.string.empty?
269
- @output_stream.puts(@startup_output.string)
270
- end
271
- @startup_output = nil
272
- end
273
- yield
274
- ensure
275
- Thread.current.thread_variable_set('holding_lock', false)
278
+ def self.eval(line, options, &block)
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...'
276
296
  end
297
+ @startup_thread.join
298
+ @startup_thread = nil
277
299
  end
278
300
  end
279
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.5
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