summary refs log tree commit diff
path: root/lib/autotest/bacon.rb
blob: 3de8753de5ba22abb5ce7935e3c0a7a2bf951f2f (plain) (blame)
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
Autotest.add_hook :initialize do |att|
  att.clear_mappings

  att.add_mapping(%r%^(test|spec)/.*\.rb$%) do |filename, _|
    filename
  end

  att.add_mapping(%r%^lib/(.*)\.rb$%) do |filename, m|
    lib_path = m[1]
    spec = File.basename(lib_path)
    path = File.dirname(lib_path)
    [
      "test/#{path}/test_#{spec}.rb",
      "test/#{path}/spec_#{spec}.rb",
      "spec/#{path}/spec_#{spec}.rb",
      # TODO : decide if the follow 'rspec style' name should be allowed?
      # "spec/#{path}/#{spec}_spec.rb"
    ]
  end

  false
end

class Autotest::Bacon < Autotest
  def initialize
    super
    self.libs = %w[. lib test spec].join(File::PATH_SEPARATOR)
  end

  def make_test_cmd(files_to_test)
    args = files_to_test.keys.flatten.join(' ')
    args = '-a' if args.empty?
    # TODO : make regex to pass to -n using values
    "#{ruby} -S bacon -I#{libs} -o TestUnit #{args}"
  end
end