megatest 0.9.1 → 0.10.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 343b3947cb15e7fcbbc9f95c16a23f4cfca526e3e9c3ee2005b3c75a383731cb
4
- data.tar.gz: 69d445b2f37ea466a08b96b797fff337cf2717127874df4b9cdbaa3775d77d33
3
+ metadata.gz: 7faf3a2246db60ac65637b81ebd4e9dcc89bcf92b632c5a1034b5871c149e79f
4
+ data.tar.gz: 2313f464b0e13b6b468461f971b439a1ef2531465bb21514b7bb8fd76aaa5098
5
5
  SHA512:
6
- metadata.gz: 9a9a3ab8fbbd173ed4ce104fef0a2a56cdcf3ffc2594893ea3712dfe94ca26c77bc8d110d7654372821fe96c99cf1cb37376248e6595efa3188f331ada5fd67d
7
- data.tar.gz: 46863ff6e30e92b18b057c59c4dc77d1769d6578de16cee5ac7adf389d967ad0d7ca3fbdd4596d72783b0b2b907914e54215c5c0e50df397b42f21cbd994abc0
6
+ metadata.gz: 9a1c9fd82548391e403aeb33ed7d6083546923e9d785a91772ba7b1d2290aec50303d0fceaff27a33442a13b4242995b84d130d72921bfabf41c098bc668b55a
7
+ data.tar.gz: 8f1bb1f7795c35dbd65698e6f979889f30f0ad96e3e768b340ea1484171f14cb11777135dab9d89972d772f18f27105b25b5699bb834afe15eb30bc976751e7d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.10.0] - 2026-05-09
4
+
5
+ - Improve reporting when running in Buildkite.
6
+
3
7
  ## [0.9.1] - 2026-05-09
4
8
 
5
9
  - `Config#seed=` noop if argument is `nil`.
data/lib/megatest/cli.rb CHANGED
@@ -165,7 +165,7 @@ module Megatest
165
165
 
166
166
  if @junit != false
167
167
  junit_file = open_file(@junit || "log/junit.xml")
168
- reporters << Reporters::JUnitReporter.new(@config, Megatest::Output.new(junit_file, colors: true))
168
+ reporters << Reporters::JUnitReporter.new(@config, Megatest::Output.new(@config, junit_file, colors: true))
169
169
  end
170
170
 
171
171
  reporters
@@ -181,7 +181,7 @@ module Megatest
181
181
  end
182
182
 
183
183
  def bisect_queue(queue, failing_test_id)
184
- err = Output.new(@err)
184
+ err = Output.new(@config, @err)
185
185
  tests = queue.to_a
186
186
  failing_test_index = tests.index { |test| test.id == failing_test_id }
187
187
  failing_test = tests[failing_test_index]
@@ -67,6 +67,7 @@ module Megatest
67
67
  config.build_id = env["BUILDKITE_BUILD_ID"]
68
68
  config.worker_id = env["BUILDKITE_PARALLEL_JOB"]
69
69
  config.workers_count = env["BUILDKITE_PARALLEL_JOB_COUNT"]
70
+ config.output_profile = :buildkite
70
71
  config.seed = env["BUILDKITE_COMMIT"]&.first(4)&.to_i(16)
71
72
  end
72
73
  end
@@ -137,7 +138,8 @@ module Megatest
137
138
 
138
139
  class Config
139
140
  attr_accessor :queue_url, :retry_tolerance, :max_retries, :job_index, :load_paths, :deprecations,
140
- :build_id, :heartbeat_frequency, :minitest_compatibility, :ci, :selectors
141
+ :build_id, :heartbeat_frequency, :minitest_compatibility, :ci, :selectors,
142
+ :output_profile
141
143
  attr_reader :before_fork_callbacks, :global_setup_callbacks, :backtrace, :circuit_breaker, :seed,
142
144
  :worker_id, :workers_count, :test_globs
143
145
  attr_writer :jobs_count, :differ, :pretty_printer, :program_name, :colors
@@ -169,6 +171,7 @@ module Megatest
169
171
  @minitest_compatibility = false
170
172
  @selectors = nil
171
173
  @test_globs = [DEFAULT_TEST_GLOB]
174
+ @output_profile = nil
172
175
  CIService.configure(self, env)
173
176
  end
174
177
 
@@ -6,7 +6,7 @@ module Megatest
6
6
  class AbstractExecutor
7
7
  def initialize(config, out)
8
8
  @config = config
9
- @out = Output.new(out, colors: @config.colors(out))
9
+ @out = Output.new(config, out, colors: config.colors(out))
10
10
  end
11
11
 
12
12
  def run(queue, reporters)
@@ -70,9 +70,10 @@ module Megatest
70
70
 
