ruby-changes:65966
From: Nobuyoshi <ko1@a...>
Date: Mon, 26 Apr 2021 21:14:56 +0900 (JST)
Subject: [ruby-changes:65966] 687ab5dcad (master): [ruby/irb] Assertions on non-tty
https://git.ruby-lang.org/ruby.git/commit/?id=687ab5dcad From 687ab5dcad7bb8069776330ca6a62640290d14f5 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Thu, 8 Apr 2021 00:20:10 +0900 Subject: [ruby/irb] Assertions on non-tty https://github.com/ruby/irb/commit/ede12890d2 --- test/irb/test_color.rb | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/test/irb/test_color.rb b/test/irb/test_color.rb index ada207d..29725c5 100644 --- a/test/irb/test_color.rb +++ b/test/irb/test_color.rb @@ -31,6 +31,8 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_color.rb#L31 [:CYAN] => "#{CYAN}#{text}#{CLEAR}", }.each do |seq, result| assert_equal_with_term(result, text, seq: seq) + + assert_equal_with_term(text, text, seq: seq, tty: false) end end @@ -124,6 +126,9 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_color.rb#L126 if colorize_code_supported? assert_equal_with_term(result, code, complete: true) assert_equal_with_term(result, code, complete: false) + + assert_equal_with_term(code, code, complete: true, tty: false) + assert_equal_with_term(code, code, complete: false, tty: false) else assert_equal_with_term(code, code) end @@ -141,6 +146,8 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_color.rb#L146 "('foo" => "(#{RED}#{BOLD}'#{CLEAR}#{RED}#{REVERSE}foo#{CLEAR}", }.each do |code, result| assert_equal_with_term(result, code, complete: true) + + assert_equal_with_term(code, code, complete: true, tty: false) end end @@ -153,8 +160,12 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_color.rb#L160 if colorize_code_supported? assert_equal_with_term(result, code, complete: false) + assert_equal_with_term(code, code, complete: false, tty: false) + unless complete_option_supported? assert_equal_with_term(result, code, complete: true) + + assert_equal_with_term(code, code, complete: true, tty: false) end else assert_equal_with_term(code, code) @@ -194,10 +205,10 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_color.rb#L205 Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0') end - def with_term + def with_term(tty: true) stdout = $stdout io = StringIO.new - def io.tty?; true; end + def io.tty?; true; end if tty $stdout = io env = ENV.to_h.dup @@ -209,8 +220,8 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_color.rb#L220 ENV.replace(env) if env end - def assert_equal_with_term(result, code, seq: nil, **opts) - actual = with_term do + def assert_equal_with_term(result, code, seq: nil, tty: true, **opts) + actual = with_term(tty: tty) do if seq IRB::Color.colorize(code, seq, **opts) else -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/