Skip to content

Commit

Permalink
Merge pull request #47 from luislavena/feature/noop-for-other-gems
Browse files Browse the repository at this point in the history
Perform noop trying to compile non-compilable gems
  • Loading branch information
luislavena authored Dec 30, 2019
2 parents ca09e3d + b38bcec commit aa79510
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ upgrading.
### Changed
- Deal with RubyGems 3.x `new_spec` deprecation in tests.
- CI: Replace Travis/AppVeyor with GitHub Actions for Ubuntu, macOS and Windows.
- No longer raise exceptions when executed against non-compilable gems. (#38)

### Removed
- Drop support for Ruby 2.3.x, as it reached EOL (End Of Life)
Expand Down
10 changes: 6 additions & 4 deletions lib/rubygems/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,16 @@ def prepare_installer

# Hmm, gem already compiled?
if installer.spec.platform != Gem::Platform::RUBY
raise CompilerError,
"The gem file seems to be compiled already."
info "The gem file seems to be compiled already. Done."
cleanup
terminate_interaction
end

# Hmm, no extensions?
if installer.spec.extensions.empty?
raise CompilerError,
"There are no extensions to build on this gem file."
info "There are no extensions to build on this gem file. Done."
cleanup
terminate_interaction
end

installer
Expand Down
14 changes: 9 additions & 5 deletions test/rubygems/test_gem_compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,32 @@ def test_compile_no_extensions

compiler = Gem::Compiler.new(gem_file, :output => @output_dir)

e = assert_raises Gem::Compiler::CompilerError do
assert_raises Gem::MockGemUi::SystemExitException do
use_ui @ui do
compiler.compile
end
end

assert_equal "There are no extensions to build on this gem file.",
e.message
out = @ui.output.split "\n"

assert_equal "There are no extensions to build on this gem file. Done.",
out.last
end

def test_compile_non_ruby
gem_file = util_bake_gem { |s| s.platform = Gem::Platform::CURRENT }

compiler = Gem::Compiler.new(gem_file, :output => @output_dir)

e = assert_raises Gem::Compiler::CompilerError do
assert_raises Gem::MockGemUi::SystemExitException do
use_ui @ui do
compiler.compile
end
end

assert_equal "The gem file seems to be compiled already.", e.message
out = @ui.output.split "\n"

assert_equal "The gem file seems to be compiled already. Done.", out.last
end

def test_compile_pre_install_hooks
Expand Down

0 comments on commit aa79510

Please sign in to comment.