tapout 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f06f3d6528ca8666a65d9b3b2534c69b90a1ffcc
4
+ data.tar.gz: a3cf2becce94f8281a017965750df1192d2a73dc
5
+ SHA512:
6
+ metadata.gz: 4e6d0606742ac06e568612e92d138850136f3863cc3163872c4388946e8f06118874ae3a961ac358e4ae3d2d4169a13512b2cb4b0c5220a50046834d54f88ea3
7
+ data.tar.gz: fcf37269ea2495e8138670852e7446486aedd15e1acf27476df3cadbc036b6ad5fab116f665801a2bfd3679d1ea3d50cb05f60b3546db41b9a95397d17eb0ca8
data/.index CHANGED
@@ -60,11 +60,11 @@ customs: []
60
60
  paths:
61
61
  lib:
62
62
  - lib
63
- created: '2010-12-23'
64
- summary: Progressive TAP Harness
65
- title: TAPOUT
66
- version: 0.4.2
67
63
  name: tapout
64
+ title: TAPOUT
65
+ summary: Progressive TAP Harness
66
+ created: '2010-12-23'
68
67
  description: Tapout is a TAP consumer that can take any TAP, TAP-Y or TAP-J stream
69
68
  and output it in a variety of useful formats.
70
- date: '2013-03-17'
69
+ version: 0.4.3
70
+ date: '2013-11-18'
data/HISTORY.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # RELEASE HISTORY
2
2
 
3
+ ## 0.4.3 / 2013-11-18
4
+
5
+ New feature allows producers to emit a *pause document* and
6
+ *resume document* code to halt and resume test result processing.
7
+ While processing is halted, $stdin is directed back to $stdout
8
+ uninterpreted.
9
+
10
+ Changes:
11
+
12
+ * Add support for pause and resume code.
13
+
14
+
3
15
  ## 0.4.2 / 2013-03-18
4
16
 
5
17
  This release adds support for trace depth and snippet size options.
data/README.md CHANGED
@@ -33,16 +33,17 @@ For information about TAP, see http://testanything.org/wiki/index.php/Main_Page.
33
33
 
34
34
  To use TAPOUT you need either a plugin for your current test framework, or use of
35
35
  a test framework that supports TAP-Y/J out of the box. You can find a
