Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 55 lines (44 sloc) 1.312 kb
51a81d2 @raggi Initial import of nginx_thin spike
authored
1 # -*- ruby -*-
2
3 require 'autotest/restart'
4
5 module Glob2Rexp
6 GLOB2REXP = {
7 '.' => '\.',
8 /(?:^|[^\\])\*/ => '\1.*'
9 }
10
11 def self.call(pattern)
12 GLOB2REXP.each { |from, to| pattern.gsub!(from, to) }
13 Regexp.new(pattern)
14 end
15 end
16
17 Autotest.add_hook :initialize do |at|
18 at.testlib = 'minitest/autorun'
19
20 # Don't track extras, this just burns cpu.
21 ignores = %w[]
22 ignores.concat File.read('.gitignore').split
23 ignores.delete_if { |pattern| pattern.nil? || pattern.empty? }
24 ignores.map! { |pattern| Glob2Rexp.call pattern }
25 ignores.each do |ignore|
26 at.add_exception ignore
27 end
28
29 # Make sure that we run all tests if the helper changes:
30 at.add_mapping(%r%^test/helper\.rb$%) do |f, _|
31 at.files_matching %r%test_.*\.rb%
32 end
33
34 # If the gemspec changes, we need to run the tests
35 at.add_mapping(%r%^.*\.gemspec$%) do |f, _|
36 at.files_matching %r%test_.*\.rb%
37 end
38
39 # If bundle did something, run all tests again
40 at.add_mapping(%r%^Gemfile\.lock$%) do |f, _|
41 at.files_matching %r%test_.*\.rb%
42 end
43 end
44
45 if File.exists?('Gemfile')
46 require 'autotest/bundler'
47
48 # If the Gemfile gets updated, run bundle install
49 Autotest.add_hook :updated do |at, *args|
50 if args.flatten.grep(%r%^Gemfile$|^.*\.gemspec$%).any?
51 system 'bundle'
52 end
53 end
54 end
Something went wrong with that request. Please try again.