From 16fec95e34ffb192d726dbb9bc56979d978ab98a Mon Sep 17 00:00:00 2001 From: jftucker Date: Wed, 25 Jun 2008 00:27:08 +0200 Subject: adding autotest support The autotest auto discovery uses bacons test/unit output. It does not currently call specific examples (TODO). It currently attempts to fix the rspec auto discovery by removing it if it finds a .bacon under test/ or spec/. In fact, these are the only conditions under which the bacon autotest will load. darcs-hash:20080624222708-28a3f-839431c7732599ab78c7279d8dffcf4f4ee3c9e8.gz --- lib/autotest/bacon.rb | 27 +++++++++++++++++++++++++++ lib/autotest/discover.rb | 9 +++++++++ 2 files changed, 36 insertions(+) create mode 100644 lib/autotest/bacon.rb create mode 100644 lib/autotest/discover.rb 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 diff --git a/lib/autotest/discover.rb b/lib/autotest/discover.rb new file mode 100644 index 0000000..8012c67 --- /dev/null +++ b/lib/autotest/discover.rb @@ -0,0 +1,9 @@ +Autotest.add_discovery do + if File.exist?('spec/.bacon') || File.exist?('test/.bacon') + class Autotest + @@discoveries.delete_if { |d| d.inspect =~ /rspec/ } + warn 'Removing rspec from autotest!' + end + 'bacon' + end +end \ No newline at end of file -- cgit 1.4.1