rspec-interactive 0.9.4 → 0.9.7
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 +4 -4
- data/.gitignore +2 -0
- data/Gemfile +0 -2
- data/Gemfile.lock +9 -4
- data/lib/rspec-interactive/client_output.rb +9 -1
- data/lib/rspec-interactive/pry.rb +1 -1
- data/lib/rspec-interactive/stdio.rb +14 -6
- data/lib/rspec-interactive/string_output.rb +23 -0
- data/lib/rspec-interactive/version.rb +1 -1
- data/lib/rspec-interactive.rb +63 -50
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19e7c3fad7abad85f3523490ddfcfd3d6091e042d99fd940c6a9a19991e7dc06
|
4
|
+
data.tar.gz: 02d25e506765d4f0c40b8b3e64ae751f6da34e06af9e845830bdc05071fc8112
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89b49ff9d0e888b8304e0c70a2fded4dd780381750fed960af5f282246accc6ae6d52eb71c5402d2be31bfb9a827c64e04cffcb7f4935d12d97e3d632843a8bf
|
7
|
+
data.tar.gz: 36320560582c44d1459e0590aa469f56e70b5411d8c3c88a499ca9f46c5075163aa3778869f65bb5cfd85dc3fc7dd196fff65c87733b5b0057352353583215c6
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rspec-interactive (0.9.
|
4
|
+
rspec-interactive (0.9.6)
|
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
|
@@ -6,7 +6,15 @@ module RSpec
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def print(str = "")
|
9
|
-
@client.print(str
|
9
|
+
@client.print(str.to_s)
|
10
|
+
end
|
11
|
+
|
12
|
+
def write(str = "")
|
13
|
+
@client.print(str.to_s)
|
14
|
+
end
|
15
|
+
|
16
|
+
def puts(str = "")
|
17
|
+
@client.print(str.to_s + "\n")
|
10
18
|
end
|
11
19
|
|
12
20
|
def string
|
@@ -1,10 +1,18 @@
|
|
1
1
|
module RSpec
|
2
2
|
module Interactive
|
3
3
|
class Stdio
|
4
|
-
def self.
|
4
|
+
def self.capture2(stdout:, stderr:)
|
5
|
+
old_stdout, old_stderr = $stdout, $stderr
|
6
|
+
$stdout, $stderr = stdout, stderr
|
7
|
+
yield
|
8
|
+
ensure
|
9
|
+
$stdout, $stderr = old_stdout, old_stderr
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.capture(stdout:, stderr:)
|
5
13
|
raise ArgumentError, 'missing block' unless block_given?
|
6
14
|
|
7
|
-
|
15
|
+
old_stdout, old_stderr = STDOUT.dup, STDERR.dup
|
8
16
|
|
9
17
|
IO.pipe do |stdout_read, stdout_write|
|
10
18
|
IO.pipe do |stderr_read, stderr_write|
|
@@ -16,13 +24,13 @@ module RSpec
|
|
16
24
|
|
17
25
|
stdout_thread = Thread.new do
|
18
26
|
while line = stdout_read.gets do
|
19
|
-
|
27
|
+
stdout.print(line)
|
20
28
|
end
|
21
29
|
end
|
22
30
|
|
23
31
|
stderr_thread = Thread.new do
|
24
32
|
while line = stderr_read.gets do
|
25
|
-
|
33
|
+
stderr.print(line)
|
26
34
|
end
|
27
35
|
end
|
28
36
|
|
@@ -30,8 +38,8 @@ module RSpec
|
|
30
38
|
yield
|
31
39
|
ensure
|
32
40
|
# TODO: should the threads be killed here?
|
33
|
-
STDOUT.reopen
|
34
|
-
STDERR.reopen
|
41
|
+
STDOUT.reopen old_stdout
|
42
|
+
STDERR.reopen old_stderr
|
35
43
|
end
|
36
44
|
|
37
45
|
stdout_thread.join
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module RSpec
|
2
|
+
module Interactive
|
3
|
+
class StringOutput
|
4
|
+
attr_reader :string
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@string = ''
|
8
|
+
end
|
9
|
+
|
10
|
+
def write(name, str = "")
|
11
|
+
@string += str.to_s
|
12
|
+
end
|
13
|
+
|
14
|
+
def puts(str = "")
|
15
|
+
@string += str.to_s + "\n"
|
16
|
+
end
|
17
|
+
|
18
|
+
def print(str = "")
|
19
|
+
@string += str.to_s
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/rspec-interactive.rb
CHANGED
@@ -18,6 +18,7 @@ require 'rspec-interactive/rspec_core_example'
|
|
18
18
|
require 'rspec-interactive/rubo_cop_command'
|
19
19
|
require 'rspec-interactive/runner'
|
20
20
|
require 'rspec-interactive/stdio'
|
21
|
+
require 'rspec-interactive/string_output'
|
21
22
|
|
22
23
|
module RSpec
|
23
24
|
module Interactive
|
@@ -56,29 +57,30 @@ module RSpec
|
|
56
57
|
load config_file if config_file
|
57
58
|
|
58
59
|
check_rails
|
59
|
-
|
60
|
+
maybe_trap_interrupt
|
60
61
|
configure_pry
|
61
|
-
load_rspec_configuration
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
63
|
+
@startup_thread = Thread.start do
|
64
|
+
@config_cache.record_configuration { @configuration.configure_rspec.call }
|
65
|
+
start_file_watcher
|
66
|
+
|
67
|
+
if server
|
68
|
+
@server_thread = Thread.start do
|
69
|
+
server = TCPServer.new port
|
70
|
+
|
71
|
+
while client = server.accept
|
72
|
+
request = client.gets
|
73
|
+
args = Shellwords.split(request)
|
74
|
+
rspec_for_server(client, args)
|
75
|
+
client.close
|
76
|
+
end
|
75
77
|
end
|
76
78
|
end
|
77
79
|
end
|
78
80
|
|
79
81
|
Pry.start
|
80
82
|
@listener.stop if @listener
|
81
|
-
server_thread.exit if server_thread
|
83
|
+
@server_thread.exit if @server_thread
|
82
84
|
0
|
83
85
|
end
|
84
86
|
|
@@ -90,7 +92,17 @@ module RSpec
|
|
90
92
|
end
|
91
93
|
end
|
92
94
|
|
93
|
-
def self.
|
95
|
+
def self.maybe_trap_interrupt
|
96
|
+
return unless RbConfig::CONFIG['ruby_install_name'] == 'jruby'
|
97
|
+
|
98
|
+
# When on JRuby, Pry traps interrupts and raises an Interrupt exception.
|
99
|
+
# Unfortunately, raising Interrupt is not enough when RSpec is running since it
|
100
|
+
# will only cause the current example to fail. We want to kill RSpec entirely
|
101
|
+
# if it is running so here we disable Pry's handling and rewrite it to include
|
102
|
+
# special handling for RSpec.
|
103
|
+
|
104
|
+
Pry.config.should_trap_interrupts = false
|
105
|
+
|
94
106
|
trap('INT') do
|
95
107
|
if @runner
|
96
108
|
# We are on a different thread. There is a race here. Ignore nil.
|
@@ -113,24 +125,7 @@ module RSpec
|
|
113
125
|
@listener.start
|
114
126
|
end
|
115
127
|
|
116
|
-
def self.load_rspec_configuration
|
117
|
-
start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
118
|
-
config_thread = Thread.start do
|
119
|
-
@config_cache.record_configuration { @configuration.configure_rspec.call }
|
120
|
-
end
|
121
|
-
unless config_thread.join(3)
|
122
|
-
@output_stream.puts "executing configure_rspec hook..."
|
123
|
-
end
|
124
|
-
config_thread.join
|
125
|
-
|
126
|
-
end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
127
|
-
@output_stream.puts "configure_rspec hook took #{(end_time - start_time).round} seconds" if end_time - start_time > 5
|
128
|
-
end
|
129
|
-
|
130
128
|
def self.configure_pry
|
131
|
-
# Prevent Pry from trapping too. It will break ctrl-c handling.
|
132
|
-
Pry.config.should_trap_interrupts = false
|
133
|
-
|
134
129
|
# Set up IO.
|
135
130
|
Pry.config.input = Readline
|
136
131
|
Pry.config.output = @output_stream
|
@@ -161,14 +156,24 @@ module RSpec
|
|
161
156
|
end
|
162
157
|
|
163
158
|
def self.parse_args(args)
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
159
|
+
i = 0
|
160
|
+
parsed_args = []
|
161
|
+
until i == args.length
|
162
|
+
case args[i]
|
163
|
+
when /[\*\?\[]/
|
164
|
+
glob = Dir.glob(args[i])
|
165
|
+
parsed_args.concat(glob.empty? ? args[i] : glob)
|
166
|
+
when '--pattern'
|
167
|
+
# RubyMine passes --pattern when running all specs in a dir.
|
168
|
+
# We don't want to expand this since it is used as a glob by RSpec.
|
169
|
+
parsed_args.concat(args[i..(i + 1)])
|
170
|
+
i += 1
|
168
171
|
else
|
169
|
-
[
|
172
|
+
parsed_args << args[i]
|
170
173
|
end
|
174
|
+
i += 1
|
171
175
|
end
|
176
|
+
parsed_args
|
172
177
|
end
|
173
178
|
|
174
179
|
def self.rspec(args)
|
@@ -187,7 +192,8 @@ module RSpec
|
|
187
192
|
end
|
188
193
|
|
189
194
|
# Run.
|
190
|
-
|
195
|
+
@runner.run
|
196
|
+
ensure
|
191
197
|
@runner = nil
|
192
198
|
|
193
199
|
# Reenable history
|
@@ -197,18 +203,17 @@ module RSpec
|
|
197
203
|
RSpec.clear_examples
|
198
204
|
RSpec.reset
|
199
205
|
@config_cache.replay_configuration
|
200
|
-
ensure
|
201
|
-
@runner = nil
|
202
206
|
end
|
203
207
|
|
204
208
|
def self.rspec_for_server(client, args)
|
205
209
|
@command_mutex.synchronize do
|
206
|
-
|
210
|
+
output = ClientOutput.new(client)
|
207
211
|
disable_pry = ENV['DISABLE_PRY']
|
208
|
-
ENV['DISABLE_PRY'] = 'true'
|
209
212
|
|
210
|
-
output
|
211
|
-
|
213
|
+
Stdio.capture(stdout: output, stderr: output) do
|
214
|
+
# Prevent the debugger from being used. The server isn't interactive.
|
215
|
+
ENV['DISABLE_PRY'] = 'true'
|
216
|
+
|
212
217
|
@runner = RSpec::Interactive::Runner.new(parse_args(args))
|
213
218
|
|
214
219
|
refresh
|
@@ -232,15 +237,16 @@ module RSpec
|
|
232
237
|
RSpec.configuration.formatter = Spec::Runner::Formatter::TeamcityFormatter
|
233
238
|
|
234
239
|
# Run.
|
235
|
-
|
240
|
+
@runner.run
|
241
|
+
ensure
|
242
|
+
@runner = nil
|
243
|
+
ENV['DISABLE_PRY'] = disable_pry
|
236
244
|
|
237
245
|
# Reset
|
238
246
|
RSpec.clear_examples
|
239
247
|
RSpec.reset
|
240
248
|
@config_cache.replay_configuration
|
241
249
|
end
|
242
|
-
ensure
|
243
|
-
ENV['DISABLE_PRY'] = disable_pry
|
244
250
|
end
|
245
251
|
end
|
246
252
|
|
@@ -252,12 +258,19 @@ module RSpec
|
|
252
258
|
end
|
253
259
|
end
|
254
260
|
|
255
|
-
def self.eval(&block)
|
256
|
-
if Thread.current.thread_variable_get('holding_lock')
|
261
|
+
def self.eval(line, options, &block)
|
262
|
+
if line.nil? || Thread.current.thread_variable_get('holding_lock')
|
257
263
|
yield
|
258
264
|
else
|
259
265
|
@command_mutex.synchronize do
|
260
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
|
261
274
|
yield
|
262
275
|
ensure
|
263
276
|
Thread.current.thread_variable_set('holding_lock', false)
|
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.
|
4
|
+
version: 0.9.7
|
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-
|
11
|
+
date: 2022-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec-core
|
@@ -102,6 +102,7 @@ files:
|
|
102
102
|
- lib/rspec-interactive/rubo_cop_command.rb
|
103
103
|
- lib/rspec-interactive/runner.rb
|
104
104
|
- lib/rspec-interactive/stdio.rb
|
105
|
+
- lib/rspec-interactive/string_output.rb
|
105
106
|
- lib/rspec-interactive/version.rb
|
106
107
|
- lib/teamcity/spec/runner/formatter/teamcity/formatter.rb
|
107
108
|
- rspec-interactive.gemspec
|