summaryrefslogtreecommitdiff
path: root/test/rubygems/test_gem_commands_pristine_command.rb
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2019-11-11 15:03:57 +0900
committerSHIBATA Hiroshi <hsbt@ruby-lang.org>2019-11-11 16:59:49 +0900
commit7d463e360b9c4718b17378eb52783116a01b884b (patch)
treeee6951d298d76fcbf0c5e062712e54de56a3fa39 /test/rubygems/test_gem_commands_pristine_command.rb
parent31416423809f64d4b5ea6b9651cced3179cc5ced (diff)
downloadruby-7d463e360b9c4718b17378eb52783116a01b884b.tar.gz
Merge RubyGems 3.1.0.pre3
* Fix gem pristine not accounting for user installed gems. Pull request #2914 by Luis Sagastume. * Refactor keyword argument test for Ruby 2.7. Pull request #2947 by SHIBATA Hiroshi. * Fix errors at frozen Gem::Version. Pull request #2949 by Nobuyoshi Nakada. * Remove taint usage on Ruby 2.7+. Pull request #2951 by Jeremy Evans. * Check Manifest.txt is up to date. Pull request #2953 by David Rodríguez. * Clarify symlink conditionals in tests. Pull request #2962 by David Rodríguez. * Update command line parsing to work under ps. Pull request #2966 by David Rodríguez. * Properly test `Gem::Specifications.stub_for`. Pull request #2970 by David Rodríguez. * Fix Gem::LOADED_SPECS_MUTEX handling for recursive locking. Pull request #2985 by MSP-Greg.
Diffstat (limited to 'test/rubygems/test_gem_commands_pristine_command.rb')
-rw-r--r--test/rubygems/test_gem_commands_pristine_command.rb49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/rubygems/test_gem_commands_pristine_command.rb b/test/rubygems/test_gem_commands_pristine_command.rb
index 962ea96a2a..e872a80957 100644
--- a/test/rubygems/test_gem_commands_pristine_command.rb
+++ b/test/rubygems/test_gem_commands_pristine_command.rb
@@ -53,6 +53,55 @@ class TestGemCommandsPristineCommand < Gem::TestCase
assert_empty out, out.inspect
end
+ def test_execute_user_install
+ FileUtils.chmod 0555, @gemhome
+
+ a = util_spec "a" do |s|
+ s.executables = %w[foo]
+ s.files = %w[bin/foo lib/a.rb]
+ end
+
+ write_file File.join(@tempdir, "lib", "a.rb") do |fp|
+ fp.puts "puts __FILE__"
+ end
+
+ write_file File.join(@tempdir, "bin", "foo") do |fp|
+ fp.puts "#!/usr/bin/ruby"
+ end
+
+ install_gem_user(a)
+
+ Gem::Specification.dirs = [Gem.dir, Gem.user_dir]
+
+ foo_path = File.join(Gem.user_dir, "gems", a.full_name, "bin", "foo")
+ a_rb_path = File.join(Gem.user_dir, "gems", a.full_name, "lib", "a.rb")
+
+ write_file foo_path do |io|
+ io.puts("I changed it!")
+ end
+
+ write_file a_rb_path do |io|
+ io.puts("I changed it!")
+ end
+
+ @cmd.options[:args] = %w[a]
+
+ use_ui @ui do
+ @cmd.execute
+ end
+
+ assert_equal "#!/usr/bin/ruby\n", File.read(foo_path), foo_path
+ assert_equal "puts __FILE__\n", File.read(a_rb_path), a_rb_path
+
+ out = @ui.output.split("\n")
+
+ assert_equal "Restoring gems to pristine condition...", out.shift
+ assert_equal "Restored #{a.full_name}", out.shift
+ assert_empty out, out.inspect
+ ensure
+ FileUtils.chmod(0755, @gemhome)
+ end
+
def test_execute_all
a = util_spec 'a' do |s|
s.executables = %w[foo]