rspec-interactive 0.9.3 → 0.9.6
Sign up to get free protection for your applications and to get access to all the features.
- 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/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 +66 -40
- data/runner/README.md +3 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 448fb430c0970d2d6f3dc12a3a1b6577dde234516d0d7f3fdccc735be784919b
|
4
|
+
data.tar.gz: 650d41f575295fb43d1c97930ae49e4a7fe34aac1d4cb1ca2a7d3fe6a1cb25c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5a4b51199209d0d248e1fc26a2d7e3cb4abf993eb2a61775162eda5107a2a97529bdd58867cb1e870a9c10f9da7c3ef60ce0ccd4ad484f6f900f9c2b0708a6f
|
7
|
+
data.tar.gz: f57523af399e9ca55303101479fbc0940c60095a0ffe93a2092255954fe5be3003bfc82c41c7a416df72a12d72fd4aae0d578b5d7f6da85c1385a9f620950227
|
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.5)
|
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,35 +57,33 @@ 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
62
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
start_file_watcher
|
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
|
70
69
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
server = TCPServer.new port
|
70
|
+
if server
|
71
|
+
@server_thread = Thread.start do
|
72
|
+
server = TCPServer.new port
|
75
73
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
74
|
+
while client = server.accept
|
75
|
+
request = client.gets
|
76
|
+
args = Shellwords.split(request)
|
77
|
+
rspec_for_server(client, args)
|
78
|
+
client.close
|
79
|
+
end
|
81
80
|
end
|
82
81
|
end
|
83
82
|
end
|
84
83
|
|
85
84
|
Pry.start
|
86
85
|
@listener.stop if @listener
|
87
|
-
server_thread.exit if server_thread
|
86
|
+
@server_thread.exit if @server_thread
|
88
87
|
0
|
89
88
|
end
|
90
89
|
|
@@ -96,15 +95,17 @@ module RSpec
|
|
96
95
|
end
|
97
96
|
end
|
98
97
|
|
99
|
-
def self.
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
98
|
+
def self.maybe_trap_interrupt
|
99
|
+
return unless RbConfig::CONFIG['ruby_install_name'] == 'jruby'
|
100
|
+
|
101
|
+
# When on JRuby, Pry traps interrupts and raises an Interrupt exception.
|
102
|
+
# Unfortunately, raising Interrupt is not enough when RSpec is running since it
|
103
|
+
# will only cause the current example to fail. We want to kill RSpec entirely
|
104
|
+
# if it is running so here we disable Pry's handling and rewrite it to include
|
105
|
+
# special handling for RSpec.
|
106
|
+
|
107
|
+
Pry.config.should_trap_interrupts = false
|
106
108
|
|
107
|
-
def self.trap_interrupt
|
108
109
|
trap('INT') do
|
109
110
|
if @runner
|
110
111
|
# We are on a different thread. There is a race here. Ignore nil.
|
@@ -128,9 +129,6 @@ module RSpec
|
|
128
129
|
end
|
129
130
|
|
130
131
|
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
132
|
# Set up IO.
|
135
133
|
Pry.config.input = Readline
|
136
134
|
Pry.config.output = @output_stream
|
@@ -161,14 +159,24 @@ module RSpec
|
|
161
159
|
end
|
162
160
|
|
163
161
|
def self.parse_args(args)
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
162
|
+
i = 0
|
163
|
+
parsed_args = []
|
164
|
+
until i == args.length
|
165
|
+
case args[i]
|
166
|
+
when /[\*\?\[]/
|
167
|
+
glob = Dir.glob(args[i])
|
168
|
+
parsed_args.concat(glob.empty? ? args[i] : glob)
|
169
|
+
when '--pattern'
|
170
|
+
# RubyMine passes --pattern when running all specs in a dir.
|
171
|
+
# We don't want to expand this since it is used as a glob by RSpec.
|
172
|
+
parsed_args.concat(args[i..(i + 1)])
|
173
|
+
i += 1
|
168
174
|
else
|
169
|
-
[
|
175
|
+
parsed_args << args[i]
|
170
176
|
end
|
177
|
+
i += 1
|
171
178
|
end
|
179
|
+
parsed_args
|
172
180
|
end
|
173
181
|
|
174
182
|
def self.rspec(args)
|
@@ -180,10 +188,15 @@ module RSpec
|
|
180
188
|
Pry.config.history_save = false
|
181
189
|
|
182
190
|
# RSpec::Interactive-specific RSpec configuration
|
183
|
-
|
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
|
184
196
|
|
185
197
|
# Run.
|
186
198
|
exit_code = @runner.run
|
199
|
+
ensure
|
187
200
|
@runner = nil
|
188
201
|
|
189
202
|
# Reenable history
|
@@ -193,8 +206,6 @@ module RSpec
|
|
193
206
|
RSpec.clear_examples
|
194
207
|
RSpec.reset
|
195
208
|
@config_cache.replay_configuration
|
196
|
-
ensure
|
197
|
-
@runner = nil
|
198
209
|
end
|
199
210
|
|
200
211
|
def self.rspec_for_server(client, args)
|
@@ -204,13 +215,17 @@ module RSpec
|
|
204
215
|
ENV['DISABLE_PRY'] = 'true'
|
205
216
|
|
206
217
|
output = ClientOutput.new(client)
|
207
|
-
Stdio.capture(
|
218
|
+
Stdio.capture(stdout: output, stderr: output) do
|
208
219
|
@runner = RSpec::Interactive::Runner.new(parse_args(args))
|
209
220
|
|
210
221
|
refresh
|
211
222
|
|
212
223
|
# RSpec::Interactive-specific RSpec configuration
|
213
|
-
|
224
|
+
RSpec.configure do |config|
|
225
|
+
config.error_stream = @error_stream
|
226
|
+
config.output_stream = @output_stream
|
227
|
+
config.start_time = RSpec::Core::Time.now
|
228
|
+
end
|
214
229
|
|
215
230
|
# RubyMine specifies --format. That causes a formatter to be added. It does not override
|
216
231
|
# the existing formatter (if one is set by default). Clear any formatters but resetting
|
@@ -250,6 +265,17 @@ module RSpec
|
|
250
265
|
else
|
251
266
|
@command_mutex.synchronize do
|
252
267
|
Thread.current.thread_variable_set('holding_lock', true)
|
268
|
+
if @startup_thread
|
269
|
+
if @startup_thread.alive?
|
270
|
+
@output_stream.puts 'waiting for configure_rspec...'
|
271
|
+
end
|
272
|
+
@startup_thread.join
|
273
|
+
@startup_thread = nil
|
274
|
+
unless @startup_output.string.empty?
|
275
|
+
@output_stream.puts(@startup_output.string)
|
276
|
+
end
|
277
|
+
@startup_output = nil
|
278
|
+
end
|
253
279
|
yield
|
254
280
|
ensure
|
255
281
|
Thread.current.thread_variable_set('holding_lock', false)
|
data/runner/README.md
ADDED
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.6
|
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,11 +102,13 @@ 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
|
108
109
|
- runner/Gemfile
|
109
110
|
- runner/Gemfile.lock
|
111
|
+
- runner/README.md
|
110
112
|
- runner/rspec-interactive-run
|
111
113
|
- scripts/release.sh
|
112
114
|
- scripts/run-with-local-dep.sh
|