summaryrefslogtreecommitdiffstats
path: root/spec/unit/parser
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-07-15 19:44:35 -0700
committerMarkus Roberts <Markus@reality.com>2010-07-18 19:44:15 -0700
commit8c8c1469ae9f1dd11c567d89a27be81653ca2052 (patch)
treed87c89e15e0b390115a53961509a54006344c0d7 /spec/unit/parser
parentd319da41e46f0f3621180d09d3110f67003a7527 (diff)
downloadpuppet-8c8c1469ae9f1dd11c567d89a27be81653ca2052.tar.gz
puppet-8c8c1469ae9f1dd11c567d89a27be81653ca2052.tar.xz
puppet-8c8c1469ae9f1dd11c567d89a27be81653ca2052.zip
Minimal fix for #4243 -- import isn't thread safe
The import function was calling type_loader#import directly so that it could pass in the current file name, but by doing so it was thwarting the thread- safety locking level. This patch rearanges things so that all imports go through the same (thread safe) code path while retaining the current_file passing, error handling, etc. from the old structure.
Diffstat (limited to 'spec/unit/parser')
-rw-r--r--spec/unit/parser/type_loader_spec.rb26
1 files changed, 13 insertions, 13 deletions
diff --git a/spec/unit/parser/type_loader_spec.rb b/spec/unit/parser/type_loader_spec.rb
index db72a236e..8f005d551 100644
--- a/spec/unit/parser/type_loader_spec.rb
+++ b/spec/unit/parser/type_loader_spec.rb
@@ -38,16 +38,16 @@ describe Puppet::Parser::TypeLoader do
it "should attempt to import each generated name" do
@loader.expects(:name2files).returns %w{foo bar}
- @loader.expects(:import).with("foo")
- @loader.expects(:import).with("bar")
+ @loader.expects(:import).with("foo",nil)
+ @loader.expects(:import).with("bar",nil)
@loader.load_until(["foo"], "bar") { |f| false }
end
it "should yield after each import" do
yielded = []
@loader.expects(:name2files).returns %w{foo bar}
- @loader.expects(:import).with("foo")
- @loader.expects(:import).with("bar")
+ @loader.expects(:import).with("foo",nil)
+ @loader.expects(:import).with("bar",nil)
@loader.load_until(["foo"], "bar") { |f| yielded << f; false }
yielded.should == %w{foo bar}
end
@@ -55,31 +55,31 @@ describe Puppet::Parser::TypeLoader do
it "should stop importing when the yielded block returns true" do
yielded = []
@loader.expects(:name2files).returns %w{foo bar baz}
- @loader.expects(:import).with("foo")
- @loader.expects(:import).with("bar")
- @loader.expects(:import).with("baz").never
+ @loader.expects(:import).with("foo",nil)
+ @loader.expects(:import).with("bar",nil)
+ @loader.expects(:import).with("baz",nil).never
@loader.load_until(["foo"], "bar") { |f| true if f == "bar" }
end
it "should return the result of the block" do
yielded = []
@loader.expects(:name2files).returns %w{foo bar baz}
- @loader.expects(:import).with("foo")
- @loader.expects(:import).with("bar")
- @loader.expects(:import).with("baz").never
+ @loader.expects(:import).with("foo",nil)
+ @loader.expects(:import).with("bar",nil)
+ @loader.expects(:import).with("baz",nil).never
@loader.load_until(["foo"], "bar") { |f| 10 if f == "bar" }.should == 10
end
it "should return nil if the block never returns true" do
@loader.expects(:name2files).returns %w{foo bar}
- @loader.expects(:import).with("foo")
- @loader.expects(:import).with("bar")
+ @loader.expects(:import).with("foo",nil)
+ @loader.expects(:import).with("bar",nil)
@loader.load_until(["foo"], "bar") { |f| false }.should be_nil
end
it "should know when a given name has been loaded" do
@loader.expects(:name2files).returns %w{file}
- @loader.expects(:import).with("file")
+ @loader.expects(:import).with("file",nil)
@loader.load_until(["foo"], "bar") { |f| true }
@loader.should be_loaded("file")
end