summaryrefslogtreecommitdiff
path: root/spec/unit/parser/functions
AgeCommit message (Collapse)AuthorFilesLines
2014-10-16(maint) Only test lookup() with future parserAndrew Parker1-12/+13
The lookup function only works when the future parser is in effect. This changes the spec tests to turn on the future parser.
2014-08-01(PUP-501) Check virtual and exported resourcesAndrew Parker1-1/+1
This adds checks for the specification's assertions that virutal and exported resources are not in the produced catalog, but are available for later operations (realization) and reference (reading a parameter value). This cannot check that the exported resources are made available to catalog processors, since that is implementation dependent. In order to check this the compile_to_catalog method needed to be changed to filter out expoerted resources, just like the catalog indirection does. This required a change to the create_resources test.
2014-07-24(maint) Remove unnecessary Puppet.settings.clear calls from specsJosh Partlow1-4/+0
I believe most of these predated our clearing the settings before each test in the central puppet/test/test_helper.rb. And since we then set some base settings (such as :environment_timeout) in the test_helper, the effect of a secondary clear in the test itself is to wipe out the baseline setup test_helper just laid down. In particular this is a problem with environment_timeout, as it leads to tests which end up creating environments, getting them cached with the default 180s timeout, which can leak to subsequent tests and create unpleasant spec order issues.
2014-07-11(maint) Remove pointless testAndrew Parker1-4/+0
Testing that the function exists isn't really needed since the later tests that actually use the function will find that fairly quickly.
2014-07-10(PUP-2626) Allow module paths in file()Daniel Thornton1-1/+48
This modifies the file() function to accept module paths (like the template() function) as well as fully qualified paths. This makes it possible for modules that use the file() function to be more portable, instead of being tied to a specific puppet server configuration. Example with directory structure: /etc/puppet/modules/example ├── files │ └──file.ext ├── manifests │ └──init.pp └── templates └──template.erb When the module path for files can be used instead of the absolute path: file('example/file.ext') returns the same as file('/etc/puppet/modules/example/files/file.ext'). This is supposed to be like how template does module paths, where: template('example/template.erb') returns the same as template('/etc/puppet/modules/example/templates/template.erb')
2014-07-01(PUP-500) Test realize for realzAndrew Parker1-35/+43
The realize() spec tests didn't really do much since they mocked out so close to the function itself. This calls it in a manner that puts resources in the catalog and checks that they are there. The accpetance tests for the realize function are no longer needed.
2014-06-27(PUP-2845) Move the inline_epp function to the new function API.Henrik Lindberg1-82/+0
This moves the function inline_epp to use the new function API. This also improves the argument checking since it is not not possible to leak non variable name compliant variables into the scope.
2014-06-27(PUP-2845) Move the epp function to the 4x function API.Henrik Lindberg1-141/+0
This moves the epp function to the new function API. The type checking is much approved as a consequence as the function is now protected against spilling non variable name compliant variables into the scope.
2014-06-26Merge pull request #2750 from hlindberg/PUP-1852_deprecate-search-functionAndrew Parker1-0/+5
(PUP-1852) Deprecate the 'search' function.
2014-06-26Merge pull request #2761 from roidelapluie/PUP-1100-fixAdrien Thebo1-0/+11
(PUP-1100) Fix error message with create_resource and auto-loaded class
2014-06-18Merge pull request #2624 from ↵Henrik Lindberg1-0/+31
jaredjennings/feature/master/pup-2511-digest-parser-function (PUP-2511) Add parser function digest: uses digest_algorithm to hash, not strictly md5
2014-06-12(PUP-514) Check for slurp arguments in EPPAndrew Parker1-0/+6
EPP, because it uses named parameters, does not support using slurped (captures rest) parameters. This adds a static check to catch that being done.
2014-06-12(PUP-514) Type check EPP argumentsAndrew Parker1-4/+36
This adds type checking to the call_by_name invocation of closures, which is used for EPP templates. There is a pending test for issuing an error for slurp parameters in EPP templates.
2014-06-12(PUP-1100) Create_resources syntax error message spec testJulien Pivotto1-0/+11
This commit adds a check for the create_resources syntax error message. If there is a syntax error, the error given by puppet master is unclear. This commits adds a test to check that the error message is correct and makes sense. This only happens when the resources are auto imported, which is why I use a fixture directory.
2014-06-11Merge pull request #2660 from hlindberg/PUP-121_remove-relative-name-spacingJosh Partlow4-6/+130
(PUP-121) remove relative name spacing
2014-06-11(PUP-121) Ensure classes are absolute when transforming to ResourceHenrik Lindberg4-3/+49
When the 3x to 4x calls take place, resource references in the form of a PCatalogEntryType are transformed to Puppet::Resource. Depending on where these (reference) Puppet::Resource instances are used they need to either be absolute, or not (yes, 3x is inconsistent). Since future parser in 3.7 (and later 4.0) will not support dynamic name scoping, the PCatalogEntryType's should in general be absolute. This commit changes the transformation to make the created Puppet::Resource (references) absolute (when it is possible). This also adds more tests
2014-06-08(PUP-1852) Deprecate the 'search' function.Henrik Lindberg1-0/+5
This function is deprecated because support for dynamic scoping has been removed in general and this function makes it possible to abuse the systems ability to search multiple disjunct name-spaces.
2014-05-26(PUP-121) Make examples for relative/absolute sharedHenrik Lindberg4-101/+55
This makes the examples that test include, require, contain share the same tests. This also adds one missing error condition.
2014-05-19Merge remote-tracking branch 'upstream/stable'Josh Partlow1-0/+15
* upstream/stable: (PUP-2584) Make 404 warning on agent specific and an error. (PUP-1894) Fix issue with loading EPP from modules Conflicts: lib/puppet/configurer.rb Resolved, merging in stable's :fail_on_404 option into the node indirection request, and keeping master's changes to set a remote env in the node in the likely case that locally there is no matching directory env.
2014-05-19(PUP-1894) Fix issue with loading EPP from modulesHenrik Lindberg1-0/+15
The problem when loading EPP was that the name of the environment was passed instead of the actual environment (which was expected). This simply changes this, and adds a test that an epp can be loaded from a module.
2014-05-16(PUP-121) Add more tests, doc, and correct behaviorHenrik Lindberg3-1/+125
This generalizes the "make names absolute" to a transformation of given arguments to class names strings suitable for lookup, and also applying the transformation to Class and Resource reference types.
2014-05-15(PUP-121) Make include, require, and contain enforce non relative namesHenrik Lindberg1-5/+5
This makes include, require, and contain functions transform relative names to absolute names before doing any lookup. The transformation is controlled by a metho on scope that is always called, and that performs the transformation when Puppet[:parser] == future. This design was selected to ensure that there is one place to later change (other flags, or in Puppet 4 when the future will be something else).
2014-05-12Merge pull request #2633 from ↵Henrik Lindberg1-0/+37
zaphod42/issue/master/pup-1597-contain-is-just-wrong (PUP-1597) Fix contain functions lookup of class with leading ::
2014-05-09(PUP-1597) Handle containment of relative namesAndrew Parker1-0/+21
The contain() function made an error when dealing with a relative name. It assumed that the class that was actually included was always the same as the name that it was given. In many cases this is true, but when the name is found via a relative lookup (e.g. contain(bar) inside a class foo, when a foo::bar exists), the assumption breaks down. The source of the problem is that it tries to look up the included class after the fact. Without all of the extra information about namespaces it isn't able to find the right class. To fix this, the include() function has been updated to return the class resources that it included (including those that were already present). This allows the contain() function to create the appriate edges with the exact resources needed. A secondary change in this was to remove the checks for include not being able to include a class. The compiler method that is involved already makes that check and raises an error, so the include functions code was simply redundant.
2014-05-08(PUP-2357) Add validation of non-productive expressionsHenrik Lindberg2-2/+2
This adds validation of non-productive expressions: * when they do not appear last * when they appear last in constructs that do not produce a value
2014-05-08(PUP-1597) Fix contain functions lookup of class with leading ::Henrik Lindberg1-0/+16
When the contain function creates edges it looked up resources without removing the leading :: in the name. The catalog never stores these, and thus an edge was formed between a resource and nil. This commit simply removes the ::. There is no checking that a resource is actually returned since they should all be there due to the call to include them in the catalog (which would fail if it was not possible to include them). A test is also added for the erronous (and now fixed case).
2014-05-07(PUP-2511) Add parser function digest: uses digest_algorithm to hash, not ↵Jared Jennings1-0/+31
strictly md5 Puppet has an md5 parser function, which returns the MD5 digest of its argument. On hosts configured for compliance with U.S. Federal Information Processing Standard (FIPS) 140-2, attempts to use the MD5 algorithm cause errors, because MD5 is no longer FIPS Approved. This patch adds a parser function called digest, which returns the digest of its argument using the algorithm named by the digest_algorithm setting in puppet.conf. Therefore, where md5 may fail on some hosts, the digest function should always return a value; but the value may vary if the digest_algorithm setting is changed.
2014-04-21(PUP-2306) Force return type of generate to StringAndrew Parker1-0/+4
When Puppet::Util::Execution.execute was changed to return a subtype of String in order to retain return code information, some callers ended up breaking. This is because they made the assertion that types were exactly the String class, rather than a subtype of String. There is also the issue that only the primitive data structures should probably be returned from puppet functions in order to not leak complex objects into the puppet language and have hard to track down issues arise. This changes the generate() function to force it to return a String of the command's output.
2014-03-08(PUP-1897) Allow EPP render expression to render a blockHenrik Lindberg1-0/+4
If a block is given in <%= {} %> the block should be evaluated, and what it produces should be rendered. This commit makes this possible by: * explicitly handle the render block case * allowing {} to be validated as r-value producing
2014-03-07(PUP-1895) Change <%( )%> to <%| |%> for EPP parametersHenrik Lindberg2-5/+5
2014-03-06(PUP-30) Add tests of inline_epp functionHenrik Lindberg1-0/+78
2014-03-06(maint) Correct name of test for epp functionHenrik Lindberg1-1/+1
2014-03-06(PUP-30) Add more tests of epp() functionHenrik Lindberg1-3/+29
2014-03-06(PUP-30) Fix tests and issues occurring when running testsHenrik Lindberg1-0/+62
2014-03-05(PUP-1372) Add variable and pops type checks to defined functionJosh Partlow1-0/+64
The original Puppet::Parser::Functions defined() checked whether a class or resource type had been defined, or a particular resource reference declared. We've extended this to allow for checking variable assignment, by looking up a string reference for the variable name. This version can also look up defined classes, types and resources by type reference if the future parser is in effect. Paired with Henrik Lindberg <henrik.lindberg@puppetlabs.com>
2014-03-04(maint) Match current spec style and usageJosh Partlow1-17/+16
2014-01-14(PUP-1118) Fetch the environment's manifest & modulepath at initAndrew Parker2-2/+0
After trying to get the manifest and modulepath during the initialization for an environment, it turned out that a lot of other things depended on a very specific load order. Some of those needed to change around, others needed to delay executing until later, after everything had been loaded and initialized (creation of the root environment was one of these). The reset of the Parser::Functions also moved so that it doesn't happen until settings have been initialized.
2014-01-08Merge pull request #2232 from ↵Josh Partlow1-3/+3
hlindberg/pup-716_short-lived-objects-in-filesystem (PUP-716) short lived objects in filesystem
2014-01-07(PUP-800) Clean up and improve handling of location / positionHenrik Lindberg1-1/+1
There were several issues with the implementation of location handling - primarily missing the ability to be able to serialize/de-serialize the model with retained positioning information. This changes the design to bring the two values offset and length into each model object and that location information is recored in the top level Program construct. With this change a Program is always returned as the result of a parse. The change touches many files, due to the change to always return a Model::Program. Most of the change is removal of now no longer needed constructs.
2014-01-06(PUP-716) Fix up FileSystem API change, tests indirector, parser, nodeHenrik Lindberg1-3/+3
2014-01-02(maint) Add convenient create/override ability to InjectorHenrik Lindberg1-3/+2
Setting up the initial injector, as well as creating an override required quite a bit of gymnastics. This is now made much simpler. The Injector now has class methods create, create_from_model, and create_from_hash. The instance has override, override_with_model, override_with_hash.
2013-12-31(maint) Remove support for categories in the binderHenrik Lindberg1-1/+0
This removes the ability to define categories and use predicated bindings. Instead, all contributors should evaluate predicates and only contribute applicable bindings. This reduces the complexity of the binder. The support for predicated bindings was only there to support the now removed experimental "hiera2-data-in-modules"
2013-12-26Merge pull request #2188 from hlindberg/pup-546_remove-hiera2-data-in-modulesHenrik Lindberg1-10/+59
(PUP-546) remove hiera2 part of data in modules
2013-12-20(PUP-1133) Clean up leftover parser generate tempEthan J. Brown1-0/+4
- Files were created without going through tmpfile as they needed specific extensions
2013-12-19(PUP-546) Fix problems with lookup after removal of hiera2Henrik Lindberg1-0/+5
Moved lookup functionality to separate helper class.
2013-12-19(PUP-546) Replace lookup function with something usefulHenrik Lindberg1-10/+54
With removed hiera2, the lookup function is not as useful and is now replaced with the lookup from (#22574) which first looks in bound data and then in hiera. The intent is to use the technolgy agnostic "lookup" in the future parser/evaluator to enable shorthand notation. The actual lookup mechanism/technology is thereby not visible to the user.
2013-12-05(maint) Cleanup Scope impl from unused methods & test specific codeHenrik Lindberg6-10/+28
This removes several unused methods and attributes from Puppet::Parser::Scope. The only places in code using them where tests. It also removes some "convenience"/"proxy" methods used by only the Collector (better for it to do this on its own than cluttering the Scope implementation) Also refactors creating scopes for the purpose of running tests by moving that logic from Scope to PuppetSpec::Scope that should be included in examples to use the no(now renamed) method Useless and tests that test that scope behaves the wrong ! way removed. (It is always illegal to set match data variables from anything but a match, but this functionality was tested by spec tests). It was then much clearer how match scope and local scope should work. Now a LocalScope always have a nested MatchScope that is transparent until a match is set, or a nested MatchScope is created for an inner scope. This enables rewriting the evaluator logic to not leak match scopes where there is a sequence of matches at top level in a define or class body.
2013-11-14(#19447) Puppet::FileSystem::File Windows symlinkEthan J. Brown1-1/+1
- Windows symlink support has been added to exist?, symlink, symlink?, readlink, stat, and lstat. This overrides any usage of Ruby File or FileTest classes which are completely borked on Windows. - :manages_symlinks feature of the file provider is enabled with a check against Puppet.features.manages_symlinks? which checks for the existence of the CreateSymbolicLink call in kernel32.dll - FFI wrappers for Win32 API calls CreateSymbolicLink, CreateFile, GetFileAttributes, DeviceIoControl and CloseHandle added to windows/file NOTE: The DeviceIoControl method of resolving symlinks was used instead of GetFinalPathNameByHandle, which is known to misbehave with UNC paths - Any tests against :manages_symlinks feature are automatically turned on for Windows, increasing test count by approximately 42 new tests - Removed a few symlink tests that were confined to any OS other than Windows since they must now be adjusted to run on Windows versions that we know support symlinks - Updated symlink documentation based on ileUtils.symlink behavior
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-09-10Merge pull request #1878 from pcarlisle/feature/8040-contain-functionJosh Partlow1-0/+185
(#8040) Add a 'contain' function