Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# RELEASE HISTORY

## Unreleased

Changes:

* Fix the TAP-Y and TAP-J reporters, which raised NoMethodError
("undefined method 'file' for nil") for a failed, errored or pending test
whose exception had no backtrace line outside the test framework. Lemon
marks a test pending that way when it doesn't call the method it covers.
The run then ended early with wrong counts. The record now has the
exception's message without a source location.

## 0.11.0 / 2026-11-17

The Rake task and the HTML reporter are back in Rubytest, so rubytest-rake
Expand Down
20 changes: 20 additions & 0 deletions demo/05_builtin_reporters.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,26 @@ YAML documents, TAP-J a line of JSON for each record.
records.count { |record| record['type'] == 'case' && !record['status'] }.assert == 2
end

An exception may have no line of backtrace outside the test framework, as
when a framework marks a test pending itself. Its record then has the message
without a source location.

bare = probe_type.new('bare') do
error = NotImplementedError.new('not tested')
error.set_backtrace([])
raise error
end

readers.each do |format, read|
success, output, report = render.call(format, [bare, passing])
records = read.call(output)
records.last['counts']['total'].assert == 2
record = records.find { |r| r['label'] == 'bare' }
record['status'].assert == 'todo'
record['exception']['message'].assert == 'not tested'
record['exception'].key?('file').assert == false
end

A TAP-Y stream ends with the YAML end-of-document marker.

render.call('tapy')[1].lines.last.chomp.assert == '...'
Expand Down
12 changes: 8 additions & 4 deletions lib/rubytest/format/abstract_hash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,14 @@ def merge_source(hash, test)
# Add exception subsection of hash.
def merge_exception(hash, test, exception, bt=false)
hash['exception'] = {}
hash['exception']['file' ] = code(exception).file
hash['exception']['line' ] = code(exception).line
hash['exception']['source' ] = code(exception).to_str
hash['exception']['snippet' ] = code(exception).to_omap
# There is no snippet when every line of the backtrace belongs to
# the test framework, or the exception has none.
if snippet = code(exception)
hash['exception']['file' ] = snippet.file
hash['exception']['line' ] = snippet.line
hash['exception']['source' ] = snippet.to_str
hash['exception']['snippet' ] = snippet.to_omap
end
hash['exception']['message' ] = exception.message
hash['exception']['backtrace'] = clean_backtrace(exception) if bt
if @current_result && @current_result.exceptions.size > 1
Expand Down
Loading