Sha256: 55b102510b8c901d2312632d2c9a6b480d08068d827677390052f85283caf474

Contents?: true

Size: 1.33 KB

Versions: 15

Compression:

Stored size: 1.33 KB

Contents

#
# Fluent
#
# Copyright (C) 2011 FURUHASHI Sadayuki
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
#
module Fluent
module Test


class TestDriver
  include ::Test::Unit::Assertions

  def initialize(klass, &block)
    if klass.is_a?(Class)
      if block
        klass = klass.dup
        klass.module_eval(&block)
      end
      @instance = klass.new
    else
      @instance = klass
    end
    @config = Config.new
  end

  attr_reader :instance, :config

  def configure(str)
    if str.is_a?(Config)
      @config = @str
    else
      @config = Config.parse(str, "(test)")
    end
    @instance.configure(@config)
    self
  end

  def run(&block)
    @instance.start
    begin
      # wait until thread starts
      10.times { sleep 0.05 }
      return yield
    ensure
      @instance.shutdown
    end
  end
end


end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
fluentd-0.10.25 lib/fluent/test/base.rb
fluentd-0.10.24 lib/fluent/test/base.rb
fluentd-0.10.23 lib/fluent/test/base.rb
fluentd-0.10.22 lib/fluent/test/base.rb
fluentd-0.10.21 lib/fluent/test/base.rb
fluentd-0.10.20 lib/fluent/test/base.rb
fluentd-0.10.19 lib/fluent/test/base.rb
fluentd-0.10.18 lib/fluent/test/base.rb
fluentd-0.10.17 lib/fluent/test/base.rb
fluentd-0.10.16 lib/fluent/test/base.rb
fluentd-0.10.15 lib/fluent/test/base.rb
fluentd-0.10.13 lib/fluent/test/base.rb
fluentd-0.10.12 lib/fluent/test/base.rb
fluentd-0.10.11 lib/fluent/test/base.rb
fluentd-0.10.10 lib/fluent/test/base.rb