ruby-changes:60014
From: Yusuke <ko1@a...>
Date: Wed, 12 Feb 2020 17:37:27 +0900 (JST)
Subject: [ruby-changes:60014] 65201c054a (master): test/rubygems: Try not only /usr/bin/env but also /bin/env
https://git.ruby-lang.org/ruby.git/commit/?id=65201c054a From 65201c054a90c8e7beb8fe1e6d0006541ac33449 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Wed, 12 Feb 2020 17:33:41 +0900 Subject: test/rubygems: Try not only /usr/bin/env but also /bin/env RubyGems chooses available one from the two 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. diff --git a/test/rubygems/test_gem_commands_pristine_command.rb b/test/rubygems/test_gem_commands_pristine_command.rb index 4ebe1ef..c40d32a 100644 --- a/test/rubygems/test_gem_commands_pristine_command.rb +++ b/test/rubygems/test_gem_commands_pristine_command.rb @@ -160,11 +160,9 @@ class TestGemCommandsPristineCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_pristine_command.rb#L160 ruby_exec = sprintf Gem.default_exec_format, 'ruby' - if win_platform? - assert_match %r%\A#!\s*#{ruby_exec}%, File.read(gem_exec) - else - assert_match %r%\A#!\s*/usr/bin/env #{ruby_exec}%, File.read(gem_exec) - end + bin_env = win_platform? ? "" : %w(/usr/bin/env /bin/env).find {|f| File.executable?(f) } + + assert_match %r%\A#!\s*#{bin_env} #{ruby_exec}%, File.read(gem_exec) end def test_execute_extensions_explicit diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb index eaeff4a..29458db 100644 --- a/test/rubygems/test_gem_installer.rb +++ b/test/rubygems/test_gem_installer.rb @@ -1794,9 +1794,9 @@ gem 'other', version https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_installer.rb#L1794 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 @@ -1875,10 +1875,18 @@ gem 'other', version https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_installer.rb#L1875 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' @@ -1894,7 +1902,7 @@ gem 'other', version https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_installer.rb#L1902 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' -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/