moto 0.7.2 → 0.7.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be0991718ac695d0b5b90b955f896fe52472b982
4
- data.tar.gz: 5a979cb0d173620014ee1c765bd1613c42d0c227
3
+ metadata.gz: b7dfa94193904de4da842adb7573c6cf154561fc
4
+ data.tar.gz: 38d2d4a3ae5d5c540fe8fbdbd7c0d5cba4ffd846
5
5
  SHA512:
6
- metadata.gz: 219808323dfc15c7046c2f29759907df267345b4839aeaaebd9f3f4c5397c199e20a49c37420a3b5de4ba0eaa6cc06219d9723bde4d9da8b857e6d45902d306f
7
- data.tar.gz: 97ceabe6d63dc2c1275e295fbae4a8bc4aeb567d0cdda684655e686f6ee71e7c97696365657bfea8f805a21da96a8d555c6324717a087475d7d8d34aee22f18e
6
+ metadata.gz: a1e9dab5e33f38f0ffaadba500774002b150d84d84975e71aa8b69daddc6d067c07e82df61cfd0c613e51f8a1c2e6d7d66c25931df9530c3b3d381a61e1a0e32
7
+ data.tar.gz: f84bf1d784121556b2f3337b52b8f7dec44fc633742f0a71070a71460468a09903cf35f7de279d283f42eecdf5db299440ce8e002d16d09ac8d6aa488668a620
data/lib/cli.rb CHANGED
@@ -39,6 +39,7 @@ module Moto
39
39
  def self.run(argv)
40
40
  test_paths_absolute = []
41
41
 
42
+ #TODO Remove providing an array ?
42
43
  unless argv[ :tests ].nil?
43
44
  argv[ :tests ].each do |dir_name|
44
45
  test_paths = Dir.glob("#{MotoApp::DIR}/tests/#{dir_name}/**/*.rb")
@@ -47,7 +48,7 @@ module Moto
47
48
  end
48
49
  end
49
50
 
50
- # TODO Optimization for files without #MOTO_TAGS
51
+ # TODO Optimization for files without #MOTO_TAGS - add support for tags in params (not here)
51
52
  unless argv[:tags].nil?
52
53
  tests_total = Dir.glob("#{MotoApp::DIR}/tests/**/*.rb")
53
54
  tests_total.each do |test_path|
@@ -1,17 +1,17 @@
1
- module Moto
2
- module EmptyListener
3
-
4
- def start_run
5
- end
6
-
7
- def end_run
8
- end
9
-
10
- def start_test(test)
11
- end
12
-
13
- def end_test(test)
14
- end
15
-
16
- end
1
+ module Moto
2
+ module EmptyListener
3
+
4
+ def start_run
5
+ end
6
+
7
+ def end_run
8
+ end
9
+
10
+ def start_test(test)
11
+ end
12
+
13
+ def end_test(test)
14
+ end
15
+
16
+ end
17
17
  end
@@ -1,7 +1,7 @@
1
- module Moto
2
- module Exceptions
3
- class MotoException < RuntimeError
4
-
5
- end
6
- end
1
+ module Moto
2
+ module Exceptions
3
+ class MotoException < RuntimeError
4
+
5
+ end
6
+ end
7
7
  end
@@ -1,7 +1,7 @@
1
- module Moto
2
- module Exceptions
3
- class TestForcedFailure < MotoException
4
-
5
- end
6
- end
1
+ module Moto
2
+ module Exceptions
3
+ class TestForcedFailure < MotoException
4
+
5
+ end
6
+ end
7
7
  end
@@ -1,7 +1,7 @@
1
- module Moto
2
- module Exceptions
3
- class TestForcedPassed < MotoException
4
-
5
- end
6
- end
1
+ module Moto
2
+ module Exceptions
3
+ class TestForcedPassed < MotoException
4
+
5
+ end
6
+ end
7
7
  end
@@ -1,7 +1,7 @@
1
- module Moto
2
- module Exceptions
3
- class TestSkipped < MotoException
4
-
5
- end
6
- end
1
+ module Moto
2
+ module Exceptions
3
+ class TestSkipped < MotoException
4
+
5
+ end
6
+ end
7
7
  end
data/lib/parser.rb CHANGED
@@ -100,9 +100,10 @@ module Moto
100
100
  moto --version Display current version
101
101
 
102
102
  moto run:
