5 require 'autotest/restart'
6 require 'autotest/isolate'
8 Autotest.add_hook :run_command do |_, cmd|
9 cmd.sub! ' -e ', ' -we '
12 Autotest.add_hook :initialize do |at|
15 at.failed_results_re = /^\s+\d+\) (?:Failure|Error):\n(.*?):/
16 at.completed_re = /\d+ tests, \d+ assertions, \d+ failures, \d+ errors/
18 at.add_exception %r%/\.git/%
19 at.add_exception %r%\.rbc$%
20 at.add_exception %r%test/rubygems/rubygems%
22 at.find_directories.clear
23 at.find_directories.push 'lib', 'test'
25 at.add_mapping %r%^lib/rubygems.rb$% do |_, m|
26 "test/rubygems/test_gem.rb"
29 at.add_mapping %r%^lib/rubygems/(.*).rb$% do |_, m|
30 "test/rubygems/test_gem_#{m[1].gsub '/', '_'}.rb"
33 args = ARGV.reject { |a| a =~ /^-/ }
34 at.find_directories = args unless args.empty?
36 def at.handle_results results
37 results = results.gsub(/\e\[\d+m/, '') # strip ascii color
38 failed = results.scan(self.failed_results_re).map { |m, k|
39 /(?<k>\w+)#(?<m>\w+)/ =~ m
43 completed = results[self.completed_re]
46 completed = completed.scan(/(\d+) (\w+)/).map { |v, k| [k, v.to_i] }
48 self.latest_results = Hash[*completed.flatten]
49 self.files_to_test = consolidate_failures failed
51 color = failed.empty? ? :green : :red
52 hook color unless $TESTING
54 self.latest_results = nil
57 self.tainted = true unless self.files_to_test.empty?
60 def at.path_to_classname s
63 f = s.sub(/^test#{sep}rubygems#{sep}/, '').sub(/\.rb$/, '').split sep
65 f = f.map { |path| path.split(/_|(\d+)/).map { |seg| seg.capitalize }.join }
69 gsub('GemDependencyApi', 'GemDependencyAPI')