tapout 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/.ruby +12 -3
  2. data/.yardopts +6 -5
  3. data/HISTORY.rdoc +16 -0
  4. data/README.rdoc +18 -16
  5. data/TAP-YJ.md +15 -15
  6. data/bin/tapout +1 -1
  7. data/demo/applique/ae.rb +1 -0
  8. data/{spec → demo}/applique/env.rb +0 -0
  9. data/{spec → demo}/issues/applique/env.rb +0 -0
  10. data/{spec → demo}/issues/default_reporter.rdoc +2 -2
  11. data/{spec → demo}/perl_adapter.rdoc +3 -3
  12. data/{spec → demo}/reporters/applique/cli.rb +1 -1
  13. data/{spec → demo}/reporters/fixtures/tapy.yml +0 -0
  14. data/{spec → demo}/reporters/reporters.rdoc +0 -0
  15. data/lib/tapout.rb +5 -101
  16. data/lib/tapout.yml +12 -3
  17. data/lib/tapout/adapters/perl.rb +1 -1
  18. data/lib/tapout/cli.rb +98 -0
  19. data/lib/tapout/config.rb +103 -0
  20. data/lib/tapout/parsers/json.rb +2 -2
  21. data/lib/tapout/parsers/perl.rb +1 -1
  22. data/lib/tapout/parsers/yaml.rb +3 -2
  23. data/lib/tapout/reporters.rb +2 -1
  24. data/lib/tapout/reporters/abstract.rb +223 -31
  25. data/lib/tapout/reporters/breakdown_reporter.rb +49 -57
  26. data/lib/tapout/reporters/dot_reporter.rb +52 -33
  27. data/lib/tapout/reporters/html_reporter.rb +3 -1
  28. data/lib/tapout/reporters/markdown_reporter.rb +101 -0
  29. data/lib/tapout/reporters/outline_reporter.rb +68 -25
  30. data/lib/tapout/reporters/pretty_reporter.rb +65 -86
  31. data/lib/tapout/reporters/progress_reporter.rb +47 -22
  32. data/lib/tapout/reporters/runtime_reporter.rb +223 -0
  33. data/lib/tapout/reporters/tap_reporter.rb +1 -1
  34. data/lib/tapout/reporters/turn_reporter.rb +26 -65
  35. data/lib/tapout/version.rb +2 -2
  36. metadata +34 -19
  37. data/test/unit/test-progressbar.rb +0 -5
@@ -1,6 +1,6 @@
1
1
  require 'tapout/reporters/abstract'
2
2
 
3
- module TapOut
3
+ module Tapout
4
4
 
5
5
  module Reporters
6
6
 
@@ -15,8 +15,9 @@ module TapOut
15
15
  end
16
16
 
17
17
  def start_suite(entry)
18
- headers = [ 'TESTCASE', 'TESTS', 'PASS', 'FAIL', 'ERR', 'SKIP' ]
19
- puts "\n%-20s %8s %8s %8s %8s %8s\n" % headers
18
+ headers = [ 'TESTCASE', 'TESTS', 'PASS', 'FAIL', 'ERROR', 'TODO', 'OMIT' ]
19
+ puts "\n%-20s %8s %8s %8s %8s %8s %8s\n" % headers
20
+ puts ("-" * 80)
20
21
  end
21
22
 
22
23
  def start_case(entry)
@@ -34,89 +35,80 @@ module TapOut
34
35
  groups = @case_entries.group_by{ |e| e['status'] }
35
36
 
36
37
  total = @case_entries.size
37
- sums = %w{pass fail error pending}.map{ |n| groups[n] ? groups[n].size : 0 }
38
+ sums = %w{pass fail error todo omit}.map{ |n| groups[n] ? groups[n].size : 0 }
38
39
 
39
40
  result = sums[1] + sums[2] > 0 ? "FAIL".ansi(:red) : "PASS".ansi(:green)
40
41
 
41
- puts "%-20s %8s %8s %8s %8s %8s [%s]" % ([label, total] + sums + [result])
42
+ puts "%-20s %8s %8s %8s %8s %8s %8s [%s]" % ([label, total] + sums + [result])
42
43
  end
43
44
 
44
45
  #
45
46
  def finish_suite(entry)
46
- #@pbar.finish
47
47
  post_report(entry)
48
48
  end
49
49
 
50
50
  #
51
51
  def post_report(entry)
52
52
 
53
- sums = %w{pass fail error todo}.map{ |n| entry['counts'][n] || 0 }
54
-
55
- puts ("-" * 80)
53
+ sums = count_tally(entry) #%w{pass fail error todo}.map{ |n| entry['counts'][n] || 0 }
56
54
 
