Age | Commit message (Collapse) | Author | Files | Lines |
|
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.
|
|
The problem was that templates reference scope variables using
instance variables e.g. @myvar, these were configured from the
hash returned by Scope#to_hash. That method did not consider
ephemeral scopes.
The solution was to add collection of the emphmeral scopes' (that
represent local scopes) variables and include them in the hash.
As before, the match scopes (i.e. for $0 - $n) are not included in
the result.
|
|
(maint) Fix rspec warnings
|
|
* stable:
(maint) Refactor type_loader, mostly specs
(#21653) Skip modules with no manifest directory when loading resource types
|
|
Running specs with rspec 2.13 caused a lot of warnings. Many of them actually
exposed preexisting bugs, the most common being a syntax error when expecting
an Exception. These are worth fixing even if we don't bump to rspec 2.13.
|
|
This cleans up the specs for type_loader a lot and slightly refactors a few
methods in type_loader.
|
|
The resource_type face tries to parse all manifests from modules, but was
failing if a module didn't have a manifest directory. This is not an error
condition so we just skip those modules.
|
|
* 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
|
|
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.
|
|
* stable:
(#21376) Sequence BlockExpressions without nesting
|
|
When merging Puppet::Resource::Type instances the code attribute was merged in
a way that caused a deep tree of BlockExpressions. This could cause stack
overflows when evaluating this tree, since evaluation is recursive. This
changes the merge method so that they are sequenced as a flat array.
|
|
Improve error messages for non-string variable names
|
|
|
|
Make sure we get ParseErrors that contain "not a hash or array" so it's
clear what has happened.
|
|
Raise ParseError rather than DevError for non-string variable names.
This is more consistent with the other validation, and also means that
we get a file and line number when hitting this error rather than just
the rather opaque message. Also inspect the variable name for good
measure.
|
|
commit 9ed6fcea48591cda58db1379b58cd39dfbdca684 which added arity checks
|
|
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
|
|
|
|
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.
|
|
|
|
The return type of select and reject where unspecified and tests
did not check for type (not caring because all tests applied more
iteration to the result and that evened out the differences).
Now both select and reject produce a result of the same class as
the receiver. This is now noted in the documentation.
Tests have been added.
|
|
The activerecord based tests would setup activerecord and rails in a
manner that included stubbing. This made some things behave as you might
want, but caused some manner of getting them to behave the wrong way. By
removing the stubbing, the test cases all work from a clean database.
Another issue occured when one of the tests assumed that no other code
that used its indirection had been run prior to it. The test itself was
very questionable and ended up breaking when the tests were run in a
particular order. The test in question tried to assert that the code
would setup activerecord when it was initialized. Since all of the other
tests relied on this, and that particular behavior did not appear to be
important to the external contract of the class, the test has been
removed.
|
|
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.
|
|
Removed trailing whitespace only.
|
|
When calling iteration functions collect, reject, and select with
a hash there were cases where only hash key was passed to the given
lambda. This commit corrects this by ensuring that it is always
a key/value tuple that is passed.
This commit also includes improved tests for these cases as well
as argument checking.
|
|
|
|
When checking whether concatenation is supported the check for the
Puppet[:parser] setting was wrong (checking for a symbol instead of array).
This caused concatenation to not be supported even with the future parser
enabled.
|
|
This cleans up source formatting (spaces/tabs), dead todo, blank lines,
ending without a linebreak, and corrects indentation.
|
|
This makes two small changes to the classic grammar since
BlockExpression should be used instead of ASTArray for
sequences of expressions to make AST comply with both grammars.
Reverts test of parser and lexer to master version.
|
|
future.
This adds an assertion that + is only allowed when --parser future is
in effect. Tests uppdated.
|
|
|
|
(and should not be there in the first place).
|
|
The earlier required fix of using AST ||= is no longer required to get
rid of redefinition errors. Instead the ||= is not possible to use in
1.8.7 since the constant is not defined).
|
|
This is an internal protection against assignment to numeric
variables - as they royally screw things up wrt being overwritten
by ephemeral scopes (or causing imutability errors).
|
|
Also fixes tests of issues.
Relabels Object and String as Ruby Object, and Ruby String.
|
|
Tests were hardwired to run for only future/eparser. Now all tests
where parser is involved runs for both current/classic and
future/eparser (except when testing methods; where parsing is only
done in order to construct a call; it is the function that is tested,
not the parsing). The collect method testing includes testing the
various ways a call can be made to it, but this is the only place; this
because it is more work to unwire all the others when the final style
for lambdas gets picked.
|
|
Eparser was unit tested by the parser unit test, but did not work
as intended. This adds a separat test
This is basically a copy of the parser unit test, but with removal
of tests that only check the parser implementation (internal calls
to "self" from the old parser).
There are also minor adjustments as the egrammar parser has better
information (e.g. the result contains "file" instead of "File" as type
is already detected and type internally has already done a downcase).
|
|
This separates the PopsParserAdapter from the ParserFactory and
renames it to EParserAdapter.
|
|
Rework each_slice/slice and fix doc of all enumerable f's
The idea that each/foreach/each_slice should produce the last produced value
from the lambda was bad. This makes it difficult to chain these
calls. These functions now produce the receiver.
Modify the return value of each_slice to the receiver.
Rename each_slice to slice and make block optional to produce array.
It was a bad idea to implement each_slice as the only way to get slices
from an array. The renamed function works as before when given an
optional lambda. When called without a lambda it produces the collected
result of all slices. Thus making it possible to iterate over it.
The alternative was to equip all other iteration methods with slicing
functionality, or to implement a separate slicing function.
Corrects documentation in all enumerable functions.
|
|
|
|
One argument, pick each entry (Array = value, Hash = array with
key,value).
Two arguments, pick each entry (Array = index, value; Hash = key,
value).
Additional arguments for array (picking pairs etc.) support removed.
|
|
This is good because it is otherwise very difficult to perform
typical data transformations (without these operations you can
filter, map, and reduce to one - or jump through hoops trying to write
a reduction that appends.
Although not strictly part of #18764, this is the same category.
|
|
Describes the intent for adding source positions to produces
AST objects.
(maint) Add read accessor for importer.
This to help debugging.
Adjust tests to not include spec helper at rspec config time.
Fix type_loader_spec test mocking the wrong object.
(The mocking in type_loader_spec still does not clean up ok.
If executed before
spec/unit/pops/impl/transform/transform_conditionals.rb, the second fail
due to getting wrong instance of AstTransformer !!??)
Update yardoc for Utils.find_adapter
Fix utils method that was not a module method (find_adapter).
Cleanup tests (comments, blank lines, debugger).
(refactor) Make AstTransformer use Utils class to find adapter.
Finding an adapter should be in one place only.
|
|
|
|
|
|
This makes it possible to invoke foreach as:
foreach($a) {|$x| ... }
The only caveat is that a parentheses-less call must have at least one
argument. This is not allowed:
foo {|$x| }
If someone implements a function that takes only a lambda that call
would need to be written as:
foo() {|$x| }
This since it is not allowed to pass a lambda as an argument (since this
would require implementing real closures).
|
|
Under some conditions, array zip in ruby 1.8.7 produces a single value
instead of an array. The result was that the integer value of the first
char was produced as the result instead of the expected string.
This fix checks if the name value is just a string name, or an array
with [name, value].
|
|
This relaxes the constraint that a = expr must be the only statement
in a lambda (or be a sequence of statements). Is is now instead possible
to place this statement last after a sequence of statements.
This commit also fixes an issue where the last value of the lambda and
foreach function did not produce a value.
There was an inspect in a rescue that was only there for debugging.
Now removed.
|
|
This adds support for "foreach" for arrays and hashes.
The implementation adds support for MethodCall and Lambda expressions to
the lexer and parser.
A method call is simply a variant of function call that supports an
optional parameterized block (i.e. a lambda). The foreach method is
simply implemented as a function that accepts a "receiver" and a lambda.
The foreach function operates on arrays and hashes.
The implementation does not alter any existing syntax and does not
introduce any additional keywords or constraints on any lexer literals.
Since racc only has one token lookahead it was necessary to add such
lookahead in the lexer for LBRACE, which now produces a LAMBDA token if
LBRACE is followed by PIPE. DOT token was reintroduced, and a PIPE
token added.
To allow a lambda to return the result of a single expression, the
syntax: {|...| = expr } may be used. Unfortunately, a major rewrite of
the grammar is required to allow this without a syntactic marker. Also
unfortunate is the fact that all functions invokable as statements does
not produce an rvalue and an rvalue function may not be used as a
statement. (To change that would also be a major rewrite). Hence, a
syntactic marker (in a lambda only), that allows a single expression to
be turned into a "rvalue" statment seems to be the best approach). If
the grammar is improved in the future, the = could be made optional.
|
|
This adds support for the functions/methods collect, reject, select, and
reduce. This implementation depends on support for lambdas being added
in puppet as described in issue #11331). Which probably will be released
in puppet 3.2.
|