Class: TF::ErrorSummaryOutput
- Inherits:
-
Object
- Object
- TF::ErrorSummaryOutput
- Defined in:
- lib/plugins/tf/error_summary_output.rb
Constant Summary collapse
- RED =
`tput setaf 1`
- GREEN =
`tput setaf 2`
- YELLOW =
`tput setaf 3`
- BLUE =
`tput setaf 4`
- RESET =
`tput setaf 9`
Class Method Summary collapse
Instance Method Summary collapse
- #command_err(err) ⇒ Object
- #command_out(out) ⇒ Object
- #end_command(line, status, env) ⇒ Object
- #end_processing ⇒ Object
- #end_test(test) ⇒ Object
-
#initialize(output = nil) ⇒ ErrorSummaryOutput
constructor
A new instance of ErrorSummaryOutput.
- #start_command(line) ⇒ Object
- #start_processing ⇒ Object
- #start_test(test, env) ⇒ Object
- #status ⇒ Object
- #summary ⇒ Object
- #test_processed(test, status, msg) ⇒ Object
Constructor Details
#initialize(output = nil) ⇒ ErrorSummaryOutput
Returns a new instance of ErrorSummaryOutput.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/plugins/tf/error_summary_output.rb', line 12 def initialize output=nil @counts={} @counts[:commands] = 0 @counts[:tests] = 0 @counts[:commands_started] = 0 @counts[:commands_finished] = 0 @counts[:tests_success] = 0 @counts[:tests_failure] = 0 @counter_id = 0 @summary = {} @output = output || $stdout end |
Class Method Details
.argument_matches?(argument) ⇒ Boolean
8 9 10 |
# File 'lib/plugins/tf/error_summary_output.rb', line 8 def self.argument_matches? argument [:load] if argument == "--dotted" end |
Instance Method Details
#command_err(err) ⇒ Object
80 81 |
# File 'lib/plugins/tf/error_summary_output.rb', line 80 def command_err err end |
#command_out(out) ⇒ Object
77 78 |
# File 'lib/plugins/tf/error_summary_output.rb', line 77 def command_out out end |
#end_command(line, status, env) ⇒ Object
73 74 75 |
# File 'lib/plugins/tf/error_summary_output.rb', line 73 def end_command line, status, env @counts[:commands_finished] += 1 end |
#end_processing ⇒ Object
53 54 55 56 57 |
# File 'lib/plugins/tf/error_summary_output.rb', line 53 def end_processing @output.printf "\n" @output.puts status @output.puts summary end |
#end_test(test) ⇒ Object
65 66 |
# File 'lib/plugins/tf/error_summary_output.rb', line 65 def end_test test end |
#start_command(line) ⇒ Object
68 69 70 71 |
# File 'lib/plugins/tf/error_summary_output.rb', line 68 def start_command line @counts[:commands_started] += 1 @current_line = line.merge(:counter_id => @counts[:commands_started]) end |
#start_processing ⇒ Object
25 26 |
# File 'lib/plugins/tf/error_summary_output.rb', line 25 def start_processing end |
#start_test(test, env) ⇒ Object
59 60 61 62 63 |
# File 'lib/plugins/tf/error_summary_output.rb', line 59 def start_test test, env @counts[:commands] += test[:commands].size tests_counts = test[:commands].map{|line| line[:tests].nil? ? 0 : line[:tests].size } @counts[:tests] += tests_counts.empty? ? 0 : tests_counts.inject(&:+) end |
#status ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/plugins/tf/error_summary_output.rb', line 28 def status text = "#{BLUE}##### Processed commands #{@counts[:commands_finished]} of #{@counts[:commands]}" if @counts[:tests_success] > 0 text += ", #{GREEN}success tests #{@counts[:tests_success]} of #{@counts[:tests]}" end if @counts[:tests_failure] > 0 text += ", #{RED}failure tests #{@counts[:tests_failure]} of #{@counts[:tests]}" end skipped = @counts[:tests] - @counts[:tests_success] - @counts[:tests_failure] if skipped > 0 text += ", #{YELLOW}skipped tests #{skipped} of #{@counts[:tests]}" end text += ".#{RESET}" text end |
#summary ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/plugins/tf/error_summary_output.rb', line 44 def summary @summary.sort{|a,b| ak,_=a ; bk,_=b ; ak <=> bk }.each{|k,v| @output.puts "#{YELLOW}$ #{v[:cmd]}#{RESET}" v[:failed_tests].each{|t| puts "#{RED}# #{t}#{RESET}" } } text = "" text end |
#test_processed(test, status, msg) ⇒ Object
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/plugins/tf/error_summary_output.rb', line 83 def test_processed test, status, msg @output.printf status ? "." : "F" if status @counts[:tests_success] += 1 else @counts[:tests_failure] += 1 @summary[@current_line[:counter_id]] ||= @current_line.merge({:failed_tests=>[]}) @summary[@current_line[:counter_id]][:failed_tests] << msg end end |