maxitest 1.5.3 → 1.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/maxitest/pending.rb +11 -5
- data/lib/maxitest/vendor/testrbl.rb +129 -127
- data/lib/maxitest/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7db9e9766430fc0c6600b33feed4c231238b6b9d
|
4
|
+
data.tar.gz: 0b4915abe95300cb7d2c1406e742cd0393130565
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b25f64c7b30d48c4f2e95b6dfc6f1fd1d0c3310330c8ed83bb03ceee8ae970dc7cf092d6e7b49bdfb8ac47a9b5c05403587340149b27140a96c5ac90993ece4
|
7
|
+
data.tar.gz: e0c6750d5f66a53d5e28b25beae1659418e19a502ccd39b6d8e0dabe1a5e9198328703c127d09adc9bcaf90c792ee3781300c0a01a801fd5798eabf0bcbb3ddc
|
data/lib/maxitest/pending.rb
CHANGED
@@ -1,11 +1,17 @@
|
|
1
1
|
module Maxitest
|
2
2
|
module Pending
|
3
3
|
def pending(reason=nil)
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
if block_given?
|
5
|
+
begin
|
6
|
+
yield
|
7
|
+
rescue StandardError, Minitest::Assertion
|
8
|
+
skip reason
|
9
|
+
else
|
10
|
+
raise "Fixed"
|
11
|
+
end
|
12
|
+
else
|
13
|
+
raise ArgumentError, "Need a block to execute"
|
14
|
+
end
|
9
15
|
end
|
10
16
|
end
|
11
17
|
end
|
@@ -13,168 +13,170 @@ module Maxitest
|
|
13
13
|
OPTION_WITH_ARGUMENT = ["-I", "-r", "-n", "-e", "--seed"]
|
14
14
|
INTERPOLATION = /\\\#\\\{.*?\\\}/
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
16
|
+
class << self
|
17
|
+
def run_from_cli(argv)
|
18
|
+
files, options = partition_argv(argv)
|
19
|
+
files.concat(changed_files) if options.delete("--changed")
|
20
|
+
files = files.map { |f| localize(f) }
|
21
|
+
load_options, options = partition_options(options)
|
22
|
+
|
23
|
+
if files.size == 1 and files.first =~ /^(\S+):(\d+)$/
|
24
|
+
file = $1
|
25
|
+
line = $2
|
26
|
+
run(ruby + load_options + line_pattern_option(file, line) + options)
|
27
|
+
else
|
28
|
+
if files.size == 1 and File.file?(files.first)
|
29
|
+
run(ruby + load_options + files + options)
|
30
|
+
elsif options.none? { |arg| arg =~ /^-n/ }
|
31
|
+
seed = if seed = options.index("--seed")
|
32
|
+
["--"] + options.slice!(seed, 2)
|
33
|
+
else
|
34
|
+
[]
|
35
|
+
end
|
36
|
+
files = files.map { |f| File.directory?(f) ? all_test_files_in(f) : f }.flatten
|
37
|
+
run(ruby + load_options + files.map { |f| "-r#{f}" } + options + ["-e", ""] + seed)
|
38
|
+
else # pass though
|
39
|
+
# no bundle exec: projects with mini and unit-test do not run well via bundle exec testrb
|
40
|
+
run ["testrb"] + argv
|
34
41
|
end
|
35
|
-
files = files.map { |f| File.directory?(f) ? all_test_files_in(f) : f }.flatten
|
36
|
-
run(ruby + load_options + files.map { |f| "-r#{f}" } + options + ["-e", ""] + seed)
|
37
|
-
else # pass though
|
38
|
-
# no bundle exec: projects with mini and unit-test do not run well via bundle exec testrb
|
39
|
-
run ["testrb"] + argv
|
40
42
|
end
|
41
43
|
end
|
42
|
-
end
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
# overwritten by maxitest to just return line
|
46
|
+
def line_pattern_option(file, line)
|
47
|
+
[file, "-n", "/#{pattern_from_file(File.readlines(file), line)}/"]
|
48
|
+
end
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
|
50
|
+
# usable via external tools like zeus
|
51
|
+
def pattern_from_file(lines, line)
|
52
|
+
possible_lines = lines[0..(line.to_i-1)].reverse
|
52
53
|
|
53
|
-
|
54
|
+
found = possible_lines.map { |line| test_pattern_from_line(line) || block_start_from_line(line) }.compact
|
54
55
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
56
|
+
# pattern and the groups it is nested under (like describe - describe - it)
|
57
|
+
last_spaces = " " * 100
|
58
|
+
patterns = found.select do |spaces, name|
|
59
|
+
last_spaces = spaces if spaces.size < last_spaces.size
|
60
|
+
end.map(&:last).compact
|
60
61
|
|
61
|
-
|
62
|
+
return filter_duplicate_final(patterns).reverse.join(".*") if found.size > 0
|
62
63
|
|
63
|
-
|
64
|
-
|
64
|
+
raise "no test found before line #{line}"
|
65
|
+
end
|
65
66
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
67
|
+
# only keep 1 pattern that stops matching via $
|
68
|
+
def filter_duplicate_final(patterns)
|
69
|
+
found_final = 0
|
70
|
+
patterns.reject { |p| p.end_with?("$") and (found_final += 1) > 1 }
|
71
|
+
end
|
71
72
|
|
72
|
-
|
73
|
+
private
|
73
74
|
|
74
|
-
|
75
|
-
|
76
|
-
|
75
|
+
def all_test_files_in(folder)
|
76
|
+
Dir[File.join(folder, "{**/,}*_{test,spec}.rb")].uniq
|
77
|
+
end
|
77
78
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
true
|
84
|
-
else
|
85
|
-
if option =~ /^-(r|I)/
|
86
|
-
next_is_before = (option.size == 2)
|
79
|
+
def partition_options(options)
|
80
|
+
next_is_before = false
|
81
|
+
options.partition do |option|
|
82
|
+
if next_is_before
|
83
|
+
next_is_before = false
|
87
84
|
true
|
88
85
|
else
|
89
|
-
|
86
|
+
if option =~ /^-(r|I)/
|
87
|
+
next_is_before = (option.size == 2)
|
88
|
+
true
|
89
|
+
else
|
90
|
+
false
|
91
|
+
end
|
90
92
|
end
|
91
93
|
end
|
92
94
|
end
|
93
|
-
end
|
94
95
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
96
|
+
# fix 1.9 not being able to load local files
|
97
|
+
def localize(file)
|
98
|
+
file =~ /^[-a-z\d_]/ ? "./#{file}" : file
|
99
|
+
end
|
99
100
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
else
|
106
|
-
if arg =~ /^-.$/ or arg =~ /^--/ # single letter option followed by argument like -I test or long options like --verbose
|
107
|
-
next_is_option = true if OPTION_WITH_ARGUMENT.include?(arg)
|
108
|
-
false
|
109
|
-
elsif arg =~ /^-/ # multi letter option like -Itest
|
110
|
-
false
|
101
|
+
def partition_argv(argv)
|
102
|
+
next_is_option = false
|
103
|
+
argv.partition do |arg|
|
104
|
+
if next_is_option
|
105
|
+
next_is_option = false
|
111
106
|
else
|
112
|
-
|
107
|
+
if arg =~ /^-.$/ or arg =~ /^--/ # single letter option followed by argument like -I test or long options like --verbose
|
108
|
+
next_is_option = true if OPTION_WITH_ARGUMENT.include?(arg)
|
109
|
+
false
|
110
|
+
elsif arg =~ /^-/ # multi letter option like -Itest
|
111
|
+
false
|
112
|
+
else
|
113
|
+
true
|
114
|
+
end
|
113
115
|
end
|
114
116
|
end
|
115
117
|
end
|
116
|
-
end
|
117
118
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
end
|
123
|
-
|
124
|
-
def self.ruby
|
125
|
-
if File.file?("Gemfile")
|
126
|
-
["ruby", "-rbundler/setup"] # faster then bundle exec ruby
|
127
|
-
else
|
128
|
-
["ruby"]
|
119
|
+
def changed_files
|
120
|
+
changed_files = `git status -s`.split("\n").map { |l| l.strip.split(/\s+/, 2)[1] }
|
121
|
+
raise "Failed: #{changed_files}" unless $?.success?
|
122
|
+
changed_files.select { |f| f =~ /_(test|spec)\.rb$/ && File.exist?(f) }
|
129
123
|
end
|
130
|
-
end
|
131
124
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
125
|
+
def ruby
|
126
|
+
if File.file?("Gemfile")
|
127
|
+
["ruby", "-rbundler/setup"] # faster then bundle exec ruby
|
128
|
+
else
|
129
|
+
["ruby"]
|
130
|
+
end
|
131
|
+
end
|
137
132
|
|
138
|
-
|
139
|
-
|
140
|
-
|
133
|
+
def run(command)
|
134
|
+
puts command.join(" ")
|
135
|
+
STDOUT.flush # if exec fails horribly we at least see some output
|
136
|
+
Kernel.exec *command
|
141
137
|
end
|
142
|
-
end
|
143
138
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
return [whitespace, test_pattern_from_match(method, test_name)]
|
139
|
+
def block_start_from_line(line)
|
140
|
+
if line =~ /^(\s*).* do( \|.*\|)?$/
|
141
|
+
[$1, nil]
|
142
|
+
end
|
149
143
|
end
|
150
|
-
nil
|
151
|
-
end
|
152
144
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
"^test(: |_)#{regex.gsub(" ", ".")}$"
|
161
|
-
elsif method == "describe" || (method == "context" && !via_shoulda?)
|
162
|
-
"#{test_name}(::)?"
|
163
|
-
elsif method == "should" && via_shoulda?
|
164
|
-
optional_test_name = "(?:\(.*\))?"
|
165
|
-
"#{method} #{regex}\. #{optional_test_name}$"
|
166
|
-
elsif ["it", "should"].include?(method) # minitest aliases for shoulda
|
167
|
-
"#test_\\d+_#{test_name}$"
|
168
|
-
else
|
169
|
-
regex
|
145
|
+
def test_pattern_from_line(line)
|
146
|
+
PATTERNS.each do |r|
|
147
|
+
next unless line =~ r
|
148
|
+
whitespace, method, test_name = $1, $2, $3
|
149
|
+
return [whitespace, test_pattern_from_match(method, test_name)]
|
150
|
+
end
|
151
|
+
nil
|
170
152
|
end
|
171
153
|
|
172
|
-
|
173
|
-
|
154
|
+
def test_pattern_from_match(method, test_name)
|
155
|
+
regex = Regexp.escape(test_name).gsub("\\ "," ").gsub(INTERPOLATION, ".*")
|
156
|
+
|
157
|
+
regex = if method == "test"
|
158
|
+
# test "xxx -_ yyy"
|
159
|
+
# test-unit: "test: xxx -_ yyy"
|
160
|
+
# activesupport: "test_xxx_-__yyy"
|
161
|
+
"^test(: |_)#{regex.gsub(" ", ".")}$"
|
162
|
+
elsif method == "describe" || (method == "context" && !via_shoulda?)
|
163
|
+
"#{regex}(::)?"
|
164
|
+
elsif method == "should" && via_shoulda?
|
165
|
+
optional_test_name = "(?:\(.*\))?"
|
166
|
+
"#{method} #{regex}\. #{optional_test_name}$"
|
167
|
+
elsif ["it", "should"].include?(method) # minitest aliases for shoulda
|
168
|
+
"#test_\\d+_#{regex}$"
|
169
|
+
else
|
170
|
+
regex
|
171
|
+
end
|
172
|
+
|
173
|
+
regex.gsub("'", ".")
|
174
|
+
end
|
174
175
|
|
175
|
-
|
176
|
-
|
177
|
-
|
176
|
+
def via_shoulda?
|
177
|
+
return @via_shoulda if defined?(@via_shoulda)
|
178
|
+
@via_shoulda = !File.exist?("Gemfile.lock") || File.read("Gemfile.lock").include?(" shoulda-context ")
|
179
|
+
end
|
178
180
|
end
|
179
181
|
end
|
180
182
|
end
|
data/lib/maxitest/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maxitest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|