tapout 0.4.5 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 0ef865a8e6a2ba4a549207c84ca0f367bdd176ad
4
- data.tar.gz: 105a3907b7d99264cf29757198664f94a24b59da
2
+ SHA256:
3
+ metadata.gz: bfd210ca78591a32fd6bc81b316276edac4ce7bfafd52a7592ddcf403981ad39
4
+ data.tar.gz: 2e37e66002b616f2dd289de03010007419d39d6ec8684fb91867e96b35ca867d
5
5
  SHA512:
6
- metadata.gz: 201e038919117862600db3d702e81a1524965dbd359e85f7d80bb116de7a9ae4e6a95a6fc1f81192c22e0dac8a7178e6c0f6050528d1c45d5046fe6c0653aebf
7
- data.tar.gz: 036b6bf3485ab03f0f99fd5701ceac773278ebd2bf608adc3da4e44fb3d6b32bb4f341dcd39be69e21ce85263d2ef6927079c5e5e6137f59b440f6950a4b743c
6
+ metadata.gz: bb320a6776d37cf4fb8a5811bb232e9b7c0d76814ec39bd7d9811bc1c8156067648ea24b3cb05b7c3aacb00a50051e60e8ad71fd7f27b825b18b362f1785cca0
7
+ data.tar.gz: 86c2bf4a0c2c14d6bd9cad477e86a4f9aa178e1684cf84472eaafd1f6c12e676ad2998c2b59f24ade3b1d2c7b83f5e52a213d38e611d8d4d2fb3f7abf76acd9a
data/HISTORY.md CHANGED
@@ -1,5 +1,41 @@
1
1
  # RELEASE HISTORY
2
2
 
