@@ -73,3 +73,46 @@ number actually recorded, including the broken and skipped cases.
7373 lines.grep(/# TODO /).size.assert == 1
7474 lines.grep(/\A# stdout: ok 999 - injected/).size.assert == 1
7575 lines.grep(/\Anot ok \d+ - broken case/).size.assert == 1
76+
77+ TAP-Y and TAP-J carry the same results as structured records: one for the
78+ suite, one for each case and test, and a final tally. TAP-Y is a stream of
79+ YAML documents, TAP-J a line of JSON for each record.
80+
81+ require 'yaml'
82+ require 'json'
83+
84+ readers = {
85+ 'tapy' => lambda { |text| YAML.load_stream(text) },
86+ 'tapj' => lambda { |text| text.lines.map { |line| JSON.parse(line) } }
87+ }
88+
89+ readers.each do |format, read|
90+ success, output, report = render.call(format)
91+ success.assert == false
92+ records = read.call(output)
93+
94+ records.first['type'].assert == 'suite'
95+ records.first['rev'].assert == 5
96+ records.last['type'].assert == 'final'
97+ records.last['counts']['total'].assert == report.total
98+ records.last['counts']['omit'].assert == 2
99+
100+ results = records.select { |record| record['status'] }
101+ results.size.assert == report.total
102+ results.map { |record| record['status'] }.sort.assert == %w[error fail omit omit pass todo]
103+ results.select { |record| record['status'] == 'omit' }.map { |record| record['type'] }.sort.assert == %w[case test]
104+ records.count { |record| record['type'] == 'case' && !record['status'] }.assert == 2
105+ end
106+
107+ A TAP-Y stream ends with the YAML end-of-document marker.
108+
109+ render.call('tapy')[1].lines.last.chomp.assert == '...'
110+
111+ The command line has a shortcut for each.
112+
113+ require 'rubytest/cli'
114+ { '-y' => 'tapy', '--tapj' => 'tapj' }.each do |flag, format|
115+ cli = Test::CLI.new
116+ cli.options.parse!([flag])
117+ cli.format.assert == format
118+ end
0 commit comments