aboutsummaryrefslogtreecommitdiffstats
path: root/test/rubygems
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2020-04-23 19:16:06 +0900
committerGitHub <noreply@github.com>2020-04-23 19:16:06 +0900
commit5c6269c4593f8b1a83b72e157c460dd2b37338c7 (patch)
treed179fbf295790b083035ddaf454f1db4b4982986 /test/rubygems
parentf563f3c5ef517b62f1a95ab03286335e4fe72314 (diff)
downloadruby-5c6269c4593f8b1a83b72e157c460dd2b37338c7.tar.gz
Support XDG_* (#2174)
* Support XDG_CONFIG_HOME for gemrc. * Support XDG_DATA_HOME for .gem * Added test for XDG_DATA_HOME * Do not reuse environmental variable. * Unify .rdoc path to RDoc.home. * Support XDG_DATA_HOME for .rdoc * Ignore exists? * Extracted config_home path * Use XDG_CONFIG_HOME for default credential path * Fixed inconsistency location. * Fixed the broken tests. * Support XDG_CONFIG_HOME for irbrc * Introduce Gem.cache_home as XDG_CACHE_HOME * Use Gem.cache_home instead of Gem.config_home for the credential file of RubyGems. * Initialized the old configurations * Fixed test failure related the configuration initialization * restore XDG_DATA_HOME * Fixed the broken examples of bundler with XDG_* * Do not modify environmental variable on test file * Use XDG_DATA_HOME insted of XDG_CACHE_HOME for credential file * stub out Gem.data_home * Move dir accessor to defaults.rb file * Use XDG_DATA_HOME for signed gem features * Use XDG_DATA_HOME for spec cache * Do not rely on Gem.user_home * Gem.user_home is always exists. Don't need to use FileUitls.mkdir_p * Bump support version to RubyGems 3.2.0+ * Removed the needless fallback configuration * Fixed the inconsistency methods that are find_config_file and config_file * Use Gem.configuration.credentials_path instead of hard-coded path * gem_path is always provided * Removed the duplicated code of find_home * Also removed the duplicated code of user_home * use Gem::UNTAINT instead of untaint for surpressing the warnings * Use File.directory * Restore XDG_DATA_HOME * Use File.write
Diffstat (limited to 'test/rubygems')
-rw-r--r--test/rubygems/test_gem.rb2
-rw-r--r--test/rubygems/test_gem_commands_build_command.rb2
-rw-r--r--test/rubygems/test_gem_commands_cert_command.rb4
-rw-r--r--test/rubygems/test_gem_commands_signout_command.rb1
-rw-r--r--test/rubygems/test_gem_config_file.rb4
-rw-r--r--test/rubygems/test_gem_source.rb2
-rw-r--r--test/rubygems/test_gem_spec_fetcher.rb2
7 files changed, 7 insertions, 10 deletions
diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb
index 1f5e0e6768..5f70a2ac6b 100644
--- a/test/rubygems/test_gem.rb
+++ b/test/rubygems/test_gem.rb
@@ -1359,6 +1359,8 @@ class TestGem < Gem::TestCase
parts = [@userhome, '.gem', Gem.ruby_engine]
parts << RbConfig::CONFIG['ruby_version'] unless RbConfig::CONFIG['ruby_version'].empty?
+ FileUtils.mkdir_p File.join(parts)
+
assert_equal File.join(parts), Gem.user_dir
end
diff --git a/test/rubygems/test_gem_commands_build_command.rb b/test/rubygems/test_gem_commands_build_command.rb
index a2e8f284eb..ca9f8b66c9 100644
--- a/test/rubygems/test_gem_commands_build_command.rb
+++ b/test/rubygems/test_gem_commands_build_command.rb
@@ -376,7 +376,6 @@ class TestGemCommandsBuildCommand < Gem::TestCase
skip 'openssl is missing' unless defined?(OpenSSL::SSL) && !java_platform?
gem_path = File.join Gem.user_home, ".gem"
- Dir.mkdir gem_path
Gem::Security.trust_dir
@@ -420,7 +419,6 @@ class TestGemCommandsBuildCommand < Gem::TestCase
skip 'openssl is missing' unless defined?(OpenSSL::SSL) && !java_platform?
gem_path = File.join Gem.user_home, ".gem"
- Dir.mkdir gem_path
Gem::Security.trust_dir
diff --git a/test/rubygems/test_gem_commands_cert_command.rb b/test/rubygems/test_gem_commands_cert_command.rb
index fd1e66b915..bb9ed9e630 100644
--- a/test/rubygems/test_gem_commands_cert_command.rb
+++ b/test/rubygems/test_gem_commands_cert_command.rb
@@ -597,7 +597,6 @@ ERROR: --private-key not specified and ~/.gem/gem-private_key.pem does not exis
def test_execute_re_sign
gem_path = File.join Gem.user_home, ".gem"
- Dir.mkdir gem_path
path = File.join @tempdir, 'cert.pem'
Gem::Security.write EXPIRED_PUBLIC_CERT, path, 0600
@@ -628,9 +627,6 @@ ERROR: --private-key not specified and ~/.gem/gem-private_key.pem does not exis
end
def test_execute_re_sign_with_cert_expiration_length_days
- gem_path = File.join Gem.user_home, ".gem"
- Dir.mkdir gem_path
-
path = File.join @tempdir, 'cert.pem'
Gem::Security.write EXPIRED_PUBLIC_CERT, path, 0600
diff --git a/test/rubygems/test_gem_commands_signout_command.rb b/test/rubygems/test_gem_commands_signout_command.rb
index 814b55cf4f..9a47dafe7c 100644
--- a/test/rubygems/test_gem_commands_signout_command.rb
+++ b/test/rubygems/test_gem_commands_signout_command.rb
@@ -8,6 +8,7 @@ class TestGemCommandsSignoutCommand < Gem::TestCase
def setup
super
+ File.delete Gem.configuration.credentials_path if File.exist?(Gem.configuration.credentials_path)
@cmd = Gem::Commands::SignoutCommand.new
end
diff --git a/test/rubygems/test_gem_config_file.rb b/test/rubygems/test_gem_config_file.rb
index 260a94953e..d31d55eba1 100644
--- a/test/rubygems/test_gem_config_file.rb
+++ b/test/rubygems/test_gem_config_file.rb
@@ -170,7 +170,7 @@ class TestGemConfigFile < Gem::TestCase
assert_nil @cfg.instance_variable_get :@api_keys
temp_cred = File.join Gem.user_home, '.gem', 'credentials'
- FileUtils.mkdir File.dirname(temp_cred)
+ FileUtils.mkdir_p File.dirname(temp_cred)
File.open temp_cred, 'w', 0600 do |fp|
fp.puts ':rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97'
end
@@ -296,7 +296,7 @@ if you believe they were disclosed to a third party.
def test_load_api_keys
temp_cred = File.join Gem.user_home, '.gem', 'credentials'
- FileUtils.mkdir File.dirname(temp_cred)
+ FileUtils.mkdir_p File.dirname(temp_cred)
File.open temp_cred, 'w', 0600 do |fp|
fp.puts ":rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97"
fp.puts ":other: a5fdbb6ba150cbb83aad2bb2fede64c"
diff --git a/test/rubygems/test_gem_source.rb b/test/rubygems/test_gem_source.rb
index 05e443c7f1..24b8edb055 100644
--- a/test/rubygems/test_gem_source.rb
+++ b/test/rubygems/test_gem_source.rb
@@ -230,7 +230,7 @@ class TestGemSource < Gem::TestCase
end
def test_update_cache_eh_home_nonexistent
- FileUtils.rmdir Gem.user_home
+ FileUtils.rm_rf Gem.user_home
refute @source.update_cache?
end
diff --git a/test/rubygems/test_gem_spec_fetcher.rb b/test/rubygems/test_gem_spec_fetcher.rb
index b7547112bb..d1633c4e3c 100644
--- a/test/rubygems/test_gem_spec_fetcher.rb
+++ b/test/rubygems/test_gem_spec_fetcher.rb
@@ -33,7 +33,7 @@ class TestGemSpecFetcher < Gem::TestCase
end
def test_initialize_nonexistent_home_dir
- FileUtils.rmdir Gem.user_home
+ FileUtils.rm_rf Gem.user_home
assert Gem::SpecFetcher.new
end