Skip to content

Commit

Permalink
add debug logging for formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
e2 committed Jun 23, 2015
1 parent 1e71c21 commit d9b8e3e
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/guard/rspec_formatter.rb
Expand Up @@ -3,6 +3,7 @@

require "pathname"
require "fileutils"
require "logger"

require "rspec"
require "rspec/core/formatters/base_formatter"
Expand All @@ -20,6 +21,9 @@ def self.rspec_3?

def example_failed(failure)
examples.push failure.example
rescue => ex
logger.debug("#{__method__}: ERROR: #{ex}: #{ex.backtrace * "\n" }")
fail
end

def examples
Expand Down Expand Up @@ -60,6 +64,7 @@ def self.spec_path?(path)
end

def dump_summary(*args)
logger.debug("#{__method__} writing summary")
return write_summary(*args) unless self.class.rspec_3?

notification = args[0]
Expand All @@ -69,16 +74,34 @@ def dump_summary(*args)
notification.failure_count,
notification.pending_count
)
rescue => ex
logger.debug("#{__method__}: ERROR: #{ex}: #{ex.backtrace * "\n" }")
fail
end

private

# Write summary to temporary file for runner
def write_summary(duration, total, failures, pending)
logger.debug("#{__method__}: #{total} examples ")
_write do |f|
f.puts _message(total, failures, pending, duration)
f.puts _failed_paths.join("\n") if failures > 0
end
rescue => ex
logger.debug("#{__method__}: ERROR: #{ex}: #{ex.backtrace * "\n" }")
fail
end

def logger
@logger ||=
begin
f = File.open("guard_rspec_debug.log", "a")
f.sync = true
::Logger.new(f).tap do |logger|
logger.level = Logger::DEBUG
end
end
end

def _write(&block)
Expand Down

0 comments on commit d9b8e3e

Please sign in to comment.