minitest-heat 1.2.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -52,13 +52,14 @@ module Minitest
52
52
  # @return [type] [description]
53
53
  def file_lines
54
54
  @raw_lines ||= File.readlines(filename, chomp: true)
55
- @raw_lines.pop while @raw_lines.last.strip.empty?
55
+ # Remove trailing empty lines, checking for nil/empty safely
56
+ @raw_lines.pop while @raw_lines.any? && @raw_lines.last&.strip.to_s.empty?
56
57
 
57
58
  @raw_lines
58
- rescue Errno::ENOENT
59
+ rescue Errno::ENOENT, Errno::EACCES, Errno::EISDIR, IOError, Encoding::UndefinedConversionError
59
60
  # Occasionally, for a variety of reasons, a file can't be read. In those cases, it's best to
60
61
  # return no source code lines rather than have the test suite raise an error unrelated to
61
- # the code being tested becaues that gets confusing.
62
+ # the code being tested because that gets confusing.
62
63
  []
63
64
  end
64
65
 
@@ -66,6 +66,19 @@ module Minitest
66
66
  (assertion_count / total_time).round(2)
67
67
  end
68
68
 
69
+ # Generates a hash representation for JSON serialization
70
+ #
71
+ # @return [Hash] timing data
72
+ def to_h
73
+ {
74
+ total_seconds: total_time,
75
+ test_count: test_count,
76
+ assertion_count: assertion_count,
77
+ tests_per_second: tests_per_second,
78
+ assertions_per_second: assertions_per_second
79
+ }
80
+ end
81
+
69
82
  private
70
83
 
71
84
  # The total time the test suite was running.
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Minitest
4
4
  module Heat
5
- VERSION = '1.2.0'
5
+ VERSION = '2.0.0'
6
6
  end
7
7
  end
@@ -3,6 +3,12 @@
3
3
  require_relative 'heat_reporter'
4
4
 
5
5
  module Minitest # rubocop:disable Style/Documentation
6
+ def self.plugin_heat_options(opts, options)
7
+ opts.on '--heat-json', 'Output results as JSON instead of human-readable format' do
8
+ options[:heat_json] = true
9
+ end
10
+ end
11
+
6
12
  def self.plugin_heat_init(options)
7
13
  io = options.fetch(:io, $stdout)
8
14
 
@@ -48,7 +48,9 @@ module Minitest
48
48
  def start
49
49
  timer.start!
50
50
 
51
- # A couple of blank lines to create some breathing room
51
+ # A couple of blank lines to create some breathing room (skip for JSON output)
52
+ return if json_output?
53
+
52
54
  output.newline
53
55
  output.newline
54
56
  end
@@ -72,8 +74,8 @@ module Minitest
72
74
  # Record the issue to show details later
73
75
  results.record(issue)
74
76
 
75
- # Show the marker
76
- output.marker(issue.type)
77
+ # Show the marker (skip for JSON output)
78
+ output.marker(issue.type) unless json_output?
77
79
  rescue StandardError => e
78
80
  display_exception_guidance(e)
79
81
  end
@@ -93,6 +95,45 @@ module Minitest
93
95
  def report
94
96
  timer.stop!
95
97
 
98
+ if json_output?
99
+ output_json
100
+ else
101
+ output_text
102
+ end
103
+ end
104
+
105
+ # Whether to output JSON instead of human-readable text
106
+ #
107
+ # @return [Boolean] true if --heat-json flag was passed
108
+ def json_output?
109
+ options[:heat_json]
110
+ end
111
+
112
+ # Did this run pass?
113
+ def passed?
114
+ results.errors.empty? && results.failures.empty?
115
+ end
116
+
117
+ private
118
+
119
+ def output_json
120
+ require 'json'
121
+ output.stream.puts JSON.pretty_generate(json_results)
122
+ end
123
+
124
+ def json_results
125
+ {
126
+ version: '1.0',
127
+ status: results.problems? ? 'failed' : 'passed',
128
+ timestamp: Time.now.iso8601,
129
+ statistics: results.statistics,
130
+ timing: timer.to_h,
131
+ heat_map: results.heat_map.to_h,
132
+ issues: results.issues_with_problems.map(&:to_h)
133
+ }
134
+ end
135
+
136
+ def output_text
96
137
  # The list of individual issues and their associated details
97
138
  output.issues_list(results)
98
139
 
@@ -107,10 +148,5 @@ module Minitest
107
148
  output.newline
108
149
  output.newline
109
150
  end
110
-
111
- # Did this run pass?
112
- def passed?
113
- results.errors.empty? && results.failures.empty?
114
- end
115
151
  end
116
152
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = 'Presents test results in a visual manner to guide you to where to look first.'
13
13
  spec.homepage = 'https://github.com/garrettdimon/minitest-heat'
14
14
  spec.license = 'MIT'
15
- spec.required_ruby_version = Gem::Requirement.new('>= 2.7.6')
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 3.2')
16
16
 
17
17
  spec.metadata['homepage_uri'] = spec.homepage
18
18
  spec.metadata['bug_tracker_uri'] = 'https://github.com/garrettdimon/minitest-heat/issues'
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.metadata['documentation_uri'] = 'https://www.rubydoc.info/gems/minitest-heat'
21
21
  spec.metadata['source_code_uri'] = 'https://github.com/garrettdimon/minitest-heat'
