You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: output_test.rb
    path of file: ./repos/fluentd/lib/fluent/test
    
    the code of the file until where you have to start completion: #
# Fluentd
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    y
    
      def run(&block)
        result = []
        super {
          block.call if block

          buffer = ''
          lines = {}
          # v0.12 TimeSlicedOutput doesn't call #format_stream
          @entries.each do |time, record|
            meta = @instance.metadata(@tag, time, record)
            line = @instance.format(@tag, time, record)
            buffer << line
            lines[meta] ||= []
            lines[meta] << line
          end

          if @expected_buffer
            assert_equal(@expected_buffer, buffer)
          end

          lines.each_key do |meta|
            chunk = @instance.buffer.generate_chunk(meta).staged!
            chunk.append(lines[meta])
            begin
              result.push(@instance.write(chunk))
            ensure
              chunk.purge
            end
          end