-
-
Notifications
You must be signed in to change notification settings - Fork 122
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
Various fixes 2 #47
Various fixes 2 #47
Changes from all commits
f4889f6
c8a0a4c
b676538
d5f4a1d
9bbc7a9
39d147f
07c28b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Run a JRuby program in process. | ||
class InProcessExec | ||
attr_reader :status, :output | ||
|
||
def initialize(env, dir, args) | ||
raise "InProcessExec is only valid on JRuby!" unless RUBY_PLATFORM == "java" | ||
@env = env | ||
@dir = dir | ||
@args = args | ||
exec | ||
end | ||
|
||
private | ||
|
||
def exec | ||
prepare_streams | ||
prepare_config | ||
@status = org.jruby.Main.new(@config).run(@args.to_java(:String)).status | ||
@output = @output_stream.to_string | ||
end | ||
|
||
def prepare_streams | ||
@input_stream = java.io.ByteArrayInputStream.new([].to_java(:byte)) | ||
@output_stream = java.io.ByteArrayOutputStream.new | ||
@output_print_stream = java.io.PrintStream.new(@output_stream) | ||
end | ||
|
||
def prepare_config | ||
@config = org.jruby.RubyInstanceConfig.new(JRuby.runtime.instance_config) | ||
@config.environment = @env | ||
@config.current_directory = @dir | ||
@config.input = @input_stream | ||
@config.output = @output_print_stream | ||
@config.error = @output_print_stream | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require "rubygems" | ||
gem "bundler" | ||
require "bundler" | ||
require "bundler/fetcher" | ||
require_relative "../in_process_exec.rb" | ||
|
||
module Bundler | ||
#:nodoc: | ||
class Fetcher | ||
# The Bundler user_agent uses SecureRandom, which causes the specs | ||
# to run out of entropy and run a lot longer than they need to. | ||
def user_agent | ||
"gemstash spec" | ||
end | ||
end | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if it makes sense to create a Random generator based on a SecureRandom seed and just keep it around. No a blocker, though There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it's necessary, this is only in use for JRuby to speed up the build there. MRI doesn't seem to have the same problem, and the random number being generated doesn't really have any benefit in our specs. André pointed out in chat, it's for matching requests, which we don't really care about in the specs (nothing is hitting the actual rubygems servers). |
||
|
||
def Kernel.exec(*args) | ||
args.pop if args.last.kind_of?(Hash) | ||
process = InProcessExec.new(ENV, File.expand_path("."), args) | ||
puts process.output | ||
exit process.status | ||
end | ||
|
||
load Gem.bin_path("bundler", "bundle") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Based on jgem | ||
require "rubygems" | ||
require "rubygems/gem_runner" | ||
require "rubygems/exceptions" | ||
|
||
begin | ||
Gem::GemRunner.new.run ARGV.clone | ||
rescue Gem::SystemExitException => e | ||
exit e.exit_code | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😆
42 is a perfect randomly generated number!