36
- [list of plugins here](https://https://github.com/rubyworks/tapout/wiki)
36
+ [list of plugins here](https://github.com/rubyworks/tapout/wiki)
37
37
  under the section "Producers".
38
38
 
39
- Using a test framework that produces a TAP-Y output stream, simply pipe
40
- the stream into `tapout`.
39
+ With a test framework that produces a TAP-Y/J output stream in hand pipe the
40
+ output stream into the `tapout` command by using a standard command line pipe.
41
41
 
42
42
  $ rubytest -y -Ilib test/foo.rb | tapout
43
43
 
44
- TAPOUT supports a variety of output formats. These are selectable via the
45
- first argument. The default if not given, as in the example above, is `dot`.
44
+ TAPOUT supports a variety of output formats. The default is the common
45
+ dot-progress format (simply called `dot`). Other formats are selectable
46
+ via the `tapout` command's first argument.
46
47
 
47
48
  $ rubytest -y -Ilib test/foo.rb | tapout progessbar
48
49
 
@@ -57,12 +58,49 @@ To see a list of supported formats use the list subcommand:
57
58
 
58
59
  $ tapout --help
59
60
 
60
- If your test framework does not support TAP-Y, but does support traditional
61
- TAP, TAPOUT will automatically recognize the difference by TAP's `1..N` header.
61
+ If your test framework does not support TAP-Y/J, but does support traditional
62
+ TAP, TAPOUT will automatically recognize the difference by TAP's `1..N` header
63
+ and automatically translate it.
62
64
 
63
65
  $ rubytest -ftap -Ilib test/foo.rb | tapout progressbar
64
66
 
65
67
 
68
+ ## Bypassing
69
+
70
+ Since tapout receives test results via a pipe, it has no direct control over
71
+ the producer, i.e the test runner. If you need to tell tapout to stop processing
72
+ the output then you can send a *PAUSE DOCUMENT* code. Likewise you can restart
73
+ processing by sending a *RESUME DOCUMENT* code. These codes are taken
74
+ from ASCII codes for DLE (Data Link Escape) and ETB (End of Transmission Block),
75
+ respectively. When tapout receives a *PAUSE DOCUMENT* code, it stops interpreting
76
+ any data it receives as test results and instead just routes `$stdin` back
77
+ to `$stdout` unmodified.
78
+
79
+ A good example of this is debugging with Pry using `binding.pry`.
80
+
81
+ def test_something
82
+ STDOUT.puts 16.chr # tells tapout to pause processing
83
+ binding.pry
84
+ STDOUT.puts 23.char # tells tapout to start again
85
+ assert somthing
86
+ end
87
+
88
+ As it turns out, if your are using TAP-Y (not TAP-J) then you can also
89
+ use YAML's *END DOCUMENT* and *NEW DOCUMENT* markers to acheive the
90
+ same effect.
91
+
92
+ def test_something
93
+ STDOUT.puts "..." # tells tapout to pause processing
94
+ binding.pry
95
+ STDOUT.puts "---" # tells tapout to start again
96
+ assert somthing
97
+ end
98
+
99
+ But remember that **only works for YAML**!
100
+
101
+ Note: when sending these codes, be sure to send a newline character as well.
102
+
103
+
66
104
  ## Legal
67
105
 
68
106
  Copyright (c) 2010 Rubyworks
@@ -65,7 +65,7 @@ status: pass
65
65
  label: test_passing
66
66
  time: 1.04997403
67
67
  ---
68
- type: tally
68
+ type: final
69
69
  time: 1.000800203
70
70
  counts:
71
71
  total: 3
@@ -0,0 +1,27 @@
1
+ require 'tapout/reporters'
2
+
3
+ module Tapout
4
+
5
+ class AbstractParser
6
+
7
+ # ASCII DLE (Data Link Escape)
8
+ PAUSE_DOCUMENT = 16.chr + "\n" #"...\n"
9
+
10
+ # ASCII ETB (End of Transmission Block)
11
+ RESUME_DOCUMENT = 23.chr + "\n" #"---\n"
12
+
13
+ # Passthru incoming data directly to `$stdout`.
14
+ #
15
+ def passthru(doc=nil)
16
+ $stdout << doc if doc
17
+ while line = @input.gets
18
+ return line if line == RESUME_DOCUMENT
19
+ $stdout << line
20
+ end
21
+ return ''
22
+ end
23
+
24
+ end
25
+
26
+ end
27
+
@@ -1,3 +1,4 @@
1
+ require 'tapout/parsers/abstract'
1
2
  require 'tapout/reporters'
2
3
  require 'json'
3
4
 
@@ -6,34 +7,57 @@ module Tapout
6
7
  # The TAP-J Parser takes a TAP-J stream and routes it through
7
8
  # a Tapout report format.
8
9
  #
9
- class JsonParser
10
+ class JsonParser < AbstractParser
10
11
 
11
12
  #
12
13
  def initialize(options={})
13
14
  format = options[:format]
14
15
  @reporter = Reporters.factory(format).new
16
+ @input = options[:input] || $stdin
15
17
  end
16
18
 
19
+ # Read from input using `gets` and parse, routing entries to reporter.
17
20
  #
18
- def consume(input)
21
+ # input - Input channel, defaults to $stdin. [#gets]
22
+ #
23
+ # Returns reporter exit code.
24
+ def consume(input=nil)
25
+ @input = input if input
26
+
19
27
  while line = input.gets
20
- self << line
28
+ case line
29
+ when PAUSE_DOCUMENT
30
+ passthru
31
+ when RESUME_DOCUMENT # has no effect here
32
+ else
33
+ handle(line)
34
+ end
21
35
  end
36
+
22
37
  @reporter.finalize
23
38
  end
24
39
 
25
- #
26
- def <<(line)
27
- handle(line)
28
- end
40
+ # Alias for consume.
41
+ alias read consume
29
42
 
43
+ # Handle document entry.
30
44
  #
31
- def handle(doc)
32
- return if doc == ''
33
- entry = JSON.load(doc)
34
- @reporter << entry
45
+ # Returns nothing.
46
+ def handle(entry)
47
+ return if entry.empty?
48
+ return if entry == RESUME_DOCUMENT
49
+
50
+ begin
51
+ data = JSON.load(entry)
52
+ @reporter << data
53
+ rescue JSON::ParserError
54
+ passthru(entry)
55
+ end
35
56
  end
36
57
 
58
+ # Alias for handle.
59
+ alias << handle
60
+
37
61
  end
38
62
 
39
63
  end
@@ -1,12 +1,13 @@
1
1
  require 'tapout/version'
2
2
  require 'tapout/adapters/perl'
3
3
  require 'tapout/reporters'
4
+ require 'tapout/parsers/abstract'
4
5
 
5
6
  module Tapout
6
7
 
7
- # The TAPLegacy Parser takes a traditional TAP stream and routes
8
- # it through a Tap Out report format.
9
- class PerlParser
8
+ # This legacy parser takes a traditional TAP stream and routes
9
+ # it through a Tapout report format.
10
+ class PerlParser < AbstractParser
10
11
 
11
12
  # options[:format] - the report format to use
12
13
  def initialize(options={})
@@ -1,59 +1,76 @@
1
+ require 'tapout/parsers/abstract'
1
2
  require 'tapout/reporters'
2
3
  require 'yaml'
3
4
 
4
5
  module Tapout
5
6
 
6
7
  # The TAP-Y Parser takes a TAP-Y stream and routes it through
7
- # a Tapout report format.
8
+ # a tapout report format.
8
9
  #
9
- class YamlParser
10
+ class YamlParser < AbstractParser
11
+
12
+ NEW_DOCUMENT = /^\-\-\-/
13
+ END_DOCUMENT = /^\.\.\.\s*$/
10
14
 
11
15
  #
12
16
  def initialize(options={})
13
17
  format = options[:format]
14
18
  @reporter = Reporters.factory(format).new
15
- @doc = ''
16
- @done = false
19
+ @input = options[:input] || $stdin
17
20
  end
18
21
 
22
+ # Read from input using `gets` and parse, routing
23
+ # entries to reporter.
19
24
  #
20
- def consume(input)
21
- @doc = ''
22
- @done = false
23
- while line = input.gets
24
- self << line
25
- end
26
- handle unless @done # in case `...` was left out
27
- return @reporter.exit_code
28
- end
25
+ # input - Input channel, defaults to $stdin. [#gets]
26
+ #
27
+ # Returns reporter exit code.
28
+ def consume(input=nil)
29
+ @input = input if input
29
30
 
30
- # TODO: write this as a YAML stream parser
31
- def <<(line)
32
- case line
33
- when /^\-\-\-/
34
- handle #@doc
35
- @doc << line
36
- when /^\.\.\./
37
- handle #@doc
38
- stop
39
- else
40
- @doc << line
31
+ entry = ''
32
+ while line = @input.gets
33
+ case line
34
+ when PAUSE_DOCUMENT
35
+ passthru
36
+ when RESUME_DOCUMENT # (no effect)
37
+ when END_DOCUMENT
38
+ handle(entry)
39
+ entry = passthru
40
+ when NEW_DOCUMENT
41
+ handle(entry)
42
+ entry = line
43
+ else
44
+ entry << line
45
+ end
41
46
  end
42
- end
47
+ handle(entry) # in case final `...` was left out
43
48
 
44
- #
45
- def handle
46
- return if @doc == ''
47
- entry = YAML.load(@doc)
48
- @reporter << entry
49
- @doc = ''
49
+ @reporter.finalize #@reporter.exit_code
50
50
  end
51
51
 
52
+ # Alias for consume.
53
+ alias read consume
54
+
55
+ # Handle document entry.
52
56
  #
53
- def stop
54
- @done = true
57
+ # Returns nothing.
58
+ def handle(entry)
59
+ return if entry.empty?
60
+ return if entry == NEW_DOCUMENT
61
+ return if entry == RESUME_DOCUMENT
62
+
63
+ begin
64
+ data = YAML.load(entry)
65
+ @reporter << data
66
+ rescue Psych::SyntaxError
67
+ passthru(entry)
68
+ end
55
69
  end
56
70
 
71
+ # Alias for handle.
72
+ alias << handle
73
+
57
74
  end
58
75
 
59
76
  end
@@ -77,7 +77,7 @@ module Tapout::Reporters
77
77
 
78
78
  time, rate, avg = time_tally(entry)
79
79
 
80
- total, pass, fail, error, todo, omit = count_tally(entry)
80
+ # total, pass, fail, error, todo, omit = count_tally(entry)
81
81
 
82
82
  #total = @passed.size + @failed.size + @raised.size + @skipped.size + @omitted.size
83
83
  #total = entry['counts']['total'] || total
@@ -89,7 +89,7 @@ module Tapout::Reporters
89
89
  puts
90
90
  puts "Finished in %.3fs (%.3f test/s, %.6fs avg.)" % [time, rate, avg]
91
91
  puts
92
- puts "%s tests: %s pass, %s fail, %s exit, %s todo, %s omit" % [total, pass, fail, error, todo, omit]
92
+ puts tally_message(entry)
93
93
  end
94
94
 
95
95
  end
metadata CHANGED
@@ -1,94 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tapout
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
5
- prerelease:
4
+ version: 0.4.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Thomas Sawyer
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-18 00:00:00.000000000 Z
11
+ date: 2013-11-18 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: ansi
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: json
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: ergo
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: qed
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: ae
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  description: Tapout is a TAP consumer that can take any TAP, TAP-Y or TAP-J stream
@@ -100,9 +89,9 @@ executables:
100
89
  extensions: []
101
90
  extra_rdoc_files:
102
91
  - COPYING.md
103
- - HISTORY.md
104
92
  - README.md
105
93
  - TAP-YJ.md
94
+ - HISTORY.md
106
95
  files:
107
96
  - .index
108
97
  - .yardopts
@@ -119,6 +108,7 @@ files:
119
108
  - lib/tapout/cli.rb
120
109
  - lib/tapout/config.rb
121
110
  - lib/tapout/core_ext.rb
111
+ - lib/tapout/parsers/abstract.rb
122
112
  - lib/tapout/parsers/json.rb
123
113
  - lib/tapout/parsers/perl.rb
124
114
  - lib/tapout/parsers/yaml.rb
@@ -138,33 +128,31 @@ files:
138
128
  - lib/tapout/version.rb
139
129
  - lib/tapout.rb
140
130
  - COPYING.md
141
- - HISTORY.md
142
131
  - README.md
143
132
  - TAP-YJ.md
133
+ - HISTORY.md
144
134
  homepage: http://rubyworks.github.com/tapout
145
135
  licenses:
146
136
  - BSD-2-Clause
137
+ metadata: {}
147
138
  post_install_message:
148
139
  rdoc_options: []
149
140
  require_paths:
150
141
  - lib
151
142
  required_ruby_version: !ruby/object:Gem::Requirement
152
- none: false
153
143
  requirements:
154
- - - ! '>='
144
+ - - '>='
155
145
  - !ruby/object:Gem::Version
156
146
  version: '0'
157
147
  required_rubygems_version: !ruby/object:Gem::Requirement
158
- none: false
159
148
  requirements:
160
- - - ! '>='
149
+ - - '>='
161
150
  - !ruby/object:Gem::Version
162
151
  version: '0'
163
152
  requirements: []
164
153
  rubyforge_project:
165
- rubygems_version: 1.8.24
154
+ rubygems_version: 2.0.3
166
155
  signing_key:
167
- specification_version: 3
156
+ specification_version: 4
168
157
  summary: Progressive TAP Harness
169
158
  test_files: []
170
- has_rdoc: