spec_run_queue 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +1 -0
- data/bin/redis_runner +1 -1
- data/lib/spec_run_queue.rb +0 -1
- data/lib/spec_run_queue/notifier/growl.rb +3 -1
- data/lib/spec_run_queue/queue/base.rb +21 -3
- data/lib/spec_run_queue/queue/redis.rb +6 -1
- data/lib/spec_run_queue/system_runner.rb +10 -2
- data/lib/spec_run_queue/version.rb +1 -1
- data/spec/queue/redis_spec.rb +6 -4
- data/spec/system_runner_spec.rb +3 -3
- metadata +4 -4
data/README.markdown
CHANGED
@@ -39,6 +39,7 @@ In order to trigger a queue run, you need your editor to insert a YAML dump of t
|
|
39
39
|
TODO
|
40
40
|
====
|
41
41
|
|
42
|
+
* Check for Gemfile to bundle exec the spec bin
|
42
43
|
* Genericify and configure the runner
|
43
44
|
* Include code or a plugin for the vim script I'm using to inject instructions into the queue
|
44
45
|
* Investigate a custom rspec runner in place of the current shell execution method
|
data/bin/redis_runner
CHANGED
@@ -15,7 +15,7 @@ end
|
|
15
15
|
|
16
16
|
runner = SpecRunQueue::SystemRunner.new(rspec_major_version)
|
17
17
|
runner.add_notifier SpecRunQueue::Notifier::Growl.new(:password => "gr0wl")
|
18
|
-
runner.add_notifier SpecRunQueue::Notifier::Stdout.new()
|
18
|
+
# runner.add_notifier SpecRunQueue::Notifier::Stdout.new()
|
19
19
|
|
20
20
|
queue = SpecRunQueue::Queue::Redis.new(runner)
|
21
21
|
queue.run
|
data/lib/spec_run_queue.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'ruby-growl'
|
2
|
+
|
1
3
|
module SpecRunQueue
|
2
4
|
module Notifier
|
3
5
|
class Growl < Base
|
@@ -22,7 +24,7 @@ module SpecRunQueue
|
|
22
24
|
end
|
23
25
|
|
24
26
|
def growl
|
25
|
-
@growl ||= Growl.new "127.0.0.1", "rspec-growl", ["rspec-growl Notification"], nil, config[:password]
|
27
|
+
@growl ||= ::Growl.new "127.0.0.1", "rspec-growl", ["rspec-growl Notification"], nil, config[:password]
|
26
28
|
end
|
27
29
|
|
28
30
|
def short_message
|
@@ -10,14 +10,32 @@ module SpecRunQueue
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def run
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
with_reconnect do
|
14
|
+
while (raw_instruction = queue_fetch)
|
15
|
+
instruction = YAML.load(raw_instruction[1])
|
16
|
+
runner.run_spec(instruction)
|
17
|
+
end
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
21
|
+
def self.run_rescue_exceptions
|
22
|
+
[]
|
23
|
+
end
|
24
|
+
|
19
25
|
private
|
20
26
|
|
27
|
+
def with_reconnect
|
28
|
+
begin
|
29
|
+
yield
|
30
|
+
# rescue *self.class.run_rescue_exceptions => e
|
31
|
+
rescue => e
|
32
|
+
$stderr.puts "exception #{e.class} occurred, reconnecting..."
|
33
|
+
sleep(1)
|
34
|
+
connect
|
35
|
+
retry
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
21
39
|
def connect
|
22
40
|
raise "Abstract method"
|
23
41
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'digest/md5'
|
1
2
|
require 'redis'
|
2
3
|
|
3
4
|
module SpecRunQueue
|
@@ -6,9 +7,13 @@ module SpecRunQueue
|
|
6
7
|
attr_reader :redis
|
7
8
|
|
8
9
|
def self.queue_key
|
9
|
-
"
|
10
|
+
@queue_key ||= ["spec_run_queue", Digest::MD5.hexdigest(Dir.pwd)].join(':')
|
10
11
|
end
|
11
12
|
|
13
|
+
# def self.run_rescue_exceptions
|
14
|
+
# [Errno::EAGAIN]
|
15
|
+
# end
|
16
|
+
|
12
17
|
private
|
13
18
|
|
14
19
|
def connect
|
@@ -29,9 +29,10 @@ module SpecRunQueue
|
|
29
29
|
end
|
30
30
|
|
31
31
|
begin
|
32
|
-
cmd = "#{rspec_bin} -f
|
32
|
+
cmd = "#{rspec_bin} -f nested --drb"
|
33
33
|
cmd << " -l #{instruction[:line]}" if instruction[:line]
|
34
34
|
cmd << " #{instruction[:target]}"
|
35
|
+
puts "Running command #{cmd}"
|
35
36
|
output = run_cmd(cmd)
|
36
37
|
|
37
38
|
output_to_notifiers(output)
|
@@ -46,7 +47,14 @@ module SpecRunQueue
|
|
46
47
|
private
|
47
48
|
|
48
49
|
def run_cmd(cmd)
|
49
|
-
|
50
|
+
specs = IO.popen cmd
|
51
|
+
output = ""
|
52
|
+
while line = specs.gets
|
53
|
+
output += line
|
54
|
+
puts line
|
55
|
+
end
|
56
|
+
|
57
|
+
output
|
50
58
|
end
|
51
59
|
|
52
60
|
def output_to_notifiers(output, options = {})
|
data/spec/queue/redis_spec.rb
CHANGED
@@ -3,23 +3,25 @@ require 'spec_run_queue/queue/redis'
|
|
3
3
|
|
4
4
|
describe SpecRunQueue::Queue::Redis do
|
5
5
|
before(:each) do
|
6
|
+
Dir.stub!(:pwd).and_return("/tmp")
|
7
|
+
@queue_key = "spec_run_queue:d42b9c57d24cf5db3bd8d332dc35437f" # /tmp hashed
|
6
8
|
@redis_mock = mock("Redis", :del => true, :blpop => true)
|
7
9
|
::Redis.stub!(:new).and_return(@redis_mock)
|
8
10
|
@runner_mock = mock("Runner")
|
9
11
|
@redis_queue = SpecRunQueue::Queue::Redis.new(@runner_mock)
|
10
12
|
end
|
11
13
|
|
12
|
-
it "should have '
|
13
|
-
SpecRunQueue::Queue::Redis.queue_key.should ==
|
14
|
+
it "should have 'spec_run_queue:<md5string>' as the key" do
|
15
|
+
SpecRunQueue::Queue::Redis.queue_key.should == @queue_key
|
14
16
|
end
|
15
17
|
|
16
18
|
it "should reset the queue by deleting the queue key" do
|
17
|
-
@redis_mock.should_receive(:del).with(
|
19
|
+
@redis_mock.should_receive(:del).with(@queue_key)
|
18
20
|
SpecRunQueue::Queue::Redis.new(@runner_mock)
|
19
21
|
end
|
20
22
|
|
21
23
|
it "should blpop instructions off the redis queue" do
|
22
|
-
@redis_mock.should_receive(:blpop).with(
|
24
|
+
@redis_mock.should_receive(:blpop).with(@queue_key, 0).and_return(nil)
|
23
25
|
@redis_queue.run
|
24
26
|
end
|
25
27
|
end
|
data/spec/system_runner_spec.rb
CHANGED
@@ -65,12 +65,12 @@ describe SpecRunQueue::SystemRunner do
|
|
65
65
|
end
|
66
66
|
|
67
67
|
it "should call to run the spec" do
|
68
|
-
runner.should_receive(:run_cmd).with("spec -f
|
68
|
+
runner.should_receive(:run_cmd).with("spec -f nested --drb foo_spec.rb")
|
69
69
|
runner.run_spec(:target => "foo_spec.rb")
|
70
70
|
end
|
71
71
|
|
72
72
|
it "should send the output from the run to all the notifiers" do
|
73
|
-
runner.should_receive(:run_cmd).with("spec -f
|
73
|
+
runner.should_receive(:run_cmd).with("spec -f nested --drb foo_spec.rb").and_return("spec output")
|
74
74
|
foo_notifier.should_receive(:notify).with("spec output", {})
|
75
75
|
bar_notifier.should_receive(:notify).with("spec output", {})
|
76
76
|
runner.run_spec(:target => "foo_spec.rb")
|
@@ -78,7 +78,7 @@ describe SpecRunQueue::SystemRunner do
|
|
78
78
|
|
79
79
|
context "with a line number" do
|
80
80
|
it "should call to run the spec using the -l flag" do
|
81
|
-
runner.should_receive(:run_cmd).with("spec -f
|
81
|
+
runner.should_receive(:run_cmd).with("spec -f nested --drb -l 42 foo_spec.rb")
|
82
82
|
runner.run_spec(:target => "foo_spec.rb", :line => 42)
|
83
83
|
end
|
84
84
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spec_run_queue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Brendon Murphy
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-29 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|