57
55
  tally_line = "%-20s " % "TOTAL"
58
- tally_line << "%8s %8s %8s %8s %8s" % [entry['count'], *sums]
56
+ tally_line << "%8s %8s %8s %8s %8s %8s" % sums
59
57
 
58
+ puts ("-" * 80)
60
59
  puts(tally_line + "\n")
61
60
 
62
- =begin
63
- tally = test_tally(entry)
61
+ index = 1
64
62
 
65
- width = suite.collect{ |tr| tr.name.size }.max
66
-
67
- headers = [ 'TESTCASE ', ' TESTS ', 'ASSERTIONS', ' FAILURES ', ' ERRORS ' ]
68
- io.puts "\n%-#{width}s %10s %10s %10s %10s\n" % headers
69
-
70
- files = nil
71
-
72
- suite.each do |testrun|
73
- if testrun.files != [testrun.name] && testrun.files != files
74
- label = testrun.files.join(' ')
75
- label = Colorize.magenta(label)
76
- io.puts(label + "\n")
77
- files = testrun.files
63
+ unless @failed.empty?
64
+ puts
65
+ @failed.each do |test|
66
+ printout(test, index, *config.fail)
67
+ index += 1
78
68
  end
79
- io.puts paint_line(testrun, width)
69
+ puts
80
70
  end
81
71
 
82
- #puts("\n%i tests, %i assertions, %i failures, %i errors\n\n" % tally)
83
-
84
- tally_line = "-----\n"
85
- tally_line << "%-#{width}s " % "TOTAL"
86
- tally_line << "%10s %10s %10s %10s" % tally
87
-
88
- io.puts(tally_line + "\n")
89
- =end
90
-
91
- bad = @failed + @raised
92
-
93
- #fails = suite.select do |testrun|
94
- # testrun.fail? || testrun.error?
95
- #end
96
-
97
- #if tally[2] != 0 or tally[3] != 0
98
- unless bad.empty? # or verbose?
99
- #puts "\n-- Failures and Errors --\n"
100
- puts
101
- bad.each do |e|
102
- x = e['exception']
103
- message = [x['class'],x['message']].compact.join(': ').strip
104
- message = message.ansi(:red)
105
- puts(message)
106
- puts "#{x['file']}:#{x['line']}"
107
- puts
108
- puts code_snippet(x)
109
- end
110
- puts
72
+ unless @raised.empty?
73
+ puts
74
+ @raised.each do |test|
75
+ printout(test, index, *config.fail)
76
+ index += 1
111
77
  end
112
- #end
78
+ puts
79
+ end
113
80
 
81
+ time, rate, avg = time_tally(entry)
82
+
83
+ puts "Finished in %.4fs at %.2f tests/s." % [time, rate, avg]
84
+ puts
114
85
  puts tally_message(entry)
115
86
  end
116
87
 
88
+ private
89
+
90
+ def printout(test, index, *ansi)
91
+ x = test['exception']
92
+
93
+ label = test['label'].to_s
94
+ exclass = test['exception']['class']
95
+ message = test['exception']['message']
96
+
97
+ exclass = nil if exclass.to_s.strip.empty?
98
+ message = nil if message.to_s.strip.empty?
99
+
100
+ print "#{index}. "
101
+ print label.ansi(*config.highlight)
102
+ print " " + exclass.ansi(*ansi) if exclass
103
+ puts
104
+ puts message.tabto(4) if message
105
+ puts backtrace_snippets(test).tabto(4)
106
+ puts captured_output(test).tabto(4)
107
+ puts
108
+ end
109
+
117
110
  end
118
111
 
119
112
  end
120
113
 
121
114
  end
122
-
@@ -1,34 +1,36 @@
1
1
  require 'tapout/reporters/abstract'
2
2
 
3
- module TapOut::Reporters
3
+ module Tapout::Reporters
4
4
 
5
5
  # Traditional dot progress reporter.
6
6
  #
7
7
  class DotReporter < Abstract
8
8
 
9
9
  #
10
- def start_suite(entry)
11
- @start_time = Time.now
12
- $stdout.puts "Started\n"
10
+ def start_suite(suite)
11
+ print "Started"
12
+ print " w/ Seed: #{suite['seed']}" if suite['seed']
13
+ puts
14
+ super(suite)
13
15
  end
14
16
 
15
17
  #
16
18
  def pass(entry)
17
- $stdout.print '.'.ansi(:green)
19
+ $stdout.print '.'.ansi(*config.pass)
18
20
  $stdout.flush
