Class: Moto::Runner
- Inherits:
-
Object
- Object
- Moto::Runner
- Defined in:
- lib/runner.rb
Instance Attribute Summary collapse
-
#assert ⇒ Object
readonly
Returns the value of attribute assert.
-
#environments ⇒ Object
readonly
Returns the value of attribute environments.
-
#listeners ⇒ Object
readonly
Returns the value of attribute listeners.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
-
#initialize(tests, listeners, config = {}) ⇒ Runner
constructor
A new instance of Runner.
- #run ⇒ Object
Constructor Details
#initialize(tests, listeners, config = {}) ⇒ Runner
Returns a new instance of Runner.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/runner.rb', line 10 def initialize(tests, listeners, config = {}) @tests = tests @config = config @threads = [] # TODO: initialize logger from config (yml or just ruby code) # @logger = Logger.new(STDOUT) @logger = Logger.new(File.open("#{APP_DIR}/moto.log", File::WRONLY | File::APPEND | File::CREAT)) # @logger.level = Logger::WARN @result = Result.new(self) # TODO: validate envs, maybe no-env should be supported as well? @environments = config[:environments] @listeners = [] listeners.each do |l| @listeners << l.new(self) end @listeners.unshift(@result) end |
Instance Attribute Details
#assert ⇒ Object (readonly)
Returns the value of attribute assert.
8 9 10 |
# File 'lib/runner.rb', line 8 def assert @assert end |
#environments ⇒ Object (readonly)
Returns the value of attribute environments.
7 8 9 |
# File 'lib/runner.rb', line 7 def environments @environments end |
#listeners ⇒ Object (readonly)
Returns the value of attribute listeners.
5 6 7 |
# File 'lib/runner.rb', line 5 def listeners @listeners end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
6 7 8 |
# File 'lib/runner.rb', line 6 def logger @logger end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
4 5 6 |
# File 'lib/runner.rb', line 4 def result @result end |
Instance Method Details
#run ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/runner.rb', line 32 def run @listeners.each { |l| l.start_run } test_slices = @tests.each_slice((@tests.size.to_f/@config[:thread_cnt]).ceil).to_a (0...test_slices.count).each do |i| @threads << Thread.new do tc = ThreadContext.new(self, test_slices[i]) tc.run end end @threads.each{ |t| t.join } @listeners.each { |l| l.end_run } end |