103
- -t, --tests = Tests to be executed.
104
- For eg. Tests\Failure\Failure.rb should be passed as Tests::Failure
105
- -l, --listeners = Reporters to be used.
103
+ -t, --tests Tests to be executed.
104
+ -g, --tags Tags of tests to be executed.
105
+ Use # MOTO_TAGS: TAGNAME in test to assign tag.
106
+ -l, --listeners Reporters to be used.
106
107
  Defaults are Moto::Listeners::ConsoleDots, Moto::Listeners::JunitXml
107
108
  -e, --environment Mandatory environment. Environment constants and tests parametrized in certain way depend on this.
108
109
  -c, --config Name of the config, without extension, to be loaded from MotoApp/config/CONFIG_NAME.rb
@@ -110,18 +111,18 @@ module Moto
110
111
 
111
112
 
112
113
  moto generate:
113
- -t, --test = Path and name of the test to be created.
114
+ -t, --test Path and name of the test to be created.
114
115
  Examples:
115
116
  -ttest_name will create MotoApp/tests/test_name/test_name.rb
116
117
  -tdir/test_name will create MotoApp/tests/dir/test_name/test_name.rb
117
- -a, --appname = Name of the application. Will be also used as topmost module in test file.
118
+ -a, --appname Name of the application. Will be also used as topmost module in test file.
118
119
  Default: MotoApp
119
- -b, --baseclass = File, without extension, with base class from which test will derive. Assumes one class per file.
120
+ -b, --baseclass File, without extension, with base class from which test will derive. Assumes one class per file.
120
121
  Examples:
121
122
  -btest_base will use the file in MotoApp/lib/test/test_base.rb
122
123
  -bsubdir/test_base will use the file in MotoApp/lib/test/subdir/test_base.rb
123
124
  By default class will derive from Moto::Test
124
- -f, --force = Forces generator to overwrite previously existing class file in specified location.
125
+ -f, --force Forces generator to overwrite previously existing class file in specified location.
125
126
  You have been warned.
