version 1.7, 2017/07/04 15:24:36 |
version 1.14, 2020/03/13 15:32:31 |
|
|
# |
# |
# $Id$ |
# $Id$ |
# |
# |
# Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org> |
# Copyright (c) 2017, 2018, 2019, 2020 Ingo Schwarze <schwarze@openbsd.org> |
# |
# |
# Permission to use, copy, modify, and distribute this software for any |
# Permission to use, copy, modify, and distribute this software for any |
# purpose with or without fee is hereby granted, provided that the above |
# purpose with or without fee is hereby granted, provided that the above |
Line 27 use IPC::Open3 qw(open3); |
|
Line 27 use IPC::Open3 qw(open3); |
|
# Define this at one place such that it can easily be changed |
# Define this at one place such that it can easily be changed |
# if diff(1) does not support the -a option. |
# if diff(1) does not support the -a option. |
my @diff = qw(diff -au); |
my @diff = qw(diff -au); |
|
system @diff, '/dev/null', '/dev/null' and @diff = qw(diff -u); |
|
|
# --- utility functions ------------------------------------------------ |
# --- utility functions ------------------------------------------------ |
|
|
|
|
exit 1; |
exit 1; |
} |
} |
|
|
|
# Modifier arguments provided on the command line, |
|
# inspected by the main program and by the utility functions. |
|
my %targets; |
|
|
# Run a command and send STDOUT and STDERR to a file. |
# Run a command and send STDOUT and STDERR to a file. |
# 1st argument: path to the output file |
# 1st argument: path to the output file |
# 2nd argument: command name |
# 2nd argument: command name |
# The remaining arguments are passed to the command. |
# The remaining arguments are passed to the command. |
sub sysout ($@) { |
sub sysout ($@) { |
my $outfile = shift; |
my $outfile = shift; |
|
print "@_\n" if $targets{verbose}; |
local *OUT_FH; |
local *OUT_FH; |
open OUT_FH, '>', $outfile or die "$outfile: $!"; |
open OUT_FH, '>', $outfile or die "$outfile: $!"; |
my $pid = open3 undef, ">&OUT_FH", undef, @_; |
my $pid = open3 undef, ">&OUT_FH", undef, @_; |
Line 53 sub sysout ($@) { |
|
Line 59 sub sysout ($@) { |
|
# Simlar, but filter the output as needed for the lint test. |
# Simlar, but filter the output as needed for the lint test. |
sub syslint ($@) { |
sub syslint ($@) { |
my $outfile = shift; |
my $outfile = shift; |
|
print "@_\n" if $targets{verbose}; |
open my $outfd, '>', $outfile or die "$outfile: $!"; |
open my $outfd, '>', $outfile or die "$outfile: $!"; |
my $infd; |
my $infd; |
my $pid = open3 undef, $infd, undef, @_; |
my $pid = open3 undef, $infd, undef, @_; |
Line 69 sub syslint ($@) { |
|
Line 76 sub syslint ($@) { |
|
# Simlar, but filter the output as needed for the html test. |
# Simlar, but filter the output as needed for the html test. |
sub syshtml ($@) { |
sub syshtml ($@) { |
my $outfile = shift; |
my $outfile = shift; |
|
print "@_\n" if $targets{verbose}; |
open my $outfd, '>', $outfile or die "$outfile: $!"; |
open my $outfd, '>', $outfile or die "$outfile: $!"; |
my $infd; |
my $infd; |
my $pid = open3 undef, $infd, undef, @_; |
my $pid = open3 undef, $infd, undef, @_; |
my $state; |
my $state = 0; |
while (<$infd>) { |
while (<$infd>) { |
chomp; |
chomp; |
if (!$state && s/.*<math class="eqn">//) { |
if (!$state && s/.*<math class="eqn">//) { |
$state = 1; |
$state = 'math'; |
next unless length; |
next unless length; |
|
} elsif (/BEGINTEST/) { |
|
$state = 'other'; |
|
next; |
|
} elsif (/ENDTEST/) { |
|
$state = 0; |
|
next; |
} |
} |
$state = 1 if /^BEGINTEST/; |
if ($state eq 'math') { |
if ($state && s/<\/math>.*//) { |
|
s/^ *//; |
s/^ *//; |
print $outfd "$_\n" if length; |
if (s/<\/math>.*//) { |
undef $state; |
print $outfd "$_\n" if length; |
next; |
$state = 0; |
|
next; |
|
} |
} |
} |
s/^ *//; |
|
print $outfd "$_\n" if $state; |
print $outfd "$_\n" if $state; |
undef $state if /^ENDTEST/; |
|
} |
} |
close $outfd; |
close $outfd; |
close $infd; |
close $infd; |
Line 97 sub syshtml ($@) { |
|
Line 110 sub syshtml ($@) { |
|
} |
} |
|
|
my @failures; |
my @failures; |
sub fail ($$$) { |
sub fail ($$) { |
warn "FAILED: @_\n"; |
warn "FAILED: @_\n"; |
push @failures, [@_]; |
push @failures, [@_]; |
} |
} |
Line 105 sub fail ($$$) { |
|
Line 118 sub fail ($$$) { |
|
|
|
# --- process command line arguments ----------------------------------- |
# --- process command line arguments ----------------------------------- |
|
|
my ($subdir, $onlytest) = split ':', (shift // '.'); |
my $onlytest = shift // ''; |
my $displaylevel = 2; |
|
my %targets; |
|
for (@ARGV) { |
for (@ARGV) { |
if (/^[0123]$/) { |
/^(all|ascii|tag|man|utf8|html|markdown|lint|clean|verbose)$/ |
$displaylevel = int; |
|
next; |
|
} |
|
/^(all|ascii|utf8|man|html|markdown|lint|clean|verbose)$/ |
|
or usage "$_: invalid modifier"; |
or usage "$_: invalid modifier"; |
$targets{$_} = 1; |
$targets{$_} = 1; |
} |
} |
$targets{all} = 1 |
$targets{all} = 1 |
unless $targets{ascii} || $targets{utf8} || $targets{man} || |
unless $targets{ascii} || $targets{tag} || $targets{man} || |
$targets{html} || $targets{markdown} || |
$targets{utf8} || $targets{html} || $targets{markdown} || |
$targets{lint} || $targets{clean}; |
$targets{lint} || $targets{clean}; |
$targets{ascii} = $targets{utf8} = $targets{man} = $targets{html} = |
$targets{ascii} = $targets{tag} = $targets{man} = $targets{utf8} = |
$targets{markdown} = $targets{lint} = 1 if $targets{all}; |
$targets{html} = $targets{markdown} = $targets{lint} = 1 |
$displaylevel = 3 if $targets{verbose}; |
if $targets{all}; |
|
|
|
|
# --- parse Makefiles -------------------------------------------------- |
# --- parse Makefiles -------------------------------------------------- |
|
|
my %vars = (MOPTS => ''); |
sub parse_makefile ($%) { |
sub parse_makefile ($) { |
my ($filename, $vars) = @_; |
my $filename = shift; |
|
open my $fh, '<', $filename or die "$filename: $!"; |
open my $fh, '<', $filename or die "$filename: $!"; |
while (<$fh>) { |
while (<$fh>) { |
chomp; |
chomp; |
Line 143 sub parse_makefile ($) { |
|
Line 149 sub parse_makefile ($) { |
|
my $var = $1; |
my $var = $1; |
my $opt = $2; |
my $opt = $2; |
my $val = $3; |
my $val = $3; |
$val =~ s/\$\{(\w+)\}/$vars{$1}/; |
$val =~ s/\$\{(\w+)\}/$vars->{$1}/; |
$val = "$vars{$var} $val" if $opt eq '+'; |
$val = "$vars->{$var} $val" if $opt eq '+'; |
$vars{$var} = $val |
$vars->{$var} = $val |
unless $opt eq '?' && defined $vars{$var}; |
unless $opt eq '?' && defined $vars->{$var}; |
} |
} |
close $fh; |
close $fh; |
} |
} |
|
|
if ($subdir eq '.') { |
my (@regress_tests, @utf8_tests, @lint_tests, @html_tests); |
$vars{SUBDIR} = 'roff char mdoc man tbl eqn'; |
my (%tag_tests, %skip_ascii, %skip_man, %skip_markdown); |
} else { |
foreach my $module (qw(roff char mdoc man tbl eqn)) { |
parse_makefile "$subdir/Makefile"; |
my %modvars; |
parse_makefile "$subdir/../Makefile.inc" |
parse_makefile "$module/Makefile", \%modvars; |
if -e "$subdir/../Makefile.inc"; |
foreach my $subdir (split ' ', $modvars{SUBDIR}) { |
} |
my %subvars = (MOPTS => ''); |
|
parse_makefile "$module/$subdir/Makefile", \%subvars; |
my @mandoc = '../mandoc'; |
parse_makefile "$module/Makefile.inc", \%subvars; |
my @subdir_names; |
delete $subvars{GOPTS}; |
my (@regress_testnames, @utf8_testnames, @lint_testnames); |
delete $subvars{SKIP_GROFF}; |
my (@html_testnames, @markdown_testnames); |
delete $subvars{SKIP_GROFF_ASCII}; |
my (%skip_ascii, %skip_man, %skip_markdown); |
my @mopts = split ' ', $subvars{MOPTS}; |
|
delete $subvars{MOPTS}; |
push @mandoc, split ' ', $vars{MOPTS} if $vars{MOPTS}; |
my @regress_testnames; |
delete $vars{MOPTS}; |
if (defined $subvars{TAG_TARGETS}) { |
delete $vars{SKIP_GROFF}; |
$tag_tests{"$module/$subdir/$_"} = 1 |
delete $vars{SKIP_GROFF_ASCII}; |
for split ' ', $subvars{TAG_TARGETS}; |
delete $vars{TBL}; |
delete $subvars{TAG_TARGETS}; |
delete $vars{EQN}; |
} |
if (defined $vars{SUBDIR}) { |
if (defined $subvars{REGRESS_TARGETS}) { |
@subdir_names = split ' ', $vars{SUBDIR}; |
push @regress_testnames, |
delete $vars{SUBDIR}; |
split ' ', $subvars{REGRESS_TARGETS}; |
} |
push @regress_tests, { |
if (defined $vars{REGRESS_TARGETS}) { |
NAME => "$module/$subdir/$_", |
@regress_testnames = split ' ', $vars{REGRESS_TARGETS}; |
MOPTS => \@mopts, |
delete $vars{REGRESS_TARGETS}; |
} foreach @regress_testnames; |
} |
delete $subvars{REGRESS_TARGETS}; |
if (defined $vars{UTF8_TARGETS}) { |
} |
@utf8_testnames = split ' ', $vars{UTF8_TARGETS}; |
if (defined $subvars{UTF8_TARGETS}) { |
delete $vars{UTF8_TARGETS}; |
push @utf8_tests, { |
} |
NAME => "$module/$subdir/$_", |
if (defined $vars{HTML_TARGETS}) { |
MOPTS => \@mopts, |
@html_testnames = split ' ', $vars{HTML_TARGETS}; |
} foreach split ' ', $subvars{UTF8_TARGETS}; |
delete $vars{HTML_TARGETS}; |
delete $subvars{UTF8_TARGETS}; |
} |
} |
if (defined $vars{MARKDOWN_TARGETS}) { |
if (defined $subvars{HTML_TARGETS}) { |
@markdown_testnames = split ' ', $vars{MARKDOWN_TARGETS}; |
push @html_tests, { |
delete $vars{MARKDOWN_TARGETS}; |
NAME => "$module/$subdir/$_", |
} |
MOPTS => \@mopts, |
if (defined $vars{LINT_TARGETS}) { |
} foreach split ' ', $subvars{HTML_TARGETS}; |
@lint_testnames = split ' ', $vars{LINT_TARGETS}; |
delete $subvars{HTML_TARGETS}; |
delete $vars{LINT_TARGETS}; |
} |
} |
if (defined $subvars{LINT_TARGETS}) { |
if (defined $vars{SKIP_ASCII}) { |
push @lint_tests, { |
for (split ' ', $vars{SKIP_ASCII}) { |
NAME => "$module/$subdir/$_", |
$skip_ascii{$_} = 1; |
MOPTS => \@mopts, |
$skip_man{$_} = 1; |
} foreach split ' ', $subvars{LINT_TARGETS}; |
|
delete $subvars{LINT_TARGETS}; |
|
} |
|
if (defined $subvars{SKIP_ASCII}) { |
|
for (split ' ', $subvars{SKIP_ASCII}) { |
|
$skip_ascii{"$module/$subdir/$_"} = 1; |
|
$skip_man{"$module/$subdir/$_"} = 1; |
|
} |
|
delete $subvars{SKIP_ASCII}; |
|
} |
|
if (defined $subvars{SKIP_TMAN}) { |
|
$skip_man{"$module/$subdir/$_"} = 1 |
|
for split ' ', $subvars{SKIP_TMAN}; |
|
delete $subvars{SKIP_TMAN}; |
|
} |
|
if (defined $subvars{SKIP_MARKDOWN}) { |
|
$skip_markdown{"$module/$subdir/$_"} = 1 |
|
for split ' ', $subvars{SKIP_MARKDOWN}; |
|
delete $subvars{SKIP_MARKDOWN}; |
|
} |
|
if (keys %subvars) { |
|
my @vars = keys %subvars; |
|
die "unknown var(s) @vars in dir $module/$subdir"; |
|
} |
|
map { |
|
$skip_ascii{"$module/$subdir/$_"} = 1; |
|
} @regress_testnames if $skip_ascii{"$module/$subdir/ALL"}; |
|
map { |
|
$skip_man{"$module/$subdir/$_"} = 1; |
|
} @regress_testnames if $skip_man{"$module/$subdir/ALL"}; |
|
map { |
|
$skip_markdown{"$module/$subdir/$_"} = 1; |
|
} @regress_testnames if $skip_markdown{"$module/$subdir/ALL"}; |
} |
} |
delete $vars{SKIP_ASCII}; |
delete $modvars{SUBDIR}; |
|
if (keys %modvars) { |
|
my @vars = keys %modvars; |
|
die "unknown var(s) @vars in module $module"; |
|
} |
} |
} |
if (defined $vars{SKIP_TMAN}) { |
|
$skip_man{$_} = 1 for split ' ', $vars{SKIP_TMAN}; |
|
delete $vars{SKIP_TMAN}; |
|
} |
|
if (defined $vars{SKIP_MARKDOWN}) { |
|
$skip_markdown{$_} = 1 for split ' ', $vars{SKIP_MARKDOWN}; |
|
delete $vars{SKIP_MARKDOWN}; |
|
} |
|
if (keys %vars) { |
|
my @vars = keys %vars; |
|
die "unknown var(s) @vars"; |
|
} |
|
map { $skip_ascii{$_} = 1; } @regress_testnames if $skip_ascii{ALL}; |
|
map { $skip_man{$_} = 1; } @regress_testnames if $skip_man{ALL}; |
|
map { $skip_markdown{$_} = 1; } @regress_testnames if $skip_markdown{ALL}; |
|
|
|
# --- run targets ------------------------------------------------------ |
# --- run targets ------------------------------------------------------ |
|
|
my $count_total = 0; |
my $count_total = 0; |
for my $dirname (@subdir_names) { |
|
$count_total++; |
|
print "\n" if $targets{verbose}; |
|
system './regress.pl', "$subdir/$dirname", keys %targets, |
|
($displaylevel ? $displaylevel - 1 : 0), |
|
and fail $subdir, $dirname, 'subdir'; |
|
} |
|
|
|
my $count_ascii = 0; |
my $count_ascii = 0; |
|
my $count_tag = 0; |
my $count_man = 0; |
my $count_man = 0; |
for my $testname (@regress_testnames) { |
my $count_rm = 0; |
next if $onlytest && $testname ne $onlytest; |
if ($targets{ascii} || $targets{tag} || $targets{man}) { |
my $i = "$subdir/$testname.in"; |
print "Running ascii, tag, and man tests "; |
my $o = "$subdir/$testname.mandoc_ascii"; |
print "...\n" if $targets{verbose}; |
my $w = "$subdir/$testname.out_ascii"; |
} |
if ($targets{ascii} && !$skip_ascii{$testname}) { |
for my $test (@regress_tests) { |
|
my $i = "$test->{NAME}.in"; |
|
my $o = "$test->{NAME}.mandoc_ascii"; |
|
my $w = "$test->{NAME}.out_ascii"; |
|
my $to = "$test->{NAME}.mandoc_tag"; |
|
my $tw = "$test->{NAME}.out_tag"; |
|
my $diff_ascii; |
|
if ($targets{tag} && $tag_tests{$test->{NAME}} && |
|
$test->{NAME} =~ /^$onlytest/) { |
|
$count_tag++; |
|
$count_total++; |
|
local $ENV{MANPAGER} = "./copyless $test->{NAME}"; |
|
my @cmd = (qw(../man -l), @{$test->{MOPTS}}, |
|
qw(-I os=OpenBSD -T ascii), $i); |
|
print "@cmd\n" if $targets{verbose}; |
|
system @cmd |
|
and fail $test->{NAME}, 'tag:man'; |
|
system @diff, $tw, $to |
|
and fail $test->{NAME}, 'tag:diff'; |
|
print "." unless $targets{verbose}; |
|
$diff_ascii = $targets{ascii}; |
|
} elsif ($targets{ascii} && !$skip_ascii{$test->{NAME}} && |
|
$test->{NAME} =~ /^$onlytest/) { |
|
sysout $o, '../mandoc', @{$test->{MOPTS}}, |
|
qw(-I os=OpenBSD -T ascii), $i |
|
and fail $test->{NAME}, 'ascii:mandoc'; |
|
$diff_ascii = 1; |
|
} |
|
if ($diff_ascii) { |
$count_ascii++; |
$count_ascii++; |
$count_total++; |
$count_total++; |
print "@mandoc -T ascii $i\n" if $targets{verbose}; |
|
sysout $o, @mandoc, qw(-I os=OpenBSD -T ascii), $i |
|
and fail $subdir, $testname, 'ascii:mandoc'; |
|
system @diff, $w, $o |
system @diff, $w, $o |
and fail $subdir, $testname, 'ascii:diff'; |
and fail $test->{NAME}, 'ascii:diff'; |
|
print "." unless $targets{verbose}; |
} |
} |
my $m = "$subdir/$testname.in_man"; |
my $m = "$test->{NAME}.in_man"; |
my $mo = "$subdir/$testname.mandoc_man"; |
my $mo = "$test->{NAME}.mandoc_man"; |
if ($targets{man} && !$skip_man{$testname}) { |
if ($targets{man} && !$skip_man{$test->{NAME}} && |
|
$test->{NAME} =~ /^$onlytest/) { |
$count_man++; |
$count_man++; |
$count_total++; |
$count_total++; |
print "@mandoc -T man $i\n" if $targets{verbose}; |
sysout $m, '../mandoc', @{$test->{MOPTS}}, |
sysout $m, @mandoc, qw(-I os=OpenBSD -T man), $i |
qw(-I os=OpenBSD -T man), $i |
and fail $subdir, $testname, 'man:man'; |
and fail $test->{NAME}, 'man:man'; |
print "@mandoc -man -T ascii $m\n" if $targets{verbose}; |
sysout $mo, '../mandoc', @{$test->{MOPTS}}, |
sysout $mo, @mandoc, qw(-man -I os=OpenBSD -T ascii -O mdoc), $m |
qw(-man -I os=OpenBSD -T ascii -O mdoc), $m |
and fail $subdir, $testname, 'man:mandoc'; |
and fail $test->{NAME}, 'man:mandoc'; |
system @diff, $w, $mo |
system @diff, $w, $mo |
and fail $subdir, $testname, 'man:diff'; |
and fail $test->{NAME}, 'man:diff'; |
|
print "." unless $targets{verbose}; |
} |
} |
if ($targets{clean}) { |
if ($targets{clean}) { |
print "rm $o\n" |
print "rm $o $to $m $mo\n" if $targets{verbose}; |
if $targets{verbose} && !$skip_ascii{$testname}; |
$count_rm += unlink $o, $to, $m, $mo; |
unlink $o; |
|
print "rm $m $mo\n" |
|
if $targets{verbose} && !$skip_man{$testname}; |
|
unlink $m, $mo; |
|
} |
} |
} |
} |
|
if ($targets{ascii} || $targets{tag} || $targets{man}) { |
|
print "Number of ascii, tag, and man tests:" if $targets{verbose}; |
|
print " $count_ascii + $count_tag + $count_man tests run.\n"; |
|
} |
|
|
my $count_utf8 = 0; |
my $count_utf8 = 0; |
for my $testname (@utf8_testnames) { |
if ($targets{utf8}) { |
next if $onlytest && $testname ne $onlytest; |
print "Running utf8 tests "; |
my $i = "$subdir/$testname.in"; |
print "...\n" if $targets{verbose}; |
my $o = "$subdir/$testname.mandoc_utf8"; |
} |
my $w = "$subdir/$testname.out_utf8"; |
for my $test (@utf8_tests) { |
if ($targets{utf8}) { |
my $i = "$test->{NAME}.in"; |
|
my $o = "$test->{NAME}.mandoc_utf8"; |
|
my $w = "$test->{NAME}.out_utf8"; |
|
if ($targets{utf8} && $test->{NAME} =~ /^$onlytest/o) { |
$count_utf8++; |
$count_utf8++; |
$count_total++; |
$count_total++; |
print "@mandoc -T utf8 $i\n" if $targets{verbose}; |
sysout $o, '../mandoc', @{$test->{MOPTS}}, |
sysout $o, @mandoc, qw(-I os=OpenBSD -T utf8), $i |
qw(-I os=OpenBSD -T utf8), $i |
and fail $subdir, $testname, 'utf8:mandoc'; |
and fail $test->{NAME}, 'utf8:mandoc'; |
system @diff, $w, $o |
system @diff, $w, $o |
and fail $subdir, $testname, 'utf8:diff'; |
and fail $test->{NAME}, 'utf8:diff'; |
|
print "." unless $targets{verbose}; |
} |
} |
if ($targets{clean}) { |
if ($targets{clean}) { |
print "rm $o\n" if $targets{verbose}; |
print "rm $o\n" if $targets{verbose}; |
unlink $o; |
$count_rm += unlink $o; |
} |
} |
} |
} |
|
if ($targets{utf8}) { |
|
print "Number of utf8 tests:" if $targets{verbose}; |
|
print " $count_utf8 tests run.\n"; |
|
} |
|
|
my $count_html = 0; |
my $count_html = 0; |
for my $testname (@html_testnames) { |
if ($targets{html}) { |
next if $onlytest && $testname ne $onlytest; |
print "Running html tests "; |
my $i = "$subdir/$testname.in"; |
print "...\n" if $targets{verbose}; |
my $o = "$subdir/$testname.mandoc_html"; |
} |
my $w = "$subdir/$testname.out_html"; |
for my $test (@html_tests) { |
if ($targets{html}) { |
my $i = "$test->{NAME}.in"; |
|
my $o = "$test->{NAME}.mandoc_html"; |
|
my $w = "$test->{NAME}.out_html"; |
|
if ($targets{html} && $test->{NAME} =~ /^$onlytest/) { |
$count_html++; |
$count_html++; |
$count_total++; |
$count_total++; |
print "@mandoc -T html $i\n" if $targets{verbose}; |
syshtml $o, '../mandoc', @{$test->{MOPTS}}, |
syshtml $o, @mandoc, qw(-T html), $i |
qw(-T html), $i |
and fail $subdir, $testname, 'html:mandoc'; |
and fail $test->{NAME}, 'html:mandoc'; |
system @diff, $w, $o |
system @diff, $w, $o |
and fail $subdir, $testname, 'html:diff'; |
and fail $test->{NAME}, 'html:diff'; |
|
print "." unless $targets{verbose}; |
} |
} |
if ($targets{clean}) { |
if ($targets{clean}) { |
print "rm $o\n" if $targets{verbose}; |
print "rm $o\n" if $targets{verbose}; |
unlink $o; |
$count_rm += unlink $o; |
} |
} |
} |
} |
|
if ($targets{html}) { |
|
print "Number of html tests:" if $targets{verbose}; |
|
print " $count_html tests run.\n"; |
|
} |
|
|
my $count_markdown = 0; |
my $count_markdown = 0; |
for my $testname (@regress_testnames) { |
if ($targets{markdown}) { |
next if $onlytest && $testname ne $onlytest; |
print "Running markdown tests "; |
my $i = "$subdir/$testname.in"; |
print "...\n" if $targets{verbose}; |
my $o = "$subdir/$testname.mandoc_markdown"; |
} |
my $w = "$subdir/$testname.out_markdown"; |
for my $test (@regress_tests) { |
if ($targets{markdown} && !$skip_markdown{$testname}) { |
my $i = "$test->{NAME}.in"; |
|
my $o = "$test->{NAME}.mandoc_markdown"; |
|
my $w = "$test->{NAME}.out_markdown"; |
|
if ($targets{markdown} && !$skip_markdown{$test->{NAME}} && |
|
$test->{NAME} =~ /^$onlytest/) { |
$count_markdown++; |
$count_markdown++; |
$count_total++; |
$count_total++; |
print "@mandoc -T markdown $i\n" if $targets{verbose}; |
sysout $o, '../mandoc', @{$test->{MOPTS}}, |
sysout $o, @mandoc, qw(-I os=OpenBSD -T markdown), $i |
qw(-I os=OpenBSD -T markdown), $i |
and fail $subdir, $testname, 'markdown:mandoc'; |
and fail $test->{NAME}, 'markdown:mandoc'; |
system @diff, $w, $o |
system @diff, $w, $o |
and fail $subdir, $testname, 'markdown:diff'; |
and fail $test->{NAME}, 'markdown:diff'; |
|
print "." unless $targets{verbose}; |
} |
} |
if ($targets{clean}) { |
if ($targets{clean}) { |
print "rm $o\n" if $targets{verbose}; |
print "rm $o\n" if $targets{verbose}; |
unlink $o; |
$count_rm += unlink $o; |
} |
} |
} |
} |
|
if ($targets{markdown}) { |
|
print "Number of markdown tests:" if $targets{verbose}; |
|
print " $count_markdown tests run.\n"; |
|
} |
|
|
my $count_lint = 0; |
my $count_lint = 0; |
for my $testname (@lint_testnames) { |
if ($targets{lint}) { |
next if $onlytest && $testname ne $onlytest; |
print "Running lint tests "; |
my $i = "$subdir/$testname.in"; |
print "...\n" if $targets{verbose}; |
my $o = "$subdir/$testname.mandoc_lint"; |
} |
my $w = "$subdir/$testname.out_lint"; |
for my $test (@lint_tests) { |
if ($targets{lint}) { |
my $i = "$test->{NAME}.in"; |
|
my $o = "$test->{NAME}.mandoc_lint"; |
|
my $w = "$test->{NAME}.out_lint"; |
|
if ($targets{lint} && $test->{NAME} =~ /^$onlytest/) { |
$count_lint++; |
$count_lint++; |
$count_total++; |
$count_total++; |
print "@mandoc -T lint -W all $i\n" if $targets{verbose}; |
syslint $o, '../mandoc', @{$test->{MOPTS}}, |
syslint $o, @mandoc, qw(-I os=OpenBSD -T lint -W all), $i |
qw(-I os=OpenBSD -T lint -W all), $i |
and fail $subdir, $testname, 'lint:mandoc'; |
and fail $test->{NAME}, 'lint:mandoc'; |
system @diff, $w, $o |
system @diff, $w, $o |
and fail $subdir, $testname, 'lint:diff'; |
and fail $test->{NAME}, 'lint:diff'; |
|
print "." unless $targets{verbose}; |
} |
} |
if ($targets{clean}) { |
if ($targets{clean}) { |
print "rm $o\n" if $targets{verbose}; |
print "rm $o\n" if $targets{verbose}; |
unlink $o; |
$count_rm += unlink $o; |
} |
} |
} |
} |
|
if ($targets{lint}) { |
exit 0 unless $displaylevel or @failures; |
print "Number of lint tests:" if $targets{verbose}; |
|
print " $count_lint tests run.\n"; |
print "\n" if $targets{verbose}; |
|
if ($onlytest) { |
|
print "test $subdir:$onlytest finished"; |
|
} else { |
|
print "testsuite $subdir finished"; |
|
} |
} |
print ' ', (scalar @subdir_names), ' subdirectories' if @subdir_names; |
|
print " $count_ascii ascii" if $count_ascii; |
|
print " $count_man man" if $count_man; |
|
print " $count_utf8 utf8" if $count_utf8; |
|
print " $count_html html" if $count_html; |
|
print " $count_markdown markdown" if $count_markdown; |
|
print " $count_lint lint" if $count_lint; |
|
|
|
|
# --- final report ----------------------------------------------------- |
|
|
if (@failures) { |
if (@failures) { |
print " (FAIL)\n\nSOME TESTS FAILED:\n\n"; |
print "\nNUMBER OF FAILED TESTS: ", scalar @failures, |
|
" (of $count_total tests run.)\n"; |
print "@$_\n" for @failures; |
print "@$_\n" for @failures; |
print "\n"; |
print "\n"; |
exit 1; |
exit 1; |
} elsif ($count_total == 1) { |
} |
print " (OK)\n"; |
print "\n" if $targets{verbose}; |
|
if ($count_total == 1) { |
|
print "Test succeeded.\n"; |
} elsif ($count_total) { |
} elsif ($count_total) { |
print " (all $count_total tests OK)\n"; |
print "All $count_total tests OK:"; |
|
print " $count_ascii ascii" if $count_ascii; |
|
print " $count_tag tag" if $count_tag; |
|
print " $count_man man" if $count_man; |
|
print " $count_utf8 utf8" if $count_utf8; |
|
print " $count_html html" if $count_html; |
|
print " $count_markdown markdown" if $count_markdown; |
|
print " $count_lint lint" if $count_lint; |
|
print "\n"; |
} else { |
} else { |
print " (no tests run)\n"; |
print "No tests were run.\n"; |
} |
} |
|
if ($targets{clean}) { |
|
if ($count_rm) { |
|
print "Deleted $count_rm test output files.\n"; |
|
print "The tree is now clean.\n"; |
|
} else { |
|
print "No test output files were found.\n"; |
|
print "The tree was already clean.\n"; |
|
} |
|
} |
exit 0; |
exit 0; |