Merge pull request #945 from kbarber/ticket/3.x/maint-find_module_root_fix_expand_path_test_failure

Fix find_module_root tests so paths are expanded in assertions
parser/files: use a cheaper test for "is this path absolute?"

The parser used `path == File.expand_path(path)` as a test for the path being
absolute - something that wasn't entirely accurate, and that also wasn't
terrible fast. It also generated substantial memory and object allocation
traffic in the VM.

Replacing that with our util absolute_path? tool is faster and more efficient.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
util: don't rebuild regexp every time we invoke absolute_file?

Previously, the `absolute_path?` tool rebuilt both regular expressions, POSIX
and Windows, every time it was invoked.  Since they are constant, promoting
them to a constant saves some time and trouble for the VM.

We can also tell it that you can interpolate the values once on Windows,
rather than every time through, which should improve performance and object
load further on that platform.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Merge remote-tracking branch 'upstream/3.x'

* upstream/3.x:
  Fix find_module_root tests so paths are expanded in assertions
  Refactor ast_spec to use real values
  (Maint) Don't assume paths are absolute
  Determine packaging version with git describe
  (#14600) Fix cleanup of tempfiles in file_spec
  (#14531) Change default ensure value from symlink to link
  (#14860) Fix puppet cert exit status on failures
  (#14599) Handle ENOTDIR in file type
  (#13880) Add openrc spec - service with extreme long name
  (#13880) Add openrc service provider for Gentoo and Funtoo
  Fixes for #10915 and #11200 - user provider for AIX
  (#10354) added delete command to fix missing userdel flag in useradd provider
zaml: don't sort object attributes for output

Sorting YAML attributes makes for marginally nicer human-friendly YAML output,
but ends up costing a non-trivial amount of computation to determine the
ordering of objects.

We can skip that with pretty much no adverse effects.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Merge pull request #935 from daniel-pittman/perf/3.x/zaml-performance

ZAML/YAML performance and correctness fixes
provider: don't create useless proc instances.

When defining commands, the code created an empty proc in the 129 out of 130
cases that the caller didn't supply one, on my test system.  That was an awful
lot of uselessly defined code to avoid "unless block" in the target method.

Which we do, and avoid that load.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
whit: cache the `to_s` result.

This saves about 1.6MB of generated memory, something on the order of 10,000
object allocations and garbage collections, and a whole lot of waste in my
test system.

This runs at, like, O(50n), so while it is just linear it is still a huge
constant factor through the system.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
15547 : use a clean env for builtin check

solaris has /bin/cd as a command to ensure posix compatibility. So
we need to avoid using '/bin' in path if we want to ensure that we
are looking at shell builtin cd.
15547 : valid locales as sentinel and check

Using spurious values for LC_ALL and LANG values in solaris causes
some commands to barf. Since we are only checking for overrides, we
can aswell use a valid locale.
15547 : Add home environemnt to pkgutil

pkgutil expects home to be set when run as non-user. Add $HOME when
invoking pkgutil
Implement `Fixnum#ord` for Ruby 1.8.5

This is a compatibility method for addressing characters introduced in 1.8.7;
we also need the same compatibility back to 1.8.5, so we monkey-patch it in
when it isn't already there.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Merge pull request #949 from daniel-pittman/bug/3.x/fix-missing-ord-on-185

Implement `Fixnum#ord` for Ruby 1.8.5
(13070) Mark files as loaded before we load

There is a loading cycle that occurs in some situations. It showed up as
not being able to describe certain types because the description
depended on the name of the type's class. For some reason (that is not
entirely clear) the multiple loading of code seems to cause the name of
the class to be wrong.

This patch changes it to mark the file as loaded first, so that we don't
get into a loading cycle.
zaml: speed micro-optimization for Time output

This is a minor reduction in the time spent outputting times in the ZAML
encoder, by using a (30 percent) faster mechanism to trim the generated ms
value down.

There is a minor reduction in memory load, but not anything substantial.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
log_paths: memoize the entire value, not just part of it.

This function would memoize the upstream input, but would then recalculate the
final string value every time through.  That doesn't make much sense, so we
might as well memoize the entire value.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
file_serving: avoid rewriting paths if possible.

A trivial change - only rewrite from '//' to '/', rather than from '/+' -
means that we can reduce the garbage generation in this
function substantially.  Most paths now pass through unmodified.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
tagging: use a static regexp rather than rebuilding it

This is worth ~ 1 percent CPU time in catalog compilation in testing.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Merge pull request #950 from zaphod42/bug/2.7.x/13070-error-describing-types

(13070) Mark files as loaded before we load
Merge remote-tracking branch 'origin/2.7.x' into 3.x