(#12101) Add shared context for specs to imitate windows or posix

Add "windows" and "posix" shared contexts to rspec. If you give :as_platform
=> :posix or :as_platform => :windows as argument to a describe block, it will
automatically stub the relevant facts and path behavior to imitate windows or
posix.
(#12101) Make Puppet::Util::absolute_path? usable in autoloader

This makes Puppet::Util::absolute_path? check File::ALT_SEPARATOR to determine
path behavior of the local system instead of Puppet.features, which required
having an Autoload instance already. File::ALT_SEPARATOR is only defined on
systems with Windows path behavior, and the Ruby standard library uses this
frequently to distinguish systems.
(#3581) Stop forking around: Add fork helper method

Without this patch we are forking all over the place. All this forking
around is problematic when it comes to things like ActiveRecord and
database connections. It turns out that forking has a nasty side effect
of aggressively closing database connections and spewing errors all over
the place.

This patch introduces a new `Puppet::Util#safe_posix_fork` method that
does forking the right way (closing file descriptors, and resetting
stdin, stdout, and stderr). Tagmail, Puppet kick, and
`Puppet::Util#execute_posix` have been updated to make use of this new
functionality.

In the future, `Puppet::Util#safe_posix_fork` should be used in-place of
direct calls to `Kernel#fork`.

This patch includes related spec tests.
(#9167) Do not send email when nothing changes

Without this patch the tagmail report sends an email even when there are
no changes or resources out of sync. This has the undesired effect of
sending emails after every Puppet run.

When there are no changes or out of sync resources, tagmail logs a
notice stating the fact and skips processing logs and sending emails.

This patch includes new spec tests for the changes in behavior.
(#13737) Swap build_tree and format_tree method names

The `Puppet::Module::Tool.build_tree` and
`Puppet::Module::Tool.format_tree` method names do not match their
behavior. Both methods actually do the inverse,
`Puppet::Module::Tool.build_tree` formats a tree for output and
`Puppet::Module::Tool.format_tree` builds the tree that is passed to
`Puppet::Module::Tool.build_tree`. Even this commit message is
confusing.

This patch swaps the names and updates the related specs.
(#13638) Add SemVer#pre function

Before this patch the `SemVer#[]` method uses a `proc` to pre-process
version strings, which seems a bit unnecessary when a method would do.

This patch replaces the `proc` with the `SemVer#pre` method and updates
the related specs.
(#13639) Don't send errors directly to stderr

Use `Puppet#err` and not `$stderr` to log error messages.
(#13642) Move search notice message

Currently the PMT search action assumes the searcher implementation will
connect to the HTTP server defined by
`Puppet.settings[:module_repository]` when searching for modules on the
Forge. The server defined by `Puppet.settings[:module_repository]` is then
used in a message printed on the console: `Searching #{server} …`. This
is a little too close to the implementation and the notice has been
moved closer to where the search is actually taking place.
(#13643) Make the use of FileUtils.rm_rf secure

Use the `:secure` option with the `FileUtils.rm_rf` method to
avoid a TOCTTOU (time-of-check-to-time-of-use) local security
vulnerability.
(#13649) Restrict module name matching

Before this patch the regex used to match valid module names in
`Puppet::Node::Environment#modules_by_path` matches invalid module
names.

This patch replaces the current regex pattern with one more accurate.
This patch also includes updated specs to cover this change in behavior.
(#13659) Convert fact values to string when searching database

When querying inventory_facts we need to treat the fact value as a string,
since it's stored as text in the database. This causes an error to be raised
on postgres.
[#13686] Fix directoryservices ShadowHashData code

Previously, Puppet wouldn't set a password if the ShadowHashData key was
missing from the User's plist.  This change will handle this situation,
create the key itself, and proceed with setting the password.
(#9167) Do not send email when nothing changes

Without this patch the tagmail report sends an email even when there are
no changes or resources out of sync. This has the undesired effect of
sending emails after every Puppet run.

When there are no changes or out of sync resources, tagmail logs a
notice stating the fact and skips processing logs and sending emails.

This patch includes new spec tests for the changes in behavior.
Merge remote-tracking branch 'kelseyhightower/kelseyhightower/ticket/2.7.x/9167_tagmail_report_sends_email_when_nothing_happens' into 2.7.x

* kelseyhightower/kelseyhightower/ticket/2.7.x/9167_tagmail_report_sends_email_when_nothing_happens:
  (#9167) Do not send email when nothing changes
Merge remote-tracking branch 'kelseyhightower/ticket/2.7.x/13637_rename_build_tree_to_format_tree' into 2.7.x

* kelseyhightower/ticket/2.7.x/13637_rename_build_tree_to_format_tree:
  (#13737) Swap build_tree and format_tree method names
Merge branch 'bug/2.7.x/13686_DS_Fix' into 2.7.x

* bug/2.7.x/13686_DS_Fix:
  [#13686] Fix directoryservices ShadowHashData code
Merge remote-tracking branch 'kelseyhightower/ticket/2.7.x/13639_use_puppet_logging_not_stderr' into 2.7.x

* kelseyhightower/ticket/2.7.x/13639_use_puppet_logging_not_stderr:
  (#13639) Don't send errors directly to stderr
(maint) Remove unnecessary step from puppet module build help

Without this patch the `puppet help module build` command says to make
sure the module directory is in the form of <username>-<modulename>.
This is an unnecessary step because it isn't actually necessary anymore.
It's a problem because we want to make things appear to be as simple as
they actually are, not more complex than they need to be.

I just tested this with a module existing at /vagrant/modules/jenkins
(no symlinks) using the command: `puppet module build .`

Everything worked out fine.  Puppet correctly reads the Modulefile and
figures out the author name.

This is a documentation only change.
Merge pull request #620 from kelseyhightower/kelseyhightower/ticket/2.7.x/3581_fork_that

(#3581) Stop forking around: Add fork helper method
Merge pull request #627 from kelseyhightower/ticket/2.7.x/13642_move_search_notice

(#13642) Move search notice message