]> git.sur5r.net Git - i3/i3/blobdiff - testcases/lib/StatusLine.pm
Replace http:// with https:// where applicable
[i3/i3] / testcases / lib / StatusLine.pm
index 823c6713df080808134aa17685db046faf8a10a2..2cf756a05715acaf8b702b18638344629921c88b 100644 (file)
@@ -15,6 +15,15 @@ my %ansi_line_upwards;
 
 my $tests_total;
 
+sub noninteractive {
+    # CONTINUOUS_INTEGRATION gets set when running under Travis, see
+    # https://docs.travis-ci.com/user/ci-environment/ and
+    # https://github.com/travis-ci/travis-ci/issues/1337
+    return (! -t STDOUT) || (
+        defined($ENV{CONTINUOUS_INTEGRATION}) &&
+        $ENV{CONTINUOUS_INTEGRATION} eq 'true');
+}
+
 # setup %ansi_line_upwards to map all working displays to the
 # specific movement commands and initialize all status lines
 sub status_init {
@@ -22,6 +31,8 @@ sub status_init {
     my $displays = $args{displays};
     $tests_total = $args{tests};
 
+    return if noninteractive();
+
     for my $n (1 .. @$displays) {
         # since we are moving upwards, get $display in reverse order
         my $display = $displays->[-$n];
@@ -35,12 +46,14 @@ sub status_init {
     status_completed(0);
 }
 
-# generates the status text, prints it in the appropiate line
-# and returns it, so it can be used in conjuction with C<Log()>
+# generates the status text, prints it in the appropriate line
+# and returns it, so it can be used in conjunction with C<Log()>
 sub status {
     my ($display, $msg) = @_;
     my $status = "[$display] $msg";
 
+    return $status if noninteractive();
+
     print
         $ansi_save_cursor,
         $ansi_line_upwards{$display},
@@ -53,6 +66,9 @@ sub status {
 
 sub status_completed {
     my $num = shift;
+
+    return if noninteractive();
+
     print
         $ansi_save_cursor,
         $ansi_clear_line,