minitest-reporters 1.3.6 → 1.3.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +28 -27
  3. data/.rubocop.yml +77 -77
  4. data/.ruby-gemset +1 -1
  5. data/.travis.yml +14 -14
  6. data/.yardopts +5 -5
  7. data/CHANGELOG.md +98 -93
  8. data/Gemfile +2 -2
  9. data/LICENSE +20 -20
  10. data/README.md +135 -135
  11. data/Rakefile +70 -70
  12. data/appveyor.yml +22 -22
  13. data/lib/minitest/extensible_backtrace_filter.rb +67 -67
  14. data/lib/minitest/minitest_reporter_plugin.rb +76 -76
  15. data/lib/minitest/old_activesupport_fix.rb +24 -24
  16. data/lib/minitest/relative_position.rb +26 -26
  17. data/lib/minitest/reporters.rb +91 -91
  18. data/lib/minitest/reporters/ansi.rb +30 -30
  19. data/lib/minitest/reporters/base_reporter.rb +136 -136
  20. data/lib/minitest/reporters/default_reporter.rb +228 -228
  21. data/lib/minitest/reporters/html_reporter.rb +224 -224
  22. data/lib/minitest/reporters/junit_reporter.rb +168 -164
  23. data/lib/minitest/reporters/mean_time_reporter.rb +388 -388
  24. data/lib/minitest/reporters/progress_reporter.rb +102 -96
  25. data/lib/minitest/reporters/ruby_mate_reporter.rb +54 -54
  26. data/lib/minitest/reporters/rubymine_reporter.rb +116 -116
  27. data/lib/minitest/reporters/spec_reporter.rb +61 -61
  28. data/lib/minitest/reporters/version.rb +5 -5
  29. data/lib/minitest/templates/index.html.erb +82 -82
  30. data/minitest-reporters.gemspec +31 -32
  31. data/test/fixtures/junit_filename_bug_example_test.rb +41 -41
  32. data/test/fixtures/mean_time_test.rb +36 -36
  33. data/test/fixtures/progress_detailed_skip_test.rb +8 -8
  34. data/test/fixtures/progress_test.rb +8 -8
  35. data/test/fixtures/sample_test.rb +15 -15
  36. data/test/fixtures/spec_test.rb +18 -18
  37. data/test/gallery/bad_test.rb +25 -25
  38. data/test/gallery/good_test.rb +14 -14
  39. data/test/integration/reporters/junit_reporter_test.rb +12 -12
  40. data/test/integration/reporters/mean_time_reporter_test.rb +7 -7
  41. data/test/integration/reporters/progress_reporter_test.rb +40 -40
  42. data/test/test_helper.rb +22 -22
  43. data/test/unit/minitest/extensible_backtrace_filter_test.rb +42 -42
  44. data/test/unit/minitest/junit_reporter_test.rb +46 -23
  45. data/test/unit/minitest/mean_time_reporter_unit_test.rb +149 -149
  46. data/test/unit/minitest/minitest_reporter_plugin_test.rb +14 -14
  47. data/test/unit/minitest/reporters_test.rb +65 -65
  48. data/test/unit/minitest/spec_reporter_test.rb +62 -62
  49. metadata +22 -5
