Skip to content

(PUP-391) Ruby 2 Compatibility / FFI fixes#2829

Merged
joshcooper merged 5 commits intopuppetlabs:masterfrom
Iristyle:ticket/master/PUP-391-validate-Ruby-2-x64
Jul 3, 2014
Merged

(PUP-391) Ruby 2 Compatibility / FFI fixes#2829
joshcooper merged 5 commits intopuppetlabs:masterfrom
Iristyle:ticket/master/PUP-391-validate-Ruby-2-x64

Conversation

@Iristyle
Copy link
Contributor

@Iristyle Iristyle commented Jul 2, 2014

No description provided.

@puppetcla
Copy link

CLA signed by all contributors.

@Iristyle Iristyle changed the title WIP - DO NOT MERGE (PUP-391) Ruby 2 / FFI fixes (PUP-391) Ruby 2 Compatibility / FFI fixes Jul 3, 2014
@Iristyle
Copy link
Contributor Author

Iristyle commented Jul 3, 2014

The taskscheduler test fails on Ruby 2 require an update to the win32-taskscheduler gem. See chef/win32-taskscheduler#9

@Iristyle
Copy link
Contributor Author

Iristyle commented Jul 3, 2014

So I'm guessing we should always be specifying the RDoc root given it's description at http://docs.ruby-lang.org/en/2.1.0/RDoc/Options.html

root[RW]
Root of the source documentation will be generated for. Set this when building documentation outside the source directory. Defaults to the current directory.

I also don't think that it should be the current source directory in specs either, but rather the folder full of test files.

I'll try to make sure I fully understand the tests, and how we use it in our codebase.

@Iristyle
Copy link
Contributor Author

Iristyle commented Jul 3, 2014

Also looks like RDoc introduced --root in RDoc 4.0.0, which came with my Ruby 2 distribution.
https://github.com/rdoc/rdoc/blob/master/History.rdoc#400--2013-02-24

In contrast, my Ruby 1.9.3 distribution has RDoc 3.9.5.

I believe that since --rootis an unknown option in 3.9.5, that --root and Dir.pwd are both actually being treated like file paths to parse, which would explain why we're now seeing parse errors in manifests inside the source directory during the spec run.

Iristyle added 2 commits July 3, 2014 06:13
 - The GetFileAttributes Win32 API call returns a DWORD, which is a
   platform independent 32-bit wide unsigned integer:
   http://msdn.microsoft.com/en-us/library/windows/desktop/aa364944(v=vs.85).aspx
   It's max value is 4294967295:
   http://msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspx
 - FFI::Pointer.new(-1).address is platform dependent and on x64 is
   18446744073709551615, the max value of a 64-bit wide unsigned int.
 - The INVALID_FILE_ATTRIBUTES constant is a valid return value of
   GetFileAttributes and is defined in winbase.h as:
   #define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
 - Therefore INVALID_FILE_ATTRIBUTES should be defined as 0xFFFFFFFF
@Iristyle
Copy link
Contributor Author

Iristyle commented Jul 3, 2014

Commit fe9f799 that makes updates for the lack of the windows-pr gem has been moved to the PUP-2521 PR at #2835

Iristyle added 3 commits July 3, 2014 07:19
 - In commit bf6f5c4, @@GetLastError
   was introduced as a band-aid to ensure the appropriate error code
   was read out of the thread local storage after a Win32 API call was
   made.  At that time, not all of the code had been converted to FFI
   compatible and not all gems had been upgraded to FFI compatible.
   Calls still made using Win32API were not captured by FFI.errno (which
   only calls GetLastError *after* making an FFI defined Win32 API call)
   resulting in a number of test fails.  The solution at the time was
   to manually call GetLastError instead to retrieve the value set by
   SetLastError.
 - Now that all Win32 API calls are made through FFI, FFI will
   automatically capture API results by calling GetLastError, and we
   can remove the unnecessary binding to GetLastError here.
 - When calling the document method on RDoc and the root option has not
   been specified, RDoc will provide a default in the options class:
   @root = Pathname(Dir.pwd).  NOTE: This does not affect RDoc 3.9.5
   that ships with Ruby 1.9.3 on Windows, only RDoc 4.0.0+ that ships
   with Ruby 2.0.0+ on Windows.
 - The win32-dir monkey patches the Dir.pwd method, and instead of
   using / separators like the rest of Ruby, it uses \ as a path
   separator.
 - RDoc uses Pathname, specifically the relative_path_from method
   which expects / separators, and gets confused with \.  Therefore,
   provide a workaround to ensure that Windows uses the appropriate
   / in paths.
 - File.open now raises EISDIR when a path is a directory, prior to
   verifying permissions in Ruby 2.  Files continue to return EACCESS.
@joshcooper joshcooper merged commit 0be9717 into puppetlabs:master Jul 3, 2014
@Iristyle Iristyle deleted the ticket/master/PUP-391-validate-Ruby-2-x64 branch July 3, 2014 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants