[rubygems/rubygems] Added only missing extensions option into pristine command
https://github.com/rubygems/rubygems/commit/cfd0e615d7
This commit is contained in:
parent
86d38b4520
commit
15739c66b7
@ -34,6 +34,12 @@ class Gem::Commands::PristineCommand < Gem::Command
|
||||
options[:extensions] = value
|
||||
end
|
||||
|
||||
add_option("--only-missing-extensions",
|
||||
"Only restore gems with missing extensions") do |value, options|
|
||||
options[:extensions_set] = true
|
||||
options[:only_missing_extensions] = value
|
||||
end
|
||||
|
||||
add_option("--only-executables",
|
||||
"Only restore executables") do |value, options|
|
||||
options[:only_executables] = value
|
||||
@ -107,6 +113,10 @@ extensions will be restored.
|
||||
Gem::Specification.select do |spec|
|
||||
spec.extensions && !spec.extensions.empty?
|
||||
end
|
||||
elsif options[:only_missing_extensions]
|
||||
Gem::Specification.select do |spec|
|
||||
spec.missing_extensions?
|
||||
end
|
||||
else
|
||||
get_all_gem_names.sort.map do |gem_name|
|
||||
Gem::Specification.find_all_by_name(gem_name, options[:version]).reverse
|
||||
|
@ -202,6 +202,54 @@ class TestGemCommandsPristineCommand < Gem::TestCase
|
||||
assert_empty out, out.inspect
|
||||
end
|
||||
|
||||
def test_execute_extensions_only_missing_extensions
|
||||
a = util_spec "a" do |s|
|
||||
s.extensions << "ext/a/extconf.rb"
|
||||
end
|
||||
|
||||
ext_path = File.join @tempdir, "ext", "a", "extconf.rb"
|
||||
write_file ext_path do |io|
|
||||
io.write <<-'RUBY'
|
||||
File.open "Makefile", "w" do |f|
|
||||
f.puts "clean:\n\techo cleaned\n"
|
||||
f.puts "all:\n\techo built\n"
|
||||
f.puts "install:\n\techo installed\n"
|
||||
end
|
||||
RUBY
|
||||
end
|
||||
|
||||
b = util_spec "b" do |s|
|
||||
s.extensions << "ext/b/extconf.rb"
|
||||
end
|
||||
|
||||
ext_path = File.join @tempdir, "ext", "b", "extconf.rb"
|
||||
write_file ext_path do |io|
|
||||
io.write <<-'RUBY'
|
||||
File.open "Makefile", "w" do |f|
|
||||
f.puts "clean:\n\techo cleaned\n"
|
||||
f.puts "all:\n\techo built\n"
|
||||
f.puts "install:\n\techo installed\n"
|
||||
end
|
||||
RUBY
|
||||
end
|
||||
|
||||
install_gem a
|
||||
install_gem b
|
||||
|
||||
# Remove the extension files for b
|
||||
FileUtils.rm_rf b.gem_build_complete_path
|
||||
|
||||
@cmd.options[:only_missing_extensions] = true
|
||||
@cmd.options[:args] = []
|
||||
|
||||
use_ui @ui do
|
||||
@cmd.execute
|
||||
end
|
||||
|
||||
refute_includes @ui.output, "Restored #{a.full_name}"
|
||||
assert_includes @ui.output, "Restored #{b.full_name}"
|
||||
end
|
||||
|
||||
def test_execute_no_extension
|
||||
a = util_spec "a" do |s|
|
||||
s.extensions << "ext/a/extconf.rb"
|
||||
|
Loading…
x
Reference in New Issue
Block a user