summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDavid Rodríguez <[email protected]>2025-06-10 17:52:42 +0200
committerHiroshi SHIBATA <[email protected]>2025-06-11 08:48:57 +0900
commitdba72134de4e8e86caf9eccb0185eb9505314f93 (patch)
tree6320c6d90790ec234dc338690d160b6944d476e1 /test
parent6560083c39e2052a5ab9f114a6dcf25317e7fdc6 (diff)
[rubygems/rubygems] Fix `gem pristine` sometimes not resetting extensions
If `gem pristine foo` is run, and there's a default copy of foo, only executables for it are reset. However, that was causing other copies of `foo` to only reset executables, which is unexpected. We should not modify `options[:only_executables]`, but respect its value for every gem, and make sure special handling for default gems does not leak to other gems. https://github.com/rubygems/rubygems/commit/2c3039f1b0
Diffstat (limited to 'test')
-rw-r--r--test/rubygems/test_gem_commands_pristine_command.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/rubygems/test_gem_commands_pristine_command.rb b/test/rubygems/test_gem_commands_pristine_command.rb
index 3ec1bc92ef..e9c4d32945 100644
--- a/test/rubygems/test_gem_commands_pristine_command.rb
+++ b/test/rubygems/test_gem_commands_pristine_command.rb
@@ -659,6 +659,42 @@ class TestGemCommandsPristineCommand < Gem::TestCase
refute_includes "ruby_executable_hooks", File.read(exe)
end
+ def test_execute_default_gem_and_regular_gem
+ a_default = new_default_spec("a", "1.2.0")
+
+ 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
+
+ install_default_gems a_default
+ install_gem a
+
+ # Remove the extension files for a
+ FileUtils.rm_rf a.gem_build_complete_path
+
+ @cmd.options[:args] = %w[a]
+
+ use_ui @ui do
+ @cmd.execute
+ end
+
+ assert_includes @ui.output, "Restored #{a.full_name}"
+
+ # Check extension files for a were restored
+ assert_path_exist a.gem_build_complete_path
+ end
+
def test_execute_multi_platform
a = util_spec "a" do |s|
s.extensions << "ext/a/extconf.rb"