Skip to content
Browse files

(#6610) Fix Autotest proper run

Autotest can be configured through the .autotest
file. Also, Autotest already has an rspec2 discovery.
  • Loading branch information...
1 parent 241cddc commit 1cb9cb6b146167d9e0a99a678f886653ee5dc115 @kavu kavu committed with adrienthebo Aug 29, 2011
Showing with 1 addition and 92 deletions.
  1. +1 −9 autotest/facter_rspec.rb → .autotest
  2. +0 −9 autotest/discover.rb
  3. +0 −74 autotest/rspec.rb
View
10 autotest/facter_rspec.rb → .autotest
@@ -1,5 +1,4 @@
-require 'autotest'
-require 'autotest/rspec'
+Autotest.add_discovery { "rspec2" }
Autotest.add_hook :initialize do |at|
at.clear_mappings
@@ -36,10 +35,3 @@
at.files_matching %r!spec/(unit|integration)/.*\.rb!
}
end
-
-class Autotest::FacterRspec < Autotest::Rspec
- def spec_commands
- ENV["AUTOTEST"] = "true"
- ENV["PATH"].split(File::PATH_SEPARATOR).collect { |dir| File.join(dir, "spec") }
- end
-end
View
9 autotest/discover.rb
@@ -1,9 +0,0 @@
-require 'autotest'
-
-Autotest.add_discovery do
- "rspec"
-end
-
-Autotest.add_discovery do
- "facter"
-end
View
74 autotest/rspec.rb
@@ -1,74 +0,0 @@
-require 'autotest'
-
-Autotest.add_hook :initialize do |at|
- at.clear_mappings
- # watch out: Ruby bug (1.8.6):
- # %r(/) != /\//
- at.add_mapping(%r%^spec/.*\.rb$%) { |filename, _|
- filename
- }
- at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m|
- ["spec/#{m[1]}_spec.rb"]
- }
- at.add_mapping(%r%^spec/(spec_helper|shared/.*)\.rb$%) {
- at.files_matching %r{^spec/.*_spec\.rb$}
- }
-end
-
-class RspecCommandError < StandardError; end
-
-class Autotest::Rspec < Autotest
-
- def initialize
- super
-
- self.failed_results_re = /^\d+\)\n(?:\e\[\d*m)?(?:.*?Error in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/m
- self.completed_re = /\Z/ # FIX: some sort of summary line at the end?
- end
-
- def consolidate_failures(failed)
- filters = Hash.new { |h,k| h[k] = [] }
- failed.each do |spec, failed_trace|
- if f = test_files_for(failed).find { |f| failed_trace =~ Regexp.new(f) } then
- filters[f] << spec
- break
- end
- end
- return filters
- end
-
- def make_test_cmd(files_to_test)
- return "#{ruby} -S #{spec_command} #{add_options_if_present} #{files_to_test.keys.flatten.join(' ')}"
- end
-
- def add_options_if_present
- File.exist?("spec/spec.opts") ? "-O spec/spec.opts " : ""
- end
-
- # Finds the proper spec command to use. Precendence is set in the
- # lazily-evaluated method spec_commands. Alias + Override that in
- # ~/.autotest to provide a different spec command then the default
- # paths provided.
- def spec_command(separator=File::ALT_SEPARATOR)
- unless defined? @spec_command then
- @spec_command = spec_commands.find { |cmd| File.exists? cmd }
-
- raise RspecCommandError, "No spec command could be found!" unless @spec_command
-
- @spec_command.gsub! File::SEPARATOR, separator if separator
- end
- @spec_command
- end
-
- # Autotest will look for spec commands in the following
- # locations, in this order:
- #
- # * bin/spec
- # * default spec bin/loader installed in Rubygems
- def spec_commands
- [
- File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin', 'spec')),
- File.join(Config::CONFIG['bindir'], 'spec')
- ]
- end
-end

0 comments on commit 1cb9cb6

Please sign in to comment.
Something went wrong with that request. Please try again.