71
71
  attr_reader :color
72
72
 
73
- def initialize(io, colors: nil)
73
+ def initialize(config, io, colors: nil)
74
74
  raise ArgumentError, "don't nest outputs" if io.is_a?(Output)
75
75
 
76
+ @config = config
76
77
  @io = io
77
78
  colors = io.tty? if colors.nil?
78
79
  case colors
@@ -119,6 +120,19 @@ module Megatest
119
120
  @io.print(*args)
120
121
  end
121
122
 
123
+ def step(title, open: false)
124
+ case @config.output_profile
125
+ when :buildkite
126
+ if open
127
+ puts("+++ #{title}")
128
+ else
129
+ puts("--- #{title}")
130
+ end
131
+ else
132
+ puts("* #{title}")
133
+ end
134
+ end
135
+
122
136
  def <<(str)
123
137
  @io << str
124
138
  end
@@ -9,7 +9,7 @@ module Megatest
9
9
 
10
10
  def initialize(config, out)
11
11
  @config = config
12
- @out = Output.new(out, colors: config.colors(out))
12
+ @out = Output.new(config, out, colors: config.colors(out))
13
13
  end
14
14
 
15
15
  def start(_executor, _queue)
@@ -71,9 +71,9 @@ module Megatest
71
71
 
72
72
  class SimpleReporter < AbstractReporter
73
73
  def start(_executor, queue)
74
- @out.print("Running #{queue.size} test cases with --seed #{@config.seed}")
75
- @out.print(" in #{@config.jobs_count} processes") if @config.jobs_count > 1
76
- @out.puts
74
+ title = "Running #{queue.size} test cases with --seed #{@config.seed}"
75
+ title += " in #{@config.jobs_count} processes" if @config.jobs_count > 1
76
+ @out.step(title)
77
77
  @out.puts
78
78
  end
79
79
 
@@ -96,6 +96,19 @@ module Megatest
96
96
  @out.puts
97
97
 
98
98
  failures = summary.failures.reject(&:skipped?)
99
+
100
+ summary_title = format(
101
+ "Ran %d cases, %d assertions, %d failures, %d errors, %d retries, %d skips",
102
+ summary.runs_count,
103
+ summary.assertions_count,
104
+ summary.failures_count,
105
+ summary.errors_count,
106
+ summary.retries_count,
107
+ summary.skips_count,
108
+ )
109
+ summary_title += " in #{@config.jobs_count} processes" if @config.jobs_count > 1
110
+ @out.step(summary_title, open: !failures.empty?)
111
+
99
112
  unless failures.empty?
100
113
  failures = failures.sort_by(&:test_id)
101
114
  failures.each_with_index do |result, index|
@@ -115,9 +128,11 @@ module Megatest
115
128
  p90 = sorted_results[(size * 0.9).to_i].duration
116
129
  p99 = sorted_results[(size * 0.99).to_i].duration
117
130
 
118
- @out.puts "Finished in #{s(executor.wall_time.to_f)}, average: #{ms(average)}, median: #{ms(median)}, p90: #{ms(p90)}, p99: #{ms(p99)}"
119
131
  cutoff = p90 * 10
120
132
  slowest_tests = sorted_results.last(5).select { |r| r.duration > cutoff }
133
+
134
+ stats = "Finished in #{s(executor.wall_time.to_f)}, average: #{ms(average)}, median: #{ms(median)}, p90: #{ms(p90)}, p99: #{ms(p99)}"
135
+ @out.step(stats, open: !slowest_tests.empty?)
121
136
  unless slowest_tests.empty?
122
137
  @out.puts "Slowest tests:"
123
138
  slowest_tests.reverse_each do |result|
@@ -127,18 +142,6 @@ module Megatest
127
142
  @out.puts ""
128
143
  end
129
144
  end
130
-
131
- @out.print format(
132
- "Ran %d cases, %d assertions, %d failures, %d errors, %d retries, %d skips",
133
- summary.runs_count,
134
- summary.assertions_count,
135
- summary.failures_count,
136
- summary.errors_count,
137
- summary.retries_count,
138
- summary.skips_count,
139
- )
140
- @out.print(" in #{@config.jobs_count} processes") if @config.jobs_count > 1
141
- @out.puts
142
145
  end
143
146
 
144
147
  def s(duration)
@@ -153,6 +156,7 @@ module Megatest
153
156
  class VerboseReporter < SimpleReporter
154
157
  def start(executor, _queue)
155
158
  @concurrent = executor.concurrent?
159
+ super
156
160
  end
157
161
 
158
162
  def before_test_case(_queue, test_case)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Megatest
4
- VERSION = "0.9.1"
4
+ VERSION = "0.10.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: megatest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Boussier