forked from rubygems/rubygems
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.autotest
71 lines (51 loc) · 1.76 KB
/
.autotest
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# -*- ruby -*-
Gem.refresh
require 'autotest/restart'
require 'autotest/isolate'
Autotest.add_hook :run_command do |_, cmd|
cmd.sub! ' -e ', ' -we '
end
Autotest.add_hook :initialize do |at|
at.testlib = ''
at.failed_results_re = /^\s+\d+\) (?:Failure|Error):\n(.*?):/
at.completed_re = /\d+ tests, \d+ assertions, \d+ failures, \d+ errors/
at.add_exception %r%/\.git/%
at.add_exception %r%\.rbc$%
at.add_exception %r%test/rubygems/rubygems%
at.find_directories.clear
at.find_directories.push 'lib', 'test'
at.add_mapping %r%^lib/rubygems.rb$% do |_, m|
"test/rubygems/test_gem.rb"
end
at.add_mapping %r%^lib/rubygems/(.*).rb$% do |_, m|
"test/rubygems/test_gem_#{m[1].gsub '/', '_'}.rb"
end
args = ARGV.reject { |a| a =~ /^-/ }
at.find_directories = args unless args.empty?
def at.handle_results results
results = results.gsub(/\e\[\d+m/, '') # strip ascii color
failed = results.scan(self.failed_results_re).map { |m, k|
/(?<k>\w+)#(?<m>\w+)/ =~ m
[m, k]
}
completed = results[self.completed_re]
if completed then
completed = completed.scan(/(\d+) (\w+)/).map { |v, k| [k, v.to_i] }
self.latest_results = Hash[*completed.flatten]
self.files_to_test = consolidate_failures failed
color = failed.empty? ? :green : :red
hook color unless $TESTING
else
self.latest_results = nil
end
self.tainted = true unless self.files_to_test.empty?
end
def at.path_to_classname s
sep = File::SEPARATOR
f = s.sub(/^test#{sep}rubygems#{sep}/, '').sub(/\.rb$/, '').split sep
f = f.map { |path| path.split(/_|(\d+)/).map { |seg| seg.capitalize }.join }
f.join('::').
gsub('Rdoc', 'RDoc').
gsub('GemDependencyApi', 'GemDependencyAPI')
end
end