moto 1.0.1 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6b4ceb470385c95d1e34d5907d3c055eb0e82d01
4
- data.tar.gz: 9787f8dd894e7c2b00ac240646c019594d336a20
3
+ metadata.gz: 58cc88ecb6791a74c19ba8f415ab37392a7189f2
4
+ data.tar.gz: b7206e4a0a7312fb01a7d40971d9119e2ee2ed5b
5
5
  SHA512:
6
- metadata.gz: 57029064fc0aac2f0cfb0a234268aac0916330bc1fae83727f08ed95349c0098113092453a93d29021b300a8c7cd968a3867b96be75df1c546adc77ab3c946e3
7
- data.tar.gz: 9a0acf25d4ea66d626c48fefdb07abc121120c7c55b0ad697dba57882cdeed506f6d6938ccfc2d4edbf398b11640a3d4c5db7dc5596f702c46e8b03f57ba8bad
6
+ metadata.gz: f20a9ea1cf5fac91e261c9bc046155a0b1a6d8f98c2f6fc8ffa3f45457b079cfe99cc7c30f265f1281aa69f2f60b8f9dfb79cc15765b79b072126f3f1a87e414
7
+ data.tar.gz: 2dcd7abbcfb2da1ff31ae97bd8ddb0c934e94dda2c900a45c47923d3bac27a167fa698f3441e8f72d1994d0e20bf9027f09576c8934204ed97765921cc090e55
data/bin/moto CHANGED
@@ -3,8 +3,11 @@
3
3
  require_relative '../lib/test/base'
4
4
 
5
5
  require_relative '../lib/reporting/listeners/base'
6
- require_relative '../lib/reporting/listeners/console'
7
6
  require_relative '../lib/reporting/listeners/console_dots'
7
+ require_relative '../lib/reporting/listeners/silent'
8
+ require_relative '../lib/reporting/listeners/summary_short'
9
+ require_relative '../lib/reporting/listeners/summary_only'
10
+ require_relative '../lib/reporting/listeners/attempts'
8
11
  require_relative '../lib/reporting/listeners/junit_xml'
9
12
  require_relative '../lib/reporting/listeners/webui'
10
13
 
@@ -17,8 +17,14 @@ module Moto
17
17
 
18
18
  # Loads configuration for whole test run and files responsible for environmental constants.
19
19
  # @param [String] config_name Name of the main Moto/MotoApp config to be loaded. Without extension.
20
- def self.load_configuration(config_name)
21
- config_path = "#{MotoApp::DIR}/config/#{config_name}.rb"
20
+ # @param [String] env Name of the env config to be loaded in addition to /config/environments/common. Without extension.
21
+ def self.load_configuration(config_name, env)
22
+
23
+ if config_name
24
+ config_path = "#{MotoApp::DIR}/config/#{config_name}.rb"
25
+ else
26
+ config_path = "#{MotoApp::DIR}/config/moto.rb"
27
+ end
22
28
 
23
29
  if File.exists?(config_path)
24
30
  @@moto = eval(File.read(config_path))
@@ -31,13 +37,20 @@ module Moto
31
37
  end
32
38
 
33
39
  # Try reading constants specific to current environment
34
- begin
35
- environment_constants = eval(File.read("config/environments/#{@@environment}.rb"))
36
- rescue
37
- environment_constants = {}
40
+ if env
41
+ self.environment = env
42
+
43
+ begin
44
+ environment_constants = eval(File.read("config/environments/#{@@environment}.rb"))
45
+ rescue
46
+ environment_constants = {}
47
+ end
48
+ end
49
+
50
+ if environment_constants
51
+ @@env_consts = common_constants.deep_merge(environment_constants)
38
52
  end
39
53
 
40
- @@env_consts = common_constants.deep_merge(environment_constants)
41
54
  else
42
55
  raise "Config file: #{config_path} does not exist.\nDoes current working directory contain Moto application?"
43
56
  end
@@ -26,7 +26,13 @@ module Moto
26
26
  if options[:base_class].nil?
27
27
  base_class_qualified_name = 'Moto::Test::Base'
28
28
  else
