maxitest 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/bin/mtest +12 -0
- data/lib/maxitest.rb +2 -0
- data/lib/maxitest/autorun.rb +21 -0
- data/lib/maxitest/let_bang.rb +6 -0
- data/lib/maxitest/trap.rb +25 -0
- data/lib/maxitest/vendor/around.rb +84 -0
- data/lib/maxitest/vendor/line.rb +101 -0
- data/lib/maxitest/vendor/rg.rb +92 -0
- data/lib/maxitest/vendor/testrbl.rb +172 -0
- data/lib/maxitest/version.rb +3 -0
- metadata +69 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3894f7f1af83137bcce04d41e4e49133c65a36db
|
4
|
+
data.tar.gz: 86757fd5bfc626049bc9f0c620f741ad0d796dd4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7e268f0581b2674d88b8c0e3f7aa57c8c3880c50255d57273e9b44a9406cd541c3509e5064ac1e72d592fde4bffd1e4eae754c96ffa651768066578fd5967461
|
7
|
+
data.tar.gz: 5f659851669f5dac806b43f323d70c504d5ecabf391ceaaab12557a88042541cfad48d094614cf08ec9941ea384340df701b85863da7fbc56d5c9087b06e8ff4
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (C) 2013 Michael Grosser <michael@grosser.it>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/bin/mtest
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'optparse'
|
3
|
+
|
4
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
5
|
+
require 'maxitest/vendor/testrbl'
|
6
|
+
|
7
|
+
class << Maxitest::Testrbl
|
8
|
+
def line_pattern_option(file, line)
|
9
|
+
[file, "-l", line]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
Maxitest::Testrbl.run_from_cli(ARGV)
|
data/lib/maxitest.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "minitest"
|
2
|
+
|
3
|
+
if $stdout.tty?
|
4
|
+
require "maxitest/vendor/rg"
|
5
|
+
Minitest.extensions << "rg"
|
6
|
+
Minitest::RG.rg!
|
7
|
+
end
|
8
|
+
|
9
|
+
require "maxitest/vendor/line"
|
10
|
+
Minitest.extensions << "line"
|
11
|
+
|
12
|
+
require "minitest/autorun"
|
13
|
+
require "maxitest/vendor/around"
|
14
|
+
require "maxitest/trap"
|
15
|
+
require "maxitest/let_bang"
|
16
|
+
|
17
|
+
Minitest::Spec::DSL.send(:alias_method, :context, :describe)
|
18
|
+
|
19
|
+
class << Minitest::Test
|
20
|
+
alias_method :order_dependent!, :i_suck_and_my_tests_are_order_dependent!
|
21
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Minitest::Test.class_eval do
|
2
|
+
alias_method :run_without_stop, :run
|
3
|
+
def run
|
4
|
+
if Maxitest.interrupted
|
5
|
+
self.failures = [Minitest::Skip.new("Maxitest::Interrupted")]
|
6
|
+
else
|
7
|
+
run_without_stop
|
8
|
+
end
|
9
|
+
self
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
module Maxitest
|
14
|
+
Interrupted = Class.new(StandardError)
|
15
|
+
class << self
|
16
|
+
attr_accessor :interrupted
|
17
|
+
|
18
|
+
def interrupt
|
19
|
+
Maxitest.interrupted = true
|
20
|
+
raise Maxitest::Interrupted, "Execution interrupted by user"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
Signal.trap(:SIGINT) { Maxitest.interrupt }
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# https://raw.githubusercontent.com/splattael/minitest-around/master/LICENSE
|
2
|
+
# BEGIN generated by rake update, do not modify
|
3
|
+
=begin
|
4
|
+
Copyright (c) 2012 Peter Suschlik
|
5
|
+
|
6
|
+
MIT License
|
7
|
+
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
9
|
+
a copy of this software and associated documentation files (the
|
10
|
+
"Software"), to deal in the Software without restriction, including
|
11
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
12
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
13
|
+
permit persons to whom the Software is furnished to do so, subject to
|
14
|
+
the following conditions:
|
15
|
+
|
16
|
+
The above copyright notice and this permission notice shall be
|
17
|
+
included in all copies or substantial portions of the Software.
|
18
|
+
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
20
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
21
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
22
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
23
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
24
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
25
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
26
|
+
=end
|
27
|
+
#END generated by rake update, do not modify
|
28
|
+
|
29
|
+
# https://raw.githubusercontent.com/splattael/minitest-around/master/lib/minitest/around/version.rb
|
30
|
+
# BEGIN generated by rake update, do not modify
|
31
|
+
module Minitest
|
32
|
+
module Around
|
33
|
+
VERSION = '0.2.0'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
#END generated by rake update, do not modify
|
37
|
+
|
38
|
+
# https://raw.githubusercontent.com/splattael/minitest-around/master/lib/minitest/around/unit.rb
|
39
|
+
# BEGIN generated by rake update, do not modify
|
40
|
+
Minitest::Test.class_eval do
|
41
|
+
alias_method :run_without_around, :run
|
42
|
+
def run(*args)
|
43
|
+
if defined?(around)
|
44
|
+
around { run_without_around(*args) }
|
45
|
+
else
|
46
|
+
run_without_around(*args)
|
47
|
+
end
|
48
|
+
self
|
49
|
+
end
|
50
|
+
end
|
51
|
+
#END generated by rake update, do not modify
|
52
|
+
|
53
|
+
# https://raw.githubusercontent.com/splattael/minitest-around/master/lib/minitest/around/spec.rb
|
54
|
+
# BEGIN generated by rake update, do not modify
|
55
|
+
Minitest::Spec::DSL.class_eval do
|
56
|
+
# - resume to call first part
|
57
|
+
# - execute test
|
58
|
+
# - resume fiber to execute last part
|
59
|
+
def around(&block)
|
60
|
+
fib = nil
|
61
|
+
before do
|
62
|
+
fib = Fiber.new do |context, resume|
|
63
|
+
begin
|
64
|
+
context.instance_exec(resume, &block)
|
65
|
+
rescue Object
|
66
|
+
fib = :failed
|
67
|
+
raise
|
68
|
+
end
|
69
|
+
end
|
70
|
+
fib.resume(self, lambda { Fiber.yield })
|
71
|
+
end
|
72
|
+
after { fib.resume unless fib == :failed }
|
73
|
+
end
|
74
|
+
|
75
|
+
# Minitest does not support multiple before/after blocks
|
76
|
+
def before(type=nil, &block)
|
77
|
+
include Module.new { define_method(:setup) { super(); instance_exec(&block) } }
|
78
|
+
end
|
79
|
+
|
80
|
+
def after(type=nil, &block)
|
81
|
+
include Module.new { define_method(:teardown) { instance_exec(&block); super() } }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
#END generated by rake update, do not modify
|
@@ -0,0 +1,101 @@
|
|
1
|
+
=begin
|
2
|
+
Copyright (c) 2014 Magnus Holm
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
=end
|
23
|
+
|
24
|
+
require 'pathname'
|
25
|
+
|
26
|
+
# https://raw.githubusercontent.com/judofyr/minitest-line/master/lib/minitest/line_plugin.rb
|
27
|
+
# BEGIN generated by rake update, do not modify
|
28
|
+
module Minitest
|
29
|
+
def self.plugin_line_options(opts, options)
|
30
|
+
opts.on '-l', '--line N', Integer, "Run test at line number" do |lineno|
|
31
|
+
options[:line] = lineno
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.plugin_line_init(options)
|
36
|
+
exp_line = options[:line]
|
37
|
+
if !exp_line
|
38
|
+
reporter.reporters << LineReporter.new
|
39
|
+
return
|
40
|
+
end
|
41
|
+
|
42
|
+
methods = Runnable.runnables.flat_map do |runnable|
|
43
|
+
runnable.runnable_methods.map do |name|
|
44
|
+
[name, runnable.instance_method(name)]
|
45
|
+
end
|
46
|
+
end.uniq
|
47
|
+
|
48
|
+
current_filename = nil
|
49
|
+
tests = {}
|
50
|
+
|
51
|
+
methods.each do |name, meth|
|
52
|
+
next unless loc = meth.source_location
|
53
|
+
current_filename ||= loc[0]
|
54
|
+
next unless current_filename == loc[0]
|
55
|
+
tests[loc[1]] = name
|
56
|
+
end
|
57
|
+
|
58
|
+
_, main_test = tests.sort_by { |k, v| -k }.detect do |line, name|
|
59
|
+
exp_line >= line
|
60
|
+
end
|
61
|
+
|
62
|
+
raise "Could not find test method after line #{exp_line}" unless main_test
|
63
|
+
|
64
|
+
options[:filter] = main_test
|
65
|
+
end
|
66
|
+
|
67
|
+
class LineReporter < Reporter
|
68
|
+
def initialize(*)
|
69
|
+
super
|
70
|
+
@failures = []
|
71
|
+
end
|
72
|
+
|
73
|
+
def record(result)
|
74
|
+
if !result.skipped? && !result.passed?
|
75
|
+
@failures << result
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def report
|
80
|
+
return unless @failures.any?
|
81
|
+
io.puts
|
82
|
+
io.puts "Focus on failing tests:"
|
83
|
+
pwd = Pathname.new(Dir.pwd)
|
84
|
+
@failures.each do |res|
|
85
|
+
meth = res.method(res.name)
|
86
|
+
file, line = meth.source_location
|
87
|
+
if file
|
88
|
+
file = Pathname.new(file)
|
89
|
+
file = file.relative_path_from(pwd) if file.absolute?
|
90
|
+
output = "ruby #{file} -l #{line}"
|
91
|
+
output = "\e[31m#{output}\e[0m" if $stdout.tty?
|
92
|
+
io.puts output
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def self.plugin_line_inject_reporter
|
99
|
+
end
|
100
|
+
end
|
101
|
+
#END generated by rake update, do not modify
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# https://raw.githubusercontent.com/blowmage/minitest-rg/master/LICENSE
|
2
|
+
# BEGIN generated by rake update, do not modify
|
3
|
+
=begin
|
4
|
+
Copyright (c) 2012 Mike Moore
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
a copy of this software and associated documentation files (the
|
8
|
+
"Software"), to deal in the Software without restriction, including
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be
|
15
|
+
included in all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
=end
|
25
|
+
#END generated by rake update, do not modify
|
26
|
+
|
27
|
+
# https://raw.githubusercontent.com/blowmage/minitest-rg/master/lib/minitest/rg_plugin.rb
|
28
|
+
# BEGIN generated by rake update, do not modify
|
29
|
+
module MiniTest
|
30
|
+
|
31
|
+
def self.plugin_rg_options opts, options # :nodoc:
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.plugin_rg_init options # :nodoc:
|
35
|
+
if RG.rg?
|
36
|
+
io = RG.new options[:io]
|
37
|
+
|
38
|
+
self.reporter.reporters.grep(Minitest::Reporter).each do |rep|
|
39
|
+
rep.io = io
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class RG
|
45
|
+
VERSION = "5.1.0"
|
46
|
+
|
47
|
+
COLORS = {
|
48
|
+
'.' => "\e[32m.\e[0m",
|
49
|
+
'E' => "\e[33mE\e[0m",
|
50
|
+
'F' => "\e[31mF\e[0m",
|
51
|
+
'S' => "\e[36mS\e[0m",
|
52
|
+
}
|
53
|
+
|
54
|
+
attr_reader :io, :colors
|
55
|
+
|
56
|
+
def self.rg!
|
57
|
+
@rg = true
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.rg?
|
61
|
+
@rg ||= false
|
62
|
+
end
|
63
|
+
|
64
|
+
def initialize io, colors = COLORS
|
65
|
+
@io = io
|
66
|
+
@colors = colors
|
67
|
+
end
|
68
|
+
|
69
|
+
def print o
|
70
|
+
io.print(colors[o] || o)
|
71
|
+
end
|
72
|
+
|
73
|
+
def puts o=nil
|
74
|
+
return io.puts if o.nil?
|
75
|
+
if o =~ /(\d+) failures, (\d+) errors/
|
76
|
+
if $1 != '0' || $2 != '0'
|
77
|
+
io.puts "\e[31m#{o}\e[0m"
|
78
|
+
else
|
79
|
+
io.puts "\e[32m#{o}\e[0m"
|
80
|
+
end
|
81
|
+
else
|
82
|
+
io.puts o
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def method_missing msg, *args
|
87
|
+
return super unless io.respond_to? msg
|
88
|
+
io.send(msg, *args)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
#END generated by rake update, do not modify
|
@@ -0,0 +1,172 @@
|
|
1
|
+
# Copyright 2014 Michael Grosser under MIT License
|
2
|
+
|
3
|
+
# https://raw.githubusercontent.com/grosser/testrbl/master/lib/testrbl.rb
|
4
|
+
# BEGIN generated by rake update, do not modify
|
5
|
+
module Maxitest
|
6
|
+
module Testrbl
|
7
|
+
PATTERNS = [
|
8
|
+
/^(\s+)(should|test|it)\s+['"](.*)['"]\s+do\s*(?:#.*)?$/,
|
9
|
+
/^(\s+)(context|describe)\s+['"]?(.*?)['"]?\s+do\s*(?:#.*)?$/,
|
10
|
+
/^(\s+)def\s+(test_)([a-z_\d]+)\s*(?:#.*)?$/
|
11
|
+
]
|
12
|
+
|
13
|
+
OPTION_WITH_ARGUMENT = ["-I", "-r", "-n", "-e"]
|
14
|
+
INTERPOLATION = /\\\#\\\{.*?\\\}/
|
15
|
+
|
16
|
+
def self.run_from_cli(argv)
|
17
|
+
files, options = partition_argv(argv)
|
18
|
+
files.concat(changed_files) if options.delete("--changed")
|
19
|
+
files = files.map { |f| localize(f) }
|
20
|
+
load_options, options = partition_options(options)
|
21
|
+
|
22
|
+
if files.size == 1 and files.first =~ /^(\S+):(\d+)$/
|
23
|
+
file = $1
|
24
|
+
line = $2
|
25
|
+
run(ruby + load_options + line_pattern_option(file, line) + options)
|
26
|
+
else
|
27
|
+
if files.size == 1 and File.file?(files.first)
|
28
|
+
run(ruby + load_options + files + options)
|
29
|
+
elsif options.none? { |arg| arg =~ /^-n/ }
|
30
|
+
files = files.map { |f| File.directory?(f) ? all_test_files_in(f) : f }.flatten
|
31
|
+
run(ruby + load_options + files.map { |f| "-r#{f}" } + options + ["-e", ""])
|
32
|
+
else # pass though
|
33
|
+
# no bundle exec: projects with mini and unit-test do not run well via bundle exec testrb
|
34
|
+
run ["testrb"] + argv
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# overwritten by maxitest to just return line
|
40
|
+
def self.line_pattern_option(file, line)
|
41
|
+
[file, "-n", "/#{pattern_from_file(File.readlines(file), line)}/"]
|
42
|
+
end
|
43
|
+
|
44
|
+
# usable via external tools like zeus
|
45
|
+
def self.pattern_from_file(lines, line)
|
46
|
+
possible_lines = lines[0..(line.to_i-1)].reverse
|
47
|
+
|
48
|
+
found = possible_lines.map { |line| test_pattern_from_line(line) || block_start_from_line(line) }.compact
|
49
|
+
|
50
|
+
# pattern and the groups it is nested under (like describe - describe - it)
|
51
|
+
last_spaces = " " * 100
|
52
|
+
patterns = found.select do |spaces, name|
|
53
|
+
last_spaces = spaces if spaces.size < last_spaces.size
|
54
|
+
end.map(&:last).compact
|
55
|
+
|
56
|
+
return filter_duplicate_final(patterns).reverse.join(".*") if found.size > 0
|
57
|
+
|
58
|
+
raise "no test found before line #{line}"
|
59
|
+
end
|
60
|
+
|
61
|
+
# only keep 1 pattern that stops matching via $
|
62
|
+
def self.filter_duplicate_final(patterns)
|
63
|
+
found_final = 0
|
64
|
+
patterns.reject { |p| p.end_with?("$") and (found_final += 1) > 1 }
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def self.all_test_files_in(folder)
|
70
|
+
Dir[File.join(folder, "{**/,}*_{test,spec}.rb")].uniq
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.partition_options(options)
|
74
|
+
next_is_before = false
|
75
|
+
options.partition do |option|
|
76
|
+
if next_is_before
|
77
|
+
next_is_before = false
|
78
|
+
true
|
79
|
+
else
|
80
|
+
if option =~ /^-(r|I)/
|
81
|
+
next_is_before = (option.size == 2)
|
82
|
+
true
|
83
|
+
else
|
84
|
+
false
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# fix 1.9 not being able to load local files
|
91
|
+
def self.localize(file)
|
92
|
+
file =~ /^[-a-z\d_]/ ? "./#{file}" : file
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.partition_argv(argv)
|
96
|
+
next_is_option = false
|
97
|
+
argv.partition do |arg|
|
98
|
+
if next_is_option
|
99
|
+
next_is_option = false
|
100
|
+
else
|
101
|
+
if arg =~ /^-.$/ or arg =~ /^--/ # single letter option followed by argument like -I test or long options like --verbose
|
102
|
+
next_is_option = true if OPTION_WITH_ARGUMENT.include?(arg)
|
103
|
+
false
|
104
|
+
elsif arg =~ /^-/ # multi letter option like -Itest
|
105
|
+
false
|
106
|
+
else
|
107
|
+
true
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def self.changed_files
|
114
|
+
changed_files = `git status -s`.split("\n").map { |l| l.strip.split(/\s+/, 2)[1] }
|
115
|
+
raise "Failed: #{changed_files}" unless $?.success?
|
116
|
+
changed_files.select { |f| f =~ /_(test|spec)\.rb$/ && File.exist?(f) }
|
117
|
+
end
|
118
|
+
|
119
|
+
def self.ruby
|
120
|
+
if File.file?("Gemfile")
|
121
|
+
["ruby", "-rbundler/setup"] # faster then bundle exec ruby
|
122
|
+
else
|
123
|
+
["ruby"]
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def self.run(command)
|
128
|
+
puts command.join(" ")
|
129
|
+
STDOUT.flush # if exec fails horribly we at least see some output
|
130
|
+
Kernel.exec *command
|
131
|
+
end
|
132
|
+
|
133
|
+
def self.block_start_from_line(line)
|
134
|
+
if line =~ /^(\s*).* do( \|.*\|)?$/
|
135
|
+
[$1, nil]
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def self.test_pattern_from_line(line)
|
140
|
+
PATTERNS.each do |r|
|
141
|
+
next unless line =~ r
|
142
|
+
whitespace, method, test_name = $1, $2, $3
|
143
|
+
return [whitespace, test_pattern_from_match(method, test_name)]
|
144
|
+
end
|
145
|
+
nil
|
146
|
+
end
|
147
|
+
|
148
|
+
def self.test_pattern_from_match(method, test_name)
|
149
|
+
regex = Regexp.escape(test_name).gsub("\\ "," ").gsub(INTERPOLATION, ".*")
|
150
|
+
|
151
|
+
regex = case method
|
152
|
+
when "should"
|
153
|
+
optional_test_name = "(?:\(.*\))?"
|
154
|
+
"#{method} #{regex}\. #{optional_test_name}$"
|
155
|
+
when "describe"
|
156
|
+
"#{test_name}(::)?"
|
157
|
+
when "test"
|
158
|
+
# test "xxx -_ yyy"
|
159
|
+
# test-unit: "test: xxx -_ yyy"
|
160
|
+
# activesupport: "test_xxx_-__yyy"
|
161
|
+
"^test(: |_)#{regex.gsub(" ", ".")}$"
|
162
|
+
when "it"
|
163
|
+
"#test_\\d+_#{test_name}$"
|
164
|
+
else
|
165
|
+
regex
|
166
|
+
end
|
167
|
+
|
168
|
+
regex.gsub("'", ".")
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
#END generated by rake update, do not modify
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: maxitest
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michael Grosser
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: minitest
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 5.4.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 5.4.2
|
27
|
+
description:
|
28
|
+
email: michael@grosser.it
|
29
|
+
executables:
|
30
|
+
- mtest
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- MIT-LICENSE
|
35
|
+
- bin/mtest
|
36
|
+
- lib/maxitest.rb
|
37
|
+
- lib/maxitest/autorun.rb
|
38
|
+
- lib/maxitest/let_bang.rb
|
39
|
+
- lib/maxitest/trap.rb
|
40
|
+
- lib/maxitest/vendor/around.rb
|
41
|
+
- lib/maxitest/vendor/line.rb
|
42
|
+
- lib/maxitest/vendor/rg.rb
|
43
|
+
- lib/maxitest/vendor/testrbl.rb
|
44
|
+
- lib/maxitest/version.rb
|
45
|
+
homepage: https://github.com/grosser/maxitest
|
46
|
+
licenses:
|
47
|
+
- MIT
|
48
|
+
metadata: {}
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
requirements: []
|
64
|
+
rubyforge_project:
|
65
|
+
rubygems_version: 2.2.2
|
66
|
+
signing_key:
|
67
|
+
specification_version: 4
|
68
|
+
summary: Full featured Minitest
|
69
|
+
test_files: []
|