summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-02-16 16:27:27 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-02-16 16:27:27 +0000
commit5f8d61553a9d83087604fe5b68146503cf55d1be (patch)
tree48ce04255a2eab6c7439f8db9fa3549cd4faab47
parent6cc8157fb0e36f2435b201abad81affe3b8e17ac (diff)
downloadpuppet-5f8d61553a9d83087604fe5b68146503cf55d1be.tar.gz
puppet-5f8d61553a9d83087604fe5b68146503cf55d1be.tar.xz
puppet-5f8d61553a9d83087604fe5b68146503cf55d1be.zip
Removed some of the autorequire stuff from :exec because it created untenable require loops, and created a test case for some complicated exec + file recursion. The test case fails, and I want to have a clean committed repository before i mess much more in trying to fix it, which might actually not be possible.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@921 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r--lib/puppet/type.rb4
-rwxr-xr-xlib/puppet/type/exec.rb7
-rwxr-xr-xlib/puppet/type/pfile/mode.rb2
-rwxr-xr-xtest/types/exec.rb37
4 files changed, 45 insertions, 5 deletions
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index 717c566eb..748a69906 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -1383,7 +1383,9 @@ class Type < Puppet::Element
obj = dep
else
# Skip autorequires that we aren't managing
- next unless obj = typeobj[dep]
+ unless obj = typeobj[dep]
+ next
+ end
end
# Skip autorequires that we already require
diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb
index 0fec635c8..b12bf159d 100755
--- a/lib/puppet/type/exec.rb
+++ b/lib/puppet/type/exec.rb
@@ -392,7 +392,12 @@ module Puppet
reqs << self[:cwd]
end
- [:command, :onlyif, :unless].each { |param|
+ self[:command].scan(/^(#{File::SEPARATOR}\S+)/) { |str|
+ self.warning "adding %s" % str
+ reqs << str
+ }
+
+ [:onlyif, :unless].each { |param|
next unless tmp = self[param]
# And search the command line for files, adding any we find. This
diff --git a/lib/puppet/type/pfile/mode.rb b/lib/puppet/type/pfile/mode.rb
index 455d52ce1..3d593caef 100755
--- a/lib/puppet/type/pfile/mode.rb
+++ b/lib/puppet/type/pfile/mode.rb
@@ -93,7 +93,7 @@ module Puppet
if @is == :absent
@parent.stat(true)
self.retrieve
- #self.debug "%s: after refresh, is '%s'" % [self.class.name,@is]
+ self.debug "%s: after refresh, is '%o'" % [self.class.name,@is]
if @is == :absent
self.info "File does not exist; cannot set mode" %
@parent.name
diff --git a/test/types/exec.rb b/test/types/exec.rb
index f097e1860..004cd6c29 100755
--- a/test/types/exec.rb
+++ b/test/types/exec.rb
@@ -9,8 +9,6 @@ require 'puppettest'
require 'test/unit'
require 'facter'
-# $Id$
-
class TestExec < Test::Unit::TestCase
include TestPuppet
def test_execution
@@ -399,4 +397,39 @@ class TestExec < Test::Unit::TestCase
assert_apply(exec)
end
+
+ def test_execthenfile
+ exec = nil
+ file = nil
+ basedir = tempfile()
+ path = File.join(basedir, "subfile")
+ assert_nothing_raised {
+ exec = Puppet.type(:exec).create(
+ :name => "mkdir",
+ :path => "/usr/bin:/bin",
+ :creates => basedir,
+ :command => "mkdir %s; touch %s" % [basedir, path]
+
+ )
+ }
+
+ assert_nothing_raised {
+ file = Puppet.type(:file).create(
+ :path => basedir,
+ :recurse => true,
+ :mode => "755",
+ :require => ["exec", "mkdir"]
+ )
+ }
+
+ Puppet::Type.finalize
+
+ comp = newcomp(file, exec)
+ assert_events([:executed_command, :file_changed], comp)
+
+ assert(FileTest.exists?(path), "Exec ran first")
+ assert(File.stat(path).mode & 007777 == 0755)
+ end
end
+
+# $Id$