29
- base_class_qualified_name = "#{options[:app_name]}::Lib::Test::#{options[:base_class].split('/').join('::').camelize}"
29
+ name_parts = options[:base_class].split('/')
30
+
31
+ name_parts.each_with_index do |part,index|
32
+ name_parts[index] = part.camelize
33
+ end
34
+
35
+ base_class_qualified_name = "#{options[:app_name]}::Lib::Test::#{name_parts.join('::')}"
30
36
  end
31
37
 
32
38
  # Where to put finished template
@@ -43,9 +49,11 @@ module Moto
43
49
 
44
50
  indent = 0
45
51
 
46
- if options[:base_class].nil?
47
- file << "\n"
48
- else
52
+ file << "# MOTO_TAGS: \n"
53
+ file << "# DESC: Template genereated by 'moto generate'\n"
54
+ file << "# DESC: line2\n\n"
55
+
56
+ if options[:base_class]
49
57
  file << "require './lib/test/#{options[:base_class]}.rb'\n\n"
50
58
  end
51
59
 
@@ -54,7 +62,6 @@ module Moto
54
62
  indent += 2
55
63
  end
56
64
 
57
- file << (' ' * indent) + "# Class template genereated by 'moto generate'\n"
58
65
  file << (' ' * indent) + "class #{class_name} < #{base_class_qualified_name}\n\n"
59
66
  indent += 2
60
67
  file << (' ' * indent) + "def run\n"
@@ -5,7 +5,6 @@ rescue
5
5
  nil
6
6
  end
7
7
 
8
-
9
8
  require 'optparse'
10
9
  require 'logger'
11
10
  require_relative 'config'
@@ -19,6 +18,11 @@ module Moto
19
18
 
20
19
  mode_selector = Moto::Modes::ModeSelector.new
21
20
 
21
+ # TODO: IMPORTANT ISSUE
22
+ # xxx_parse functions should not return parsed arguments and pass them to functions
23
+ # but instead all should inject proper values into Moto::Lib::Config.moto[:xxx][:yyy]
24
+ # on which all further components should relay
25
+
22
26
  if argv[0] == '--version'
23
27
  mode_selector.version
24
28
  elsif argv[0] == 'run' && argv.length > 1
@@ -39,6 +43,27 @@ module Moto
39
43
  end
40
44
  end
41
45
 
46
+ def self.prepare_config(options)
47
+ Moto::Lib::Config.load_configuration(options[:config_name], options[:environment])
48
+
49
+ if !config_test_runner
50
+ Moto::Lib::Config.moto[:test_runner] = {}
51
+ end
52
+
53
+ if !config_test_generator
54
+ Moto::Lib::Config.moto[:test_generator] = {}
55
+ end
56
+
57
+ end
58
+
59
+ def self.config_test_runner
60
+ Moto::Lib::Config.moto[:test_runner]
61
+ end
62
+
63
+ def self.config_test_generator
64
+ Moto::Lib::Config.moto[:test_generator]
65
+ end
66
+
42
67
  def self.run_parse(argv)
43
68
  # Default options
44
69
  options = {}
@@ -50,27 +75,29 @@ module Moto
50
75
 
51
76
  # Parse arguments
52
77
  OptionParser.new do |opts|
53
- opts.on('-t', '--tests Tests', Array) {|v| options[:tests] = v}
54
- opts.on('-g', '--tags Tags', Array) {|v| options[:tags] = v}
55
- opts.on('-f', '--filters Filters', Array) {|v| options[:filters] = v}
78
+ opts.on('-c', '--config Config') {|v| options[:config_name] = v}
79
+ opts.on('-e', '--environment Environment') {|v| options[:environment] = v}
80
+ opts.on('-t', '--tests Tests', Array) {|v| options[:tests] = v}
81
+ opts.on('-g', '--tags Tags', Array) {|v| options[:tags] = v}
82
+ opts.on('-f', '--filters Filters', Array) {|v| options[:filters] = v}
56
83
  opts.on('-l', '--listeners Listeners', Array) {|v| options[:listeners] = v}
