Skip to content
Permalink
Browse files

Get the build passing on JRuby

(though for now that's largely because we're skipping everything
interesting)
  • Loading branch information...
matthewd committed Dec 29, 2018
1 parent f16f75f commit 28580c33bc4123bcde7c7651120a6fe530db3a29
@@ -1,9 +1,16 @@
ARG RUBY_IMAGE
FROM ruby:${RUBY_IMAGE:-latest}
FROM ${RUBY_IMAGE:-ruby:latest}

RUN mkdir /app
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
git

RUN mkdir -p /app/test/fixtures
WORKDIR /app

ADD Rakefile /app
RUN rake fixtures

ADD . /app

RUN ./bin/setup
@@ -7,16 +7,20 @@ steps:
run: app
config: .buildkite/docker-compose.yml
env:
RUBY_IMAGE: "2.3"
RUBY_IMAGE: "ruby:2.3"
- <<: *rake
name: ":ruby: 2.4"
env:
RUBY_IMAGE: "2.4"
RUBY_IMAGE: "ruby:2.4"
- <<: *rake
name: ":ruby: 2.5"
env:
RUBY_IMAGE: "2.5"
RUBY_IMAGE: "ruby:2.5"
- <<: *rake
name: ":ruby: 2.6"
env:
RUBY_IMAGE: "2.6"
RUBY_IMAGE: "ruby:2.6"
- <<: *rake
name: "JRuby"
env:
RUBY_IMAGE: "jruby:latest"
@@ -1,5 +1,4 @@
/.buildkite/
/.dockerignore
/pkg/
/test/fixtures/*.gem
/tmp/
@@ -13,21 +13,23 @@ Rake::TestTask.new(:test) do |t|
t.test_files = FileList["test/**/*_test.rb"]
end

[
FIXTURE_GEMS = [
["rack", "2.0.3"],
["rack", "0.1.0"],
["hoe", "3.0.0"],
["rack-test", "0.6.3"],
["fast_blank", "1.0.0"],
["atomic", "1.1.16"],
].each do |name, version|
file "test/fixtures/#{name}-#{version}.gem" do
Dir.chdir "test/fixtures" do
system "../../bin/paperruby", "../../bootstrap.rb", "fetch", name, version
]

task :fixtures do
Dir.chdir "test/fixtures" do
FIXTURE_GEMS.each do |name, version|
filename = "#{name}-#{version}.gem"
next if File.exist?(filename)
system "curl", "-s", "-o", filename, "https://rubygems.org/gems/#{filename}"
end
end

task :fixtures => "test/fixtures/#{name}-#{version}.gem"
end

task :test => :fixtures
@@ -13,14 +13,6 @@

loader.activate(nil, store, install: true, output: $stderr)

when "fetch"
name, version = ARGV.shift, ARGV.shift

require_relative "lib/paperback/catalog"
cache_location = Paperback::Catalog.new("https://rubygems.org/").download_gem(name, version)
require "fileutils"
FileUtils.cp cache_location, "#{name}-#{version}.gem"

else
raise "unknown"
end
@@ -1,6 +1,9 @@
# frozen_string_literal: true

require "sdbm"
begin
require "sdbm"
rescue LoadError
end
require "pstore"
require "pathname"

@@ -10,7 +13,7 @@ class Paperback::DB
def self.new(root, name)
return super unless self == Paperback::DB

SDBM.new(root, name)
PStore.new(root, name)
end

def initialize(root, name)
@@ -170,7 +170,7 @@ def compile
end

def install
loadable_file_types = ["rb", RbConfig::CONFIG["DLEXT"], RbConfig::CONFIG["DLEXT2"]].reject(&:empty?)
loadable_file_types = ["rb", RbConfig::CONFIG["DLEXT"], RbConfig::CONFIG["DLEXT2"]].compact.reject(&:empty?)
loadable_file_types_re = /\.#{Regexp.union loadable_file_types}\z/
loadable_file_types_pattern = "*.{#{loadable_file_types.join(",")}}"

@@ -24,7 +24,7 @@

Paperback::Environment.open(Paperback::LockedStore.new(store))

if ENV["PAPERBACK_LOCKFILE"]
if ENV["PAPERBACK_LOCKFILE"] && ENV["PAPERBACK_LOCKFILE"] != ""
Paperback::Environment.activate(output: $stderr)
end

@@ -156,6 +156,8 @@ def test_report_unsatisfiable_constraints
end

def test_activate_gem_with_extensions
skip if jruby?

with_fixture_gems_installed(["fast_blank-1.0.0.gem"]) do |store|
assert_raises(LoadError) { require "fast_blank" }
assert_raises(NoMethodError) { "x".blank? }
@@ -62,6 +62,8 @@ def test_mode_on_installed_files
end

def test_installing_an_extension
skip if jruby?

Dir.mktmpdir do |dir|
store = Paperback::Store.new(dir)
result = Paperback::Package::Installer.new(store)
@@ -55,6 +55,8 @@ def with_fixture_gems_installed(paths)
end

def read_from_fork
skip "Can't fork" if jruby?

r, w = IO.pipe

child_pid = fork do
@@ -70,6 +72,12 @@ def read_from_fork
w.close
r.read
ensure
_, status = Process.waitpid2(child_pid)
raise "child failed: #{status.inspect}" unless status.success?
if child_pid
_, status = Process.waitpid2(child_pid)
raise "child failed: #{status.inspect}" unless status.success?
end
end

def jruby?
RUBY_ENGINE == "jruby"
end

0 comments on commit 28580c3

Please sign in to comment.
You can’t perform that action at this time.