hydra 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/hydra.gemspec +2 -2
- data/lib/hydra/master.rb +36 -7
- data/lib/hydra/tasks.rb +11 -2
- data/test/master_test.rb +1 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.12.0
|
data/hydra.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{hydra}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.12.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Nick Gauthier"]
|
12
|
-
s.date = %q{2010-02-
|
12
|
+
s.date = %q{2010-02-18}
|
13
13
|
s.description = %q{Spread your tests over multiple machines to test your code faster.}
|
14
14
|
s.email = %q{nick@smartlogicsolutions.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/hydra/master.rb
CHANGED
@@ -32,6 +32,8 @@ module Hydra #:nodoc:
|
|
32
32
|
@listeners = []
|
33
33
|
@verbose = opts.fetch('verbose') { false }
|
34
34
|
@report = opts.fetch('report') { false }
|
35
|
+
@autosort = opts.fetch('autosort') { true }
|
36
|
+
sort_files_from_report if @autosort
|
35
37
|
init_report_file
|
36
38
|
@sync = opts.fetch('sync') { nil }
|
37
39
|
|
@@ -56,6 +58,8 @@ module Hydra #:nodoc:
|
|
56
58
|
trace "Sending #{f.inspect}"
|
57
59
|
report_start_time(f)
|
58
60
|
worker[:io].write(RunFile.new(:file => f))
|
61
|
+
else
|
62
|
+
trace "No more files to send"
|
59
63
|
end
|
60
64
|
end
|
61
65
|
|
@@ -186,30 +190,55 @@ module Hydra #:nodoc:
|
|
186
190
|
end
|
187
191
|
|
188
192
|
def init_report_file
|
189
|
-
|
190
|
-
FileUtils.rm_f(
|
193
|
+
FileUtils.rm_f(report_file)
|
194
|
+
FileUtils.rm_f(report_results_file)
|
191
195
|
end
|
192
196
|
|
193
197
|
def report_start_time(file)
|
194
|
-
File.open(
|
198
|
+
File.open(report_file, 'a'){|f| f.write "#{file}|start|#{Time.now.to_f}\n" }
|
195
199
|
end
|
196
200
|
|
197
201
|
def report_finish_time(file)
|
198
|
-
File.open(
|
202
|
+
File.open(report_file, 'a'){|f| f.write "#{file}|finish|#{Time.now.to_f}\n" }
|
199
203
|
end
|
200
204
|
|
201
205
|
def generate_report
|
202
206
|
report = {}
|
203
207
|
lines = nil
|
204
|
-
File.open(
|
208
|
+
File.open(report_file, 'r'){|f| lines = f.read.split("\n")}
|
205
209
|
lines.each{|l| l = l.split('|'); report[l[0]] ||= {}; report[l[0]][l[1]] = l[2]}
|
206
210
|
report.each{|file, times| report[file]['duration'] = times['finish'].to_f - times['start'].to_f}
|
207
211
|
report = report.sort{|a, b| b[1]['duration'] <=> a[1]['duration']}
|
208
|
-
output = [
|
212
|
+
output = []
|
209
213
|
report.each{|file, times| output << "%.2f\t#{file}" % times['duration']}
|
210
|
-
output << "Report available @ #{@report_file}"
|
211
214
|
@report_text = output.join("\n")
|
215
|
+
File.open(report_results_file, 'w'){|f| f.write @report_text}
|
216
|
+
return report_text
|
217
|
+
end
|
218
|
+
|
219
|
+
def reported_files
|
220
|
+
return [] unless File.exists?(report_results_file)
|
221
|
+
rep = []
|
222
|
+
File.open(report_results_file, 'r') do |f|
|
223
|
+
lines = f.read.split("\n")
|
224
|
+
lines.each{|l| rep << l.split(" ")[1] }
|
225
|
+
end
|
226
|
+
return rep
|
227
|
+
end
|
228
|
+
|
229
|
+
def sort_files_from_report
|
230
|
+
sorted_files = reported_files
|
231
|
+
reported_files.each do |f|
|
232
|
+
@files.push(@files.delete_at(@files.index(f))) if @files.index(f)
|
233
|
+
end
|
212
234
|
end
|
213
235
|
|
236
|
+
def report_file
|
237
|
+
@report_file ||= File.join(Dir.tmpdir, 'hydra_report.txt')
|
238
|
+
end
|
239
|
+
|
240
|
+
def report_results_file
|
241
|
+
@report_results_file ||= File.join(Dir.tmpdir, 'hydra_report_results.txt')
|
242
|
+
end
|
214
243
|
end
|
215
244
|
end
|
data/lib/hydra/tasks.rb
CHANGED
@@ -20,8 +20,15 @@ module Hydra #:nodoc:
|
|
20
20
|
attr_accessor :config
|
21
21
|
|
22
22
|
# Set to true if you want hydra to generate a report.
|
23
|
-
# Defaults to
|
23
|
+
# Defaults to false
|
24
24
|
attr_accessor :report
|
25
|
+
|
26
|
+
# Automatically sort files using their historical runtimes.
|
27
|
+
# Defaults to true
|
28
|
+
# To disable:
|
29
|
+
# t.autosort = false
|
30
|
+
attr_accessor :autosort
|
31
|
+
|
25
32
|
#
|
26
33
|
# Search for the hydra config file
|
27
34
|
def find_config_file
|
@@ -59,6 +66,7 @@ module Hydra #:nodoc:
|
|
59
66
|
@files = []
|
60
67
|
@verbose = false
|
61
68
|
@report = false
|
69
|
+
@autosort = true
|
62
70
|
|
63
71
|
yield self if block_given?
|
64
72
|
|
@@ -67,6 +75,7 @@ module Hydra #:nodoc:
|
|
67
75
|
@opts = {
|
68
76
|
:verbose => @verbose,
|
69
77
|
:report => @report,
|
78
|
+
:autosort => @autosort,
|
70
79
|
:files => @files
|
71
80
|
}
|
72
81
|
if @config
|
@@ -85,7 +94,7 @@ module Hydra #:nodoc:
|
|
85
94
|
task @name do
|
86
95
|
$stdout.write "Hydra Testing #{files.inspect}\n"
|
87
96
|
h = Hydra::Master.new(@opts)
|
88
|
-
$stdout.write h.report_text if @report
|
97
|
+
$stdout.write "\n"+h.report_text if @report
|
89
98
|
$stdout.write "\nHydra Completed\n"
|
90
99
|
exit(0) #bypass test on_exit output
|
91
100
|
end
|
data/test/master_test.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hydra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Gauthier
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
12
|
+
date: 2010-02-18 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|