57
- opts.on('-e', '--environment Environment') {|v| options[:environment] = v}
58
- opts.on('-r', '--runname RunName') {|v| options[:run_name] = v}
59
- opts.on('-s', '--suitename SuiteName') {|v| options[:suite_name] = v}
60
- opts.on('-a', '--assignee Assignee') {|v| options[:assignee] = v}
61
- opts.on('-c', '--config Config') {|v| options[:config_name] = v}
62
- opts.on('--threads ThreadCount', Integer) {|v| options[:threads] = v}
63
- opts.on('--attempts AttemptCount', Integer) {|v| options[:attempts] = v}
64
- opts.on('--stop-on-error') {options[:stop_on][:error] = true}
65
- opts.on('--stop-on-fail') {options[:stop_on][:fail] = true}
66
- opts.on('--stop-on-skip') {options[:stop_on][:skip] = true}
67
- opts.on('--dry-run') {options[:dry_run] = true}
68
- opts.on('-x', '--explicit-errors') {options[:explicit_errors] = true}
69
- opts.on('--log-level LogLevel') {|v| options[:log_level] = v}
70
- opts.on('--param-name ParamName') {|v| options[:param_name] = v}
71
-
84
+ opts.on('-r', '--runname RunName') {|v| options[:run_name] = v}
85
+ opts.on('-s', '--suitename SuiteName') {|v| options[:suite_name] = v}
86
+ opts.on('-a', '--assignee Assignee') {|v| options[:assignee] = v}
87
+ opts.on('-c', '--config Config') {|v| options[:config_name] = v}
88
+ opts.on('--threads ThreadCount', Integer) {|v| options[:threads] = v}
89
+ opts.on('--attempts AttemptCount', Integer) {|v| options[:attempts] = v}
90
+ opts.on('--stop-on-error') {options[:stop_on][:error] = true}
91
+ opts.on('--stop-on-fail') {options[:stop_on][:fail] = true}
92
+ opts.on('--stop-on-skip') {options[:stop_on][:skip] = true}
93
+ opts.on('--dry-run') {options[:dry_run] = true}
94
+ opts.on('-x', '--explicit-errors') {options[:explicit_errors] = true}
95
+ opts.on('--log-level LogLevel') {|v| options[:log_level] = v}
96
+ opts.on('--param-name ParamName') {|v| options[:param_name] = v}
72
97
  end.parse!
73
98
 
99
+ self.prepare_config(options)
100
+
74
101
  if options[:tests]
75
102
  options[:tests].each do |path|
76
103
  path.sub!(%r{\/$}, '') # remove trailing "/"
@@ -81,23 +108,6 @@ module Moto
81
108
  options[:run_name] = evaluate_name(options[:tests], options[:tags], options[:filters])
82
109
  end
83
110
 
84
- if options[:environment]
85
- Moto::Lib::Config.environment = options[:environment]
86
- else
87
- puts 'ERROR: Environment is mandatory.'
88
- Kernel.exit(-1)
89
- end
90
-
91
- Moto::Lib::Config.load_configuration(options[:config_name] ? options[:config_name] : 'moto')
92
-
93
- if !Moto::Lib::Config.moto[:test_runner]
94
- Moto::Lib::Config.moto[:test_runner] = {}
95
- end
96
-
97
- if !Moto::Lib::Config.moto[:test_generator]
98
- Moto::Lib::Config.moto[:test_generator] = {}
99
- end
100
-
101
111
  # Runner configuration
102
112
 
103
113
  Moto::Lib::Config.moto[:test_runner][:thread_count] = options[:threads] if options[:threads]
@@ -120,7 +130,6 @@ module Moto
120
130
  end
121
131
 
122
132
  # Generator configuration
123
-
124
133
  Moto::Lib::Config.moto[:test_generator][:param_name] = options[:param_name] if options[:param_name]
125
134
 
126
135
  return options
@@ -136,6 +145,7 @@ module Moto
136
145
 
137
146
  # Parse arguments
138
147
  OptionParser.new do |opts|
148
+ opts.on('-c', '--config Config') {|v| options[:config_name] = v}
139
149
  opts.on('-t', '--tests Tests', Array) {|v| options[:tests] = v}
140
150
  opts.on('-g', '--tags Tags', Array) {|v| options[:tags] = v}
141
151
  opts.on('-f', '--filters Filters', Array) {|v| options[:filters] = v}
@@ -143,7 +153,6 @@ module Moto
143
153
  opts.on('-r', '--runname RunName') {|v| options[:run_name] = v}
144
154
  opts.on('-s', '--suitename SuiteName') {|v| options[:suite_name] = v}
