Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ jobs:
- '3.4'
- '4.0'
- 'truffleruby'
minitest:
- '~> 5.11'
- '~> 6.0'
exclude:
# minitest 6 requires Ruby >= 3.2
- ruby: '3.1'
minitest: '~> 6.0'
steps:
- uses: actions/checkout@v2
- name: Install deps
Expand All @@ -38,6 +45,7 @@ jobs:
env:
SUITE: ruby
REDIS_HOST: localhost
MINITEST_VERSION: ${{ matrix.minitest }}

python-tests:
runs-on: ubuntu-latest
Expand Down
5 changes: 4 additions & 1 deletion ruby/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ GEM
lint_roller (1.1.0)
logger (1.7.0)
minitest (5.27.0)
minitest-mock (5.27.0)
minitest-reporters (1.7.1)
ansi
builder
Expand Down Expand Up @@ -106,14 +107,16 @@ GEM

PLATFORMS
arm64-darwin-23
arm64-darwin-24
ruby
Comment thread
catwomey marked this conversation as resolved.

DEPENDENCIES
activesupport
benchmark
bundler
ci-queue!
minitest (~> 5.11)
minitest (>= 5.11)
minitest-mock
minitest-reporters (~> 1.1)
mocha
msgpack
Expand Down
3 changes: 2 additions & 1 deletion ruby/ci-queue.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ Gem::Specification.new do |spec|

spec.add_development_dependency 'bundler'
spec.add_development_dependency 'rake'
spec.add_development_dependency 'minitest', ENV.fetch('MINITEST_VERSION', '~> 5.11')
spec.add_development_dependency 'minitest', ENV.fetch('MINITEST_VERSION', '>= 5.11')
spec.add_development_dependency 'rspec', '~> 3.10'
spec.add_development_dependency 'redis'
spec.add_development_dependency 'simplecov', '~> 0.12'
spec.add_development_dependency 'minitest-reporters', '~> 1.1'
spec.add_development_dependency 'minitest-mock'
spec.add_development_dependency 'mocha'

spec.add_development_dependency 'rexml'
Expand Down
45 changes: 33 additions & 12 deletions ruby/lib/minitest/queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def with_timestamps

def run
with_timestamps do
Minitest.run_one_method(@runnable, @method_name)
@runnable.new(@method_name).run
end
end

Expand Down Expand Up @@ -450,7 +450,7 @@ def run
elsif skip_stale_tests? && !(runnable.method_defined?(@method_name) || runnable.private_method_defined?(@method_name))
build_stale_skip_result
else
Minitest.run_one_method(runnable, @method_name)
runnable.new(@method_name).run
end
rescue StandardError, ScriptError => error
build_error_result(error)
Expand Down Expand Up @@ -552,6 +552,12 @@ def queue_reporters=(reporters)
Reporters.use!(((Reporters.reporters || []) - @queue_reporters) + reporters)
Minitest.backtrace_filter.add_filter(%r{exe/minitest-queue|lib/ci/queue/})
@queue_reporters = reporters

# minitest 6 made plugin loading opt-in (no longer called from
# Minitest.run). Ensure minitest-reporters' plugin is loaded so
# that its DelegateReporter wires our reporters into the
# CompositeReporter that Minitest.run creates.
Minitest.load_plugins if Minitest.respond_to?(:load_plugins)
end

def loaded_tests
Expand All @@ -562,19 +568,34 @@ def loaded_tests
end
end

def __run(*args)
if queue
Queue.run(*args)
# minitest 5 calls __run; minitest 6 renamed it to run_all_suites.
# Define both so the prepend intercepts whichever version is active.
%i[__run run_all_suites].each do |name|
define_method(name) do |*args|
if queue
Queue.run(*args)

if queue.config.circuit_breakers.any?(&:open?)
STDERR.puts queue.config.circuit_breakers.map(&:message).join(' ').strip
end
if queue.config.circuit_breakers.any?(&:open?)
STDERR.puts queue.config.circuit_breakers.map(&:message).join(' ').strip
end

if queue.max_test_failed?
STDERR.puts 'This worker is exiting early because too many failed tests were encountered.'
end

if queue.max_test_failed?
STDERR.puts 'This worker is exiting early because too many failed tests were encountered.'
# minitest 6 starts a Parallel::Executor thread pool before
# calling run_all_suites, then joins those threads in shutdown
# afterward. ci-queue bypasses the executor entirely (it has
# its own Redis poll loop), so the worker threads sit idle and
# shutdown hangs forever. Drain them here so the later
# shutdown in Minitest.run is a no-op.
if Minitest.respond_to?(:parallel_executor)
executor = Minitest.parallel_executor
executor.shutdown if executor.respond_to?(:shutdown)
end
else
super(*args)
end
else
super
end
end
end
Expand Down
1 change: 1 addition & 0 deletions ruby/lib/minitest/queue/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ def run_tests_in_fork(queue)
child_pid = fork do
Minitest.queue = queue
Minitest::Reporters.use!([Minitest::Reporters::BisectReporter.new])
Minitest.load_plugins if Minitest.respond_to?(:load_plugins)
exit # let minitest excute its at_exit
end

Expand Down
8 changes: 8 additions & 0 deletions ruby/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
require 'ci/queue/redis'
require 'minitest/queue'
require 'minitest/autorun'

# minitest 6 extracted mock into a separate gem
begin
require 'minitest/mock'
rescue LoadError
require 'minitest-mock'
end

require 'mocha/minitest'

Minitest::Reporters.use!([Minitest::Reporters::SpecReporter.new])
Expand Down
Loading