rspec-interactive 0.9.4 → 0.9.5
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/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 +44 -32
- 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: bfaebc90c8fc0856566eb671fb122248778540ce78832af3a4c7b8cc3e8374a2
|
4
|
+
data.tar.gz: 476896ae26c3acf5fef26486ba7d3b5ee4caa2de220bb2c42b61f740989d6d92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20746051789c2591c9e398e65e645b343c994b1cae438f5c509d107217298af9bbef9d0c12327f446ed47214a7800c3ed594acad929fc48873280f5aed380c36
|
7
|
+
data.tar.gz: e844ef291294500ca6702a876662f03f6c20ec261a4864eb43dacca7d8b17fd29b995ea567ccbb3c0d9170c204e24902679b0ca4e24aa4e3925c86026ba5eca3
|
data/Gemfile.lock
CHANGED
@@ -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
|
@@ -58,27 +59,31 @@ module RSpec
|
|
58
59
|
check_rails
|
59
60
|
trap_interrupt
|
60
61
|
configure_pry
|
61
|
-
load_rspec_configuration
|
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
|
64
69
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
server = TCPServer.new port
|
70
|
+
if server
|
71
|
+
@server_thread = Thread.start do
|
72
|
+
server = TCPServer.new port
|
69
73
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
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
|
75
80
|
end
|
76
81
|
end
|
77
82
|
end
|
78
83
|
|
79
84
|
Pry.start
|
80
85
|
@listener.stop if @listener
|
81
|
-
server_thread.exit if server_thread
|
86
|
+
@server_thread.exit if @server_thread
|
82
87
|
0
|
83
88
|
end
|
84
89
|
|
@@ -113,20 +118,6 @@ module RSpec
|
|
113
118
|
@listener.start
|
114
119
|
end
|
115
120
|
|
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
121
|
def self.configure_pry
|
131
122
|
# Prevent Pry from trapping too. It will break ctrl-c handling.
|
132
123
|
Pry.config.should_trap_interrupts = false
|
@@ -161,14 +152,24 @@ module RSpec
|
|
161
152
|
end
|
162
153
|
|
163
154
|
def self.parse_args(args)
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
155
|
+
i = 0
|
156
|
+
parsed_args = []
|
157
|
+
until i == args.length
|
158
|
+
case args[i]
|
159
|
+
when /[\*\?\[]/
|
160
|
+
glob = Dir.glob(args[i])
|
161
|
+
parsed_args.concat(glob.empty? ? args[i] : glob)
|
162
|
+
when '--pattern'
|
163
|
+
# RubyMine passes --pattern when running all specs in a dir.
|
164
|
+
# We don't want to expand this since it is used as a glob by RSpec.
|
165
|
+
parsed_args.concat(args[i..(i + 1)])
|
166
|
+
i += 1
|
168
167
|
else
|
169
|
-
[
|
168
|
+
parsed_args << args[i]
|
170
169
|
end
|
170
|
+
i += 1
|
171
171
|
end
|
172
|
+
parsed_args
|
172
173
|
end
|
173
174
|
|
174
175
|
def self.rspec(args)
|
@@ -208,7 +209,7 @@ module RSpec
|
|
208
209
|
ENV['DISABLE_PRY'] = 'true'
|
209
210
|
|
210
211
|
output = ClientOutput.new(client)
|
211
|
-
Stdio.capture(
|
212
|
+
Stdio.capture(stdout: output, stderr: output) do
|
212
213
|
@runner = RSpec::Interactive::Runner.new(parse_args(args))
|
213
214
|
|
214
215
|
refresh
|
@@ -258,6 +259,17 @@ module RSpec
|
|
258
259
|
else
|
259
260
|
@command_mutex.synchronize do
|
260
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
|
261
273
|
yield
|
262
274
|
ensure
|
263
275
|
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.5
|
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
|