summaryrefslogtreecommitdiff
path: root/test/reline
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-04-24 17:54:54 +0900
committeraycabta <aycabta@gmail.com>2020-04-29 19:13:14 +0900
commit0ac5009165e0d743b82ac673d4eb98e871f4ea0b (patch)
tree5090dd46cf6dbaf79a77545fbe9586e852e42f44 /test/reline
parente801e9ba65f6d98f6fee32a1e7e553e6586230cd (diff)
[ruby/reline] Ignore non-absolute XDG_CONFIG_HOME
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html > All paths set in these environment variables must be absolute. > If an implementation encounters a relative path in any of these > variables it should consider the path invalid and ignore it. https://github.com/ruby/reline/commit/45af6eea77
Diffstat (limited to 'test/reline')
-rw-r--r--test/reline/test_config.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/reline/test_config.rb b/test/reline/test_config.rb
index bf980a2c98..d24d4e837e 100644
--- a/test/reline/test_config.rb
+++ b/test/reline/test_config.rb
@@ -213,6 +213,7 @@ class Reline::Config::Test < Reline::TestCase
assert_nothing_raised do
@config.read
end
+ ensure
ENV['INPUTRC'] = inputrc_backup
end
@@ -221,6 +222,7 @@ class Reline::Config::Test < Reline::TestCase
expected = "#{@tmpdir}/abcde"
ENV['INPUTRC'] = expected
assert_equal expected, @config.inputrc_path
+ ensure
ENV['INPUTRC'] = inputrc_backup
end
@@ -234,6 +236,7 @@ class Reline::Config::Test < Reline::TestCase
ENV['HOME'] = @tmpdir
ENV['XDG_CONFIG_HOME'] = xdg_config_home
assert_equal expected, @config.inputrc_path
+ ensure
FileUtils.rm(expected)
ENV['XDG_CONFIG_HOME'] = xdg_config_home_backup
ENV['HOME'] = home_backup
@@ -248,6 +251,28 @@ class Reline::Config::Test < Reline::TestCase
FileUtils.mkdir_p(File.dirname(expected))
FileUtils.touch(expected)
assert_equal expected, @config.inputrc_path
+ ensure
+ FileUtils.rm(expected)
+ ENV['XDG_CONFIG_HOME'] = xdg_config_home_backup
+ ENV['HOME'] = home_backup
+ end
+
+ def test_relative_xdg_config_home
+ home_backup = ENV['HOME']
+ xdg_config_home_backup = ENV['XDG_CONFIG_HOME']
+ ENV['HOME'] = @tmpdir
+ expected = File.expand_path('~/.config/readline/inputrc')
+ FileUtils.mkdir_p(File.dirname(expected))
+ FileUtils.touch(expected)
+ result = Dir.chdir(@tmpdir) do
+ xdg_config_home = ".config/example_dir"
+ ENV['XDG_CONFIG_HOME'] = xdg_config_home
+ inputrc = "#{xdg_config_home}/readline/inputrc"
+ FileUtils.mkdir_p(File.dirname(inputrc))
+ FileUtils.touch(inputrc)
+ @config.inputrc_path
+ end
+ assert_equal expected, result
FileUtils.rm(expected)
ENV['XDG_CONFIG_HOME'] = xdg_config_home_backup
ENV['HOME'] = home_backup