diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2020-10-15 13:20:25 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2020-10-15 17:19:02 +0900 |
commit | d386a58f6f1865aaa35eda5af55cff3ff3cca4ca (patch) | |
tree | 0665fe806540deae7f8e52095af6dba70f940aa3 /spec/bundler/support | |
parent | 7ffd14a18c341565afaf80d259f9fe5df8a13d29 (diff) | |
download | ruby-d386a58f6f1865aaa35eda5af55cff3ff3cca4ca.tar.gz |
Merge bundler-2.2.0.rc.2
Diffstat (limited to 'spec/bundler/support')
-rw-r--r-- | spec/bundler/support/build_metadata.rb | 49 | ||||
-rw-r--r-- | spec/bundler/support/builders.rb | 15 | ||||
-rw-r--r-- | spec/bundler/support/filters.rb | 1 | ||||
-rw-r--r-- | spec/bundler/support/hax.rb | 2 | ||||
-rw-r--r-- | spec/bundler/support/helpers.rb | 23 | ||||
-rw-r--r-- | spec/bundler/support/path.rb | 20 | ||||
-rw-r--r-- | spec/bundler/support/rubygems_ext.rb | 2 | ||||
-rw-r--r-- | spec/bundler/support/rubygems_version_manager.rb | 2 |
8 files changed, 79 insertions, 35 deletions
diff --git a/spec/bundler/support/build_metadata.rb b/spec/bundler/support/build_metadata.rb new file mode 100644 index 0000000000..98d8ac23c8 --- /dev/null +++ b/spec/bundler/support/build_metadata.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +require_relative "path" +require_relative "helpers" + +module Spec + module BuildMetadata + include Spec::Path + include Spec::Helpers + + def write_build_metadata(dir: source_root) + build_metadata = { + :git_commit_sha => git_commit_sha, + :built_at => loaded_gemspec.date.utc.strftime("%Y-%m-%d"), + :release => true, + } + + replace_build_metadata(build_metadata, dir: dir) # rubocop:disable Style/HashSyntax + end + + def reset_build_metadata(dir: source_root) + build_metadata = { + :release => false, + } + + replace_build_metadata(build_metadata, dir: dir) # rubocop:disable Style/HashSyntax + end + + private + + def replace_build_metadata(build_metadata, dir:) + build_metadata_file = File.expand_path("lib/bundler/build_metadata.rb", dir) + + ivars = build_metadata.sort.map do |k, v| + " @#{k} = #{loaded_gemspec.send(:ruby_code, v)}" + end.join("\n") + + contents = File.read(build_metadata_file) + contents.sub!(/^(\s+# begin ivars).+(^\s+# end ivars)/m, "\\1\n#{ivars}\n\\2") + File.open(build_metadata_file, "w") {|f| f << contents } + end + + def git_commit_sha + ruby_core_tarball? ? "unknown" : sys_exec("git rev-parse --short HEAD", :dir => source_root).strip + end + + extend self + end +end diff --git a/spec/bundler/support/builders.rb b/spec/bundler/support/builders.rb index 65f30d1f38..a1770759a9 100644 --- a/spec/bundler/support/builders.rb +++ b/spec/bundler/support/builders.rb @@ -322,10 +322,21 @@ module Spec "documentation_uri" => "https://www.example.info/gems/bestgemever/0.0.1", "homepage_uri" => "https://bestgemever.example.io", "mailing_list_uri" => "https://groups.example.com/bestgemever", + "funding_uri" => "https://example.com/has_metadata/funding", "source_code_uri" => "https://example.com/user/bestgemever", "wiki_uri" => "https://example.com/user/bestgemever/wiki", } end + + build_gem "has_funding", "1.2.3" do |s| + s.metadata = { + "funding_uri" => "https://example.com/has_funding/funding", + } + end + + build_gem "gem_with_dependent_funding", "1.0" do |s| + s.add_dependency "has_funding" + end end end @@ -461,7 +472,7 @@ module Spec build_with(PluginBuilder, name, args, &blk) end - private + private def build_with(builder, name, args, &blk) @_build_path ||= nil @@ -758,7 +769,7 @@ module Spec gem_path = File.expand_path("#{@spec.full_name}.gem", lib_path) if opts[:to_system] - @context.system_gems gem_path + @context.system_gems gem_path, :default => opts[:default] elsif opts[:to_bundle] @context.system_gems gem_path, :path => @context.default_bundle_path else diff --git a/spec/bundler/support/filters.rb b/spec/bundler/support/filters.rb index 6322efda8b..b1978e44e6 100644 --- a/spec/bundler/support/filters.rb +++ b/spec/bundler/support/filters.rb @@ -26,7 +26,6 @@ RSpec.configure do |config| git_version = Bundler::Source::Git::GitProxy.new(nil, nil, nil).version - config.filter_run_excluding :rubygems => RequirementChecker.against(Gem::VERSION) config.filter_run_excluding :git => RequirementChecker.against(git_version) config.filter_run_excluding :bundler => RequirementChecker.against(Bundler::VERSION.split(".")[0]) config.filter_run_excluding :ruby_repo => !ENV["GEM_COMMAND"].nil? diff --git a/spec/bundler/support/hax.rb b/spec/bundler/support/hax.rb index 7529dc460a..fc8e0ad55d 100644 --- a/spec/bundler/support/hax.rb +++ b/spec/bundler/support/hax.rb @@ -9,6 +9,8 @@ module Gem Gem.ruby = ENV["RUBY"] end + @default_dir = ENV["BUNDLER_GEM_DEFAULT_DIR"] if ENV["BUNDLER_GEM_DEFAULT_DIR"] + if ENV["BUNDLER_SPEC_PLATFORM"] class Platform @local = new(ENV["BUNDLER_SPEC_PLATFORM"]) diff --git a/spec/bundler/support/helpers.rb b/spec/bundler/support/helpers.rb index b5648b84a8..c4018eb818 100644 --- a/spec/bundler/support/helpers.rb +++ b/spec/bundler/support/helpers.rb @@ -290,26 +290,30 @@ module Spec gems = gems.flatten options = gems.last.is_a?(Hash) ? gems.pop : {} path = options.fetch(:path, system_gem_path) + default = options.fetch(:default, false) with_gem_path_as(path) do gem_repo = options.fetch(:gem_repo, gem_repo1) gems.each do |g| gem_name = g.to_s if gem_name.start_with?("bundler") version = gem_name.match(/\Abundler-(?<version>.*)\z/)[:version] if gem_name != "bundler" - with_built_bundler(version) {|gem_path| install_gem(gem_path) } + with_built_bundler(version) {|gem_path| install_gem(gem_path, default) } elsif gem_name =~ %r{\A(?:[a-zA-Z]:)?/.*\.gem\z} - install_gem(gem_name) + install_gem(gem_name, default) else - install_gem("#{gem_repo}/gems/#{gem_name}.gem") + install_gem("#{gem_repo}/gems/#{gem_name}.gem", default) end end end end - def install_gem(path) + def install_gem(path, default = false) raise "OMG `#{path}` does not exist!" unless File.exist?(path) - gem_command "install --no-document --ignore-dependencies '#{path}'" + args = "--no-document --ignore-dependencies" + args += " --default --install-dir #{system_gem_path}" if default + + gem_command "install #{args} '#{path}'" end def with_built_bundler(version = nil) @@ -330,12 +334,7 @@ module Spec replace_version_file(version, dir: build_path) # rubocop:disable Style/HashSyntax - build_metadata = { - :built_at => loaded_gemspec.date.utc.strftime("%Y-%m-%d"), - :git_commit_sha => git_commit_sha, - } - - replace_build_metadata(build_metadata, dir: build_path) # rubocop:disable Style/HashSyntax + Spec::BuildMetadata.write_build_metadata(dir: build_path) # rubocop:disable Style/HashSyntax gem_command "build #{relative_gemspec}", :dir => build_path @@ -570,7 +569,7 @@ module Spec port end - private + private def git_root_dir? root.to_s == `git rev-parse --show-toplevel`.chomp diff --git a/spec/bundler/support/path.rb b/spec/bundler/support/path.rb index 042aae92fd..305ea0a876 100644 --- a/spec/bundler/support/path.rb +++ b/spec/bundler/support/path.rb @@ -34,7 +34,7 @@ module Spec end def dev_gemfile - @dev_gemfile ||= source_root.join("dev_gems.rb") + @dev_gemfile ||= git_root.join("dev_gems.rb") end def bindir @@ -208,18 +208,6 @@ module Spec File.open(version_file, "w") {|f| f << contents } end - def replace_build_metadata(build_metadata, dir: source_root) - build_metadata_file = File.expand_path("lib/bundler/build_metadata.rb", dir) - - ivars = build_metadata.sort.map do |k, v| - " @#{k} = #{loaded_gemspec.send(:ruby_code, v)}" - end.join("\n") - - contents = File.read(build_metadata_file) - contents.sub!(/^(\s+# begin ivars).+(^\s+# end ivars)/m, "\\1\n#{ivars}\n\\2") - File.open(build_metadata_file, "w") {|f| f << contents } - end - def ruby_core? # avoid to warnings @ruby_core ||= nil @@ -231,11 +219,7 @@ module Spec end end - def git_commit_sha - ruby_core_tarball? ? "unknown" : sys_exec("git rev-parse --short HEAD", :dir => source_root).strip - end - - private + private def git_ls_files(glob) skip "Not running on a git context, since running tests from a tarball" if ruby_core_tarball? diff --git a/spec/bundler/support/rubygems_ext.rb b/spec/bundler/support/rubygems_ext.rb index d13567d7af..d743a76391 100644 --- a/spec/bundler/support/rubygems_ext.rb +++ b/spec/bundler/support/rubygems_ext.rb @@ -71,7 +71,7 @@ module Spec install_gems(test_gemfile, test_lockfile) end - private + private # Some rubygems versions include loaded specs when loading gemspec stubs # from the file system. In this situation, that makes bundler incorrectly diff --git a/spec/bundler/support/rubygems_version_manager.rb b/spec/bundler/support/rubygems_version_manager.rb index 66dcdc7ad3..ac02021cff 100644 --- a/spec/bundler/support/rubygems_version_manager.rb +++ b/spec/bundler/support/rubygems_version_manager.rb @@ -51,7 +51,7 @@ class RubygemsVersionManager end end -private + private def use_system? @source.nil? |