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

CI: let's roll tests with JRuby #1755

Merged
merged 4 commits into from Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Expand Up @@ -14,8 +14,7 @@ jobs:
fail-fast: false
matrix:
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
# TODO: Add jruby if something like allow_failures will be implemented on Actions.
ruby: [2.6, 2.7, '3.0', 3.1]
ruby: [2.6, 2.7, '3.0', 3.1, 'jruby-9.3']
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
Expand Down
54 changes: 1 addition & 53 deletions test/integration_helper.rb
Expand Up @@ -105,59 +105,7 @@ def run_test(target, &block)
end
end

if RUBY_ENGINE == "jruby"
class JRubyServer < BaseServer
def start_vm
require 'java'
# Create a new container, set load paths and env
# SINGLETHREAD means create a new runtime
vm = org.jruby.embed.ScriptingContainer.new(org.jruby.embed.LocalContextScope::SINGLETHREAD)
vm.load_paths = [File.expand_path('../lib', __dir__)]
vm.environment = ENV.merge('APP_ENV' => environment.to_s)

# This ensures processing of RUBYOPT which activates Bundler
vm.provider.ruby_instance_config.process_arguments []
vm.argv = ['-s', server.to_s, '-o', '127.0.0.1', '-p', port.to_s, '-e', environment.to_s]

# Set stdout/stderr so we can retrieve log
@pipe = java.io.ByteArrayOutputStream.new
vm.output = java.io.PrintStream.new(@pipe)
vm.error = java.io.PrintStream.new(@pipe)

Thread.new do
# Hack to ensure that Kernel#caller has the same info as
# when run from command-line, for Sinatra::Application.app_file.
# Also, line numbers are zero-based in JRuby's parser
vm.provider.runtime.current_context.set_file_and_line(app_file, 0)
# Run the app
vm.run_scriptlet org.jruby.embed.PathType::ABSOLUTE, app_file
# terminate launches at_exit hooks which start server
vm.terminate
end
end

def run
return unless installed?
kill
@thread = start_vm
@started = Time.now
warn "#{server} up and running on port #{port}" if ping
at_exit { kill }
end

def log
String.from_java_bytes @pipe.to_byte_array
end

def kill
@thread.kill if @thread
@thread = nil
end
end
Server = JRubyServer
else
Server = BaseServer
end
Server = BaseServer

def it(message, &block)
Server.each do |server|
Expand Down