19
21
  super(entry)
20
22
  end
21
23
 
22
24
  #
23
25
  def fail(entry)
24
- $stdout.print 'F'.ansi(:red)
26
+ $stdout.print 'F'.ansi(*config.fail)
25
27
  $stdout.flush
26
28
  super(entry)
27
29
  end
28
30
 
29
31
  #
30
32
  def error(entry)
31
- $stdout.print 'E'.ansi(:yellow)
33
+ $stdout.print 'E'.ansi(*config.error)
32
34
  $stdout.flush
33
35
  super(entry)
34
36
  end
@@ -39,38 +41,55 @@ module TapOut::Reporters
39
41
 
40
42
  i = 1
41
43
 
42
- @failed.each do |e|
43
- backtrace = clean_backtrace(e['exception']['backtrace'])
44
- depth = TapOut.trace || backtrace.size
45
-
46
- $stdout.puts "#{i}. " + (e['label']).ansi(:red)
47
- $stdout.puts
48
- $stdout.puts " #{e['exception']['class']}" if e['exception']['class']
49
- $stdout.puts e['exception']['message'].to_s.tabto(4)
50
- $stdout.puts " #{e['exception']['file']}:#{e['exception']['line']}" #+ backtrace[0]
51
- $stdout.puts code_snippet(e['exception'])
52
- $stdout.puts backtrace[0,depth].join("\n").tabto(4)
53
- $stdout.puts
44
+ @failed.each do |test|
45
+ label = test['label'].to_s
46
+ snippets = backtrace_snippets(test)
47
+ errclass = test['exception']['class']
48
+ message = test['exception']['message']
49
+ capture = captured_output(test)
50
+
51
+ parts = [errclass, message, snippets, capture].compact.map{ |e| e.strip }.reject{ |e| e.empty? }
52
+
53
+ puts "#{i}. " + "FAIL".ansi(*config.error) + " " + label.ansi(*config.fail)
54
+ puts
55
+ puts parts.join("\n\n").tabto(4)
56
+ puts
57
+
54
58
  i += 1
55
59
  end
56
60
 
57
- @raised.each do |e|
58
- backtrace = clean_backtrace(e['exception']['backtrace'])
59
- depth = TapOut.trace || backtrace.size
60
-
61
- $stdout.puts "#{i}. " + (e['label']).ansi(:yellow)
62
- $stdout.puts
63
- $stdout.puts " #{e['exception']['class']}" if e['exception']['class']
64
- $stdout.puts " #{e['exception']['message']}"
65
- $stdout.puts " #{e['exception']['file']}:#{e['exception']['line']}" #+ backtrace[0..2].join(" \n")
66
- $stdout.puts code_snippet(e['exception'])
67
- $stdout.puts backtrace[0,depth].join("\n").tabto(4)
68
- $stdout.puts
61
+ @raised.each do |test|
62
+ label = test['label'].to_s
63
+ snippets = backtrace_snippets(test)
64
+ errclass = test['exception']['class']
65
+ message = test['exception']['message']
66
+ capture = captured_output(test)
67
+
68
+ parts = [errclass, message, snippets, capture].compact.map{ |e| e.strip }.reject{ |e| e.empty? }
69
+
70
+ puts "#{i}. " + "ERROR".ansi(*config.error) + " " + label.ansi(*config.highlight)
71
+ puts
72
+ puts parts.join("\n\n").tabto(4)
73
+ puts
74
+
69
75
  i += 1
70
76
  end
71
77
 
72
- $stdout.puts "Finished in #{Time.now - @start_time}s"
73
- $stdout.puts tally_message(entry)
78
+ time, rate, avg = time_tally(entry)
79
+
80
+ total, pass, fail, error, todo, omit = count_tally(entry)
81
+
82
+ #total = @passed.size + @failed.size + @raised.size + @skipped.size + @omitted.size
83
+ #total = entry['counts']['total'] || total
84
+
85
+ #time = (entry['time'] || (Time.now - @start_time)).to_f
86
+ #avg = time / total
87
+ #rate = total / time
88
+
89
+ puts
90
+ puts "Finished in %.3fs (%.3f test/s, %.6fs avg.)" % [time, rate, avg]
91
+ puts
92
+ puts "%s tests: %s pass, %s fail, %s exit, %s todo, %s omit" % [total, pass, fail, error, todo, omit]
74
93
  end
75
94
 
76
95
  end
@@ -1,6 +1,6 @@
1
1
  require 'tapout/reporters/abstract'
2
2
 
