maint: relax spec test of resources

The resource_spec performs some comparisons by using the equal_attributes_of
matcher. This is mostly correct, but considers some instance variables that are
of no consequence to the resource, e.g. @rstype. As a result, internal changes
to Puppet::Resource that may lead to this attribute not being set in a resource
that is generated from YAML would break this expectation:

expected
Foo::Bar[xyzzy]{:name=>"xyzzy", :one=>"test", :two=>"other"}
to equal attributes of
Foo::Bar[xyzzy]{:name=>"xyzzy", :one=>"test", :two=>"other"}

This is not only difficult to debug, it first and foremost misses the intention
of the example, which is only concerned with RAL attributes, not "internal"
instance variables.
(PUP-1381) issue warnings to current users of cron purging

A behavioral fix is planned for the 4.0 release. The final
3.x point releases should issue early warnings to users who employ
the functionality that is about to change.
(PUP-1381) make file_setting spec test more robust

A new call to self.resource_type in Puppet::Resource#initialize can cause
the loading of type code as a side effect. This interfered with the mocking
for the test

Puppet::Settings::FileSetting when being converted to a resource
should manage existent files even if 'create_files' is not enabled

Add a stubs call to one of the uncritical expectations so that
additional calls are not considered as spurious.
(PUP-1843) Restore hiera indirector terminus

This was collapsed into the DataBindings code in 9a5b81b412. That broke
community plugins using this code. This commit just restores the code
but doesn't revert the other changes from that commit.
(PUP-2298) add resource lifecycle method Puppet::Type#pre_run_check

In order to deprecate the builtin defined function (which is often abused
to work around resource duplication among modules) it is desirable to
add resource constraints to the language. An easy approach to allowing such
constraints to work is to add them as a special resource type that does not
take effect during the transaction, but fails the whole catalog in case of
validation failure.

To make this possible, add a new method #pre_run_check to the Type base class
for overriding in appropriate resource types (such as constraint).

The semantics is simply
- raise nothing if the pre-run check is succesful
- raise a Puppet::Error otherwise

The check is performed during evaluation of the transaction, just before
the catalog is applied. The generating of additional resources should be
complete when this is done (because the hook is meant to be able to
check the whole catalog for consistency).
(PUP-2298) protect transaction spec test against new exceptions

The new perform_pre_run_checks method in the transaction loops over
all resources in the catalog. This is prone to failures if any nil references
end up in the catalog. This can happen during the addition of resources
to the catalog under test conditions, because the mock resources are not
sufficiently contained.

To work around this effect, stub the very #container_of method in the mock
catalog so that all resources will have an apparent container.
(PUP-1381) Add link to explanation of message

Our standard practice for deprecation messages is to provide a link that
can point to more information than the message can provide.
Merge branch 'pr/2492'

* pr/2492:
  (PUP-1381) Add link to explanation of message
  (PUP-1381) make file_setting spec test more robust
  (PUP-1381) issue warnings to current users of cron purging
  maint: relax spec test of resources
(PUP-1070) cleanup empty/invalid lockfiles

Currently lockfiles won't be cleaned up automatically if they're empty or contain
non numeric characters.

This commit solves this by verifying that the content of the lockfile
contains a number or otherwise return nil which will result in deleting
the pidfile.
Merge branch 'ticket/master/PUP-1070-cleanup-invalid-lockfiles'

* ticket/master/PUP-1070-cleanup-invalid-lockfiles:
  (PUP-1070) cleanup empty/invalid lockfiles
(PUP-1843) Refactor duplicate code

Puppet::Indirector::Hiera and Puppet::DataBinding::Hiera had
identical implementations.  Puppet::DataBinding::Hiera is now a subclass
of Puppet::Indirector::Hiera.  Common behavior in their specs was also
moved into spec/shared_behaviors.
(PUP-2298) Use resource specific log_exception

Previously, we were logging the exception using `Puppet.err` and
passing in the resource reference in the message.

This commit changes it to use the log_exception method mixed into the
resource (Puppet::Type) so that we get resource-specific error
messages.

    Error: /Stage[main]/Main/Notify[hello]: something is not right
Merge branch 'pr/2549'

* pr/2549:
  (PUP-2298) Use resource specific log_exception
  (PUP-2298) protect transaction spec test against new exceptions
  (PUP-2298) add resource lifecycle method Puppet::Type#pre_run_check

Closes GH-2549
Merge pull request #2703 from jpartlow/issue/master/pup-1843-hiera-indirector

Issue/master/pup 1843 hiera indirector
(maint) Use real types and providers to exercise post_resource_eval

Previously, the spec tests were using the `user` type to test
post_resource_eval, but this has the side-effect of enumerating all of
the users on the system. On Mac OSX, this takes upwards of 4 seconds due
to parsing plist info.

This commit adds two new test-specific providers, which override the
`post_resource_eval` method, like a real type would do.
(maint) Use transaction_with_resource helpers to build up catalog and transaction

Cleanup the test to reuse the helpers that build up the catalog and
transaction. Eliminate instance variables of the form `@transaction` as
these can and should be local to the rspec example.
(PUP-1843) Clean up hiera terminus

The data_binding/hiera_spec.rb had a specific after block to clear up
the hiera terminus for following tests.  Moved this to the
shared_behaviors/hiera_indirections so that both indirector/hiera_spec
and data_binding/hiera_spec would be cleaned up, preventing order
dependent errors caused by global terminus state leaking between tests.
Merge branch 'maint/master/transaction_spec'

* maint/master/transaction_spec:
  (maint) Use transaction_with_resource helpers to build up catalog and transaction
  (maint) Use real types and providers to exercise post_resource_eval
(PUP-2657) FFI Puppet::Util::Windows::Error

 - Remove dependency on 'windows/error'
 - Expand FFI helper methods from MemoryPointer to Pointer as we need
   them to operate on a chunk of memory that will be LocalFree'd (i.e.
   MemoryPointer is set to own the memory and autorelease when done)
 - Unfortunately, attempts to use FFI to call GetLastError were futile.
   FFI.errno should automatically be capturing the GetLastError result
   of any call made through FFI, however this doesn't appear to be the
   case in practice.  Furthermore, attempting to define GetLastError as
   a function in FFI yields the same result.  A number of tests fail
   as the error code is being stomped / swallowed.  The solution is to
   use Win32API.new to define / use this single function.  Sigh.
Merge pull request #2695 from Iristyle/ticket/master/PUP-2657-FFI-Puppet-Util-Windows-Error

(PUP-2657) FFI Puppet::Util::Windows:Error