minitest-reporters 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -2
- data/lib/minitest/{backtrace_filter.rb → extensible_backtrace_filter.rb} +2 -2
- data/lib/minitest/reporter.rb +4 -0
- data/lib/minitest/reporters.rb +25 -4
- data/lib/minitest/reporters/default_reporter.rb +35 -43
- data/lib/minitest/reporters/junit_reporter.rb +3 -4
- data/lib/minitest/reporters/progress_reporter.rb +3 -10
- data/lib/minitest/reporters/ruby_mate_reporter.rb +2 -6
- data/lib/minitest/reporters/rubymine_reporter.rb +1 -1
- data/lib/minitest/reporters/spec_reporter.rb +2 -6
- data/lib/minitest/reporters/version.rb +1 -1
- data/minitest-reporters.gemspec +1 -1
- data/test/unit/minitest/{backtrace_filter_test.rb → extensible_backtrace_filter_test.rb} +3 -3
- metadata +7 -7
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
# minitest-reporters - create customizable MiniTest output formats [![Build Status](
|
1
|
+
# minitest-reporters - create customizable MiniTest output formats [![Build Status](https://secure.travis-ci.org/CapnKernul/minitest-reporters.png)](http://travis-ci.org/CapnKernul/minitest-reporters)
|
2
|
+
|
2
3
|
|
3
4
|
Death to haphazard monkey-patching! Extend MiniTest through simple hooks.
|
4
5
|
|
@@ -25,7 +26,7 @@ Want to use multiple reporters?
|
|
25
26
|
|
26
27
|
The following reporters are provided:
|
27
28
|
|
28
|
-
MiniTest::Reporters::DefaultReporter # =>
|
29
|
+
MiniTest::Reporters::DefaultReporter # => Redgreen version of standard MiniTest reporter
|
29
30
|
MiniTest::Reporters::SpecReporter # => Turn-like output that reads like a spec
|
30
31
|
MiniTest::Reporters::ProgressReporter # => Fuubar-like output with a progress bar
|
31
32
|
MiniTest::Reporters::RubyMateReporter # => Simple reporter designed for RubyMate
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module MiniTest
|
2
2
|
# Filters backtraces of exceptions that may arise when running tests.
|
3
|
-
class
|
3
|
+
class ExtensibleBacktraceFilter
|
4
4
|
# Returns the default filter.
|
5
5
|
#
|
6
6
|
# The default filter will filter out all MiniTest and minitest-reporters
|
7
7
|
# lines.
|
8
8
|
#
|
9
|
-
# @return [MiniTest::
|
9
|
+
# @return [MiniTest::ExtensibleBacktraceFilter]
|
10
10
|
def self.default_filter
|
11
11
|
unless defined? @default_filter
|
12
12
|
filter = self.new
|
data/lib/minitest/reporter.rb
CHANGED
data/lib/minitest/reporters.rb
CHANGED
@@ -5,7 +5,7 @@ module MiniTest
|
|
5
5
|
require "minitest/reporter_runner"
|
6
6
|
require "minitest/before_test_hook"
|
7
7
|
require "minitest/test_runner"
|
8
|
-
require "minitest/
|
8
|
+
require "minitest/extensible_backtrace_filter"
|
9
9
|
|
10
10
|
module Reporters
|
11
11
|
require "minitest/reporters/version"
|
@@ -18,14 +18,19 @@ module MiniTest
|
|
18
18
|
autoload :GuardReporter, "minitest/reporters/guard_reporter"
|
19
19
|
autoload :JUnitReporter, "minitest/reporters/junit_reporter"
|
20
20
|
|
21
|
-
def self.use!(console_reporters = ProgressReporter.new, env = ENV)
|
22
|
-
|
21
|
+
def self.use!(console_reporters = ProgressReporter.new, env = ENV, backtrace_filter = ExtensibleBacktraceFilter.default_filter)
|
22
|
+
use_runner!(console_reporters, env)
|
23
|
+
use_before_test_hook!
|
24
|
+
use_backtrace_filter!(backtrace_filter)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.use_runner!(console_reporters, env)
|
23
28
|
runner = ReporterRunner.new
|
24
29
|
runner.reporters = choose_reporters(console_reporters, env)
|
25
30
|
Unit.runner = runner
|
26
31
|
end
|
27
32
|
|
28
|
-
def self.
|
33
|
+
def self.use_before_test_hook!
|
29
34
|
if Unit::VERSION >= "3.3.0"
|
30
35
|
Unit::TestCase.send(:include, BeforeTestHook)
|
31
36
|
else
|
@@ -35,6 +40,22 @@ module MiniTest
|
|
35
40
|
end
|
36
41
|
end
|
37
42
|
|
43
|
+
def self.use_backtrace_filter!(backtrace_filter)
|
44
|
+
if Unit::VERSION < "4.1.0"
|
45
|
+
MiniTest.class_eval do
|
46
|
+
class << self
|
47
|
+
attr_accessor :backtrace_filter
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.filter_backtrace(backtrace)
|
51
|
+
backtrace_filter.filter(backtrace)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
MiniTest.backtrace_filter = backtrace_filter
|
57
|
+
end
|
58
|
+
|
38
59
|
def self.choose_reporters(console_reporters, env)
|
39
60
|
if env["TM_PID"]
|
40
61
|
[RubyMateReporter.new]
|
@@ -1,8 +1,9 @@
|
|
1
|
-
require 'ansi'
|
1
|
+
require 'ansi/code'
|
2
2
|
|
3
3
|
module MiniTest
|
4
4
|
module Reporters
|
5
|
-
# A reporter identical to the standard MiniTest reporter
|
5
|
+
# A reporter identical to the standard MiniTest reporter except with more
|
6
|
+
# colors.
|
6
7
|
#
|
7
8
|
# Based upon Ryan Davis of Seattle.rb's MiniTest (MIT License).
|
8
9
|
#
|
@@ -11,21 +12,13 @@ module MiniTest
|
|
11
12
|
include Reporter
|
12
13
|
|
13
14
|
def initialize(options = {})
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
ENV["EMACS"] == "t"
|
22
|
-
)
|
23
|
-
end
|
24
|
-
else
|
25
|
-
warn "Please use :backtrace_filter => filter instead of passing in the filter directly."
|
26
|
-
@backtrace_filter = options
|
27
|
-
@detailed_skip = true
|
28
|
-
@color = false
|
15
|
+
@detailed_skip = options.fetch(:detailed_skip, true)
|
16
|
+
@color = options.fetch(:color) do
|
17
|
+
output.tty? && (
|
18
|
+
ENV["TERM"] == "screen" ||
|
19
|
+
ENV["TERM"] =~ /term(?:-(?:256)?color)?\z/ ||
|
20
|
+
ENV["EMACS"] == "t"
|
21
|
+
)
|
29
22
|
end
|
30
23
|
end
|
31
24
|
|
@@ -40,71 +33,70 @@ module MiniTest
|
|
40
33
|
end
|
41
34
|
|
42
35
|
def pass(suite, test, test_runner)
|
43
|
-
after_test(green
|
36
|
+
after_test(green('.'))
|
44
37
|
end
|
45
38
|
|
46
39
|
def skip(suite, test, test_runner)
|
47
|
-
after_test(yellow
|
40
|
+
after_test(yellow('S'))
|
48
41
|
end
|
49
42
|
|
50
43
|
def failure(suite, test, test_runner)
|
51
|
-
after_test(red
|
44
|
+
after_test(red('F'))
|
52
45
|
end
|
53
46
|
|
54
47
|
def error(suite, test, test_runner)
|
55
|
-
after_test(red
|
48
|
+
after_test(red('E'))
|
56
49
|
end
|
57
50
|
|
58
51
|
def after_suites(suites, type)
|
59
52
|
time = Time.now - runner.suites_start_time
|
60
|
-
status_line =
|
61
|
-
|
62
|
-
[type, time, runner.test_count / time, runner.assertion_count / time]
|
63
|
-
end
|
53
|
+
status_line = "Finished %ss in %.6fs, %.4f tests/s, %.4f assertions/s." %
|
54
|
+
[type, time, runner.test_count / time, runner.assertion_count / time]
|
64
55
|
|
65
56
|
puts
|
66
57
|
puts
|
67
|
-
puts status_line
|
58
|
+
puts colored_for(suite_result, status_line)
|
68
59
|
|
69
60
|
runner.test_results.each do |suite, tests|
|
70
61
|
tests.each do |test, test_runner|
|
71
62
|
if message = message_for(test_runner)
|
72
63
|
puts
|
73
|
-
print
|
64
|
+
print colored_for(test_runner.result, message)
|
74
65
|
end
|
75
66
|
end
|
76
67
|
end
|
77
68
|
|
78
69
|
puts
|
79
|
-
puts
|
70
|
+
puts colored_for(suite_result, result_line)
|
80
71
|
end
|
81
72
|
|
82
73
|
private
|
83
74
|
|
84
|
-
def green(
|
85
|
-
@color ? ANSI::Code.green(
|
75
|
+
def green(string)
|
76
|
+
@color ? ANSI::Code.green(string) : string
|
86
77
|
end
|
87
78
|
|
88
|
-
def yellow(
|
89
|
-
@color ? ANSI::Code.yellow(
|
79
|
+
def yellow(string)
|
80
|
+
@color ? ANSI::Code.yellow(string) : string
|
90
81
|
end
|
91
82
|
|
92
|
-
def red(
|
93
|
-
@color ? ANSI::Code.red(
|
83
|
+
def red(string)
|
84
|
+
@color ? ANSI::Code.red(string) : string
|
94
85
|
end
|
95
86
|
|
96
|
-
def colored_for(result,
|
87
|
+
def colored_for(result, string)
|
97
88
|
case result
|
98
|
-
when :failure, :error; red(
|
99
|
-
when :skip; yellow(
|
100
|
-
else green(
|
89
|
+
when :failure, :error; red(string)
|
90
|
+
when :skip; yellow(string)
|
91
|
+
else green(string)
|
101
92
|
end
|
102
93
|
end
|
103
94
|
|
104
95
|
def suite_result
|
105
|
-
|
106
|
-
|
107
|
-
|
96
|
+
case
|
97
|
+
when runner.failures > 0; :failure
|
98
|
+
when runner.errors > 0; :error
|
99
|
+
when runner.skips > 0; :skip
|
108
100
|
else :pass
|
109
101
|
end
|
110
102
|
end
|
@@ -141,12 +133,12 @@ module MiniTest
|
|
141
133
|
end
|
142
134
|
when :failure then "Failure:\n#{test}(#{suite}) [#{location(e)}]:\n#{e.message}\n"
|
143
135
|
when :error
|
144
|
-
bt =
|
136
|
+
bt = filter_backtrace(test_runner.exception.backtrace).join "\n "
|
145
137
|
"Error:\n#{test}(#{suite}):\n#{e.class}: #{e.message}\n #{bt}\n"
|
146
138
|
end
|
147
139
|
end
|
148
140
|
|
149
|
-
def
|
141
|
+
def result_line
|
150
142
|
'%d tests, %d assertions, %d failures, %d errors, %d skips' %
|
151
143
|
[runner.test_count, runner.assertion_count, runner.failures, runner.errors, runner.skips]
|
152
144
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'ansi'
|
1
|
+
require 'ansi/code'
|
2
2
|
require 'builder'
|
3
3
|
require 'fileutils'
|
4
4
|
module MiniTest
|
@@ -12,8 +12,7 @@ module MiniTest
|
|
12
12
|
class JUnitReporter
|
13
13
|
include Reporter
|
14
14
|
|
15
|
-
def initialize(reports_dir = "test/reports"
|
16
|
-
@backtrace_filter = backtrace_filter
|
15
|
+
def initialize(reports_dir = "test/reports")
|
17
16
|
@reports_path = File.join(Dir.getwd, reports_dir)
|
18
17
|
puts "Emptying #{@reports_path}"
|
19
18
|
FileUtils.remove_dir(@reports_path) if File.exists?(@reports_path)
|
@@ -74,7 +73,7 @@ module MiniTest
|
|
74
73
|
when :skip then "Skipped:\n#{test}(#{suite}) [#{location(e)}]:\n#{e.message}\n"
|
75
74
|
when :failure then "Failure:\n#{test}(#{suite}) [#{location(e)}]:\n#{e.message}\n"
|
76
75
|
when :error
|
77
|
-
bt =
|
76
|
+
bt = filter_backtrace(test_runner.exception.backtrace).join "\n "
|
78
77
|
"Error:\n#{test}(#{suite}):\n#{e.class}: #{e.message}\n #{bt}\n"
|
79
78
|
end
|
80
79
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'ansi'
|
1
|
+
require 'ansi/code'
|
2
2
|
require 'powerbar'
|
3
3
|
|
4
4
|
module MiniTest
|
@@ -17,14 +17,7 @@ module MiniTest
|
|
17
17
|
INFO_PADDING = 2
|
18
18
|
|
19
19
|
def initialize(options = {})
|
20
|
-
|
21
|
-
@backtrace_filter = options.fetch(:backtrace_filter, BacktraceFilter.default_filter)
|
22
|
-
@detailed_skip = options.fetch(:detailed_skip, true)
|
23
|
-
else
|
24
|
-
warn "Please use :backtrace_filter => filter instead of passing in the filter directly."
|
25
|
-
@backtrace_filter = options
|
26
|
-
@detailed_skip = true
|
27
|
-
end
|
20
|
+
@detailed_skip = options.fetch(:detailed_skip, true)
|
28
21
|
|
29
22
|
@progress = PowerBar.new(:msg => "0/#{runner.test_count}")
|
30
23
|
@progress.settings.tty.finite.output = lambda { |s| print(s) }
|
@@ -119,7 +112,7 @@ module MiniTest
|
|
119
112
|
def print_info(e)
|
120
113
|
e.message.each_line { |line| puts pad(line) }
|
121
114
|
|
122
|
-
trace =
|
115
|
+
trace = filter_backtrace(e.backtrace)
|
123
116
|
trace.each { |line| puts pad(line) }
|
124
117
|
end
|
125
118
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'ansi'
|
1
|
+
require 'ansi/code'
|
2
2
|
|
3
3
|
module MiniTest
|
4
4
|
module Reporters
|
@@ -8,10 +8,6 @@ module MiniTest
|
|
8
8
|
|
9
9
|
INFO_PADDING = 2
|
10
10
|
|
11
|
-
def initialize(backtrace_filter = BacktraceFilter.default_filter)
|
12
|
-
@backtrace_filter = backtrace_filter
|
13
|
-
end
|
14
|
-
|
15
11
|
def before_suites(suites, type)
|
16
12
|
puts 'Started'
|
17
13
|
puts
|
@@ -61,7 +57,7 @@ module MiniTest
|
|
61
57
|
def print_info(e)
|
62
58
|
e.message.each_line { |line| puts pad(line) }
|
63
59
|
|
64
|
-
trace =
|
60
|
+
trace = filter_backtrace(e.backtrace)
|
65
61
|
trace.each { |line| puts pad(line) }
|
66
62
|
end
|
67
63
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Test results reporter for RubyMine IDE (http://www.jetbrains.com/ruby/) and
|
2
2
|
# TeamCity(http://www.jetbrains.com/teamcity/) Continuous Integration Server
|
3
3
|
|
4
|
-
require
|
4
|
+
require 'ansi/code'
|
5
5
|
begin
|
6
6
|
require 'teamcity/runner_common'
|
7
7
|
require 'teamcity/utils/service_message_factory'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'ansi'
|
1
|
+
require 'ansi/code'
|
2
2
|
|
3
3
|
module MiniTest
|
4
4
|
module Reporters
|
@@ -17,10 +17,6 @@ module MiniTest
|
|
17
17
|
MARK_SIZE = 5
|
18
18
|
INFO_PADDING = 8
|
19
19
|
|
20
|
-
def initialize(backtrace_filter = BacktraceFilter.default_filter)
|
21
|
-
@backtrace_filter = backtrace_filter
|
22
|
-
end
|
23
|
-
|
24
20
|
def before_suites(suites, type)
|
25
21
|
puts 'Started'
|
26
22
|
puts
|
@@ -86,7 +82,7 @@ module MiniTest
|
|
86
82
|
def print_info(e)
|
87
83
|
e.message.each_line { |line| puts pad(line, INFO_PADDING) }
|
88
84
|
|
89
|
-
trace =
|
85
|
+
trace = filter_backtrace(e.backtrace)
|
90
86
|
trace.each { |line| puts pad(line, INFO_PADDING) }
|
91
87
|
end
|
92
88
|
|
data/minitest-reporters.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
|
|
14
14
|
|
15
15
|
s.rubyforge_project = 'minitest-reporters'
|
16
16
|
|
17
|
-
s.add_dependency 'minitest', '>= 2.12', '<
|
17
|
+
s.add_dependency 'minitest', '>= 2.12', '< 5.0'
|
18
18
|
s.add_dependency 'ansi'
|
19
19
|
s.add_dependency 'powerbar'
|
20
20
|
s.add_dependency 'builder'
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require_relative "../../test_helper"
|
2
2
|
|
3
3
|
module MiniTestReportersTest
|
4
|
-
class
|
4
|
+
class ExtensibleBacktraceFilterTest < TestCase
|
5
5
|
def setup
|
6
|
-
@default_filter = MiniTest::
|
7
|
-
@filter = MiniTest::
|
6
|
+
@default_filter = MiniTest::ExtensibleBacktraceFilter.default_filter
|
7
|
+
@filter = MiniTest::ExtensibleBacktraceFilter.new
|
8
8
|
@backtrace = ["foo", "bar", "baz"]
|
9
9
|
end
|
10
10
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest-reporters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '2.12'
|
22
22
|
- - <
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: '
|
24
|
+
version: '5.0'
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
27
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '2.12'
|
33
33
|
- - <
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: '
|
35
|
+
version: '5.0'
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: ansi
|
38
38
|
requirement: !ruby/object:Gem::Requirement
|
@@ -143,8 +143,8 @@ files:
|
|
143
143
|
- LICENSE
|
144
144
|
- README.md
|
145
145
|
- Rakefile
|
146
|
-
- lib/minitest/backtrace_filter.rb
|
147
146
|
- lib/minitest/before_test_hook.rb
|
147
|
+
- lib/minitest/extensible_backtrace_filter.rb
|
148
148
|
- lib/minitest/reporter.rb
|
149
149
|
- lib/minitest/reporter_runner.rb
|
150
150
|
- lib/minitest/reporters.rb
|
@@ -161,7 +161,7 @@ files:
|
|
161
161
|
- test/gallery/bad_test.rb
|
162
162
|
- test/gallery/good_test.rb
|
163
163
|
- test/test_helper.rb
|
164
|
-
- test/unit/minitest/
|
164
|
+
- test/unit/minitest/extensible_backtrace_filter_test.rb
|
165
165
|
- test/unit/minitest/reporter_test.rb
|
166
166
|
- test/unit/minitest/reporters_test.rb
|
167
167
|
homepage: https://github.com/CapnKernul/minitest-reporters
|
@@ -192,7 +192,7 @@ test_files:
|
|
192
192
|
- test/gallery/bad_test.rb
|
193
193
|
- test/gallery/good_test.rb
|
194
194
|
- test/test_helper.rb
|
195
|
-
- test/unit/minitest/
|
195
|
+
- test/unit/minitest/extensible_backtrace_filter_test.rb
|
196
196
|
- test/unit/minitest/reporter_test.rb
|
197
197
|
- test/unit/minitest/reporters_test.rb
|
198
198
|
has_rdoc:
|