moto 0.0.45 → 0.0.51
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 +3 -2
- data/lib/clients/base.rb +7 -0
- data/lib/clients/website.rb +22 -7
- data/lib/config.rb +53 -0
- 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/forward_context_methods.rb +0 -5
- data/lib/page.rb +7 -0
- data/lib/parser.rb +4 -14
- data/lib/reporting/listeners/base.rb +1 -4
- data/lib/reporting/listeners/junit_xml.rb +2 -1
- data/lib/reporting/listeners/webui.rb +3 -2
- data/lib/reporting/test_reporter.rb +9 -12
- data/lib/runner/test_provider.rb +2 -3
- data/lib/runner/test_runner.rb +4 -7
- data/lib/runner/thread_context.rb +13 -33
- data/lib/runner_logging.rb +26 -26
- data/lib/test/base.rb +7 -0
- data/lib/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a076c0650fb6ef90310fa2e9ef0f36665c02d7d1
|
4
|
+
data.tar.gz: f1582e2cb2ff664724a89636b26e3850ef03049e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a889e5ad07bbb420b3d05f4ad4b1edf357f29c189190f05735de1f0e6d779bbd669615c66cd6da7c57d668b58ff2bca68c3c7f63a2fb513b019283fa44c266b3
|
7
|
+
data.tar.gz: 77e51385da1ae1a87dbafcfdf9e63d81ad134e7790d4456d1f2abc09a312e5ae5fbaf590326586d8c630b2aeabdb108e688b52f3dd0c28010c400425a85dfa98
|
data/lib/cli.rb
CHANGED
@@ -32,6 +32,7 @@ require_relative './exceptions/moto'
|
|
32
32
|
require_relative './exceptions/test_skipped'
|
33
33
|
require_relative './exceptions/test_forced_failure'
|
34
34
|
require_relative './exceptions/test_forced_passed'
|
35
|
+
require_relative 'config'
|
35
36
|
|
36
37
|
module Moto
|
37
38
|
|
@@ -74,9 +75,9 @@ module Moto
|
|
74
75
|
initializer.init
|
75
76
|
end
|
76
77
|
|
77
|
-
test_reporter = Moto::Reporting::TestReporter.new(argv[:listeners], argv[:
|
78
|
+
test_reporter = Moto::Reporting::TestReporter.new(argv[:listeners], argv[:name])
|
78
79
|
|
79
|
-
runner = Moto::Runner::TestRunner.new(test_paths_absolute, argv[:environments],
|
80
|
+
runner = Moto::Runner::TestRunner.new(test_paths_absolute, argv[:environments], test_reporter)
|
80
81
|
runner.run
|
81
82
|
end
|
82
83
|
|
data/lib/clients/base.rb
CHANGED
@@ -24,6 +24,13 @@ module Moto
|
|
24
24
|
# abstract
|
25
25
|
end
|
26
26
|
|
27
|
+
# Retrieves specified key's value for current test environment
|
28
|
+
# @param [String] key Key which's value will be returned from merged config files
|
29
|
+
# @return [String] key's value
|
30
|
+
def const(key)
|
31
|
+
Moto::Lib::Config.environment_const(key)
|
32
|
+
end
|
33
|
+
|
27
34
|
end
|
28
35
|
end
|
29
36
|
end
|
data/lib/clients/website.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'capybara'
|
2
|
+
require_relative '../../lib/config'
|
2
3
|
|
3
4
|
module Moto
|
4
5
|
module Clients
|
@@ -13,15 +14,22 @@ module Moto
|
|
13
14
|
|
14
15
|
def init
|
15
16
|
register_grid_driver
|
17
|
+
register_chrome_driver
|
16
18
|
end
|
17
19
|
|
20
|
+
# @return [Hash] Config section for Capybara driver.
|
21
|
+
def config
|
22
|
+
Moto::Lib::Config.moto[:clients][:website][:capybara]
|
23
|
+
end
|
24
|
+
private :config
|
25
|
+
|
18
26
|
def start_run
|
19
27
|
# TODO: make session driver configurable
|
20
|
-
if
|
21
|
-
Capybara.default_selector =
|
28
|
+
if config[:default_selector]
|
29
|
+
Capybara.default_selector = config[:default_selector]
|
22
30
|
end
|
23
31
|
|
24
|
-
Thread.current['capybara_session'] = Capybara::Session.new(
|
32
|
+
Thread.current['capybara_session'] = Capybara::Session.new(config[:default_driver])
|
25
33
|
@pages = {}
|
26
34
|
end
|
27
35
|
|
@@ -30,7 +38,6 @@ module Moto
|
|
30
38
|
end
|
31
39
|
|
32
40
|
def start_test(test)
|
33
|
-
# @context.current_test.logger.info("Hi mom, I'm opening some pages!")
|
34
41
|
Thread.current['capybara_session'].reset_session!
|
35
42
|
end
|
36
43
|
|
@@ -50,10 +57,8 @@ module Moto
|
|
50
57
|
@pages[page_class_name]
|
51
58
|
end
|
52
59
|
|
53
|
-
private
|
54
|
-
|
55
60
|
def register_grid_driver
|
56
|
-
grid_config =
|
61
|
+
grid_config = config[:grid]
|
57
62
|
return if grid_config.nil?
|
58
63
|
if grid_config[:capabilities].nil?
|
59
64
|
capabilities = Selenium::WebDriver::Remote::Capabilities.firefox
|
@@ -67,6 +72,16 @@ module Moto
|
|
67
72
|
:desired_capabilities => capabilities)
|
68
73
|
end
|
69
74
|
end
|
75
|
+
private :register_grid_driver
|
76
|
+
|
77
|
+
def register_chrome_driver
|
78
|
+
Capybara.register_driver :chrome do |app|
|
79
|
+
client = Selenium::WebDriver::Remote::Http::Default.new
|
80
|
+
Capybara::Selenium::Driver.new(app, browser: :chrome, http_client: client)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
private :register_chrome_driver
|
84
|
+
|
70
85
|
|
71
86
|
def handle_test_exception(test, exception)
|
72
87
|
#Thread.current['capybara_session'].save_screenshot "#{test.dir}/#{test.filename}_#{Time.new.strftime('%Y%m%d_%H%M%S')}.png"
|
data/lib/config.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
module Moto
|
2
|
+
module Lib
|
3
|
+
class Config
|
4
|
+
|
5
|
+
def self.load_configuration
|
6
|
+
if File.exists? "#{MotoApp::DIR}/config/moto.rb"
|
7
|
+
@@moto = eval(File.read("#{MotoApp::DIR}/config/moto.rb"))
|
8
|
+
|
9
|
+
@@env_consts = {}
|
10
|
+
Dir.glob('config/*.yml').each do |f|
|
11
|
+
@@env_consts.deep_merge! YAML.load_file(f)
|
12
|
+
end
|
13
|
+
|
14
|
+
else
|
15
|
+
raise "Config file (config/moto.rb) not present.\nDoes current working directory contain Moto application?"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# @return [Hash] Hash representing data from MotoApp/config/moto.rb file
|
20
|
+
def self.moto
|
21
|
+
@@moto
|
22
|
+
end
|
23
|
+
|
24
|
+
#
|
25
|
+
# @param [String] key Name of the key which's value is to be retrieved
|
26
|
+
# @return [String] Value of the key
|
27
|
+
def self.environment_const(key)
|
28
|
+
key = key.to_s
|
29
|
+
env = Thread.current['test_environment']
|
30
|
+
|
31
|
+
if env != :__default
|
32
|
+
key = "#{env.to_s}.#{key}"
|
33
|
+
end
|
34
|
+
|
35
|
+
code = if key.include? '.'
|
36
|
+
"@@env_consts#{key.split('.').map { |a| "['#{a}']" }.join('')}"
|
37
|
+
else
|
38
|
+
"@@env_consts['#{key}']"
|
39
|
+
end
|
40
|
+
|
41
|
+
begin
|
42
|
+
value = eval code
|
43
|
+
raise if value.nil?
|
44
|
+
rescue
|
45
|
+
raise "There is no const defined for key: #{key}. Environment: #{ (env == :__default) ? '<none>' : env }"
|
46
|
+
end
|
47
|
+
|
48
|
+
value
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
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/page.rb
CHANGED
@@ -24,5 +24,12 @@ module Moto
|
|
24
24
|
raise "Invalid state: page #{self.class.name} is not loaded." unless loaded?
|
25
25
|
end
|
26
26
|
|
27
|
+
# Retrieves specified key's value for current test environment
|
28
|
+
# @param [String] key Key which's value will be returned from merged config files
|
29
|
+
# @return [String] key's value
|
30
|
+
def const(key)
|
31
|
+
Moto::Lib::Config.environment_const(key)
|
32
|
+
end
|
33
|
+
|
27
34
|
end
|
28
35
|
end
|
data/lib/parser.rb
CHANGED
@@ -3,7 +3,7 @@ require 'yaml'
|
|
3
3
|
|
4
4
|
require_relative '../lib/cli'
|
5
5
|
require_relative '../lib/app_generator'
|
6
|
-
|
6
|
+
require_relative '../lib/config'
|
7
7
|
module Moto
|
8
8
|
|
9
9
|
class Parser
|
@@ -29,12 +29,7 @@ module Moto
|
|
29
29
|
|
30
30
|
def self.run_parse(argv)
|
31
31
|
|
32
|
-
|
33
|
-
if !File.exists? "#{MotoApp::DIR}/config/moto.rb"
|
34
|
-
msg = "Config file (config/moto.rb) not present.\n"
|
35
|
-
msg << 'Does current working directory contain Moto application?'
|
36
|
-
raise msg
|
37
|
-
end
|
32
|
+
Moto::Lib::Config.load_configuration
|
38
33
|
|
39
34
|
require 'bundler/setup'
|
40
35
|
Bundler.require
|
@@ -43,29 +38,24 @@ module Moto
|
|
43
38
|
options = {}
|
44
39
|
options[:listeners] = []
|
45
40
|
# TODO Mandatory env var in app config
|
46
|
-
options[:config] = eval(File.read("#{MotoApp::DIR}/config/moto.rb"))
|
47
41
|
options[:environments] = []
|
48
42
|
options[:name] = ''
|
49
43
|
|
50
44
|
# Parse arguments
|
51
|
-
# TODO eval ?
|
52
|
-
# TODO const
|
53
|
-
# TODO listeners should be consts - not strings
|
54
45
|
OptionParser.new do |opts|
|
55
46
|
opts.on('-t', '--tests Tests', Array) { |v| options[:tests ] = v }
|
56
47
|
opts.on('-g', '--tags Tags', Array) { |v| options[:tags ] = v }
|
57
48
|
opts.on('-l', '--listeners Listeners', Array) { |v| options[:listeners] = v }
|
58
49
|
opts.on('-e', '--environments Environment', Array) { |v| options[:environments] = v }
|
59
|
-
opts.on('-c', '--const Const') { |v| options[:const] = v }
|
60
50
|
opts.on('-n', '--name Name') { |v| options[:name] = v }
|
61
|
-
opts.on('-f', '--config Config') { |v| options[:config].deep_merge!( eval( File.read(v) ) ) }
|
51
|
+
# opts.on('-f', '--config Config') { |v| options[:config].deep_merge!( eval( File.read(v) ) ) }
|
62
52
|
end.parse!
|
63
53
|
|
64
54
|
if options[:name].empty?
|
65
55
|
options[:name] = evaluate_name(options[:tags], options[:tests])
|
66
56
|
end
|
67
57
|
|
68
|
-
if
|
58
|
+
if Moto::Lib::Config.moto[:test_runner][:mandatory_environment] && options[:environments].empty?
|
69
59
|
puts 'Environment is mandatory for this project.'
|
70
60
|
exit 1
|
71
61
|
end
|
@@ -5,13 +5,10 @@ module Moto
|
|
5
5
|
# Base class for listeners that report results of testing 'outside' of the application.
|
6
6
|
class Base
|
7
7
|
|
8
|
-
attr_reader :config
|
9
8
|
attr_reader :custom_run_name
|
10
9
|
|
11
|
-
# @param [Hash] config
|
12
10
|
# @param [String] custom_run_name Optional run name to be passed to listeners
|
13
|
-
def initialize(
|
14
|
-
@config = config
|
11
|
+
def initialize(custom_run_name = '')
|
15
12
|
@custom_run_name = custom_run_name
|
16
13
|
end
|
17
14
|
|
@@ -7,8 +7,9 @@ module Moto
|
|
7
7
|
class Webui < Base
|
8
8
|
|
9
9
|
def start_run
|
10
|
-
|
11
|
-
@url =
|
10
|
+
|
11
|
+
@url = Moto::Lib::Config.moto[:test_reporter][:listeners][:webui][:url]
|
12
|
+
|
12
13
|
data = {
|
13
14
|
name: custom_run_name,
|
14
15
|
result: :running,
|
@@ -7,12 +7,11 @@ module Moto
|
|
7
7
|
class TestReporter
|
8
8
|
# @param [Array] listeners An array of strings, which represent qualified names of classes (listeners) that will be instantiated.
|
9
9
|
# empty array is passed then :default_listeners will be taken from config
|
10
|
-
# @param [Hash] config to be passed to listeners during creation
|
11
10
|
# @param [String] custom_run_name Optional, to be passed to listeners during creation
|
12
|
-
def initialize(listeners,
|
11
|
+
def initialize(listeners, custom_run_name)
|
13
12
|
|
14
13
|
if listeners.empty?
|
15
|
-
config[:
|
14
|
+
config[:default_listeners].each do |listener_class_name|
|
16
15
|
listeners << listener_class_name
|
17
16
|
end
|
18
17
|
else
|
@@ -22,7 +21,6 @@ module Moto
|
|
22
21
|
end
|
23
22
|
|
24
23
|
@listeners = []
|
25
|
-
@config = config
|
26
24
|
@custom_run_name = custom_run_name
|
27
25
|
listeners.each { |l| add_listener(l) }
|
28
26
|
end
|
@@ -31,14 +29,7 @@ module Moto
|
|
31
29
|
# All listeners on the list will have events reported to them.
|
32
30
|
# @param [Moto::Listener::Base] listener class to be added
|
33
31
|
def add_listener(listener)
|
34
|
-
@listeners << listener.new(
|
35
|
-
end
|
36
|
-
|
37
|
-
# @return [Hash] hash containing part of the config meant for a specific listener
|
38
|
-
# @param [Moto::Listener::Base] listener class for which config is to be retrieved
|
39
|
-
def listener_config(listener)
|
40
|
-
listener_symbol = listener.name.demodulize.underscore.to_sym
|
41
|
-
@config[:moto][:listeners][listener_symbol]
|
32
|
+
@listeners << listener.new(@custom_run_name)
|
42
33
|
end
|
43
34
|
|
44
35
|
# Reports start of the whole run (set of tests) to attached listeners
|
@@ -78,6 +69,12 @@ module Moto
|
|
78
69
|
end
|
79
70
|
end
|
80
71
|
|
72
|
+
# @return [Hash] Hash with config for TestReporter
|
73
|
+
def config
|
74
|
+
Moto::Lib::Config.moto[:test_reporter]
|
75
|
+
end
|
76
|
+
private :config
|
77
|
+
|
81
78
|
end
|
82
79
|
end
|
83
80
|
end
|
data/lib/runner/test_provider.rb
CHANGED
@@ -8,10 +8,9 @@ module Moto
|
|
8
8
|
|
9
9
|
# @param [Array] test_paths_absolute
|
10
10
|
# @param [Array] environments Array
|
11
|
-
|
12
|
-
def initialize(test_paths_absolute, environments, test_repeats)
|
11
|
+
def initialize(test_paths_absolute, environments)
|
13
12
|
super()
|
14
|
-
@test_repeats = test_repeats
|
13
|
+
@test_repeats = Moto::Lib::Config.moto[:test_runner][:test_repeats]
|
15
14
|
@current_test_repeat = 1
|
16
15
|
@queue = Queue.new
|
17
16
|
@test_paths_absolute = test_paths_absolute
|
data/lib/runner/test_runner.rb
CHANGED
@@ -6,23 +6,20 @@ module Moto
|
|
6
6
|
class TestRunner
|
7
7
|
|
8
8
|
attr_reader :logger
|
9
|
-
attr_reader :config
|
10
9
|
attr_reader :test_reporter
|
11
10
|
|
12
|
-
def initialize(test_paths_absolute, environments,
|
11
|
+
def initialize(test_paths_absolute, environments, test_reporter)
|
13
12
|
@test_paths_absolute = test_paths_absolute
|
14
|
-
@config = config
|
15
13
|
@test_reporter = test_reporter
|
16
14
|
|
17
15
|
# TODO: initialize logger from config (yml or just ruby code)
|
18
16
|
@logger = Logger.new(File.open("#{MotoApp::DIR}/moto.log", File::WRONLY | File::APPEND | File::CREAT))
|
19
|
-
|
20
17
|
@environments = environments.empty? ? environments << :__default : environments
|
21
18
|
end
|
22
19
|
|
23
20
|
def run
|
24
|
-
test_provider = TestProvider.new(@test_paths_absolute, @environments
|
25
|
-
threads_max =
|
21
|
+
test_provider = TestProvider.new(@test_paths_absolute, @environments)
|
22
|
+
threads_max = Moto::Lib::Config.moto[:test_runner][:thread_count] || 1
|
26
23
|
|
27
24
|
# remove log/screenshot files from previous execution
|
28
25
|
@test_paths_absolute.each do |test_path|
|
@@ -38,7 +35,7 @@ module Moto
|
|
38
35
|
Thread.new do
|
39
36
|
Thread.current[:id] = index
|
40
37
|
loop do
|
41
|
-
tc = ThreadContext.new(
|
38
|
+
tc = ThreadContext.new(test_provider.get_test, @test_reporter)
|
42
39
|
tc.run
|
43
40
|
end
|
44
41
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'erb'
|
2
2
|
require 'fileutils'
|
3
|
+
require_relative '../../lib/config'
|
3
4
|
|
4
5
|
module Moto
|
5
6
|
module Runner
|
@@ -8,11 +9,8 @@ module Moto
|
|
8
9
|
# all resources specific for single thread will be initialized here. E.g. browser session
|
9
10
|
attr_reader :logger
|
10
11
|
attr_reader :test
|
11
|
-
attr_reader :moto_app_config_yml
|
12
|
-
attr_reader :moto_app_config_rb
|
13
12
|
|
14
|
-
def initialize(
|
15
|
-
@config = config
|
13
|
+
def initialize(test, test_reporter)
|
16
14
|
@test = test
|
17
15
|
@clients = {}
|
18
16
|
@test.context = self
|
@@ -20,15 +18,7 @@ module Moto
|
|
20
18
|
|
21
19
|
# TODO: temporary fix
|
22
20
|
Thread.current['context'] = self
|
23
|
-
|
24
|
-
# TODO: temporary fix (Configs rework incoming)
|
25
|
-
@moto_app_config_yml = {}
|
26
|
-
Dir.glob('config/*.yml').each do |f|
|
27
|
-
@moto_app_config_yml.deep_merge! YAML.load_file(f)
|
28
|
-
end
|
29
|
-
|
30
|
-
# TODO: temporary fix (Configs rework incoming)
|
31
|
-
@moto_app_config_rb = eval(File.read("#{MotoApp::DIR}/config/moto.rb"))
|
21
|
+
Thread.current['test_environment'] = @test.env
|
32
22
|
end
|
33
23
|
|
34
24
|
def client(name)
|
@@ -69,26 +59,10 @@ module Moto
|
|
69
59
|
end
|
70
60
|
end
|
71
61
|
|
72
|
-
|
73
|
-
key = key.to_s
|
74
|
-
key = "#{@test.env.to_s}.#{key}" if @test.env != :__default
|
75
|
-
code = if key.include? '.'
|
76
|
-
"@moto_app_config_yml#{key.split('.').map { |a| "['#{a}']" }.join('')}"
|
77
|
-
else
|
78
|
-
"@moto_app_config_yml['#{key}']"
|
79
|
-
end
|
80
|
-
begin
|
81
|
-
v = eval code
|
82
|
-
raise if v.nil?
|
83
|
-
rescue
|
84
|
-
raise "There is no const defined for key: #{key}. Environment: #{ (@test.env == :__default) ? '<none>' : @test.env }"
|
85
|
-
end
|
86
|
-
v
|
87
|
-
end
|
88
|
-
|
62
|
+
#
|
89
63
|
def run
|
90
|
-
max_attempts =
|
91
|
-
sleep_time
|
64
|
+
max_attempts = config[:test_attempt_max] || 1
|
65
|
+
sleep_time = config[:test_attempt_sleep] || 0
|
92
66
|
|
93
67
|
log_directory = File.dirname(@test.log_path)
|
94
68
|
if !File.directory?(log_directory)
|
@@ -96,7 +70,7 @@ module Moto
|
|
96
70
|
end
|
97
71
|
|
98
72
|
@logger = Logger.new(File.open(@test.log_path, File::WRONLY | File::TRUNC | File::CREAT))
|
99
|
-
@logger.level =
|
73
|
+
@logger.level = config[:test_log_level] || Logger::DEBUG
|
100
74
|
|
101
75
|
# Reporting: start_test
|
102
76
|
@test_reporter.report_start_test(@test.status)
|
@@ -145,6 +119,12 @@ module Moto
|
|
145
119
|
|
146
120
|
end
|
147
121
|
|
122
|
+
# @return [Hash] Hash with config for ThreadContext
|
123
|
+
def config
|
124
|
+
Moto::Lib::Config.moto[:test_runner]
|
125
|
+
end
|
126
|
+
private :config
|
127
|
+
|
148
128
|
end
|
149
129
|
end
|
150
130
|
end
|
data/lib/runner_logging.rb
CHANGED
@@ -1,27 +1,27 @@
|
|
1
|
-
module Moto
|
2
|
-
module RunnerLogging
|
3
|
-
|
4
|
-
|
5
|
-
# TODO: merge it somehow with TestLogging. Parametrize logger object?
|
6
|
-
def self.included(cls)
|
7
|
-
def cls.method_added(name)
|
8
|
-
excluded_methods = Moto::EmptyListener.instance_methods(false)
|
9
|
-
excluded_methods << :new
|
10
|
-
excluded_methods << :initialize
|
11
|
-
# TODO: configure more excluded classes/methods
|
12
|
-
return if @added
|
13
|
-
@added = true # protect from recursion
|
14
|
-
original_method = "original_#{name}"
|
15
|
-
alias_method original_method, name
|
16
|
-
define_method(name) do |*args|
|
17
|
-
@context.runner.logger.debug("#{self.class.name}::#{__callee__} ENTER >>> #{args}") unless excluded_methods.include? name
|
18
|
-
result = send original_method, *args
|
19
|
-
@context.runner.logger.debug("#{self.class.name}::#{__callee__} LEAVE <<< #{result} ") unless excluded_methods.include? name
|
20
|
-
result
|
21
|
-
end
|
22
|
-
@added = false
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
1
|
+
module Moto
|
2
|
+
module RunnerLogging
|
3
|
+
|
4
|
+
|
5
|
+
# TODO: merge it somehow with TestLogging. Parametrize logger object?
|
6
|
+
def self.included(cls)
|
7
|
+
def cls.method_added(name)
|
8
|
+
excluded_methods = Moto::EmptyListener.instance_methods(false)
|
9
|
+
excluded_methods << :new
|
10
|
+
excluded_methods << :initialize
|
11
|
+
# TODO: configure more excluded classes/methods
|
12
|
+
return if @added
|
13
|
+
@added = true # protect from recursion
|
14
|
+
original_method = "original_#{name}"
|
15
|
+
alias_method original_method, name
|
16
|
+
define_method(name) do |*args|
|
17
|
+
@context.runner.logger.debug("#{self.class.name}::#{__callee__} ENTER >>> #{args}") unless excluded_methods.include? name
|
18
|
+
result = send original_method, *args
|
19
|
+
@context.runner.logger.debug("#{self.class.name}::#{__callee__} LEAVE <<< #{result} ") unless excluded_methods.include? name
|
20
|
+
result
|
21
|
+
end
|
22
|
+
@added = false
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
27
|
end
|
data/lib/test/base.rb
CHANGED
@@ -166,6 +166,13 @@ module Moto
|
|
166
166
|
end
|
167
167
|
end
|
168
168
|
|
169
|
+
# Read a constants value from YML configuration files while taking the current execution environment into the account.
|
170
|
+
# @param [String] key Key to be searched for.
|
171
|
+
# @return [String] Value of the key or nil if not found
|
172
|
+
def const(key)
|
173
|
+
Moto::Lib::Config.environment_const(key)
|
174
|
+
end
|
175
|
+
|
169
176
|
end
|
170
177
|
end
|
171
178
|
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.0.
|
4
|
+
version: 0.0.51
|
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-04-
|
14
|
+
date: 2016-04-29 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|
@@ -88,6 +88,7 @@ files:
|
|
88
88
|
- lib/cli.rb
|
89
89
|
- lib/clients/base.rb
|
90
90
|
- lib/clients/website.rb
|
91
|
+
- lib/config.rb
|
91
92
|
- lib/empty_listener.rb
|
92
93
|
- lib/exceptions/moto.rb
|
93
94
|
- lib/exceptions/test_forced_failure.rb
|