summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/bundler/definition.rb36
-rw-r--r--lib/bundler/dependency.rb2
-rw-r--r--lib/bundler/dsl.rb4
-rw-r--r--lib/bundler/errors.rb2
-rw-r--r--lib/bundler/fetcher.rb4
-rw-r--r--lib/bundler/fetcher/base.rb14
-rw-r--r--lib/bundler/plugin/api/source.rb6
-rw-r--r--lib/bundler/resolver.rb22
-rw-r--r--lib/bundler/source/git.rb12
-rw-r--r--lib/rubygems.rb2
-rw-r--r--lib/rubygems/commands/install_command.rb2
-rw-r--r--lib/rubygems/commands/sources_command.rb2
-rw-r--r--lib/rubygems/core_ext/kernel_require.rb2
-rw-r--r--lib/rubygems/errors.rb2
-rw-r--r--lib/rubygems/ext/builder.rb6
-rw-r--r--lib/rubygems/ext/cargo_builder.rb151
-rw-r--r--lib/rubygems/ext/cargo_builder/link_flag_converter.rb23
-rw-r--r--lib/rubygems/local_remote_options.rb2
-rw-r--r--lib/rubygems/psych_additions.rb10
-rw-r--r--lib/rubygems/request.rb2
-rw-r--r--lib/rubygems/source.rb11
-rw-r--r--lib/rubygems/source/git.rb4
-rw-r--r--lib/rubygems/source_list.rb6
-rw-r--r--lib/rubygems/specification.rb22
-rw-r--r--lib/rubygems/uri.rb67
-rw-r--r--spec/bundler/bundler/dsl_spec.rb2
-rw-r--r--spec/bundler/bundler/plugin_spec.rb22
-rw-r--r--spec/bundler/install/gemfile/platform_spec.rb4
-rw-r--r--test/rubygems/data/excon-0.7.7.gemspec.rzbin0 -> 388 bytes
-rw-r--r--test/rubygems/data/pry-0.4.7.gemspec.rz (renamed from test/rubygems/data/null-type.gemspec.rz)bin433 -> 433 bytes
-rw-r--r--test/rubygems/helper.rb2
-rw-r--r--test/rubygems/test_gem_commands_cert_command.rb2
-rw-r--r--test/rubygems/test_gem_commands_sources_command.rb51
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder.rb69
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.lock67
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.toml3
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/custom_name/build.rb4
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock67
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml3
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder_link_flag_converter.rb33
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder_unit.rb75
-rw-r--r--test/rubygems/test_gem_ext_ext_conf_builder.rb1
-rw-r--r--test/rubygems/test_gem_request_set_gem_dependency_api.rb2
-rw-r--r--test/rubygems/test_gem_specification.rb11
-rw-r--r--test/rubygems/test_require.rb4
-rw-r--r--tool/bundler/dev_gems.rb5
-rw-r--r--tool/bundler/dev_gems.rb.lock21
47 files changed, 530 insertions, 334 deletions
@@ -255,20 +255,18 @@ module Bundler
#
# @return [SpecSet] resolved dependencies
def resolve
- @resolve ||= begin
- if Bundler.frozen_bundle?
- Bundler.ui.debug "Frozen, using resolution from the lockfile"
- @locked_specs
- elsif !unlocking? && nothing_changed?
- Bundler.ui.debug("Found no changes, using resolution from the lockfile")
- SpecSet.new(filter_specs(@locked_specs, @dependencies.select {|dep| @locked_specs[dep].any? }))
- else
- last_resolve = converge_locked_specs
- # Run a resolve against the locally available gems
- Bundler.ui.debug("Found changes from the lockfile, re-resolving dependencies because #{change_reason}")
- expanded_dependencies = expand_dependencies(dependencies + metadata_dependencies, true)
- Resolver.resolve(expanded_dependencies, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms)
- end
end
end
@@ -735,12 +733,10 @@ module Bundler
end
def metadata_dependencies
- @metadata_dependencies ||= begin
- [
- Dependency.new("Ruby\0", RubyVersion.system.gem_version),
- Dependency.new("RubyGems\0", Gem::VERSION),
- ]
- end
end
def expand_dependencies(dependencies, remote = false)
@@ -9,6 +9,7 @@ module Bundler
attr_reader :autorequire
attr_reader :groups, :platforms, :gemfile, :git, :, :branch, :ref
PLATFORM_MAP = {
:ruby => Gem::Platform::RUBY,
:ruby_18 => Gem::Platform::RUBY,
@@ -91,6 +92,7 @@ module Bundler
:x64_mingw_30 => Gem::Platform::X64_MINGW,
:x64_mingw_31 => Gem::Platform::X64_MINGW,
}.freeze
def initialize(name, version, options = {}, &blk)
type = options["type"] || :runtime
@@ -511,9 +511,7 @@ module Bundler
# be raised.
#
def contents
- @contents ||= begin
- dsl_path && File.exist?(dsl_path) && File.read(dsl_path)
- end
end
# The message of the exception reports the content of podspec for the
@@ -41,12 +41,14 @@ module Bundler
class GemspecError < BundlerError; status_code(14); end
class InvalidOption < BundlerError; status_code(15); end
class ProductionError < BundlerError; status_code(16); end
class HTTPError < BundlerError
status_code(17)
def filter_uri(uri)
URICredentialsFilter.credential_filtered_uri(uri)
end
end
class RubyVersionMismatch < BundlerError; status_code(18); end
class SecurityError < BundlerError; status_code(19); end
class LockfileError < BundlerError; status_code(20); end
@@ -20,6 +20,7 @@ module Bundler
class TooManyRequestsError < HTTPError; end
# This error is raised if the API returns a 413 (only printed in verbose)
class FallbackError < HTTPError; end
# This is the error raised if OpenSSL fails the cert verification
class CertificateFailureError < HTTPError
def initialize(remote_uri)
@@ -33,6 +34,7 @@ module Bundler
" sources and change 'https' to 'http'."
end
end
# This is the error raised when a source is HTTPS and OpenSSL didn't load
class SSLError < HTTPError
def initialize(msg = nil)
@@ -42,6 +44,7 @@ module Bundler
"using RVM are available at rvm.io/packages/openssl."
end
end
# This error is raised if HTTP authentication is required, but not provided.
class AuthenticationRequiredError < HTTPError
def initialize(remote_uri)
@@ -52,6 +55,7 @@ module Bundler
"or by storing the credentials in the `#{Settings.key_for(remote_uri)}` environment variable"
end
end
# This error is raised if HTTP authentication is provided, but incorrect.
class BadAuthenticationError < HTTPError
def initialize(remote_uri)
@@ -19,14 +19,12 @@ module Bundler
end
def fetch_uri
- @fetch_uri ||= begin
- if remote_uri.host == "rubygems.org"
- uri = remote_uri.dup
- uri.host = "index.rubygems.org"
- uri
- else
- remote_uri
- end
end
end
@@ -258,7 +258,7 @@ module Bundler
@dependencies |= Array(names)
end
- # Note: Do not override if you don't know what you are doing.
def can_lock?(spec)
spec.source == self
end
@@ -285,7 +285,7 @@ module Bundler
end
alias_method :identifier, :to_s
- # Note: Do not override if you don't know what you are doing.
def include?(other)
other == self
end
@@ -294,7 +294,7 @@ module Bundler
SharedHelpers.digest(:SHA1).hexdigest(uri)
end
- # Note: Do not override if you don't know what you are doing.
def gem_install_dir
Bundler.install_path
end
@@ -233,19 +233,17 @@ module Bundler
# before dependencies that are unconstrained
def amount_constrained(dependency)
@amount_constrained ||= {}
- @amount_constrained[dependency.name] ||= begin
- if (base = @base[dependency.name]) && !base.empty?
- dependency.requirement.satisfied_by?(base.first.version) ? 0 : 1
- else
- all = index_for(dependency).search(dependency.name).size
- if all <= 1
- all - 1_000_000
- else
- search = search_for(dependency)
- search = @prerelease_specified[dependency.name] ? search.count : search.count {|s| !s.version.prerelease? }
- search - all
- end
end
end
end
@@ -219,13 +219,11 @@ module Bundler
# across different projects, this cache will be shared.
# When using local git repos, this is set to the local repo.
def cache_path
- @cache_path ||= begin
- if Bundler.requires_sudo? || Bundler.feature_flag.global_gem_cache?
- Bundler.user_cache
- else
- Bundler.bundle_path.join("cache", "bundler")
- end.join("git", git_scope)
- end
end
def app_cache_dirname
@@ -607,7 +607,6 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
return if @yaml_loaded
require 'psych'
- require_relative 'rubygems/psych_additions'
require_relative 'rubygems/psych_tree'
require_relative 'rubygems/safe_yaml'
@@ -1018,7 +1017,6 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
def self.load_plugin_files(plugins) # :nodoc:
plugins.each do |plugin|
-
# Skip older versions of the GemCutter plugin: Its commands are in
# RubyGems proper now.
@@ -261,7 +261,7 @@ You can use `i` command instead of `install`.
return unless Gem::SourceFetchProblem === x
require_relative "../uri"
- msg = "Unable to pull data from '#{Gem::Uri.new(x.source.uri).redacted}': #{x.error.message}"
alert_warning msg
end
@@ -62,7 +62,7 @@ class Gem::Commands::SourcesCommand < Gem::Command
say "#{source_uri} is not a URI"
terminate_interaction 1
rescue Gem::RemoteFetcher::FetchError => e
- say "Error fetching #{source_uri}:\n\t#{e.message}"
terminate_interaction 1
end
end
@@ -18,7 +18,7 @@ module Kernel
end
file = Gem::KERNEL_WARN_IGNORES_INTERNAL_ENTRIES ? "<internal:#{__FILE__}>" : __FILE__
- module_eval <<'RUBY', file, __LINE__ + 1
##
# When RubyGems is required, Kernel#require is replaced with our own which
# is capable of loading gems on demand.
@@ -168,7 +168,7 @@ module Gem
# An English description of the error.
def wordy
- "Unable to download data from #{Gem::Uri.new(@source.uri).redacted} - #{@error.message}"
end
##
@@ -55,7 +55,7 @@ class Gem::Ext::Builder
end
end
- def self.run(command, results, command_name = nil, dir = Dir.pwd)
verbose = Gem.configuration.really_verbose
begin
@@ -70,9 +70,9 @@ class Gem::Ext::Builder
require "open3"
# Set $SOURCE_DATE_EPOCH for the subprocess.
- env = { 'SOURCE_DATE_EPOCH' => Gem.source_date_epoch_string }
output, status = begin
- Open3.capture2e(env, *command, :chdir => dir)
rescue => error
raise Gem::InstallError, "#{command_name || class_name} failed#{error.message}"
end
@@ -4,48 +4,67 @@
# over the `cargo rustc` command which takes care of building Rust code in a way
# that Ruby can use.
class Gem::Ext::CargoBuilder < Gem::Ext::Builder
- attr_reader :spec
def initialize(spec)
@spec = spec
end
def build(_extension, dest_path, results, args = [], lib_dir = nil, cargo_dir = Dir.pwd)
- require "rubygems/command"
require "fileutils"
require "shellwords"
build_crate(dest_path, results, args, cargo_dir)
- ext_path = rename_cdylib_for_ruby_compatibility(dest_path)
- finalize_directory(ext_path, dest_path, lib_dir, cargo_dir)
results
end
- private
-
def build_crate(dest_path, results, args, cargo_dir)
- manifest = File.join(cargo_dir, "Cargo.toml")
- given_ruby_static = ENV["RUBY_STATIC"]
- ENV["RUBY_STATIC"] = "true" if ruby_static? && !given_ruby_static
cargo = ENV.fetch("CARGO", "cargo")
cmd = []
cmd += [cargo, "rustc"]
cmd += ["--target-dir", dest_path]
cmd += ["--manifest-path", manifest]
- cmd += ["--lib", "--release", "--locked"]
- cmd += ["--"]
- cmd += [*cargo_rustc_args(dest_path)]
cmd += Gem::Command.build_args
cmd += args
- self.class.run cmd, results, self.class.class_name, cargo_dir
- results
- ensure
- ENV["RUBY_STATIC"] = given_ruby_static
end
def cargo_rustc_args(dest_dir)
@@ -92,7 +111,7 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder
def libruby_args(dest_dir)
libs = makefile_config(ruby_static? ? "LIBRUBYARG_STATIC" : "LIBRUBYARG_SHARED")
raw_libs = Shellwords.split(libs)
- raw_libs.flat_map {|l| ldflag_to_link_modifier(l, dest_dir) }
end
def ruby_static?
@@ -103,22 +122,33 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder
# Ruby expects the dylib to follow a file name convention for loading
def rename_cdylib_for_ruby_compatibility(dest_path)
- dylib_path = validate_cargo_build!(dest_path)
- dlext_name = "#{spec.name}.#{makefile_config("DLEXT")}"
- new_name = dylib_path.gsub(File.basename(dylib_path), dlext_name)
- FileUtils.cp(dylib_path, new_name)
- new_name
end
def validate_cargo_build!(dir)
- prefix = so_ext == "dll" ? "" : "lib"
- dylib_path = File.join(dir, "release", "#{prefix}#{cargo_crate_name}.#{so_ext}")
raise DylibNotFoundError, dir unless File.exist?(dylib_path)
dylib_path
end
def cargo_crate_name
spec.metadata.fetch('cargo_crate_name', spec.name).tr('-', '_')
end
@@ -127,42 +157,19 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder
split_flags("DLDFLAGS")
.map {|arg| maybe_resolve_ldflag_variable(arg, dest_dir) }
.compact
- .flat_map {|arg| ldflag_to_link_modifier(arg, dest_dir) }
end
def rustc_lib_flags(dest_dir)
- split_flags("LIBS").flat_map {|arg| ldflag_to_link_modifier(arg, dest_dir) }
end
def split_flags(var)
Shellwords.split(RbConfig::CONFIG.fetch(var, ""))
end
- def ldflag_to_link_modifier(arg, dest_dir)
- flag = arg[0..1]
- val = arg[2..-1]
-
- case flag
- when "-L" then ["-L", "native=#{val}"]
- when "-l" then ["-l", val.to_s]
- when "-F" then ["-l", "framework=#{val}"]
- else ["-C", "link_arg=#{arg}"]
- end
- end
-
- def link_flag(link_name)
- # These are provided by the CRT with MSVC
- # @see https://.com/rust-lang/pkg-config-rs/blob/49a4ac189aafa365167c72e8e503565a7c2697c2/src/lib.rs#L622
- return [] if msvc_target? && ["m", "c", "pthread"].include?(link_name)
-
- if link_name.include?("ruby")
- # Specify the lib kind and give it the name "ruby" for linking
- kind = ruby_static? ? "static" : "dylib"
-
- ["-l", "#{kind}=ruby:#{link_name}"]
- else
- ["-l", link_name]
- end
end
def msvc_target?
@@ -182,20 +189,24 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder
!!Gem::WIN_PATTERNS.find {|r| target_platform =~ r }
end
- # Intepolate substition vars in the arg (i.e. $(DEFFILE))
def maybe_resolve_ldflag_variable(input_arg, dest_dir)
- str = input_arg.gsub(/\$\((\w+)\)/) do |var_name|
- case var_name
- # On windows, it is assumed that mkmf has setup an exports file for the
- # extension, so we have to to create one ourselves.
- when "DEFFILE"
- write_deffile(dest_dir)
- else
- RbConfig::CONFIG[var_name]
- end
- end.strip
- str == "" ? nil : str
end
def write_deffile(dest_dir)
@@ -241,14 +252,18 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder
# Good balance between binary size and debugability
def debug_flags
["-C", "debuginfo=1"]
end
# Copied from ExtConfBuilder
- def finalize_directory(ext_path, dest_path, lib_dir, extension_dir)
require "fileutils"
require "tempfile"
begin
tmp_dest = Dir.mktmpdir(".gem.", extension_dir)
@@ -280,6 +295,14 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder
path
end
# Error raised when no cdylib artifact was created
class DylibNotFoundError < StandardError
def initialize(dir)
@@ -0,0 +1,23 @@
@@ -78,7 +78,6 @@ module Gem::LocalRemoteOptions
def add_clear_sources_option
add_option(:"Local/Remote", '--clear-sources',
'Clear the gem sources') do |value, options|
-
Gem.sources = nil
options[:sources_cleared] = true
end
@@ -105,7 +104,6 @@ module Gem::LocalRemoteOptions
add_option(:"Local/Remote", '-s', '--source URL', URI::HTTP,
'Append URL to list of remote gem sources') do |source, options|
-
source << '/' if source !~ /\/\z/
if options.delete :sources_cleared
@@ -1,10 +0,0 @@
-# frozen_string_literal: true
-# This exists just to satisfy bugs in marshal'd gemspecs that
-# contain a reference to Psych::PrivateType. We prune these out
-# in Specification._load, but if we don't have the constant, Marshal
-# blows up.
-
-module Psych # :nodoc:
- class PrivateType # :nodoc:
- end
-end
@@ -193,7 +193,7 @@ class Gem::Request
begin
@requests[connection.object_id] += 1
- verbose "#{request.method} #{Gem::Uri.new(@uri).redacted}"
file_name = File.basename(@uri.path)
# perform download progress reporter only for gems
@@ -26,15 +26,8 @@ class Gem::Source
# Creates a new Source which will use the index located at +uri+.
def initialize(uri)
- begin
- unless uri.kind_of? URI
- uri = URI.parse(uri.to_s)
- end
- rescue URI::InvalidURIError
- raise if Gem::Source == self.class
- end
-
- @uri = uri
@update_cache = nil
end
@@ -49,8 +49,8 @@ class Gem::Source::Git < Gem::Source
# will be checked out when the gem is installed.
def initialize(name, repository, reference, submodules = false)
- super repository
-
@name = name
@repository = repository
@reference = reference
@@ -48,15 +48,11 @@ class Gem::SourceList
# String.
def <<(obj)
- require "uri"
-
src = case obj
- when URI
- Gem::Source.new(obj)
when Gem::Source
obj
else
- Gem::Source.new(URI.parse(obj))
end
@sources << src unless @sources.include?(src)
@@ -1272,10 +1272,26 @@ class Gem::Specification < Gem::BasicSpecification
array = begin
Marshal.load str
rescue ArgumentError => e
- raise unless e.message.include?("YAML")
- Object.const_set "YAML", Psych
- Marshal.load str
end
spec = Gem::Specification.new
@@ -5,6 +5,44 @@
#
class Gem::Uri
def initialize(source_uri)
@parsed_uri = parse(source_uri)
end
@@ -26,7 +64,7 @@ class Gem::Uri
end
def redact_credentials_from(text)
- return text unless valid_uri? && password?
text.sub(password, 'REDACTED')
end
@@ -50,35 +88,12 @@ class Gem::Uri
private
- ##
- # Parses the #uri, raising if it's invalid
-
def parse!(uri)
- require "uri"
-
- raise URI::InvalidURIError unless uri
-
- # Always escape URI's to deal with potential spaces and such
- # It should also be considered that source_uri may already be
- # a valid URI with escaped characters. e.g. "{DESede}" is encoded
- # as "%7BDESede%7D". If this is escaped again the percentage
- # symbols will be escaped.
- begin
- URI.parse(uri)
- rescue URI::InvalidURIError
- URI.parse(URI::DEFAULT_PARSER.escape(uri))
- end
end
- ##
- # Parses the #uri, returning the original uri if it's invalid
-
def parse(uri)
- return uri unless uri.is_a?(String)
-
- parse!(uri)
- rescue URI::InvalidURIError
- uri
end
def with_redacted_user
@@ -137,6 +137,7 @@ RSpec.describe Bundler::Dsl do
end
describe "#gem" do
[:ruby, :ruby_18, :ruby_19, :ruby_20, :ruby_21, :ruby_22, :ruby_23, :ruby_24, :ruby_25, :ruby_26, :ruby_27,
:ruby_30, :ruby_31, :mri, :mri_18, :mri_19, :mri_20, :mri_21, :mri_22, :mri_23, :mri_24, :mri_25, :mri_26,
:mri_27, :mri_30, :mri_31, :jruby, :rbx, :truffleruby].each do |platform|
@@ -144,6 +145,7 @@ RSpec.describe Bundler::Dsl do
subject.gem("foo", :platform => platform)
end
end
it "rejects invalid platforms" do
expect { subject.gem("foo", :platform => :bogus) }.
@@ -280,12 +280,12 @@ RSpec.describe Bundler::Plugin do
end
Bundler::Plugin::Events.send(:reset)
- Bundler::Plugin::Events.send(:define, :EVENT_1, "event-1")
- Bundler::Plugin::Events.send(:define, :EVENT_2, "event-2")
- allow(index).to receive(:hook_plugins).with(Bundler::Plugin::Events::EVENT_1).
and_return(["foo-plugin", "", nil])
- allow(index).to receive(:hook_plugins).with(Bundler::Plugin::Events::EVENT_2).
and_return(["foo-plugin"])
allow(index).to receive(:plugin_path).with("foo-plugin").and_return(path)
allow(index).to receive(:load_paths).with("foo-plugin").and_return([])
@@ -303,33 +303,33 @@ RSpec.describe Bundler::Plugin do
it "executes the hook" do
expect do
- Plugin.hook(Bundler::Plugin::Events::EVENT_1)
end.to output("hook for event 1\n").to_stdout
end
context "single plugin declaring more than one hook" do
let(:code) { <<-RUBY }
- Bundler::Plugin::API.hook(Bundler::Plugin::Events::EVENT_1) {}
- Bundler::Plugin::API.hook(Bundler::Plugin::Events::EVENT_2) {}
puts "loaded"
RUBY
it "evals plugins.rb once" do
expect do
- Plugin.hook(Bundler::Plugin::Events::EVENT_1)
- Plugin.hook(Bundler::Plugin::Events::EVENT_2)
end.to output("loaded\n").to_stdout
end
end
context "a block is passed" do
let(:code) { <<-RUBY }
- Bundler::Plugin::API.hook(Bundler::Plugin::Events::EVENT_1) { |&blk| blk.call }
RUBY
it "is passed to the hook" do
expect do
- Plugin.hook(Bundler::Plugin::Events::EVENT_1) { puts "win" }
end.to output("win\n").to_stdout
end
end
@@ -466,11 +466,9 @@ RSpec.describe "bundle install with platform conditionals" do
it "does not attempt to install gems from other rubies when using --local" do
bundle "config set --local force_ruby_platform true"
- other_ruby_version_tag = RUBY_VERSION =~ /^1\.8/ ? :ruby_19 : :ruby_18
-
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
- gem "some_gem", platform: :#{other_ruby_version_tag}
G
bundle "install --local"
Binary files differBinary files differ
@@ -1191,7 +1191,7 @@ Also, a list:
# Is this test being run on a ruby/ruby repository?
#
- def testing_ruby_repo?
!ENV["GEM_COMMAND"].nil?
end
@@ -188,7 +188,6 @@ Added '/CN=alternate/DC=example'
@build_ui = Gem::MockGemUi.new "#{passphrase}\n#{passphrase}"
use_ui @build_ui do
-
e = assert_raise Gem::CommandLineError do
@cmd.execute
end
@@ -266,7 +265,6 @@ Added '/CN=alternate/DC=example'
assert_equal "Passphrase and passphrase confirmation don't match",
e.message
-
end
assert_path_not_exist File.join(@tempdir, 'gem-private_key.pem')
@@ -161,7 +161,6 @@ class TestGemCommandsSourcesCommand < Gem::TestCase
ui = Gem::MockGemUi.new("n")
use_ui ui do
-
assert_raise Gem::MockGemUi::TermError do
@cmd.execute
end
@@ -202,6 +201,56 @@ Error fetching http://beta-gems.example.com:
assert_equal '', @ui.error
end
def test_execute_add_redundant_source
spec_fetcher
@@ -1,4 +1,5 @@
# frozen_string_literal: true
require_relative 'helper'
require 'rubygems/ext'
@@ -7,12 +8,9 @@ class TestGemExtCargoBuilder < Gem::TestCase
super
@rust_envs = {
- 'CARGO_HOME' => File.join(@orig_env['HOME'], '.cargo'),
- 'RUSTUP_HOME' => File.join(@orig_env['HOME'], '.rustup'),
}
-
- system(@rust_envs, 'cargo', '-V', out: IO::NULL, err: [:child, :out])
- pend 'cargo not present' unless $?.success?
end
def setup_rust_gem(name)
@@ -57,15 +55,35 @@ class TestGemExtCargoBuilder < Gem::TestCase
end
output = output.join "\n"
-
bundle = File.join(@dest_path, "release/rust_ruby_example.#{RbConfig::CONFIG['DLEXT']}")
- require(bundle)
- assert_match RustRubyExample.reverse('hello'), 'olleh'
- assert_match "Compiling rust_ruby_example v0.1.0", output
- assert_match "Finished release [optimized] target(s)", output
rescue Exception => e
pp output if output
@@ -98,21 +116,23 @@ class TestGemExtCargoBuilder < Gem::TestCase
skip_unsupported_platforms!
setup_rust_gem "rust_ruby_example"
Dir.chdir @ext do
require 'tmpdir'
- gem = [@rust_envs, *ruby_with_rubygems_in_load_path, File.expand_path('../../bin/gem', __dir__)]
Dir.mktmpdir("rust_ruby_example") do |dir|
built_gem = File.expand_path(File.join(dir, "rust_ruby_example.gem"))
Open3.capture2e(*gem, "build", "rust_ruby_example.gemspec", "--output", built_gem)
Open3.capture2e(*gem, "install", "--verbose", "--local", built_gem, *ARGV)
- end
- stdout_and_stderr_str, status = Open3.capture2e(@rust_envs, *ruby_with_rubygems_in_load_path, "-rrust_ruby_example", "-e", "puts 'Result: ' + RustRubyExample.reverse('hello world')")
-
- assert status.success?, stdout_and_stderr_str
- assert_match "Result: #{"hello world".reverse}", stdout_and_stderr_str
end
end
@@ -123,7 +143,8 @@ class TestGemExtCargoBuilder < Gem::TestCase
Dir.chdir @ext do
require 'tmpdir'
- gem = [@rust_envs, *ruby_with_rubygems_in_load_path, File.expand_path('../../bin/gem', __dir__)]
Dir.mktmpdir("custom_name") do |dir|
built_gem = File.expand_path(File.join(dir, "custom_name.gem"))
@@ -131,17 +152,27 @@ class TestGemExtCargoBuilder < Gem::TestCase
Open3.capture2e(*gem, "install", "--verbose", "--local", built_gem, *ARGV)
end
- stdout_and_stderr_str, status = Open3.capture2e(@rust_envs, *ruby_with_rubygems_in_load_path, "-rcustom_name", "-e", "puts 'Result: ' + CustomName.say_hello")
assert status.success?, stdout_and_stderr_str
assert_match "Result: Hello world!", stdout_and_stderr_str
end
end
def skip_unsupported_platforms!
pend "jruby not supported" if java_platform?
pend "truffleruby not supported (yet)" if RUBY_ENGINE == 'truffleruby'
pend "mswin not supported (yet)" if /mswin/ =~ RUBY_PLATFORM && ENV.key?('_ACTIONS')
- pend "ruby.h is not provided by ruby repo" if testing_ruby_repo?
end
end
@@ -83,9 +83,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clang-sys"
-version = "1.3.1"
source = "registry+https://.com/rust-lang/crates.io-index"
-checksum = "4cc00842eed744b858222c4c9faf7243aafc6d33f92f96935263ef4d8a41ce21"
dependencies = [
"glob",
"libc",
@@ -193,18 +193,18 @@ dependencies = [
[[package]]
name = "log"
-version = "0.4.14"
source = "registry+https://.com/rust-lang/crates.io-index"
-checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
dependencies = [
"cfg-if",
]
[[package]]
name = "memchr"
-version = "2.4.1"
source = "registry+https://.com/rust-lang/crates.io-index"
-checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
[[package]]
name = "minimal-lexical"
@@ -214,13 +214,12 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "nom"
-version = "7.1.0"
source = "registry+https://.com/rust-lang/crates.io-index"
-checksum = "1b1d11e1ef389c76fe5b81bcaf2ea32cf88b62bc494e19f493d0b30e7a930109"
dependencies = [
"memchr",
"minimal-lexical",
- "version_check",
]
[[package]]
@@ -231,37 +230,37 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
[[package]]
name = "pkg-config"
-version = "0.3.24"
source = "registry+https://.com/rust-lang/crates.io-index"
-checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe"
[[package]]
name = "proc-macro2"
-version = "1.0.36"
source = "registry+https://.com/rust-lang/crates.io-index"
-checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"
dependencies = [
- "unicode-xid",
]
[[package]]
name = "quote"
-version = "1.0.15"
source = "registry+https://.com/rust-lang/crates.io-index"
-checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rb-sys"
-version = "0.9.0"
-source = "git+https://.com/ianks/rb-sys?tag=v0.9.0#e4f00b9761af818d069a35d3802afdb15f5da5c3"
dependencies = [
"bindgen",
"cc",
"lazy_static",
- "libc",
"linkify",
"pkg-config",
"shell-words",
@@ -269,9 +268,9 @@ dependencies = [
[[package]]
name = "regex"
-version = "1.5.5"
source = "registry+https://.com/rust-lang/crates.io-index"
-checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286"
dependencies = [
"aho-corasick",
"memchr",
@@ -280,9 +279,9 @@ dependencies = [
[[package]]
name = "regex-syntax"
-version = "0.6.25"
source = "registry+https://.com/rust-lang/crates.io-index"
-checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
[[package]]
name = "rustc-hash"
@@ -327,16 +326,16 @@ dependencies = [
]
[[package]]
-name = "unicode-width"
-version = "0.1.9"
source = "registry+https://.com/rust-lang/crates.io-index"
-checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
[[package]]
-name = "unicode-xid"
-version = "0.2.2"
source = "registry+https://.com/rust-lang/crates.io-index"
-checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
[[package]]
name = "vec_map"
@@ -345,16 +344,10 @@ source = "registry+https://.com/rust-lang/crates.io-index"
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]]
-name = "version_check"
-version = "0.9.4"
-source = "registry+https://.com/rust-lang/crates.io-index"
-checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
-
-[[package]]
name = "which"
-version = "4.2.4"
source = "registry+https://.com/rust-lang/crates.io-index"
-checksum = "2a5a7e487e921cf220206864a94a89b6c6905bfc19f1057fa26a4cb360e5c1d2"
dependencies = [
"either",
"lazy_static",
@@ -6,5 +6,4 @@ version = "0.1.0"
crate-type = ["cdylib"]
[dependencies]
-# Needed until bindgen has the `allowlist_file` feature
-rb-sys = { git = "https://.com/ianks/rb-sys", tag = "v0.9.0" }
@@ -15,7 +15,7 @@ gemspec = File.expand_path('custom_name.gemspec', __dir__)
Dir.mktmpdir("custom_name") do |dir|
built_gem = File.expand_path(File.join(dir, "custom_name.gem"))
- system(*gem, "build", gemspec, "--output", built_gem)
- system(*gem, "install", "--verbose", "--local", built_gem, *ARGV)
system %q(ruby -rcustom_name -e "puts 'Result: ' + CustomName.say_hello")
end
@@ -83,9 +83,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clang-sys"
-version = "1.3.1"
source = "registry+https://.com/rust-lang/crates.io-index"
-checksum = "4cc00842eed744b858222c4c9faf7243aafc6d33f92f96935263ef4d8a41ce21"
dependencies = [
"glob",
"libc",
@@ -186,18 +186,18 @@ dependencies = [
[[package]]
name = "log"
-version = "0.4.14"
source = "registry+https://.com/rust-lang/crates.io-index"
-checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
dependencies = [
"cfg-if",
]
[[package]]
name = "memchr"
-version = "2.4.1"
source = "registry+https://.com/rust-lang/crates.io-index"
-checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
[[package]]
name = "minimal-lexical"
@@ -207,13 +207,12 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "nom"
-version = "7.1.0"
source = "registry+https://.com/rust-lang/crates.io-index"
-checksum = "1b1d11e1ef389c76fe5b81bcaf2ea32cf88b62bc494e19f493d0b30e7a930109"
dependencies = [
"memchr",
"minimal-lexical",
- "version_check",
]
[[package]]
@@ -224,37 +223,37 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
[[package]]
name = "pkg-config"
-version = "0.3.24"
source = "registry+https://.com/rust-lang/crates.io-index"
-checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe"
[[package]]
name = "proc-macro2"
-version = "1.0.36"
source = "registry+https://.com/rust-lang/crates.io-index"
-checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"
dependencies = [
- "unicode-xid",
]
[[package]]
name = "quote"
-version = "1.0.15"
source = "registry+https://.com/rust-lang/crates.io-index"
-checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rb-sys"
-version = "0.9.0"
-source = "git+https://.com/ianks/rb-sys?tag=v0.9.0#e4f00b9761af818d069a35d3802afdb15f5da5c3"
dependencies = [
"bindgen",
"cc",
"lazy_static",
- "libc",
"linkify",
"pkg-config",
"shell-words",
@@ -262,9 +261,9 @@ dependencies = [
[[package]]
name = "regex"
-version = "1.5.5"
source = "registry+https://.com/rust-lang/crates.io-index"
-checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286"
dependencies = [
"aho-corasick",
"memchr",
@@ -273,9 +272,9 @@ dependencies = [
[[package]]
name = "regex-syntax"
-version = "0.6.25"
source = "registry+https://.com/rust-lang/crates.io-index"
-checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
[[package]]
name = "rust_ruby_example"
@@ -327,16 +326,16 @@ dependencies = [
]
[[package]]
-name = "unicode-width"
-version = "0.1.9"
source = "registry+https://.com/rust-lang/crates.io-index"
-checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
[[package]]
-name = "unicode-xid"
-version = "0.2.2"
source = "registry+https://.com/rust-lang/crates.io-index"
-checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
[[package]]
name = "vec_map"
@@ -345,16 +344,10 @@ source = "registry+https://.com/rust-lang/crates.io-index"
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]]
-name = "version_check"
-version = "0.9.4"
-source = "registry+https://.com/rust-lang/crates.io-index"
-checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
-
-[[package]]
name = "which"
-version = "4.2.4"
source = "registry+https://.com/rust-lang/crates.io-index"
-checksum = "2a5a7e487e921cf220206864a94a89b6c6905bfc19f1057fa26a4cb360e5c1d2"
dependencies = [
"either",
"lazy_static",
@@ -6,5 +6,4 @@ version = "0.1.0"
crate-type = ["cdylib"]
[dependencies]
-# Needed until bindgen has the `allowlist_file` feature
-rb-sys = { git = "https://.com/ianks/rb-sys", tag = "v0.9.0" }
@@ -0,0 +1,33 @@
@@ -0,0 +1,75 @@
@@ -50,7 +50,6 @@ class TestGemExtExtConfBuilder < Gem::TestCase
end
configure_args do
-
File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf|
extconf.puts "require 'mkmf'\ncreate_makefile 'foo'"
end
@@ -758,13 +758,11 @@ end
with_engine_version 'jruby', '1.7.6' do
assert @gda.ruby RUBY_VERSION,
:engine => 'jruby', :engine_version => '1.7.6'
-
end
with_engine_version 'truffleruby', '1.0.0-rc11' do
assert @gda.ruby RUBY_VERSION,
:engine => 'truffleruby', :engine_version => '1.0.0-rc11'
-
end
end
@@ -1068,7 +1068,15 @@ dependencies: []
end
def test_handles_private_null_type
- path = File.expand_path 'data/null-type.gemspec.rz', __dir__
data = Marshal.load Gem::Util.inflate(Gem.read_binary(path))
@@ -3006,7 +3014,6 @@ Please report a bug if this causes problems.
@a1.homepage = 'https://rubygems.org'
assert_equal true, @a1.validate
-
end
end
@@ -444,7 +444,7 @@ class TestGemRequire < Gem::TestCase
end
def test_realworld_default_gem
- omit "this test can't work under ruby-core setup" if testing_ruby_repo?
cmd = <<-RUBY
$stderr = $stdout
@@ -457,7 +457,7 @@ class TestGemRequire < Gem::TestCase
end
def test_realworld_upgraded_default_gem
- omit "this test can't work under ruby-core setup" if testing_ruby_repo?
newer_json = util_spec("json", "999.99.9", nil, ["lib/json.rb"])
install_gem newer_json
@@ -6,11 +6,6 @@ gem "rdoc", "6.2.0" # 6.2.1 is required > Ruby 2.3
gem "test-unit", "~> 3.0"
gem "rake", "~> 13.0"
-group :lint do
- gem "rubocop", "~> 0.80.1"
- gem "rubocop-performance", "~> 1.5.2"
-end
-
gem "webrick", "~> 1.6"
gem "parallel_tests", "~> 2.29"
gem "parallel", "1.19.2" # 1.20+ is required > Ruby 2.3
@@ -1,23 +1,16 @@
GEM
remote: https://rubygems.org/
specs:
- ast (2.4.2)
diff-lcs (1.5.0)
hpricot (0.8.6)
- jaro_winkler (1.5.4)
- jaro_winkler (1.5.4-java)
mustache (1.1.1)
parallel (1.19.2)
parallel_tests (2.32.0)
parallel
- parser (3.1.0.0)
- ast (~> 2.4.1)
power_assert (2.0.1)
- rainbow (3.1.1)
rake (13.0.6)
rdiscount (2.2.0.2)
rdoc (6.2.0)
- rexml (3.2.5)
ronn (0.7.3)
hpricot (>= 0.8.2)
mustache (>= 0.7.0)
@@ -31,20 +24,8 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-support (3.11.0)
- rubocop (0.80.1)
- jaro_winkler (~> 1.5.1)
- parallel (~> 1.10)
- parser (>= 2.7.0.1)
- rainbow (>= 2.2.2, < 4.0)
- rexml
- ruby-progressbar (~> 1.7)
- unicode-display_width (>= 1.4.0, < 1.7)
- rubocop-performance (1.5.2)
- rubocop (>= 0.71.0)
- ruby-progressbar (1.11.0)
test-unit (3.5.3)
power_assert
- unicode-display_width (1.6.1)
uri (0.10.1)
webrick (1.7.0)
@@ -65,8 +46,6 @@ DEPENDENCIES
rspec-core (~> 3.8)
rspec-expectations (~> 3.8)
rspec-mocks (~> 3.11.1)
- rubocop (~> 0.80.1)
- rubocop-performance (~> 1.5.2)
test-unit (~> 3.0)
uri (~> 0.10.1)
webrick (~> 1.6)