Age | Commit message (Collapse) | Author | Files | Lines |
|
Conflicts:
lib/puppet/util/adsi.rb
spec/unit/util/adsi_spec.rb
|
|
Added Puppet::Util.path_to_uri and uri_to_path. These methods will be
needed to support Windows file paths as the file 'source' property,
metadata, and indirector.
The path_to_uri method takes an absolute path and constructs a file
URI, e.g. 'file:/foo'. Note this is equivalent to 'file:///foo' as in
both cases the authority component of the URI is optional.
On Windows local file paths are typically URI-ized as 'file:/C:/foo'
(or 'file:///C:/foo'), whereas 'file://host/C:/foo' is used to express
UNC paths.
The uri_to_path method takes a URI (not necessarily a file URI) and
extracts the unescaped path portion. So given a URI of
'file:/foo%20bar', the method returns '/foo bar'.
On Windows, this method strips the leading slash from file URIs that
contain drive letters. It also converts UNC URIs of the form
'file://host/share/file' to '//host/share/file'
|
|
Previously the regex used to detect Windows absolute paths only
applied the caret to the first part of the regex (the part that
matched drive letters). But the parts used to detect UNC paths
(\\server\name) and prefixed paths (\\?\C:\foo) were matching any part
of the string. And since / and \ are valid path separators on Windows,
URIs like puppet://foo/bar (used as file sources) were incorrectly
thought to be absolute paths.
This commit ensures the absolute path regex is restricted to the start
of the string for all cases.
|
|
The Process.waitpid2 method in the win32-process gem returns an array,
with the child's exit status as the last element. This is different
than ruby's implementation where the last element is a Process::Status
object, which has an exitstatus method.
As a result, if a child process returned a non-zero exit status on
Windows, then Puppet::Util.execute would raise an error while trying
to call the exitstatus method on a Fixnum (the actual exit status).
This commit ensures we consistently retrieve the exit status
across all platforms.
|
|
This test had previously been checking that the path attribute of the
Tempfile used for stdout was nil, in order to determine whether or not
the file had been deleted. However, on Ruby 1.8.5, a Tempfile's data is
not cleared when the file is closed and deleted. Thus, its path wasn't
actually nil and it was failing, even though the file had properly been
deleted.
Now, we just check whether or not the file exists, which will always
directly correspond to whether or not the file has been deleted.
Reviewed-By: Matt Robinson <matt@puppetlabs.com>
|
|
The primary change in this commit is fixing the support for Windows in
Puppet::Util.execute. However, properly testing this commit required
significant refactoring (which was long overdue for this old code) for
testability.
The functionality for executing on posix and windows was extracted into
platform-specific methods, execute_posix and execute_windows. These
methods are self-contained and will both return the PID of the child
process, which the caller then waits on before reading and returning the
output of the command.
|
|
The method Puppet::Util.absolute_path? accepts a path and an optional
platform (:windows or :posix) as an argument. If no platform is given,
it will default to the local platform. The method will return true if
the path provided is absolute on that platform, and false if it is not.
This method is also being used in Puppet::Util.which in lieu of testing
against a platform-specific regex inline.
|