mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Sync RubyGems & Bundler with upstream repo
This commit is contained in:
parent
333754ace8
commit
12a5fa408b
Notes:
git
2022-06-24 10:52:35 +09:00
47 changed files with 533 additions and 337 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
|
||||
@resolve ||= 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
|
||||
|
||||
|
@ -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
|
||||
@metadata_dependencies ||= [
|
||||
Dependency.new("Ruby\0", RubyVersion.system.gem_version),
|
||||
Dependency.new("RubyGems\0", Gem::VERSION),
|
||||
]
|
||||
end
|
||||
|
||||
def expand_dependencies(dependencies, remote = false)
|
||||
|
|
|
@ -9,6 +9,7 @@ module Bundler
|
|||
attr_reader :autorequire
|
||||
attr_reader :groups, :platforms, :gemfile, :git, :github, :branch, :ref
|
||||
|
||||
# rubocop:disable Naming/VariableNumber
|
||||
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
|
||||
# rubocop:enable Naming/VariableNumber
|
||||
|
||||
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
|
||||
@contents ||= dsl_path && File.exist?(dsl_path) && File.read(dsl_path)
|
||||
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
|
||||
@fetch_uri ||= if remote_uri.host == "rubygems.org"
|
||||
uri = remote_uri.dup
|
||||
uri.host = "index.rubygems.org"
|
||||
uri
|
||||
else
|
||||
remote_uri
|
||||
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.
|
||||
# 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.
|
||||
# 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.
|
||||
# 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
|
||||
@amount_constrained[dependency.name] ||= 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
|
||||
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
|
||||
|
|
|
@ -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
|
||||
@cache_path ||= 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
|
||||
|
||||
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}"
|
||||
msg = "Unable to pull data from '#{Gem::Uri.redact(x.source.uri)}': #{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}"
|
||||
say "Error fetching #{Gem::Uri.redact(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
|
||||
module_eval <<'RUBY', file, __LINE__ + 1 # rubocop:disable Style/EvalWithLocation
|
||||
##
|
||||
# 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}"
|
||||
"Unable to download data from #{Gem::Uri.redact(@source.uri)} - #{@error.message}"
|
||||
end
|
||||
|
||||
##
|
||||
|
|
|
@ -55,7 +55,7 @@ class Gem::Ext::Builder
|
|||
end
|
||||
end
|
||||
|
||||
def self.run(command, results, command_name = nil, dir = Dir.pwd)
|
||||
def self.run(command, results, command_name = nil, dir = Dir.pwd, env = {})
|
||||
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 }
|
||||
build_env = { 'SOURCE_DATE_EPOCH' => Gem.source_date_epoch_string }.merge(env)
|
||||
output, status = begin
|
||||
Open3.capture2e(env, *command, :chdir => dir)
|
||||
Open3.capture2e(build_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
|
||||
attr_accessor :spec, :runner, :profile
|
||||
|
||||
def initialize(spec)
|
||||
require_relative "../command"
|
||||
require_relative "cargo_builder/link_flag_converter"
|
||||
|
||||
@spec = spec
|
||||
@runner = self.class.method(:run)
|
||||
@profile = :release
|
||||
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)
|
||||
validate_cargo_build!(dest_path)
|
||||
rename_cdylib_for_ruby_compatibility(dest_path)
|
||||
finalize_directory(dest_path, lib_dir, cargo_dir)
|
||||
results
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def build_crate(dest_path, results, args, cargo_dir)
|
||||
env = build_env
|
||||
cmd = cargo_command(cargo_dir, dest_path, args)
|
||||
runner.call cmd, results, 'cargo', cargo_dir, env
|
||||
|
||||
results
|
||||
end
|
||||
|
||||
def build_env
|
||||
build_env = rb_config_env
|
||||
build_env["RUBY_STATIC"] = "true" if ruby_static? && ENV.key?('RUBY_STATIC')
|
||||
build_env
|
||||
end
|
||||
|
||||
def cargo_command(cargo_dir, dest_path, args = [])
|
||||
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", ENV['CARGO_BUILD_TARGET']] if ENV['CARGO_BUILD_TARGET']
|
||||
cmd += ["--target-dir", dest_path]
|
||||
cmd += ["--manifest-path", manifest]
|
||||
cmd += ["--lib", "--release", "--locked"]
|
||||
cmd += ["--"]
|
||||
cmd += [*cargo_rustc_args(dest_path)]
|
||||
cmd += ["--lib"]
|
||||
cmd += ["--profile", profile.to_s]
|
||||
cmd += ["--locked"] if profile == :release
|
||||
cmd += Gem::Command.build_args
|
||||
cmd += args
|
||||
cmd += ["--"]
|
||||
cmd += [*cargo_rustc_args(dest_path)]
|
||||
cmd
|
||||
end
|
||||
|
||||
self.class.run cmd, results, self.class.class_name, cargo_dir
|
||||
results
|
||||
ensure
|
||||
ENV["RUBY_STATIC"] = given_ruby_static
|
||||
private
|
||||
|
||||
def rb_config_env
|
||||
result = {}
|
||||
RbConfig::CONFIG.each {|k, v| result["RBCONFIG_#{k}"] = v }
|
||||
result
|
||||
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) }
|
||||
raw_libs.flat_map {|l| ldflag_to_link_modifier(l) }
|
||||
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
|
||||
new_path = final_extension_path(dest_path)
|
||||
FileUtils.cp(cargo_dylib_path(dest_path), new_path)
|
||||
new_path
|
||||
end
|
||||
|
||||
def validate_cargo_build!(dir)
|
||||
prefix = so_ext == "dll" ? "" : "lib"
|
||||
dylib_path = File.join(dir, "release", "#{prefix}#{cargo_crate_name}.#{so_ext}")
|
||||
dylib_path = cargo_dylib_path(dir)
|
||||
|
||||
raise DylibNotFoundError, dir unless File.exist?(dylib_path)
|
||||
|
||||
dylib_path
|
||||
end
|
||||
|
||||
def final_extension_path(dest_path)
|
||||
dylib_path = cargo_dylib_path(dest_path)
|
||||
dlext_name = "#{spec.name}.#{makefile_config("DLEXT")}"
|
||||
dylib_path.gsub(File.basename(dylib_path), dlext_name)
|
||||
end
|
||||
|
||||
def cargo_dylib_path(dest_path)
|
||||
prefix = so_ext == "dll" ? "" : "lib"
|
||||
path_parts = [dest_path]
|
||||
path_parts << ENV['CARGO_BUILD_TARGET'] if ENV['CARGO_BUILD_TARGET']
|
||||
path_parts += [profile_target_directory, "#{prefix}#{cargo_crate_name}.#{so_ext}"]
|
||||
File.join(*path_parts)
|
||||
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) }
|
||||
.flat_map {|arg| ldflag_to_link_modifier(arg) }
|
||||
end
|
||||
|
||||
def rustc_lib_flags(dest_dir)
|
||||
split_flags("LIBS").flat_map {|arg| ldflag_to_link_modifier(arg, dest_dir) }
|
||||
split_flags("LIBS").flat_map {|arg| ldflag_to_link_modifier(arg) }
|
||||
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://github.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
|
||||
def ldflag_to_link_modifier(arg)
|
||||
LinkFlagConverter.convert(arg)
|
||||
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))
|
||||
# Interpolate 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
|
||||
var_matches = input_arg.match(/\$\((\w+)\)/)
|
||||
|
||||
str == "" ? nil : str
|
||||
return input_arg unless var_matches
|
||||
|
||||
var_name = var_matches[1]
|
||||
|
||||
return input_arg if var_name.nil? || var_name.chomp.empty?
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
return [] if profile == :dev
|
||||
|
||||
["-C", "debuginfo=1"]
|
||||
end
|
||||
|
||||
# Copied from ExtConfBuilder
|
||||
def finalize_directory(ext_path, dest_path, lib_dir, extension_dir)
|
||||
def finalize_directory(dest_path, lib_dir, extension_dir)
|
||||
require "fileutils"
|
||||
require "tempfile"
|
||||
|
||||
ext_path = final_extension_path(dest_path)
|
||||
|
||||
begin
|
||||
tmp_dest = Dir.mktmpdir(".gem.", extension_dir)
|
||||
|
||||
|
@ -280,6 +295,14 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder
|
|||
path
|
||||
end
|
||||
|
||||
def profile_target_directory
|
||||
case profile
|
||||
when :release then 'release'
|
||||
when :dev then 'debug'
|
||||
else raise "unknown target directory for profile: #{profile}"
|
||||
end
|
||||
end
|
||||
|
||||
# Error raised when no cdylib artifact was created
|
||||
class DylibNotFoundError < StandardError
|
||||
def initialize(dir)
|
||||
|
|
23
lib/rubygems/ext/cargo_builder/link_flag_converter.rb
Normal file
23
lib/rubygems/ext/cargo_builder/link_flag_converter.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Gem::Ext::CargoBuilder < Gem::Ext::Builder
|
||||
# Converts Ruby link flags into something cargo understands
|
||||
class LinkFlagConverter
|
||||
def self.convert(arg)
|
||||
case arg.chomp
|
||||
when /^-L\s*(.+)$/
|
||||
["-L", "native=#{$1}"]
|
||||
when /^--library=(\w+\S+)$/, /^-l\s*(\w+\S+)$/
|
||||
["-l", $1]
|
||||
when /^-l\s*:lib(\S+).a$/
|
||||
["-l", "static=#{$1}"]
|
||||
when /^-l\s*:lib(\S+).(so|dylib|dll)$/
|
||||
["-l", "dylib=#{$1}"]
|
||||
when /^-F\s*(.*)$/
|
||||
["-l", "framework=#{$1}"]
|
||||
else
|
||||
["-C", "link_arg=#{arg}"]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -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}"
|
||||
verbose "#{request.method} #{Gem::Uri.redact(@uri)}"
|
||||
|
||||
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
|
||||
require_relative "uri"
|
||||
@uri = Gem::Uri.parse!(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
|
||||
|
||||
require_relative "../uri"
|
||||
@uri = Gem::Uri.parse(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))
|
||||
Gem::Source.new(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")
|
||||
#
|
||||
# Some very old marshaled specs included references to `YAML::PrivateType`
|
||||
# and `YAML::Syck::DefaultKey` constants due to bugs in the old emitter
|
||||
# that generated them. Workaround the issue by defining the necessary
|
||||
# constants and retrying.
|
||||
#
|
||||
message = e.message
|
||||
raise unless message.include?("YAML::")
|
||||
|
||||
Object.const_set "YAML", Psych
|
||||
Marshal.load str
|
||||
Object.const_set "YAML", Psych unless Object.const_defined?(:YAML)
|
||||
|
||||
if message.include?("YAML::Syck::")
|
||||
YAML.const_set "Syck", YAML unless YAML.const_defined?(:Syck)
|
||||
|
||||
YAML::Syck.const_set "DefaultKey", Class.new if message.include?("YAML::Syck::DefaultKey")
|
||||
elsif message.include?("YAML::PrivateType")
|
||||
YAML.const_set "PrivateType", Class.new
|
||||
end
|
||||
|
||||
retry
|
||||
end
|
||||
|
||||
spec = Gem::Specification.new
|
||||
|
|
|
@ -5,6 +5,44 @@
|
|||
#
|
||||
|
||||
class Gem::Uri
|
||||
##
|
||||
# Parses and redacts uri
|
||||
|
||||
def self.redact(uri)
|
||||
new(uri).redacted
|
||||
end
|
||||
|
||||
##
|
||||
# Parses uri, raising if it's invalid
|
||||
|
||||
def self.parse!(uri)
|
||||
require "uri"
|
||||
|
||||
raise URI::InvalidURIError unless uri
|
||||
|
||||
return uri unless uri.is_a?(String)
|
||||
|
||||
# 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 uri, returning the original uri if it's invalid
|
||||
|
||||
def self.parse(uri)
|
||||
parse!(uri)
|
||||
rescue URI::InvalidURIError
|
||||
uri
|
||||
end
|
||||
|
||||
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?
|
||||
return text unless valid_uri? && password? && text.include?(to_s)
|
||||
|
||||
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
|
||||
self.class.parse!(uri)
|
||||
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
|
||||
self.class.parse(uri)
|
||||
end
|
||||
|
||||
def with_redacted_user
|
||||
|
|
|
@ -137,6 +137,7 @@ RSpec.describe Bundler::Dsl do
|
|||
end
|
||||
|
||||
describe "#gem" do
|
||||
# rubocop:disable Naming/VariableNumber
|
||||
[: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
|
||||
# rubocop:enable Naming/VariableNumber
|
||||
|
||||
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")
|
||||
Bundler::Plugin::Events.send(:define, :EVENT1, "event-1")
|
||||
Bundler::Plugin::Events.send(:define, :EVENT2, "event-2")
|
||||
|
||||
allow(index).to receive(:hook_plugins).with(Bundler::Plugin::Events::EVENT_1).
|
||||
allow(index).to receive(:hook_plugins).with(Bundler::Plugin::Events::EVENT1).
|
||||
and_return(["foo-plugin", "", nil])
|
||||
allow(index).to receive(:hook_plugins).with(Bundler::Plugin::Events::EVENT_2).
|
||||
allow(index).to receive(:hook_plugins).with(Bundler::Plugin::Events::EVENT2).
|
||||
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)
|
||||
Plugin.hook(Bundler::Plugin::Events::EVENT1)
|
||||
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) {}
|
||||
Bundler::Plugin::API.hook(Bundler::Plugin::Events::EVENT1) {}
|
||||
Bundler::Plugin::API.hook(Bundler::Plugin::Events::EVENT2) {}
|
||||
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)
|
||||
Plugin.hook(Bundler::Plugin::Events::EVENT1)
|
||||
Plugin.hook(Bundler::Plugin::Events::EVENT2)
|
||||
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 }
|
||||
Bundler::Plugin::API.hook(Bundler::Plugin::Events::EVENT1) { |&blk| blk.call }
|
||||
RUBY
|
||||
|
||||
it "is passed to the hook" do
|
||||
expect do
|
||||
Plugin.hook(Bundler::Plugin::Events::EVENT_1) { puts "win" }
|
||||
Plugin.hook(Bundler::Plugin::Events::EVENT1) { 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}
|
||||
gem "some_gem", platform: :ruby_22
|
||||
G
|
||||
|
||||
bundle "install --local"
|
||||
|
|
BIN
test/rubygems/data/excon-0.7.7.gemspec.rz
Normal file
BIN
test/rubygems/data/excon-0.7.7.gemspec.rz
Normal file
Binary file not shown.
|
@ -1191,7 +1191,7 @@ Also, a list:
|
|||
# Is this test being run on a ruby/ruby repository?
|
||||
#
|
||||
|
||||
def testing_ruby_repo?
|
||||
def 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_existent_source_invalid_uri
|
||||
spec_fetcher
|
||||
|
||||
uri = "https://u:p@example.com/specs.#{@marshal_version}.gz"
|
||||
|
||||
@cmd.handle_options %w[--add https://u:p@example.com]
|
||||
@fetcher.data[uri] = proc do
|
||||
raise Gem::RemoteFetcher::FetchError.new('it died', uri)
|
||||
end
|
||||
|
||||
use_ui @ui do
|
||||
assert_raise Gem::MockGemUi::TermError do
|
||||
@cmd.execute
|
||||
end
|
||||
end
|
||||
|
||||
expected = <<-EOF
|
||||
Error fetching https://u:REDACTED@example.com:
|
||||
\tit died (https://u:REDACTED@example.com/specs.#{@marshal_version}.gz)
|
||||
EOF
|
||||
|
||||
assert_equal expected, @ui.output
|
||||
assert_equal '', @ui.error
|
||||
end
|
||||
|
||||
def test_execute_add_existent_source_invalid_uri_with_error_by_chance_including_the_uri_password
|
||||
spec_fetcher
|
||||
|
||||
uri = "https://u:secret@example.com/specs.#{@marshal_version}.gz"
|
||||
|
||||
@cmd.handle_options %w[--add https://u:secret@example.com]
|
||||
@fetcher.data[uri] = proc do
|
||||
raise Gem::RemoteFetcher::FetchError.new('it secretly died', uri)
|
||||
end
|
||||
|
||||
use_ui @ui do
|
||||
assert_raise Gem::MockGemUi::TermError do
|
||||
@cmd.execute
|
||||
end
|
||||
end
|
||||
|
||||
expected = <<-EOF
|
||||
Error fetching https://u:REDACTED@example.com:
|
||||
\tit secretly died (https://u:REDACTED@example.com/specs.#{@marshal_version}.gz)
|
||||
EOF
|
||||
|
||||
assert_equal expected, @ui.output
|
||||
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'),
|
||||
'CARGO_HOME' => ENV.fetch('CARGO_HOME', File.join(@orig_env['HOME'], '.cargo')),
|
||||
'RUSTUP_HOME' => ENV.fetch('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
|
||||
assert_ffi_handle bundle, 'Init_rust_ruby_example'
|
||||
rescue Exception => e
|
||||
pp output if output
|
||||
|
||||
raise(e)
|
||||
end
|
||||
|
||||
def test_build_dev_profile
|
||||
skip_unsupported_platforms!
|
||||
setup_rust_gem "rust_ruby_example"
|
||||
|
||||
output = []
|
||||
|
||||
Dir.chdir @ext do
|
||||
ENV.update(@rust_envs)
|
||||
spec = Gem::Specification.new 'rust_ruby_example', '0.1.0'
|
||||
builder = Gem::Ext::CargoBuilder.new(spec)
|
||||
builder.profile = :dev
|
||||
builder.build nil, @dest_path, output
|
||||
end
|
||||
|
||||
output = output.join "\n"
|
||||
bundle = File.join(@dest_path, "debug/rust_ruby_example.#{RbConfig::CONFIG['DLEXT']}")
|
||||
|
||||
assert_match "Finished dev [unoptimized + debuginfo] target(s)", output
|
||||
assert_ffi_handle bundle, 'Init_rust_ruby_example'
|
||||
rescue Exception => e
|
||||
pp output if output
|
||||
|
||||
|
@ -98,21 +116,23 @@ class TestGemExtCargoBuilder < Gem::TestCase
|
|||
skip_unsupported_platforms!
|
||||
setup_rust_gem "rust_ruby_example"
|
||||
|
||||
require 'open3'
|
||||
|
||||
Dir.chdir @ext do
|
||||
require 'tmpdir'
|
||||
|
||||
gem = [@rust_envs, *ruby_with_rubygems_in_load_path, File.expand_path('../../bin/gem', __dir__)]
|
||||
env_for_subprocess = @rust_envs.merge("GEM_HOME" => Gem.paths.home)
|
||||
gem = [env_for_subprocess, *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)
|
||||
|
||||
stdout_and_stderr_str, status = Open3.capture2e(env_for_subprocess, *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
|
||||
|
||||
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__)]
|
||||
env_for_subprocess = @rust_envs.merge("GEM_HOME" => Gem.paths.home)
|
||||
gem = [env_for_subprocess, *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")
|
||||
stdout_and_stderr_str, status = Open3.capture2e(env_for_subprocess, *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
|
||||
|
||||
private
|
||||
|
||||
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?('GITHUB_ACTIONS')
|
||||
pend "ruby.h is not provided by ruby repo" if testing_ruby_repo?
|
||||
system(@rust_envs, 'cargo', '-V', out: IO::NULL, err: [:child, :out])
|
||||
pend 'cargo not present' unless $?.success?
|
||||
pend "ruby.h is not provided by ruby repo" if ruby_repo?
|
||||
end
|
||||
|
||||
def assert_ffi_handle(bundle, name)
|
||||
require 'fiddle'
|
||||
dylib_handle = Fiddle.dlopen bundle
|
||||
assert_nothing_raised { dylib_handle[name] }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -83,9 +83,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
|||
|
||||
[[package]]
|
||||
name = "clang-sys"
|
||||
version = "1.3.1"
|
||||
version = "1.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4cc00842eed744b858222c4c9faf7243aafc6d33f92f96935263ef4d8a41ce21"
|
||||
checksum = "5a050e2153c5be08febd6734e29298e844fdb0fa21aeddd63b4eb7baa106c69b"
|
||||
dependencies = [
|
||||
"glob",
|
||||
"libc",
|
||||
|
@ -193,18 +193,18 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.14"
|
||||
version = "0.4.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
|
||||
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.4.1"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
|
||||
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
||||
|
||||
[[package]]
|
||||
name = "minimal-lexical"
|
||||
|
@ -214,13 +214,12 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
|||
|
||||
[[package]]
|
||||
name = "nom"
|
||||
version = "7.1.0"
|
||||
version = "7.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b1d11e1ef389c76fe5b81bcaf2ea32cf88b62bc494e19f493d0b30e7a930109"
|
||||
checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"minimal-lexical",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -231,37 +230,37 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
|
|||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.24"
|
||||
version = "0.3.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe"
|
||||
checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.36"
|
||||
version = "1.0.39"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"
|
||||
checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f"
|
||||
dependencies = [
|
||||
"unicode-xid",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.15"
|
||||
version = "1.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145"
|
||||
checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rb-sys"
|
||||
version = "0.9.0"
|
||||
source = "git+https://github.com/ianks/rb-sys?tag=v0.9.0#e4f00b9761af818d069a35d3802afdb15f5da5c3"
|
||||
version = "0.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f5465c5bd695ef70959b91b4ca9cfd515e9af012f6d9f0ae46f09fa4bcc3b722"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"cc",
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"linkify",
|
||||
"pkg-config",
|
||||
"shell-words",
|
||||
|
@ -269,9 +268,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.5.5"
|
||||
version = "1.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286"
|
||||
checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
|
@ -280,9 +279,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.25"
|
||||
version = "0.6.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
|
||||
checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64"
|
||||
|
||||
[[package]]
|
||||
name = "rustc-hash"
|
||||
|
@ -326,35 +325,29 @@ dependencies = [
|
|||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
|
||||
|
||||
[[package]]
|
||||
name = "vec_map"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
||||
|
||||
[[package]]
|
||||
name = "which"
|
||||
version = "4.2.4"
|
||||
version = "4.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a5a7e487e921cf220206864a94a89b6c6905bfc19f1057fa26a4cb360e5c1d2"
|
||||
checksum = "5c4fb54e6113b6a8772ee41c3404fb0301ac79604489467e0a9ce1f3e97c24ae"
|
||||
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://github.com/ianks/rb-sys", tag = "v0.9.0" }
|
||||
rb-sys = "0.9.4"
|
||||
|
|
|
@ -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 *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"
|
||||
version = "1.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4cc00842eed744b858222c4c9faf7243aafc6d33f92f96935263ef4d8a41ce21"
|
||||
checksum = "5a050e2153c5be08febd6734e29298e844fdb0fa21aeddd63b4eb7baa106c69b"
|
||||
dependencies = [
|
||||
"glob",
|
||||
"libc",
|
||||
|
@ -186,18 +186,18 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.14"
|
||||
version = "0.4.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
|
||||
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.4.1"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
|
||||
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
||||
|
||||
[[package]]
|
||||
name = "minimal-lexical"
|
||||
|
@ -207,13 +207,12 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
|||
|
||||
[[package]]
|
||||
name = "nom"
|
||||
version = "7.1.0"
|
||||
version = "7.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b1d11e1ef389c76fe5b81bcaf2ea32cf88b62bc494e19f493d0b30e7a930109"
|
||||
checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"minimal-lexical",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -224,37 +223,37 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
|
|||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.24"
|
||||
version = "0.3.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe"
|
||||
checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.36"
|
||||
version = "1.0.39"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"
|
||||
checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f"
|
||||
dependencies = [
|
||||
"unicode-xid",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.15"
|
||||
version = "1.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145"
|
||||
checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rb-sys"
|
||||
version = "0.9.0"
|
||||
source = "git+https://github.com/ianks/rb-sys?tag=v0.9.0#e4f00b9761af818d069a35d3802afdb15f5da5c3"
|
||||
version = "0.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f5465c5bd695ef70959b91b4ca9cfd515e9af012f6d9f0ae46f09fa4bcc3b722"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"cc",
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"linkify",
|
||||
"pkg-config",
|
||||
"shell-words",
|
||||
|
@ -262,9 +261,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.5.5"
|
||||
version = "1.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286"
|
||||
checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
|
@ -273,9 +272,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.25"
|
||||
version = "0.6.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
|
||||
checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64"
|
||||
|
||||
[[package]]
|
||||
name = "rust_ruby_example"
|
||||
|
@ -326,35 +325,29 @@ dependencies = [
|
|||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
|
||||
|
||||
[[package]]
|
||||
name = "vec_map"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
||||
|
||||
[[package]]
|
||||
name = "which"
|
||||
version = "4.2.4"
|
||||
version = "4.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a5a7e487e921cf220206864a94a89b6c6905bfc19f1057fa26a4cb360e5c1d2"
|
||||
checksum = "5c4fb54e6113b6a8772ee41c3404fb0301ac79604489467e0a9ce1f3e97c24ae"
|
||||
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://github.com/ianks/rb-sys", tag = "v0.9.0" }
|
||||
rb-sys = "0.9.4"
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
# frozen_string_literal: true
|
||||
require_relative 'helper'
|
||||
require 'rubygems/ext'
|
||||
require 'rubygems/ext/cargo_builder/link_flag_converter'
|
||||
|
||||
class TestGemExtCargoBuilderLinkFlagConverter < Gem::TestCase
|
||||
CASES = {
|
||||
test_search_path_basic: ["-L/usr/local/lib", ["-L", "native=/usr/local/lib"]],
|
||||
test_search_path_space: ["-L /usr/local/lib", ["-L", "native=/usr/local/lib"]],
|
||||
test_search_path_space_in_path: ["-L/usr/local/my\ lib", ["-L", "native=/usr/local/my\ lib"]],
|
||||
test_simple_lib: ["-lfoo", ["-l", "foo"]],
|
||||
test_lib_with_nonascii: ["-lws2_32", ["-l", "ws2_32"]],
|
||||
test_simple_lib_space: ["-l foo", ["-l", "foo"]],
|
||||
test_verbose_lib_space: ["--library=foo", ["-l", "foo"]],
|
||||
test_libstatic_with_colon: ["-l:libssp.a", ["-l", "static=ssp"]],
|
||||
test_libstatic_with_colon_space: ["-l :libssp.a", ["-l", "static=ssp"]],
|
||||
test_unconventional_lib_with_colon: ["-l:ssp.a", ["-C", "link_arg=-l:ssp.a"]],
|
||||
test_dylib_with_colon_space: ["-l :libssp.dylib", ["-l", "dylib=ssp"]],
|
||||
test_so_with_colon_space: ["-l :libssp.so", ["-l", "dylib=ssp"]],
|
||||
test_dll_with_colon_space: ["-l :libssp.dll", ["-l", "dylib=ssp"]],
|
||||
test_framework: ["-F/some/path", ["-l", "framework=/some/path"]],
|
||||
test_framework_space: ["-F /some/path", ["-l", "framework=/some/path"]],
|
||||
test_non_lib_dash_l: ["test_rubygems_20220413-976-lemgf9/prefix", ["-C", "link_arg=test_rubygems_20220413-976-lemgf9/prefix"]],
|
||||
}.freeze
|
||||
|
||||
CASES.each do |test_name, (arg, expected)|
|
||||
raise "duplicate test name" if instance_methods.include?(test_name)
|
||||
|
||||
define_method(test_name) do
|
||||
assert_equal(expected, Gem::Ext::CargoBuilder::LinkFlagConverter.convert(arg))
|
||||
end
|
||||
end
|
||||
end
|
75
test/rubygems/test_gem_ext_cargo_builder_unit.rb
Normal file
75
test/rubygems/test_gem_ext_cargo_builder_unit.rb
Normal file
|
@ -0,0 +1,75 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require_relative 'helper'
|
||||
require 'rubygems/ext'
|
||||
|
||||
class TestGemExtCargoBuilderUnit < Gem::TestCase
|
||||
def test_cargo_command_passes_args
|
||||
skip_unsupported_platforms!
|
||||
spec = Gem::Specification.new 'rust_ruby_example', '0.1.0'
|
||||
builder = Gem::Ext::CargoBuilder.new(spec)
|
||||
command = builder.cargo_command(Dir.pwd, @tempdir, ['--all-features'])
|
||||
|
||||
assert_includes command, '--all-features'
|
||||
end
|
||||
|
||||
def test_cargo_command_locks_in_release_profile
|
||||
skip_unsupported_platforms!
|
||||
spec = Gem::Specification.new 'rust_ruby_example', '0.1.0'
|
||||
builder = Gem::Ext::CargoBuilder.new(spec)
|
||||
builder.profile = :release
|
||||
command = builder.cargo_command(Dir.pwd, @tempdir)
|
||||
|
||||
assert_includes command, '--locked'
|
||||
end
|
||||
|
||||
def test_cargo_command_does_not_lock_in_dev_profile
|
||||
skip_unsupported_platforms!
|
||||
spec = Gem::Specification.new 'rust_ruby_example', '0.1.0'
|
||||
builder = Gem::Ext::CargoBuilder.new(spec)
|
||||
builder.profile = :dev
|
||||
command = builder.cargo_command(Dir.pwd, @tempdir)
|
||||
|
||||
assert_not_includes command, '--locked'
|
||||
end
|
||||
|
||||
def test_cargo_command_passes_respects_cargo_env_var
|
||||
skip_unsupported_platforms!
|
||||
old_cargo = ENV['CARGO']
|
||||
ENV['CARGO'] = 'mycargo'
|
||||
spec = Gem::Specification.new 'rust_ruby_example', '0.1.0'
|
||||
builder = Gem::Ext::CargoBuilder.new(spec)
|
||||
command = builder.cargo_command(Dir.pwd, @tempdir)
|
||||
|
||||
assert_includes command, 'mycargo'
|
||||
ensure
|
||||
ENV['CARGO'] = old_cargo
|
||||
end
|
||||
|
||||
def test_build_env_includes_rbconfig
|
||||
skip_unsupported_platforms!
|
||||
spec = Gem::Specification.new 'rust_ruby_example', '0.1.0'
|
||||
builder = Gem::Ext::CargoBuilder.new(spec)
|
||||
env = builder.build_env
|
||||
|
||||
assert_equal env.fetch('RBCONFIG_RUBY_SO_NAME'), RbConfig::CONFIG['RUBY_SO_NAME']
|
||||
end
|
||||
|
||||
def test_cargo_command_passes_respects_cargo_build_target
|
||||
skip_unsupported_platforms!
|
||||
old_cargo = ENV['CARGO_BUILD_TARGET']
|
||||
ENV['CARGO_BUILD_TARGET'] = 'x86_64-unknown-linux-gnu'
|
||||
spec = Gem::Specification.new 'rust_ruby_example', '0.1.0'
|
||||
builder = Gem::Ext::CargoBuilder.new(spec)
|
||||
command = builder.cargo_command(Dir.pwd, @tempdir, ['--locked'])
|
||||
|
||||
assert_includes command, '--target'
|
||||
assert_includes command, 'x86_64-unknown-linux-gnu'
|
||||
ensure
|
||||
ENV['CARGO_BUILD_TARGET'] = old_cargo
|
||||
end
|
||||
|
||||
def skip_unsupported_platforms!
|
||||
pend "jruby not supported" if java_platform?
|
||||
end
|
||||
end
|
|
@ -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__
|
||||
path = File.expand_path 'data/pry-0.4.7.gemspec.rz', __dir__
|
||||
|
||||
data = Marshal.load Gem::Util.inflate(Gem.read_binary(path))
|
||||
|
||||
assert_instance_of Gem::Specification, data
|
||||
end
|
||||
|
||||
def test_handles_dependencies_with_syck_requirements_bug
|
||||
path = File.expand_path 'data/excon-0.7.7.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?
|
||||
omit "this test can't work under ruby-core setup" if 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?
|
||||
omit "this test can't work under ruby-core setup" if 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)
|
||||
|
|
Loading…
Add table
Reference in a new issue