Sha256: fb635067e3fb35b70b3dc02cbb5f9ec7f1452d0794ccba59073d2692d72ed3b4

Contents?: true

Size: 1.63 KB

Versions: 9

Compression:

Stored size: 1.63 KB

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

# This module is responsible for intercepting output made through various stdlib
# calls (i.e. puts, print, etc.) and printing summary information (e.g. a list
# of failing tests) at the end of the process.

require 'thread'

module Multiverse
  module OutputCollector
    include Color
    extend Color

    @output_lock = Mutex.new
    @buffer_lock = Mutex.new

    def self.failing_output
      @failing ||= []
    end

    def self.buffer(suite, env)
      key = [suite, env]
      @buffer_lock.synchronize do
        @buffers ||= {}
        @buffers[key] ||= ""
        @buffers[key]
      end
    end

    def self.failed(suite, env)
      @failing ||= []
      @failing << buffer(suite, env) + "\n"
    end

    def self.write(suite, env, msg)
      buffer(suite, env) << msg
    end

    def self.suite_report(suite, env)
      output(buffer(suite, env))
    end

    def self.overall_report
      output("", "")
      if failing_output.empty?
        output(green("There were no test failures"))
      else
        output(
          red("*" * 80),
          red("There were failures in #{failing_output.size} test suites"),
          red("Here is their output"),
          red("*" * 80),
          *failing_output)
      end
    end

    # Because the various environments potentially run in separate threads to
    # start their processes, make sure we don't blatantly interleave output.
    def self.output(*args)
      @output_lock.synchronize do
        puts(*args)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
newrelic_rpm-3.10.0.279 test/multiverse/lib/multiverse/output_collector.rb
newrelic_rpm-3.9.9.275 test/multiverse/lib/multiverse/output_collector.rb
newrelic_rpm-3.9.8.273 test/multiverse/lib/multiverse/output_collector.rb
newrelic_rpm-3.9.7.266 test/multiverse/lib/multiverse/output_collector.rb
newrelic_rpm-3.9.6.257 test/multiverse/lib/multiverse/output_collector.rb
newrelic_rpm-3.9.5.251 test/multiverse/lib/multiverse/output_collector.rb
newrelic_rpm-3.9.4.245 test/multiverse/lib/multiverse/output_collector.rb
newrelic_rpm-3.9.3.241 test/multiverse/lib/multiverse/output_collector.rb
newrelic_rpm-3.9.2.239 test/multiverse/lib/multiverse/output_collector.rb