Skip to content

Instantly share code, notes, and snippets.

View zenspider's full-sized avatar
🌈
It's complicated?

Ryan Davis zenspider

🌈
It's complicated?
View GitHub Profile
self.post_install_message = <<~EOM
NOTE: minitest 5 will be the last in the minitest family to support
ruby 1.8 to 2.7. If you need to keep using these versions,
you need to pin your dependency to minitest with something
like "~> 5.0". See History.rdoc to locate compatible
versions.
Further, minitest 6 will be dropping the following:
+ MiniTest (it's been Minitest for *years*)
ERR_RE = /unexpected (?:end-of-input|\$end|end-of-file|END_OF_FILE)|embedded document meets end of file|unterminated (?:string|regexp|list) meets end of file/.freeze
def self.complete_expression?(str)
catch(:valid) do
eval("BEGIN{throw :valid}\n#{str}")
end
true
rescue SyntaxError => ex
if ENV["FASTER"] then
msg = ex.message
@zenspider
zenspider / mini.rb
Last active November 6, 2025 05:45
at_exit { exit Mini.autotest }
module Mini
def self.all_tests = Test.subklasses.flat_map { |k| k.tests.map { |m| [k, m] } }
def self.autotest = all_tests.shuffle.count { |k, m| k.run m }.zero?
class Test
@@subklasses = []
def self.subklasses = @@subklasses
def self.inherited(k) = subklasses << k
diff -r old/lib/minitest.rb new/lib/minitest.rb
--- old/lib/minitest.rb
+++ new/lib/minitest.rb
@@ -36,7 +36,7 @@
warn "DEPRECATED: use MT_CPU instead of N for parallel test runs" if ENV["N"] && ENV["N"].to_i > 0
n_threads = (ENV["MT_CPU"] || ENV["N"] || Etc.nprocessors).to_i
- self.parallel_executor = Parallel::Executor.new n_threads
+ self.parallel_executor = Parallel::Executor.new n_threads if n_threads > 1
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|
# which one do I hate least and why?
ban, = db.execute(<<~SQL, ip:, jail:, offset:) # parens, anti-seattle.rb style
ban, = db.execute <<~SQL, {ip:, jail:, offset:} # braces, same
ban, = db.execute <<~SQL, ip:, jail:, offset:offset # one value, to prevent hanging:
ban, = db.execute <<~SQL, ip:ip, jail:jail, offset:offset # consistent, but long
ban, = db.execute <<~SQL, ip:, jail:, offset:; # you monster version
#!/usr/bin/env -S ruby -w
$: << File.expand_path("~/Links/RI/lib")
$: << File.expand_path("~/Links/ZT/lib")
require "rubygems"
require "inline"
class X
inline :C do |builder|
10000 $ ./diffdump 'def a(...); b(...); end' 'def a(x, ...); b(...); end'
--- /dev/fd/63 2025-05-10 14:00:39
+++ /dev/fd/62 2025-05-10 14:00:39
@@ -1,12 +1,17 @@
-== disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,23)>
+== disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,26)>
0000 definemethod :a, a ( 1)[Li]
0003 putobject :a
0005 leave
--- /dev/fd/63 2025-05-08 15:52:58
+++ /dev/fd/62 2025-05-08 15:52:58
@@ -1,14 +1,19 @@
-== disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,33)>
+== disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,36)>
0000 definemethod :x, x ( 1)[Li]
0003 putself
0004 putobject 4
0006 opt_send_without_block <calldata!mid:x, argc:1, FCALL|ARGS_SIMPLE>
0008 leave
### Renames::
* Minitest.__run becomes Minitest.run_all_suites
* Runnable.run becomes Runnable.run_suite
* Minitest.run_one_method becomes Runnable.run (essentially, see below)
### Additions::
* Added Runnable#filter_runnable_methods # extraction from Runnable.run_suite
* ? maybe add --plugins option?