Test unit results in color using console but not tmux unless --use-color is specified

▼魔方 西西 提交于 2019-12-25 05:35:29

问题


If I create a new Rails (3.2.12) app. Add the test-unit gem to my development, test group, and then scaffolded resource. When I run the tests from the Mac console.app, I get color output.

bundle exec rake test

When I create a tmux session (in console.app) for the app and run the exact same command. I don't get color output. However if I pass the "--use-color" switch, then I do get color output for the tests in tmux.

bundle exec rake test TESTOPTS="--use-color"

I'm setting 256 colors in my tmux.config with set -g default-terminal "screen-256color". Any idea why I don't get color in tmux when I run the rake task without the TESTOPTS?


回答1:


It appears that test-unit guesses whether the terminal supports color by (mainly) looking at the TERM environment variable. Unfortunately, screen-256color does not satisfy the checks that it makes.

It might be reasonable to ask that its recognition of screen be extended to include screen-256color, also.

I think you can drop some entries in a configuration file to supply default arguments. The first of test-unit.yml (in the current directory) or ~/.test-unit.yml (a “hidden” file in your home directory) will be loaded:

runner: console
console_options:
  arguments: --use-color=yes


来源:https://stackoverflow.com/questions/15029071/test-unit-results-in-color-using-console-but-not-tmux-unless-use-color-is-spec

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!