Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Ruby's built-in windows platform detection #813

Merged
merged 1 commit into from
Jun 20, 2021
Merged

Conversation

mvz
Copy link
Contributor

@mvz mvz commented Jun 14, 2021

Summary

Use Ruby's built-in windows platform detection.

Details

Use Gem.win_platform? instead of piggy-backing on Cucumber to check if we're running on Windows.

Motivation and Context

This avoids the need to load Cucumber when using Aruba with RSpec. A step toward fixing #402 and #806.

How Has This Been Tested?

Mostly CI.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Internal change (refactoring, test improvements, developer experience or update of dependencies)

Checklist:

  • I've added tests for my code
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@mvz mvz force-pushed the easy-windows-detection branch 3 times, most recently from 74c4231 to 3f00f77 Compare June 19, 2021 11:20
@mvz mvz merged commit 01eefdf into main Jun 20, 2021
@mvz mvz deleted the easy-windows-detection branch June 20, 2021 13:09
@voxik
Copy link

voxik commented Jan 4, 2022

Sadly, this interchange dependency on Cucumber for dependency on RubyGems. While I understand, that RubyGems is mostly available, I don't think it needs to be always the case, e.g. in case bundle install --standalone is used.

@voxik
Copy link

voxik commented Jan 4, 2022

I am thinking, would it be acceptable to use RSpec::Support::OS.windows? instead?

@mvz
Copy link
Contributor Author

mvz commented Jan 4, 2022

Unfortunately, rspec-support is only for internal use by rspec, so not something we can rely on.

@mvz
Copy link
Contributor Author

mvz commented Jan 4, 2022

ruby -e 'puts Gem.win_platform?' seems to run fine even on Ruby 2.5.0, so I don't think this is a problem. If you can produce a test case where Gem is not available, I can investigate and look into alternatives.

@jackorp
Copy link

jackorp commented Jan 11, 2022

ruby -e 'puts Gem.win_platform?' seems to run fine even on Ruby 2.5.0, so I don't think this is a problem. If you can produce a test case where Gem is not available, I can investigate and look into alternatives.

This is the issue for example with the rspec-core v3.10 spec suite, which uses the --disable-gems ruby option, resulting in Rubygems not being available.

When I follow steps for running the CI with unrestricted Aruba version (which pulls in Aruba 2.0), available in my branch: https://github.com/jackorp/rspec-core/tree/unrestrict-aruba

$ bundle install --standalone
$ bundle binstubs --all
$ script/run_build

then I get an exception regarding the Gem module:

$  script/run_build
============= Starting binstub check ===============
Checking required binstubs
============= Ending binstub check ===============
============= Starting specs ===============
/home/jprokop/projects/ruby/rspec-core/bin/rspec

An error occurred while loading spec_helper.
Failure/Error: require 'aruba/api'

NameError:
  uninitialized constant Aruba::Platforms::WindowsPlatform::Gem
# ./bundle/ruby/3.0.0/gems/aruba-2.0.0/lib/aruba/platforms/windows_platform.rb:21:in `match?'
# ./bundle/ruby/3.0.0/gems/aruba-2.0.0/lib/aruba/platform.rb:8:in `each'
# ./bundle/ruby/3.0.0/gems/aruba-2.0.0/lib/aruba/platform.rb:8:in `find'
# ./bundle/ruby/3.0.0/gems/aruba-2.0.0/lib/aruba/platform.rb:8:in `<module:Aruba>'
# ./bundle/ruby/3.0.0/gems/aruba-2.0.0/lib/aruba/platform.rb:5:in `<top (required)>'
# ./bundle/ruby/3.0.0/gems/aruba-2.0.0/lib/aruba/api.rb:6:in `require'
# ./bundle/ruby/3.0.0/gems/aruba-2.0.0/lib/aruba/api.rb:6:in `<top (required)>'
# ./spec/support/aruba_support.rb:28:in `require'
# ./spec/support/aruba_support.rb:28:in `block in <module:ArubaLoader>'
# ./spec/support/aruba_support.rb:27:in `<module:ArubaLoader>'
# ./spec/support/aruba_support.rb:25:in `<top (required)>'
# ./spec/spec_helper.rb:24:in `require'
# ./spec/spec_helper.rb:24:in `block in <top (required)>'
# ./spec/spec_helper.rb:17:in `map'
# ./spec/spec_helper.rb:17:in `<top (required)>'
# script/rspec_with_simplecov:42:in `load'
# script/rspec_with_simplecov:42:in `<main>'
No examples found.


Finished in 0.00008 seconds (files took 0.13783 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples

@mvz
Copy link
Contributor Author

mvz commented Jan 11, 2022

Thanks, @jackorp, I made an issue to track this.

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