summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-04-05 20:27:27 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-04-05 20:27:27 +0000
commit1e4abaeccaef620f7e44b21479d5c9ea52c3360a (patch)
treea8fc334c5f2e534bfd929130d689d53f168269e8
parent7dae24f481282539bb8b2ef544d4c7476fb7631b (diff)
downloadpuppet-1e4abaeccaef620f7e44b21479d5c9ea52c3360a.tar.gz
puppet-1e4abaeccaef620f7e44b21479d5c9ea52c3360a.tar.xz
puppet-1e4abaeccaef620f7e44b21479d5c9ea52c3360a.zip
moving cwd existence check into "sync" instead of "validate"
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1085 980ebf18-57e1-0310-9a29-db15c13687c0
-rwxr-xr-xlib/puppet/type/exec.rb11
-rwxr-xr-xtest/types/exec.rb34
2 files changed, 41 insertions, 4 deletions
diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb
index a7d637e57..6fec43520 100755
--- a/lib/puppet/type/exec.rb
+++ b/lib/puppet/type/exec.rb
@@ -128,6 +128,12 @@ module Puppet
self.checkexe
+ if cwd = self.parent[:cwd]
+ unless File.directory?(cwd)
+ self.fail "Working directory '%s' does not exist" % cwd
+ end
+ end
+
# We need a dir to change to, even if it's just the cwd
dir = self.parent[:cwd] || Dir.pwd
tmppath = ENV["PATH"]
@@ -248,10 +254,6 @@ module Puppet
if dir.is_a?(Array)
dir = dir[0]
end
-
- unless File.directory?(dir)
- self.fail "Directory '%s' does not exist" % dir
- end
dir
end
@@ -391,6 +393,7 @@ module Puppet
validatecmd(self[:command])
end
+ # FIXME exec should autorequire any exec that 'creates' our cwd
autorequire(:file) do
reqs = []
diff --git a/test/types/exec.rb b/test/types/exec.rb
index f776dbd3b..782f1a871 100755
--- a/test/types/exec.rb
+++ b/test/types/exec.rb
@@ -449,6 +449,40 @@ class TestExec < Test::Unit::TestCase
end
end
end
+
+ def test_createcwdandexe
+ exec1 = exec2 = nil
+ dir = tempfile()
+ file = tempfile()
+
+ assert_nothing_raised {
+ exec1 = Puppet.type(:exec).create(
+ :path => ENV["PATH"],
+ :command => "mkdir #{dir}"
+ )
+ }
+
+ assert_nothing_raised("Could not create exec w/out existing cwd") {
+ exec2 = Puppet.type(:exec).create(
+ :path => ENV["PATH"],
+ :command => "touch #{file}",
+ :cwd => dir
+ )
+ }
+
+ assert_raise(Puppet::Error) do
+ exec2.state(:returns).sync
+ end
+
+ assert_nothing_raised do
+ exec2[:require] = ["exec", exec1.name]
+ exec2.finish
+ end
+
+ assert_apply(exec1, exec2)
+
+ assert(FileTest.exists?(file))
+ end
end
# $Id$