145
155
  opts.on('-a', '--assignee Assignee') {|v| options[:assignee] = v}
146
- opts.on('-c', '--config Config') {|v| options[:config_name] = v}
147
156
  opts.on('-p', '--tagregexpos RegexPositive') {|v| options[:validator_regex_positive] = v}
148
157
  opts.on('-n', '--tagregexneg RegexNegative') {|v| options[:validator_regex_negative] = v}
149
158
  opts.on('-h', '--hastags') {|v| options[:validate_has_tags] = v}
@@ -151,6 +160,8 @@ module Moto
151
160
  opts.on('-w', '--tagwhitelist TagWhitelist', Array) {|v| options[:tag_whitelist] = v}
152
161
  end.parse!
153
162
 
163
+ self.prepare_config(options)
164
+
154
165
  if options[:tests]
155
166
  options[:tests].each do |path|
156
167
  path.sub!(%r{\/$}, '') # remove trailing "/"
@@ -161,8 +172,6 @@ module Moto
161
172
  options[:run_name] = evaluate_name(options[:tests], options[:tags], options[:filters])
162
173
  end
163
174
 
164
- Moto::Lib::Config.load_configuration(options[:config_name] ? options[:config_name] : 'moto')
165
-
166
175
  return options
167
176
  end
168
177
 
@@ -196,6 +205,8 @@ module Moto
196
205
  opts.on('-f', '--force') {options[:force] = true}
197
206
  end.parse!
198
207
 
208
+ self.prepare_config(options)
209
+
199
210
  options[:dir] = options[:dir].underscore
200
211
 
201
212
  if options[:app_name].nil?
@@ -231,7 +242,10 @@ module Moto
231
242
  Use ~ to filter tests that do not contain specific tag, e.g. ~tag
232
243
 
233
244
 
234
- -e, --environment Mandatory environment. Environment constants and tests parametrized in certain way depend on this.
245
+ -e, --environment Environment constants and tests parametrized in certain way depend on this.
246
+ Without this param only `config/environment/common.rb` will be loaded.
247
+ If provided moto will try to load additionally `config/environment/NAME.rb` and apply changes
248
+ on top of already loaded common configuration.
235
249
  -c, --config Name of the config, without extension, to be loaded from MotoApp/config/CONFIG_NAME.rb
236
250
  Default: moto (which loads: MotoApp/config/moto.rb)
237
251
 
@@ -0,0 +1,46 @@
1
+ module Moto
2
+ module Reporting
3
+ module Listeners
4
+ class Attempts < Base
5
+
6
+ def initialize(run_params)
7
+ @displayed_results = 0
8
+ @semaphore = Mutex.new
9
+ end
10
+
11
+ def end_run(run_status)
12
+ puts ''
13
+ puts "FINISHED: #{run_status.to_s}, duration: #{Time.at(run_status.duration).utc.strftime("%H:%M:%S")}"
14
+ puts "Tests executed: #{run_status.tests_all.length}"
15
+ puts " Passed: #{run_status.tests_passed.length}"
16
+ puts " Failure: #{run_status.tests_failed.length}"
17
+ puts " Error: #{run_status.tests_error.length}"
18
+ puts " Skipped: #{run_status.tests_skipped.length}"
19
+ end
20
+
21
+ def start_test(test_status, test_metadata)
22
+ end
23
+
24
+ def end_test(test_status)
25
+ @semaphore.synchronize do
26
+
27
+ @displayed_results += 1
28
+
29
+ representation =
30
+ case test_status.results.last.code
31
+ when Moto::Test::Result::PASSED then 'Pass'
32
+ when Moto::Test::Result::FAILURE then 'Fail'
33
+ when Moto::Test::Result::ERROR then 'Error'
34
+ when Moto::Test::Result::SKIPPED then 'Skip'
35
+ end
36
+
37
+ if test_status.attempts > 1
38
+ puts "#{test_status.display_name} :: #{test_status.attempts} :: #{representation}"
39
+ end
40
+ end
41
+ end
42
+
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,21 @@
1
+ module Moto
2
+ module Reporting
3
+ module Listeners
4
+ class Silent < Base
5
+
6
+ def start_run
7
+ end
8
+
9
+ def end_run(run_status)
10
+ end
11
+
12
+ def start_test(test_status, test_metadata)
13
+ end
14
+
15
+ def end_test(test_status)
16
+ end
17
+
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,10 +1,9 @@
1
1
  module Moto
