moto 0.0.28 → 0.0.29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/moto +5 -5
- data/lib/initializer.rb +6 -6
- data/lib/listeners/webui.rb +70 -70
- data/lib/result.rb +83 -83
- data/lib/test_logging.rb +49 -48
- data/lib/version.rb +1 -1
- metadata +2 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46635f4f7327df68be383058775c5c5c8707aee7
|
4
|
+
data.tar.gz: 5bbc41c516291b2218b500595b430860e2ad6ee4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14c54e69cc76e246c013e75818311530b2a4a88e5bd8181833cf0a9a230af2205cef7d048cec1ebbc1a6cce04693277fa98abbea089dd2a78d021acfb34f588f
|
7
|
+
data.tar.gz: a37712967f69ea24f637b4c7a475d52166b7e32a0a6c0fadcd54f53c5255e8a2d1164254ff34b72666fb64fa89b21d84ee2267a7c8d15eeadd6a3007a74723b2
|
data/bin/moto
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require_relative '../lib/parser'
|
4
|
-
|
5
|
-
Moto::Parser.run ARGV
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require_relative '../lib/parser'
|
4
|
+
|
5
|
+
Moto::Parser.run ARGV
|
data/lib/initializer.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
module Moto
|
2
|
-
class Initializer
|
3
|
-
def initialize(runner)
|
4
|
-
@runner = runner
|
5
|
-
end
|
6
|
-
end
|
1
|
+
module Moto
|
2
|
+
class Initializer
|
3
|
+
def initialize(runner)
|
4
|
+
@runner = runner
|
5
|
+
end
|
6
|
+
end
|
7
7
|
end
|
data/lib/listeners/webui.rb
CHANGED
@@ -1,71 +1,71 @@
|
|
1
|
-
require 'rest-client'
|
2
|
-
require 'sys/uname'
|
3
|
-
|
4
|
-
module Moto
|
5
|
-
module Listeners
|
6
|
-
class Webui < Base
|
7
|
-
|
8
|
-
def start_run
|
9
|
-
# POST http://sandbox.dev:3000/api/runs/create
|
10
|
-
@url = @runner.my_config[:url]
|
11
|
-
data = {
|
12
|
-
name: @runner.name,
|
13
|
-
result: Moto::Result::RUNNING,
|
14
|
-
cnt_all: nil,
|
15
|
-
cnt_passed: nil,
|
16
|
-
cnt_failure: nil,
|
17
|
-
cnt_error: nil,
|
18
|
-
cnt_skipped: nil,
|
19
|
-
user: Sys::Uname.sysname.downcase.include?('windows') ? ENV['USERNAME'] : ENV['LOGNAME'],
|
20
|
-
host: Sys::Uname.nodename,
|
21
|
-
pid: Process.pid
|
22
|
-
}
|
23
|
-
@run = JSON.parse( RestClient.post( "#{@url}/api/runs", data.to_json, :content_type => :json, :accept => :json ) )
|
24
|
-
@tests = {}
|
25
|
-
end
|
26
|
-
|
27
|
-
def end_run
|
28
|
-
# PUT http://sandbox.dev:3000/api/runs/1
|
29
|
-
data = {
|
30
|
-
result: @runner.result.summary[:result],
|
31
|
-
cnt_all: @runner.result.summary[:cnt_all],
|
32
|
-
cnt_passed: @runner.result.summary[:cnt_passed],
|
33
|
-
cnt_failure: @runner.result.summary[:cnt_failure],
|
34
|
-
cnt_error: @runner.result.summary[:cnt_error],
|
35
|
-
cnt_skipped: @runner.result.summary[:cnt_skipped],
|
36
|
-
duration: @runner.result.summary[:duration]
|
37
|
-
}
|
38
|
-
@run = JSON.parse( RestClient.put( "#{@url}/api/runs/#{@run['id']}", data.to_json, :content_type => :json, :accept => :json ) )
|
39
|
-
end
|
40
|
-
|
41
|
-
def start_test(test)
|
42
|
-
# POST http://sandbox.dev:3000/api/tests/create
|
43
|
-
data = {
|
44
|
-
name: test.name,
|
45
|
-
class_name: test.class.name,
|
46
|
-
log: nil,
|
47
|
-
run_id: @run['id'],
|
48
|
-
env: test.env,
|
49
|
-
parameters: test.params.to_s,
|
50
|
-
result: Moto::Result::RUNNING,
|
51
|
-
error: nil,
|
52
|
-
failures: nil,
|
53
|
-
}
|
54
|
-
@tests[test.name] = JSON.parse( RestClient.post( "#{@url}/api/tests", data.to_json, :content_type => :json, :accept => :json ) )
|
55
|
-
end
|
56
|
-
|
57
|
-
def end_test(test)
|
58
|
-
log = File.read(test.log_path)
|
59
|
-
data = {
|
60
|
-
log: log,
|
61
|
-
result: @runner.result[test.name][:result],
|
62
|
-
error: @runner.result[test.name][:error].nil? ? nil : @runner.result[test.name][:error].message,
|
63
|
-
failures: @runner.result[test.name][:failures].join("\n\t"),
|
64
|
-
duration: @runner.result[test.name][:duration]
|
65
|
-
}
|
66
|
-
@tests[test.name] = JSON.parse( RestClient.put( "#{@url}/api/tests/#{@tests[test.name]['id']}", data.to_json, :content_type => :json, :accept => :json ) )
|
67
|
-
end
|
68
|
-
|
69
|
-
end
|
70
|
-
end
|
1
|
+
require 'rest-client'
|
2
|
+
require 'sys/uname'
|
3
|
+
|
4
|
+
module Moto
|
5
|
+
module Listeners
|
6
|
+
class Webui < Base
|
7
|
+
|
8
|
+
def start_run
|
9
|
+
# POST http://sandbox.dev:3000/api/runs/create
|
10
|
+
@url = @runner.my_config[:url]
|
11
|
+
data = {
|
12
|
+
name: @runner.name,
|
13
|
+
result: Moto::Result::RUNNING,
|
14
|
+
cnt_all: nil,
|
15
|
+
cnt_passed: nil,
|
16
|
+
cnt_failure: nil,
|
17
|
+
cnt_error: nil,
|
18
|
+
cnt_skipped: nil,
|
19
|
+
user: Sys::Uname.sysname.downcase.include?('windows') ? ENV['USERNAME'] : ENV['LOGNAME'],
|
20
|
+
host: Sys::Uname.nodename,
|
21
|
+
pid: Process.pid
|
22
|
+
}
|
23
|
+
@run = JSON.parse( RestClient.post( "#{@url}/api/runs", data.to_json, :content_type => :json, :accept => :json ) )
|
24
|
+
@tests = {}
|
25
|
+
end
|
26
|
+
|
27
|
+
def end_run
|
28
|
+
# PUT http://sandbox.dev:3000/api/runs/1
|
29
|
+
data = {
|
30
|
+
result: @runner.result.summary[:result],
|
31
|
+
cnt_all: @runner.result.summary[:cnt_all],
|
32
|
+
cnt_passed: @runner.result.summary[:cnt_passed],
|
33
|
+
cnt_failure: @runner.result.summary[:cnt_failure],
|
34
|
+
cnt_error: @runner.result.summary[:cnt_error],
|
35
|
+
cnt_skipped: @runner.result.summary[:cnt_skipped],
|
36
|
+
duration: @runner.result.summary[:duration]
|
37
|
+
}
|
38
|
+
@run = JSON.parse( RestClient.put( "#{@url}/api/runs/#{@run['id']}", data.to_json, :content_type => :json, :accept => :json ) )
|
39
|
+
end
|
40
|
+
|
41
|
+
def start_test(test)
|
42
|
+
# POST http://sandbox.dev:3000/api/tests/create
|
43
|
+
data = {
|
44
|
+
name: test.name,
|
45
|
+
class_name: test.class.name,
|
46
|
+
log: nil,
|
47
|
+
run_id: @run['id'],
|
48
|
+
env: test.env,
|
49
|
+
parameters: test.params.to_s,
|
50
|
+
result: Moto::Result::RUNNING,
|
51
|
+
error: nil,
|
52
|
+
failures: nil,
|
53
|
+
}
|
54
|
+
@tests[test.name] = JSON.parse( RestClient.post( "#{@url}/api/tests", data.to_json, :content_type => :json, :accept => :json ) )
|
55
|
+
end
|
56
|
+
|
57
|
+
def end_test(test)
|
58
|
+
log = File.read(test.log_path)
|
59
|
+
data = {
|
60
|
+
log: log,
|
61
|
+
result: @runner.result[test.name][:result],
|
62
|
+
error: @runner.result[test.name][:error].nil? ? nil : @runner.result[test.name][:error].message,
|
63
|
+
failures: @runner.result[test.name][:failures].join("\n\t"),
|
64
|
+
duration: @runner.result[test.name][:duration]
|
65
|
+
}
|
66
|
+
@tests[test.name] = JSON.parse( RestClient.put( "#{@url}/api/tests/#{@tests[test.name]['id']}", data.to_json, :content_type => :json, :accept => :json ) )
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
71
71
|
end
|
data/lib/result.rb
CHANGED
@@ -1,84 +1,84 @@
|
|
1
|
-
module Moto
|
2
|
-
class Result
|
3
|
-
|
4
|
-
PENDING = :pending # -2
|
5
|
-
RUNNING = :running # -1
|
6
|
-
PASSED = :passed # 0
|
7
|
-
FAILURE = :failure # 1
|
8
|
-
ERROR = :error # 2
|
9
|
-
SKIPPED = :skipped # 3
|
10
|
-
|
11
|
-
attr_reader :summary
|
12
|
-
|
13
|
-
def [](key)
|
14
|
-
@results[key]
|
15
|
-
end
|
16
|
-
|
17
|
-
def all
|
18
|
-
@results
|
19
|
-
end
|
20
|
-
|
21
|
-
def initialize(runner)
|
22
|
-
@runner = runner
|
23
|
-
@results = {}
|
24
|
-
@summary = {}
|
25
|
-
end
|
26
|
-
|
27
|
-
def start_run
|
28
|
-
# start timer
|
29
|
-
@summary[:started_at] = Time.now.to_f
|
30
|
-
end
|
31
|
-
|
32
|
-
def end_run
|
33
|
-
# info about duration and overall execution result
|
34
|
-
@summary[:finished_at] = Time.now.to_f
|
35
|
-
@summary[:duration] = @summary[:finished_at] - @summary[:started_at]
|
36
|
-
@summary[:result] = PASSED
|
37
|
-
@summary[:result] = FAILURE unless @results.values.select{ |v| v[:failures].count > 0 }.empty?
|
38
|
-
@summary[:result] = ERROR unless @results.values.select{ |v| v[:result] == ERROR }.empty?
|
39
|
-
@summary[:cnt_all] = @results.count
|
40
|
-
@summary[:tests_passed] = @results.select{ |k,v| v[:result] == PASSED }
|
41
|
-
@summary[:tests_failure] = @results.select{ |k,v| v[:result] == FAILURE }
|
42
|
-
@summary[:tests_error] = @results.select{ |k,v| v[:result] == ERROR }
|
43
|
-
@summary[:tests_skipped] = @results.select{ |k,v| v[:result] == SKIPPED }
|
44
|
-
@summary[:cnt_passed] = @summary[:tests_passed].count
|
45
|
-
@summary[:cnt_failure] = @summary[:tests_failure].count
|
46
|
-
@summary[:cnt_error] = @summary[:tests_error].count
|
47
|
-
@summary[:cnt_skipped] = @summary[:tests_skipped].count
|
48
|
-
end
|
49
|
-
|
50
|
-
def start_test(test)
|
51
|
-
@results[test.name] = { class: test.class, result: RUNNING, env: test.env, params: test.params, name: test.name, error: nil, failures: [], started_at: Time.now.to_f }
|
52
|
-
end
|
53
|
-
|
54
|
-
def end_test(test)
|
55
|
-
# calculate result basing on errors/failures
|
56
|
-
@results[test.name][:finished_at] = Time.now.to_f
|
57
|
-
test.result = PASSED
|
58
|
-
test.result = FAILURE unless @results[test.name][:failures].empty?
|
59
|
-
unless @results[test.name][:error].nil?
|
60
|
-
if @results[test.name][:error].is_a? Moto::Exceptions::TestSkipped
|
61
|
-
test.result = SKIPPED
|
62
|
-
elsif @results[test.name][:error].is_a? Moto::Exceptions::TestForcedPassed
|
63
|
-
test.result = PASSED
|
64
|
-
elsif @results[test.name][:error].is_a? Moto::Exceptions::TestForcedFailure
|
65
|
-
add_failure(test, @results[test.name][:error].message)
|
66
|
-
test.result = FAILURE
|
67
|
-
else
|
68
|
-
test.result = ERROR
|
69
|
-
end
|
70
|
-
end
|
71
|
-
@results[test.name][:duration] = @results[test.name][:finished_at] - @results[test.name][:started_at]
|
72
|
-
@results[test.name][:result] = test.result
|
73
|
-
end
|
74
|
-
|
75
|
-
def add_failure(test, msg)
|
76
|
-
@results[test.name][:failures] << msg
|
77
|
-
end
|
78
|
-
|
79
|
-
def add_error(test, e)
|
80
|
-
@results[test.name][:error] = e
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
1
|
+
module Moto
|
2
|
+
class Result
|
3
|
+
|
4
|
+
PENDING = :pending # -2
|
5
|
+
RUNNING = :running # -1
|
6
|
+
PASSED = :passed # 0
|
7
|
+
FAILURE = :failure # 1
|
8
|
+
ERROR = :error # 2
|
9
|
+
SKIPPED = :skipped # 3
|
10
|
+
|
11
|
+
attr_reader :summary
|
12
|
+
|
13
|
+
def [](key)
|
14
|
+
@results[key]
|
15
|
+
end
|
16
|
+
|
17
|
+
def all
|
18
|
+
@results
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(runner)
|
22
|
+
@runner = runner
|
23
|
+
@results = {}
|
24
|
+
@summary = {}
|
25
|
+
end
|
26
|
+
|
27
|
+
def start_run
|
28
|
+
# start timer
|
29
|
+
@summary[:started_at] = Time.now.to_f
|
30
|
+
end
|
31
|
+
|
32
|
+
def end_run
|
33
|
+
# info about duration and overall execution result
|
34
|
+
@summary[:finished_at] = Time.now.to_f
|
35
|
+
@summary[:duration] = @summary[:finished_at] - @summary[:started_at]
|
36
|
+
@summary[:result] = PASSED
|
37
|
+
@summary[:result] = FAILURE unless @results.values.select{ |v| v[:failures].count > 0 }.empty?
|
38
|
+
@summary[:result] = ERROR unless @results.values.select{ |v| v[:result] == ERROR }.empty?
|
39
|
+
@summary[:cnt_all] = @results.count
|
40
|
+
@summary[:tests_passed] = @results.select{ |k,v| v[:result] == PASSED }
|
41
|
+
@summary[:tests_failure] = @results.select{ |k,v| v[:result] == FAILURE }
|
42
|
+
@summary[:tests_error] = @results.select{ |k,v| v[:result] == ERROR }
|
43
|
+
@summary[:tests_skipped] = @results.select{ |k,v| v[:result] == SKIPPED }
|
44
|
+
@summary[:cnt_passed] = @summary[:tests_passed].count
|
45
|
+
@summary[:cnt_failure] = @summary[:tests_failure].count
|
46
|
+
@summary[:cnt_error] = @summary[:tests_error].count
|
47
|
+
@summary[:cnt_skipped] = @summary[:tests_skipped].count
|
48
|
+
end
|
49
|
+
|
50
|
+
def start_test(test)
|
51
|
+
@results[test.name] = { class: test.class, result: RUNNING, env: test.env, params: test.params, name: test.name, error: nil, failures: [], started_at: Time.now.to_f }
|
52
|
+
end
|
53
|
+
|
54
|
+
def end_test(test)
|
55
|
+
# calculate result basing on errors/failures
|
56
|
+
@results[test.name][:finished_at] = Time.now.to_f
|
57
|
+
test.result = PASSED
|
58
|
+
test.result = FAILURE unless @results[test.name][:failures].empty?
|
59
|
+
unless @results[test.name][:error].nil?
|
60
|
+
if @results[test.name][:error].is_a? Moto::Exceptions::TestSkipped
|
61
|
+
test.result = SKIPPED
|
62
|
+
elsif @results[test.name][:error].is_a? Moto::Exceptions::TestForcedPassed
|
63
|
+
test.result = PASSED
|
64
|
+
elsif @results[test.name][:error].is_a? Moto::Exceptions::TestForcedFailure
|
65
|
+
add_failure(test, @results[test.name][:error].message)
|
66
|
+
test.result = FAILURE
|
67
|
+
else
|
68
|
+
test.result = ERROR
|
69
|
+
end
|
70
|
+
end
|
71
|
+
@results[test.name][:duration] = @results[test.name][:finished_at] - @results[test.name][:started_at]
|
72
|
+
@results[test.name][:result] = test.result
|
73
|
+
end
|
74
|
+
|
75
|
+
def add_failure(test, msg)
|
76
|
+
@results[test.name][:failures] << msg
|
77
|
+
end
|
78
|
+
|
79
|
+
def add_error(test, e)
|
80
|
+
@results[test.name][:error] = e
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
84
|
end
|
data/lib/test_logging.rb
CHANGED
@@ -1,49 +1,50 @@
|
|
1
|
-
module Moto
|
2
|
-
module TestLogging
|
3
|
-
|
4
|
-
@@ignore_logging = []
|
5
|
-
|
6
|
-
def self.included(cls)
|
7
|
-
|
8
|
-
def cls.ignore_logging(method)
|
9
|
-
full_name = "#{self.name}::#{method}"
|
10
|
-
@@ignore_logging << full_name
|
11
|
-
end
|
12
|
-
|
13
|
-
def cls.method_added(name)
|
14
|
-
|
15
|
-
Moto::EmptyListener.instance_methods(false).each do |m|
|
16
|
-
full_name = "#{self.name}::#{m}"
|
17
|
-
@@ignore_logging << full_name unless @@ignore_logging.include? full_name
|
18
|
-
end
|
19
|
-
@@ignore_logging << "#{self.name}::new"
|
20
|
-
@@ignore_logging << "#{self.name}::initialize"
|
21
|
-
|
22
|
-
return if @added
|
23
|
-
@added = true # protect from recursion
|
24
|
-
original_method = "original_#{name}"
|
25
|
-
alias_method original_method, name
|
26
|
-
define_method(name) do |*args|
|
27
|
-
full_name = "#{self.class.name}::#{__callee__}"
|
28
|
-
# TODO: use self.class.ancestors to figure out if ancestor::__callee__ is not in @@ignore_logging
|
29
|
-
skip_logging = @@ignore_logging.include? full_name
|
30
|
-
unless skip_logging
|
31
|
-
self.class.ancestors.each do |a|
|
32
|
-
ancestor_name = "#{a.name}::#{__callee__}"
|
33
|
-
if @@ignore_logging.include? ancestor_name
|
34
|
-
skip_logging = true
|
35
|
-
break
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
@context.current_test.logger.debug("ENTER >>> #{self.class.name}::#{__callee__}(#{args})") unless skip_logging
|
40
|
-
result = send original_method, *args
|
41
|
-
|
42
|
-
result
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
1
|
+
module Moto
|
2
|
+
module TestLogging
|
3
|
+
|
4
|
+
@@ignore_logging = []
|
5
|
+
|
6
|
+
def self.included(cls)
|
7
|
+
|
8
|
+
def cls.ignore_logging(method)
|
9
|
+
full_name = "#{self.name}::#{method}"
|
10
|
+
@@ignore_logging << full_name
|
11
|
+
end
|
12
|
+
|
13
|
+
def cls.method_added(name)
|
14
|
+
|
15
|
+
Moto::EmptyListener.instance_methods(false).each do |m|
|
16
|
+
full_name = "#{self.name}::#{m}"
|
17
|
+
@@ignore_logging << full_name unless @@ignore_logging.include? full_name
|
18
|
+
end
|
19
|
+
@@ignore_logging << "#{self.name}::new"
|
20
|
+
@@ignore_logging << "#{self.name}::initialize"
|
21
|
+
|
22
|
+
return if @added
|
23
|
+
@added = true # protect from recursion
|
24
|
+
original_method = "original_#{name}"
|
25
|
+
alias_method original_method, name
|
26
|
+
define_method(name) do |*args|
|
27
|
+
full_name = "#{self.class.name}::#{__callee__}"
|
28
|
+
# TODO: use self.class.ancestors to figure out if ancestor::__callee__ is not in @@ignore_logging
|
29
|
+
skip_logging = @@ignore_logging.include? full_name
|
30
|
+
unless skip_logging
|
31
|
+
self.class.ancestors.each do |a|
|
32
|
+
ancestor_name = "#{a.name}::#{__callee__}"
|
33
|
+
if @@ignore_logging.include? ancestor_name
|
34
|
+
skip_logging = true
|
35
|
+
break
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
@context.current_test.logger.debug("ENTER >>> #{self.class.name}::#{__callee__}(#{args})") unless skip_logging
|
40
|
+
result = send original_method, *args
|
41
|
+
# Below is the hack to properly escape binary data (if any manages to make it to logs)
|
42
|
+
@context.current_test.logger.debug("LEAVE <<< #{self.class.name}::#{__callee__} => #{[result].to_s[1..-2]}") unless skip_logging
|
43
|
+
result
|
44
|
+
end
|
45
|
+
@added = false
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
49
50
|
end
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.29
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bartek Wilczek
|
8
8
|
- Maciej Stark
|
9
9
|
- Radosław Sporny
|
10
|
-
- Michał Kujawski
|
11
10
|
autorequire:
|
12
11
|
bindir: bin
|
13
12
|
cert_chain: []
|
14
|
-
date: 2016-03-
|
13
|
+
date: 2016-03-10 00:00:00.000000000 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: activesupport
|
@@ -77,7 +76,6 @@ email:
|
|
77
76
|
- bwilczek@gmail.com
|
78
77
|
- stark.maciej@gmail.com
|
79
78
|
- r.sporny@gmail.com
|
80
|
-
- michal.kujawski@gmail.com
|
81
79
|
executables:
|
82
80
|
- moto
|
83
81
|
extensions: []
|