Sha256: 0dc328a34ae9e49dbde2e8f84b798930c10d99f0d7b42afacdcf61c6189659a9

Contents?: true

Size: 1.31 KB

Versions: 4

Compression:

Stored size: 1.31 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 = Class.new(klass, &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.01 }
      return yield
    ensure
      @instance.shutdown
    end
  end
end


end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fluentd-0.10.3 lib/fluent/test/base.rb
fluentd-0.10.2 lib/fluent/test/base.rb
fluentd-0.10.1 lib/fluent/test/base.rb
fluentd-0.10.0 lib/fluent/test/base.rb