spassky 0.1.36 → 0.1.37
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +43 -4
- data/lib/spassky/client/cli.rb +3 -3
- data/lib/spassky/client/directory_reader.rb +17 -13
- data/lib/spassky/client/pusher.rb +21 -9
- data/lib/spassky/client/test_suite_runner.rb +62 -0
- data/lib/spassky/device_test_status.rb +9 -0
- data/lib/spassky/server/app.rb +28 -18
- data/lib/spassky/server/device_database.rb +20 -13
- data/lib/spassky/server/device_list.rb +7 -1
- data/lib/spassky/server/test_run.rb +13 -7
- data/lib/spassky/test_suite_result.rb +70 -0
- data/lib/spassky/{test_result_summariser.rb → test_suite_result_summariser.rb} +7 -7
- data/lib/spassky/version.rb +1 -1
- data/spassky.gemspec +0 -1
- data/spec/spassky/client/cli_spec.rb +7 -7
- data/spec/spassky/client/pusher_spec.rb +4 -4
- data/spec/spassky/client/{test_runner_spec.rb → test_suite_runner_spec.rb} +42 -42
- data/spec/spassky/server/app_spec.rb +8 -8
- data/spec/spassky/server/device_database_spec.rb +0 -10
- data/spec/spassky/{test_result_spec.rb → test_suite_result_spec.rb} +19 -19
- data/spec/spassky/{test_result_summariser_spec.rb → test_suite_result_summariser_spec.rb} +5 -5
- metadata +37 -48
- data/lib/spassky/client/test_runner.rb +0 -52
- data/lib/spassky/test_result.rb +0 -76
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'spassky/client/writer'
|
2
|
-
|
3
|
-
module Spassky::Client
|
4
|
-
class TestRunner
|
5
|
-
def initialize(pusher, writer, directory_reader)
|
6
|
-
@pusher = pusher
|
7
|
-
@writer = writer
|
8
|
-
@directory_reader = directory_reader
|
9
|
-
end
|
10
|
-
|
11
|
-
def run_tests(pattern, test_name)
|
12
|
-
begin
|
13
|
-
@pusher.push(:name => test_name, :contents => @directory_reader.read_files.to_json) do |result|
|
14
|
-
handle_test_result(result)
|
15
|
-
end
|
16
|
-
rescue => error
|
17
|
-
@writer.write_failing(error.message)
|
18
|
-
Kernel.exit(1)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def handle_test_result(test_result)
|
23
|
-
write_in_progress_status test_result
|
24
|
-
unless test_result.status == "in progress"
|
25
|
-
write(test_result.status, test_result.summary)
|
26
|
-
end
|
27
|
-
@previous_test_result = test_result
|
28
|
-
write_exit_code(test_result)
|
29
|
-
end
|
30
|
-
|
31
|
-
def write_in_progress_status test_result
|
32
|
-
test_result.completed_since(@previous_test_result).each do |device_test_status|
|
33
|
-
write_completed_test_status device_test_status
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def write_completed_test_status device_test_status
|
38
|
-
write(device_test_status.status, "#{device_test_status.status.upcase} #{device_test_status.test_name} on #{device_test_status.device_id}")
|
39
|
-
write(device_test_status.status, device_test_status.message)
|
40
|
-
end
|
41
|
-
|
42
|
-
def write status, message
|
43
|
-
method = status == 'pass' ? :write_passing : :write_failing
|
44
|
-
@writer.send(method, message)
|
45
|
-
end
|
46
|
-
|
47
|
-
def write_exit_code(result)
|
48
|
-
Kernel.exit(1) if result.status == 'fail'
|
49
|
-
Kernel.exit(2) if result.status == 'timed out'
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
data/lib/spassky/test_result.rb
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
require 'spassky/test_result_summariser'
|
2
|
-
require 'spassky/device_test_status'
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
module Spassky
|
6
|
-
class TestResult
|
7
|
-
attr_reader :device_statuses
|
8
|
-
def initialize device_statuses
|
9
|
-
@device_statuses = device_statuses
|
10
|
-
end
|
11
|
-
|
12
|
-
def status
|
13
|
-
statuses = @device_statuses.map { |s| s.status }.uniq
|
14
|
-
return "in progress" if statuses.include?("in progress") || statuses.size == 0
|
15
|
-
return "fail" if statuses.include?("fail")
|
16
|
-
return "timed out" if statuses.include?("timed out")
|
17
|
-
"pass"
|
18
|
-
end
|
19
|
-
|
20
|
-
def completed_since(older_test_result)
|
21
|
-
if older_test_result.nil?
|
22
|
-
device_statuses.select { |s| s.completed? }
|
23
|
-
else
|
24
|
-
find_newly_completed_device_results(older_test_result)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def summary
|
29
|
-
TestResultSummariser.new(@device_statuses).summary
|
30
|
-
end
|
31
|
-
|
32
|
-
def to_json
|
33
|
-
{
|
34
|
-
:status => "pass",
|
35
|
-
:device_statuses => @device_statuses.map do |status|
|
36
|
-
{
|
37
|
-
:device_id => status.device_id,
|
38
|
-
:test_name => status.test_name,
|
39
|
-
:status => status.status,
|
40
|
-
:message => status.message
|
41
|
-
}
|
42
|
-
end
|
43
|
-
}.to_json
|
44
|
-
end
|
45
|
-
|
46
|
-
def self.from_json json
|
47
|
-
device_test_statuses = JSON.parse(json)['device_statuses'].map do |device_test_status|
|
48
|
-
DeviceTestStatus.new({
|
49
|
-
:device_id => device_test_status["device_id"],
|
50
|
-
:test_name => device_test_status["test_name"],
|
51
|
-
:status => device_test_status["status"],
|
52
|
-
:message => device_test_status["message"]}
|
53
|
-
)
|
54
|
-
end
|
55
|
-
test_result = TestResult.new(device_test_statuses)
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
def find_newly_completed_device_results(older_test_result)
|
61
|
-
completed = []
|
62
|
-
before_and_after(older_test_result) do |before, after|
|
63
|
-
if before.in_progress? && after.completed?
|
64
|
-
completed << after
|
65
|
-
end
|
66
|
-
end
|
67
|
-
completed
|
68
|
-
end
|
69
|
-
|
70
|
-
def before_and_after(older_test_result)
|
71
|
-
device_statuses.each_with_index do |s, i|
|
72
|
-
yield older_test_result.device_statuses[i], s
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|