tests: don’t print interactive status when running on travis

(or without a tty)
This commit is contained in:
Michael Stapelberg 2015-03-14 12:33:54 +01:00
parent 69be6e4a8e
commit aa4aec41f5
1 changed files with 14 additions and 0 deletions

View File

@ -15,6 +15,13 @@ my %ansi_line_upwards;
my $tests_total; my $tests_total;
sub noninteractive {
# CONTINUOUS_INTEGRATION gets set when running under Travis, see
# http://docs.travis-ci.com/user/ci-environment/ and
# https://github.com/travis-ci/travis-ci/issues/1337
return (! -t STDOUT) || $ENV{CONTINUOUS_INTEGRATION} eq 'true';
}
# setup %ansi_line_upwards to map all working displays to the # setup %ansi_line_upwards to map all working displays to the
# specific movement commands and initialize all status lines # specific movement commands and initialize all status lines
sub status_init { sub status_init {
@ -22,6 +29,8 @@ sub status_init {
my $displays = $args{displays}; my $displays = $args{displays};
$tests_total = $args{tests}; $tests_total = $args{tests};
return if noninteractive();
for my $n (1 .. @$displays) { for my $n (1 .. @$displays) {
# since we are moving upwards, get $display in reverse order # since we are moving upwards, get $display in reverse order
my $display = $displays->[-$n]; my $display = $displays->[-$n];
@ -41,6 +50,8 @@ sub status {
my ($display, $msg) = @_; my ($display, $msg) = @_;
my $status = "[$display] $msg"; my $status = "[$display] $msg";
return $status if noninteractive();
print print
$ansi_save_cursor, $ansi_save_cursor,
$ansi_line_upwards{$display}, $ansi_line_upwards{$display},
@ -53,6 +64,9 @@ sub status {
sub status_completed { sub status_completed {
my $num = shift; my $num = shift;
return if noninteractive();
print print
$ansi_save_cursor, $ansi_save_cursor,
$ansi_clear_line, $ansi_clear_line,