-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The new output looks as follows: ============================= common test starting ============================= cwd: /home/user/workspace/otp/_worktree/more-silent-tests/lib/inets/make_test_dir/inets_test make: 1 test module(s) compiled collected: 1 test(s), 451 case(s) in 11 suite(s) Testing make_test_dir.inets_test: Starting test, 451 test cases The new module `ct_console` is introduced to serve as the main point for new "fancy" terminal formatting. Note that there is some duplication going on with respect to the color formatting from `shell_docs`. We also don't really respect any "no color" options the user might have (yet). This should later become part of the `ct_console` module once we've figured out a clean way to do so. The `Testing` output and below will be worked on in a following commit.
- Loading branch information
1 parent
a13c7f0
commit 9b7f21b
Showing
5 changed files
with
86 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ MODULES= \ | |
ct \ | ||
ct_logs \ | ||
ct_framework \ | ||
ct_console \ | ||
ct_ftp \ | ||
ct_ssh \ | ||
ct_snmp \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
% Deals with output formatting for the terminal. | ||
|
||
-module(ct_console). | ||
-export([print_header/1]). | ||
|
||
|
||
print_header(Message) -> | ||
{ok, Columns} = terminal_width(user), | ||
MessageLength = length(Message), | ||
PaddingSize = trunc(Columns / 2) - trunc(MessageLength / 2) - 1, | ||
% shell_docs contains a lot of useful functions that we could maybe factor | ||
% out and use here. | ||
Start = "\033[;1m", | ||
Stop = "\033[0m", | ||
case PaddingSize of | ||
Amount when Amount < 0 -> | ||
% Not enough space to print the padding, proceed normally. | ||
io:format("~s~s~s~n", [Start, Message, Stop]); | ||
_Amount -> | ||
Padding = lists:duplicate(PaddingSize, "="), | ||
io:format("~s~s ~s ~s~s~n", [Start, Padding, Message, Padding, Stop]) | ||
end. | ||
|
||
-spec terminal_width(atom()) -> {ok, pos_integer()}. | ||
terminal_width(Driver) -> | ||
case io:columns(Driver) of | ||
{ok, _Columns} = Result -> | ||
Result; | ||
{error, enotsup} -> | ||
{ok, 80} | ||
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters