summaryrefslogtreecommitdiff
path: root/test/rubygems/test_gem_installer.rb
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2020-03-24 17:21:55 +0900
committerYusuke Endoh <mame@ruby-lang.org>2020-03-24 17:21:55 +0900
commit12a3671a9bfb6d6d9bd358ee453b3f21e66d3092 (patch)
treea8410a90faa159dae0e5c980edaa62ddd6620774 /test/rubygems/test_gem_installer.rb
parent96064e6f1ce100a37680dc8f9509f06b3350e9c8 (diff)
test/rubygems: Try not only /usr/bin/env but also /bin/env
RubyGems chooses available one from the two: /usr/bin/env or /bin/env https://github.com/rubygems/rubygems/blob/20b0d609484df2b514954ba9ef890a7cbdd01d18/lib/rubygems/installer.rb#L38 So, it is good not to hard-code /usr/bin/env in tests. This is a retry of 65201c054a90c8e7beb8fe1e6d0006541ac33449 which was accidentally deleted by 96064e6f1ce100a37680dc8f9509f06b3350e9c8
Diffstat (limited to 'test/rubygems/test_gem_installer.rb')
-rw-r--r--test/rubygems/test_gem_installer.rb16
1 files changed, 12 insertions, 4 deletions
diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb
index 9f531d4258..082e47205a 100644
--- a/test/rubygems/test_gem_installer.rb
+++ b/test/rubygems/test_gem_installer.rb
@@ -1824,9 +1824,9 @@ gem 'other', version
shebang = installer.shebang 'executable'
- env_shebang = "/usr/bin/env" unless Gem.win_platform?
+ bin_env = get_bin_env
- assert_equal("#!#{env_shebang} #{RbConfig::CONFIG['ruby_install_name']}",
+ assert_equal("#!#{bin_env} #{RbConfig::CONFIG['ruby_install_name']}",
shebang)
end
@@ -1905,10 +1905,18 @@ gem 'other', version
assert_equal "#!test", shebang
end
+ def get_bin_env
+ if win_platform?
+ ""
+ else
+ %w(/usr/bin/env /bin/env).find {|f| File.executable?(f) }
+ end
+ end
+
def test_shebang_custom_with_expands
installer = setup_base_installer
- bin_env = win_platform? ? '' : '/usr/bin/env'
+ bin_env = get_bin_env
conf = Gem::ConfigFile.new []
conf[:custom_shebang] = '1 $env 2 $ruby 3 $exec 4 $name'
@@ -1924,7 +1932,7 @@ gem 'other', version
def test_shebang_custom_with_expands_and_arguments
installer = setup_base_installer
- bin_env = win_platform? ? '' : '/usr/bin/env'
+ bin_env = get_bin_env
conf = Gem::ConfigFile.new []
conf[:custom_shebang] = '1 $env 2 $ruby 3 $exec'