[ruby/irb] respect NO_COLOR environment variable

When `NO_COLOR` is set to any non-nil value, output is not colorized.

See https://no-color.org/

401d0916fe
This commit is contained in:
Mark Delk 2020-05-17 20:12:02 -05:00 committed by git
parent e16a642900
commit b8ffb1c46f
2 changed files with 18 additions and 2 deletions

View file

@ -67,6 +67,22 @@ module TestIRB
Process.kill("SIGKILL", status.pid) if !status.exited? && !status.stopped? && !status.signaled?
end
def test_no_color_environment_variable
orig = ENV['NO_COLOR']
assert IRB.conf[:USE_COLORIZE]
ENV['NO_COLOR'] = 'true'
IRB.setup(eval("__FILE__"))
refute IRB.conf[:USE_COLORIZE]
ENV['NO_COLOR'] = nil
IRB.setup(eval("__FILE__"))
assert IRB.conf[:USE_COLORIZE]
ensure
ENV['NO_COLOR'] = orig
end
private
def with_argv(argv)