@@ -1,22 +1,22 @@
1
- ---
2
- version: '#{build}'
3
- cache:
4
- - vendor/bundle
5
- environment:
6
- matrix:
7
- - RUBY_VERSION: 25-x64
8
- - RUBY_VERSION: 24-x64
9
-
10
- install:
11
- - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
12
- - bundle install
13
-
14
- build: off
15
-
16
- before_test:
17
- - ruby -v
18
- - gem -v
19
- - bundle -v
20
-
21
- test_script:
22
- - bundle exec rake test
1
+ ---
2
+ version: '#{build}'
3
+ cache:
4
+ - vendor/bundle
5
+ environment:
6
+ matrix:
7
+ - RUBY_VERSION: 25-x64
8
+ - RUBY_VERSION: 24-x64
9
+
10
+ install:
11
+ - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
12
+ - bundle install
13
+
14
+ build: off
15
+
16
+ before_test:
17
+ - ruby -v
18
+ - gem -v
19
+ - bundle -v
20
+
21
+ test_script:
22
+ - bundle exec rake test
@@ -1,67 +1,67 @@
1
- module Minitest
2
- # Filters backtraces of exceptions that may arise when running tests.
3
- class ExtensibleBacktraceFilter
4
- # Returns the default filter.
5
- #
6
- # The default filter will filter out all Minitest and minitest-reporters
7
- # lines.
8
- #
9
- # @return [Minitest::ExtensibleBacktraceFilter]
10
- def self.default_filter
11
- unless defined? @default_filter
12
- filter = self.new
13
- filter.add_filter(/lib\/minitest/)
14
- @default_filter = filter
15
- end
16
-
17
- @default_filter
18
- end
19
-
20
- # Creates a new backtrace filter.
21
- def initialize
22
- @filters = []
23
- end
24
-
25
- # Adds a filter.
26
- #
27
- # @param [Regex] regex the filter
28
- def add_filter(regex)
29
- @filters << regex
30
- end
31
-
32
- # Determines if the string would be filtered.
33
- #
34
- # @param [String] str
35
- # @return [Boolean]
36
- def filters?(str)
37
- @filters.any? { |filter| str =~ filter }
38
- end
39
-
40
- # Filters a backtrace.
41
- #
42
- # This will add new lines to the new backtrace until a filtered line is
43
- # encountered. If there were lines added to the new backtrace, it returns
44
- # those lines. However, if the first line in the backtrace was filtered,
45
- # resulting in an empty backtrace, it returns all lines that would have
46
- # been unfiltered. If that in turn does not contain any lines, it returns
47
- # the original backtrace.
48
- #
49
- # @param [Array] backtrace the backtrace to filter
50
- # @return [Array] the filtered backtrace
51
- # @note This logic is based off of Minitest's #filter_backtrace.
52
- def filter(backtrace)
53
- result = []
54
- return result unless backtrace
55
-
56
- backtrace.each do |line|
57
- break if filters?(line)
58
- result << line
59
- end
60
-
61
- result = backtrace.reject { |line| filters?(line) } if result.empty?
62
- result = backtrace.dup if result.empty?
63
-
64
- result
65
- end
66
- end
67
- end
1
+ module Minitest
2
+ # Filters backtraces of exceptions that may arise when running tests.
3
+ class ExtensibleBacktraceFilter
4
+ # Returns the default filter.
5
+ #
6
+ # The default filter will filter out all Minitest and minitest-reporters
7
+ # lines.
8
+ #
9
+ # @return [Minitest::ExtensibleBacktraceFilter]
10
+ def self.default_filter
11
+ unless defined? @default_filter
12
+ filter = self.new
13
+ filter.add_filter(/lib\/minitest/)
14
+ @default_filter = filter
15
+ end
16
+
17
+ @default_filter
18
+ end
19
+
20
+ # Creates a new backtrace filter.
21
+ def initialize
22
+ @filters = []
23
+ end
24
+
25
+ # Adds a filter.
26
+ #
27
+ # @param [Regex] regex the filter
28
+ def add_filter(regex)
29
+ @filters << regex
30
+ end
31
+
32
+ # Determines if the string would be filtered.
33
+ #
34
+ # @param [String] str
35
+ # @return [Boolean]
36
+ def filters?(str)
37
+ @filters.any? { |filter| str =~ filter }
38
+ end
39
+
40
+ # Filters a backtrace.
41
+ #
42
+ # This will add new lines to the new backtrace until a filtered line is
43
+ # encountered. If there were lines added to the new backtrace, it returns
44
+ # those lines. However, if the first line in the backtrace was filtered,
45
+ # resulting in an empty backtrace, it returns all lines that would have
46
+ # been unfiltered. If that in turn does not contain any lines, it returns
47
+ # the original backtrace.
48
+ #
49
+ # @param [Array] backtrace the backtrace to filter
50
+ # @return [Array] the filtered backtrace
51
+ # @note This logic is based off of Minitest's #filter_backtrace.
52
+ def filter(backtrace)
53
+ result = []
54
+ return result unless backtrace
55
+
56
+ backtrace.each do |line|
57
+ break if filters?(line)
58
+ result << line
59
+ end
60
+
61
+ result = backtrace.reject { |line| filters?(line) } if result.empty?
62
+ result = backtrace.dup if result.empty?
63
+
64
+ result
65
+ end
66
+ end
67
+ end
@@ -1,76 +1,76 @@
1
- module Minitest
2
- module Reporters
3
- class DelegateReporter < Minitest::AbstractReporter
4
- def initialize(reporters, options = {})
5
- @reporters = reporters
6
- @options = options
7
- @all_reporters = nil
8
- end
9
-
10
- def io
11
- all_reporters.first.io unless all_reporters.empty?
12
- @options[:io]
13
- end
14
-
15
- def start
16
- all_reporters.each(&:start)
17
- end
18
-
19
- def record(result)
20
- all_reporters.each do |reporter|
21
- reporter.record result
22
- end
23
- end
24
-
25
- def report
26
- all_reporters.each(&:report)
27
- end
28
-
29
- def passed?
30
- all_reporters.all?(&:passed?)
31
- end
32
-
33
- private
34
-
35
- # stolen from minitest self.run
36
- def total_count(options)
37
- filter = options[:filter] || '/./'
38
- filter = Regexp.new $1 if filter =~ /\/(.*)\//
39
-
40
- Minitest::Runnable.runnables.map { |runnable|
41
- runnable.runnable_methods.find_all { |m|
42
- filter === m || filter === "#{runnable}##{m}"
43
- }.size
44
- }.inject(:+)
45
- end
46
-
47
- def all_reporters
48
- @all_reporters ||= init_all_reporters
49
- end
50
-
51
- def init_all_reporters
52
- return @reporters unless defined?(Minitest::Reporters.reporters) && Minitest::Reporters.reporters
53
- (Minitest::Reporters.reporters + guard_reporter(@reporters)).each do |reporter|
54
- reporter.io = @options[:io]
55
- if reporter.respond_to?(:add_defaults)
56
- reporter.add_defaults(@options.merge(:total_count => total_count(@options)))
57
- end
58
- end
59
- end
60
-
61
- def guard_reporter(reporters)
62
- guards = Array(reporters.detect { |r| r.class.name == "Guard::Minitest::Reporter" })
63
- return guards unless ENV['RM_INFO']
64
-
65
- warn 'RM_INFO is set thus guard reporter has been dropped' unless guards.empty?
66
- []
67
- end
68
- end
69
- end
70
-
71
- class << self
72
- def plugin_minitest_reporter_init(options)
73
- reporter.reporters = [Minitest::Reporters::DelegateReporter.new(reporter.reporters, options)]
74
- end
75
- end
76
- end
1
+ module Minitest
2
+ module Reporters
3
+ class DelegateReporter < Minitest::AbstractReporter
4
+ def initialize(reporters, options = {})
5
+ @reporters = reporters
6
+ @options = options
7
+ @all_reporters = nil
8
+ end
9
+
10
+ def io
11
+ all_reporters.first.io unless all_reporters.empty?
12
+ @options[:io]
13
+ end
14
+
15
+ def start
16
+ all_reporters.each(&:start)
17
+ end
18
+
19
+ def record(result)
20
+ all_reporters.each do |reporter|
21
+ reporter.record result
22
+ end
23
+ end
24
+
25
+ def report
26
+ all_reporters.each(&:report)
27
+ end
28
+
29
+ def passed?
30
+ all_reporters.all?(&:passed?)
31
+ end
32
+
33
+ private
34
+
35
+ # stolen from minitest self.run
36
+ def total_count(options)
37
+ filter = options[:filter] || '/./'
38
+ filter = Regexp.new $1 if filter =~ /\/(.*)\//
39
+
40
+ Minitest::Runnable.runnables.map { |runnable|
41
+ runnable.runnable_methods.find_all { |m|
42
+ filter === m || filter === "#{runnable}##{m}"
43
+ }.size
44
+ }.inject(:+)
45
+ end
46
+
47
+ def all_reporters
48
+ @all_reporters ||= init_all_reporters
49
+ end
50
+
51
+ def init_all_reporters
52
+ return @reporters unless defined?(Minitest::Reporters.reporters) && Minitest::Reporters.reporters
53
+ (Minitest::Reporters.reporters + guard_reporter(@reporters)).each do |reporter|
54
+ reporter.io = @options[:io]
55
+ if reporter.respond_to?(:add_defaults)
56
+ reporter.add_defaults(@options.merge(:total_count => total_count(@options)))
57
+ end
58
+ end
59
+ end
60
+
61
+ def guard_reporter(reporters)
62
+ guards = Array(reporters.detect { |r| r.class.name == "Guard::Minitest::Reporter" })
63
+ return guards unless ENV['RM_INFO']
64
+
65
+ warn 'RM_INFO is set thus guard reporter has been dropped' unless guards.empty?
66
+ []
67
+ end
68
+ end
69
+ end
70
+
71
+ class << self
72
+ def plugin_minitest_reporter_init(options)
73
+ reporter.reporters = [Minitest::Reporters::DelegateReporter.new(reporter.reporters, options)]
74
+ end
75
+ end
76
+ end
@@ -1,24 +1,24 @@
1
- require "active_support/testing/setup_and_teardown"
2
-
3
- module ActiveSupport
4
- module Testing
5
- module SetupAndTeardown
6
- if defined?(ForMinitest)
7
- ForMiniTest = ForMinitest
8
- end
9
- module ForMiniTest
10
- remove_method :run
11
-
12
- def before_setup
13
- super
14
- run_callbacks :setup
15
- end
16
-
17
- def after_teardown
18
- run_callbacks :teardown
19
- super
20
- end
21
- end
22
- end
23
- end
24
- end
1
+ require "active_support/testing/setup_and_teardown"
2
+
3
+ module ActiveSupport
4
+ module Testing
5
+ module SetupAndTeardown
6
+ if defined?(ForMinitest)
7
+ ForMiniTest = ForMinitest
8
+ end
9
+ module ForMiniTest
10
+ remove_method :run
11
+
12
+ def before_setup
13
+ super
14
+ run_callbacks :setup
15
+ end
16
+
17
+ def after_teardown
18
+ run_callbacks :teardown
19
+ super
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,26 +1,26 @@
1
- module Minitest
2
- module RelativePosition
3
- TEST_PADDING = 2
4
- TEST_SIZE = 63
5
- MARK_SIZE = 5
6
- INFO_PADDING = 8
7
-
8
- private
9
-
10
- def print_with_info_padding(line)
11
- puts pad(line, INFO_PADDING)
12
- end
13
-
14
- def pad(str, size = INFO_PADDING)
15
- ' ' * size + str
16
- end
17
-
18
- def pad_mark(str)
19
- "%#{MARK_SIZE}s" % str
20
- end
21
-
22
- def pad_test(str)
23
- pad("%-#{TEST_SIZE}s" % str, TEST_PADDING)
24
- end
25
- end
26
- end
1
+ module Minitest
2
+ module RelativePosition
3
+ TEST_PADDING = 2
4
+ TEST_SIZE = 63
5
+ MARK_SIZE = 5
6
+ INFO_PADDING = 8
7
+
8
+ private
9
+
10
+ def print_with_info_padding(line)
11
+ puts pad(line, INFO_PADDING)
12
+ end
13
+
14
+ def pad(str, size = INFO_PADDING)
15
+ ' ' * size + str
16
+ end
17
+
18
+ def pad_mark(str)
19
+ "%#{MARK_SIZE}s" % str
20
+ end
21
+
22
+ def pad_test(str)
23
+ pad("%-#{TEST_SIZE}s" % str, TEST_PADDING)
24
+ end
25
+ end
26
+ end
@@ -1,91 +1,91 @@
1
- require 'minitest'
2
-
3
- module Minitest
4
- require "minitest/relative_position"
5
- require "minitest/extensible_backtrace_filter"
6
-
7
- module Reporters
8
- require "minitest/reporters/version"
9
-
10
- autoload :ANSI, "minitest/reporters/ansi"
11
- autoload :BaseReporter, "minitest/reporters/base_reporter"
12
- autoload :DefaultReporter, "minitest/reporters/default_reporter"
13
- autoload :SpecReporter, "minitest/reporters/spec_reporter"
14
- autoload :ProgressReporter, "minitest/reporters/progress_reporter"
15
- autoload :RubyMateReporter, "minitest/reporters/ruby_mate_reporter"
16
- autoload :RubyMineReporter, "minitest/reporters/rubymine_reporter"
17
- autoload :JUnitReporter, "minitest/reporters/junit_reporter"
18
- autoload :HtmlReporter, "minitest/reporters/html_reporter"
19
- autoload :MeanTimeReporter, "minitest/reporters/mean_time_reporter"
20
-
21
- class << self
22
- attr_accessor :reporters
23
- end
24
-
25
- def self.use!(console_reporters = ProgressReporter.new, env = ENV, backtrace_filter = nil)
26
- use_runner!(console_reporters, env)
27
- if backtrace_filter.nil? && !defined?(::Rails)
28
- backtrace_filter = ExtensibleBacktraceFilter.default_filter
29
- end
30
- Minitest.backtrace_filter = backtrace_filter unless backtrace_filter.nil?
31
-
32
- unless defined?(@@loaded)
33
- use_around_test_hooks!
34
- use_old_activesupport_fix!
35
- @@loaded = true
36
- end
37
- end
38
-
39
- def self.use_runner!(console_reporters, env)
40
- self.reporters = choose_reporters(console_reporters, env)
41
- end
42
-
43
- def self.use_around_test_hooks!
44
- Minitest::Test.class_eval do
45
- def run_with_hooks(*args)
46
- if defined?(Minitest::Reporters) && (reporters = Minitest::Reporters.reporters)
47
- reporters.each { |r| r.before_test(self) }
48
- result = run_without_hooks(*args)
49
- reporters.each { |r| r.after_test(self) }
50
- result
51
- else
52
- run_without_hooks(*args)
53
- end
54
- end
55
-
56
- alias_method :run_without_hooks, :run
57
- alias_method :run, :run_with_hooks
58
- end
59
- end
60
-
61
- def self.choose_reporters(console_reporters, env)
62
- if env["MINITEST_REPORTER"]
63
- [Minitest::Reporters.const_get(env["MINITEST_REPORTER"]).new]
64
- elsif env["TM_PID"]
65
- [RubyMateReporter.new]
66
- elsif env["RM_INFO"] || env["TEAMCITY_VERSION"]
67
- [RubyMineReporter.new]
68
- elsif !env["VIM"]
69
- Array(console_reporters)
70
- end
71
- end
72
-
73
- def self.clock_time
74
- if minitest_version >= 561
75
- Minitest.clock_time
76
- else
77
- Time.now
78
- end
79
- end
80
-
81
- def self.minitest_version
82
- Minitest::VERSION.delete('.').to_i
83
- end
84
-
85
- def self.use_old_activesupport_fix!
86
- if defined?(ActiveSupport::VERSION) && ActiveSupport::VERSION::MAJOR < 4
87
- require "minitest/old_activesupport_fix"
88
- end
89
- end
90
- end
91
- end
1
+ require 'minitest'
2
+
3
+ module Minitest
4
+ require "minitest/relative_position"
5
+ require "minitest/extensible_backtrace_filter"
6
+
7
+ module Reporters
8
+ require "minitest/reporters/version"
9
+
10
+ autoload :ANSI, "minitest/reporters/ansi"
11
+ autoload :BaseReporter, "minitest/reporters/base_reporter"
12
+ autoload :DefaultReporter, "minitest/reporters/default_reporter"
13
+ autoload :SpecReporter, "minitest/reporters/spec_reporter"
14
+ autoload :ProgressReporter, "minitest/reporters/progress_reporter"
15
+ autoload :RubyMateReporter, "minitest/reporters/ruby_mate_reporter"
16
+ autoload :RubyMineReporter, "minitest/reporters/rubymine_reporter"
17
+ autoload :JUnitReporter, "minitest/reporters/junit_reporter"
18
+ autoload :HtmlReporter, "minitest/reporters/html_reporter"
19
+ autoload :MeanTimeReporter, "minitest/reporters/mean_time_reporter"
20
+
21
+ class << self
22
+ attr_accessor :reporters
23
+ end
24
+
25
+ def self.use!(console_reporters = ProgressReporter.new, env = ENV, backtrace_filter = nil)
26
+ use_runner!(console_reporters, env)
27
+ if backtrace_filter.nil? && !defined?(::Rails)
28
+ backtrace_filter = ExtensibleBacktraceFilter.default_filter
29
+ end
30
+ Minitest.backtrace_filter = backtrace_filter unless backtrace_filter.nil?
31
+
32
+ unless defined?(@@loaded)
33
+ use_around_test_hooks!
34
+ use_old_activesupport_fix!
35
+ @@loaded = true
36
+ end
37
+ end
38
+
39
+ def self.use_runner!(console_reporters, env)
40
+ self.reporters = choose_reporters(console_reporters, env)
41
+ end
42
+
43
+ def self.use_around_test_hooks!
44
+ Minitest::Test.class_eval do
45
+ def run_with_hooks(*args)
46
+ if defined?(Minitest::Reporters) && (reporters = Minitest::Reporters.reporters)
47
+ reporters.each { |r| r.before_test(self) }
48
+ result = run_without_hooks(*args)
49
+ reporters.each { |r| r.after_test(self) }
50
+ result
51
+ else
52
+ run_without_hooks(*args)
53
+ end
54
+ end
55
+
56
+ alias_method :run_without_hooks, :run
57
+ alias_method :run, :run_with_hooks
58
+ end
59
+ end
60
+
61
+ def self.choose_reporters(console_reporters, env)
62
+ if env["MINITEST_REPORTER"]
63
+ [Minitest::Reporters.const_get(env["MINITEST_REPORTER"]).new]
64
+ elsif env["TM_PID"]
65
+ [RubyMateReporter.new]
66
+ elsif env["RM_INFO"] || env["TEAMCITY_VERSION"]
67
+ [RubyMineReporter.new]
68
+ elsif !env["VIM"]
69
+ Array(console_reporters)
70
+ end
71
+ end
72
+
73
+ def self.clock_time
74
+ if minitest_version >= 561
75
+ Minitest.clock_time
76
+ else
77
+ Time.now
78
+ end
79
+ end
80
+
81
+ def self.minitest_version
82
+ Minitest::VERSION.delete('.').to_i
83
+ end
84
+
85
+ def self.use_old_activesupport_fix!
86
+ if defined?(ActiveSupport::VERSION) && ActiveSupport::VERSION::MAJOR < 4
87
+ require "minitest/old_activesupport_fix"
88
+ end
89
+ end
90
+ end
91
+ end