maxitest-3.6.0/0000755000004100000410000000000013573510167013416 5ustar www-datawww-datamaxitest-3.6.0/bin/0000755000004100000410000000000013573510167014166 5ustar www-datawww-datamaxitest-3.6.0/bin/mtest0000755000004100000410000000041713573510167015252 0ustar www-datawww-data#!/usr/bin/env ruby require 'optparse' $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib') require 'maxitest/vendor/testrbl' class << Maxitest::Testrbl def line_pattern_option(file, line) [file, "-l", line] end end Maxitest::Testrbl.run_from_cli(ARGV) maxitest-3.6.0/maxitest.gemspec0000644000004100000410000000532713573510167016630 0ustar www-datawww-data######################################################### # This file has been automatically generated by gem2tgz # ######################################################### # -*- encoding: utf-8 -*- # stub: maxitest 3.6.0 ruby lib Gem::Specification.new do |s| s.name = "maxitest".freeze s.version = "3.6.0" s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= s.require_paths = ["lib".freeze] s.authors = ["Michael Grosser".freeze] s.date = "2019-11-10" s.email = "michael@grosser.it".freeze s.executables = ["mtest".freeze] s.files = ["MIT-LICENSE".freeze, "Readme.md".freeze, "bin/mtest".freeze, "lib/maxitest.rb".freeze, "lib/maxitest/autorun.rb".freeze, "lib/maxitest/global_must.rb".freeze, "lib/maxitest/implicit_subject.rb".freeze, "lib/maxitest/let_all.rb".freeze, "lib/maxitest/let_bang.rb".freeze, "lib/maxitest/pending.rb".freeze, "lib/maxitest/shorted_backtrace.rb".freeze, "lib/maxitest/static_class_order.rb".freeze, "lib/maxitest/threads.rb".freeze, "lib/maxitest/timeout.rb".freeze, "lib/maxitest/trap.rb".freeze, "lib/maxitest/vendor/around.rb".freeze, "lib/maxitest/vendor/line.rb".freeze, "lib/maxitest/vendor/line_describe.rb".freeze, "lib/maxitest/vendor/rg.rb".freeze, "lib/maxitest/vendor/testrbl.rb".freeze, "lib/maxitest/verbose_backtrace.rb".freeze, "lib/maxitest/version.rb".freeze, "lib/maxitest/xit.rb".freeze, "lib/minitest/maxitest_plugin.rb".freeze] s.homepage = "https://github.com/grosser/maxitest".freeze s.licenses = ["MIT".freeze] s.required_ruby_version = Gem::Requirement.new(">= 2.0.0".freeze) s.rubygems_version = "2.5.2.1".freeze s.summary = "Minitest + all the features you always wanted".freeze if s.respond_to? :specification_version then s.specification_version = 4 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then s.add_development_dependency(%q.freeze, [">= 0"]) s.add_runtime_dependency(%q.freeze, ["< 5.14.0", ">= 5.0.0"]) s.add_development_dependency(%q.freeze, [">= 0"]) s.add_development_dependency(%q.freeze, [">= 0"]) s.add_development_dependency(%q.freeze, [">= 0"]) else s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, ["< 5.14.0", ">= 5.0.0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) end else s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, ["< 5.14.0", ">= 5.0.0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) end end maxitest-3.6.0/Readme.md0000644000004100000410000000441713573510167015143 0ustar www-datawww-dataMinitest + all the features you always wanted. ![Failure](assets/failure.png?raw=true) Features ======== - **Ctrl+c** stops tests and prints failures - **pastable rerun snippet** for failures (disabled/integrated on rails 5) - multiple before & after blocks - **around** blocks `around { |t| Dir.chdir(...) { t.call } }` - **red-green** output (disabled/integrated on rails 5) - `mtest` executable to **run by line number** and by folder (disabled/integrated on rails 5) - full backtrace for errors and assertions with verbose (`-v`) - `let!` - `let_all` execute once for all tests in a class and it's subclasses - `order_dependent!` to make your tests run in given order - `Maxitest.static_class_order = true` no longer sort tests class/sub-classes in random order - `context` for more expression - `pending { assert false }` is skip when it fails, but fails when it passes - implicit subject via `require 'maxitest/implicit_subject'` - `xit` to skip test (also does not call setup or teardown) - `require 'maxitest/timeout'` to make hanging tests fail after `Maxitest.timeout` seconds - `require 'maxitest/threads'` fail tests that leave extra threads running - `require 'maxitest/global_must'` (before autorun) disable deprecation on global `must_*` or [global_expectations](https://github.com/jeremyevans/minitest-global_expectations) gem Install ======= ```Bash gem install maxitest ``` Usage ===== ```Ruby require "maxitest/autorun" ... normal tests ... ``` Development =========== - everything vendored into 1 gem to avoid dependency madness - tested via rspec to avoid messing up our own tests by accident - fixes should go back to the original libraries - restrictive minitest dependency so nothing breaks by accident - ruby 1.9+ - `rake update` to update all vendored gems Author ====== - running by line number from [minitest-line](https://github.com/judofyr/minitest-line) - around from [minitest-around](https://github.com/splattael/minitest-around) - mtest from [testrbl](https://github.com/grosser/testrbl) - red-green from [minitest-rg](https://github.com/blowmage/minitest-rg) [Michael Grosser](http://grosser.it)
michael@grosser.it
License: MIT
[![Build Status](https://travis-ci.org/grosser/maxitest.png)](https://travis-ci.org/grosser/maxitest) maxitest-3.6.0/lib/0000755000004100000410000000000013573510167014164 5ustar www-datawww-datamaxitest-3.6.0/lib/maxitest/0000755000004100000410000000000013573510167016022 5ustar www-datawww-datamaxitest-3.6.0/lib/maxitest/shorted_backtrace.rb0000644000004100000410000000033113573510167022013 0ustar www-datawww-dataMinitest::BacktraceFilter.send(:prepend, Module.new do def filter(*) backtrace = super pwd = "#{Dir.pwd}/" section = pwd.size..-1 backtrace.map { |b| b.start_with?(pwd) ? b[section] : b } end end) maxitest-3.6.0/lib/maxitest/version.rb0000644000004100000410000000005013573510167020027 0ustar www-datawww-datamodule Maxitest VERSION = "3.6.0" end maxitest-3.6.0/lib/maxitest/pending.rb0000644000004100000410000000057213573510167017777 0ustar www-datawww-datamodule Maxitest module Pending def pending(reason=nil) if block_given? begin yield rescue StandardError, Minitest::Assertion skip reason else raise "Fixed" end else raise ArgumentError, "Need a block to execute" end end end end Minitest::Test.send(:include, Maxitest::Pending) maxitest-3.6.0/lib/maxitest/autorun.rb0000644000004100000410000000104613573510167020045 0ustar www-datawww-datarequire "minitest" require "minitest/autorun" require "maxitest/vendor/around" require "maxitest/trap" require "maxitest/let_bang" require "maxitest/let_all" require "maxitest/pending" require "maxitest/xit" require "maxitest/static_class_order" require "maxitest/shorted_backtrace" require "maxitest/vendor/line_describe" # not a plugin module Maxitest ENABLE_PLUGINS = true end Minitest::Spec::DSL.send(:alias_method, :context, :describe) class << Minitest::Test alias_method :order_dependent!, :i_suck_and_my_tests_are_order_dependent! end maxitest-3.6.0/lib/maxitest/implicit_subject.rb0000644000004100000410000000072113573510167021700 0ustar www-datawww-data# this is a bit hacky / overwrites describe, so not included by default ... module Maxitest module ImplicitSubject def describe(*args, &block) klass = super if args.first.is_a?(Class) && !klass.instance_methods(false).include?(:subject) klass.let(:subject) { args.first.new } end klass end end end Object.send(:include, Maxitest::ImplicitSubject) # Minitest hacks Kernel -> we need to use alias method or go into Object maxitest-3.6.0/lib/maxitest/xit.rb0000644000004100000410000000024113573510167017150 0ustar www-datawww-dataMinitest::Spec::DSL.class_eval do def xit(*args, &block) describe "skip" do def setup; end def teardown; end it(*args) end end end maxitest-3.6.0/lib/maxitest/trap.rb0000644000004100000410000000157013573510167017320 0ustar www-datawww-dataMinitest::Test.class_eval do alias_method :capture_exceptions_without_stop, :capture_exceptions def capture_exceptions(&block) capture_exceptions_without_stop(&block) rescue Interrupt Maxitest.interrupted = true self.failures << Minitest::UnexpectedError.new($!) end alias_method :run_without_stop, :run def run if Maxitest.interrupted # only things with class `Minitest::Skip` get counted as skips # we need to raise and capture to get a skip with a backtrace skip = begin raise Minitest::Skip, "Maxitest::Interrupted" rescue Minitest::Skip $! end self.failures = [skip] defined?(Minitest::Result) ? Minitest::Result.from(self) : self else run_without_stop end end end module Maxitest Interrupted = Class.new(StandardError) class << self attr_accessor :interrupted end end maxitest-3.6.0/lib/maxitest/vendor/0000755000004100000410000000000013573510167017317 5ustar www-datawww-datamaxitest-3.6.0/lib/maxitest/vendor/around.rb0000644000004100000410000000602613573510167021140 0ustar www-datawww-data# https://raw.githubusercontent.com/splattael/minitest-around/master/LICENSE # BEGIN generated by rake update, do not modify =begin Copyright (c) 2012 Peter Suschlik Copyright (c) 2018 Peter Leitzen (Suschlik) MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. =end #END generated by rake update, do not modify # https://raw.githubusercontent.com/splattael/minitest-around/master/lib/minitest/around/version.rb # BEGIN generated by rake update, do not modify module MinitestAround VERSION = '0.5.0' end #END generated by rake update, do not modify # https://raw.githubusercontent.com/splattael/minitest-around/master/lib/minitest/around/unit.rb # BEGIN generated by rake update, do not modify Minitest::Test.class_eval do alias_method :run_without_around, :run def run(*args) if defined?(around) result = nil around { result = run_without_around(*args) } result else run_without_around(*args) end end end #END generated by rake update, do not modify # https://raw.githubusercontent.com/splattael/minitest-around/master/lib/minitest/around/spec.rb # BEGIN generated by rake update, do not modify Minitest::Spec::DSL.class_eval do # - resume to call first part # - execute test # - resume fiber to execute last part def around(*args, &block) fib = nil before do fib = Fiber.new do |context, resume| begin context.instance_exec(resume, &block) rescue Object fib = :failed raise end end fib.resume(self, lambda { Fiber.yield }) end after { fib.resume if fib && fib != :failed } end # Minitest does not support multiple before/after blocks remove_method :before def before(type=nil, &block) include Module.new { define_method(:setup) { super(); instance_exec(&block) } } end remove_method :after def after(type=nil, &block) include(Module.new do define_method(:teardown) do begin instance_exec(&block) ensure super() end end end) end end #END generated by rake update, do not modify maxitest-3.6.0/lib/maxitest/vendor/line_describe.rb0000644000004100000410000000073313573510167022436 0ustar www-datawww-data# https://raw.githubusercontent.com/judofyr/minitest-line/master/lib/minitest/line/describe_track.rb # BEGIN generated by rake update, do not modify module Minitest module Line module DescribeTrack def describe(*args, &block) klass = super klass.instance_variable_set(:@minitest_line_caller, caller(0..5)) klass end end end end Object.send(:include, Minitest::Line::DescribeTrack) #END generated by rake update, do not modify maxitest-3.6.0/lib/maxitest/vendor/testrbl.rb0000644000004100000410000001437513573510167021335 0ustar www-datawww-data# Copyright 2014 Michael Grosser under MIT License # https://raw.githubusercontent.com/grosser/testrbl/master/lib/testrbl.rb # BEGIN generated by rake update, do not modify module Maxitest module Testrbl PATTERNS = [ /^(\s+)(should|test|it)\s+['"](.*)['"]\s+do\s*(?:#.*)?$/, /^(\s+)(context|describe)\s+['"]?(.*?)['"]?\s+do\s*(?:#.*)?$/, /^(\s+)def\s+(test_)([a-z_\d]+)\s*(?:#.*)?$/ ] OPTION_WITH_ARGUMENT = ["-I", "-r", "-n", "--name", "-e", "--exclude", "-s", "--seed"] INTERPOLATION = /\\\#\\\{.*?\\\}/ class << self def run_from_cli(argv) files, options = partition_argv(argv) files.concat(changed_files) if options.delete("--changed") files = files.map { |f| localize(f) } load_options, options = partition_options(options) if files.size == 1 and files.first =~ /^(\S+):(\d+)$/ file = $1 line = $2 run(ruby + load_options + line_pattern_option(file, line) + options) else if files.size == 1 and File.file?(files.first) run(ruby + load_options + files + options) elsif options.none? { |arg| arg =~ /^-n/ } seed = if seed = options.index("--seed") ["--"] + options.slice!(seed, 2) else [] end files = files.map { |f| File.directory?(f) ? all_test_files_in(f) : f }.flatten run(ruby + load_options + files.map { |f| "-r#{f}" } + options + ["-e", ""] + seed) else # pass though # no bundle exec: projects with mini and unit-test do not run well via bundle exec testrb run ["testrb"] + argv end end end # overwritten by maxitest to just return line def line_pattern_option(file, line) [file, "-n", "/#{pattern_from_file(File.readlines(file), line)}/"] end # usable via external tools like zeus def pattern_from_file(lines, line) possible_lines = lines[0..(line.to_i-1)].reverse found = possible_lines.map { |line| test_pattern_from_line(line) || block_start_from_line(line) }.compact # pattern and the groups it is nested under (like describe - describe - it) last_spaces = " " * 100 patterns = found.select do |spaces, name| last_spaces = spaces if spaces.size < last_spaces.size end.map(&:last).compact return filter_duplicate_final(patterns).reverse.join(".*") if found.size > 0 raise "no test found before line #{line}" end # only keep 1 pattern that stops matching via $ def filter_duplicate_final(patterns) found_final = 0 patterns.reject { |p| p.end_with?("$") and (found_final += 1) > 1 } end private def all_test_files_in(folder) Dir[File.join(folder, "{**/,}*_{test,spec}.rb")].uniq end def partition_options(options) next_is_before = false options.partition do |option| if next_is_before next_is_before = false true else if option =~ /^-(r|I)/ next_is_before = (option.size == 2) true else false end end end end # fix 1.9 not being able to load local files def localize(file) file =~ /^[-a-z\d_]/ ? "./#{file}" : file end def partition_argv(argv) next_is_option = false argv.partition do |arg| if next_is_option next_is_option = false else if arg =~ /^-.$/ or arg =~ /^--/ # single letter option followed by argument like -I test or long options like --verbose next_is_option = true if OPTION_WITH_ARGUMENT.include?(arg) false elsif arg =~ /^-/ # multi letter option like -Itest false else true end end end end def changed_files changed_files = sh("git status -s").split("\n").map { |l| l.strip.split(/\s+/, 2)[1] } if changed_files.empty? # user wants to test last commit and not current diff changed_files = sh("git show --name-only").split("\n\n").last.split("\n") end # we only want test files that were added or changed (not deleted) changed_files.select { |f| f =~ /_(test|spec)\.rb$/ && File.exist?(f) } end def sh(command) result = `#{command}` raise "Failed: #{command} -> #{result}" unless $?.success? result end def ruby if File.file?("Gemfile") ["ruby", "-rbundler/setup"] # faster then bundle exec ruby else ["ruby"] end end def run(command) puts command.join(" ") STDOUT.flush # if exec fails horribly we at least see some output Kernel.exec *command end def block_start_from_line(line) if line =~ /^(\s*).* do( \|.*\|)?$/ [$1, nil] end end def test_pattern_from_line(line) PATTERNS.each do |r| next unless line =~ r whitespace, method, test_name = $1, $2, $3 return [whitespace, test_pattern_from_match(method, test_name)] end nil end def test_pattern_from_match(method, test_name) regex = Regexp.escape(test_name).gsub("\\ "," ").gsub(INTERPOLATION, ".*") regex = if method == "test" # test "xxx -_ yyy" # test-unit: "test: xxx -_ yyy" # activesupport: "test_xxx_-__yyy" "^test(: |_)#{regex.gsub(" ", ".")}$" elsif method == "describe" || (method == "context" && !via_shoulda?) "#{regex}(::)?" elsif method == "should" && via_shoulda? optional_test_name = "(?:\(.*\))?" "#{method} #{regex}\. #{optional_test_name}$" elsif ["it", "should"].include?(method) # minitest aliases for shoulda "#test_\\d+_#{regex}$" else regex end regex.gsub("'", ".") end def via_shoulda? return @via_shoulda if defined?(@via_shoulda) @via_shoulda = !File.exist?("Gemfile.lock") || File.read("Gemfile.lock").include?(" shoulda-context ") end end end end #END generated by rake update, do not modify maxitest-3.6.0/lib/maxitest/vendor/line.rb0000644000004100000410000000755613573510167020610 0ustar www-datawww-datarequire 'pathname' # https://raw.githubusercontent.com/judofyr/minitest-line/master/MIT-LICENSE.txt # BEGIN generated by rake update, do not modify =begin Copyright (c) 2014 Magnus Holm Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. =end #END generated by rake update, do not modify # https://raw.githubusercontent.com/judofyr/minitest-line/master/lib/minitest/line_plugin.rb # BEGIN generated by rake update, do not modify module Minitest module Line class << self def tests_with_lines target_file = $0 methods_with_lines(target_file).concat describes_with_lines(target_file) end private def methods_with_lines(target_file) runnables.flat_map do |runnable| rname = runnable.name runnable.runnable_methods.map do |name| file, line = runnable.instance_method(name).source_location next unless file == target_file test_name = (rname ? "#{rname}##{name}" : name) [test_name, line] end end.uniq.compact end def describes_with_lines(target_file) runnables.map do |runnable| next unless caller = runnable.instance_variable_defined?(:@minitest_line_caller) && runnable.instance_variable_get(:@minitest_line_caller) next unless line = caller.detect { |l| l.include?(target_file) } ["/#{Regexp.escape(runnable.name)}/", line[/:(\d+):in/, 1].to_i] end.compact end def runnables Minitest::Runnable.runnables end end end def self.plugin_line_options(opts, options) opts.on '-l', '--line N', Integer, "Run test at line number" do |lineno| options[:line] = lineno end end def self.plugin_line_init(options) unless exp_line = options[:line] reporter.reporters << LineReporter.new return end tests = Minitest::Line.tests_with_lines filter, _ = tests.sort_by { |n, l| -l }.detect { |n, l| exp_line >= l } raise "Could not find test method before line #{exp_line}" unless filter options[:filter] = filter end class LineReporter < Reporter def initialize(*) super @failures = [] end def record(result) if !result.skipped? && !result.passed? @failures << result end end def report return unless @failures.any? io.puts io.puts "Focus on failing tests:" pwd = Pathname.new(Dir.pwd) @failures.each do |res| result = (res.respond_to?(:source_location) ? res : res.method(res.name)) file, line = result.source_location if file file = Pathname.new(file) file = file.relative_path_from(pwd) if file.absolute? output = "mtest #{file}:#{line}" output = "\e[31m#{output}\e[0m" if $stdout.tty? io.puts output end end end end def self.plugin_line_inject_reporter end end #END generated by rake update, do not modify maxitest-3.6.0/lib/maxitest/vendor/rg.rb0000644000004100000410000000517213573510167020261 0ustar www-datawww-data# https://raw.githubusercontent.com/blowmage/minitest-rg/master/LICENSE # BEGIN generated by rake update, do not modify =begin Copyright (c) 2012 Mike Moore Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. =end #END generated by rake update, do not modify # https://raw.githubusercontent.com/blowmage/minitest-rg/master/lib/minitest/rg_plugin.rb # BEGIN generated by rake update, do not modify module Minitest def self.plugin_rg_options opts, _options # :nodoc: opts.on "--[no-]rg", "Add red/green to test output." do |bool| RG.rg! bool end end def self.plugin_rg_init options # :nodoc: if RG.rg? io = RG.new options[:io] reporter.reporters.grep(Minitest::Reporter).each do |rep| rep.io = io end end end class RG VERSION = "5.2.0".freeze COLORS = { "." => "\e[32m.\e[0m", "E" => "\e[33mE\e[0m", "F" => "\e[31mF\e[0m", "S" => "\e[36mS\e[0m" }.freeze attr_reader :io, :colors def self.rg!(bool = true) @rg = bool end def self.rg? @rg ||= false end def initialize io, colors = COLORS @io = io @colors = colors end def print o io.print(colors[o] || o) end def puts o = nil return io.puts if o.nil? if o =~ /(\d+) failures, (\d+) errors/ if Regexp.last_match[1] != "0" || Regexp.last_match[2] != "0" io.puts "\e[31m#{o}\e[0m" else io.puts "\e[32m#{o}\e[0m" end else io.puts o end end def method_missing msg, *args return super unless io.respond_to? msg io.send(msg, *args) end end end #END generated by rake update, do not modify maxitest-3.6.0/lib/maxitest/let_all.rb0000644000004100000410000000033713573510167017766 0ustar www-datawww-dataMinitest::Spec::DSL.class_eval do def let_all(name, &block) cache = [] define_method(name) do if cache.empty? cache[0] = instance_eval(&block) else cache[0] end end end end maxitest-3.6.0/lib/maxitest/static_class_order.rb0000644000004100000410000000121113573510167022211 0ustar www-datawww-datamodule Maxitest class << self attr_accessor :static_class_order end end class << Minitest::Runnable alias_method :runnables_without_static_order, :runnables def runnables return runnables_without_static_order unless Maxitest.static_class_order # Minitest.__run uses Runnable.runnables.shuffle -> hack it runnables = runnables_without_static_order def runnables.shuffle self end # ugly hack to fight minitest 5.10 https://github.com/seattlerb/minitest/commit/478e3f9cfeb0a2f8cc4b029bbcbe7bb16648dd96 def runnables.reject(*args, &block) reject!(*args, &block) end runnables end end maxitest-3.6.0/lib/maxitest/threads.rb0000644000004100000410000000224713573510167020006 0ustar www-datawww-data# tests that leave extra threads running can break other tests in weird ways ... prevent that from happening raise "Upgrade above minitest 5.0 to use this feature" if Minitest::VERSION.start_with?("5.0") module Maxitest module Threads def setup @maxitest_threads_before = Thread.list super end def teardown super found = maxitest_extra_threads raise "Test left #{found.size} extra threads (#{found})" if found.any? ensure maxitest_kill_extra_threads end # also a helper methods for users def maxitest_wait_for_extra_threads sleep 0.01 while maxitest_extra_threads.any? end # also a helper methods for users def maxitest_kill_extra_threads maxitest_extra_threads.map(&:kill).map(&:join) end # if setup crashes we do not return anything to make the initial error visible def maxitest_extra_threads @maxitest_threads_before ? Thread.list - @maxitest_threads_before : [] end end end # not using prepend since that would clash with webmock # include works because original setup lives in also included Minitest::LifecycleHooks Minitest::Test.send :include, Maxitest::Threads maxitest-3.6.0/lib/maxitest/let_bang.rb0000644000004100000410000000016513573510167020124 0ustar www-datawww-dataMinitest::Spec::DSL.class_eval do def let!(name, &block) let(name, &block) before { send(name) } end end maxitest-3.6.0/lib/maxitest/global_must.rb0000644000004100000410000000100213573510167020650 0ustar www-datawww-data# Allow global must_* assertion style without deprecations # # Must be required before maxitest/autorun Module.prepend(Module.new do def infect_an_assertion(_, new_name, *) super # define with deprecation # remove old to avoid warnings from re-defining remove_method new_name # re-define without deprecation class_eval <<-EOM, __FILE__, __LINE__ + 1 def #{new_name} *args Minitest::Expectation.new(self, Minitest::Spec.current).#{new_name}(*args) end EOM end end) maxitest-3.6.0/lib/maxitest/timeout.rb0000644000004100000410000000163213573510167020037 0ustar www-datawww-data# tests sometimes hang locally or on ci and with this we can actually debug the cause instead of just hanging forever require 'timeout' module Maxitest class << self attr_accessor :timeout end module Timeout class TestCaseTimeout < StandardError def message "Test took too long to finish, aborting. To use a debugger, def maxitest_timeout;false;end in the test file." end end def run(*, &block) # NOTE: having a default def maxitest_timeout would break using let(:maxitest_timeout) timeout = (defined?(maxitest_timeout) ? maxitest_timeout : Maxitest.timeout || 5) if timeout == false super else begin ::Timeout.timeout(timeout, TestCaseTimeout) { super } rescue TestCaseTimeout => e failures << UnexpectedError.new(e) end end end end end Minitest::Test.send :prepend, Maxitest::Timeout maxitest-3.6.0/lib/maxitest/verbose_backtrace.rb0000644000004100000410000000156413573510167022021 0ustar www-datawww-datamodule Maxitest module VerboseBacktrace class NullFilter def self.filter(backtrace) backtrace end end class << self attr_accessor :verbose end def plugin_maxitest_verbose_backtrace_init(options) return unless options[:verbose] Maxitest::VerboseBacktrace.verbose = true Minitest.backtrace_filter = Maxitest::VerboseBacktrace::NullFilter Rails.backtrace_cleaner.remove_silencers! if defined?(Rails) && Rails.respond_to?(:backtrace_cleaner) end end end Minitest.extensions << 'maxitest_verbose_backtrace' Minitest.extend Maxitest::VerboseBacktrace module Maxitest::VerboseAssertion def message if Maxitest::VerboseBacktrace.verbose "#{self.class}: #{super}\n #{backtrace.join "\n "}" else super end end end Minitest::Assertion.send(:include, Maxitest::VerboseAssertion) maxitest-3.6.0/lib/maxitest.rb0000644000004100000410000000002413573510167016343 0ustar www-datawww-datamodule Maxitest end maxitest-3.6.0/lib/minitest/0000755000004100000410000000000013573510167016020 5ustar www-datawww-datamaxitest-3.6.0/lib/minitest/maxitest_plugin.rb0000644000004100000410000000157013573510167021564 0ustar www-datawww-data# we are not enabling our extensions unless maxitest/autorun was loaded # minitests plugin system auto-loads all files in the load path and that would # always enable all our plugins even if they were not wanted if defined?(Maxitest::ENABLE_PLUGINS) && Maxitest::ENABLE_PLUGINS disabled_for_rails = begin require 'rails/version' Rails::VERSION::MAJOR >= 5 rescue LoadError false end # rails has --backtrace which disables rails own backtrace cleaner, but not minitests require "maxitest/verbose_backtrace" unless disabled_for_rails # rails 5 add default red/green output require "maxitest/vendor/rg" Minitest.extensions << "rg" Minitest::RG.rg! $stdout.tty? end # latest rails 5.2 has it's own line support but it does not work when just using ruby, so we need our own plugin require "maxitest/vendor/line" Minitest.extensions << "line" end maxitest-3.6.0/MIT-LICENSE0000644000004100000410000000207013573510167015051 0ustar www-datawww-dataCopyright (C) 2013 Michael Grosser Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.