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

1

0

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?

Teleplay answered 22/2, 2013 at 16:44 Comment(0)
S
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
Story answered 23/2, 2013 at 5:10 Comment(2)
Thanks. I wasn't able to get the configuration file to work when named .test-unit.yml. I read in test-unit help doc (test-unit.rubyforge.org/test-unit/en/Test/…) that it needed to be named test-unit.yml (without the period - so I guess it can't be a hidden file :().Teleplay
Right, it only checks for the non-hidden version in the current directory, the hidden one is read from your home directory (and only if the non-hidden one does not exist in the current directory).Story

© 2022 - 2024 — McMap. All rights reserved.