summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-02-08 05:11:49 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-02-08 05:11:49 +0000
commit1756bec99b9136463e5d35f1de4119b813ce40cc (patch)
tree380c1f37b2238fd37842a3b9934f6be16f36b450
parenta216df2bcb304ad379e152f2f59ef7d942f54f3b (diff)
downloadpuppet-1756bec99b9136463e5d35f1de4119b813ce40cc.tar.gz
puppet-1756bec99b9136463e5d35f1de4119b813ce40cc.tar.xz
puppet-1756bec99b9136463e5d35f1de4119b813ce40cc.zip
Fixing #484. Moving unit tests at the same time.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2181 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r--lib/puppet/util/config.rb9
-rwxr-xr-xtest/lib/puppettest.rb5
-rwxr-xr-xtest/util/autoload.rb (renamed from test/other/autoload.rb)0
-rwxr-xr-xtest/util/config.rb (renamed from test/other/config.rb)21
-rwxr-xr-xtest/util/features.rb (renamed from test/other/features.rb)0
-rwxr-xr-xtest/util/filetype.rb (renamed from test/other/filetype.rb)0
-rwxr-xr-xtest/util/inifile.rb (renamed from test/other/inifile.rb)0
-rwxr-xr-xtest/util/loadedfile.rb (renamed from test/other/loadedfile.rb)0
-rwxr-xr-xtest/util/log.rb (renamed from test/other/log.rb)0
-rwxr-xr-xtest/util/metrics.rb (renamed from test/other/metrics.rb)0
-rwxr-xr-xtest/util/storage.rb (renamed from test/other/storage.rb)0
11 files changed, 34 insertions, 1 deletions
diff --git a/lib/puppet/util/config.rb b/lib/puppet/util/config.rb
index 097d59b9f..b94b84051 100644
--- a/lib/puppet/util/config.rb
+++ b/lib/puppet/util/config.rb
@@ -39,7 +39,7 @@ class Puppet::Util::Config
param = symbolize(param)
unless @config.include?(param)
raise Puppet::Error,
- "Unknown configuration parameter %s" % param.inspect
+ "Attempt to assign a value to unknown configuration parameter %s" % param.inspect
end
unless @order.include?(param)
@order << param
@@ -283,6 +283,13 @@ class Puppet::Util::Config
var = $1.intern
value = mungearg($2)
+ # Only warn if we don't know what this config var is. This
+ # prevents exceptions later on.
+ unless @config.include?(var) or metas.include?(var.to_s)
+ Puppet.warning "Discarded unknown configuration parameter %s" % var.inspect
+ next # Skip this line.
+ end
+
# Mmm, "special" attributes
if metas.include?(var.to_s)
unless values.include?(section)
diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb
index 6d19ba983..99794bc3b 100755
--- a/test/lib/puppettest.rb
+++ b/test/lib/puppettest.rb
@@ -269,6 +269,11 @@ module PuppetTest
exit(74)
end
end
+
+ def logstore
+ @logs = []
+ Puppet::Util::Log.newdestination(@logs)
+ end
end
require 'puppettest/support'
diff --git a/test/other/autoload.rb b/test/util/autoload.rb
index 34f40df24..34f40df24 100755
--- a/test/other/autoload.rb
+++ b/test/util/autoload.rb
diff --git a/test/other/config.rb b/test/util/config.rb
index fad3e9763..a18eddd0c 100755
--- a/test/other/config.rb
+++ b/test/util/config.rb
@@ -932,6 +932,27 @@ inttest = 27
assert_nothing_raised { config.parse(file) }
assert_equal("something", config[:rah], "did not remove trailing whitespace in parsing")
end
+
+ # #484
+ def test_parsing_unknown_variables
+ logstore()
+ config = mkconfig()
+ config.setdefaults(:mysection, :one => ["yay", "yay"])
+ file = tempfile()
+ File.open(file, "w") { |f|
+ f.puts %{[mysection]\n
+ one = one
+ two = yay
+ }
+ }
+
+ assert_nothing_raised("Unknown parameter threw an exception") do
+ config.parse(file)
+ end
+
+ assert(@logs.detect { |l| l.message =~ /unknown configuration/ and l.level == :warning },
+ "Did not generate warning message")
+ end
end
# $Id$
diff --git a/test/other/features.rb b/test/util/features.rb
index 129c14769..129c14769 100755
--- a/test/other/features.rb
+++ b/test/util/features.rb
diff --git a/test/other/filetype.rb b/test/util/filetype.rb
index 81a2af2c8..81a2af2c8 100755
--- a/test/other/filetype.rb
+++ b/test/util/filetype.rb
diff --git a/test/other/inifile.rb b/test/util/inifile.rb
index bdac23f7d..bdac23f7d 100755
--- a/test/other/inifile.rb
+++ b/test/util/inifile.rb
diff --git a/test/other/loadedfile.rb b/test/util/loadedfile.rb
index 2c6b241fb..2c6b241fb 100755
--- a/test/other/loadedfile.rb
+++ b/test/util/loadedfile.rb
diff --git a/test/other/log.rb b/test/util/log.rb
index e1af9897a..e1af9897a 100755
--- a/test/other/log.rb
+++ b/test/util/log.rb
diff --git a/test/other/metrics.rb b/test/util/metrics.rb
index c4e375e7b..c4e375e7b 100755
--- a/test/other/metrics.rb
+++ b/test/util/metrics.rb
diff --git a/test/other/storage.rb b/test/util/storage.rb
index dd68af5bf..dd68af5bf 100755
--- a/test/other/storage.rb
+++ b/test/util/storage.rb