summary refs log tree commit diff
path: root/lib/autotest/bacon.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/autotest/bacon.rb')
-rw-r--r--lib/autotest/bacon.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/autotest/bacon.rb b/lib/autotest/bacon.rb
new file mode 100644
index 0000000..d2e3be0
--- /dev/null
+++ b/lib/autotest/bacon.rb
@@ -0,0 +1,27 @@
+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|
+    ["test/test_#{m[1]}.rb", "test/spec_#{m[1]}.rb", "spec/spec_#{m[1]}.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 -o TestUnit #{args}"
+  end
+end
\ No newline at end of file