3
- module TapOut::Reporters
3
+ module Tapout::Reporters
4
4
 
5
5
  # HTML Test Reporter
6
6
  #
@@ -78,6 +78,7 @@ module TapOut::Reporters
78
78
  puts clean_backtrace(e['backtrace']).join("\n")
79
79
  puts "</pre>"
80
80
  puts %[</li>]
81
+ # TODO: Add captured_stdout and _stderr
81
82
  end
82
83
 
83
84
  #
@@ -91,6 +92,7 @@ module TapOut::Reporters
91
92
  puts clean_backtrace(e['backtrace']).join("\n")
92
93
  puts "</pre>"
93
94
  puts %[</li>]
95
+ # TODO: Add captured_stdout and _stderr
94
96
  end
95
97
 
96
98
  #
@@ -0,0 +1,101 @@
1
+ require 'tapout/reporters/abstract'
2
+
3
+ module Tapout::Reporters
4
+
5
+ # Markdown reporter.
6
+ #
7
+ class Markdown < Abstract
8
+
9
+ #
10
+ def start_suite(entry)
11
+ @start_time = Time.now
12
+ end
13
+
14
+ #
15
+ def mark
16
+ ('#' * (@_level + 1)) + ' '
17
+ end
18
+
19
+ #
20
+ def start_case(entry)
21
+ @_level = entry['level'].to_i + 1
22
+ $stdout.print('#' * @_level + ' ')
23
+ $stdout.puts(entry['label'])
24
+ end
25
+
26
+ #
27
+ def pass(entry)
28
+ super(entry)
29
+ $stdout.puts "#{mark}" + entry['label'] + " #{entry['source']}"
30
+ end
31
+
32
+ #
33
+ def fail(entry)
34
+ super(entry)
35
+
36
+ $stdout.puts "#{mark}" + entry['label'] + " #{entry['source']}"
37
+
38
+ $stdout.puts "\n**MESSAGE**\n\n"
39
+ $stdout.puts entry['exception']['message'].tabto(4)
40
+
41
+ $stdout.puts "\n**TYPE**\n\n"
42
+ $stdout.puts entry['exception']['class'].tabto(4)
43
+
44
+ #$stdout.puts " " + ok.caller #clean_backtrace(exception.backtrace)[0]
45
+
46
+ $stdout.puts "\n**SNIPPET**\n\n"
47
+ $stdout.puts code_snippet(entry['exception'])
48
+
49
+ if captured_stdout?(entry)
50
+ $stdout.puts "\n**STDOUT**\n\n"
51
+ $stdout.puts captured_stdout(entry).tabto(4)
52
+ end
53
+
54
+ if captured_stderr?(entry)
55
+ $stdout.puts "\n**STDERR**\n\n"
56
+ $stdout.puts captured_stderr(entry).tabto(4)
57
+ end
58
+
59
+ $stdout.puts
60
+ end
61
+
62
+ #
63
+ def error(entry)
64
+ super(entry)
65
+
66
+ $stdout.puts "#{mark}" + entry['label'] + " #{entry['source']}"
67
+
68
+ $stdout.puts "\n**MESSAGE**\n\n"
69
+ $stdout.puts entry['exception']['message'].tabto(4)
70
+
71
+ $stdout.puts "\n**TYPE**\n\n"
72
+ $stdout.puts entry['exception']['class'].tabto(4)
73
+
74
+ #$stdout.puts " " + ok.caller #clean_backtrace(exception.backtrace)[0..2].join(" \n")
75
+
76
+ $stdout.puts "\n**SNIPPET**\n\n"
77
+ $stdout.puts code_snippet(entry['exception'])
78
+
79
+ if captured_stdout?(entry)
80
+ $stdout.puts "\n**STDOUT**\n\n"
81
+ $stdout.puts captured_stdout(entry).tabto(4)
82
+ end
83
+
84
+ if captured_stderr?(entry)
85
+ $stdout.puts "\n**STDERR**\n\n"
86
+ $stdout.puts captured_stderr(entry).tabto(4)
87
+ end
88
+
89
+ $stdout.puts
90
+ end
91
+
92
+ #
93
+ def finish_suite(entry)
94
+ #$stderr.puts
95
+ $stderr.print tally_message(entry)
96
+ $stderr.puts " [%0.4fs] " % [Time.now - @start_time]
97
+ end
98
+
99
+ end
100
+
101
+ end
@@ -1,61 +1,104 @@
1
1
  require 'tapout/reporters/abstract'
2
2
 
3
- module TapOut::Reporters
3
+ module Tapout::Reporters
4
4
 
