(#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
Add recognizable prefix string to profiling log statements

This commit simply prefixes the profiling log strings with
the word "PROFILE", so that they are easy to grep for in
the output.
(#7841) Always read SELinux module header as little endian

These are always little endian, but are currently being read as native
byte order, which obviously causes failures.
Fix service enable specs on platforms without enable

These specs use the default service provider, but in the case where that
provider doesn't support the enable property, they were failing when
testing various values for that property. Many of these went unnoticed
because they weren't actually making any assertions, but rather checking
that nothing failed, so now they do assert.
Use the right provider instance in launchd provider specs

These tests were creating a resource and a launchd provider instance
from that resource, when the resource already has a (default) provider instance.
In most cases this was working fine, because the resource's provider
instance wasn't often being referred to. However, a couple of tests were
trying to set the enable property of the resource, which fails on systems without an
enableable provider. Now, we explicitly set the resource's provider to
launchd, as use its provider instance for all of our tests.
Fix posix exec provider spec on systems with /bin/cd

This test was setting path to /bin with the assumption that it didn't
contain cd, and therefore the only cd would be a shell built-in. On
system which *do* contain /bin/cd, this was failing. Now we just use a
bogus path so this will work everywhere.
Skip test that runs git if we can't run git

This test was assuming, incorrectly, that it will always be run from
inside a git repo with git installed. Now we properly handle the case
where it's not, and skip the test.
(maint) RPM package provider broken on AIX.

Prior to this commit, the RPM package provider would barf when
attempting to run `self.instances` on AIX. The culprit is the archaic
version of RPM (3.0.5) on AIX. The RPM provider assumed that the
`--nodigest` option (introduced in 4.0.2, circa 2001) was available.
This commit removes the `--nodigest` option for RPM versions older than
4.0.2.
Explicitly fail on downgrades in the AIX package provider

Downgrades do nothing because the package is superseded by a newer
version, but still don't exit non-zero. The only way to downgrade is to
force the installation, which requires us to ignore dependencies. As
this isn't palatable, we now explicitly fail if we see that the
package was superseded by a newer version.

This also fixes an issue of using << vs. +=, which would cause the
resource's name to be modified during installation.
(AIX) Convert rpm comparisons (regex -> semver)

Prior to this commit, the RPM package provider was using regular
expressions for comparing versions of the `rpm` utility. The regex
method, while functional, is not exactly readable nor does the regex
hold up once `rpm` hits version 10. This commit uses SemVer (even though
the `rpm` versions are *semantically* versioned, the SemVer library
already exists and can easily handle version comparisons) for checking
the specific cases of `rpm` versions < 4.1 and < 4.0.2.