126
127
  """
127
128
  end
@@ -33,40 +33,28 @@ module Moto
33
33
  def variantize(test_path_absolute)
34
34
  variants = []
35
35
 
36
- params_path = test_path_absolute.sub(/\.rb\z/, '')
37
-
38
- if File.exists?(params_path)
39
- begin
40
- params_all = eval(File.read(params_path))
41
- rescue Exception => e
42
- # Error will be injected into test.run after test is created
43
- params_error = e.message
44
- params_all = [{}]
45
- end
46
- else
47
- params_all = [{}]
48
- end
36
+ # TODO CHANGED TEMPORARY
37
+ #params_path = test_path_absolute.sub(/\.rb\z/, '')
38
+ params_directory = File.dirname(test_path_absolute).to_s + '/params/**'
39
+ param_files_paths = Dir.glob(params_directory)
40
+ param_files_paths = [nil] if param_files_paths.empty?
49
41
 
50
- params_all.each_with_index do |params, params_index|
42
+ #TODO Fix
43
+ param_files_paths.each_with_index do |params_path, params_index|
51
44
 
45
+ #TODO environment support
52
46
  # Filtering out param sets that are specific to certain envs
53
- unless params['__env'].nil?
54
- allowed_envs = params['__env'].is_a?(String) ? [params['__env']] : params['__env']
55
- next unless allowed_envs.include?(Moto::Lib::Config.environment)
56
- end
47
+ # unless params['__env'].nil?
48
+ # allowed_envs = params['__env'].is_a?(String) ? [params['__env']] : params['__env']
49
+ # next unless allowed_envs.include?(Moto::Lib::Config.environment)
50
+ # end
57
51
 
52
+ #TODO Name/logname/displayname
58
53
  test = generate(test_path_absolute)
59
- test.init(params, params_index, @internal_counter)
60
- test.log_path = "#{test.dir}/logs/#{test.name.gsub(/[^0-9A-Za-z.\-]/, '_')}.log"
54
+ test.init(params_path, params_index, @internal_counter)
55
+ test.log_path = "#{File.dirname(test_path_absolute).to_s}/logs/#{test.name.gsub(/[^0-9A-Za-z.\-]/, '_')}.log"
61
56
  @internal_counter += 1
62
57
 
63
- # Error handling, test.run() contents will be swapped with raised exception
64
- # so there is an indication in reporters/logs that something went wrong
65
- if params_error
66
- error_message = "ERROR: Invalid parameters file: #{test.dir}.\n\tMESSAGE: #{params_error}"
67
- inject_error_to_test(test, error_message)
68
- end
69
-
70
58
  variants << test
71
59
  end
72
60
 
@@ -157,21 +145,6 @@ module Moto
157
145
  end
158
146
  private :generate_for_run_body
159
147
 
160
- # Injects raise into test.run so it will report an error when executed
161
- # @param [Moto::Test::Base] test An instance of test that is supposed to be modified
162
- # @param [String] error_message Message to be attached to the raised exception
163
- def inject_error_to_test(test, error_message)
164
- class << test
165
- attr_accessor :injected_error_message
166
-
167
- def run
168
- raise injected_error_message
169
- end
170
- end
171
-
172
- test.injected_error_message = error_message
173
- end
174
-
175
148
  end
176
149
  end
177
150
  end
@@ -51,8 +51,8 @@ module Moto
51
51
  Thread.current['logger'].info("Result: #{@test.status.results.last.code}")
52
52
 
53
53
  # test should have another attempt in case of an error / failure / none at all
54
- if !(@test.status.results.last.code == Moto::Test::Result::ERROR && config[:test_reattempt_on_error]) &&
55
- !(@test.status.results.last.code == Moto::Test::Result::FAILURE && config[:test_reattempt_on_fail] )
54
+ unless (@test.status.results.last.code == Moto::Test::Result::ERROR && config[:test_reattempt_on_error]) ||
55
+ (@test.status.results.last.code == Moto::Test::Result::FAILURE && config[:test_reattempt_on_fail] )
56
56
  break
57
57
  end
58
58
 
data/lib/test/base.rb CHANGED
@@ -24,31 +24,18 @@ module Moto
24
24
  end
25
25
 
26
26
  # Initializes test to be executed with specified params and environment
27
- def init(params, params_index, global_index)
27
+ def init(params_path, params_index, global_index)
28
28
  @env = Moto::Lib::Config.environment
29
- @params = params
30
- @name = generate_name(params_index, global_index)
31
-
29
+ @params = []
30
+ @params_path = params_path
31
+ #TODO Display name
32
+ @name = self.class.to_s.demodulize
33
+ @name += "_#{@params_path.split("/")[-1].chomp('.param')}" if @params_path
32
34
  @status = Moto::Test::Status.new
33
35
  @status.name = @name
34
36
  @status.test_class_name = self.class.name
35
37
  @status.env = Moto::Lib::Config.environment
36
- @status.params = @params
37
- end
38
-
39
- # Generates name of the test based on its properties:
40
- # - number/name of currently executed configuration run
41
- # - env
42
- def generate_name(params_index, global_index)
43
- simple_class_name = self.class.to_s.demodulize
44
-
45
- return "#{simple_class_name}_#{@env}_##{global_index}" if @params.empty?
46
- return "#{simple_class_name}_#{@env}_#{@params[:__name]}_#{global_index}" if @params.key?(:__name)
47
- return "#{simple_class_name}_#{@env}_P#{params_index}_#{global_index}" unless @params.key?(:__name)
48
-
49
- self.class.to_s
50
38
  end
51
- private :generate_name
52
39
 
53
40
  # Setter for :log_path
54
41
  def log_path=(param)
@@ -64,21 +51,30 @@ module Moto
64
51
  @log_path
65
52
  end
66
53
 
67
- def dir
68
- return File.dirname(static_path) unless static_path.nil?
69
- File.dirname(self.path)
70
- end
71
-
72
- def filename
73
- return File.basename(static_path, '.*') unless static_path.nil?
74
- File.basename(path, '.*')
75
- end
54
+ #TODO Remove possibly?
55
+ # def dir
56
+ # return File.dirname(static_path) unless static_path.nil?
57
+ # File.dirname(self.path)
58
+ # end
59
+ #
60
+ # def filename
61
+ # return File.basename(static_path, '.*') unless static_path.nil?
62
+ # File.basename(path, '.*')
63
+ # end
76
64
 
77
65
  # Use this to run test
78
66
  # Initializes status, runs test, handles exceptions, finalizes status after run completion
79
67
  def run_test
80
68
  status.initialize_run
81
69
 
70
+ #TODO Formatting/optimization
71
+ begin
72
+ @params = eval(File.read(@params_path)) if File.exists?(@params_path.to_s)
73
+ @status.params = @params
74
+ rescue Exception => exception
75
+ raise "ERROR: Invalid parameters file: #{@params_path}.\n\tMESSAGE: #{exception.message}"
76
+ end
77
+
82
78
  begin
83
79
  run
84
80
  rescue Exception => exception
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Moto
2
- VERSION = '0.7.2'
2
+ VERSION = '0.7.3'
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: 0.7.2
4
+ version: 0.7.3
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: 2016-06-01 00:00:00.000000000 Z
14
+ date: 2016-07-18 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport