Sha256: dbd25ebf1bce6f3aec0eed557a53a2993902320455e252476528633ee9d4aa55

Contents?: true

Size: 1.33 KB

Versions: 6

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.01 }
      return yield
    ensure
      @instance.shutdown
    end
  end
end


end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
fluentd-0.10.9 lib/fluent/test/base.rb
fluentd-0.10.8 lib/fluent/test/base.rb
fluentd-0.10.7 lib/fluent/test/base.rb
fluentd-0.10.6 lib/fluent/test/base.rb
fluentd-0.10.5 lib/fluent/test/base.rb
fluentd-0.10.4 lib/fluent/test/base.rb