-
Notifications
You must be signed in to change notification settings - Fork 33
Improve test summary output for rspec and minitest
#361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| # frozen_string_literal: true | ||
| module RSpec | ||
| module Queue | ||
| class ErrorReport | ||
| class << self | ||
| attr_accessor :coder | ||
|
|
||
| def load(payload) | ||
| new(coder.load(payload)) | ||
| end | ||
| end | ||
|
|
||
| # Default to Marshal | ||
| self.coder = Marshal | ||
|
|
||
| # Try to use SnappyPack if available from consumer's bundle | ||
| begin | ||
| require 'snappy' | ||
| require 'msgpack' | ||
| require 'stringio' | ||
|
|
||
| module SnappyPack | ||
| extend self | ||
|
|
||
| MSGPACK = MessagePack::Factory.new | ||
| MSGPACK.register_type(0x00, Symbol) | ||
|
|
||
| def load(payload) | ||
| io = StringIO.new(Snappy.inflate(payload)) | ||
| MSGPACK.unpacker(io).unpack | ||
| end | ||
|
|
||
| def dump(object) | ||
| io = StringIO.new | ||
| packer = MSGPACK.packer(io) | ||
| packer.pack(object) | ||
| packer.flush | ||
| io.rewind | ||
| Snappy.deflate(io.string).force_encoding(Encoding::UTF_8) | ||
| end | ||
| end | ||
|
|
||
| self.coder = SnappyPack | ||
| rescue LoadError | ||
| end | ||
|
|
||
| def initialize(data) | ||
| @data = data | ||
| end | ||
|
|
||
| def dump | ||
| self.class.coder.dump(@data) | ||
| end | ||
|
|
||
| def test_name | ||
| @data[:test_name] | ||
| end | ||
|
|
||
| def error_class | ||
| @data[:error_class] | ||
| end | ||
|
|
||
| def test_and_module_name | ||
| @data[:test_and_module_name] | ||
| end | ||
|
|
||
| def test_suite | ||
| @data[:test_suite] | ||
| end | ||
|
|
||
| def test_file | ||
| @data[:test_file] | ||
| end | ||
|
|
||
| def test_line | ||
| @data[:test_line] | ||
| end | ||
|
|
||
| def to_h | ||
| @data | ||
| end | ||
|
|
||
| def to_s | ||
| output | ||
| end | ||
|
|
||
| def output | ||
| @data[:output] | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| # frozen_string_literal: true | ||
| require 'delegate' | ||
| require 'ci/queue/output_helpers' | ||
|
|
||
| module RSpec | ||
| module Queue | ||
| class FailureFormatter < SimpleDelegator | ||
| include ::CI::Queue::OutputHelpers | ||
|
|
||
| def initialize(notification) | ||
| @notification = notification | ||
| super | ||
| end | ||
|
|
||
| def to_s | ||
| [ | ||
| @notification.fully_formatted(nil), | ||
| colorized_rerun_command(@notification.example) | ||
| ].join("\n") | ||
| end | ||
|
Comment on lines
+17
to
+20
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is a breakdown from an existing build on where these are located |
||
|
|
||
| def to_h | ||
| example = @notification.example | ||
| { | ||
| test_file: example.file_path, | ||
| test_line: example.metadata[:line_number], | ||
| test_and_module_name: example.id, | ||
| test_name: example.description, | ||
| test_suite: example.example_group.description, | ||
| error_class: @notification.exception.class.name, | ||
| output: to_s, | ||
| } | ||
| end | ||
|
|
||
| private | ||
|
|
||
| attr_reader :notification | ||
|
|
||
| def colorized_rerun_command(example, colorizer=::RSpec::Core::Formatters::ConsoleCodes) | ||
| colorizer.wrap("rspec #{example.location_rerun_argument}", RSpec.configuration.failure_color) + " " + | ||
| colorizer.wrap("# #{example.full_description}", RSpec.configuration.detail_color) | ||
| end | ||
| end | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved into
failure_formatter.rb