diff options
| author | Luke Kanies <luke@madstop.com> | 2008-02-18 09:38:32 -0600 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2008-02-18 09:38:32 -0600 |
| commit | a53106cf08c28e996502cba703f64944250a4b29 (patch) | |
| tree | 4dee55340a4d91083e940fecb9087ecfaa7c279f /test | |
| parent | be58bb5c4bc19e59685e0a8953eaf2d3b7844110 (diff) | |
| parent | 62d7616a457f33eb660454fcdcefe8dab84522c0 (diff) | |
| download | puppet-a53106cf08c28e996502cba703f64944250a4b29.tar.gz puppet-a53106cf08c28e996502cba703f64944250a4b29.tar.xz puppet-a53106cf08c28e996502cba703f64944250a4b29.zip | |
Merge branch '0.24.x'
Conflicts:
CHANGELOG
man/man8/puppet.8
Diffstat (limited to 'test')
| -rwxr-xr-x | test/executables/puppetbin.rb | 17 | ||||
| -rwxr-xr-x | test/lib/puppettest.rb | 3 | ||||
| -rwxr-xr-x | test/util/autoload.rb | 29 |
3 files changed, 43 insertions, 6 deletions
diff --git a/test/executables/puppetbin.rb b/test/executables/puppetbin.rb index 218787c92..08329efb6 100755 --- a/test/executables/puppetbin.rb +++ b/test/executables/puppetbin.rb @@ -83,5 +83,22 @@ class TestPuppetBin < Test::Unit::TestCase assert(FileTest.exists?(path), "Failed to create config'ed file") end + + def test_parseonly + path = tempfile() + manifest = tempfile() + puppet = %x{which puppet}.chomp + if puppet == "" + Puppet.info "cannot find puppet; cannot test parseonly" + return + end + code = 'File <<| |>> + include nosuchclass' + + assert_nothing_raised { + IO.popen("#{puppet} --parseonly", 'w') { |p| p.puts code } + } + assert($? == 0, "parseonly test exited with code %s" % $?.to_i) + end end diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb index 6c95985bf..902831e68 100755 --- a/test/lib/puppettest.rb +++ b/test/lib/puppettest.rb @@ -17,6 +17,8 @@ Dir["#{mainlib}/../vendor/gems/**"].each do |path| end end +require 'mocha' + # Only load the test/unit class if we're not in the spec directory. # Else we get the bogus 'no tests, no failures' message. unless Dir.getwd =~ /spec/ @@ -315,7 +317,6 @@ module PuppetTest rescue Timeout::Error # just move on end - mocha_verify end def logstore diff --git a/test/util/autoload.rb b/test/util/autoload.rb index 6babed774..de503ab99 100755 --- a/test/util/autoload.rb +++ b/test/util/autoload.rb @@ -103,10 +103,10 @@ TestAutoload.newthing(:#{name.to_s}) assert(loader.send(:searchpath).include?(dir), "searchpath does not include the libdir") end - # This causes very strange behaviour in the tests. We need to make sure we - # require the same path that a user would use, otherwise we'll result in - # a reload of the - def test_require_does_not_cause_reload + # This tests #1027, which was caused by using the unqualified + # path for requires, which was initially done so that the kernel + # would keep track of which files got loaded. + def test_require_uses_full_path loadname = "testing" loader = Puppet::Util::Autoload.new(self.class, loadname) @@ -120,7 +120,26 @@ TestAutoload.newthing(:#{name.to_s}) Dir.expects(:glob).with("#{dir}/*.rb").returns(file) - Kernel.expects(:require).with(File.join(loadname, subname)) + Kernel.expects(:require).with(file) loader.loadall end + + def test_searchpath_includes_plugin_dirs + moddir = "/what/ever" + libdir = "/other/dir" + Puppet.settings.stubs(:value).with(:modulepath).returns(moddir) + Puppet.settings.stubs(:value).with(:libdir).returns(libdir) + + loadname = "testing" + loader = Puppet::Util::Autoload.new(self.class, loadname) + + # Currently, include both plugins and libs. + paths = %w{plugins lib}.inject({}) { |hash, d| hash[d] = File.join(moddir, "testing", d); FileTest.stubs(:directory?).with(hash[d]).returns(true); hash } + Dir.expects(:glob).with("#{moddir}/*/{plugins,lib}").returns(paths.values) + + searchpath = loader.searchpath + paths.each do |dir, path| + assert(searchpath.include?(path), "search path did not include path for %s" % dir) + end + end end |
