moto 0.0.29 → 0.0.30
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.
- checksums.yaml +4 -4
- data/bin/moto +5 -5
- data/lib/clients/website.rb +4 -2
- data/lib/initializer.rb +6 -6
- data/lib/listeners/webui.rb +70 -70
- data/lib/result.rb +83 -83
- data/lib/runner.rb +2 -0
- data/lib/test.rb +4 -0
- data/lib/test_generator.rb +27 -2
- data/lib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7dd8f5b2e3a238f83d7e898e6279ec2f788ce54
|
4
|
+
data.tar.gz: 7ab6ef95c08fa90a159db853094efaacb06f1c01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b32033f7ea015858a23f4546b9e03ef1e8627c3e3639f0f240a253376cacab9e2950970e7c4441e956f206ffbba32279ba465c0a10b10ce212de47a168e9c61f
|
7
|
+
data.tar.gz: a5a1d760afaee024f47d736065bfbcc203846c16076a9f8333d820db042718b98c48264627ffaf2d8576db4dde3c0334949e3213fbf195bc15a2cbaca6755e69
|
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/clients/website.rb
CHANGED
@@ -17,8 +17,10 @@ module Moto
|
|
17
17
|
|
18
18
|
def start_run
|
19
19
|
# TODO: make session driver configurable
|
20
|
-
context.runner.my_config[:capybara][:default_selector]
|
21
|
-
|
20
|
+
if context.runner.my_config[:capybara][:default_selector]
|
21
|
+
Capybara.default_selector = context.runner.my_config[:capybara][:default_selector]
|
22
|
+
end
|
23
|
+
|
22
24
|
Thread.current['capybara_session'] = Capybara::Session.new(context.runner.my_config[:capybara][:default_driver])
|
23
25
|
@pages = {}
|
24
26
|
end
|
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/runner.rb
CHANGED
@@ -57,12 +57,14 @@ module Moto
|
|
57
57
|
|
58
58
|
def run
|
59
59
|
@listeners.each { |l| l.start_run }
|
60
|
+
|
60
61
|
@tests.each do |test|
|
61
62
|
@thread_pool.schedule do
|
62
63
|
tc = ThreadContext.new(self, test)
|
63
64
|
tc.run
|
64
65
|
end
|
65
66
|
end
|
67
|
+
|
66
68
|
@thread_pool.shutdown
|
67
69
|
@listeners.each { |l| l.end_run }
|
68
70
|
end
|
data/lib/test.rb
CHANGED
@@ -36,6 +36,9 @@ module Moto
|
|
36
36
|
set_name(params_index)
|
37
37
|
end
|
38
38
|
|
39
|
+
# Sets name of the test based on its properties:
|
40
|
+
# - number/name of currently executed configuration run
|
41
|
+
# - env
|
39
42
|
def set_name(params_index)
|
40
43
|
if @env == :__default
|
41
44
|
return @name = "#{self.class.to_s}" if @params.empty?
|
@@ -48,6 +51,7 @@ module Moto
|
|
48
51
|
end
|
49
52
|
@name = self.class.to_s
|
50
53
|
end
|
54
|
+
private :set_name
|
51
55
|
|
52
56
|
def dir
|
53
57
|
# puts self.class.path
|
data/lib/test_generator.rb
CHANGED
@@ -50,8 +50,33 @@ module Moto
|
|
50
50
|
# Generates objects with tests that are supposed to be executed in this run.
|
51
51
|
def generate_for_full_class_code(test_path_absolute)
|
52
52
|
require test_path_absolute
|
53
|
-
|
54
|
-
test_object =
|
53
|
+
|
54
|
+
test_object = nil
|
55
|
+
|
56
|
+
# Checking if it's possible to create test based on provided path. In case something is wrong with
|
57
|
+
# modules structure in class itself Moto::Test will be instantized with raise injected into its run()
|
58
|
+
# so we can have proper reporting and summary even if the test doesn't execute.
|
59
|
+
begin
|
60
|
+
class_name = test_path_absolute.gsub("#{MotoApp::DIR}/",'moto_app/').camelize.chomp('.rb').constantize
|
61
|
+
test_object = class_name.new
|
62
|
+
rescue NameError
|
63
|
+
class_name = Moto::Test
|
64
|
+
test_object = class_name.new
|
65
|
+
|
66
|
+
class << test_object
|
67
|
+
attr_accessor :custom_name
|
68
|
+
end
|
69
|
+
|
70
|
+
test_object.custom_name = test_path_absolute.gsub("#{MotoApp::DIR}/",'moto_app/').camelize.chomp('.rb')
|
71
|
+
|
72
|
+
class << test_object
|
73
|
+
def run
|
74
|
+
raise "ERROR: Invalid module structure: #{custom_name}"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
55
80
|
test_object.static_path = test_path_absolute
|
56
81
|
test_object.evaled = false
|
57
82
|
test_object
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.30
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bartek Wilczek
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-03-
|
13
|
+
date: 2016-03-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|