From c7b36b76f1319ee18efee8ec1bdf08825cb66f81 Mon Sep 17 00:00:00 2001 From: Rick Bradley Date: Fri, 26 Oct 2007 15:23:51 -0500 Subject: One significant step closer to getting autotest running properly on the Puppet specs. Created a spec/lib/monkey_patches/ directory for holding patches to RSpec functionality. Extraced 'confine' and 'runnable?' support from the local copy of RSpec (spec/lib/spec/) and now load them from the monkey_patches/ directory. Fixed a bad include in one of the specs. Made it possible for the gem-installed spec binary (which autotest calls) to be used with Puppet. Imported the Autotest::Rspec class, created a PuppetRspec autotest class, added a discovery.rb file for autotest to pick these up. Autotest still has the following problems: * it needs to be run with the proper include path: % ruby -I spec/lib/ `which autotest` * the patterns in our custom autotest handler (puppet_rspec) aren't yet fully specified (they only recognize changes in our spec files, not changes in the puppet libs which they are testing) --- spec/lib/autotest/puppet_rspec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 spec/lib/autotest/puppet_rspec.rb (limited to 'spec/lib/autotest/puppet_rspec.rb') diff --git a/spec/lib/autotest/puppet_rspec.rb b/spec/lib/autotest/puppet_rspec.rb new file mode 100644 index 000000000..e7de8b615 --- /dev/null +++ b/spec/lib/autotest/puppet_rspec.rb @@ -0,0 +1,13 @@ +require 'autotest' +require 'autotest/rspec' + +class Autotest::PuppetRspec < Autotest::Rspec + def initialize # :nodoc: + super + @test_mappings = { + %r%^spec/(unit|integration)/.*\.rb$% => proc { |filename, _| + filename + }, + } + end +end -- cgit From 956daa5b4b1c61db9a5e1d7638ca819005fd7ef0 Mon Sep 17 00:00:00 2001 From: Rick Bradley Date: Fri, 26 Oct 2007 22:58:47 -0500 Subject: This won't be perfect by any stretch, but put in a moderately reasonable autotest config file. --- spec/lib/autotest/puppet_rspec.rb | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'spec/lib/autotest/puppet_rspec.rb') diff --git a/spec/lib/autotest/puppet_rspec.rb b/spec/lib/autotest/puppet_rspec.rb index e7de8b615..8536f3912 100644 --- a/spec/lib/autotest/puppet_rspec.rb +++ b/spec/lib/autotest/puppet_rspec.rb @@ -5,9 +5,42 @@ class Autotest::PuppetRspec < Autotest::Rspec def initialize # :nodoc: super @test_mappings = { + # the libraries under lib/puppet + %r%^lib/puppet/(.*)\.rb$% => proc { |filename, m| + files_matching %r!spec/(unit|integration)/#{m[1]}.rb! + }, + + # the actual spec files themselves %r%^spec/(unit|integration)/.*\.rb$% => proc { |filename, _| filename }, + + # force a complete re-run for all of these: + + # main puppet lib + %r!^lib/puppet\.rb$! => proc { |filename, _| + files_matching %r!spec/(unit|integration)/.*\.rb! + }, + + # the spec_helper + %r!^spec/spec_helper\.rb$! => proc { |filename, _| + files_matching %r!spec/(unit|integration)/.*\.rb! + }, + + # the puppet test libraries + %r!^test/lib/puppettest/.*! => proc { |filename, _| + files_matching %r!spec/(unit|integration)/.*\.rb! + }, + + # the puppet spec libraries + %r!^spec/lib/spec.*! => proc { |filename, _| + files_matching %r!spec/(unit|integration)/.*\.rb! + }, + + # the monkey patches for rspec + %r!^spec/lib/monkey_patches/.*! => proc { |filename, _| + files_matching %r!spec/(unit|integration)/.*\.rb! + }, } end end -- cgit