rspec_runner 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/bin/rspec_runner +0 -3
- data/lib/rspec_runner/client.rb +14 -4
- data/lib/rspec_runner/configuration.rb +3 -3
- data/lib/rspec_runner/monitor.rb +5 -2
- data/lib/rspec_runner/server.rb +21 -1
- data/lib/rspec_runner/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6537a01d0edf8244bee0f8e8c1561950e92260a2
|
4
|
+
data.tar.gz: a6b5dde3a76f11d61f30b2f593ff3a8dc9674e31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d260b1df5d8ffc2ff71d0df28a912ac37b532a220c15315cbbbbc6afa23aff2eb7776f4cc388f65b8e1bc23d8ffefea67353a4674d067f949f4213e2dbfdb5e
|
7
|
+
data.tar.gz: 6b4aee0adc08c8b15f80bfa52066be7c2dc73b29935e8c8cd8c57822eab882d9e15335754861fd48000e1bbce3cd32b8cd2955ffeb2d71c61cee0b751ba2cfcd
|
data/README.md
CHANGED
@@ -37,6 +37,12 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
37
37
|
|
38
38
|
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rspec_runner. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
39
39
|
|
40
|
+
## TODO
|
41
|
+
|
42
|
+
* Try to kill a process without `kill -9`
|
43
|
+
* Make it configurable
|
44
|
+
* Add tests!
|
45
|
+
* Speedup client
|
40
46
|
|
41
47
|
## License
|
42
48
|
|
data/bin/rspec_runner
CHANGED
data/lib/rspec_runner/client.rb
CHANGED
@@ -6,12 +6,16 @@ module RspecRunner
|
|
6
6
|
class << self
|
7
7
|
def execute(*args)
|
8
8
|
DRb.start_service
|
9
|
-
runner = DRbObject.new_with_uri(RspecRunner.configuration.uri)
|
10
|
-
|
11
9
|
try_count = 0
|
12
|
-
print '
|
13
|
-
|
10
|
+
print 'Connecting... '
|
11
|
+
|
12
|
+
while try_count < RspecRunner.configuration.client_timeout
|
14
13
|
begin
|
14
|
+
uri = fetch_uri
|
15
|
+
raise DRb::DRbConnError unless uri
|
16
|
+
|
17
|
+
runner = DRbObject.new_with_uri(uri)
|
18
|
+
print 'running... '
|
15
19
|
runner.execute(*args)
|
16
20
|
puts 'done!'
|
17
21
|
return true
|
@@ -23,6 +27,12 @@ module RspecRunner
|
|
23
27
|
|
24
28
|
puts 'Server is down :('
|
25
29
|
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def fetch_uri
|
34
|
+
File.read(RspecRunner.configuration.uri_filepath) if File.exist?(RspecRunner.configuration.uri_filepath)
|
35
|
+
end
|
26
36
|
end
|
27
37
|
end
|
28
38
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module RspecRunner
|
2
2
|
class Configuration
|
3
|
-
attr_accessor :
|
3
|
+
attr_accessor :uri_filepath, :client_timeout, :watch_directories, :watch_pattern, :ignore_pattern
|
4
4
|
|
5
5
|
def initialize
|
6
|
-
@
|
7
|
-
@client_timeout =
|
6
|
+
@uri_filepath = "#{Dir.pwd}/tmp/rspec_runner"
|
7
|
+
@client_timeout = 60 # seconds
|
8
8
|
@watch_directories = ["#{Dir.pwd}"]
|
9
9
|
@watch_pattern = /\.rb$/
|
10
10
|
@ignore_pattern = /spec\/.+_spec\.rb$/
|
data/lib/rspec_runner/monitor.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'open3'
|
2
|
+
require 'rspec_runner/server'
|
2
3
|
require 'rspec_runner/watcher'
|
3
4
|
|
4
5
|
module RspecRunner
|
@@ -23,13 +24,15 @@ module RspecRunner
|
|
23
24
|
private
|
24
25
|
|
25
26
|
def start
|
26
|
-
@pid = fork {
|
27
|
+
@pid = fork { RspecRunner::Server.run }
|
27
28
|
Process.detach(@pid) # so if the child exits, it dies
|
28
29
|
end
|
29
30
|
|
30
31
|
def stop
|
31
32
|
if @pid && @pid != 0
|
32
|
-
|
33
|
+
# TODO: try to kill without -9
|
34
|
+
send_signal('KILL')
|
35
|
+
RspecRunner::Server.stop
|
33
36
|
end
|
34
37
|
end
|
35
38
|
|
data/lib/rspec_runner/server.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'socket'
|
1
2
|
require 'drb/drb'
|
2
3
|
require 'rspec_runner/configuration'
|
3
4
|
|
@@ -11,9 +12,11 @@ module RspecRunner
|
|
11
12
|
require 'rspec'
|
12
13
|
require 'spec_helper.rb'
|
13
14
|
|
14
|
-
DRb.start_service(
|
15
|
+
DRb.start_service(assign_uri, self)
|
15
16
|
puts 'Server started!'
|
16
17
|
|
18
|
+
at_exit { stop }
|
19
|
+
|
17
20
|
DRb.thread.join
|
18
21
|
end
|
19
22
|
|
@@ -24,8 +27,25 @@ module RspecRunner
|
|
24
27
|
reset_rspec!
|
25
28
|
end
|
26
29
|
|
30
|
+
def stop
|
31
|
+
File.delete(RspecRunner.configuration.uri_filepath) if File.exist?(RspecRunner.configuration.uri_filepath)
|
32
|
+
end
|
33
|
+
|
27
34
|
private
|
28
35
|
|
36
|
+
def assign_uri
|
37
|
+
socket = Socket.new(:INET, :STREAM, 0)
|
38
|
+
socket.bind(Addrinfo.tcp('127.0.0.1'.freeze, 0))
|
39
|
+
free_port = socket.local_address.ip_port
|
40
|
+
uri = "druby://localhost:#{free_port}"
|
41
|
+
|
42
|
+
dirname = File.dirname(RspecRunner.configuration.uri_filepath)
|
43
|
+
FileUtils.mkdir_p(dirname) unless File.directory?(dirname)
|
44
|
+
File.write(RspecRunner.configuration.uri_filepath, uri)
|
45
|
+
|
46
|
+
uri
|
47
|
+
end
|
48
|
+
|
29
49
|
def filepaths(path)
|
30
50
|
multiple_files?(path) ? Dir.glob(path) : [path]
|
31
51
|
end
|
data/lib/rspec_runner/version.rb
CHANGED