From 8a29419b7fb723b3faf04b3d9a3cb0740213d946 Mon Sep 17 00:00:00 2001 From: Sorah Fukumori Date: Mon, 6 Feb 2023 04:38:33 +0900 Subject: [ruby/reline] test_dumb_terminal: "ruby" command is not always available Fixes the same issue at https://github.com/ruby/ruby/pull/5417 `ruby` is not always available in certain build environments and configure options (e.g. --program-suffix) This patch tries to choose an appropriate command line for spawning a fresh Ruby process, based on EnvUtil implementation in ruby/ruby's test suite. Plus when this library is directly mirrored into ruby/ruby, prefer EnvUtil available there over the implementation in this library's test suite. https://github.com/ruby/reline/commit/278327d2e9 --- test/reline/helper.rb | 41 +++++++++++++++++++++++++++++++++++++++++ test/reline/test_reline.rb | 2 +- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/test/reline/helper.rb b/test/reline/helper.rb index e3ce318c44..c2a47a79d1 100644 --- a/test/reline/helper.rb +++ b/test/reline/helper.rb @@ -5,6 +5,19 @@ ENV['TERM'] = 'xterm' # for some CI environments require 'reline' require 'test/unit' +begin + require 'rbconfig' +rescue LoadError +end + +begin + # This should exist and available in load path when this file is mirrored to ruby/ruby and running at there + if File.exist?(File.expand_path('../../tool/lib/envutil.rb', __dir__)) + require 'envutil' + end +rescue LoadError +end + module Reline class <"dumb"}, "ruby", "-I#{lib}", "-rreline", "-e", "p Reline::IOGate"], &:read) + out = IO.popen([{"TERM"=>"dumb"}, Reline.test_rubybin, "-I#{lib}", "-rreline", "-e", "p Reline::IOGate"], &:read) assert_equal("Reline::GeneralIO", out.chomp) end -- cgit v1.2.3