[rubygems/rubygems] Fix gemspec require_paths
type validation
It was not properly being detected as an Array attribute, and thus not properly validated. Fixing this allows us to remove a strange `rescue` clause in Bundler. https://github.com/rubygems/rubygems/commit/4121a32408
This commit is contained in:
parent
95728a8b42
commit
86c99a8d14
@ -58,9 +58,6 @@ module Bundler
|
|||||||
else
|
else
|
||||||
SharedHelpers.relative_path_to(full_path, from: Bundler.root.join(bundler_path))
|
SharedHelpers.relative_path_to(full_path, from: Bundler.root.join(bundler_path))
|
||||||
end
|
end
|
||||||
rescue TypeError
|
|
||||||
error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
|
|
||||||
raise Gem::InvalidSpecificationException.new(error_message)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def prevent_gem_activation
|
def prevent_gem_activation
|
||||||
|
@ -60,6 +60,12 @@ module Gem
|
|||||||
FLATTENS_REQUIRED_PATHS = Specification.new.respond_to?(:flatten_require_paths).freeze
|
FLATTENS_REQUIRED_PATHS = Specification.new.respond_to?(:flatten_require_paths).freeze
|
||||||
|
|
||||||
class Specification
|
class Specification
|
||||||
|
# Can be removed once RubyGems 3.5.15 support is dropped
|
||||||
|
correct_array_attributes = @@default_value.select {|_k,v| v.is_a?(Array) }.keys
|
||||||
|
unless @@array_attributes == correct_array_attributes
|
||||||
|
@@array_attributes = correct_array_attributes # rubocop:disable Style/ClassVars
|
||||||
|
end
|
||||||
|
|
||||||
require_relative "match_metadata"
|
require_relative "match_metadata"
|
||||||
require_relative "match_platform"
|
require_relative "match_platform"
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|||||||
end
|
end
|
||||||
|
|
||||||
@@attributes = @@default_value.keys.sort_by(&:to_s)
|
@@attributes = @@default_value.keys.sort_by(&:to_s)
|
||||||
@@array_attributes = @@default_value.reject {|_k,v| v != [] }.keys
|
@@array_attributes = @@default_value.select {|_k,v| v.is_a?(Array) }.keys
|
||||||
@@nil_attributes, @@non_nil_attributes = @@default_value.keys.partition do |k|
|
@@nil_attributes, @@non_nil_attributes = @@default_value.keys.partition do |k|
|
||||||
@@default_value[k].nil?
|
@@default_value[k].nil?
|
||||||
end
|
end
|
||||||
|
@ -295,7 +295,7 @@ RSpec.shared_examples "bundle install --standalone" do
|
|||||||
|
|
||||||
it "outputs a helpful error message" do
|
it "outputs a helpful error message" do
|
||||||
expect(err).to include("You have one or more invalid gemspecs that need to be fixed.")
|
expect(err).to include("You have one or more invalid gemspecs that need to be fixed.")
|
||||||
expect(err).to include("bar 1.0 has an invalid gemspec")
|
expect(err).to include("bar.gemspec is not valid")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2989,6 +2989,18 @@ duplicate dependency on c (>= 1.2.3, development), (~> 1.2) use:
|
|||||||
e.message
|
e.message
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_validate_require_paths_with_invalid_types
|
||||||
|
util_setup_validate
|
||||||
|
|
||||||
|
@a1.require_paths = [1, 2]
|
||||||
|
e = assert_raise Gem::InvalidSpecificationException do
|
||||||
|
@a1.validate
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal "require_paths must be an Array of String",
|
||||||
|
e.message
|
||||||
|
end
|
||||||
|
|
||||||
def test_validate_files
|
def test_validate_files
|
||||||
pend "test_validate_files skipped on MS Windows (symlink)" if Gem.win_platform?
|
pend "test_validate_files skipped on MS Windows (symlink)" if Gem.win_platform?
|
||||||
util_setup_validate
|
util_setup_validate
|
||||||
|
Loading…
x
Reference in New Issue
Block a user