summaryrefslogtreecommitdiff
path: root/test/optparse/test_load.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2025-08-03 22:41:21 +0900
committergit <svn-admin@ruby-lang.org>2025-08-03 13:53:27 +0000
commitdeb0240ea06d3353fe3238d41f2534d9acc108a9 (patch)
tree055604987de06da925ca9e08b2fcac6fbf02b898 /test/optparse/test_load.rb
parent1619afb3500bb695140df6e9dacaa901bc21920c (diff)
[ruby/optparse] Expand literal home paths only
Paths in environment variables should already be expanded. The base name of the program is also not subject to expansion. https://github.com/ruby/optparse/commit/181752391c
Diffstat (limited to 'test/optparse/test_load.rb')
-rw-r--r--test/optparse/test_load.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/optparse/test_load.rb b/test/optparse/test_load.rb
index b8b76a31c5..8c835032ba 100644
--- a/test/optparse/test_load.rb
+++ b/test/optparse/test_load.rb
@@ -75,6 +75,10 @@ class TestOptionParserLoad < Test::Unit::TestCase
setup_options({}, "config/settings", ".options", &block)
end
+ def setup_options_home_options(envname, &block)
+ setup_options({envname => '~/options'}, "options", ".options", &block)
+ end
+
def test_load_home_options
result, = setup_options_home
assert_load(result)
@@ -145,4 +149,30 @@ class TestOptionParserLoad < Test::Unit::TestCase
assert_load_nothing
end
end
+
+ def test_not_expand_path_basename
+ basename = @basename
+ @basename = "~"
+ $test_optparse_basename = "/" + @basename
+ alias $test_optparse_prog $0
+ alias $0 $test_optparse_basename
+ setup_options({'HOME'=>@tmpdir+"/~options"}, "", "options") do
+ assert_load_nothing
+ end
+ ensure
+ alias $0 $test_optparse_prog
+ @basename = basename
+ end
+
+ def test_not_expand_path_xdg_config_home
+ setup_options_home_options('XDG_CONFIG_HOME') do
+ assert_load_nothing
+ end
+ end
+
+ def test_not_expand_path_xdg_config_dirs
+ setup_options_home_options('XDG_CONFIG_DIRS') do
+ assert_load_nothing
+ end
+ end
end