specjour 0.1.9 → 0.1.10
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.
- data/VERSION +1 -1
- data/bin/specjour +1 -2
- data/lib/specjour/dispatcher.rb +6 -10
- data/lib/specjour/distributed_formatter.rb +2 -3
- data/lib/specjour/manager.rb +3 -3
- data/lib/specjour/printer.rb +16 -8
- data/lib/specjour/protocol.rb +12 -6
- data/lib/specjour/worker.rb +36 -22
- data/lib/specjour.rb +1 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.10
|
data/bin/specjour
CHANGED
@@ -20,8 +20,7 @@ optparse = OptionParser.new do |opts|
|
|
20
20
|
end
|
21
21
|
|
22
22
|
opts.on('--do-work OPTIONS', Array, 'INTERNAL USE ONLY') do |args|
|
23
|
-
|
24
|
-
options[:worker_args] = args[0], args[1], args[2], specs_to_run
|
23
|
+
options[:worker_args] = args[0], args[1], args[2]
|
25
24
|
end
|
26
25
|
|
27
26
|
opts.on_tail('-v', '--version', 'Show the version of specjour') do
|
data/lib/specjour/dispatcher.rb
CHANGED
@@ -42,15 +42,7 @@ module Specjour
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def dispatch_work
|
45
|
-
|
46
|
-
last_index = 0
|
47
|
-
managers.each_with_index do |manager, index|
|
48
|
-
manager.specs_to_run = Array.new(manager.worker_size) do |i|
|
49
|
-
distributable_specs[last_index + i]
|
50
|
-
end
|
51
|
-
last_index += manager.worker_size
|
52
|
-
manager_threads << Thread.new(manager) {|m| m.dispatch}
|
53
|
-
end
|
45
|
+
command_managers(true) { |m| m.dispatch }
|
54
46
|
end
|
55
47
|
|
56
48
|
def drb_start
|
@@ -87,7 +79,11 @@ module Specjour
|
|
87
79
|
end
|
88
80
|
|
89
81
|
def printer
|
90
|
-
@printer ||=
|
82
|
+
@printer ||= begin
|
83
|
+
p = Printer.new
|
84
|
+
p.specs_to_run = all_specs
|
85
|
+
p.start
|
86
|
+
end
|
91
87
|
end
|
92
88
|
|
93
89
|
def project_name
|
@@ -12,7 +12,7 @@ module Specjour
|
|
12
12
|
|
13
13
|
def initialize(options, output)
|
14
14
|
@options = options
|
15
|
-
@output = output
|
15
|
+
@output = output
|
16
16
|
@failing_messages = []
|
17
17
|
@passing_messages = []
|
18
18
|
@pending_messages = []
|
@@ -41,8 +41,7 @@ module Specjour
|
|
41
41
|
@example_count = example_count
|
42
42
|
@failure_count = failure_count
|
43
43
|
@pending_count = pending_count
|
44
|
-
output.
|
45
|
-
output.flush
|
44
|
+
output.send_message(:worker_summary=, to_hash)
|
46
45
|
end
|
47
46
|
|
48
47
|
def dump_pending
|
data/lib/specjour/manager.rb
CHANGED
@@ -37,7 +37,7 @@ module Specjour
|
|
37
37
|
bonjour_service.stop
|
38
38
|
(1..worker_size).each do |index|
|
39
39
|
worker_pids << fork do
|
40
|
-
exec("specjour --batch-size #{batch_size} --do-work #{project_path},#{dispatcher_uri},#{index}
|
40
|
+
exec("specjour --batch-size #{batch_size} --do-work #{project_path},#{dispatcher_uri},#{index}")
|
41
41
|
Kernel.exit!
|
42
42
|
end
|
43
43
|
end
|
@@ -55,7 +55,7 @@ module Specjour
|
|
55
55
|
|
56
56
|
def drb_start
|
57
57
|
DRb.start_service nil, self
|
58
|
-
|
58
|
+
puts "Manager started at #{drb_uri}"
|
59
59
|
at_exit { DRb.stop_service }
|
60
60
|
end
|
61
61
|
|
@@ -66,7 +66,7 @@ module Specjour
|
|
66
66
|
protected
|
67
67
|
|
68
68
|
def cmd(command)
|
69
|
-
|
69
|
+
puts command
|
70
70
|
system command
|
71
71
|
end
|
72
72
|
|
data/lib/specjour/printer.rb
CHANGED
@@ -3,8 +3,7 @@ module Specjour
|
|
3
3
|
include Protocol
|
4
4
|
RANDOM_PORT = 0
|
5
5
|
|
6
|
-
|
7
|
-
attr_accessor :worker_size
|
6
|
+
attr_accessor :worker_size, :specs_to_run, :completed_workers
|
8
7
|
|
9
8
|
def initialize
|
10
9
|
super(
|
@@ -19,34 +18,43 @@ module Specjour
|
|
19
18
|
end
|
20
19
|
|
21
20
|
def serve(client)
|
21
|
+
client.extend Protocol
|
22
22
|
client.each(TERMINATOR) do |data|
|
23
|
-
process load_object(data)
|
23
|
+
process load_object(data), client
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
27
|
+
def ready(client)
|
28
|
+
client.print specs_to_run.shift
|
29
|
+
client.flush
|
30
|
+
end
|
31
|
+
|
32
|
+
def done(client)
|
33
|
+
self.completed_workers += 1
|
34
|
+
end
|
35
|
+
|
36
|
+
def worker_summary=(client, summary)
|
28
37
|
report.add(summary)
|
29
38
|
end
|
30
39
|
|
31
40
|
protected
|
32
41
|
|
33
42
|
def disconnecting(client_port)
|
34
|
-
@completed_workers += 1
|
35
43
|
if completed_workers == worker_size
|
36
44
|
stop
|
37
45
|
end
|
38
46
|
end
|
39
47
|
|
40
48
|
def log(msg)
|
41
|
-
#noop
|
49
|
+
# noop
|
42
50
|
end
|
43
51
|
|
44
|
-
def process(message)
|
52
|
+
def process(message, client)
|
45
53
|
if message.is_a?(String)
|
46
54
|
$stdout.print message
|
47
55
|
$stdout.flush
|
48
56
|
elsif message.is_a?(Array)
|
49
|
-
send(message.first, message[1])
|
57
|
+
send(message.first, client, *message[1..-1])
|
50
58
|
end
|
51
59
|
end
|
52
60
|
|
data/lib/specjour/protocol.rb
CHANGED
@@ -1,21 +1,27 @@
|
|
1
1
|
module Specjour
|
2
2
|
module Protocol
|
3
3
|
TERMINATOR = "|ruojceps|"
|
4
|
+
TERMINATOR_REGEXP = /#{TERMINATOR}$/
|
4
5
|
|
5
|
-
def
|
6
|
-
|
6
|
+
def dump_object(data)
|
7
|
+
Marshal.dump(data) << TERMINATOR
|
8
|
+
end
|
9
|
+
|
10
|
+
def load_object(data)
|
11
|
+
Marshal.load(data.sub(TERMINATOR_REGEXP, ''))
|
7
12
|
end
|
8
13
|
|
9
14
|
def print(arg)
|
10
15
|
super dump_object(arg)
|
11
16
|
end
|
12
17
|
|
13
|
-
def
|
14
|
-
|
18
|
+
def puts(arg)
|
19
|
+
print(arg << "\n")
|
15
20
|
end
|
16
21
|
|
17
|
-
def
|
18
|
-
|
22
|
+
def send_message(method_name, *args)
|
23
|
+
print([method_name, *args])
|
24
|
+
flush
|
19
25
|
end
|
20
26
|
end
|
21
27
|
end
|
data/lib/specjour/worker.rb
CHANGED
@@ -1,45 +1,59 @@
|
|
1
1
|
module Specjour
|
2
2
|
class Worker
|
3
|
-
|
3
|
+
include Protocol
|
4
|
+
attr_accessor :printer_uri
|
4
5
|
attr_reader :project_path, :specs_to_run, :number, :batch_size
|
5
6
|
|
6
|
-
def initialize(project_path,
|
7
|
+
def initialize(project_path, printer_uri, number, batch_size)
|
7
8
|
@project_path = project_path
|
8
9
|
@specs_to_run = specs_to_run
|
9
10
|
@number = number.to_i
|
10
11
|
@batch_size = batch_size.to_i
|
11
|
-
self.
|
12
|
+
self.printer_uri = printer_uri
|
13
|
+
GC.copy_on_write_friendly = true if GC.respond_to?(:copy_on_write_friendly=)
|
14
|
+
DistributedFormatter.batch_size = batch_size
|
15
|
+
Dir.chdir(project_path)
|
16
|
+
set_env_variables
|
12
17
|
end
|
13
18
|
|
14
|
-
def
|
15
|
-
@
|
19
|
+
def printer_uri=(val)
|
20
|
+
@printer_uri = URI.parse(val)
|
16
21
|
end
|
17
22
|
|
18
23
|
def run
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
Spec::Runner.use options
|
30
|
-
options.run_examples
|
31
|
-
Spec::Runner.options.instance_variable_set(:@examples_run, true)
|
24
|
+
printer.send_message(:ready)
|
25
|
+
while !printer.closed? && data = printer.gets(TERMINATOR)
|
26
|
+
spec = load_object(data)
|
27
|
+
if spec
|
28
|
+
run_spec spec
|
29
|
+
printer.send_message(:ready)
|
30
|
+
else
|
31
|
+
printer.send_message(:done)
|
32
|
+
printer.close
|
33
|
+
end
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
35
37
|
protected
|
36
38
|
|
37
|
-
def
|
38
|
-
@
|
39
|
+
def printer
|
40
|
+
@printer ||= printer_connection
|
41
|
+
end
|
42
|
+
|
43
|
+
def printer_connection
|
44
|
+
TCPSocket.open(printer_uri.host, printer_uri.port).extend Protocol
|
39
45
|
end
|
40
46
|
|
41
|
-
def
|
42
|
-
|
47
|
+
def run_spec(spec)
|
48
|
+
Kernel.puts "Running #{spec}"
|
49
|
+
options = Spec::Runner::OptionParser.parse(
|
50
|
+
['--format=Specjour::DistributedFormatter', spec],
|
51
|
+
$stderr,
|
52
|
+
printer_connection
|
53
|
+
)
|
54
|
+
Spec::Runner.use options
|
55
|
+
options.run_examples
|
56
|
+
Spec::Runner.options.instance_variable_set(:@examples_run, true)
|
43
57
|
end
|
44
58
|
|
45
59
|
def set_env_variables
|
data/lib/specjour.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 10
|
9
|
+
version: 0.1.10
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Sandro Turriate
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-04-05 00:00:00 -04:00
|
18
18
|
default_executable: specjour
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|