Don't duplicate CHILD_STATUS: it can't be modified.

The object in $CHILD_STATUS can't be modified except by executing an external
command; it is literally impossible for anyone to change it in any other way.
(A fact that causes us pain in other parts of the code.)

Given that, duplicating it is useless in most places, rather than just
returning a reference to the same object.  The runtime also doesn't mutate in
place, it points the top level variable somewhere else.

In MRI the extraneous dup was just a waste of CPU cycles allocating the
object.  JRuby literally can't allocate a new Process::Status object in Ruby
code, and caused a hard failure in consequence.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Avoid dangling symlinks for the sake of JRuby

JRuby 1.6.7.2 (and 1.7.0-preview1) have a bug where they are unable to
`readlink` on a dangling symlink.  This isn't actually needed in this
particular test - it was just a happenstance of implementation.

So, if we create the second target file as well as the first we can have the
suite pass on both platforms before the upstream problem is resolved.

See https://github.com/jruby/jruby/issues/210 for the upstream bug report.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Rewrite binwrite emulation again, this time for JRuby.

This emulation is an ongoing source of pain: every obscure platform has a
different set of things that go wrong, or are not implemented, or are
not abstracted.

In this case the IO.new mode operation on JRuby doesn't support POSIX numeric
modes, only string modes.  That blows up the last way we tried to work around
this stuff.

On the plus side, now we have a slow, ugly, but portable implementation that
passes on Windows, JRuby, and MRI 1.8.  This is good, finally.

Writing portable Ruby is just like writing portable C, only slower.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
JRuby < 1.7.0 fails on recursive YAML loading

Expanding YAML that contains a reference to a reference cycle - a child that
references a parent, for example - is mishandled by JRuby 1.6.7.2 and earlier.

JRuby 1.7 does the right thing, so we can just mark the test pending (with a
block to catch unexpected success) for the interim.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Disable `safe_posix_fork` tests on JRuby.

JRuby doesn't implement fork, but does explode if you close off an FD that it
uses; other platforms have tests that stub out fork itself, but let the other
behaviour alone, and that work exactly and only by chance.

JRuby doesn't - but we can disable the tests, as it doesn't break anything
deeper in the system that wouldn't already be broken.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Skip ~ expansion failure test that passes on JRuby

JRuby actually goes out and does the right thing  when faced with expanding a
path containing a tilde, but when 'HOME' is not set in the environment.
This is unlike MRI, which just fails in that case.

This is actually desirable behaviour, so just skip the test that asserts we
warn in that failure case.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Avoid stubbing methods on `nil`

Recent versions of Mocha treat stubbing something on the `nil` object as an
error, which is reasonable, but we did that in the queue application spec.

Since it makes no great difference, we can just put a stub object in place
where nil was sitting, and let that save us the trouble instead.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
more CA disabling stuff

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>