(#14985) Fix hiera lookup for calling_module and calling_class
(#14985) Fix hiera does not lookup calling_class and calling_module
(#14985) Fix test, return downcase values and check for nil scope.source
(#14985) Fix exception when nil is returned from inner scope
(#14985) Ensure hostclass finder is private

The nested definition of the recurse_for_hostclass method caused that
method to be created lazily and as a public method. By pulling it out to
be declared outside the calling method it can be made private and
created only once. It has also been renamed to show the intention
instead of the mechanism (recursion).
(Maint) Require Hiera::Config to avoid warning

When the hiera tests were run alone the puppet_backend_spec.rb issued a
warning:

  /Users/andy/work/puppet/spec/unit/hiera/backend/puppet_backend_spec.rb:25:
  warning: toplevel constant Config referenced by Hiera::Config

The warning was caused by a reference to Hiera::Config where Hiera was
defined, but Hiera::Config was not. This resulted in getting the top
level Config constant and a warning being issued. By requiring
hiera/config this problem is avoided.
(Maint) Use real scope in testing

Using the real scope is completely possible in these tests since it has
no dependencies on the outside world and is essentially a value object.
Therefore it should be used in the tests to make them more
comprehensive.
(#14985) Describe behavior of calling_(class|module)

The original tests for calling_module and calling_class used a mock,
when this is really just a value that can be setup. It also didn't
separate out and describe the behavior of the two pieces in the
variations in which they can come up. Specifically the difference
between a `define` and a `class` for the meaning of calling_class.
(Maint) Clarify scope lookup rules

The lookup rules for variables in the puppet language have always been a
bit hard for me to understand. I knew the rules as

  the current scope => inherited => node => topscope

but the code never seemed to express that clearly. This refactors the
`lookupvar` method to extract out a few pieces to make that clearer.
Specifically the mechanism for walking from a class to the enclosing
node (which is why this gets the name "two-step" by some people) has
been called out as a lookup of the `enclosing_scope`. Calling out the
enclosing scope as a specific lookup allows for getting rid of the
`:origin` part of the options hash, which was to provide a mechanism for
skipping over some scope objects.

This also tries to remove some duplication that was occurring because
there was not a consistent symbol table concept. It turns out that the
existing `Ephemeral` fits that nicely and so it now used as the scope's
symbol table as well as for the ephemeral variables.
(#14985) Preserve casing on looked up values

The initial fix for looked up values downcased everything that was being
returned. This causes problems when the data is not a string that the
previous behavior was to only do this for the calling_class and
calling_module. This commit us returns to that behavior.
(Maint) Extract constant strings as constants
(maint) Make external CA acceptance test work with SELinux

Without this patch the External CA acceptance tests are failing in CI.
This is a problem because we need to automatically validate that our
documented external CA configuration remains in order.

The root cause of the problem is that SELinux is enabled and enforcing.
This patch addresses the problem by setting the appropriate permissions
on TCP port 8141 and the document root used for testing.
Merge branch 'external_ca_test_fix'

* external_ca_test_fix:
  (maint) Make external CA acceptance test work with SELinux
(maint) Make external CA acceptance test work with SELinux (TRY #2)

The previous attempt to make Apache and Passenger play nicely with
SELinux was sufficient to get httpd started, but insufficient to allow
Passenger to run.  Passenger switches users and creates sockets all over
the place, which SELinux denies.

This patch simply disables SELinux for the duration of the external CA
testing and re-enables it if it was originally enabled.
(#14985) Alias module_name as calling_module

The new implementation of calling_module turned out to be the same as
puppet's own module_name. This makes it simply and alias so that we keep
that as the definition of calling_module.
Merge pull request #1497 from zaphod42/issue/master/16688-hiera-extra-vars

(#14985) Enable calling_class and calling_module for defined types
(#11331) Add pops - this is the base implementation of new DSL model.

This adds a pops basic implementation of the DSL model, an evaluator,
the start of a validator, infrastructure classes and tests.

This commit contains the first working version of parsing. New test
parses a simple puppet DSL expressions and returns the expected result.

This adds proper handling of numbers:
- an lex error if a number is not formatted correctly
- parser creates QualifiedName or LiteralNumber for NAME token
- tree dumper outputs numbers with specified radix

Add support for match expr with quoted text as RHS.

This adds support for expressions like 'a'=~ "ends with ${foo}" to
interpolate into the regular expression (a string is compiled into a
regular expression).

Note that lexer now does not produce a REGEXP after INHERITS as it used
to in earlier versions. (3.1 flags inherits with regexp as syntax error
even if it is allowed in the grammar).

Add parse test for some 3.x "weird" class and define syntax.

This includes performing look ahead in the lexer (for {|) and emitting a
LAMBDA token instead of a LBRACE for the lambda start LBRACE.
(#11331) Add support for foreach.

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.
(#11331) Add support to end a lambda with = expression.

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.
(#11331) Make implementation of lambda call work under Ruby 1.8.7

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].