moto 1.0.7 → 1.0.8
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/lib/modes/mode_selector.rb +2 -3
- data/lib/modes/run/test_provider.rb +7 -1
- data/lib/parameter_parser.rb +15 -48
- data/lib/reporting/listeners/junit_xml.rb +0 -1
- data/lib/reporting/listeners/webui.rb +46 -99
- data/lib/reporting/test_reporter.rb +1 -5
- data/lib/test/base.rb +1 -0
- data/lib/test/metadata.rb +3 -0
- 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: edd2e049b0e7dba56343581d50e61e9a88026eb7
|
4
|
+
data.tar.gz: 17e66c69f025ae75cf1b42c019024bd91812a715
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e34d0f3514791a3ddc4ff69820bbb81ceb7d1f3308925cb66aabd34db31c76b0e54ac03ad410685a23674a0009e6abaf7705566c0838497544c1adde822efe0
|
7
|
+
data.tar.gz: cc84b318230866656c81e91594dcce32e27d3538b375af3d5c0cb20d7d7303d86dd66c4cfda9afcce5e18ef5721457ce72d3b322fd3fb3b63228f022c7e5c976
|
data/lib/modes/mode_selector.rb
CHANGED
@@ -65,9 +65,8 @@ module Moto
|
|
65
65
|
|
66
66
|
def prepare_test_reporter(parsed_arguments)
|
67
67
|
run_params = {}
|
68
|
-
run_params[:
|
69
|
-
run_params[:
|
70
|
-
run_params[:assignee] = parsed_arguments[:assignee]
|
68
|
+
run_params[:mwui_path] = parsed_arguments[:mwui_path]
|
69
|
+
run_params[:mwui_assignee_id] = parsed_arguments[:mwui_assignee_id]
|
71
70
|
|
72
71
|
Moto::Reporting::TestReporter.new(parsed_arguments[:listeners], run_params)
|
73
72
|
end
|
@@ -49,13 +49,19 @@ module Moto
|
|
49
49
|
@test_metadata = @tests_metadata.shift
|
50
50
|
end
|
51
51
|
|
52
|
+
test_metadata = Marshal.load(Marshal.dump(@test_metadata))
|
53
|
+
|
54
|
+
if test_metadata
|
55
|
+
test_metadata.test_repeat = @current_test_repeat
|
56
|
+
end
|
57
|
+
|
52
58
|
if @current_test_repeat == @test_repeats
|
53
59
|
@current_test_repeat = 1
|
54
60
|
else
|
55
61
|
@current_test_repeat += 1
|
56
62
|
end
|
57
63
|
|
58
|
-
|
64
|
+
test_metadata
|
59
65
|
end
|
60
66
|
private :get_test_metadata
|
61
67
|
|
data/lib/parameter_parser.rb
CHANGED
@@ -68,9 +68,8 @@ module Moto
|
|
68
68
|
# Default options
|
69
69
|
options = {}
|
70
70
|
options[:listeners] = []
|
71
|
-
options[:
|
72
|
-
options[:
|
73
|
-
options[:assignee] = nil
|
71
|
+
options[:mwui_path] = nil
|
72
|
+
options[:mwui_assignee_id] = nil
|
74
73
|
options[:stop_on] = {error: false, fail: false, skip: false}
|
75
74
|
|
76
75
|
# Parse arguments
|
@@ -81,9 +80,8 @@ module Moto
|
|
81
80
|
opts.on('-g', '--tags Tags', Array) {|v| options[:tags] = v}
|
82
81
|
opts.on('-f', '--filters Filters', Array) {|v| options[:filters] = v}
|
83
82
|
opts.on('-l', '--listeners Listeners', Array) {|v| options[:listeners] = v}
|
84
|
-
opts.on('-
|
85
|
-
opts.on('-
|
86
|
-
opts.on('-a', '--assignee Assignee') {|v| options[:assignee] = v}
|
83
|
+
opts.on('--mwui-path MwuiPath') {|v| options[:mwui_path] = v}
|
84
|
+
opts.on('--mwui-assignee-id MwuiAssignee') {|v| options[:mwui_assignee_id] = v}
|
87
85
|
opts.on('-c', '--config Config') {|v| options[:config_name] = v}
|
88
86
|
opts.on('--threads ThreadCount', Integer) {|v| options[:threads] = v}
|
89
87
|
opts.on('--attempts AttemptCount', Integer) {|v| options[:attempts] = v}
|
@@ -104,10 +102,6 @@ module Moto
|
|
104
102
|
end
|
105
103
|
end
|
106
104
|
|
107
|
-
if options[:run_name].nil?
|
108
|
-
options[:run_name] = evaluate_name(options[:tests], options[:tags], options[:filters])
|
109
|
-
end
|
110
|
-
|
111
105
|
# Runner configuration
|
112
106
|
|
113
107
|
Moto::Lib::Config.moto[:test_runner][:thread_count] = options[:threads] if options[:threads]
|
@@ -139,24 +133,20 @@ module Moto
|
|
139
133
|
# Default options
|
140
134
|
options = {}
|
141
135
|
options[:listeners] = []
|
142
|
-
options[:run_name] = nil
|
143
|
-
options[:suite_name] = nil
|
144
|
-
options[:assignee] = nil
|
145
136
|
|
146
137
|
# Parse arguments
|
147
138
|
OptionParser.new do |opts|
|
148
|
-
opts.on('-c', '--config Config')
|
149
|
-
opts.on('-t', '--tests Tests', Array)
|
150
|
-
opts.on('-g', '--tags Tags', Array)
|
151
|
-
opts.on('-f', '--filters Filters', Array)
|
152
|
-
opts.on('-l', '--listeners Listeners', Array)
|
153
|
-
opts.on('-
|
154
|
-
opts.on('-
|
155
|
-
opts.on('-
|
156
|
-
opts.on('-
|
157
|
-
opts.on('-
|
158
|
-
opts.on('-
|
159
|
-
opts.on('-d', '--hasdescription') {|v| options[:validate_has_description] = v}
|
139
|
+
opts.on('-c', '--config Config') {|v| options[:config_name] = v}
|
140
|
+
opts.on('-t', '--tests Tests', Array) {|v| options[:tests] = v}
|
141
|
+
opts.on('-g', '--tags Tags', Array) {|v| options[:tags] = v}
|
142
|
+
opts.on('-f', '--filters Filters', Array) {|v| options[:filters] = v}
|
143
|
+
opts.on('-l', '--listeners Listeners', Array) {|v| options[:listeners] = v}
|
144
|
+
opts.on('--mwui-path MwuiPath') {|v| options[:mwui_path] = v}
|
145
|
+
opts.on('--mwui-assignee-id MwuiAssignee') {|v| options[:mwui_assignee_id] = v}
|
146
|
+
opts.on('-p', '--tagregexpos RegexPositive') {|v| options[:validator_regex_positive] = v}
|
147
|
+
opts.on('-n', '--tagregexneg RegexNegative') {|v| options[:validator_regex_negative] = v}
|
148
|
+
opts.on('-h', '--hastags') {|v| options[:validate_has_tags] = v}
|
149
|
+
opts.on('-d', '--hasdescription') {|v| options[:validate_has_description] = v}
|
160
150
|
opts.on('-w', '--tagwhitelist TagWhitelist', Array) {|v| options[:tag_whitelist] = v}
|
161
151
|
end.parse!
|
162
152
|
|
@@ -168,32 +158,9 @@ module Moto
|
|
168
158
|
end
|
169
159
|
end
|
170
160
|
|
171
|
-
if options[:run_name].nil?
|
172
|
-
options[:run_name] = evaluate_name(options[:tests], options[:tags], options[:filters])
|
173
|
-
end
|
174
|
-
|
175
161
|
return options
|
176
162
|
end
|
177
163
|
|
178
|
-
# Generate default name based on input parameters
|
179
|
-
def self.evaluate_name(tests, tags, filters)
|
180
|
-
name = ''
|
181
|
-
|
182
|
-
if tests
|
183
|
-
name << "Tests: #{tests.join(',')} "
|
184
|
-
end
|
185
|
-
|
186
|
-
if tags
|
187
|
-
name << "Tags: #{tags.join(',')} "
|
188
|
-
end
|
189
|
-
|
190
|
-
if filters
|
191
|
-
name << "Filters: #{filters.join(',')} "
|
192
|
-
end
|
193
|
-
|
194
|
-
return name
|
195
|
-
end
|
196
|
-
|
197
164
|
# Parses attributes passed to the application when run by 'moto generate'
|
198
165
|
def self.generate_parse(argv)
|
199
166
|
options = {}
|
@@ -13,7 +13,6 @@ module Moto
|
|
13
13
|
errors: run_status.tests_error.length,
|
14
14
|
failures: run_status.tests_failed.length,
|
15
15
|
skipped: run_status.tests_skipped.length,
|
16
|
-
name: run_params[:run_name],
|
17
16
|
tests: run_status.tests_all.length,
|
18
17
|
time: run_status.duration,
|
19
18
|
timestamp: Time.at(run_status.time_start)
|
@@ -9,92 +9,36 @@ module Moto
|
|
9
9
|
|
10
10
|
REST_MAX_TRIES = 1
|
11
11
|
REST_TIMEOUT = 15
|
12
|
+
REST_RESULTS_AT_ONCE = 500
|
12
13
|
|
13
14
|
def initialize(run_params)
|
14
15
|
super
|
15
16
|
|
16
|
-
if run_params[:
|
17
|
-
raise 'ERROR: Please specify
|
17
|
+
if run_params[:mwui_path].nil?
|
18
|
+
raise 'ERROR: Please specify directory path (--mwui-path /EXAMPLE/PATH) when using MotoWebUI as one of the listeners.'
|
19
|
+
else
|
20
|
+
@mwui_path = run_params[:mwui_path]
|
18
21
|
end
|
19
22
|
|
20
|
-
if run_params[:
|
21
|
-
@assignee = run_params[:
|
23
|
+
if run_params[:mwui_assignee_id]
|
24
|
+
@assignee = run_params[:mwui_assignee_id]
|
22
25
|
else
|
23
26
|
@assignee = config[:default_assignee]
|
24
27
|
end
|
25
28
|
|
26
29
|
@tests = {}
|
27
|
-
@url = "#{config[:url]}/api"
|
30
|
+
@url = URI.escape("#{config[:url]}/api/motoresults")
|
28
31
|
@send_log_on_pass = config[:send_log_on_pass]
|
29
32
|
end
|
30
33
|
|
31
34
|
def start_run
|
32
|
-
|
33
|
-
# Create Suite, if it did exist already nothing new will be created and existing data will be sent in the response
|
34
|
-
url_suites = "#{@url}/suites"
|
35
|
-
suite_data = {name: run_params[:suite_name]}.to_json
|
36
|
-
|
37
|
-
response = try {
|
38
|
-
RestClient::Request.execute(method: :post,
|
39
|
-
url: URI.escape(url_suites),
|
40
|
-
payload: suite_data,
|
41
|
-
timeout: REST_TIMEOUT,
|
42
|
-
headers: {content_type: :json, accept: :json})
|
43
|
-
}
|
44
|
-
suite = JSON.parse(response, symbolize_names: true)
|
45
|
-
|
46
|
-
# Store ID of current Suite
|
47
|
-
@suite_id = suite[:id]
|
48
|
-
|
49
|
-
# Prepare data for new TestRun
|
50
|
-
url_runs = "#{@url}/suites/#{@suite_id}/runs"
|
51
|
-
run_data = {
|
52
|
-
name: run_params[:run_name],
|
53
|
-
start_time: Time.now
|
54
|
-
}
|
55
|
-
|
56
|
-
if @assignee
|
57
|
-
run_data[:tester_id] = @assignee
|
58
|
-
end
|
59
|
-
|
60
|
-
run_data = run_data.to_json
|
61
|
-
|
62
|
-
# Create new TestRun based on prepared data
|
63
|
-
response = try {
|
64
|
-
RestClient::Request.execute(method: :post,
|
65
|
-
url: URI.escape(url_runs),
|
66
|
-
payload: run_data,
|
67
|
-
timeout: REST_TIMEOUT,
|
68
|
-
headers: {content_type: :json, accept: :json})
|
69
|
-
}
|
70
|
-
|
71
|
-
@run = JSON.parse(response, symbolize_names: true)
|
72
|
-
end
|
73
|
-
|
74
|
-
|
75
|
-
def end_run(run_status)
|
76
|
-
|
77
|
-
url_run = "#{@url}/suites/#{@suite_id}/runs/#{@run[:id]}"
|
78
|
-
run_data = {
|
79
|
-
duration: (Time.now.to_f - run_status.time_start).to_i
|
80
|
-
}.to_json
|
81
|
-
|
82
|
-
response = try {
|
83
|
-
RestClient::Request.execute(method: :put,
|
84
|
-
url: URI.escape(url_run),
|
85
|
-
payload: run_data,
|
86
|
-
timeout: REST_TIMEOUT,
|
87
|
-
headers: {content_type: :json, accept: :json})
|
88
|
-
}
|
89
|
-
@run = JSON.parse(response, symbolize_names: true)
|
90
35
|
end
|
91
36
|
|
92
37
|
def start_test(test_status, test_metadata)
|
93
38
|
|
94
39
|
# Prepare data for new Test
|
95
|
-
url_tests = "#{@url}/suites/#{@suite_id}/runs/#{@run[:id]}/tests"
|
96
40
|
test_data = {
|
97
|
-
name: test_status.display_name,
|
41
|
+
name: test_status.display_name,
|
98
42
|
start_time: Time.now
|
99
43
|
}
|
100
44
|
|
@@ -110,62 +54,65 @@ module Moto
|
|
110
54
|
test_data[:description] = test_metadata.description
|
111
55
|
end
|
112
56
|
|
113
|
-
|
114
|
-
|
115
|
-
# Create new Test based on prepared data
|
116
|
-
response = try {
|
117
|
-
RestClient::Request.execute(method: :post,
|
118
|
-
url: URI.escape(url_tests),
|
119
|
-
payload: test_data,
|
120
|
-
timeout: REST_TIMEOUT,
|
121
|
-
headers: {content_type: :json, accept: :json})
|
122
|
-
}
|
123
|
-
|
124
|
-
test = JSON.parse(response, symbolize_names: true)
|
125
|
-
|
126
|
-
# Store Test in a hash with its name as key so later it can be accessed and server side ID can be retrieved
|
127
|
-
@tests[test[:name]] = test
|
57
|
+
# Store Test in a hash with its name as key so later it can be accessed
|
58
|
+
@tests[test_data[:name]] = test_data
|
128
59
|
end
|
129
60
|
|
130
61
|
|
131
62
|
def end_test(test_status)
|
132
|
-
|
133
|
-
url_test = "#{@url}/suites/#{@suite_id}/runs/#{@run[:id]}/tests/#{@tests[test_status.display_name][:id]}"
|
134
63
|
test_data = {
|
135
64
|
duration: (Time.now.to_f - test_status.time_start).to_i,
|
136
65
|
error_message: test_status.results.last.code == Moto::Test::Result::ERROR ? test_status.results.last.message : nil,
|
137
66
|
fail_message: test_failures(test_status),
|
138
67
|
result_id: webui_result_id(test_status.results.last.code)
|
139
|
-
}.to_json
|
140
|
-
|
141
|
-
# Create new Test based on prepared data
|
142
|
-
response = try {
|
143
|
-
RestClient::Request.execute(method: :put,
|
144
|
-
url: URI.escape(url_test),
|
145
|
-
payload: test_data,
|
146
|
-
timeout: REST_TIMEOUT,
|
147
|
-
headers: {content_type: :json, accept: :json})
|
148
68
|
}
|
149
69
|
|
150
|
-
|
151
|
-
|
152
|
-
@tests[test_status.name] = test
|
70
|
+
@tests[test_status.display_name].merge!(test_data)
|
153
71
|
|
154
72
|
# Add Log to already existing Test
|
155
|
-
if (test_status.results.last.code == Moto::Test::Result::PASSED && @send_log_on_pass) || test_status.results.last.code != Moto::Test::Result::PASSED
|
73
|
+
# if (test_status.results.last.code == Moto::Test::Result::PASSED && @send_log_on_pass) || test_status.results.last.code != Moto::Test::Result::PASSED
|
74
|
+
#
|
75
|
+
# url_log = "#{url_test}/logs"
|
76
|
+
# log_data = { text: File.read(test_status.log_path) }.to_json
|
77
|
+
#
|
78
|
+
# response = try {
|
79
|
+
# RestClient::Request.execute(method: :post,
|
80
|
+
# url: URI.escape(url_log),
|
81
|
+
# payload: log_data,
|
82
|
+
# timeout: REST_TIMEOUT,
|
83
|
+
# headers: {content_type: :json, accept: :json})
|
84
|
+
# }
|
85
|
+
# response
|
86
|
+
# end
|
87
|
+
|
88
|
+
end
|
156
89
|
|
157
|
-
|
158
|
-
|
90
|
+
|
91
|
+
def end_run(run_status)
|
92
|
+
# Ultimately converts Hash to Array, which is going to be way more useful at this point
|
93
|
+
# Assignment is done to the same variable, instead of new one, in order to conserve memory since effectively
|
94
|
+
# we're just duplicating the same data
|
95
|
+
@tests = @tests.values
|
96
|
+
|
97
|
+
while !@tests.empty?
|
98
|
+
partial_run_data = {
|
99
|
+
path: @mwui_path,
|
100
|
+
tester_id: @assignee,
|
101
|
+
tests: @tests.shift(REST_RESULTS_AT_ONCE)
|
102
|
+
}.to_json
|
159
103
|
|
160
104
|
response = try {
|
161
105
|
RestClient::Request.execute(method: :post,
|
162
|
-
url:
|
163
|
-
payload:
|
106
|
+
url: @url,
|
107
|
+
payload: partial_run_data,
|
164
108
|
timeout: REST_TIMEOUT,
|
165
109
|
headers: {content_type: :json, accept: :json})
|
166
110
|
}
|
111
|
+
|
112
|
+
response = JSON.parse(response, symbolize_names: true)
|
167
113
|
response
|
168
114
|
end
|
115
|
+
|
169
116
|
end
|
170
117
|
|
171
118
|
# @return [String] string with messages of all failures in a test
|
@@ -10,10 +10,6 @@ module Moto
|
|
10
10
|
|
11
11
|
# @param [Array] listeners An array of strings, which represent qualified names of classes (listeners) that will be instantiated.
|
12
12
|
# empty array is passed then :default_listeners will be taken from config
|
13
|
-
# @param[Hash] run_params Variables specified by the user when parametrizing current moto run
|
14
|
-
# suite_name: String Name of the test suite
|
15
|
-
# run_name: String Name of the test run, may be custom made or automatically generated
|
16
|
-
# assignee: ID of person responsible for test run
|
17
13
|
def initialize(listeners, run_params)
|
18
14
|
|
19
15
|
if listeners.empty?
|
@@ -65,7 +61,7 @@ module Moto
|
|
65
61
|
end
|
66
62
|
end
|
67
63
|
|
68
|
-
# Reports
|
64
|
+
# Reports start of a test to all attached listeners
|
69
65
|
# @param [Moto::Test::Status] test_status of test which's start is to be reported on
|
70
66
|
# @param [Moto::Test::Metadata] test_metadata of test which's start is to be reported on
|
71
67
|
def report_start_test(test_status, test_metadata)
|
data/lib/test/base.rb
CHANGED
@@ -40,6 +40,7 @@ module Moto
|
|
40
40
|
@status.test_class_name = self.class.name
|
41
41
|
@status.display_name = @status.test_class_name.split('::')[2..-2].join(' > ')
|
42
42
|
@status.display_name += "_#{@params_path.split('/')[-1].chomp('.param')}" if @params_path
|
43
|
+
@status.display_name += "(#{metadata.test_repeat})" if metadata.test_repeat > 1
|
43
44
|
end
|
44
45
|
|
45
46
|
# Setter for :log_path
|
data/lib/test/metadata.rb
CHANGED
@@ -6,6 +6,9 @@ module Moto
|
|
6
6
|
# Absolute test path
|
7
7
|
attr_reader :test_path
|
8
8
|
|
9
|
+
# Indicates which repetition of the same test is represented by this metadata
|
10
|
+
attr_accessor :test_repeat
|
11
|
+
|
9
12
|
# @param [String] test_path Absolute path to file with test
|
10
13
|
def initialize(test_path)
|
11
14
|
@test_path = test_path
|
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: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bartek Wilczek
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2018-01-
|
14
|
+
date: 2018-01-31 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|