minitest-failure-reporter 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/ruby.yml +33 -0
- data/.gitignore +11 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +24 -0
- data/LICENSE.txt +21 -0
- data/README.md +56 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/dev.yml +14 -0
- data/lib/minitest/failure_reporter/version.rb +5 -0
- data/lib/minitest/failure_reporter_plugin.rb +22 -0
- data/lib/minitest/failure_reporter_reporter.rb +67 -0
- data/minitest-failure_reporter.gemspec +34 -0
- metadata +115 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6e1e7d1744ab09ea7c43e7b0917a86033a1221e2ba2363219fe5c40477db3e8f
|
4
|
+
data.tar.gz: fd4abe0fb346cbfbce80efbfa990f1c30b7904fa8747cc4bd7a7e089adc9cd28
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c192329a14482959975d601c100107abcbfcaf2ef2f7198c29647368f640007d06cacfba82dd68970a610ab942526a84119df671f44a0e9659ade149e0a4abc4
|
7
|
+
data.tar.gz: 7a0ad5c78445975a264899f0a0ac00fa2a734b586a40187d9f26345d63ec0139a92767cfa24edc889afe3c75e99d188924a6f37243ef6ab6b5355e697062b3fa
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ master ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ master ]
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
test:
|
18
|
+
|
19
|
+
runs-on: ubuntu-latest
|
20
|
+
|
21
|
+
steps:
|
22
|
+
- uses: actions/checkout@v2
|
23
|
+
- name: Set up Ruby
|
24
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
25
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
26
|
+
# uses: ruby/setup-ruby@v1
|
27
|
+
uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
|
28
|
+
with:
|
29
|
+
ruby-version: 2.6
|
30
|
+
- name: Install dependencies
|
31
|
+
run: bundle install
|
32
|
+
- name: Run tests
|
33
|
+
run: bundle exec rake
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
minitest-failure-reporter (0.1.0)
|
5
|
+
minitest (~> 5.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
byebug (11.1.3)
|
11
|
+
minitest (5.14.1)
|
12
|
+
rake (12.3.3)
|
13
|
+
|
14
|
+
PLATFORMS
|
15
|
+
ruby
|
16
|
+
|
17
|
+
DEPENDENCIES
|
18
|
+
bundler (~> 2.1)
|
19
|
+
byebug
|
20
|
+
minitest-failure-reporter!
|
21
|
+
rake (~> 12.3)
|
22
|
+
|
23
|
+
BUNDLED WITH
|
24
|
+
2.1.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Frederik Dudzik
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# Minitest::FailureReporter
|
2
|
+
|
3
|
+
Generates a json file that includes test failures and is compatible with ci-queue's failure file.
|
4
|
+
|
5
|
+
The format of the file looks as follows:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
[{
|
9
|
+
test_file: String,
|
10
|
+
test_line: Int,
|
11
|
+
test_and_module_name: String,
|
12
|
+
test_name: String,
|
13
|
+
test_suite: String,
|
14
|
+
error_class: String,
|
15
|
+
error_message: String,
|
16
|
+
output: String,
|
17
|
+
}]
|
18
|
+
```
|
19
|
+
|
20
|
+
## Installation
|
21
|
+
|
22
|
+
Add this line to your application's Gemfile:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
gem 'minitest_failure-reporter'
|
26
|
+
```
|
27
|
+
|
28
|
+
And then execute:
|
29
|
+
|
30
|
+
$ bundle install
|
31
|
+
|
32
|
+
Or install it yourself as:
|
33
|
+
|
34
|
+
$ gem install minitest_failure-reporter
|
35
|
+
|
36
|
+
## Usage
|
37
|
+
|
38
|
+
```
|
39
|
+
--failure-reporter # Generate a failure json report
|
40
|
+
--failure-reporter-filename=OUT # Target output filename. Defaults to failure_file.json
|
41
|
+
```
|
42
|
+
|
43
|
+
## Development
|
44
|
+
|
45
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
46
|
+
|
47
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Shopify/minitest_failure-reporter.
|
52
|
+
|
53
|
+
|
54
|
+
## License
|
55
|
+
|
56
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "minitest_failure/reporter"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/dev.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require "minitest/failure_reporter/version"
|
2
|
+
require "minitest/failure_reporter_reporter"
|
3
|
+
|
4
|
+
module Minitest
|
5
|
+
def self.plugin_failure_reporter_options(opts, options)
|
6
|
+
opts.on '--failure-reporter', 'Generate a failure json report' do
|
7
|
+
options[:failure_reporter] = true
|
8
|
+
end
|
9
|
+
opts.on '--failure-reporter-filename=OUT', 'Target output filename.'\
|
10
|
+
' Defaults to failure_file.json' do |out|
|
11
|
+
options[:failure_reporter_filename] = out
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.plugin_failure_reporter_init(options)
|
16
|
+
return unless options.delete :failure_reporter
|
17
|
+
file_klass = options.delete(:file_klass) || File
|
18
|
+
filename = options.delete(:failure_reporter_filename) || 'failure_file.json'
|
19
|
+
io = file_klass.new(filename, 'w')
|
20
|
+
reporter << FailureReporter::Reporter.new(io, options)
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Minitest
|
4
|
+
module FailureReporter
|
5
|
+
class Reporter
|
6
|
+
def initialize(io, options)
|
7
|
+
@io = io
|
8
|
+
@results = []
|
9
|
+
@options = options
|
10
|
+
end
|
11
|
+
|
12
|
+
def passed?
|
13
|
+
true
|
14
|
+
end
|
15
|
+
|
16
|
+
def start; end
|
17
|
+
|
18
|
+
def record(result)
|
19
|
+
if has_failures?(result)
|
20
|
+
@results << result
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def report
|
25
|
+
failures = @results.map { |test| format(test) }.to_json
|
26
|
+
@io.puts(failures)
|
27
|
+
end
|
28
|
+
|
29
|
+
def format(test)
|
30
|
+
test_file, test_line = test.source_location
|
31
|
+
{
|
32
|
+
test_file: test_file,
|
33
|
+
test_line: test_line,
|
34
|
+
test_and_module_name: "#{test.klass}##{test.name}",
|
35
|
+
test_name: test.name,
|
36
|
+
test_suite: test.klass,
|
37
|
+
error_class: test.failure.exception.class.name,
|
38
|
+
error_message: full_error_message(test),
|
39
|
+
output: full_error_message(test),
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def has_failures?(test)
|
46
|
+
!test.failures.empty? || test.error?
|
47
|
+
end
|
48
|
+
|
49
|
+
def full_error_message(test)
|
50
|
+
[message(test), *backtrace(test)].join("\n")
|
51
|
+
end
|
52
|
+
|
53
|
+
def message(test)
|
54
|
+
error = test.failure
|
55
|
+
if error.is_a?(UnexpectedError)
|
56
|
+
"#{error.exception.class}: #{error.exception.message}"
|
57
|
+
else
|
58
|
+
error.exception.message
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def backtrace(test)
|
63
|
+
test.failure.backtrace.join("\n")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require_relative 'lib/minitest/failure_reporter/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "minitest-failure-reporter"
|
5
|
+
spec.version = Minitest::FailureReporter::VERSION
|
6
|
+
spec.authors = ["Frederik Dudzik"]
|
7
|
+
spec.email = ["frederik.dudzik@shopify.com"]
|
8
|
+
|
9
|
+
spec.summary = "Writes a json file with all test failures to disk"
|
10
|
+
spec.description = "Writes a json file with all test failures to disk"
|
11
|
+
spec.homepage = "https://github.com/Shopify/minitest-failure_reporter"
|
12
|
+
spec.license = "MIT"
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
|
+
|
15
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
19
|
+
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
+
end
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
spec.add_dependency 'minitest', '~> 5.0'
|
30
|
+
|
31
|
+
spec.add_development_dependency("bundler", "~> 2.1")
|
32
|
+
spec.add_development_dependency("rake", "~> 12.3")
|
33
|
+
spec.add_development_dependency("byebug", "~> 11.1")
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: minitest-failure-reporter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Frederik Dudzik
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-07-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: minitest
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.1'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '12.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '12.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: byebug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '11.1'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '11.1'
|
69
|
+
description: Writes a json file with all test failures to disk
|
70
|
+
email:
|
71
|
+
- frederik.dudzik@shopify.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".github/workflows/ruby.yml"
|
77
|
+
- ".gitignore"
|
78
|
+
- Gemfile
|
79
|
+
- Gemfile.lock
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- bin/setup
|
85
|
+
- dev.yml
|
86
|
+
- lib/minitest/failure_reporter/version.rb
|
87
|
+
- lib/minitest/failure_reporter_plugin.rb
|
88
|
+
- lib/minitest/failure_reporter_reporter.rb
|
89
|
+
- minitest-failure_reporter.gemspec
|
90
|
+
homepage: https://github.com/Shopify/minitest-failure_reporter
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata:
|
94
|
+
homepage_uri: https://github.com/Shopify/minitest-failure_reporter
|
95
|
+
source_code_uri: https://github.com/Shopify/minitest-failure_reporter
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 2.3.0
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubygems_version: 3.1.2
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Writes a json file with all test failures to disk
|
115
|
+
test_files: []
|