version 1.8, 2017/07/18 18:47:06 |
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 ------------------------------------------------ |
|
|
Line 79 sub syshtml ($@) { |
|
Line 80 sub syshtml ($@) { |
|
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; |
|
|
|
|
my $onlytest = shift // ''; |
my $onlytest = shift // ''; |
for (@ARGV) { |
for (@ARGV) { |
/^(all|ascii|utf8|man|html|markdown|lint|clean|verbose)$/ |
/^(all|ascii|tag|man|utf8|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 |
|
if $targets{all}; |
|
|
|
|
# --- parse Makefiles -------------------------------------------------- |
# --- parse Makefiles -------------------------------------------------- |
Line 151 sub parse_makefile ($%) { |
|
Line 158 sub parse_makefile ($%) { |
|
} |
} |
|
|
my (@regress_tests, @utf8_tests, @lint_tests, @html_tests); |
my (@regress_tests, @utf8_tests, @lint_tests, @html_tests); |
my (%skip_ascii, %skip_man, %skip_markdown); |
my (%tag_tests, %skip_ascii, %skip_man, %skip_markdown); |
foreach my $module (qw(roff char mdoc man tbl eqn)) { |
foreach my $module (qw(roff char mdoc man tbl eqn)) { |
my %modvars; |
my %modvars; |
parse_makefile "$module/Makefile", \%modvars; |
parse_makefile "$module/Makefile", \%modvars; |
Line 159 foreach my $module (qw(roff char mdoc man tbl eqn)) { |
|
Line 166 foreach my $module (qw(roff char mdoc man tbl eqn)) { |
|
my %subvars = (MOPTS => ''); |
my %subvars = (MOPTS => ''); |
parse_makefile "$module/$subdir/Makefile", \%subvars; |
parse_makefile "$module/$subdir/Makefile", \%subvars; |
parse_makefile "$module/Makefile.inc", \%subvars; |
parse_makefile "$module/Makefile.inc", \%subvars; |
|
delete $subvars{GOPTS}; |
delete $subvars{SKIP_GROFF}; |
delete $subvars{SKIP_GROFF}; |
delete $subvars{SKIP_GROFF_ASCII}; |
delete $subvars{SKIP_GROFF_ASCII}; |
delete $subvars{TBL}; |
my @mopts = split ' ', $subvars{MOPTS}; |
delete $subvars{EQN}; |
|
my @mandoc = ('../mandoc', split ' ', $subvars{MOPTS}); |
|
delete $subvars{MOPTS}; |
delete $subvars{MOPTS}; |
my @regress_testnames; |
my @regress_testnames; |
|
if (defined $subvars{TAG_TARGETS}) { |
|
$tag_tests{"$module/$subdir/$_"} = 1 |
|
for split ' ', $subvars{TAG_TARGETS}; |
|
delete $subvars{TAG_TARGETS}; |
|
} |
if (defined $subvars{REGRESS_TARGETS}) { |
if (defined $subvars{REGRESS_TARGETS}) { |
push @regress_testnames, |
push @regress_testnames, |
split ' ', $subvars{REGRESS_TARGETS}; |
split ' ', $subvars{REGRESS_TARGETS}; |
push @regress_tests, { |
push @regress_tests, { |
NAME => "$module/$subdir/$_", |
NAME => "$module/$subdir/$_", |
MANDOC => \@mandoc, |
MOPTS => \@mopts, |
} foreach @regress_testnames; |
} foreach @regress_testnames; |
delete $subvars{REGRESS_TARGETS}; |
delete $subvars{REGRESS_TARGETS}; |
} |
} |
if (defined $subvars{UTF8_TARGETS}) { |
if (defined $subvars{UTF8_TARGETS}) { |
push @utf8_tests, { |
push @utf8_tests, { |
NAME => "$module/$subdir/$_", |
NAME => "$module/$subdir/$_", |
MANDOC => \@mandoc, |
MOPTS => \@mopts, |
} foreach split ' ', $subvars{UTF8_TARGETS}; |
} foreach split ' ', $subvars{UTF8_TARGETS}; |
delete $subvars{UTF8_TARGETS}; |
delete $subvars{UTF8_TARGETS}; |
} |
} |
if (defined $subvars{HTML_TARGETS}) { |
if (defined $subvars{HTML_TARGETS}) { |
push @html_tests, { |
push @html_tests, { |
NAME => "$module/$subdir/$_", |
NAME => "$module/$subdir/$_", |
MANDOC => \@mandoc, |
MOPTS => \@mopts, |
} foreach split ' ', $subvars{HTML_TARGETS}; |
} foreach split ' ', $subvars{HTML_TARGETS}; |
delete $subvars{HTML_TARGETS}; |
delete $subvars{HTML_TARGETS}; |
} |
} |
if (defined $subvars{LINT_TARGETS}) { |
if (defined $subvars{LINT_TARGETS}) { |
push @lint_tests, { |
push @lint_tests, { |
NAME => "$module/$subdir/$_", |
NAME => "$module/$subdir/$_", |
MANDOC => \@mandoc, |
MOPTS => \@mopts, |
} foreach split ' ', $subvars{LINT_TARGETS}; |
} foreach split ' ', $subvars{LINT_TARGETS}; |
delete $subvars{LINT_TARGETS}; |
delete $subvars{LINT_TARGETS}; |
} |
} |
Line 238 foreach my $module (qw(roff char mdoc man tbl eqn)) { |
|
Line 249 foreach my $module (qw(roff char mdoc man tbl eqn)) { |
|
|
|
my $count_total = 0; |
my $count_total = 0; |
my $count_ascii = 0; |
my $count_ascii = 0; |
|
my $count_tag = 0; |
my $count_man = 0; |
my $count_man = 0; |
my $count_rm = 0; |
my $count_rm = 0; |
if ($targets{ascii} || $targets{man}) { |
if ($targets{ascii} || $targets{tag} || $targets{man}) { |
print "Running ascii and man tests "; |
print "Running ascii, tag, and man tests "; |
print "...\n" if $targets{verbose}; |
print "...\n" if $targets{verbose}; |
} |
} |
for my $test (@regress_tests) { |
for my $test (@regress_tests) { |
my $i = "$test->{NAME}.in"; |
my $i = "$test->{NAME}.in"; |
my $o = "$test->{NAME}.mandoc_ascii"; |
my $o = "$test->{NAME}.mandoc_ascii"; |
my $w = "$test->{NAME}.out_ascii"; |
my $w = "$test->{NAME}.out_ascii"; |
if ($targets{ascii} && !$skip_ascii{$test->{NAME}} && |
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/) { |
$test->{NAME} =~ /^$onlytest/) { |
$count_ascii++; |
$count_tag++; |
$count_total++; |
$count_total++; |
sysout $o, @{$test->{MANDOC}}, qw(-I os=OpenBSD -T ascii), $i |
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'; |
and fail $test->{NAME}, 'ascii:mandoc'; |
|
$diff_ascii = 1; |
|
} |
|
if ($diff_ascii) { |
|
$count_ascii++; |
|
$count_total++; |
system @diff, $w, $o |
system @diff, $w, $o |
and fail $test->{NAME}, 'ascii:diff'; |
and fail $test->{NAME}, 'ascii:diff'; |
print "." unless $targets{verbose}; |
print "." unless $targets{verbose}; |
Line 264 for my $test (@regress_tests) { |
|
Line 297 for my $test (@regress_tests) { |
|
$test->{NAME} =~ /^$onlytest/) { |
$test->{NAME} =~ /^$onlytest/) { |
$count_man++; |
$count_man++; |
$count_total++; |
$count_total++; |
sysout $m, @{$test->{MANDOC}}, qw(-I os=OpenBSD -T man), $i |
sysout $m, '../mandoc', @{$test->{MOPTS}}, |
|
qw(-I os=OpenBSD -T man), $i |
and fail $test->{NAME}, 'man:man'; |
and fail $test->{NAME}, 'man:man'; |
sysout $mo, @{$test->{MANDOC}}, |
sysout $mo, '../mandoc', @{$test->{MOPTS}}, |
qw(-man -I os=OpenBSD -T ascii -O mdoc), $m |
qw(-man -I os=OpenBSD -T ascii -O mdoc), $m |
and fail $test->{NAME}, 'man:mandoc'; |
and fail $test->{NAME}, 'man:mandoc'; |
system @diff, $w, $mo |
system @diff, $w, $mo |
Line 274 for my $test (@regress_tests) { |
|
Line 308 for my $test (@regress_tests) { |
|
print "." unless $targets{verbose}; |
print "." unless $targets{verbose}; |
} |
} |
if ($targets{clean}) { |
if ($targets{clean}) { |
print "rm $o $m $mo\n" if $targets{verbose}; |
print "rm $o $to $m $mo\n" if $targets{verbose}; |
$count_rm += unlink $o, $m, $mo; |
$count_rm += unlink $o, $to, $m, $mo; |
} |
} |
} |
} |
if ($targets{ascii} || $targets{man}) { |
if ($targets{ascii} || $targets{tag} || $targets{man}) { |
print "Number of ascii and man tests:" if $targets{verbose}; |
print "Number of ascii, tag, and man tests:" if $targets{verbose}; |
print " $count_ascii + $count_man tests run.\n"; |
print " $count_ascii + $count_tag + $count_man tests run.\n"; |
} |
} |
|
|
my $count_utf8 = 0; |
my $count_utf8 = 0; |
Line 295 for my $test (@utf8_tests) { |
|
Line 329 for my $test (@utf8_tests) { |
|
if ($targets{utf8} && $test->{NAME} =~ /^$onlytest/o) { |
if ($targets{utf8} && $test->{NAME} =~ /^$onlytest/o) { |
$count_utf8++; |
$count_utf8++; |
$count_total++; |
$count_total++; |
sysout $o, @{$test->{MANDOC}}, qw(-I os=OpenBSD -T utf8), $i |
sysout $o, '../mandoc', @{$test->{MOPTS}}, |
|
qw(-I os=OpenBSD -T utf8), $i |
and fail $test->{NAME}, 'utf8:mandoc'; |
and fail $test->{NAME}, 'utf8:mandoc'; |
system @diff, $w, $o |
system @diff, $w, $o |
and fail $test->{NAME}, 'utf8:diff'; |
and fail $test->{NAME}, 'utf8:diff'; |
Line 323 for my $test (@html_tests) { |
|
Line 358 for my $test (@html_tests) { |
|
if ($targets{html} && $test->{NAME} =~ /^$onlytest/) { |
if ($targets{html} && $test->{NAME} =~ /^$onlytest/) { |
$count_html++; |
$count_html++; |
$count_total++; |
$count_total++; |
syshtml $o, @{$test->{MANDOC}}, qw(-T html), $i |
syshtml $o, '../mandoc', @{$test->{MOPTS}}, |
|
qw(-T html), $i |
and fail $test->{NAME}, 'html:mandoc'; |
and fail $test->{NAME}, 'html:mandoc'; |
system @diff, $w, $o |
system @diff, $w, $o |
and fail $test->{NAME}, 'html:diff'; |
and fail $test->{NAME}, 'html:diff'; |
Line 352 for my $test (@regress_tests) { |
|
Line 388 for my $test (@regress_tests) { |
|
$test->{NAME} =~ /^$onlytest/) { |
$test->{NAME} =~ /^$onlytest/) { |
$count_markdown++; |
$count_markdown++; |
$count_total++; |
$count_total++; |
sysout $o, @{$test->{MANDOC}}, |
sysout $o, '../mandoc', @{$test->{MOPTS}}, |
qw(-I os=OpenBSD -T markdown), $i |
qw(-I os=OpenBSD -T markdown), $i |
and fail $test->{NAME}, 'markdown:mandoc'; |
and fail $test->{NAME}, 'markdown:mandoc'; |
system @diff, $w, $o |
system @diff, $w, $o |
Line 381 for my $test (@lint_tests) { |
|
Line 417 for my $test (@lint_tests) { |
|
if ($targets{lint} && $test->{NAME} =~ /^$onlytest/) { |
if ($targets{lint} && $test->{NAME} =~ /^$onlytest/) { |
$count_lint++; |
$count_lint++; |
$count_total++; |
$count_total++; |
syslint $o, @{$test->{MANDOC}}, |
syslint $o, '../mandoc', @{$test->{MOPTS}}, |
qw(-I os=OpenBSD -T lint -W all), $i |
qw(-I os=OpenBSD -T lint -W all), $i |
and fail $test->{NAME}, 'lint:mandoc'; |
and fail $test->{NAME}, 'lint:mandoc'; |
system @diff, $w, $o |
system @diff, $w, $o |
Line 413 if ($count_total == 1) { |
|
Line 449 if ($count_total == 1) { |
|
} elsif ($count_total) { |
} elsif ($count_total) { |
print "All $count_total tests OK:"; |
print "All $count_total tests OK:"; |
print " $count_ascii ascii" if $count_ascii; |
print " $count_ascii ascii" if $count_ascii; |
|
print " $count_tag tag" if $count_tag; |
print " $count_man man" if $count_man; |
print " $count_man man" if $count_man; |
print " $count_utf8 utf8" if $count_utf8; |
print " $count_utf8 utf8" if $count_utf8; |
print " $count_html html" if $count_html; |
print " $count_html html" if $count_html; |
Line 421 if ($count_total == 1) { |
|
Line 458 if ($count_total == 1) { |
|
print "\n"; |
print "\n"; |
} else { |
} else { |
print "No tests were run.\n"; |
print "No tests were run.\n"; |
} |
} |
if ($targets{clean}) { |
if ($targets{clean}) { |
if ($count_rm) { |
if ($count_rm) { |
print "Deleted $count_rm test output files.\n"; |
print "Deleted $count_rm test output files.\n"; |