Class: OCRunner::OutputProcessor

Inherits:
ParseMachine show all
Includes:
Console
Defined in:
lib/ocrunner/output_processor.rb

Instance Attribute Summary

Attributes included from Console

#output

Instance Method Summary collapse

Methods included from Console

#blue, #clean_path, #colorize, #execute, #green, #growl, #indent, #out, #present, #red

Methods inherited from ParseMachine

#default_state, default_state, event, #event, #initialize_state, match, #process_input, state

Constructor Details

#initialize(out, options) ⇒ OutputProcessor

Returns a new instance of OutputProcessor.



6
7
8
9
10
11
12
13
14
# File 'lib/ocrunner/output_processor.rb', line 6

def initialize(out, options)
  initialize_state
  @passed = true
  @suites = []
  @log = ''
  @out = out
  @options = options
  @compilation_error_occurred = false
end

Instance Method Details

#build_error(message) ⇒ Object



22
23
24
25
# File 'lib/ocrunner/output_processor.rb', line 22

def build_error(message)
  out red(message)
  @passed = false
end

#build_failedObject



27
28
29
30
# File 'lib/ocrunner/output_processor.rb', line 27

def build_failed
  growl('BUILD FAILED!')
  out red('*** BUILD FAILED ***')
end

#build_succeededObject



32
33
34
35
# File 'lib/ocrunner/output_processor.rb', line 32

def build_succeeded
  growl('Build succeeded.')
  out green('*** BUILD SUCCEEDED ***')
end

#compilation_error_occurred!Object



74
75
76
# File 'lib/ocrunner/output_processor.rb', line 74

def compilation_error_occurred!
  @compilation_error_occurred = true
end

#display_resultsObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/ocrunner/output_processor.rb', line 37

def display_results
  @suites.each do |suite|
    suite.failed_cases.each do |kase|
      out indent red("[#{suite.name} #{kase.name}] FAILED")
      kase.errors.each do |error|
        out indent 2, "on line #{error.line} of #{clean_path(error.path)}:"
        error.message.each_line do |line|
          out indent 2, red(line.strip)
        end
      end
    end
    out if suite.failures?
  end
  
  @suites.each do |suite|
    number = suite.failed_cases.size
    out "Suite '#{suite.name}': #{suite.cases.size - number} passes and #{number} failures in #{suite.time} seconds."
  end
  
  out
  
  if @passed
    build_succeeded
  else
    build_failed
  end
  
  puts @log if @options[:verbose] || (@compilation_error_occurred && @options[:loud_compilation])
  puts red "A compilation error occurred" if @compilation_error_occurred
  puts @output.join("\n")
  puts
end

#process_console_output(line) ⇒ Object



70
71
72
# File 'lib/ocrunner/output_processor.rb', line 70

def process_console_output(line)
  process_input(line)
end

#process_line(line) ⇒ Object



16
17
18
19
20
# File 'lib/ocrunner/output_processor.rb', line 16

def process_line(line)
  @log << line unless line =~ /setenv/
  process_console_output(line)
  @out.flush
end