Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for output of ANSI-colored text #80

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

n1tehawk
Copy link
Contributor

This is eye-candy based on the existing "text" class, augmented by ANSI control sequences for different colors.

To use it, request "color" output, e.g.:
./run_functional_tests.lua -v --output color

@coveralls
Copy link

coveralls commented Nov 18, 2016

Coverage Status

Coverage increased (+0.007%) to 99.831% when pulling 63ad634 on n1tehawk:20161118_ansicolors into d1a9ddc on bluebird75:master.

@n1tehawk
Copy link
Contributor Author

Will rebase onto current master...

@coveralls
Copy link

coveralls commented Nov 19, 2016

Coverage Status

Coverage increased (+0.006%) to 99.844% when pulling 32ac773 on n1tehawk:20161118_ansicolors into 41927da on bluebird75:master.

@coveralls
Copy link

coveralls commented Nov 19, 2016

Coverage Status

Coverage increased (+0.006%) to 99.844% when pulling afa3e17 on n1tehawk:20161118_ansicolors into 41927da on bluebird75:master.

@bluebird75
Copy link
Owner

Initially, I was thinking about a command line option --color to deal with color. However, I see that busted also used an outputter approach to deal with the color thing, so why not...

However, the text output itself should be identical with and without colors. Internally, the best way to go is to make this an option of the general text outputting class.

I did not check your branch under windows yet, but as far as I know, unix color codes don't work in the default windows console.

[Googling a bit on the topic]

So, on windows 10, ansi color codes work out of the box. On previous versions of windows, using program such as ansicon can make them work but I find the approach tedious.

So, as first step, let's just enable colors on unix. We will improve later on Windows support.

@n1tehawk
Copy link
Contributor Author

I selected the "outputter" class as a natural approach at first, but I do agree that we're duplicating code from the text output. And I assume that we don't expect to require any other output that would be 'colored'?

Re-uniting the code should be straightforward enough. We could start with a COLOR table that initially holds empty strings, and only set those (to the needed control sequences) when --color is encountered. If older Windows (Win32 console) needs special treatment, we could introduce a different option (--wincolor?) to adjust the control strings. The text outputter would just always concatenate the COLOR strings to its output; in the case of "plain" text those would simply be empty.

@coveralls
Copy link

coveralls commented Nov 27, 2016

Coverage Status

Coverage increased (+0.001%) to 99.839% when pulling 593a3e3 on n1tehawk:20161118_ansicolors into d2f1ffa on bluebird75:master.

@n1tehawk n1tehawk changed the title Add a new outputter class that supports ANSI-colored text Add support for output of ANSI-colored text Nov 27, 2016
@n1tehawk
Copy link
Contributor Author

Fixed typo in commit message, rebased to current master

@coveralls
Copy link

coveralls commented Jan 23, 2017

Coverage Status

Coverage increased (+0.001%) to 99.839% when pulling b7d7722 on n1tehawk:20161118_ansicolors into d2f1ffa on bluebird75:master.

@coveralls
Copy link

coveralls commented Feb 14, 2017

Coverage Status

Coverage increased (+0.002%) to 99.71% when pulling c6aa528 on n1tehawk:20161118_ansicolors into 4345dbd on bluebird75:master.

The output routine for a single failed test isn't used anywhere
else, so there's no need to make it a separate function.
The text outputter will now automatically insert (control) string
fields from the COLOR table. By default, these are all empty, so
"plain" text output is unchanged. Use the new "--color" option to
activate ANSI colors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants