Sample
minitest 6.0.6: Setting MT_CPU=1 causes Minitest.parallel_executor to remain nil, making parallelize_me! a silent no-op with serial execution unless an executor is assigned
Verified sample for gem minitest 6.0.6: Setting MT_CPU=1 causes Minitest.parallel_executor to remain nil, making parallelize_me! a silent no-op with serial…
sha256:0199365007f54358f8e7dc42e65dee893c7de0bcabb962584bf17d58e0e689b3
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 2
- Signing keys that built it
- 2
Declared environment
ruby linux x64 ruby ruby bundler
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| ruby 3 · linux debian/x64 · docker ed25519:d91480838ac982c9 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · rubygems@1 |
2026-08-17 |
| ruby 3 · linux debian/x64 · docker ed25519:2175b912ea1c23b1 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · rubygems@1 |
2026-08-18 |
Case
HOW- Goal
- Setting MT_CPU=1 causes Minitest.parallel_executor to remain nil, making parallelize_me! a silent no-op with serial execution unless an executor is assigned
- Packages
- Symbols
-
- Minitest.parallel_executor
- Minitest::Test.parallelize_me!
- Minitest::Parallel::Executor
- Minitest::Parallel::Test
- Minitest::Test.run_order
- Minitest::Test.i_suck_and_my_tests_are_order_dependent!
- Environment
- ruby
- Created
- 2026-08-17T11:15:02Z
Contract
- When MT_CPU is 1 or less at load time, Minitest.parallel_executor is nil, causing parallelize_me! to leave test class run_order as :random without including Minitest::Parallel::Test, running tests synchronously on the main thread
- Modifying ENV['MT_CPU'] after minitest is loaded has no effect on Minitest.parallel_executor because thread pool initialization occurs at file load time
- Explicitly assigning Minitest.parallel_executor = Minitest::Parallel::Executor.new(2) enables parallelize_me! to set run_order to :parallel and execute test methods on background worker threads
- Calling i_suck_and_my_tests_are_order_dependent! forces run_order to :alpha, sorting runnable test methods alphabetically
Files
- Gemfile
- Gemfile.lock
- NOTES.md
- csx.json
- test/contract.rb
Source
source "https://rubygems.org"
gem "minitest", "= 6.0.6"
GEM
remote: https://rubygems.org/
specs:
drb (2.2.1)
minitest (6.0.6)
drb (~> 2.0)
prism (~> 1.5)
prism (1.5.3)
PLATFORMS
ruby
x64-mingw-ucrt
x86_64-linux
x86_64-linux-musl
DEPENDENCIES
minitest (= 6.0.6)
CHECKSUMS
drb (2.2.1) sha256=e9d472bf785f558b96b25358bae115646da0dbfd45107ad858b0bc0d935cb340
minitest (6.0.6) sha256=153ea36d1d987a62942382b61075745042a2b3123b1cd48f4c3675af9cc7d6f1
prism (1.5.3)
BUNDLED WITH
2.6.9
# Minitest Configuration and Parallel Execution Notes
## Known Solutions Search
A search with `search_known_solution` for `minitest` identified cached sample `sha256:b46d09ac09a40810f24397605f05ee322446d0b080b89fbb246295977afede04`, which proves explicit assertion behaviors and mock extractions in Minitest 6.0.6.
This project focuses on a distinct configuration behavior: how `ENV["MT_CPU"]` interacts with `Minitest.parallel_executor`, `parallelize_me!`, and test method execution ordering.
## Pinned Version
- `minitest` version: `6.0.6`
## Observed Behavior
1. **Load-Time Thread Pool Initialization (`MT_CPU=1`)**:
During gem loading, `minitest` evaluates `n_threads = (ENV["MT_CPU"] || Etc.nprocessors).to_i`. If `n_threads <= 1` (e.g. when `MT_CPU=1` or in a single-processor environment), `Minitest.parallel_executor` remains `nil`.
2. **Silent No-Op in `parallelize_me!`**:
The method `Minitest::Test.parallelize_me!` begins with `return unless Minitest.parallel_executor`. When the executor is `nil`, calling `parallelize_me!` inside a test class returns immediately without modifying `run_order` (which stays `:random`) and without including `Minitest::Parallel::Test`. Test methods run serially on the main caller thread.
3. **Post-Load Environment Variables**:
Modifying `ENV["MT_CPU"]` after `minitest` has already been required has no effect on `Minitest.parallel_executor` because the assignment is performed once during initial file evaluation.
4. **Explicit Executor Assignment**:
To activate parallel execution dynamically or after loading with `MT_CPU=1`, `Minitest.parallel_executor` must be explicitly instantiated as `Minitest::Parallel::Executor.new(pool_size)`. Subsequent calls to `parallelize_me!` then set `run_order` to `:parallel` and execute tests asynchronously on background worker threads.
5. **Deterministic Ordering with `i_suck_and_my_tests_are_order_dependent!`**:
Calling `i_suck_and_my_tests_are_order_dependent!` on a test class sets `run_order` to `:alpha`, ensuring that `runnable_methods` are executed in strict alphabetical order rather than random or parallel ordering.
## Failure Mode
When developers or CI pipelines set `MT_CPU=1` expecting a single background worker thread to process parallel tests, the failure mode is **silent with a green build**. `parallelize_me!` does not raise an exception or issue a warning; it silently falls back to synchronous serial execution on the main thread.
{"case":{"believed":"Calling parallelize_me! inside a test class always enables parallel test execution across worker threads or raises an error if threads cannot be allocated","caseId":"case:sha256:691beb46c5ecc0a7eb304cf4ccbc3d260adfb547a5f4e5d2e80d02f249c2431c","contract":["When MT_CPU is 1 or less at load time, Minitest.parallel_executor is nil, causing parallelize_me! to leave test class run_order as :random without including Minitest::Parallel::Test, running tests synchronously on the main thread","Modifying ENV['MT_CPU'] after minitest is loaded has no effect on Minitest.parallel_executor because thread pool initialization occurs at file load time","Explicitly assigning Minitest.parallel_executor = Minitest::Parallel::Executor.new(2) enables parallelize_me! to set run_order to :parallel and execute test methods on background worker threads","Calling i_suck_and_my_tests_are_order_dependent! forces run_order to :alpha, sorting runnable test methods alphabetically"],"goal":"Setting MT_CPU=1 causes Minitest.parallel_executor to remain nil, making parallelize_me! a silent no-op with serial execution unless an executor is assigned","kind":"HOW","packages":["pkg:gem/minitest@6.0.6"],"schemaVersion":1,"symbols":["Minitest.parallel_executor","Minitest::Test.parallelize_me!","Minitest::Parallel::Executor","Minitest::Parallel::Test","Minitest::Test.run_order","Minitest::Test.i_suck_and_my_tests_are_order_dependent!"]},"contractCommand":["bundle","exec","ruby","test/contract.rb"],"environment":{"arch":"x64","ecosystem":"gem","executionContext":"ruby","language":"ruby","os":"linux","packageManager":"bundler","runtime":"ruby","schemaVersion":1},"license":"MIT-0","packages":["pkg:gem/minitest@6.0.6"],"schemaVersion":1,"symbols":["Minitest.parallel_executor","Minitest::Test.parallelize_me!","Minitest::Parallel::Executor","Minitest::Parallel::Test","Minitest::Test.run_order","Minitest::Test.i_suck_and_my_tests_are_order_dependent!"],"verifierAdapter":"rubygems@1"}
ENV["MT_CPU"] = "1"
require "minitest"
require "minitest/test"
require "stringio"
raise "unexpected minitest version" unless Minitest::VERSION == "6.0.6"
# 1. When MT_CPU=1 at load time, parallel_executor is nil, so parallelize_me! is a silent no-op.
$serial_thread = nil
class SerialDueToEnvTest < Minitest::Test
parallelize_me!
def test_serial_execution
$serial_thread = Thread.current
end
end
raise "expected parallel_executor to be nil when MT_CPU=1" unless Minitest.parallel_executor.nil?
raise "expected run_order to remain :random" unless SerialDueToEnvTest.run_order == :random
raise "expected Parallel::Test not to be included" if SerialDueToEnvTest.ancestors.include?(Minitest::Parallel::Test)
Minitest.seed = 42
reporter = Minitest::CompositeReporter.new
reporter << Minitest::SummaryReporter.new(StringIO.new, {})
SerialDueToEnvTest.run_suite(reporter, {})
raise "expected test to run on caller thread" unless $serial_thread == Thread.current
# 2. Modifying ENV["MT_CPU"] after load has no effect because pool initialization happens at load time.
ENV["MT_CPU"] = "4"
raise "parallel_executor should still be nil after ENV update" unless Minitest.parallel_executor.nil?
class StillSerialTest < Minitest::Test
parallelize_me!
end
raise "expected run_order to remain :random" unless StillSerialTest.run_order == :random
raise "expected Parallel::Test not to be included" if StillSerialTest.ancestors.include?(Minitest::Parallel::Test)
# 3. Explicitly assigning Minitest.parallel_executor activates parallelize_me! and executes on worker threads.
$parallel_thread = nil
Minitest.parallel_executor = Minitest::Parallel::Executor.new(2)
raise "expected Parallel::Executor instance" unless Minitest.parallel_executor.is_a?(Minitest::Parallel::Executor)
raise "expected pool size to be 2" unless Minitest.parallel_executor.size == 2
class ParallelTest < Minitest::Test
parallelize_me!
def test_parallel_execution
$parallel_thread = Thread.current
end
end
raise "expected run_order to be :parallel" unless ParallelTest.run_order == :parallel
raise "expected Parallel::Test in ancestors" unless ParallelTest.ancestors.include?(Minitest::Parallel::Test)
Minitest.parallel_executor.start
ParallelTest.run_suite(reporter, {})
Minitest.parallel_executor.shutdown
raise "expected worker thread to execute test" if $parallel_thread == Thread.current
raise "expected worker thread to have recorded thread" if $parallel_thread.nil?
# 4. i_suck_and_my_tests_are_order_dependent! forces run_order to :alpha and sorts runnable methods.
class AlphaOrderTest < Minitest::Test
i_suck_and_my_tests_are_order_dependent!
def test_z; end
def test_m; end
def test_a; end
end
raise "expected run_order to be :alpha" unless AlphaOrderTest.run_order == :alpha
raise "expected alphabetical method order" unless AlphaOrderTest.runnable_methods == ["test_a", "test_m", "test_z"]