Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Speed up test gem installation
Browse files Browse the repository at this point in the history
  • Loading branch information
segiddins committed Aug 29, 2016
1 parent 289040e commit 5843270
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions spec/support/rubygems_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def self.setup
FileUtils.rm_rf(Path.base_system_gems)
FileUtils.mkdir_p(Path.base_system_gems)
puts "installing gems for the tests to use..."
DEPS.sort {|a, _| a[1].nil? ? 1 : -1 }.each {|n, v| install_gem(n, v) }
install_gems(DEPS)
File.open(manifest_path, "w") {|f| f << manifest.join }
end

Expand All @@ -46,10 +46,14 @@ def self.setup
Gem::DefaultUserInteraction.ui = Gem::SilentUI.new
end

def self.install_gem(name, version = nil)
cmd = "gem install #{name} --no-rdoc --no-ri"
cmd += " --version '#{version}'" if version
system(cmd) || raise("Installing gem #{name} for the tests to use failed!")
def self.install_gems(gems)
reqs, no_reqs = gems.partition {|_, req| !req.nil? && !req.split(" ").empty? }
no_reqs.map!(&:first)
reqs.map! {|name, req| "'#{name}:#{req}'" }
deps = reqs.concat(no_reqs).join(" ")
cmd = "gem install #{deps} --no-rdoc --no-ri"
puts cmd
system(cmd) || raise("Installing gems #{deps} for the tests to use failed!")
end
end
end

0 comments on commit 5843270

Please sign in to comment.