moto 0.8.4 → 0.8.5
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/cli.rb +46 -11
- data/lib/parser.rb +32 -20
- data/lib/runner/test_runner.rb +1 -1
- 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: 3e65386856ade15e4eae651e3cab0c53ecfffe6e
|
4
|
+
data.tar.gz: 7f2b839cc1e8cee8f4c4115a6904133379eff395
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5b8bfc2a6ec600a3c71bc93c0f4415072d239e92c0553a449fc524add7e8662dda586d87546b43700114c7830a683b12d5c2e51e6249de36b1618e96a839d7f
|
7
|
+
data.tar.gz: ce2dd0e518627bbd7ce5714f36c29c1f7cec99a73f8d1699e6cf226ae645dd88828a7dfb36faab8ef5696c8197c6a3b571d624b1589af61519ce18bb044e0110
|
data/lib/cli.rb
CHANGED
@@ -34,34 +34,69 @@ module Moto
|
|
34
34
|
|
35
35
|
class Cli
|
36
36
|
def self.run(argv)
|
37
|
+
|
37
38
|
test_paths_absolute = []
|
39
|
+
directories = argv[:tests]
|
40
|
+
tags = argv[:tags]
|
41
|
+
filters = argv[:filters]
|
38
42
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
test_paths = Dir.glob("#{MotoApp::DIR}/tests/#{dir_name}/**/*.rb")
|
43
|
-
test_paths -= test_paths_absolute
|
44
|
-
test_paths_absolute += test_paths
|
43
|
+
if directories
|
44
|
+
directories.each do |directory|
|
45
|
+
test_paths_absolute += Dir.glob("#{MotoApp::DIR}/tests/#{directory}/**/*.rb")
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
48
|
-
|
49
|
-
unless argv[:tags].nil?
|
49
|
+
if tags
|
50
50
|
tests_total = Dir.glob("#{MotoApp::DIR}/tests/**/*.rb")
|
51
51
|
tests_total.each do |test_path|
|
52
|
+
|
52
53
|
test_body = File.read(test_path)
|
53
|
-
matches = test_body.match(/^#(\s*)MOTO_TAGS:(
|
54
|
+
matches = test_body.match(/^#(\s*)MOTO_TAGS:(.*?)$/)
|
55
|
+
|
54
56
|
if matches
|
55
57
|
test_tags = matches.to_a[2].gsub(/\s*/, '').split(',')
|
56
|
-
test_paths_absolute << test_path unless (
|
58
|
+
test_paths_absolute << test_path unless (tags & test_tags).empty?
|
57
59
|
end
|
60
|
+
|
58
61
|
end
|
59
62
|
end
|
60
63
|
|
64
|
+
# Make sure there are no repetitions in gathered set
|
65
|
+
test_paths_absolute.uniq!
|
66
|
+
|
67
|
+
# Tests to be removed due to filtering will be gathered in this array
|
68
|
+
# [].delete(item) cannot be used since it interferes with [].each
|
69
|
+
filtered_test_paths = []
|
70
|
+
|
71
|
+
# Filter tests by provied tags
|
72
|
+
if filters
|
73
|
+
test_paths_absolute.each do |test_path|
|
74
|
+
test_body = File.read(test_path)
|
75
|
+
|
76
|
+
matches = test_body.match(/^#(\s*)MOTO_TAGS:(.*?)$/)
|
77
|
+
|
78
|
+
if matches
|
79
|
+
|
80
|
+
test_tags = matches.to_a[2].gsub(/\s*/, '').split(',')
|
81
|
+
if (filters & test_tags).empty?
|
82
|
+
# Test doesn't contain any tags to be filtered upon
|
83
|
+
filtered_test_paths << test_path
|
84
|
+
end
|
85
|
+
|
86
|
+
else
|
87
|
+
# Test has no tags at all
|
88
|
+
filtered_test_paths << test_path
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
test_paths_absolute -= filtered_test_paths
|
95
|
+
|
61
96
|
#TODO Display criteria used
|
62
97
|
if test_paths_absolute.empty?
|
63
98
|
puts 'No tests found for given arguments.'
|
64
|
-
Kernel.exit
|
99
|
+
Kernel.exit(-1)
|
65
100
|
end
|
66
101
|
|
67
102
|
# Requires custom initializer if provided by application that uses Moto
|
data/lib/parser.rb
CHANGED
@@ -20,7 +20,8 @@ module Moto
|
|
20
20
|
else
|
21
21
|
show_help
|
22
22
|
end
|
23
|
-
|
23
|
+
rescue SystemExit
|
24
|
+
nil
|
24
25
|
rescue Exception => e
|
25
26
|
puts e.message + "\n\n"
|
26
27
|
puts e.backtrace.join("\n")
|
@@ -38,16 +39,17 @@ module Moto
|
|
38
39
|
|
39
40
|
# Parse arguments
|
40
41
|
OptionParser.new do |opts|
|
41
|
-
opts.on('-t', '--tests Tests', Array) { |v| options[:tests
|
42
|
-
opts.on('-g', '--tags Tags', Array) { |v| options[:tags
|
43
|
-
opts.on('-
|
44
|
-
opts.on('-
|
45
|
-
opts.on('-
|
46
|
-
opts.on('-
|
42
|
+
opts.on('-t', '--tests Tests', Array) { |v| options[:tests] = v }
|
43
|
+
opts.on('-g', '--tags Tags', Array) { |v| options[:tags] = v }
|
44
|
+
opts.on('-f', '--filters Filters', Array) { |v| options[:filters] = v }
|
45
|
+
opts.on('-l', '--listeners Listeners', Array) { |v| options[:listeners] = v }
|
46
|
+
opts.on('-e', '--environment Environment') { |v| options[:environment] = v }
|
47
|
+
opts.on('-n', '--name Name') { |v| options[:name] = v }
|
48
|
+
opts.on('-c', '--config Config') { |v| options[:config_name] = v }
|
47
49
|
end.parse!
|
48
50
|
|
49
51
|
if options[:name].empty?
|
50
|
-
options[:name] = evaluate_name(options[:tags], options[:tests])
|
52
|
+
options[:name] = evaluate_name(options[:tags], options[:tests], options[:filters])
|
51
53
|
end
|
52
54
|
|
53
55
|
if options[:environment]
|
@@ -55,23 +57,29 @@ module Moto
|
|
55
57
|
Moto::Lib::Config.load_configuration(options[:config_name] ? options[:config_name] : 'moto')
|
56
58
|
else
|
57
59
|
puts 'ERROR: Environment is mandatory.'
|
58
|
-
exit
|
60
|
+
Kernel.exit(-1)
|
59
61
|
end
|
60
62
|
|
61
|
-
|
62
63
|
return options
|
63
64
|
end
|
64
65
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
66
|
+
# Generate default name based on input parameters
|
67
|
+
def self.evaluate_name(tests, tags, filters)
|
68
|
+
name = ''
|
69
|
+
|
70
|
+
if tests
|
71
|
+
name << "Tests: #{tests.join(',')} "
|
72
|
+
end
|
73
|
+
|
74
|
+
if tags
|
75
|
+
name << "Tags: #{tags.join(',')} "
|
74
76
|
end
|
77
|
+
|
78
|
+
if filters
|
79
|
+
name << "Filters: #{filters.join(',')} "
|
80
|
+
end
|
81
|
+
|
82
|
+
return name
|
75
83
|
end
|
76
84
|
|
77
85
|
# Parses attributes passed to the application when run by 'moto generate'
|
@@ -103,8 +111,12 @@ module Moto
|
|
103
111
|
-t, --tests Tests to be executed.
|
104
112
|
-g, --tags Tags of tests to be executed.
|
105
113
|
Use # MOTO_TAGS: TAGNAME in test to assign tag.
|
114
|
+
-f, --filters Tags that filter tests passed via -t parameter.
|
115
|
+
Only tests in appropriate directory, having appropriate tag will be executed.
|
116
|
+
Use # MOTO_TAGS: TAGNAME in test to assign tag.
|
106
117
|
-l, --listeners Reporters to be used.
|
107
|
-
Defaults are Moto::Listeners::ConsoleDots, Moto::Listeners::JunitXml
|
118
|
+
Defaults are Moto::Reporting::Listeners::ConsoleDots, Moto::Reporting::Listeners::JunitXml
|
119
|
+
One reporter that is always used: Moto::Reporting::Listeners::KernelCode
|
108
120
|
-e, --environment Mandatory environment. Environment constants and tests parametrized in certain way depend on this.
|
109
121
|
-c, --config Name of the config, without extension, to be loaded from MotoApp/config/CONFIG_NAME.rb
|
110
122
|
Default: moto (which loads: MotoApp/config/moto.rb)
|
data/lib/runner/test_runner.rb
CHANGED
@@ -52,7 +52,7 @@ module Moto
|
|
52
52
|
@test_reporter.report_end_run
|
53
53
|
|
54
54
|
# Exit application with appropriate code generated by KernelCode listener
|
55
|
-
Kernel.exit
|
55
|
+
Kernel.exit(Moto::Reporting::Listeners::KernelCode.code)
|
56
56
|
end
|
57
57
|
|
58
58
|
end
|
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.8.
|
4
|
+
version: 0.8.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: 2016-09-
|
14
|
+
date: 2016-09-09 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|