mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[rubygems/rubygems] Support running specs against a tarball
When bundler specs are run from a ruby tarball (ruby-core does this), there's no git folder, so `git ls-files` fails. Support this case by making specs rely on the list of files from the bundler gemspec instead, and invert the spec that makes sure we ship the right set of files. As per the other quality specs, skip them in this case. https://github.com/rubygems/rubygems/commit/b28d5ec931
This commit is contained in:
parent
bd9a6ba4ef
commit
592762069d
Notes:
git
2020-06-05 07:34:03 +09:00
3 changed files with 18 additions and 8 deletions
|
@ -216,7 +216,7 @@ RSpec.describe "The library itself" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "ships the correct set of files" do
|
it "ships the correct set of files" do
|
||||||
git_list = shipped_files
|
git_list = git_ls_files(ruby_core? ? "lib/bundler lib/bundler.rb man/bundle* man/gemfile* libexec/bundle*" : "lib man exe CHANGELOG.md LICENSE.md README.md bundler.gemspec")
|
||||||
|
|
||||||
gem_list = loaded_gemspec.files
|
gem_list = loaded_gemspec.files
|
||||||
|
|
||||||
|
|
|
@ -331,7 +331,7 @@ module Spec
|
||||||
|
|
||||||
build_metadata = {
|
build_metadata = {
|
||||||
:built_at => loaded_gemspec.date.utc.strftime("%Y-%m-%d"),
|
:built_at => loaded_gemspec.date.utc.strftime("%Y-%m-%d"),
|
||||||
:git_commit_sha => sys_exec("git rev-parse --short HEAD", :dir => source_root).strip,
|
:git_commit_sha => git_commit_sha,
|
||||||
}
|
}
|
||||||
|
|
||||||
replace_build_metadata(build_metadata, dir: build_path) # rubocop:disable Style/HashSyntax
|
replace_build_metadata(build_metadata, dir: build_path) # rubocop:disable Style/HashSyntax
|
||||||
|
|
|
@ -68,7 +68,7 @@ module Spec
|
||||||
end
|
end
|
||||||
|
|
||||||
def shipped_files
|
def shipped_files
|
||||||
@shipped_files ||= git_ls_files(shipped_files_glob)
|
@shipped_files ||= loaded_gemspec.files
|
||||||
end
|
end
|
||||||
|
|
||||||
def lib_tracked_files
|
def lib_tracked_files
|
||||||
|
@ -231,20 +231,22 @@ module Spec
|
||||||
end
|
end
|
||||||
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)
|
def git_ls_files(glob)
|
||||||
sys_exec("git ls-files -z -- #{glob}", :dir => source_root).split("\x0")
|
skip "Not running on a git context, since running tests from a tarball" if ruby_core_tarball?
|
||||||
|
|
||||||
|
sys_exec!("git ls-files -z -- #{glob}", :dir => source_root).split("\x0")
|
||||||
end
|
end
|
||||||
|
|
||||||
def tracked_files_glob
|
def tracked_files_glob
|
||||||
ruby_core? ? "lib/bundler lib/bundler.rb spec/bundler man/bundle*" : ""
|
ruby_core? ? "lib/bundler lib/bundler.rb spec/bundler man/bundle*" : ""
|
||||||
end
|
end
|
||||||
|
|
||||||
def shipped_files_glob
|
|
||||||
ruby_core? ? "lib/bundler lib/bundler.rb man/bundle* man/gemfile* libexec/bundle*" : "lib man exe CHANGELOG.md LICENSE.md README.md bundler.gemspec"
|
|
||||||
end
|
|
||||||
|
|
||||||
def lib_tracked_files_glob
|
def lib_tracked_files_glob
|
||||||
ruby_core? ? "lib/bundler lib/bundler.rb" : "lib"
|
ruby_core? ? "lib/bundler lib/bundler.rb" : "lib"
|
||||||
end
|
end
|
||||||
|
@ -253,6 +255,14 @@ module Spec
|
||||||
ruby_core? ? "man/bundle* man/gemfile*" : "man"
|
ruby_core? ? "man/bundle* man/gemfile*" : "man"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def git_root
|
||||||
|
ruby_core? ? source_root : source_root.parent
|
||||||
|
end
|
||||||
|
|
||||||
|
def ruby_core_tarball?
|
||||||
|
!git_root.join(".git").directory?
|
||||||
|
end
|
||||||
|
|
||||||
extend self
|
extend self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue