diff options
| author | Markus Roberts <Markus@reality.com> | 2009-12-18 13:40:29 -0800 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-12-20 09:13:55 +1100 |
| commit | e9a0cb7a28a34fd04db4bfe1db347da5d774f2e8 (patch) | |
| tree | 69201d8414c255c3c7eb685f2701e48943a6f715 /spec | |
| parent | 727ee72b12125223b5d0d0704dc35f5c71a1a04e (diff) | |
| download | puppet-e9a0cb7a28a34fd04db4bfe1db347da5d774f2e8.tar.gz puppet-e9a0cb7a28a34fd04db4bfe1db347da5d774f2e8.tar.xz puppet-e9a0cb7a28a34fd04db4bfe1db347da5d774f2e8.zip | |
Fix for #2657 (retain old setting if config has syntax error)
This appears to be regression introduced by threading changes. The fix was
to rearrange things to keep the old behaviour (don't clear the settings
until you know the config file parses) and the new (don't nest calls to
synchronize) by:
1. Splitting clear into two parts--clear, which works as before, and
unsafe_clear which it calls and which expects synchronization to be
handled externally.
2. Rearranging the code to recover the previous calling order
3. Trapping syntax errors and turning them into logged messages and a
no-op effect.
4. Fixing reparse to not wrap a call to this code with a synchronize.
5. Tests.
Signed-off-by: Markus Roberts <Markus@reality.com>
Diffstat (limited to 'spec')
| -rwxr-xr-x | spec/unit/util/settings.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/unit/util/settings.rb b/spec/unit/util/settings.rb index aa2101f6e..56428132d 100755 --- a/spec/unit/util/settings.rb +++ b/spec/unit/util/settings.rb @@ -579,6 +579,25 @@ describe Puppet::Util::Settings do # and we should now have the new value in memory @settings[:two].should == "disk-replace" end + + it "should retain in-memory values if the file has a syntax error" do + # Init the value + text = "[main]\none = initial-value\n" + @settings.expects(:read_file).returns(text) + @settings.parse + @settings[:one].should == "initial-value" + + # Now replace the value with something bogus + text = "[main]\nkenny = killed-by-what-follows\n1 is 2, blah blah florp\n" + @settings.expects(:read_file).returns(text) + @settings.parse + + # The originally-overridden value should not be replaced with the default + @settings[:one].should == "initial-value" + + # and we should not have the new value in memory + @settings[:kenny].should be_nil + end end it "should provide a method for creating a catalog of resources from its configuration" do |
