Class: Kronk::Player::Suite
Overview
Outputs Player requests and results in a test-suite like format.
Instance Method Summary
collapse
Methods inherited from Output
#initialize
Instance Method Details
#completed ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/kronk/player/suite.rb', line 47
def completed
player_time = (Time.now - @start_time).to_f
total_time = 0
bad_count = 0
failure_count = 0
error_count = 0
err_buffer = ""
@results.each do |(status, time, text)|
case status
when "F"
total_time += time.to_f
bad_count += 1
failure_count += 1
err_buffer << "\n #{bad_count}) Failure:\n#{text}"
when "E"
bad_count += 1
error_count += 1
err_buffer << "\n #{bad_count}) Error:\n#{text}"
else
total_time += time.to_f
end
end
non_error_count = @results.length - error_count
avg_time = non_error_count > 0 ? total_time / non_error_count : "n/a"
avg_qps = non_error_count > 0 ? non_error_count / player_time : "n/a"
$stdout.puts "\nFinished in #{player_time} seconds.\n"
$stderr.puts err_buffer unless err_buffer.empty?
$stdout.puts "\n#{@results.length} cases, " +
"#{failure_count} failures, #{error_count} errors"
$stdout.puts "Avg Time: #{avg_time}"
$stdout.puts "Avg QPS: #{avg_qps}"
return bad_count == 0
end
|
#error(err, kronk = nil, mutex = nil) ⇒ Object
38
39
40
41
42
43
44
|
# File 'lib/kronk/player/suite.rb', line 38
def error err, kronk=nil, mutex=nil
status = "E"
@results << [status, 0, error_text(err, kronk)]
$stdout << status
$stdout.flush
end
|
#result(kronk, mutex = nil) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/kronk/player/suite.rb', line 15
def result kronk, mutex=nil
status = "."
@results <<
if kronk.diff
status = "F" if kronk.diff.count > 0
text = diff_text kronk if status == "F"
time =
(kronk.responses[0].time.to_f + kronk.responses[1].time.to_f) / 2
[status, time, text]
elsif kronk.response
status = "F" if !kronk.response.success?
text = resp_text kronk if status == "F"
[status, kronk.response.time, text]
end
$stdout << status
$stdout.flush
end
|
#start ⇒ Object
8
9
10
11
12
|
# File 'lib/kronk/player/suite.rb', line 8
def start
@results = []
$stdout.puts "Started"
super
end
|