summaryrefslogtreecommitdiff
path: root/spec/unit/parser
AgeCommit message (Collapse)AuthorFilesLines
2013-11-08(#19447) Puppet::FileSystem::File.exist?Ethan J. Brown3-13/+13
- All previous File and FileTest calls to exist? or exists? go through the new FileSystem::File abstraction so that the implementation can later be swapped for a Windows specific one to support symlinks
2013-11-06(#23096) Treat ENC classes with empty params as if they had no paramsNick Lewis1-27/+97
(PE-455) Previously, all classes specified by an ENC in parameterized format (a hash from class to a hash of its parameters) would be evaluated as if they had parameters. This causes a failure if the class is already included elsewhere. This also caused classes with empty parameters to conflict, just because they happened to be sent as if they were parameterized. For ENCs which always submit classes in the parameterized form, this causes strange errors even though there isn't any real conflict, and substantially diminishes the utility of the ENC. With this change, ENC classes which have no parameters won't conflict if they are already included. Classes which do have parameters continue to conflict the same as they did before, as do classes which are declared in Puppet code without parameters using resource syntax. Conflicts: spec/unit/parser/compiler_spec.rb Resolved in favor of 64ff835, removing two specs which had been later modified in favor of the introduced specs for 'when evaluating node classes'.
2013-10-30Merge pull request #2008 from pcarlisle/performance/taggingAndrew Parker2-2/+3
improve tag performance
2013-10-24(#22969) Remove alternative lambda syntaxHenrik Lindberg3-100/+42
This removes the two alternative lambda syntax forms from the grammar and changes (and removes) tests that were testing (or using) the removed forms. The two removed forms are: * {|$x| } * |$x| => { }
2013-10-24(#22962) Remove alternative lambda syntaxes from testsHenrik Lindberg4-33/+34
Conflicts: spec/unit/parser/methods/collect_spec.rb spec/unit/parser/methods/reject_spec.rb spec/unit/parser/methods/select_spec.rb
2013-10-23(#22956) Remove temporary TagSet#== implementationPatrick Carlisle1-1/+2
2013-10-23(#22956) Use a set to store tagsPatrick Carlisle1-1/+1
Tags were being stored in an array, which is inefficient as the number of tags grows. This commit changes Puppet::Util::Tagging to store tags in a set. A new class is added, Puppet::Util::TagSet, which subclasses the built in set while allowing it to be compatible with the old serialization format.
2013-10-23(#22943) Refactor/rename Puppet::Resource#to_resourceKylo Ginsberg1-14/+14
* Promote Puppet::Parser::Resource#to_resource to the parent class, Puppet::Resource * Cleanup in Puppet::Resource::Catalog#to_catalog: ** It was using dup to copy the resource, then (for this issue) needing to nil-out the catalog. Now just use copy_as_resource ** The conditional around which convert method to use was more flexible (and thus confusing) than it needed to be. Distilled to the two cases: to_resource vs to_ral * Rename to_resource to copy_as_resource for clarity. This required updating a number of unit tests.
2013-10-14Merge branch 'issues/issue-22785-rename-collect'Josh Cooper1-19/+19
* issues/issue-22785-rename-collect: (Maint) Whitespace fixup (#22785) Deprecate the collect function (by making it raise an error) (#22785) Rename and update collect_spec to map_spec and use map (#22785) Add map function (copy of collect)
2013-10-14(Maint) Whitespace fixupJosh Cooper1-4/+4
Remove trailing whitespace.
2013-10-14Merge remote-tracking branch 'henrik/issues/issue-22729-remove-reject'Josh Cooper1-73/+0
* henrik/issues/issue-22729-remove-reject: (#22729) Remove the reject function.
2013-10-11(#22792) Rename select_spec.rb to filter_spec.rbHenrik Lindberg1-0/+0
2013-10-10(#22792) Rename 'select' to 'filter' in spec testsHenrik Lindberg1-11/+11
2013-10-10(#22729) Remove the reject function.Henrik Lindberg1-73/+0
The iterative 'reject' function shadowed the stdlib function with the same name. At the same time there was a decision to rename the 'select' function to 'filter' (to use a name in the functional programming languages family map/reduce/filter). The reject function was then rejected [sic]. This commit removes the reject function and the corresponding tests. The function was not used anywhere else in puppet logic or testing. User documentation needs to be updated.
2013-10-08Merge pull request #1965 from zacharyalexstern/masterAdrien Thebo1-0/+8
(#22740) create_resources input validation
2013-10-08(#22740) create_resources input validationZachary Alex Stern1-0/+8
Currently, Puppet's `create_resources()` function only validates that the number of arguments. However, the function expects a hash for the second argument, and Puppet explodes with an unhelpful error if the second argument is not a hash, or nil. For example, if the second argument is a string, you'll receive something along the lines of `undefined method `each' for "":String at /etc/puppetlabs/puppet/manifests/site.pp:45`. This is less than helpful for users. This patch raises an argument error if the second argument is not a hash, warning the user that it should be. Also adds input validation for optional third argument of create_resources, and added a test to match.
2013-10-05(#22785) Rename and update collect_spec to map_spec and use mapHenrik Lindberg1-19/+19
This updates the test to use map instead of collect.
2013-10-05(#22784) Update tests that indirectly depended on foreach function.Henrik Lindberg4-25/+25
Tests updated to use the each function.
2013-10-05(#22784) Remove the foreach functionsHenrik Lindberg1-91/+0
The each function should be used instead.
2013-10-03Merge remote-tracking branch 'upstream/stable'Josh Cooper1-3/+2
* upstream/stable: (maint) Move constant outside shared_examples_for to avoid "already initialized" warning (maint) Windows failing spec fixes Conflicts: spec/unit/node/environment_spec.rb
2013-09-10Merge pull request #1878 from pcarlisle/feature/8040-contain-functionJosh Partlow1-0/+185
(#8040) Add a 'contain' function
2013-09-10(#8040) Clarify behavior in tests around multiple containmentPatrick Carlisle1-37/+58
2013-09-10(#8040) Do not create duplicate edgesPatrick Carlisle1-0/+20
If a class is contained twice in the same location, this is consistent but should only create one edge.
2013-09-09(#8040) Test order of application for contained classesPatrick Carlisle1-6/+20
This also includes some minor refactoring of the contain function.
2013-09-06(maint) Windows failing spec fixesIristyle1-3/+2
- The usage of Dir.getwd in tests has been simplified to File.expand_path to properly handle mixed case CWD - util_spec.rb ensures 'FOO' Env var cleared before test starts - Windows SID checks should be performed as a regex match to properly handle all accounts starting with S-1-5-*, which denotes accounts with an identifier authority of SECURITY_NT_AUTHORITY instead of hardcoding S-1-5-32-544, the Administrators group
2013-09-05(#8040) Don't allow duplicate contain callsPatrick Carlisle1-0/+17
2013-09-05(#8040) Add a function to specify containmentPatrick Carlisle1-0/+113
This adds the 'contain' function. When used inside of a class definition, it will create a containment relationship such that the current class contains the argument of 'contain'.
2013-09-03(maint) fix typo in comment and clean whitespaceKylo Ginsberg1-5/+5
2013-08-30Merge branch 'maint/master/21201-remove-threading-code'Josh Cooper2-9/+7
* maint/master/21201-remove-threading-code: (#21201) Remove test for thread-safety (#21201) Remove thread-safety code (Maint) Remove whitespace errors
2013-08-20Merge pull request #1766 from ↵Henrik Lindberg1-18/+6
zaphod42/issue/master/21409-create_resources-differs-from-real-resource (#21409) Ensure that create_resources acts the same as a resource decl
2013-08-20(#21201) Remove thread-safety codeAndrew Parker2-9/+7
Puppet does not support running in any threaded environments. The thread safety code that has been added has been, for the most part, haphazard and not a holistic solution to the threading problem. There are many areas that are not protected at all and others that were protected in incomplete ways. The extra code and logic only caused more complication in the codebase and is removed by this commit.
2013-08-16(#22205) Chose a Prioritizer based on Puppet[:ordering]Andrew Parker1-7/+3
This ties the selection of the Puppet::Graph::Prioritizer to the Puppet[:ordering] setting. In order to make it easier to ensure that all of the uses of the prioritizer use the same one (because it needs to track state) this also moves around the relationship of the catalog and the transaction. Previously the catalog was responsible for converting itself into a relationship graph. This now puts that responsibility on the transaction, which much now be constructed with the desired Prioritizer. The selection is still done in the catalog (because that is where #apply lives, which is the public starting point of applying a catalog). Additionally this adds a random prioritizer.
2013-08-15Merge branch 'stable'Josh Partlow3-106/+43
* stable: (21 commits) (packaging) Update PUPPETVERSION for 3.2.4 (maint) Correct type in speeeeling of pl-fedora-18-i386 mock in ext/build_defaults.yaml (packaging) Move systemd BuildRequires into conditional (Bug #21768) Update puppet for F19 (maint) Remove rspec requires from the Rakefile (maint) Fix module_utils regex tests for module file perms (maint) Fix windows test for embedded '..' in path Improving testing around PMT module install permissions. Ensure that PMT uses the correct group membership. (#21971) Allow paths that contain .. as part of a name Fixing a missed test for minitar. (Maint) Reinstate check for manifest dir (#21953) Add test to verify module permissions (#14333) Ensure module permissions are sane. (#21971) Fixes PathPattern's usage of Dir.glob for Windows (#21971) Fix TypeLoader#import_all on Ruby 1.8.7 (#21971) Create system for safely dealing with path patterns (#21971) Split import and autoloading code paths (#21971) Check for possible directory traversal (Maint) Clean up specs ...
2013-08-15Merge branch 'release_3.2.4' into stableJosh Partlow3-106/+43
3.2.4 * tag '3.2.4': (21 commits) (packaging) Update PUPPETVERSION for 3.2.4 (maint) Correct type in speeeeling of pl-fedora-18-i386 mock in ext/build_defaults.yaml (packaging) Move systemd BuildRequires into conditional (Bug #21768) Update puppet for F19 (maint) Remove rspec requires from the Rakefile (maint) Fix module_utils regex tests for module file perms (maint) Fix windows test for embedded '..' in path Improving testing around PMT module install permissions. Ensure that PMT uses the correct group membership. (#21971) Allow paths that contain .. as part of a name Fixing a missed test for minitar. (Maint) Reinstate check for manifest dir (#21953) Add test to verify module permissions (#14333) Ensure module permissions are sane. (#21971) Fixes PathPattern's usage of Dir.glob for Windows (#21971) Fix TypeLoader#import_all on Ruby 1.8.7 (#21971) Create system for safely dealing with path patterns (#21971) Split import and autoloading code paths (#21971) Check for possible directory traversal (Maint) Clean up specs ... Conflicts: lib/puppet/parser/type_loader.rb spec/unit/parser/type_loader_spec.rb Conflicts were between changes Patrick Carlisle made in stable between 3.2.3..3331528, mostly refactoring the type_loader_spec to be independent of parser implementation: * 0c6060f Patrick Carlisle 5 weeks ago (maint) Refactor type_loader, mostly specs * 27a69f2 Patrick Carlisle 5 weeks ago (#21653) Skip modules with no manifest directory when loading resource types And the above security work.
2013-08-07Merge pull request #1827 from kylog/feature/binder-rebased-2kylo2-1/+97
(#16856) Add support for Data-in-Modules
2013-08-06(#21971) Split import and autoloading code pathsAndrew Parker3-107/+42
The codepaths for import and autoloading of manifest files were combined at many levels, which made them share behaviors that were not wanted. The import ability to load absolute paths leaked through into how autoloading would try to find files for a particular class name, which resulted in a possible vulnerability to injected class names (ENC values, hiera data, etc). This splits those code paths to ensure that the one used for autoloading only will ever look in modules that are registered on the modulepath, while still allowing the import path to look at absolute and relative file paths.
2013-08-05Merge pull request #1825 from jpartlow/issue/master/22079-fix-hash-array-accessJosh Partlow1-0/+8
(#22079) Fix HashArrayAccess produces :undef when value is false
2013-08-05(#22079) Fix HashArrayAccess produces :undef when value is falseHenrik Lindberg1-0/+8
It should naturally have produced false. The test for "having value" was wrong and equated nil with false.
2013-08-03(#16856) Fix failing lookup function test (missing setting of --binder)Henrik Lindberg1-0/+4
The lookup function test was missing because the setting --binder was missing, and lookup only works when this feature is turned on).
2013-08-03(#16856) Make use of Puppet Binder optional (and thus also rgen)Henrik Lindberg1-1/+0
The Puppet Binder a.k.a "Data-in-Modules" is based on Rgen, and is required to be able to use the data-in-module/hiera2 features. The setting :binder must be set to true, or :parser set to 'future' for the bindings system, data-in-modules, and hiera2 to be in effect. The bindings system is now "booted" by the compiler on demand if the settings dictate this. Implicit lookup of undefined class parameters will not use injector unless active. Explicit lookup using lookup will raise an error unless the bindings system is active. Tests toggle the activation
2013-08-03(#16856) Fix test failing because lookup returns :undef instead of nil.Henrik Lindberg1-2/+2
2013-08-03(#16856) Add ability to call lookup function with a lambda.Henrik Lindberg1-0/+25
This adds the ability to call lookup with a lambda that gets the looked up result for futher processing. The lambda gets undef when nothing was found. This enables a convenient way to define a default when value is missing.
2013-08-03(#16856) Check looked up type against provided type in lookup()Andrew Parker1-6/+38
The lookup() function can now enforce the type that the caller of the function is expecting to receive by being provided a type specification as a second argument. If no argument is provided it will default to needing "Data", which is the supertype of all of the data types (Object is a supertype, but doesn't not result in getting a looked up value because the type is also part of a namespace for the injection system and it holds object separate from data).
2013-08-03(#16856) Add implicit parameter lookup for hostclass resources.Henrik Lindberg1-1/+2
This adds implicit lookup of host class parameters via injector. Checks DataBindings (i.e. Hiera) if there is no bound value. Fixes tests that were mocking scope and did not expect calls to compiler. Also adds accessor method that creates an injector if none was created.
2013-08-03(#16856) Add a lookup() function for injected valuesAndrew Parker1-0/+35
The lookup() function will use the configured bindings and injector to lookup a value. If one is not found, then nil is returned (which is undef in the puppet language). Any errors from the injector are propogated out to the caller.
2013-07-19Merge pull request #1791 from zaphod42/issues/master/issue-21252Henrik Lindberg1-0/+43
(#21252) Fix problems with false/nil args and returns in lambda
2013-07-19(#21252) Define behavior around undef and nil argumentsAndrew Parker1-0/+25
The behavior for an argument that was :undef (from an undefined variable) and nil (from a function returning a nil in a data structure) was different. This fixes that inconsistency by making them both the same. It also clarifies that passing undef to a lambda does not result in the default value for that parameter. In addition some of the variables have been renamed to clarify their purpose and extra code for a 1.8.7 difference that we were unable to reproduce has been removed.
2013-07-19(#21252) Fix problems with false/nil args and returns in lambdaHenrik Lindberg1-0/+18
The issue 21252 was triggered by a documentation error but should have produced a different result than the error that was presented. This was caused by a series of problems. It was not possible to pass `false` as a parameter value as this was taken as missing parameter value. Also, it was not possible to return the value `false` as this was translated to `nil` due to defective work around for missing initialized variable on return. The fix changes the handling of making sure that the variable that is returned exists (by setting value explicelty to `nil` before the start of the exception handling block. This commit also modifies how a lambda call matches arguments to parameters and checks what is missing (now with `false` as a valid value in mind). A test is added to `collect` that checks that a value of `false` can both be passed and returned.
2013-07-17(maint) Remove publicize_methods from specsPatrick Carlisle1-2/+3
This was a bad idea.
2013-07-15Merge pull request #1735 from hlindberg/issue/issue-21508Andrew Parker1-0/+43
(#21508) Make local variables available to templates as instance vars