Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
test: Added the -r option to resume a test at a given line
Added the -r option to resume a test at a given line.
It can be used with the -l option to run only a certain part of a test
or to skip part of a test.

Also slightly modified the behavior of the -l option to prevent running
one more command than intended if the line given wasn't a command.

Signed-off-by: Michael Groshans <groshans@umich.edu>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
  • Loading branch information
Michael Groshans authored and kvaneesh committed Jun 24, 2011
1 parent 9c86e0a commit 95baa06
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions test/run
Expand Up @@ -5,20 +5,19 @@
#
# - distinguish stdout and stderr output
# - add environment variable like assignments
# - run up to a specific line
# - resume at a specific line
#

use strict;
use FileHandle;
use Getopt::Std;
use POSIX qw(isatty setuid getcwd);
use vars qw($opt_l $opt_v);
use vars qw($opt_l $opt_r $opt_v);

no warnings qw(taint);

$opt_l = ~0; # a really huge number
getopts('l:v');
$opt_r = 0;
getopts('l:r:v');

my ($OK, $FAILED) = ("ok", "failed");
if (isatty(fileno(STDOUT))) {
Expand All @@ -37,6 +36,8 @@ my $width = ($ENV{COLUMNS} || 80) >> 1;

for (;;) {
my $line = <>; $lineno++;
next if ($lineno < $opt_r && ($opt_l > $opt_r || $lineno > $opt_l));
last if ($prog_line > $opt_l && $opt_r < $opt_l);
if (defined $line) {
# Substitute %VAR and %{VAR} with environment variables.
$line =~ s[%(\w+)][$ENV{$1}]eg;
Expand All @@ -49,7 +50,6 @@ for (;;) {
push @$out, $line;
} else {
process_test($prog, $prog_line, $in, $out);
last if $prog_line >= $opt_l;

$prog = [];
$prog_line = 0;
Expand Down

0 comments on commit 95baa06

Please sign in to comment.