moto 0.7.2 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cli.rb +2 -1
- data/lib/empty_listener.rb +16 -16
- data/lib/exceptions/moto.rb +6 -6
- data/lib/exceptions/test_forced_failure.rb +6 -6
- data/lib/exceptions/test_forced_passed.rb +6 -6
- data/lib/exceptions/test_skipped.rb +6 -6
- data/lib/parser.rb +8 -7
- data/lib/runner/test_generator.rb +15 -42
- data/lib/runner/thread_context.rb +2 -2
- data/lib/test/base.rb +24 -28
- 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: b7dfa94193904de4da842adb7573c6cf154561fc
|
4
|
+
data.tar.gz: 38d2d4a3ae5d5c540fe8fbdbd7c0d5cba4ffd846
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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|
|
data/lib/empty_listener.rb
CHANGED
@@ -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
|
data/lib/exceptions/moto.rb
CHANGED
@@ -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
|
104
|
-
|
105
|
-
|
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
|
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
|
118
|
+
-a, --appname Name of the application. Will be also used as topmost module in test file.
|
118
119
|
Default: MotoApp
|
119
|
-
-b, --baseclass
|
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
|
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
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
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
|
-
|
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
|
-
|
55
|
-
|
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(
|
60
|
-
test.log_path = "#{
|
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
|
-
|
55
|
-
|
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(
|
27
|
+
def init(params_path, params_index, global_index)
|
28
28
|
@env = Moto::Lib::Config.environment
|
29
|
-
@params =
|
30
|
-
@
|
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
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
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
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.
|
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-
|
14
|
+
date: 2016-07-18 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|