Skip to content

Instantly share code, notes, and snippets.

@zenspider
Created August 7, 2025 20:31
Show Gist options
  • Save zenspider/f36b1fa04e4fd0f704df2b7dd08f8094 to your computer and use it in GitHub Desktop.
Save zenspider/f36b1fa04e4fd0f704df2b7dd08f8094 to your computer and use it in GitHub Desktop.
modified lib/minitest.rb
@@ -185,6 +185,10 @@ module Minitest
options[:show_skips] = true
end
+ opts.on "--hard-mode", "Run tests in 'hard mode', aka fully random." do
+ options[:hard_mode] = true
+ end
+
opts.on "-n", "--name PATTERN", "Filter run on /regexp/ or string." do |a|
options[:filter] = a # TODO: rename include?
end
@@ -337,7 +341,13 @@ module Minitest
# the serial tests won't lock around Reporter#record. Run the serial tests
# first, so that after they complete, the parallel tests will lock when
# recording results.
- serial.map { |suite| suite.run_suite reporter, options } +
+ if options[:hard_mode] then
+ serial.flat_map { |suite| suite.runnable_methods.map { |m| [suite, m] } }
+ .shuffle
+ .map { |(suite, method_name)| suite.run suite, method_name, reporter }
+ else
+ serial.map { |suite| suite.run_suite reporter, options }
+ end +
parallel.map { |suite| suite.run_suite reporter, options }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment