rspec-interactive 0.9.8 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/rspec-interactive/string_output.rb +7 -0
- data/lib/rspec-interactive/threaded_output.rb +33 -0
- data/lib/rspec-interactive/version.rb +1 -1
- data/lib/rspec-interactive.rb +70 -34
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c87a284feb4bf76bac68cda8cbe5703a66f04a856c8e2aed9e27d30b89e2654e
|
4
|
+
data.tar.gz: 9336d2bff3ba1973921f8d7ba6a36d88bc11d4acd1c2b2ee86d7c47cb58d0356
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36afe559f97bc7cdee9e6833655f23e6092004b800e53beed28099afb8db6ce5511bc8177c9cc648ffc0a558bd221ca2ff13c5ff44e76132c20af99b30281fda
|
7
|
+
data.tar.gz: '097084b7f1fec026f08433a8d12d56997b83a8deb8852026fc04dc1f3e7ec5410433e0758b374724cb2b5450f7b5be4e4db2d9953241a7bbd703f610f032e6ef'
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
module RSpec
|
2
|
+
module Interactive
|
3
|
+
class ThreadedOutput
|
4
|
+
attr_reader :string
|
5
|
+
|
6
|
+
def initialize(thread_map:, default:)
|
7
|
+
@thread_map = thread_map
|
8
|
+
@default = default
|
9
|
+
@string = ''
|
10
|
+
end
|
11
|
+
|
12
|
+
def write(name, str = "")
|
13
|
+
(@thread_map[Thread.current] || @default).write(name, str)
|
14
|
+
end
|
15
|
+
|
16
|
+
def puts(str = "")
|
17
|
+
(@thread_map[Thread.current] || @default).puts(str)
|
18
|
+
end
|
19
|
+
|
20
|
+
def print(str = "")
|
21
|
+
(@thread_map[Thread.current] || @default).puts(str)
|
22
|
+
end
|
23
|
+
|
24
|
+
def flush
|
25
|
+
(@thread_map[Thread.current] || @default).flush
|
26
|
+
end
|
27
|
+
|
28
|
+
def closed?
|
29
|
+
(@thread_map[Thread.current] || @default).closed?
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/rspec-interactive.rb
CHANGED
@@ -19,6 +19,7 @@ require 'rspec-interactive/rubo_cop_command'
|
|
19
19
|
require 'rspec-interactive/runner'
|
20
20
|
require 'rspec-interactive/stdio'
|
21
21
|
require 'rspec-interactive/string_output'
|
22
|
+
require 'rspec-interactive/threaded_output'
|
22
23
|
|
23
24
|
module RSpec
|
24
25
|
module Interactive
|
@@ -47,7 +48,7 @@ module RSpec
|
|
47
48
|
@updated_files = []
|
48
49
|
@stty_save = %x`stty -g`.chomp
|
49
50
|
@file_change_mutex = Mutex.new
|
50
|
-
@
|
51
|
+
@rspec_mutex = Mutex.new
|
51
52
|
@output_stream = output_stream
|
52
53
|
@input_stream = input_stream
|
53
54
|
@error_stream = error_stream
|
@@ -61,21 +62,38 @@ module RSpec
|
|
61
62
|
configure_pry
|
62
63
|
|
63
64
|
@startup_thread = Thread.start do
|
65
|
+
Thread.current.report_on_exception = false
|
64
66
|
if server
|
65
67
|
@server_thread = Thread.start do
|
66
68
|
server = TCPServer.new port
|
67
69
|
|
68
|
-
while
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
70
|
+
while true
|
71
|
+
break unless client = server.accept
|
72
|
+
begin
|
73
|
+
request = client.gets
|
74
|
+
args = Shellwords.split(request)
|
75
|
+
rspec_for_server(client, args)
|
76
|
+
rescue StandardError => e
|
77
|
+
# It would be nice to log to the client here but it might be
|
78
|
+
# disconnected or disconnect before we successfully write. Any
|
79
|
+
# error here is unexpected so just log to the console.
|
80
|
+
@output_stream.puts
|
81
|
+
@output_stream.puts 'error handling client request'
|
82
|
+
log_exception(@output_stream, e)
|
83
|
+
ensure
|
84
|
+
client.close
|
85
|
+
end
|
73
86
|
end
|
74
87
|
end
|
75
88
|
end
|
76
89
|
|
77
|
-
@
|
78
|
-
|
90
|
+
@startup_output = StringOutput.new
|
91
|
+
output = ThreadedOutput.new(thread_map: { Thread.current => @startup_output }, default: @output_stream)
|
92
|
+
|
93
|
+
Stdio.capture(stdout: output, stderr: output) do
|
94
|
+
@config_cache.record_configuration { @configuration.configure_rspec.call }
|
95
|
+
start_file_watcher
|
96
|
+
end
|
79
97
|
end
|
80
98
|
|
81
99
|
Pry.start
|
@@ -139,17 +157,17 @@ module RSpec
|
|
139
157
|
Pry.config.history_file = @history_file
|
140
158
|
end
|
141
159
|
|
142
|
-
def self.refresh
|
160
|
+
def self.refresh(output: @output_stream)
|
143
161
|
@file_change_mutex.synchronize do
|
144
162
|
@updated_files.uniq.each do |filename|
|
145
|
-
|
163
|
+
output.puts "changed: #{filename}"
|
146
164
|
trace = TracePoint.new(:class) do |tp|
|
147
165
|
@configuration.on_class_load.call(tp.self)
|
148
166
|
end
|
149
167
|
trace.enable
|
150
168
|
load filename
|
151
169
|
trace.disable
|
152
|
-
|
170
|
+
output.puts
|
153
171
|
end
|
154
172
|
@updated_files.clear
|
155
173
|
end
|
@@ -178,7 +196,7 @@ module RSpec
|
|
178
196
|
end
|
179
197
|
|
180
198
|
def self.rspec(args)
|
181
|
-
@
|
199
|
+
@rspec_mutex.synchronize do
|
182
200
|
begin
|
183
201
|
@runner = RSpec::Interactive::Runner.new(parse_args(args))
|
184
202
|
|
@@ -211,25 +229,22 @@ module RSpec
|
|
211
229
|
end
|
212
230
|
|
213
231
|
def self.rspec_for_server(client, args)
|
214
|
-
@
|
232
|
+
@rspec_mutex.synchronize do
|
215
233
|
disable_pry = ENV['DISABLE_PRY']
|
216
234
|
output = ClientOutput.new(client)
|
217
235
|
|
218
236
|
ENV['TEAMCITY_RAKE_RUNNER_DEBUG_OUTPUT_CAPTURER_ENABLED'] = 'false'
|
219
237
|
Rake::TeamCity::RunnerCommon.class_variable_set(:@@original_stdout, output)
|
220
238
|
|
221
|
-
|
222
|
-
stdout: output,
|
223
|
-
stderr: output) do
|
224
|
-
|
225
|
-
await_startup(output: output)
|
239
|
+
return unless await_startup(output: output)
|
226
240
|
|
241
|
+
Stdio.capture(stdout: output, stderr: output) do
|
227
242
|
# Prevent the debugger from being used. The server isn't interactive.
|
228
243
|
ENV['DISABLE_PRY'] = 'true'
|
229
244
|
|
230
|
-
|
245
|
+
runner = RSpec::Interactive::Runner.new(parse_args(args))
|
231
246
|
|
232
|
-
refresh
|
247
|
+
refresh(output: output)
|
233
248
|
|
234
249
|
# RSpec::Interactive-specific RSpec configuration
|
235
250
|
RSpec.configure do |config|
|
@@ -250,18 +265,17 @@ module RSpec
|
|
250
265
|
RSpec.configuration.formatter = Spec::Runner::Formatter::TeamcityFormatter
|
251
266
|
|
252
267
|
# Run.
|
253
|
-
|
254
|
-
rescue Errno::EPIPE
|
268
|
+
runner.run
|
269
|
+
rescue Errno::EPIPE, IOError
|
255
270
|
# Don't care.
|
256
271
|
ensure
|
257
272
|
ENV['DISABLE_PRY'] = disable_pry
|
258
|
-
|
273
|
+
runner = nil
|
259
274
|
|
260
275
|
# Reset
|
261
276
|
RSpec.clear_examples
|
262
277
|
RSpec.reset
|
263
278
|
|
264
|
-
await_startup(output: output)
|
265
279
|
@config_cache.replay_configuration
|
266
280
|
end
|
267
281
|
end
|
@@ -279,24 +293,46 @@ module RSpec
|
|
279
293
|
return yield if line.nil? # EOF
|
280
294
|
return yield if line.empty? # blank line
|
281
295
|
|
282
|
-
|
283
|
-
|
284
|
-
|
296
|
+
if await_startup
|
297
|
+
yield
|
298
|
+
else
|
285
299
|
@output_stream.puts
|
286
|
-
|
300
|
+
true
|
287
301
|
end
|
288
|
-
|
289
|
-
yield
|
290
302
|
end
|
291
303
|
|
292
304
|
def self.await_startup(output: @output_stream)
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
305
|
+
return true unless @startup_thread
|
306
|
+
|
307
|
+
if @startup_thread.alive?
|
308
|
+
output.puts 'waiting for configure_rspec...'
|
309
|
+
end
|
310
|
+
|
311
|
+
begin
|
297
312
|
@startup_thread.join
|
298
313
|
@startup_thread = nil
|
314
|
+
print_startup_output(output: output)
|
315
|
+
true
|
316
|
+
rescue Interrupt
|
317
|
+
false
|
318
|
+
rescue StandardError => e
|
319
|
+
print_startup_output(output: output)
|
320
|
+
output.puts 'configure_rspec failed'
|
321
|
+
log_exception(output, e)
|
322
|
+
false
|
299
323
|
end
|
300
324
|
end
|
325
|
+
|
326
|
+
def self.log_exception(output, e)
|
327
|
+
output.puts "#{e.backtrace[0]}: #{e.message} (#{e.class})"
|
328
|
+
e.backtrace[1..-1].each { |b| output.puts "\t#{b}" }
|
329
|
+
end
|
330
|
+
|
331
|
+
def self.print_startup_output(output: @output_stream)
|
332
|
+
return if @startup_output.nil? || @startup_output.string.empty?
|
333
|
+
|
334
|
+
output.puts(@startup_output.string)
|
335
|
+
@startup_output = nil
|
336
|
+
end
|
301
337
|
end
|
302
338
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-interactive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Dower
|
@@ -103,6 +103,7 @@ files:
|
|
103
103
|
- lib/rspec-interactive/runner.rb
|
104
104
|
- lib/rspec-interactive/stdio.rb
|
105
105
|
- lib/rspec-interactive/string_output.rb
|
106
|
+
- lib/rspec-interactive/threaded_output.rb
|
106
107
|
- lib/rspec-interactive/version.rb
|
107
108
|
- lib/teamcity/spec/runner/formatter/teamcity/formatter.rb
|
108
109
|
- rspec-interactive.gemspec
|