summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Wolfe <jes5199@gmail.com>2011-03-25 16:24:01 -0700
committerJesse Wolfe <jes5199@gmail.com>2011-03-25 16:24:01 -0700
commitcc43dd79ad8d40b5b7bf3f4480ff794e99f733a4 (patch)
tree22a21fb53c44bcb433dafb8bb373e3f41afde6eb
parentc0236aab1145e01e26f59cf1d823dc6966ba567b (diff)
parent0fec21fcd887685cf8421fdc309b878088f9fc48 (diff)
downloadpuppet-cc43dd79ad8d40b5b7bf3f4480ff794e99f733a4.tar.gz
puppet-cc43dd79ad8d40b5b7bf3f4480ff794e99f733a4.tar.xz
puppet-cc43dd79ad8d40b5b7bf3f4480ff794e99f733a4.zip
Merge commit '2.6.next^1' into next
These changes were superseded by existing commits in next: lib/puppet/parser/compiler.rb spec/unit/parser/compiler_spec.rb
-rw-r--r--CHANGELOG5
-rw-r--r--lib/puppet/file_serving/fileset.rb1
-rwxr-xr-xlib/puppet/type/exec.rb14
-rwxr-xr-xspec/unit/file_serving/fileset_spec.rb8
-rwxr-xr-xspec/unit/type/exec_spec.rb16
5 files changed, 32 insertions, 12 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 2885596e3..755dd82a8 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,5 +1,6 @@
-2.6.7rc1
-========
+2.6.7
+=====
+17f673d Updated CHANGELOG for 2.6.7rc1
852fb97 (#5073) Download plugins even if you're filtering on tags
4f34dbf Fix #5610: Prevent unnecessary RAL lookups
9781032 Revert "Merge branch 'ticket/2.6.x/5605' of git://github.com/stschulte/puppet into 2.6.next"
diff --git a/lib/puppet/file_serving/fileset.rb b/lib/puppet/file_serving/fileset.rb
index fdbcf93a3..c020f036d 100644
--- a/lib/puppet/file_serving/fileset.rb
+++ b/lib/puppet/file_serving/fileset.rb
@@ -59,6 +59,7 @@ class Puppet::FileServing::Fileset
end
def initialize(path, options = {})
+ path = path.chomp(File::SEPARATOR)
raise ArgumentError.new("Fileset paths must be fully qualified") unless File.expand_path(path) == path
@path = path
diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb
index 773df2bb4..3ba488f19 100755
--- a/lib/puppet/type/exec.rb
+++ b/lib/puppet/type/exec.rb
@@ -220,19 +220,17 @@ module Puppet
newparam(:timeout) do
desc "The maximum time the command should take. If the command takes
longer than the timeout, the command is considered to have failed
- and will be stopped. Use any negative number to disable the timeout.
+ and will be stopped. Use 0 to disable the timeout.
The time is specified in seconds."
munge do |value|
value = value.shift if value.is_a?(Array)
- if value.is_a?(String)
- unless value =~ /^[-\d.]+$/
- raise ArgumentError, "The timeout must be a number."
- end
- Float(value)
- else
- value
+ begin
+ value = Float(value)
+ rescue ArgumentError => e
+ raise ArgumentError, "The timeout must be a number."
end
+ [value, 0.0].max
end
defaultto 300
diff --git a/spec/unit/file_serving/fileset_spec.rb b/spec/unit/file_serving/fileset_spec.rb
index 1ef9cdc50..3b12c953e 100755
--- a/spec/unit/file_serving/fileset_spec.rb
+++ b/spec/unit/file_serving/fileset_spec.rb
@@ -13,6 +13,14 @@ describe Puppet::FileServing::Fileset, " when initializing" do
proc { Puppet::FileServing::Fileset.new("some/file") }.should raise_error(ArgumentError)
end
+ it "should not fail if the path is fully qualified, with a trailing separator" do
+ path = "/some/path/with/trailing/separator"
+ path_with_separator = "#{path}#{File::SEPARATOR}"
+ File.stubs(:lstat).with(path).returns stub('stat')
+ fileset = Puppet::FileServing::Fileset.new(path_with_separator)
+ fileset.path.should == path
+ end
+
it "should fail if its path does not exist" do
File.expects(:lstat).with("/some/file").returns nil
proc { Puppet::FileServing::Fileset.new("/some/file") }.should raise_error(ArgumentError)
diff --git a/spec/unit/type/exec_spec.rb b/spec/unit/type/exec_spec.rb
index a1ffb1636..86b824423 100755
--- a/spec/unit/type/exec_spec.rb
+++ b/spec/unit/type/exec_spec.rb
@@ -307,7 +307,7 @@ describe Puppet::Type.type(:exec) do
end
describe "when setting timeout" do
- [-3.5, -1, 0, 0.1, 1, 10, 4294967295].each do |valid|
+ [0, 0.1, 1, 10, 4294967295].each do |valid|
it "should accept '#{valid}' as valid" do
@exec[:timeout] = valid
@exec[:timeout].should == valid
@@ -319,7 +319,7 @@ describe Puppet::Type.type(:exec) do
end
end
- ['1/2', '1_000_000', '+12', '', 'foo'].each do |invalid|
+ ['1/2', '', 'foo', '5foo'].each do |invalid|
it "should reject '#{invalid}' as invalid" do
expect { @exec[:timeout] = invalid }.
should raise_error Puppet::Error, /The timeout must be a number/
@@ -337,6 +337,18 @@ describe Puppet::Type.type(:exec) do
sleep_exec = Puppet::Type.type(:exec).new(:name => 'sleep 1', :path => ['/bin'], :timeout => '0.2')
lambda { sleep_exec.refresh }.should raise_error Puppet::Error, "Command exceeded timeout"
end
+
+ it "should convert timeout to a float" do
+ resource = Puppet::Type.type(:exec).new :command => "/bin/false", :timeout => "12"
+ resource[:timeout].should be_a(Float)
+ resource[:timeout].should == 12.0
+ end
+
+ it "should munge negative timeouts to 0.0" do
+ resource = Puppet::Type.type(:exec).new :command => "/bin/false", :timeout => "-12.0"
+ resource.parameter(:timeout).value.should be_a(Float)
+ resource.parameter(:timeout).value.should == 0.0
+ end
end
describe "when setting tries" do