3
+ ## 0.5.0 / 2026-11-21
4
+
5
+ Tapout runs on current Ruby again. It needs Ruby 2.7 or newer.
6
+
7
+ Changes:
8
+
9
+ * Work with Bundler on Ruby 3.4 and newer, where the `abbrev` library is
10
+ no longer part of Ruby. Reporter names are matched without it: a name
11
+ can still be shortened to any unique beginning, as in `tapout pro`.
12
+ * Work with frozen string literals.
13
+ * Work on Ruby 4.0, by loading only the parts of the ANSI library that
14
+ Tapout uses. Loading all of it fails there for want of `logger`.
15
+ * Replace the old packaging (`.index`, `.gemspec`, `Assembly`, `MANIFEST`,
16
+ `var/`) with a plain `tapout.gemspec`, and Travis with GitHub Actions,
17
+ testing Ruby 2.7 to 4.0.
18
+ * `Tapout::VERSION` is a constant in `tapout/version.rb`. `Tapout.metadata`
19
+ and the lookup of other project metadata as constants are gone.
20
+ * Correct the README, which named a `progressbar` reporter; it is
21
+ `progress`.
22
+ * Reporters no longer raise for a test that didn't pass and says little
23
+ about why. Only an exception's message is required by TAP-Y/J, but the
24
+ `markdown` and `html` reporters needed its class or backtrace, and
25
+ every reporter needed the exception section itself, which a failed test
26
+ from plain TAP doesn't have.
27
+ * The `tap` reporter prints a line for a test that was omitted
28
+ (`ok N - label # SKIP reason`) or is still to be done
29
+ (`not ok N - label # TODO reason`), so the lines match the plan (#14).
30
+ Without a count at the start of the stream, it prints the plan at the end.
31
+ * The `outline` reporter lists omitted and to-do tests, with the reason.
32
+ * Reading plain TAP: a `TAP version` line is accepted, as is a stream that
33
+ starts with a test line or a comment; `# SKIP` and `# TODO` directives
34
+ become `omit` and `todo`; a test line needn't have a number; and the
35
+ final counts include errors, omissions and to-dos.
36
+ * The `outline` and `markdown` reporters no longer raise for tests that
37
+ belong to no case, as in plain TAP.
38
+
3
39
  ## 0.4.5 / 2013-11-20
4
40
 
5
41
  Added some convenience methods for test runners using tapout.
data/README.md CHANGED
@@ -1,21 +1,20 @@
1
1
  # TAPOUT
2
2
 
3
- [Website](http://rubyworks.github.com/tapout) |
4
- [User Guide](http://github.com/rubyworks/tapout/wiki) |
5
- [Report Issue](http://github.com/rubyworks/tapout/issues) |
6
- [Development](http://github.com/rubyworks/tapout)
3
+ [Website](https://rubyworks.github.io/tapout) |
4
+ [User Guide](https://github.com/rubyworks/tapout/wiki) |
5
+ [Report Issue](https://github.com/rubyworks/tapout/issues) |
6
+ [Development](https://github.com/rubyworks/tapout)
7
7
 
8
- [![Build Status](https://secure.travis-ci.org/rubyworks/tapout.png)](http://travis-ci.org/rubyworks/tapout)
9
- [![Gem Version](https://badge.fury.io/rb/tapout.png)](http://badge.fury.io/rb/tapout)    
10
- [![Flattr Me](http://api.flattr.com/button/flattr-badge-large.png)](http://flattr.com/thing/324911/Rubyworks-Ruby-Development-Fund)
8
+ [![CI](https://github.com/rubyworks/tapout/actions/workflows/ci.yml/badge.svg)](https://github.com/rubyworks/tapout/actions/workflows/ci.yml)
9
+ [![Gem Version](https://badge.fury.io/rb/tapout.svg)](https://rubygems.org/gems/tapout)
11
10
 
12
11
 
13
12
  ## About
14
13
 
15
14
  *TAPOUT* is the next generation in test results viewing. You may have heard
16
15
  of Turn or minitest-reporters. TAPOUT is the conceptual successor to these
17
- gems by virture of its use of TAP, a standardized intermediate test results
18
- protocol.
16
+ gems by virtue of its use of TAP, a standardized intermediate test results
17
+ protocol.
19
18
 
20
19
  TAPOUT works as a TAP handler which supports TAP-Y/J as well as traditional
21
20
  TAP streams. TAP-Y/J is a modernization of TAP using pure YAML/JSON streams.
@@ -24,16 +23,20 @@ with fairly good results. TAPOUT includes a TAP adapter to handle the
24
23
  translation transparently. Currently TAPOUT supports TAP v12 with some minor
25
24
  limitations.
26
25
 
27
- To learn about the TAP-Y/J specification, see the [TAP-Y/J Specification](https://github.com/rubyworks/tapout/wiki/Specification) document.
26
+ To learn about the TAP-Y/J specification, see the [TAP-Y/J Specification](https://github.com/rubyworks/tapout/wiki/TAP-Y-J-Specification) document.
28
27
 
29
- For information about TAP, see http://testanything.org/wiki/index.php/Main_Page.
28
+ For information about TAP, see https://testanything.org/
30
29
 
31
30
 
32
31
  ## Usage
33
32
 
33
+ To learn more about using Tapout, please see the [wiki](https://github.com/rubyworks/tapout/wiki).
34
+ It provides more detailed information on how to put Tapout to work for you using your preferred
35
+ testing framework and build tool. What follows here is a very general overview of usage.
36
+
34
37
  To use TAPOUT you need either a plugin for your current test framework, or use of
35
- a test framework that supports TAP-Y/J out of the box. You can find a
36
- [list of plugins here](https://github.com/rubyworks/tapout/wiki)
38
+ a test framework that supports TAP-Y/J out of the box. You can find a
39
+ [list of plugins here](https://github.com/rubyworks/tapout/wiki#producers)
37
40
  under the section "Producers".
38
41
 
39
42
  With a test framework that produces a TAP-Y/J output stream in hand pipe the
@@ -45,14 +48,14 @@ TAPOUT supports a variety of output formats. The default is the common
45
48
  dot-progress format (simply called `dot`). Other formats are selectable
46
49
  via the `tapout` command's first argument.
47
50
 
48
- $ rubytest -y -Ilib test/foo.rb | tapout progessbar
51
+ $ rubytest -y -Ilib test/foo.rb | tapout progress
49
52
 
50
53
  TAPOUT is smart enough to match the closest matching format name. So, for
51
54
  example, the above could be written as:
52
55
 
53
56
  $ rubytest -y -Ilib test/foo.rb | tapout pro
54
57
 
55
- And tapout will know to use the `progressbar` format.
58
+ And tapout will know to use the `progress` format.
56
59
 
57
60
  To see a list of supported formats use the list subcommand:
58
61
 
@@ -62,7 +65,7 @@ If your test framework does not support TAP-Y/J, but does support traditional
62
65
  TAP, TAPOUT will automatically recognize the difference by TAP's `1..N` header
63
66
  and automatically translate it.
64
67
 
65
- $ rubytest -ftap -Ilib test/foo.rb | tapout progressbar
68
+ $ rubytest -ftap -Ilib test/foo.rb | tapout progress
66
69
 
67
70
 
68
71
  ## Bypassing
@@ -81,8 +84,8 @@ A good example of this is debugging with Pry using `binding.pry`.
81
84
  def test_something
82
85
  STDOUT.puts 16.chr # tells tapout to pause processing
83
86
  binding.pry
84
- STDOUT.puts 23.char # tells tapout to start again
85
- assert somthing
87
+ STDOUT.puts 23.chr # tells tapout to start again
88
+ assert something
86
89
  end
87
90
 
88
91
  As it turns out, if your are using TAP-Y (not TAP-J) then you can also
@@ -91,14 +94,14 @@ use YAML's *END DOCUMENT* marker to acheive a similar result.
91
94
  def test_something
92
95
  STDOUT.puts "..." # tells tapout to pause processing
93
96
  binding.pry
94
- assert somthing
97
+ assert something
95
98
  end
96
99
 
97
- But this **only works for YAML** and if you happend to be debugging code
98
- that emits YAML you might accidently trigger tapout to resume. Therefore
100
+ But this **only works for YAML** and if you happened to be debugging code
101
+ that emits YAML you might accidentally trigger tapout to resume. Therefore
99
102
  it is recommended that the ASCII codes be used.
100
103
 
101
- Note: When sending these codes, be sure to send a newline character as well.
104
+ Note: When sending these codes, be sure to send a newline character as well.
102
105
 
103
106
 
104
107
  ## Legal
@@ -108,4 +111,3 @@ Copyright (c) 2010 Rubyworks
108
111
  TAPOUT is modifiable and redistributable in accordance with the *BSD-2-Clause* license.
109
112
 
110
113
  See COPYING.md for details.
111
-
@@ -6,7 +6,7 @@ end
6
6
 
7
7
  When '(((\w+))) reporter should run without error' do |format|
8
8
  $stdin = StringIO.new(@tapy)
9
- $stdout = StringIO.new(out = '')
9
+ $stdout = StringIO.new(out = String.new)
10
10
 
11
11
  Tapout.cli(format)
12
12
  end
@@ -0,0 +1,98 @@
1
+ # Sparse Streams
2
+
3
+ A test that didn't pass is meant to carry an `exception` section, but only
4
+ its `message` is required, and not every producer gives even that. Rubytest
5
+ gives no exception class, and a backtrace only for errors. Plain TAP gives
6
+ nothing at all for a failed test. Every reporter has to cope.
7
+
8
+ require 'stringio'
9
+
10
+ run = lambda do |format, text, parser = Tapout::YamlParser|
11
+ stdout, stderr = $stdout, $stderr
12
+ $stdout = StringIO.new(out = String.new)
13
+ $stderr = StringIO.new(String.new)
14
+ begin
15
+ parser.new(:format => format).consume(StringIO.new(text))
16
+ ensure
17
+ $stdout, $stderr = stdout, stderr
18
+ end
19
+ out
20
+ end
21
+
22
+ reporters = %w[dot progress outline pretty breakdown runtime tap turn markdown html]
23
+
24
+ Here a failure has a message and a location but no class or backtrace, an
25
+ error has a message alone, and another failure has no exception section.
26
+
27
+ sparse = <<-END.gsub(/^ /, '')
28
+ ---
29
+ type: suite
30
+ count: 6
31
+ rev: 5
32
+ ---
33
+ type: case
34
+ level: 0
35
+ label: Sparse
36
+ ---
37
+ type: test
38
+ status: pass
39
+ label: passes
40
+ ---
41
+ type: test
42
+ status: fail
43
+ label: fails
44
+ exception:
45
+ file: test/sparse.rb
46
+ line: 9
47
+ message: wrong value
48
+ ---
49
+ type: test
50
+ status: error
51
+ label: errors
52
+ exception:
53
+ message: boom
54
+ ---
55
+ type: test
56
+ status: fail
57
+ label: fails without saying why
58
+ ---
59
+ type: test
60
+ status: todo
61
+ label: is pending
62
+ exception:
63
+ message: later
64
+ ---
65
+ type: test
66
+ status: omit
67
+ label: is omitted
68
+ ---
69
+ type: final
70
+ counts:
71
+ total: 6
72
+ pass: 1
73
+ fail: 2
74
+ error: 1
75
+ omit: 1
76
+ todo: 1
77
+ ...
78
+ END
79
+
80
+ reporters.each do |format|
81
+ run.call(format, sparse).empty?.assert == false
82
+ end
83
+
84
+ The same goes for tests that belong to no case, as in a stream converted
85
+ from plain TAP.
86
+
87
+ plain = <<-END.gsub(/^ /, '')
88
+ TAP version 13
89
+ 1..4
90
+ ok 1 - passes
91
+ not ok 2 - fails
92
+ ok 3 - is skipped # SKIP no network
93
+ not ok 4 - is pending # TODO soon
94
+ END
95
+
96
+ reporters.each do |format|
97
+ run.call(format, plain, Tapout::PerlParser).empty?.assert == false
98
+ end
@@ -36,7 +36,7 @@ Or pipe the converted stream directly to another stream.
36
36
 
37
37
  adapter = Tapout::PerlAdapter.new(stream)
38
38
 
39
- output = ""
39
+ output = String.new
40
40
 
41
41
  tapy = adapter | output
42
42
 
@@ -64,3 +64,37 @@ and five passing tests.
64
64
 
65
65
  entries.size.assert == 8
66
66
 
67
+
68
+ ## Version line and directives
69
+
70
+ A stream may open with a version line, and a test line may end with a
71
+ `SKIP` or `TODO` directive. Given a legacy TAP stream:
72
+
73
+ TAP version 13
74
+ 1..5
75
+ ok 1 - passes
76
+ not ok 2 - fails
77
+ ok 3 - is skipped # SKIP no network
78
+ not ok 4 - is pending # TODO soon
79
+ ok
80
+
81
+ The version line is ignored. A skipped test becomes an `omit` and a test
82
+ still to be done a `todo`, each with its reason as the message. A test
83
+ without a number takes the next one.
84
+
85
+ entries = Tapout::PerlAdapter.new(StringIO.new(@tap)).to_a
86
+
87
+ tests = entries.select{ |e| e['type'] == 'test' }
88
+
89
+ tests.map{ |e| e['status'] }.assert == %w[pass fail omit todo pass]
90
+ tests.map{ |e| e['label'] }.assert == ['passes', 'fails', 'is skipped', 'is pending', '']
91
+ tests.map{ |e| e['index'] }.assert == [1, 2, 3, 4, 5]
92
+
93
+ tests[2]['exception']['message'].assert == 'no network'
94
+ tests[3]['exception']['message'].assert == 'soon'
95
+
96
+ The final entry counts each kind.
97
+
98
+ entries.last['counts'].assert == {
99
+ 'total' => 5, 'pass' => 2, 'fail' => 1, 'error' => 0, 'omit' => 1, 'todo' => 1
100
+ }
@@ -0,0 +1,60 @@
1
+ ## TAP Reporter
2
+
3
+ ### Issue #14 - tap reporter with skipped tests reports wrong number of tests
4
+
5
+ The tap reporter printed the plan, say `1..4`, and then a line for each
6
+ test that passed, failed or errored, but none for a test that was omitted
7
+ or still to be done. A stream with such tests came out short of its plan.
8
+
9
+ See https://github.com/rubyworks/tapout/issues/14.
10
+
11
+ require 'stringio'
12
+
13
+ tapy = <<-END.gsub(/^ /, '')
14
+ ---
15
+ type: suite
16
+ count: 4
17
+ ---
18
+ type: test
19
+ status: pass
20
+ label: one
21
+ ---
22
+ type: test
23
+ status: omit
24
+ label: two
25
+ exception:
26
+ message: no network
27
+ ---
28
+ type: test
29
+ status: todo
30
+ label: three
31
+ exception:
32
+ message: soon
33
+ ---
34
+ type: test
35
+ status: pass
36
+ label: four
37
+ ---
38
+ type: final
39
+ counts: {total: 4, pass: 2, fail: 0, error: 0, omit: 1, todo: 1}
40
+ ...
41
+ END
42
+
43
+ stdout = $stdout
44
+ $stdout = StringIO.new(out = String.new)
45
+ begin
46
+ Tapout::YamlParser.new(:format => 'tap').consume(StringIO.new(tapy))
47
+ ensure
48
+ $stdout = stdout
49
+ end
50
+
51
+ Every test now has its line, with TAP's directives for the two that
52
+ weren't run to a verdict.
53
+
54
+ out.lines.map(&:chomp).assert == [
55
+ '1..4',
56
+ 'ok 1 - one',
57
+ 'ok 2 - two # SKIP no network',
58
+ 'not ok 3 - three # TODO soon',
59
+ 'ok 4 - four'
60
+ ]
@@ -1,4 +1,5 @@
1
1
  require 'tapout/version'
2
+ require 'yaml'
2
3
 
3
4
  module Tapout
4
5
 
@@ -21,6 +22,7 @@ module Tapout
21
22
  @state = nil
22
23
  @entries = []
23
24
  @cache = []
25
+ @count = nil
24
26
  end
25
27
 
26
28
  # We need to keep an internal list of all entries
@@ -29,7 +31,7 @@ module Tapout
29
31
 
30
32
  # Convert input stream to TAP-Y string.
31
33
  def to_s
32
- self | ""
34
+ self | String.new
33
35
  end
34
36
 
35
37
  # Route stream to an array of entires.
@@ -55,9 +57,11 @@ module Tapout
55
57
  parse(@cache)
56
58
  @state = :footer
57
59
  finish
60
+ when /^TAP version/i
61
+ return
58
62
  when /^\d+\.\.\d+/
59
- #parse(@cache) if @state != :plan
60
63
  return if @head
64
+ parse(@cache)
61
65
  @head = true
62
66
  @state = :plan
63
67
  @cache << line
@@ -86,19 +90,17 @@ module Tapout
86
90
  when :plan
87
91
  line = cache[0]
88
92
  md = /^(\d+)\.\.(\d+)\s*$/.match(line)
89
- count = md[2].to_i - md[1].to_i + 1
90
- entry = {'count'=>count, 'type'=>'suite', 'rev'=>REVISION}
93
+ md = /^(\d+)\.\.(\d+)/.match(line)
94
+ @count = md[2].to_i - md[1].to_i + 1
95
+ entry = {'count'=>@count, 'type'=>'suite', 'rev'=>REVISION}
91
96
  when :ok
92
- line = cache[0]
93
- md = /^ok\s+(\d+)\s*\-?\s*(.*?)($|#)/.match(line)
94
- entry = {'type'=>'test','status'=>'pass','index'=>md[1].to_i, 'label'=>md[2]}
97
+ number, label, directive, reason = parse_test_line(cache[0])
98
+ entry = {'type'=>'test', 'status'=>'pass', 'index'=>number, 'label'=>label}
99
+ apply_directive(entry, directive, reason)
95
100
  when :not_ok
96
- line = cache[0]
97
- yaml = cache[1..-2].join('')
98
- yaml = unindent(yaml)
99
- data = YAML.load(yaml)
100
- md = /^not ok\s+(\d+)\s*\-?\s*(.*?)($|#)/.match(line)
101
- entry = convert_not_ok(md[1], md[2], data)
101
+ number, label, directive, reason = parse_test_line(cache[0])
102
+ entry = convert_not_ok(number, label, diagnostics(cache[1..-1]))
103
+ apply_directive(entry, directive, reason)
102
104
  when :comment
103
105
  desc = cache.map{ |c| c.sub(/^\#\s{0,1}/, '') }.join("\n")
104
106
  entry = {'type'=>'note', 'text'=>desc.rstrip}
@@ -129,6 +131,39 @@ module Tapout
129
131
 
130
132
  private
131
133
 
134
+ # Split a test line into its number, description, and the directive
135
+ # (`skip` or `todo`) and reason that may follow a `#`. The number is
136
+ # optional in TAP; a test without one is numbered in order.
137
+ def parse_test_line(line)
138
+ md = /^(?:not )?ok\b\s*(\d+)?\s*-?\s*(.*)$/.match(line.chomp)
139
+ number = md[1] ? md[1].to_i : @entries.count{ |e| e['type'] == 'test' } + 1
140
+ label, directive, reason = md[2], nil, nil
141
+ if dm = /(\A|\s)#\s*(skip\w*|todo)\b\s*(.*)\z/i.match(label)
142
+ label = dm.pre_match
143
+ directive = dm[2].downcase.start_with?('skip') ? 'skip' : 'todo'
144
+ reason = dm[3]
145
+ end
146
+ return number, label.strip, directive, reason
147
+ end
148
+
149
+ # In TAP a skipped test is reported `ok`, and one still to be done
150
+ # either way. TAP-Y calls these `omit` and `todo`.
151
+ def apply_directive(entry, directive, reason)
152
+ return unless directive
153
+ entry['status'] = (directive == 'skip' ? 'omit' : 'todo')
154
+ entry['exception'] ||= {}
155
+ entry['exception']['message'] = reason unless reason.to_s.empty?
156
+ end
157
+
158
+ # The YAML block that may follow a test line, as a Hash, or nil.
159
+ def diagnostics(lines)
160
+ lines = lines.reject{ |l| l =~ /^\s*(---|\.\.\.)\s*$/ }
161
+ data = YAML.load(unindent(lines.join('')))
162
+ Hash === data ? data : nil
163
+ rescue Psych::SyntaxError
164
+ nil
165
+ end
166
+
132
167
  #
133
168
  # TODO: Any way to distinguish fail vs error?
134
169
  def convert_not_ok(number, label, data)
@@ -141,7 +176,7 @@ module Tapout
141
176
  entry['exception'] = {}
142
177
  entry['exception']['file'] = data['file']
143
178
  entry['exception']['line'] = data['line']
144
- entry['exception']['message'] = data['description']
179
+ entry['exception']['message'] = data['description'] || data['message']
145
180
 
146
181
  entry['expected'] = data['wanted']
147
182
  entry['returned'] = data['found']
@@ -157,10 +192,14 @@ module Tapout
157
192
 
158
193
  entry = {}
159
194
  entry['type'] = 'final'
195
+ tests = @entries.count{ |e| e['type'] == 'test' }
160
196
  entry['counts'] = {
161
- 'total' => @count,
162
- 'pass' => (groups['pass'] || []).size,
163
- 'fail' => (groups['fail'] || []).size
197
+ 'total' => @count || tests,
198
+ 'pass' => (groups['pass'] || []).size,
199
+ 'fail' => (groups['fail'] || []).size,
200
+ 'error' => (groups['error'] || []).size,
201
+ 'omit' => (groups['omit'] || []).size,
202
+ 'todo' => (groups['todo'] || []).size
164
203
  }
165
204
  entry
166
205
  end
data/lib/tapout/cli.rb CHANGED
@@ -61,7 +61,7 @@ module Tapout
61
61
  stdin = Curmudgeon.new($stdin)
62
62
 
63
63
  case stdin.line1
64
- when /^\d/
64
+ when /^\d/, /^TAP version/i, /^(not )?ok\b/, /^\#/
65
65
  type = :perl
66
66
  when /^\-/
67
67
  type = :yaml
@@ -18,7 +18,7 @@ module Tapout
18
18
  return line if RESUME_DOCUMENT === line
19
19
  $stdout << line
20
20
  end
21
- return ''
21
+ return String.new
22
22
  end
23
23
 
24
24
  end
@@ -32,7 +32,7 @@ module Tapout
32
32
  def consume(input=nil)
33
33
  @input = input if input
34
34
 
35
- entry = ''
35
+ entry = String.new
36
36
  while line = @input.gets
37
37
  case line
38
38
  when PAUSE_DOCUMENT
@@ -88,7 +88,7 @@ module Tapout
88
88
  return line if @resume === line
89
89
  $stdout << line
90
90
  end
91
- return ''
91
+ return String.new
92
92
  end
93
93
 
94
94
  end
@@ -1,5 +1,6 @@
1
- require 'ansi'
2
- require 'abbrev'
1
+ # Only the parts of ANSI that are used: all of it brings in its logger,
2
+ # which needs the logger library that Ruby 4.0 no longer ships.
3
+ require 'ansi/core'
3
4
 
4
5
  module Tapout
5
6
 
@@ -19,13 +20,11 @@ module Tapout
19
20
  # Returns a reporter class given it's name or a unique abbreviation of it.
20
21
  # If `name` is `nil` then the default dot reporter is returned.
21
22
  def self.factory(name)
22
- list = index.keys.abbrev
23
- rptr = index[list[name || DEAFULT_REPORTER]]
23
+ rptr = lookup(name || DEAFULT_REPORTER)
24
24
  unless rptr
25
25
  begin
26
26
  require "tapout-#{name}"
27
- list = index.keys.abbrev
28
- rptr = index[list[name || DEAFULT_REPORTER]]
27
+ rptr = lookup(name || DEAFULT_REPORTER)
29
28
  rescue LoadError
30
29
  end
31
30
  raise ArgumentError, "Unrecognized reporter -- #{name.inspect}" unless rptr
@@ -33,6 +32,15 @@ module Tapout
33
32
  rptr
34
33
  end
35
34
 
35
+ # Returns the reporter class with the given name, or the one whose name
36
+ # it is the start of, if there is only one such.
37
+ def self.lookup(name)
38
+ name = name.to_s
39
+ return index[name] if index.key?(name)
40
+ keys = index.keys.select { |key| key.start_with?(name) }
41
+ keys.size == 1 ? index[keys.first] : nil
42
+ end
43
+
36
44
  ##
37
45
  # The Abstract class serves as a base class for all reporters. Reporters
38
46
  # must sublcass Abstract in order to be added the the Reporters Index.
@@ -61,6 +69,7 @@ module Tapout
61
69
 
62
70
  @case_stack = []
63
71
  @source = {}
72
+ @start_time = Time.now
64
73
  @exit_code = 0 # assume passing
65
74
  end
66
75
 
@@ -150,6 +159,7 @@ module Tapout
150
159
  when 'note'
151
160
  note(entry)
152
161
  when 'test'
162
+ complete_exception(entry)
153
163
  start_test(entry)
154
164
  case entry['status']
155
165
  when 'pass'
@@ -174,6 +184,18 @@ module Tapout
174
184
  end
175
185
  end
176
186
 
187
+ # A test that didn't pass is supposed to say why, in an `exception`
188
+ # section with at least a message. Not every producer gives one, or
189
+ # all of it: plain TAP has none, and others leave out the class or
190
+ # the backtrace. Fill in what reporters rely on.
191
+ def complete_exception(entry)
192
+ return if entry['status'] == 'pass' && !entry['exception']
193
+ exception = entry['exception']
194
+ exception = entry['exception'] = {} unless Hash === exception
195
+ exception['message'] = exception['message'].to_s
196
+ exception['class'] = exception['class'].to_s
197
+ end
198
+
177
199
  # Get the exit code.
178
200
  def exit_code
179
201
  @exit_code
@@ -274,6 +296,7 @@ module Tapout
274
296
 
275
297
  # Clean the backtrace of any "boring" reference.
276
298
  def clean_backtrace(backtrace)
299
+ backtrace = Array(backtrace)
277
300
  if ENV['debug']
278
301
  trace = backtrace
279
302
  else
@@ -495,7 +518,7 @@ module Tapout
495
518
 
496
519
  #
497
520
  def captured_output(test)
498
- str = ""
521
+ str = String.new
499
522
  str += captured_stdout(test){ |c| "\nSTDOUT\n#{c.tabto(4)}\n" }.to_s
500
523
  str += captured_stderr(test){ |c| "\nSTDERR\n#{c.tabto(4)}\n" }.to_s
501
524
  str
@@ -9,6 +9,7 @@ module Tapout::Reporters
9
9
  #
10
10
  def start_suite(entry)
11
11
  @start_time = Time.now
12
+ @_level = 0 # for tests outside of any case
12
13
  end
13
14
 
14
15
  #
@@ -38,8 +39,10 @@ module Tapout::Reporters
38
39
  $stdout.puts "\n**MESSAGE**\n\n"
39
40
  $stdout.puts entry['exception']['message'].tabto(4)
40
41
 
41
- $stdout.puts "\n**TYPE**\n\n"
42
- $stdout.puts entry['exception']['class'].tabto(4)
42
+ unless entry['exception']['class'].empty?
43
+ $stdout.puts "\n**TYPE**\n\n"
44
+ $stdout.puts entry['exception']['class'].tabto(4)
45
+ end
43
46
 
44
47
  #$stdout.puts " " + ok.caller #clean_backtrace(exception.backtrace)[0]
45
48
 
@@ -68,8 +71,10 @@ module Tapout::Reporters
68
71
  $stdout.puts "\n**MESSAGE**\n\n"
69
72
  $stdout.puts entry['exception']['message'].tabto(4)
70
73
 
71
- $stdout.puts "\n**TYPE**\n\n"
72
- $stdout.puts entry['exception']['class'].tabto(4)
74
+ unless entry['exception']['class'].empty?
75
+ $stdout.puts "\n**TYPE**\n\n"
76
+ $stdout.puts entry['exception']['class'].tabto(4)
77
+ end
73
78
 
74
79
  #$stdout.puts " " + ok.caller #clean_backtrace(exception.backtrace)[0..2].join(" \n")
75
80
 
@@ -11,6 +11,8 @@ module Tapout::Reporters
11
11
  #
12
12
  def start_suite(entry)
13
13
  @_case_count = [0]
14
+ @_test_count = 0
15
+ @_level = -1 # tests outside of any case start at the margin
14
16
  @start_time = Time.now
15
17
  end
16
18
 
@@ -68,6 +70,18 @@ module Tapout::Reporters
68
70
  printout(entry, 'ERROR', config.error)
69
71
  end
70
72
 
73
+ def todo(entry)
74
+ super(entry)
75
+
76
+ remark(entry, 'TODO', config.todo)
77
+ end
78
+
79
+ def omit(entry)
80
+ super(entry)
81
+
82
+ remark(entry, 'OMIT', config.omit)
83
+ end
84
+
71
85
  #
72
86
  def finish_suite(entry)
73
87
  time, rate, avg = time_tally(entry)
@@ -81,6 +95,17 @@ module Tapout::Reporters
81
95
 
82
96
  private
83
97
 
98
+ # One line for a test that wasn't run to a verdict, with the reason.
99
+ def remark(entry, type, ansi)
100
+ reason = entry['reason'] || entry['exception']['message']
101
+ reason = reason.to_s.lines.first.to_s.strip
102
+
103
+ print(' ' * level_tab)
104
+ line = "#{test_count}. " + entry['label'].ansi(*ansi) + " #{type}"
105
+ line += ": #{reason}" unless reason.empty?
106
+ puts line
107
+ end
108
+
84
109
  #
85
110
  def printout(entry, type, ansi)
86
111
  counter = "#{test_count}. "
@@ -175,7 +175,7 @@ end
175
175
 
176
176
  #puts("\n%i tests, %i assertions, %i failures, %i errors\n\n" % tally)
177
177
 
178
- tally_line = "-----\n"
178
+ tally_line = +"-----\n"
179
179
  tally_line << "%-#{width}s " % "TOTAL"
180
180
  tally_line << "%10s %10s %10s %10s" % tally
181
181
 
@@ -201,7 +201,7 @@ end
201
201
  private
202
202
 
203
203
  def paint_line(testrun, width)
204
- line = ''
204
+ line = String.new
205
205
  line << "%-#{width}s " % [testrun.name]
206
206
  line << "%10s %10s %10s %10s" % testrun.counts
207
207
  line << " " * 8
@@ -11,7 +11,13 @@ module Tapout::Reporters
11
11
  @i = 0
12
12
  #n = 0
13
13
  #suite.concerns.each{ |f| f.concerns.each { |s| n += s.ok.size } }
14
- puts "1..#{entry['count']}"
14
+ @plan = entry['count']
15
+ puts "1..#{@plan}" if @plan
16
+ end
17
+
18
+ # Without a count at the start, the plan goes at the end.
19
+ def finish_suite(entry)
20
+ puts "1..#{@i}" unless @plan
15
21
  end
16
22
 
17
23
  #
@@ -64,7 +70,7 @@ module Tapout::Reporters
64
70
 
65
71
  body = []
66
72
  body << "ERROR #{x['file']}:#{x['line']}" #clean_backtrace(exception.backtrace)[0..2].join(" \n")
67
- body << "#{x['class']}: #{x['message']}"
73
+ body << [x['class'], x['message']].reject{ |s| s.to_s.empty? }.join(': ')
68
74
  #body << "#{x['message']}"
69
75
  body << ""
70
76
  body << code_snippet(entry)
@@ -75,12 +81,30 @@ module Tapout::Reporters
75
81
  puts body
76
82
  end
77
83
 
78
- #
79
- #def pending(ok, exception)
80
- # puts "not ok #{@i} - #{unit.description}"
81
- # puts " PENDING"
82
- # puts " #{exception.backtrace[1]}"
83
- #end
84
+ # A test still to be done is `not ok` with a TODO directive, which
85
+ # TAP consumers don't count as a failure.
86
+ def todo(entry)
87
+ super(entry)
88
+
89
+ @i += 1
90
+ puts "not ok #{@i} - #{entry['label']} # TODO #{directive_reason(entry)}".rstrip
91
+ end
92
+
93
+ # An omitted test is `ok` with a SKIP directive.
94
+ def omit(entry)
95
+ super(entry)
96
+
97
+ @i += 1
98
+ puts "ok #{@i} - #{entry['label']} # SKIP #{directive_reason(entry)}".rstrip
99
+ end
100
+
101
+ private
102
+
103
+ # The reason for a directive, on one line.
104
+ def directive_reason(entry)
105
+ reason = entry['reason'] || (entry['exception'] || {})['message']
106
+ reason.to_s.lines.first.to_s.strip
107
+ end
84
108
  end
85
109
 
86
110
  end
@@ -1,20 +1,7 @@
1
1
  module Tapout
2
+ # The version of Tapout.
3
+ VERSION = '0.5.0'
4
+
2
5
  # The current revision of the TAP-Y/J format.
3
6
  REVISION = "4"
4
-
5
- # Project metadata.
6
- #
7
- # @return [Hash] metadata from .ruby file
8
- def self.metadata
9
- @metadata ||= (
10
- require 'yaml'
11
- YAML.load_file(File.join(File.dirname(__FILE__), '/../tapout.yml'))
12
- )
13
- end
14
-
15
- # Any missing constant will be looked for in
16
- # project metadata.
17
- def self.const_missing(name)
18
- metadata[name.to_s.downcase] || super(name)
19
- end
20
7
  end
data/lib/tapout.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  module Tapout
2
2
  end
3
3
 
4
+ require 'tapout/version'
4
5
  require 'tapout/config'
5
6
  require 'tapout/cli'
6
7
  require 'tapout/parsers'
metadata CHANGED
@@ -1,85 +1,84 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tapout
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
- - Thomas Sawyer
8
- autorequire:
7
+ - Trans
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2013-11-20 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: ansi
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
- - - '>='
16
+ - - ">="
18
17
  - !ruby/object:Gem::Version
19
- version: '0'
18
+ version: '1.5'
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
- - - '>='
23
+ - - ">="
25
24
  - !ruby/object:Gem::Version
26
- version: '0'
25
+ version: '1.5'
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: json
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
- - - '>='
30
+ - - ">="
32
31
  - !ruby/object:Gem::Version
33
32
  version: '0'
34
33
  type: :runtime
35
34
  prerelease: false
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
38
- - - '>='
37
+ - - ">="
39
38
  - !ruby/object:Gem::Version
40
39
  version: '0'
41
40
  - !ruby/object:Gem::Dependency
42
- name: ergo
41
+ name: rake
43
42
  requirement: !ruby/object:Gem::Requirement
44
43
  requirements:
45
- - - '>='
44
+ - - ">="
46
45
  - !ruby/object:Gem::Version
47
- version: '0'
46
+ version: '13'
48
47
  type: :development
49
48
  prerelease: false
50
49
  version_requirements: !ruby/object:Gem::Requirement
51
50
  requirements:
52
- - - '>='
51
+ - - ">="
53
52
  - !ruby/object:Gem::Version
54
- version: '0'
53
+ version: '13'
55
54
  - !ruby/object:Gem::Dependency
56
55
  name: qed
57
56
  requirement: !ruby/object:Gem::Requirement
58
57
  requirements:
59
- - - '>='
58
+ - - ">="
60
59
  - !ruby/object:Gem::Version
61
- version: '0'
60
+ version: '2.9'
62
61
  type: :development
63
62
  prerelease: false
64
63
  version_requirements: !ruby/object:Gem::Requirement
65
64
  requirements:
66
- - - '>='
65
+ - - ">="
67
66
  - !ruby/object:Gem::Version
68
- version: '0'
67
+ version: '2.9'
69
68
  - !ruby/object:Gem::Dependency
70
69
  name: ae
71
70
  requirement: !ruby/object:Gem::Requirement
72
71
  requirements:
73
- - - '>='
72
+ - - ">="
74
73
  - !ruby/object:Gem::Version
75
- version: '0'
74
+ version: '1.8'
76
75
  type: :development
77
76
  prerelease: false
78
77
  version_requirements: !ruby/object:Gem::Requirement
79
78
  requirements:
80
- - - '>='
79
+ - - ">="
81
80
  - !ruby/object:Gem::Version
82
- version: '0'
81
+ version: '1.8'
83
82
  description: Tapout is a TAP consumer that can take any TAP, TAP-Y or TAP-J stream
84
83
  and output it in a variety of useful formats.
85
84
  email:
@@ -89,30 +88,37 @@ executables:
89
88
  extensions: []
90
89
  extra_rdoc_files:
91
90
  - COPYING.md
91
+ - HISTORY.md
92
92
  - README.md
93
93
  - TAP-YJ.md
94
- - HISTORY.md
95
94
  files:
96
- - .index
97
- - .yardopts
95
+ - ".yardopts"
96
+ - COPYING.md
97
+ - HISTORY.md
98
+ - README.md
99
+ - TAP-YJ.md
98
100
  - bin/tapout
99
101
  - demo/01_reporters/applique/cli.rb
100
102
  - demo/01_reporters/fixtures/tapy.yml
101
103
  - demo/01_reporters/reporters.md
104
+ - demo/01_reporters/sparse_streams.md
102
105
  - demo/02_adapters/perl_adapter.md
103
106
  - demo/09_issues/applique/env.rb
104
107
  - demo/09_issues/default_reporter.md
108
+ - demo/09_issues/tap_reporter_plan.md
105
109
  - demo/applique/ae.rb
106
110
  - demo/applique/env.rb
111
+ - lib/tapout.rb
107
112
  - lib/tapout/adapters/perl.rb
108
113
  - lib/tapout/cli.rb
109
114
  - lib/tapout/config.rb
110
115
  - lib/tapout/core_ext.rb
116
+ - lib/tapout/parsers.rb
111
117
  - lib/tapout/parsers/abstract.rb
112
118
  - lib/tapout/parsers/json.rb
113
119
  - lib/tapout/parsers/perl.rb
114
120
  - lib/tapout/parsers/yaml.rb
115
- - lib/tapout/parsers.rb
121
+ - lib/tapout/reporters.rb
116
122
  - lib/tapout/reporters/abstract.rb
117
123
  - lib/tapout/reporters/breakdown_reporter.rb
118
124
  - lib/tapout/reporters/dot_reporter.rb
@@ -124,37 +130,32 @@ files:
124
130
  - lib/tapout/reporters/runtime_reporter.rb
125
131
  - lib/tapout/reporters/tap_reporter.rb
126
132
  - lib/tapout/reporters/turn_reporter.rb
127
- - lib/tapout/reporters.rb
128
133
  - lib/tapout/utility.rb
129
134
  - lib/tapout/version.rb
130
- - lib/tapout.rb
131
- - lib/tapout.yml
132
- - COPYING.md
133
- - README.md
134
- - TAP-YJ.md
135
- - HISTORY.md
136
- homepage: http://rubyworks.github.com/tapout
135
+ homepage: https://rubyworks.github.io/tapout
137
136
  licenses:
138
137
  - BSD-2-Clause
139
- metadata: {}
140
- post_install_message:
138
+ metadata:
139
+ homepage_uri: https://rubyworks.github.io/tapout
140
+ source_code_uri: https://github.com/rubyworks/tapout
141
+ bug_tracker_uri: https://github.com/rubyworks/tapout/issues
142
+ changelog_uri: https://github.com/rubyworks/tapout/blob/master/HISTORY.md
143
+ documentation_uri: https://rubydoc.info/gems/tapout
141
144
  rdoc_options: []
142
145
  require_paths:
143
146
  - lib
144
147
  required_ruby_version: !ruby/object:Gem::Requirement
145
148
  requirements:
146
- - - '>='
149
+ - - ">="
147
150
  - !ruby/object:Gem::Version
148
- version: '0'
151
+ version: '2.7'
149
152
  required_rubygems_version: !ruby/object:Gem::Requirement
150
153
  requirements:
151
- - - '>='
154
+ - - ">="
152
155
  - !ruby/object:Gem::Version
153
156
  version: '0'
154
157
  requirements: []
155
- rubyforge_project:
156
- rubygems_version: 2.0.3
157
- signing_key:
158
+ rubygems_version: 3.6.9
158
159
  specification_version: 4
159
160
  summary: Progressive TAP Harness
160
161
  test_files: []
data/.index DELETED
@@ -1,70 +0,0 @@
1
- ---
2
- revision: 2013
3
- type: ruby
4
- sources:
5
- - var
6
- authors:
7
- - name: Thomas Sawyer
8
- email: transfire@gmail.com
9
- organizations:
10
- - name: Rubyworks
11
- requirements:
12
- - name: ansi
13
- - name: json
14
- - groups:
15
- - build
16
- development: true
17
- name: ergo
18
- - groups:
19
- - test
20
- development: true
21
- name: qed
22
- - groups:
23
- - test
24
- development: true
25
- name: ae
26
- conflicts: []
27
- alternatives: []
28
- resources:
29
- - type: home
30
- uri: http://rubyworks.github.com/tapout
31
- label: Homepage
32
- - type: wiki
33
- uri: http://github.com/rubyworks/tapout/wiki
34
- label: User Guide
35
- - type: docs
36
- uri: http://rubydoc.info/gems/tapout/frames
37
- label: Documentation
38
- - type: code
39
- uri: http://github.com/rubyworks/tapout
40
- label: Source Code
41
- - type: bugs
42
- uri: http://github.com/rubyworks/tapout/issues
43
- label: Issue Tracker
44
- - type: mail
45
- uri: http://groups.google.com/rubyworks-mailinglist
46
- label: Mailing List
47
- - type: chat
48
- uri: irc://chat.us.freenode.net#rubyworks
49
- label: IRC Channel
50
- repositories:
51
- - name: upstream
52
- scm: git
53
- uri: git://github.com/rubyworks/tapout.git
54
- categories: []
55
- copyrights:
56
- - holder: Thomas Sawyer
57
- year: '2010'
58
- license: BSD-2-Clause
59
- customs: []
60
- paths:
61
- lib:
62
- - lib
63
- name: tapout
64
- title: TAPOUT
65
- summary: Progressive TAP Harness
66
- created: '2010-12-23'
67
- description: Tapout is a TAP consumer that can take any TAP, TAP-Y or TAP-J stream
68
- and output it in a variety of useful formats.
69
- version: 0.4.5
70
- date: '2013-11-20'
data/lib/tapout.yml DELETED
@@ -1,70 +0,0 @@
1
- ---
2
- revision: 2013
3
- type: ruby
4
- sources:
5
- - var
6
- authors:
7
- - name: Thomas Sawyer
8
- email: transfire@gmail.com
9
- organizations:
10
- - name: Rubyworks
11
- requirements:
12
- - name: ansi
13
- - name: json
14
- - groups:
15
- - build
16
- development: true
17
- name: ergo
18
- - groups:
19
- - test
20
- development: true
21
- name: qed
22
- - groups:
23
- - test
24
- development: true
25
- name: ae
26
- conflicts: []
27
- alternatives: []
28
- resources:
29
- - type: home
30
- uri: http://rubyworks.github.com/tapout
31
- label: Homepage
32
- - type: wiki
33
- uri: http://github.com/rubyworks/tapout/wiki
34
- label: User Guide
35
- - type: docs
36
- uri: http://rubydoc.info/gems/tapout/frames
37
- label: Documentation
38
- - type: code
39
- uri: http://github.com/rubyworks/tapout
40
- label: Source Code
41
- - type: bugs
42
- uri: http://github.com/rubyworks/tapout/issues
43
- label: Issue Tracker
44
- - type: mail
45
- uri: http://groups.google.com/rubyworks-mailinglist
46
- label: Mailing List
47
- - type: chat
48
- uri: irc://chat.us.freenode.net#rubyworks
49
- label: IRC Channel
50
- repositories:
51
- - name: upstream
52
- scm: git
53
- uri: git://github.com/rubyworks/tapout.git
54
- categories: []
55
- copyrights:
56
- - holder: Thomas Sawyer
57
- year: '2010'
58
- license: BSD-2-Clause
59
- customs: []
60
- paths:
61
- lib:
62
- - lib
63
- name: tapout
64
- title: TAPOUT
65
- summary: Progressive TAP Harness
66
- created: '2010-12-23'
67
- description: Tapout is a TAP consumer that can take any TAP, TAP-Y or TAP-J stream
68
- and output it in a variety of useful formats.
69
- version: 0.4.5
70
- date: '2013-11-20'