[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 2.6.1rc3-129-g74f8285

James Turnbull james at lovedthanlost.net
Tue Sep 7 13:30:37 UTC 2010


The following commit has been merged in the upstream branch:
commit 07d0be4684f75e6edc6fbb5d1397dd79b8ca2b6b
Author: Matt Robinson <matt at puppetlabs.com>
Date:   Fri Jul 2 22:19:28 2010 -0700

    [#4308] Remove puppettest from specs
    
    The less stuff being done in the spec_helper the better for reasoning
    about what's happening in the tests.  puppettest.rb does a lot of things
    that aren't necessary for the specs, so this patch gets those things out
    of the spec_helper.
    
    Reviewed by: Jesse Wolfe

diff --git a/spec/integration/provider/mailalias/aliases_spec.rb b/spec/integration/provider/mailalias/aliases_spec.rb
index 8106c2c..0511205 100755
--- a/spec/integration/provider/mailalias/aliases_spec.rb
+++ b/spec/integration/provider/mailalias/aliases_spec.rb
@@ -2,7 +2,6 @@
 
 require File.dirname(__FILE__) + '/../../../spec_helper'
 
-require 'puppettest'
 require 'puppettest/support/utils'
 require 'puppettest/fileparsing'
 
@@ -11,15 +10,16 @@ provider_class = Puppet::Type.type(:mailalias).provider(:aliases)
 describe provider_class do
   include PuppetTest
   include PuppetTest::FileParsing
+  include PuppetTest::Support::Utils
 
   before :each do
     @provider = provider_class
   end
 
   # #1560
-  PuppetTest.fakedata("data/providers/mailalias/aliases").each { |file|
-    it "should be able to parse the examples in #{file}" do
+  it "should be able to parse the mailalias examples" do
+    fakedata("data/providers/mailalias/aliases").each { |file|
       fakedataparse(file)
-    end
-  }
+    }
+  end
 end
diff --git a/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb b/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb
index 15a7cd0..3762b70 100644
--- a/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb
+++ b/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb
@@ -5,7 +5,6 @@ dir = File.expand_path(File.dirname(__FILE__))
 end
 
 require 'spec'
-require 'puppettest'
 require 'puppettest/runnable_test'
 
 module Spec
diff --git a/spec/monkey_patches/publicize_methods.rb b/spec/monkey_patches/publicize_methods.rb
new file mode 100644
index 0000000..b39e9c0
--- /dev/null
+++ b/spec/monkey_patches/publicize_methods.rb
@@ -0,0 +1,11 @@
+# Some monkey-patching to allow us to test private methods.
+class Class
+    def publicize_methods(*methods)
+        saved_private_instance_methods = methods.empty? ? self.private_instance_methods : methods
+
+        self.class_eval { public(*saved_private_instance_methods) }
+        yield
+        self.class_eval { private(*saved_private_instance_methods) }
+    end
+end
+
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 539ae20..ab7ff6c 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -6,20 +6,8 @@ dir = File.expand_path(File.dirname(__FILE__))
 $LOAD_PATH.unshift("#{dir}/")
 $LOAD_PATH.unshift("#{dir}/lib") # a spec-specific test lib dir
 $LOAD_PATH.unshift("#{dir}/../lib")
-$LOAD_PATH.unshift("#{dir}/../test/lib")  # Add the old test dir, so that we can still find our local mocha and spec
 
-# include any gems in vendor/gems
-Dir["#{dir}/../vendor/gems/**"].each do |path|
-  libpath = File.join(path, "lib")
-  if File.directory?(libpath)
-    $LOAD_PATH.unshift(libpath)
-  else
-    $LOAD_PATH.unshift(path)
-  end
-end
-
-require 'puppettest'
-require 'puppettest/runnable_test'
+require 'puppet'
 require 'mocha'
 gem 'rspec', '>=1.2.9'
 require 'spec/autorun'
@@ -29,17 +17,13 @@ module PuppetSpec
   FIXTURE_DIR = File.join(dir = File.expand_path(File.dirname(__FILE__)), "fixtures") unless defined?(FIXTURE_DIR)
 end
 
-# load any monkey-patches
-Dir["#{dir}/monkey_patches/*.rb"].map { |file| require file }
+require 'monkey_patches/alias_should_to_must'
+require 'monkey_patches/add_confine_and_runnable_to_rspec_dsl'
+require 'monkey_patches/publicize_methods'
 
 Spec::Runner.configure do |config|
   config.mock_with :mocha
 
-#  config.prepend_before :all do
-#      setup_mocks_for_rspec
-#      setup if respond_to? :setup
-#  end
-#
   config.prepend_after :each do
     Puppet.settings.clear
     Puppet::Node::Environment.clear
@@ -88,10 +72,4 @@ Spec::Runner.configure do |config|
   end
 end
 
-# We need this because the RAL uses 'should' as a method.  This
-# allows us the same behaviour but with a different method name.
-class Object
-  alias :must :should
-end
-
 end
diff --git a/spec/unit/network/http/webrick/rest_spec.rb b/spec/unit/network/http/webrick/rest_spec.rb
index aa2b931..b00c62d 100755
--- a/spec/unit/network/http/webrick/rest_spec.rb
+++ b/spec/unit/network/http/webrick/rest_spec.rb
@@ -2,6 +2,7 @@
 
 require File.dirname(__FILE__) + '/../../../../spec_helper'
 require 'puppet/network/http'
+require 'webrick'
 require 'puppet/network/http/webrick/rest'
 
 describe Puppet::Network::HTTP::WEBrickREST do
diff --git a/spec/unit/parser/lexer_spec.rb b/spec/unit/parser/lexer_spec.rb
index 7e51423..b27980b 100755
--- a/spec/unit/parser/lexer_spec.rb
+++ b/spec/unit/parser/lexer_spec.rb
@@ -644,7 +644,6 @@ end
 
 require 'puppettest/support/utils'
 describe "Puppet::Parser::Lexer in the old tests when lexing example files" do
-  extend PuppetTest
   extend PuppetTest::Support::Utils
   textfiles do |file|
     it "should correctly lex #{file}" do
diff --git a/spec/unit/provider/ssh_authorized_key/parsed_spec.rb b/spec/unit/provider/ssh_authorized_key/parsed_spec.rb
index 059d010..6485279 100755
--- a/spec/unit/provider/ssh_authorized_key/parsed_spec.rb
+++ b/spec/unit/provider/ssh_authorized_key/parsed_spec.rb
@@ -3,14 +3,16 @@
 require File.dirname(__FILE__) + '/../../../spec_helper'
 
 require 'puppet_spec/files'
-require 'puppettest'
 require 'puppettest/support/utils'
 require 'puppettest/fileparsing'
+require 'tmpdir'
+require 'puppettest/fakes'
 
 provider_class = Puppet::Type.type(:ssh_authorized_key).provider(:parsed)
 
 describe provider_class do
   include PuppetSpec::Files
+  extend PuppetTest::Support::Utils
   include PuppetTest
   include PuppetTest::FileParsing
 
@@ -49,7 +51,7 @@ describe provider_class do
     @provider.target_object(@keyfile).read
   end
 
-  PuppetTest.fakedata("data/providers/ssh_authorized_key/parsed").each { |file|
+  fakedata("data/providers/ssh_authorized_key/parsed").each { |file|
     it "should be able to parse example data in #{file}" do
       fakedataparse(file)
     end
diff --git a/spec/unit/reports/tagmail_spec.rb b/spec/unit/reports/tagmail_spec.rb
index 4349e99..59cb5b2 100755
--- a/spec/unit/reports/tagmail_spec.rb
+++ b/spec/unit/reports/tagmail_spec.rb
@@ -3,12 +3,12 @@
 Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
 
 require 'puppet/reports'
-require 'puppettest'
+require 'puppettest/support/utils'
 
 tagmail = Puppet::Reports.report(:tagmail)
 
 describe tagmail do
-  extend PuppetTest
+  extend PuppetTest::Support::Utils
 
   before do
     @processor = Puppet::Transaction::Report.new
diff --git a/spec/unit/util/backups_spec.rb b/spec/unit/util/backups_spec.rb
index 5c10d4c..259b186 100755
--- a/spec/unit/util/backups_spec.rb
+++ b/spec/unit/util/backups_spec.rb
@@ -3,7 +3,6 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 
 require 'puppet/util/backups'
-include PuppetTest
 
 describe Puppet::Util::Backups do
   before do
diff --git a/test/lib/mocha_standalone.rb b/test/lib/mocha_standalone.rb
deleted file mode 100644
index ce60581..0000000
--- a/test/lib/mocha_standalone.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-require 'mocha/standalone'
-require 'mocha/object'
diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb
index 294d0ef..0b3a89a 100755
--- a/test/lib/puppettest.rb
+++ b/test/lib/puppettest.rb
@@ -6,17 +6,6 @@ mainlib = File.expand_path(File.join(File.dirname(__FILE__), '../../lib'))
 $LOAD_PATH.unshift(mainlib) unless $LOAD_PATH.include?(mainlib)
 
 require 'puppet'
-
-# include any gems in vendor/gems
-Dir["#{mainlib}/../vendor/gems/**"].each do |path|
-  libpath = File.join(path, "lib")
-  if File.directory?(libpath)
-    $LOAD_PATH.unshift(libpath)
-  else
-    $LOAD_PATH.unshift(path)
-  end
-end
-
 require 'mocha'
 
 # Only load the test/unit class if we're not in the spec directory.
@@ -31,16 +20,7 @@ if ARGV.include?("-d")
   $console = true
 end
 
-# Some monkey-patching to allow us to test private methods.
-class Class
-  def publicize_methods(*methods)
-    saved_private_instance_methods = methods.empty? ? self.private_instance_methods : methods
-
-    self.class_eval { public(*saved_private_instance_methods) }
-    yield
-    self.class_eval { private(*saved_private_instance_methods) }
-  end
-end
+require File.expand_path(File.join(File.dirname(__FILE__), '../../spec/monkey_patches/publicize_methods'))
 
 module PuppetTest
   # These need to be here for when rspec tests use these
diff --git a/test/lib/puppettest/fakes.rb b/test/lib/puppettest/fakes.rb
index aaa7110..712332b 100644
--- a/test/lib/puppettest/fakes.rb
+++ b/test/lib/puppettest/fakes.rb
@@ -1,4 +1,4 @@
-require 'puppettest'
+require File.expand_path(File.join(File.dirname(__FILE__), '../../../lib/puppet/util'))
 
 module PuppetTest
   # A baseclass for the faketypes.
diff --git a/test/lib/puppettest/support/assertions.rb b/test/lib/puppettest/support/assertions.rb
index 7f326b1..31fa3f1 100644
--- a/test/lib/puppettest/support/assertions.rb
+++ b/test/lib/puppettest/support/assertions.rb
@@ -1,8 +1,6 @@
-require 'puppettest'
 require 'puppettest/support/utils'
 require 'fileutils'
 
-
 module PuppetTest
   include PuppetTest::Support::Utils
   def assert_logged(level, regex, msg = nil)
diff --git a/test/lib/puppettest/support/utils.rb b/test/lib/puppettest/support/utils.rb
index edc81d3..e022f12 100644
--- a/test/lib/puppettest/support/utils.rb
+++ b/test/lib/puppettest/support/utils.rb
@@ -1,5 +1,3 @@
-require 'puppettest'
-
 module PuppetTest::Support
 end
 module PuppetTest::Support::Utils
@@ -7,6 +5,30 @@ module PuppetTest::Support::Utils
     Puppet.warning "#{type}: #{ObjectSpace.each_object(type) { |o| }}"
   end
 
+  def basedir(*list)
+    unless defined? @@basedir
+      Dir.chdir(File.dirname(__FILE__)) do
+        @@basedir = File.dirname(File.dirname(File.dirname(File.dirname(Dir.getwd))))
+      end
+    end
+    if list.empty?
+      @@basedir
+    else
+      File.join(@@basedir, *list)
+    end
+  end
+
+  def fakedata(dir,pat='*')
+    glob = "#{basedir}/test/#{dir}/#{pat}"
+    files = Dir.glob(glob,File::FNM_PATHNAME)
+    raise Puppet::DevError, "No fakedata matching #{glob}" if files.empty?
+    files
+  end
+
+  def datadir(*list)
+    File.join(basedir, "test", "data", *list)
+  end
+
   #
   # TODO: I think this method needs to be renamed to something a little more
   # explanatory.
@@ -38,10 +60,6 @@ module PuppetTest::Support::Utils
     config
   end
 
-  # stop any services that might be hanging around
-  def stopservices
-  end
-
   # TODO: rewrite this to use the 'etc' module.
 
   # Define a variable that contains the name of my user.
@@ -84,7 +102,7 @@ module PuppetTest::Support::Utils
   end
 
   def fakefile(name)
-    ary = [PuppetTest.basedir, "test"]
+    ary = [basedir, "test"]
     ary += name.split("/")
     file = File.join(ary)
     raise Puppet::DevError, "No fakedata file #{file}" unless FileTest.exists?(file)
@@ -140,16 +158,3 @@ module PuppetTest::Support::Utils
     config
   end
 end
-
-module PuppetTest
-  include PuppetTest::Support::Utils
-
-  def fakedata(dir,pat='*')
-    glob = "#{basedir}/test/#{dir}/#{pat}"
-    files = Dir.glob(glob,File::FNM_PATHNAME)
-    raise Puppet::DevError, "No fakedata matching #{glob}" if files.empty?
-    files
-  end
-  module_function :fakedata
-
-end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list