diff options
author | Luke Kanies <luke@madstop.com> | 2008-02-12 14:57:24 -0600 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2008-02-12 14:57:24 -0600 |
commit | 7e45553448f2a051594ee4f2fc83ebcfa4a8114a (patch) | |
tree | 1d64489aa420ee391fb0fe51673fad92232bdcc6 /test | |
parent | 9b66251076e0403afde5b1ad7aa543d18e302a94 (diff) | |
download | puppet-7e45553448f2a051594ee4f2fc83ebcfa4a8114a.tar.gz puppet-7e45553448f2a051594ee4f2fc83ebcfa4a8114a.tar.xz puppet-7e45553448f2a051594ee4f2fc83ebcfa4a8114a.zip |
Fixed #997 -- virtual defined types are no longer evaluated.
NOTE: This introduces a behaviour change, in that you previously
could realize a resource within a virtual defined resource, and now
you must realize the entire defined resource, rather than just
the contained resource.
Diffstat (limited to 'test')
-rw-r--r-- | test/data/snippets/collection_within_virtual_definitions.pp | 20 | ||||
-rw-r--r-- | test/data/snippets/realize_defined_types.pp | 13 | ||||
-rwxr-xr-x | test/language/scope.rb | 34 | ||||
-rwxr-xr-x | test/language/snippets.rb | 5 |
4 files changed, 34 insertions, 38 deletions
diff --git a/test/data/snippets/collection_within_virtual_definitions.pp b/test/data/snippets/collection_within_virtual_definitions.pp new file mode 100644 index 000000000..3c21468b0 --- /dev/null +++ b/test/data/snippets/collection_within_virtual_definitions.pp @@ -0,0 +1,20 @@ +define test($name) { + file {"/tmp/collection_within_virtual_definitions1_$name.txt": + content => "File name $name\n" + } + Test2 <||> +} + +define test2() { + file {"/tmp/collection_within_virtual_definitions2_$name.txt": + content => "This is a test\n" + } +} + +node default { + @test {"foo": + name => "foo" + } + @test2 {"foo2": } + Test <||> +} diff --git a/test/data/snippets/realize_defined_types.pp b/test/data/snippets/realize_defined_types.pp deleted file mode 100644 index a4b562258..000000000 --- a/test/data/snippets/realize_defined_types.pp +++ /dev/null @@ -1,13 +0,0 @@ -define testing { - file { "/tmp/realize_defined_test1": ensure => file } -} -@testing { yay: } - -define deeper { - file { "/tmp/realize_defined_test2": ensure => file } -} - -@deeper { boo: } - -realize Testing[yay] -realize File["/tmp/realize_defined_test2"] diff --git a/test/language/scope.rb b/test/language/scope.rb index 9c0e583e4..c96581a23 100755 --- a/test/language/scope.rb +++ b/test/language/scope.rb @@ -328,10 +328,9 @@ class TestScope < Test::Unit::TestCase "undef considered true") end - if defined? ActiveRecord # Verify that we recursively mark as exported the results of collectable # components. - def test_exportedcomponents + def test_virtual_definitions_do_not_get_evaluated config = mkcompiler parser = config.parser @@ -348,7 +347,7 @@ class TestScope < Test::Unit::TestCase :children => [nameobj("arg")] ) - # Create a top-level component + # Create a top-level define parser.newdefine "one", :arguments => [%w{arg}], :code => AST::ASTArray.new( :children => [ @@ -356,27 +355,11 @@ class TestScope < Test::Unit::TestCase ] ) - # And a component that calls it - parser.newdefine "two", :arguments => [%w{arg}], - :code => AST::ASTArray.new( - :children => [ - resourcedef("one", "ptest", {"arg" => varref("arg")}) - ] - ) - - # And then a third component that calls the second - parser.newdefine "three", :arguments => [%w{arg}], - :code => AST::ASTArray.new( - :children => [ - resourcedef("two", "yay", {"arg" => varref("arg")}) - ] - ) - - # lastly, create an object that calls our third component - obj = resourcedef("three", "boo", {"arg" => "parentfoo"}) + # create a resource that calls our third define + obj = resourcedef("one", "boo", {"arg" => "parentfoo"}) - # And mark it as exported - obj.exported = true + # And mark it as virtual + obj.virtual = true # And then evaluate it obj.evaluate config.topscope @@ -385,12 +368,13 @@ class TestScope < Test::Unit::TestCase config.send(:evaluate_generators) %w{File}.each do |type| - objects = config.resources.find_all { |r| r.type == type and r.exported } + objects = config.resources.find_all { |r| r.type == type and r.virtual } - assert(!objects.empty?, "Did not get an exported %s" % type) + assert(objects.empty?, "Virtual define got evaluated") end end + if defined? ActiveRecord # Verify that we can both store and collect an object in the same # run, whether it's in the same scope as a collection or a different # scope. diff --git a/test/language/snippets.rb b/test/language/snippets.rb index def3d4cf9..982ddfec4 100755 --- a/test/language/snippets.rb +++ b/test/language/snippets.rb @@ -424,6 +424,11 @@ class TestSnippets < Test::Unit::TestCase assert_file("/tmp/realize_defined_test2") end + def snippet_collection_within_virtual_definitions + assert_file("/tmp/collection_within_virtual_definitions1_foo.txt") + assert_file("/tmp/collection_within_virtual_definitions2_foo2.txt") + end + def snippet_fqparents assert_file("/tmp/fqparent1", "Did not make file from parent class") assert_file("/tmp/fqparent2", "Did not make file from subclass") |