selftest: handle progress output in verbose mode
authorStefan Metzmacher <metze@sernet.de>
Mon, 17 Mar 2008 14:17:19 +0000 (15:17 +0100)
committerStefan Metzmacher <metze@samba.org>
Mon, 17 Mar 2008 14:50:49 +0000 (15:50 +0100)
metze
(This used to be commit 9196213c49532ac60349ff55e66430b7c80b09c2)

source4/selftest/Subunit.pm
source4/selftest/output/plain.pm
source4/selftest/selftest.pl

index e5c61ca9ba748ce92e0bc2ebc753da45d295e581..f8a7794aac4e83ba4e5d24bdb264eb566d4806d2 100644 (file)
@@ -15,7 +15,34 @@ sub parse_results($$$$$)
        my $unexpected_err = 0;
        my $orig_open_len = $#$open_tests;
 
-       while(<$fh>) {
+       while(1) {
+               my $line = "";
+               my $char = "";
+               my $eof = 0;
+               my $error = 0;
+
+               while ($char ne "\n") {
+                       my $ret = sysread($fh, $char, 1);
+                       if (not defined($ret)) {
+                               $error = $!;
+                               last;
+                       }
+                       if ($ret == 0) {
+                               $eof = 1;
+                               last;
+                       }
+
+                       $line .= $char;
+                       if ($char eq "\r") {
+                               $msg_ops->output_msg($line);
+                               $line = "";
+                       }
+               }
+
+               last if ($eof or $error);
+
+               $_ = $line;
+
                if (/^test: (.+)\n/) {
                        $msg_ops->control_msg($_);
                        $msg_ops->start_test($open_tests, $1);
index e491a999ab196e9fd09fc0ff5d6aa1a21c592098..25ff74792e518f01e0a010ab8b8d8fbbdb52419c 100644 (file)
@@ -7,8 +7,6 @@ use Exporter;
 use FindBin qw($RealBin);
 use lib "$RealBin/..";
 
-use Subunit qw(parse_results);
-
 use strict;
 
 sub new($$$$$$$) {
@@ -62,7 +60,9 @@ sub output_msg($$)
        my ($self, $output) = @_;
 
        if ($self->{verbose}) {
+               require FileHandle;
                print $output;
+               STDOUT->flush();
        } else {
                $self->{test_output}->{$self->{NAME}} .= $output;
        }
index 73d03f3d4ca57e0e9d05c76d8b7bcaf80c23ef86..39a1b5a45089be203d4da12aa4dd4730f3a0b6b6 100755 (executable)
@@ -584,7 +584,7 @@ push (@torture_options, "--configfile=$conffile");
 push (@torture_options, "--maximum-runtime=$torture_maxtime");
 push (@torture_options, "--target=$opt_target");
 push (@torture_options, "--basedir=$prefix_abs");
-push (@torture_options, "--option=torture:progress=no") if ($opt_format eq "buildfarm");
+push (@torture_options, "--option=torture:progress=no") unless ($opt_verbose);
 push (@torture_options, "--format=subunit");
 push (@torture_options, "--option=torture:quick=yes") if ($opt_quick);