Test unit results in color using console but not t

2019-08-31 10:40发布

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条回答
老娘就宠你
2楼-- · 2019-08-31 10:56

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
查看更多
登录 后发表回答