2
2
  module Reporting
3
3
  module Listeners
4
- class Console < Base
4
+ class SummaryOnly < Base
5
5
 
6
6
  def start_run
7
- # puts 'START'
8
7
  end
9
8
 
10
9
  def end_run(run_status)
@@ -17,8 +16,10 @@ module Moto
17
16
  puts " Skipped: #{run_status.tests_skipped.length}"
18
17
  end
19
18
 
19
+ def start_test(test_status, test_metadata)
20
+ end
21
+
20
22
  def end_test(test_status)
21
- puts "\n#{test_status.name}\n\t#{test_status.results.last.message}"
22
23
  end
23
24
 
24
25
  end
@@ -0,0 +1,48 @@
1
+ module Moto
2
+ module Reporting
3
+ module Listeners
4
+ class SummaryShort < Base
5
+
6
+ def initialize(run_params)
7
+ @displayed_results = 0
8
+ @semaphore = Mutex.new
9
+ end
10
+
11
+ def end_run(run_status)
12
+ puts ''
13
+ puts "FINISHED: #{run_status.to_s}, duration: #{Time.at(run_status.duration).utc.strftime("%H:%M:%S")}"
14
+ puts "Tests executed: #{run_status.tests_all.length}"
15
+ puts " Passed: #{run_status.tests_passed.length}"
16
+ puts " Failure: #{run_status.tests_failed.length}"
17
+ puts " Error: #{run_status.tests_error.length}"
18
+ puts " Skipped: #{run_status.tests_skipped.length}"
19
+ end
20
+
21
+ def start_test(test_status, test_metadata)
22
+ end
23
+
24
+ def end_test(test_status)
25
+ @semaphore.synchronize do
26
+ @displayed_results += 1
27
+
28
+ representation =
29
+ case test_status.results.last.code
30
+ when Moto::Test::Result::PASSED then '.'
31
+ when Moto::Test::Result::FAILURE then 'F'
32
+ when Moto::Test::Result::ERROR then 'E'
33
+ when Moto::Test::Result::SKIPPED then 's'
34
+ end
35
+
36
+ if @displayed_results%50 != 0
37
+ print representation
38
+ else
39
+ puts representation
40
+ end
41
+
42
+ end
43
+ end
44
+
45
+ end
46
+ end
47
+ end
48
+ end
@@ -36,8 +36,12 @@ module Moto
36
36
  # Path to test's log, for purpose of making test logs accessible via listeners
37
37
  attr_accessor :log_path
38
38
 
39
+ # Amount of attempts that have been made to successfuly complete a test
40
+ attr_accessor :attempts
41
+
39
42
  def initialize
40
43
  @results = []
44
+ @attempts = 0
41
45
  end
42
46
 
43
47
  def initialize_run
@@ -45,6 +49,8 @@ module Moto
45
49
  @time_start = Time.now.to_f
46
50
  end
47
51
 
52
+ @attempts += 1
53
+
48
54
  result = Moto::Test::Result.new
49
55
  result.code = Moto::Test::Result::RUNNING
50
56
  @results.push(result)
@@ -1,3 +1,3 @@
1
1
  module Moto
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.5'
3
3
  end
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.1
4
+ version: 1.0.5
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: 2017-10-10 00:00:00.000000000 Z
14
+ date: 2017-11-27 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport
@@ -97,10 +97,13 @@ files:
97
97
  - lib/modes/run/thread_context.rb
98
98
  - lib/modes/validate/test_validator.rb
99
99
  - lib/parameter_parser.rb
100
+ - lib/reporting/listeners/attempts.rb
100
101
  - lib/reporting/listeners/base.rb
101
- - lib/reporting/listeners/console.rb
102
102
  - lib/reporting/listeners/console_dots.rb
103
103
  - lib/reporting/listeners/junit_xml.rb
104
+ - lib/reporting/listeners/silent.rb
105
+ - lib/reporting/listeners/summary_only.rb
106
+ - lib/reporting/listeners/summary_short.rb
104
107
  - lib/reporting/listeners/webui.rb
105
108
  - lib/reporting/run_status.rb
106
109
  - lib/reporting/test_reporter.rb