Age | Commit message (Collapse) | Author | Files | Lines |
|
The loaders previously assumed that any installation of puppet would be
under a directory called lib. This holds true when running puppet from
source (during development), or in some package cases, but is not
generally true. This simplifying assumption was made so that the loading
path for both puppet system extensions (built in functions) and module
extensions could be loaded in the same manner: find the root of the
extender and loading code from `lib/puppet/...`.
This changes to loading to instead only assume that there is a `puppet`
directory and not the name of the parent. This, however, forces the
loader for modules to become specialized to only be able to find ruby
extentions, because they are in the 'lib' directory, which is how the
loader must now be configured.
|
|
Maint/master/update rspec
|
|
From RSpec:
DEPRECATION: `expect { }.not_to raise_error(SpecificErrorClass, message)` is deprecated. Use `expect { }.not_to raise_error` (with no args) instead.
This commit removes all args from `.to_not raise_error` expectations.
|
|
This allows an epp body to be empty by making grammar accept an
empty list of statements. This avoids getting a cryptic error message
about "syntax error at end of file" when using parameters, but having no
body that produces output, or when having a completely empty template.
|
|
(PUP-2794) Change Callable to mean "can be called with"
|
|
This commit moves the shared behavior for iterative functions to
shared_behaviours/iterative_functions.
|
|
|
|
|
|
This updates the shared tests for iterative functions to also
be capable of handling reduce. This also adds missing tests
that were part of one of the individual tests earlier.
The test for reduce now also invokes the shared behavior for argument
checking.
|
|
This changes the reduce function to use the dispatchers to check
the block arity.
|
|
This changes the function filter to use the dispatchers instead
of having a special arity check.
|
|
This changes the function filter to use the dispatchers instead
of having a special arity check.
|
|
This changes the evaluation of a LiteralUndef to nil from :undef.
As a consequence, there were minor adjustments needed to the Closure's
call_by_name support to get the correct semantics for "missing"
parameters.
Tests are also added to ensure that :undef does not sneak into arrays or
hashes in the 4x function API.
This commit contains a cheat for epp and inline_epp functions as they
need to receive their arguments without transformation. When that is
fixed (PUP-2845) the cheat in runtime3_support#call_function() should be
removed.
:undef is still used in the "puppet/pops" section of the code (mainly
for reasons of transforming to 3x, and if :undef symbols leak from 3x.)
|
|
It is more meaningful to check that a Callable can be called with
certain types (exact or more generic) than to check the reverse.
This alters the meaning of Callable assignability so that a more generic
Callable is accepted. While this seems counterintuitive from the
perspective of the type system, it is the constraint that is expected as
the constraint being expressed means "Must be callable with arguments of
these types", and a more generic callable is just that.
The current implementation got that wrong, and will actually accept
callables that can in fact not be called.
This also alters the assert_type function that declared that it would
call a given block with Any, Any, when in fact it will call with
Type, Type.
Note, that a function that after this delares that it calls
Callable[Any] will enforce that the given callable is Any. If the intent
is to accept any callable, the type should be given as just Callable.
|
|
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.
|
|
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.
|
|
This renames the top most type in the type system to Any from
the name Object. This is done because the word Object carries
connotations of "Object Oriented Programming" that simply adds confusion
about how puppet works.
This commit is basically a rename refactoring.
|
|
This moves all the iterative functions to the 4x function API.
Functions are now simpler to read. A shared utility module
was created for repeated asserts.
While testing it was clear that it is difficult to use
Puppet.lookup(:loaders), and the evaluator was changed to get the
loaders via the compiler instead.
The evaluator tests are changed to make use of the simplified
handling of the loaders.
The tests for the functions that have moved, were also moved, but
are unchanged in what they test.
|
|
Object is now the top class and so there is no need to use
Optional[Object] everywhere. This removes the type factory method
optional_object and replaces all occurrances with just object. It also
updates all of the uses of Optional[Object] to use just Object.
|
|
The previous implementation checked the argument types twice against the
signature. This reduces it to a single check. The error for a missing
argument is now caught in a place that used to be unreachable and so the
error has been converted into an issue, which also provides the
information about where the failure occurred.
|
|
With hadn't been checked that it can take a Type as an argument.
Normally this kind of check wouldn't be needed, but as the type system
and calling conventions have been sorted out, this hasn't always worked
as intended.
|
|
The with function is needed in order to easily try out invoking lambdas.
Because this kind of thing can also be generally useful to anyone who
wants to learn the puppet language (understand lambdas, for instance) or
want to have a way of creating private scopes within a class, the with
function is being added as a normal APIv4 function rather than something
that is only available in tests.
|
|
This adds the ability to handle a Callable as the value, as well
as supporting a lambda that takes over the built in raising of
an error. This means that assert_type can be customized to fail
with special message, or to issue a warning and use a default.
assert_type(String, 1) |$expected, $actual| {
warning("a $actual is not a $expected")
"Free Beer, is the default"
}
|
|
|
|
The function handles matching of String, and Array[String] against:
* regexp
* string
* Regexp type
* Pattern type
|
|
Having code depend on the "current environment" has lead to trouble in
many instances. Having the loaders be given an explicit environment is a
much safer way to proceed.
|
|
This fixes the problem where inter-module function calls could
not be made. The main problem was that a function when loaded
was given the public loader and thus had no visibility into its
containing module's dependencies.
The design is that module resolution should be on-demand, only
when something actually needs the proviate loader should it be resolved.
The resolution is triggered by asking for the private loader, but no
such call was made on the call-path when a function was loaded.
This commit adds the notion of private_loader to the loaders (those that
do not have one respond with self). Those that do either provide the
private loader explicitly (environment loader), or on demand (by
obtaining the private loader from loaders).
This change required tests to be modified since the logic now depends
on :loaders being bound in the Puppet context
logic that made this happen on demand was not implemented
|
|
This adds the ability to also give the type as a String (it is
parsed with the TypeParser). This is good when reading the type
specification from an external source that cannot directly serialize
a Puppet Type.
|
|
|
|
This function asserts that the value is an instance of the given type.
The value is returned or an error is raised.
This function use the new 4x function API.
|