summaryrefslogtreecommitdiff
path: root/spec/unit/parser
AgeCommit message (Collapse)AuthorFilesLines
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-04-17Merge pull request #2533 from nespresso/fix/master/resource_paser_error_message2Charlie Sharpsteen1-1/+1
(PUP-2101) resource parser: add the resource name on the validation e…
2014-04-14(PUP-2101) resource parser: add the resource name on the validation error ↵David Portabella1-1/+1
message when using create_resources
2014-04-07(PUP-2158) Default a missing manifest to no_manifestAndrew Parker7-12/+12
The tests were often creating environments that didn't need to have manifests. Since we didn't have a way of specifying that when they were written, we used '' to fill in the blank. This actually caused a large number of tests to try to find code to load in the PWD, which caused tests to break if a developer had parse errors in manifests being used for testing in the root directory of their puppet project. This changes the manifest to be optional and removes '' from those tests. The tests no longer fail if a bad manifest is in the PWD :D
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-02-07(PUP-1029) Make map function consistent with othersHenrik Lindberg1-7/+65
The map function only supported a single argument which made it impossible to map based on index in an Array, and made in awkward to map on only hash key or value. Now the map function accepts either value (as before), or index/value, or key/value (for hash).
2014-02-06(PUP-1029) Make the slice function use the common Enumeration support.Henrik Lindberg1-2/+24
This adds use of the common Enumeration support to the slice function. The documentation of the function is also updated.
2014-02-06(PUP-1029) Make map function use common Enumeration support.Henrik Lindberg1-0/+19
This makes the map function use the common Enumeration support.
2014-02-06(PUP-1029) Make filter function use common Enumeration support.Henrik Lindberg2-18/+32
This makes the filter function use the common Enumeration support and makes it consistent with how all iterative functions should behave. The function's documentation is also updated.
2014-01-29(PUP-1118) Stop using Environment.newAndrew Parker9-77/+49
Instead of creating environments directly, we need to go through the configured environment loaders, otherwise environments can't come from other places.
2014-01-24(PUP-1118) Move root environment to ContextAndrew Parker2-5/+5
And adjust TestHelper initialization to preserve base context setup without requiring settings initialization in before_all_tests hook. Initializing settings in the before_all_tests was causing a slowdown somewhere in call_hooks_deferred_to_application_initialization. The issue came from the root environment needing to have the modulepath, which interpolates in the confdir to produce the value. However, after an initial run, the after each hook tears down the settings, which makes them unavailable in the second before all call. This problem had been masked previously because of the way the root environment was cached and not reset between tests.
2014-01-17Merge pull request #2272 from ↵Henrik Lindberg1-25/+14
hlindberg/pup-1166_better-error-for-strict-var-lookup (PUP-1166) Add better error for 3x --strict_variables
2014-01-17(PUP-1166) Add better error message when turning on strict_variablesHenrik Lindberg1-0/+14
When turning on --strict_variables without also using --future parser with the future evaluator, the raised error is an uncaught throw. Now the error message is "Undefined Variable".
2014-01-17(maint) remove dead code in scope_specHenrik Lindberg1-25/+0
Commented out code was testing removed behavior. Removed comments.
2014-01-17(PUP-1118) Move global context methods to PuppetAndrew Parker1-3/+3
This moves the global context handling out of the Puppet::Context class and onto the Puppet module, which allows Puppet::Context to be a more generic, overridable context system. It also allows references to context information to be a little bit shorter. This doesn't tackle making settings information available in the context, and so there might be a little confusion between Puppet[] and Puppet.lookup.
2014-01-17(PUP-1118) Remove use of Environment.currentAndrew Parker1-84/+24
One does not simply change the current environment! This replaces use of Environment.current= and Environment.current with Puppet::Context.lookup(:current_environment). This uncovered a lot of assumptions about what the current environment is at various times, such as during startup before initialization. There is now a "bootstrap" context that is setup as soon as possible which provides a basic setup, once initialization occures this is overridden with another context that is able to do more.
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 Partlow4-17/+17
hlindberg/pup-716_short-lived-objects-in-filesystem (PUP-716) short lived objects in filesystem
2014-01-08(PUP-716) Fix issues found in review (mainly typos)Henrik Lindberg1-1/+1
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 Lindberg4-16/+16
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-16(PUP-939) Add support for enumerable type to slice function.Henrik Lindberg1-1/+17
This adds support for iterating / slicing an enumerable type (Integer range). This also corrects the size calculation done in Integer range (off by one since it is an end inclusive range).
2013-12-16(PUP-939) Add support to iterate over enumerable type in map functionHenrik Lindberg2-1/+14
This adds support to iterate / map an enumerable type (Integer range).
2013-12-16(PUP-939) Add support for enumerable type in reduce function.Henrik Lindberg1-0/+10
This adds support to perform reduce on an enumerable type (Integer range). This also corrects a typo in an error message (said 'collect' instead of 'reduce').
2013-12-16(PUP-939) Add ability to filter an enumerable type.Henrik Lindberg1-0/+26
This adds the ability to filter the sequence of elements produced by an enumerable type (just like for array and hash).
2013-12-16(PUP-864) Add deprecation warning for mutation of array/hashHenrik Lindberg1-0/+2
This adds a deprecation warning to operations that mutates array and hash - i.e. $a = [1,2,4] $a[3] = 5, and equivalent for hash. The warning message has a URL that leads to PUP-864. Existing tests that test that mutation is possible now also checks that a warning is issued.
2013-12-13(PUP-866) Deprecate ImportHenrik Lindberg1-0/+8
This deprecates the use of import. A deprecation warning is generated with a URL to a link that in turn points to the original Redmine issue. A test is added. Note this does not deprecate the underlying "import" mechanism as it is used for all types of loading of manifests. The deprecation is for the puppet language construct.
2013-12-05(#22363) Handle failing tests due to renamed collect/mapHenrik Lindberg1-2/+1
Collect/map was renamed, but there were tests that still used collect. One test was broken in map_spec.rb (due to fix of undef/nil problem that was missed in rename/merge/rebase).
2013-12-05(maint) Cleanup Scope impl from unused methods & test specific codeHenrik Lindberg7-66/+91
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-12-05(maint) Remove unused ephemeral?(name) from scope.Henrik Lindberg1-8/+0
The method was only used from scope_spec.rb
2013-12-05(#22454) Fix partial shadowing of match variables.Henrik Lindberg1-6/+21
Scope only performed partial shadowing of match variables. This was caused by a search of missing numeric variables in outer scopes. This commit changes that by making the most nested match scope authoritative wrt numerical variables. It also changes the scope to use individually stored variables to simply looking them up in the match data that is used to construct the match scope. The scope_spec is changed to test for this. Some other tests changes as a consequence of the internal refactor.
2013-11-15Merge pull request #2049 from domcleal/tickets/master/23115-param-nilHenrik Lindberg2-0/+95
(#23115) Convert nil resource parameter values to undef.
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-11-09(#23115) Convert nil resource parameter values to undefDominic Cleal1-0/+8
If a resource parameter evaluates to nil (e.g. a return value from a parser function), then convert the value to undef. This prevents an error in Puppet::Parser::Resource::Param which requires a non-nil value on instantiation.
2013-11-09(#23115) Include manifest context in Puppet::DevErrorDominic Cleal1-0/+6
When a 'devfail' or Puppet::DevError is thrown, include the user's manifest file/line context as it can help in finding the problem.
2013-11-09(maint) Add specs for parser resource parametersDominic Cleal2-0/+81
Classes Puppet::Parser::AST::ResourceParam and Puppet::Parser::Resource::Param
2013-11-08Merge pull request #2047 from ↵kylo3-13/+13
Iristyle/ticket/master/19447-windows-symlinks-1-abstraction (#19447) Phase one, manages_symlinks feature, FileSystem abstraction