From 0b191eec5dd6cdb8b74d92a34bd5f0d0261b0009 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Fri, 20 Dec 2013 22:36:29 +0100 Subject: test/run: Rewrite the main parsing loop Rewrite the main parsing loop of the tester scripts, in a way which is easier to understand and avoids redundant tests. No functional change here. --- test/run | 65 ++++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/test/run b/test/run index f78276d..2d1fe9a 100755 --- a/test/run +++ b/test/run @@ -81,38 +81,41 @@ if (defined $ARGV[0]) { *SOURCE = *STDIN; } -for (;;) { - my $line = ; $lineno++; - if (defined $line) { - # Substitute %{VAR} with environment variables. - $line =~ s[%{(\w+)}][$ENV{$1}]eg; - } - if (defined $line) { - if ($line =~ s/^\s*< ?//) { - push @$in, $line; - } elsif ($line =~ s/^\s*> ?//) { - push @$out, $line; - } else { - $last_status = process_test($prog, $prog_line, $in, $out) if @$prog; - last if $prog_line >= $opt_l; +while (defined(my $line = )) { + $lineno++; + # Substitute %{VAR} with environment variables + $line =~ s[%{(\w+)}][$ENV{$1}]eg; + + # Collect input and output for the previous command + if ($line =~ s/^\s*< ?//) { + push @$in, $line; + next; + } + if ($line =~ s/^\s*> ?//) { + push @$out, $line; + next; + } - $prog = []; - $prog_line = 0; - } - if ($line =~ s/^\s*\$ ?//) { - # Substitute %{?} with the last command's status. - $line =~ s[%{\?}][$last_status]eg; - - $prog = [ map { s/\\(.)/$1/g; $_ } split /(?= $opt_l; + } + + # Parse the next command + if ($line =~ s/^\s*\$ ?//) { + # Substitute %{?} with the last command's status + $line =~ s[%{\?}][$last_status]eg; + + $prog = [ map { s/\\(.)/$1/g; $_ } split /(?