-
Notifications
You must be signed in to change notification settings - Fork 7
/
runtests
executable file
·60 lines (46 loc) · 1.02 KB
/
runtests
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/perl -w
#
# Bare-bones test suite for cuts
# Add more tests in tests/tests.spec
#
use Getopt::Std;
use vars qw($opt_c);
$ENV{'PATH'} = '.:..:/bin:/usr/bin';
my $TestNo = 0;
my $Fails = 0;
my $OKs = 0;
getopts('c:');
$Cuts = $opt_c || `which cuts`;
printf "cuts is: %s\n", $Cuts;
while (<>) {
# skip comments and empty lines
next if (/^\s*#/);
next unless (/\w/);
s/\s+$//;
my ($cmd, $ref) = split(/\s{3,}/);
$TestNo++;
printf "Test %03d:\t%-40s\t", $TestNo, $cmd;
unless (-f $ref) {
print "$ref: $!\n";
$Fails++;
next;
}
system("$cmd > tmp.out");
if ($?) {
print "FAIL ($!)\n";
next;
}
system("diff '$ref' tmp.out >tmp.diff");
if ($?) {
print "FAIL (diff follows)\n";
print `cat tmp.diff`;
$Fails++;
} else {
print "OK\n";
$OKs++;
}
}
unlink 'tmp.out', 'tmp.diff';
printf "Summary: %d tests, %d successful (%.2f%% OK)\n",
$TestNo, $OKs, 100.0*$OKs/$TestNo;
exit $Fails;