22
22
  spec.metadata['wiki_uri'] = 'https://github.com/garrettdimon/minitest-heat/wiki'
23
+ spec.metadata['rubygems_mfa_required'] = 'true'
23
24
 
24
25
  # Specify which files should be added to the gem when it is released.
25
26
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -33,10 +34,10 @@ Gem::Specification.new do |spec|
33
34
  spec.add_runtime_dependency 'minitest'
34
35
 
35
36
  spec.add_development_dependency 'awesome_print'
36
- spec.add_development_dependency 'dead_end'
37
37
  spec.add_development_dependency 'debug'
38
38
  spec.add_development_dependency 'rubocop'
39
39
  spec.add_development_dependency 'rubocop-minitest'
40
40
  spec.add_development_dependency 'rubocop-rake'
41
41
  spec.add_development_dependency 'simplecov'
42
+ spec.add_development_dependency 'simplecov_json_formatter'
42
43
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-heat
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garrett Dimon
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2022-10-31 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: minitest
@@ -39,7 +38,7 @@ dependencies:
39
38
  - !ruby/object:Gem::Version
40
39
  version: '0'
41
40
  - !ruby/object:Gem::Dependency
42
- name: dead_end
41
+ name: debug
43
42
  requirement: !ruby/object:Gem::Requirement
44
43
  requirements:
45
44
  - - ">="
@@ -53,7 +52,7 @@ dependencies:
53
52
  - !ruby/object:Gem::Version
54
53
  version: '0'
55
54
  - !ruby/object:Gem::Dependency
56
- name: debug
55
+ name: rubocop
57
56
  requirement: !ruby/object:Gem::Requirement
58
57
  requirements:
59
58
  - - ">="
@@ -67,7 +66,7 @@ dependencies:
67
66
  - !ruby/object:Gem::Version
68
67
  version: '0'
69
68
  - !ruby/object:Gem::Dependency
70
- name: rubocop
69
+ name: rubocop-minitest
71
70
  requirement: !ruby/object:Gem::Requirement
72
71
  requirements:
73
72
  - - ">="
@@ -81,7 +80,7 @@ dependencies:
81
80
  - !ruby/object:Gem::Version
82
81
  version: '0'
83
82
  - !ruby/object:Gem::Dependency
84
- name: rubocop-minitest
83
+ name: rubocop-rake
85
84
  requirement: !ruby/object:Gem::Requirement
86
85
  requirements:
87
86
  - - ">="
@@ -95,7 +94,7 @@ dependencies:
95
94
  - !ruby/object:Gem::Version
96
95
  version: '0'
97
96
  - !ruby/object:Gem::Dependency
98
- name: rubocop-rake
97
+ name: simplecov
99
98
  requirement: !ruby/object:Gem::Requirement
100
99
  requirements:
101
100
  - - ">="
@@ -109,7 +108,7 @@ dependencies:
109
108
  - !ruby/object:Gem::Version
110
109
  version: '0'
111
110
  - !ruby/object:Gem::Dependency
112
- name: simplecov
111
+ name: simplecov_json_formatter
113
112
  requirement: !ruby/object:Gem::Requirement
114
113
  requirements:
115
114
  - - ">="
@@ -132,15 +131,16 @@ extra_rdoc_files: []
132
131
  files:
133
132
  - ".github/FUNDING.yml"
134
133
  - ".github/workflows/main.yml"
134
+ - ".github/workflows/release.yml"
135
135
  - ".gitignore"
136
136
  - ".rubocop.yml"
137
- - ".travis.yml"
138
137
  - CHANGELOG.md
139
138
  - CODE_OF_CONDUCT.md
140
139
  - Gemfile
141
140
  - Gemfile.lock
142
141
  - LICENSE.txt
143
142
  - README.md
143
+ - RELEASING.md
144
144
  - Rakefile
145
145
  - bin/console
146
146
  - bin/setup
@@ -179,7 +179,7 @@ metadata:
179
179
  documentation_uri: https://www.rubydoc.info/gems/minitest-heat
180
180
  source_code_uri: https://github.com/garrettdimon/minitest-heat
181
181
  wiki_uri: https://github.com/garrettdimon/minitest-heat/wiki
182
- post_install_message:
182
+ rubygems_mfa_required: 'true'
183
183
  rdoc_options: []
184
184
  require_paths:
185
185
  - lib
@@ -187,15 +187,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
187
187
  requirements:
188
188
  - - ">="
189
189
  - !ruby/object:Gem::Version
190
- version: 2.7.6
190
+ version: '3.2'
191
191
  required_rubygems_version: !ruby/object:Gem::Requirement
192
192
  requirements:
193
193
  - - ">="
194
194
  - !ruby/object:Gem::Version
195
195
  version: '0'
196
196
  requirements: []
197
- rubygems_version: 3.3.22
198
- signing_key:
197
+ rubygems_version: 3.6.9
199
198
  specification_version: 4
200
199
  summary: Presents test results in a visual manner to guide you to where to look first.
201
200
  test_files: []
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- ---
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.7.2
6
- before_install: gem install bundler -v 2.1.4