summaryrefslogtreecommitdiff
path: root/spec/unit/parser/functions
AgeCommit message (Collapse)AuthorFilesLines
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-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-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-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-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) 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 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-13(#21409) Ensure that create_resources acts the same as a resource declAndrew Parker1-18/+6
The previous implementation of create_resources duplicated most of the logic of Puppet::Parser::AST::Resource, but had variations which meant that it didn't actually behave the same. This lead to the possibility that what should have been equivalent statements in the language did not always result in the same catalog. This re-implements create_resources to construct the AST that is needed to create the requested resources and evaluate the resulting structure. This should only be able to differ from actual resource declarations in the language if the constructed AST is wrong.
2013-06-24Merge branch 'stable'Patrick Carlisle1-42/+22
* stable: (#21043) Use ruby.exe instead of rubyw.exe (#21264) Update rgen dependency to 0.6.5 (Maint) Cleanup specs (#21320) Use sleep in the daemon loop instead of select
2013-06-24(Maint) Cleanup specsAndrew Parker1-42/+22
This cleans up the specs to make them a little more expressive of the behavior of the fqdn_rand function's real functionality. One surprising result that came out of this was that the tests tried to assert that the fqdn_rand function was callable without any arguments. However the test for this passed simply because it asserted that a particular error was *not* raised, when in fact a different exception that expressed what it was trying to catch (ArgumentError vs. Puppet::ParserError). The docs indicate that calling with no arguments is not actually supported and so that test has been removed.
2013-06-07Merge pull request #1665 from lollipopman/hiera_include_arityAdrien Thebo1-0/+12
commit 9ed6fcea48591cda58db1379b58cd39dfbdca684 which added arity checks
2013-05-31Change hiera_include to properly call include with an array of argumentsJesse Hathaway1-0/+12
Before this change hiera includes which looked up an empty array resulted in this error: ArgumentError: include(): Wrong number of arguments given (0 for minimum 1) Now hiera includes properly allow for a lookup that results in an empty array This regression was caused by the arity checks committed in 9ed6fcea48591cda58db1379b58cd39dfbdca684
2013-05-30Merge branch 'stable'Adrien Thebo1-1/+6
2013-05-28(#20302) Windows ruby 1.8 workarounds are not necessary in 1.9Josh Cooper1-1/+6
Previously, the sprintf spec failed, because ruby outputted the exponent with a leading zero, despite a precision of 2. The zaml spec failed, because ruby didn't recognize the Europe/London timezone. Ruby 1.9 fixes these issues, so the workaround in sprintf_spec is no longer necessary, and the zaml_spec issue is no longer pending.
2013-04-23spelling/grammatical fixesRichard Soderberg5-9/+9
2013-04-11(Maint) Ensure that 'hiera-puppet' is loaded correctlyAndrew Parker2-4/+0
The test for the hiera_* functions showed an interesting error. If the hiera_hash or hiera_array tests were run in isolation they would complain that Hiera was not defined and then fail. If the hiera_include tests were run beforehand, then the tests for hash and array worked as expected. The issues seems to have been that the require that brought in hiera was being delayed until too late. By making sure that hiera-puppet is loaded as soon as the function is defined, rather than called, we are certain that hiera will be around when we need it.
2013-03-20(#15791) isolate deterministic random functionPeter Meier1-0/+5
We should not fiddle with the global seed, as other people might still depend on Kernel.rand() not being that deterministic as it is the idea with the fqdn_rand function. However, as ruby < 1.9.2 does not provide such a nice solution, as a dedicated Random class we simply call Kernel.srand() again on ruby < 1.9.2 -> Reinitialize with a less deterministic seed.
2013-02-21(#14093) Remove unsafe attributes from TemplateWrapperAndrew Parker2-44/+25
The attribute accessor for the :string attribute in the TemplateWrapper conflicted with a variable being in scope that is named string. The variable would take precedence and because of the way the TemplateWrapper accessed the value of the attribute, the variable's value would be used as the template. This changes the TemplateWrapper to completely remove :string as an attribute and only use local variables. This also removes the :file attribute in favor of a "private"-style naming of the instance variable. There are no collisions with @__file__ that would cause problems, but this should reduce the likelihood of them happening in the first place.
2013-02-21(#14093) Cleanup tests for template functionalityAndrew Parker1-58/+35
Some of the previous tests were unneeded (check for simple existance) or mis-named. This cleans those up. A few other tests were trying to indirectly test many things at once (the ones about access to instance variables). Instead of the indirect test this splits it into much more specific tests and statement of behavior.
2013-02-11(#19167) Fix skipped tests due to Tempfile.new block not being runDominic Cleal1-17/+20
Tests for extlookup() key lookups were passing a block into Tempfile.new, which it doesn't run. The initialization of the CSV file was performed and then extlookup() was called inside the block. Since it isn't run, the tests aren't executed. This moves the tests out of the block and changes how the CSV file is created, since the extlookup() function doesn't take an absolute path to a CSV file. Instead a temporary directory is now created and the CSV file created inside. An incorrect test that should have checked for a raised error has also been fixed.
2012-11-07Merge branch 'dalen-function_arity'Jeff McCune10-23/+23
* dalen-function_arity: (#15989) Tests for function arity (#15989) Set arity on functions (#15989) Allow setting arity on functions
2012-11-07Merge branch '3.0.x'Jeff McCune1-4/+11
* 3.0.x: (maint) Fix hiera_include spec tests Maint: Clarify that the managehome parameter will delete a home directory
2012-11-07(maint) Fix hiera_include spec testsJeff McCune1-4/+11
Without this patch applied, the hiera_include function spec tests are not examples of actual behavior. In the spec tests the stubbed methods would return an empty array, which would then be forwarded straight away to the include parser function. The example did not have the expectation that this would raise an error. This behavior is a problem because adding arity checking to the functions becomes more difficult if theses examples are not demonstrating exepcted behavior. Instead, the change to check arity causes these examples to fail unexpectedly. This patch fixes the problem by setting the expectations of the actual behavior of the hiera_include functions more accurately. An empty array is no longer returned from the stubbed Hiera behaviors. This patch causes us to expect the system to take exception with trying to include a non-existent class.
2012-10-25(#15081) Make virtual resources work with create_resourcesErik Dalén1-0/+11
Without this patch the create_resources function is unable to create virtual or exported resources. This is a problem because the resources created by create_resources are not a first class citizen with respect to resources created from the Puppet DSL, or other means. This patch fixes the problem by allowing the create resources function to accept type names prefixed with @ or @@. For example, the following puppet manifest works with this patch applied. create_resources('@file', {'/etc/foo' => {'ensure'=>'present'}}) realize(File['/etc/foo']
2012-10-05(#15989) Set arity on functionsErik Dalén10-23/+23
Set the arity on builtin functions.
2012-09-26(Maint) Remove rspec from shebang lineJeff McCune19-19/+19
Without this patch Ruby 1.9 is still complaining loudly about trying to parse the spec files. The previous attempt to clean up this problem in edc3ddf works for Ruby 1.8 but not 1.9. I'd prefer to remove the shebang lines entirely, but doing so will cause encoding errors in Ruby 1.9. This patch strives for a happy middle ground of convincing Ruby it is actually working with Ruby while not confusing it to think it should exec() to rspec. This patch is the result of the following command run against the source tree: find spec -type f -print0 | \ xargs -0 perl -pl -i -e 's,^\#\!\s?/(.*)rspec,\#! /usr/bin/env ruby,'
2012-09-11Merge pull request #1105 from ↵Daniel Pittman8-20/+20
zaphod42/ticket/3.x/15756-disallow-incorrect-function-calls (#15756) Do not allow functions called without Array
2012-09-10Merge pull request #1103 from ↵pcarlisle1-1/+1
daniel-pittman/maint/3.x/ast-scope-only-uses-string-names AST Scope variable names must be strings.
2012-09-10(#15756) Call functions correctly in testsAndrew Parker8-20/+20
These tests relied on being able to call functions in the incorrect fashion of not passing an array as the argument. They now call the function under test correctly.
2012-09-05Clean up the Hiera Puppet integration.Daniel Pittman4-0/+82
This updates the tests to work correctly in the Puppet environment, rather than running as part of a separate repository and package. It also moves the examples into a more appropriate location. Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
2012-09-04AST Scope variable names must be strings.Daniel Pittman1-1/+1
The Parser AST scope had an embedded assumption that variable names were always strings, but didn't actually enforce that. A consequence of this is that a couple of tests violated that agreement. This adds an internal error report when someone tries the wrong thing, and cleans up the handful of tests that failed. Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
2012-08-31Merge remote-tracking branch 'origin/2.7.x' into 3.xDaniel Pittman1-4/+0
Conflicts: lib/puppet/parser/functions/shellquote.rb lib/puppet/type/package.rb spec/integration/util/file_locking_spec.rb spec/unit/parser/functions/shellquote_spec.rb spec/unit/util/command_line_spec.rb Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
2012-08-31Don't pollute Functions namespace in shellquote functionPatrick Carlisle1-5/+0
This moves two constants into local variables inside the function, as the constants polluted the Puppet::Parser::Functions namespace and caused warnings when the function was reloaded.
2012-08-13Always set log functions on root environmentPatrick Carlisle2-7/+4
Set the logging parser functions (notice, err, etc) on the root environment. This also requires setting the current environment to be nil in Environment.clear by setting it directly on Thread.current. Otherwise the default environment from puppet.conf is used. In tests this was interfering with the log functions being set on the root environment instead of the current environment.
2012-08-08Merge branch '2.7.x' into 3.xPatrick Carlisle1-6/+0
* 2.7.x: Add Puppet::Parser::Functions::clear for specs Clear Environment.current when calling Environment.clear Check that function loading worked correctly. Avoid stubbing Thread::new due to issues in newer mocha Rename specs to end in _spec.rb Don't require mocha in spec_helper Fix stubbing on nil in some specs (#14515) Tests fail with mocha 0.11.4 Conflicts: spec/unit/network/http/webrick_spec.rb spec/unit/parser/functions/require_spec.rb spec/unit/parser/functions/template_spec.rb
2012-08-08Add Puppet::Parser::Functions::clear for specsPatrick Carlisle1-6/+0
Since functions uses class instance variables to track which functions are loaded, we need to clear this between tests.
2012-08-08(#14515) Tests fail with mocha 0.11.4Jeff Weiss1-0/+7
Prior to this commit, these tests only worked with mocha 0.10.5 because the tests were broken and trying to stub methods on nil, which mocha 0.11.4 no longer allows. After this commit, these tests work with both mocha 0.10.5 and 0.11.4.
2012-07-24Use rspec 2.11 compatible block syntaxPatrick Carlisle1-6/+6
In rspec 2.11, expectations on a block must take the form of expect...to or lambda...should. Other combinations of those are no longer accepted. This commit converts all mixed cases to use expect...to, as it seems to be the preferred syntax now.
2012-07-24Make 3.x specs compatible with rspec 2.11Patrick Carlisle1-2/+2
2012-07-24wipPatrick Carlisle2-9/+15
2012-07-24Merge branch '2.7.x' into 3.xPatrick Carlisle1-6/+6
* 2.7.x: Use rspec 2.11 compatible block syntax Conflicts: spec/integration/faces/ca_spec.rb spec/integration/network/server/mongrel_spec.rb spec/unit/application_spec.rb spec/unit/face/help_spec.rb spec/unit/network/handler/fileserver_spec.rb spec/unit/parser/functions/create_resources_spec.rb spec/unit/provider/nameservice/directoryservice_spec.rb spec/unit/type/file_spec.rb spec/unit/type_spec.rb
2012-07-23Use rspec 2.11 compatible block syntaxPatrick Carlisle1-6/+6
In rspec 2.11, expectations on a block must take the form of expect...to or lambda...should. Other combinations of those are no longer accepted. This commit converts all mixed cases to use expect...to, as it seems to be the preferred syntax now.
2012-07-15resource: eliminat 0.24 compatibility metaparameter supportDaniel Pittman1-10/+0
The parser resource object had a bunch of support for handling metaparameters differently for clients less than 0.25 - which is long, long dead, and can just be eliminated from the tree. Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
2012-07-15Drop the hash prefix when passing compiler to scope.Daniel Pittman19-19/+19
Now that the compiler is always required by the scope we can save a few keystrokes by making the non-optional argument a regular value, not a name prefixed option. (...even if I love Objective-C as much as the next developer, having the same text in every call just to name the argument doesn't make much sense in such an internal context.) Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>