5
5
  # Outline reporter.
6
6
  #
7
- # TODO: This is still a work in progress.
7
+ # TODO: Not sure there is really any good point to this reporter.
8
8
  #
9
9
  class Outline < Abstract
10
10
 
11
11
  #
12
12
  def start_suite(entry)
13
+ @_case_count = [0]
13
14
  @start_time = Time.now
14
15
  end
15
16
 
16
17
  #
17
18
  def start_case(entry)
18
- $stdout.puts entry['label'].ansi(:bold)
19
+ @_test_count = 0
20
+ @_level = entry['level'].to_i
21
+
22
+ print(' ' * (level_tab - 2))
23
+ puts(case_count(entry) + '. ' + entry['label'].ansi(*config.highlight))
24
+ #puts
25
+ end
26
+
27
+ #
28
+ def level_tab
29
+ 2 * (@_level + 1)
30
+ end
31
+
32
+ #
33
+ def case_count(entry)
34
+ level = entry['level'].to_i
35
+ @_case_count = @_case_count[0,level+1]
36
+ @_case_count[level] ||= 0
37
+ @_case_count[level] += 1
38
+ @_case_count.join('.') #+ '.'
39
+ @_case_count[level].to_s
40
+ end
41
+
42
+ #
43
+ def start_test(test)
44
+ @_test_count += 1
45
+ end
46
+
47
+ #
48
+ def test_count
49
+ @_test_count
19
50
  end
20
51
 
52
+ #
21
53
  def pass(entry)
22
54
  super(entry)
23
- $stdout.puts "* " + entry['label'].ansi(:green) + " #{entry['source']}"
55
+ print(' ' * level_tab)
56
+ puts "#{test_count}. " + entry['label'].ansi(:green) + " #{entry['source']}"
24
57
  end
25
58
 
26
59
  def fail(entry)
27
60
  super(entry)
28
61
 
29
- msg = entry['exception'].values_at('class', 'message').compact.join(' - ')
30
-
31
- $stdout.puts "* " + entry['label'].ansi(:red) + " #{entry['source']}"
32
- $stdout.puts
33
- $stdout.puts " #{msg}"
34
- #$stdout.puts " " + ok.caller #clean_backtrace(exception.backtrace)[0]
35
- $stdout.puts
36
- $stdout.puts code_snippet(entry['exception'])
37
- $stdout.puts
62
+ printout(entry, 'FAIL', config.fail)
38
63
  end
39
64
 
40
65
  def error(entry)
41
66
  super(entry)
42
67
 
43
- msg = entry['exception'].values_at('class', 'message').compact.join(' - ')
44
-
45
- $stdout.puts "* " + entry['label'].ansi(:yellow) + " #{entry['source']}"
46
- $stdout.puts
47
- $stdout.puts " #{msg}"
48
- #$stdout.puts " " + ok.caller #clean_backtrace(exception.backtrace)[0..2].join(" \n")
49
- $stdout.puts
50
- $stdout.puts code_snippet(entry['exception'])
51
- $stdout.puts
68
+ printout(entry, 'ERROR', config.error)
52
69
  end
53
70
 
54
71
  #
55
72
  def finish_suite(entry)
56
- #$stderr.puts
57
- $stdout.print tally_message(entry)
58
- $stdout.puts " [%0.4fs] " % [Time.now - @start_time]
73
+ time, rate, avg = time_tally(entry)
74
+ delta = duration(time)
75
+
76
+ puts
77
+ print tally_message(entry)
78
+ #puts " [%0.4fs %.4ft/s %.4fs/t] " % [time, rate, avg]
79
+ puts " [%s %.2ft/s %.4fs/t] " % [delta, rate, avg]
80
+ end
81
+
82
+ private
83
+
84
+ #
85
+ def printout(entry, type, ansi)
86
+ counter = "#{test_count}. "
87
+
88
+ label = entry['label'].ansi(*ansi)
89
+ message = entry['exception']['message']
90
+ exclass = entry['exception']['class']
91
+
92
+ parts = [message, exclass].compact.reject{ |x| x.strip.empty? }
93
+
94
+ print(' ' * level_tab)
95
+ puts counter + label + " #{entry['source']}"
96
+ puts
97
+ puts parts.join("\n\n").tabto(level_tab+counter.size)
98
+ puts
99
+ puts backtrace_snippets(entry).tabto(level_tab++counter.size+4)
100
+ print captured_output(entry).tabto(level_tab+counter.size)
101
+ puts
59
102
  end
60
103
 
61
104
  end