=================================================================== RCS file: /cvs/mandoc/regress/regress.pl,v retrieving revision 1.1 retrieving revision 1.4 diff -u -p -r1.1 -r1.4 --- mandoc/regress/regress.pl 2017/02/08 03:02:13 1.1 +++ mandoc/regress/regress.pl 2017/03/05 19:57:39 1.4 @@ -1,6 +1,6 @@ #!/usr/bin/env perl # -# $Id: regress.pl,v 1.1 2017/02/08 03:02:13 schwarze Exp $ +# $Id: regress.pl,v 1.4 2017/03/05 19:57:39 schwarze Exp $ # # Copyright (c) 2017 Ingo Schwarze # @@ -24,6 +24,10 @@ use strict; # nor for piping it into the Perl program. use IPC::Open3 qw(open3); +# Define this at one place such that it can easily be changed +# if diff(1) does not support the -a option. +my @diff = qw(diff -au); + # --- utility functions ------------------------------------------------ sub usage ($) { @@ -109,15 +113,16 @@ for (@ARGV) { $displaylevel = int; next; } - /^(all|ascii|utf8|man|html|lint|clean|verbose)$/ + /^(all|ascii|utf8|man|html|markdown|lint|clean|verbose)$/ or usage "$_: invalid modifier"; $targets{$_} = 1; } $targets{all} = 1 unless $targets{ascii} || $targets{utf8} || $targets{man} || - $targets{html} || $targets{lint} || $targets{clean}; + $targets{html} || $targets{markdown} || + $targets{lint} || $targets{clean}; $targets{ascii} = $targets{utf8} = $targets{man} = $targets{html} = - $targets{lint} = 1 if $targets{all}; + $targets{markdown} = $targets{lint} = 1 if $targets{all}; $displaylevel = 3 if $targets{verbose}; @@ -138,7 +143,7 @@ sub parse_makefile ($) { my $var = $1; my $opt = $2; my $val = $3; - $val =~ s/\${(\w+)}/$vars{$1}/; + $val =~ s/\$\{(\w+)\}/$vars{$1}/; $val = "$vars{$var} $val" if $opt eq '+'; $vars{$var} = $val unless $opt eq '?' && defined $vars{$var}; @@ -156,7 +161,8 @@ if ($subdir eq '.') { my @mandoc = '../mandoc'; my @subdir_names; -my (@regress_testnames, @utf8_testnames, @html_testnames, @lint_testnames); +my (@regress_testnames, @utf8_testnames, @lint_testnames); +my (@html_testnames, @markdown_testnames); my (%skip_ascii, %skip_man); push @mandoc, split ' ', $vars{MOPTS} if $vars{MOPTS}; @@ -181,6 +187,10 @@ if (defined $vars{HTML_TARGETS}) { @html_testnames = split ' ', $vars{HTML_TARGETS}; delete $vars{HTML_TARGETS}; } +if (defined $vars{MARKDOWN_TARGETS}) { + @markdown_testnames = split ' ', $vars{MARKDOWN_TARGETS}; + delete $vars{MARKDOWN_TARGETS}; +} if (defined $vars{LINT_TARGETS}) { @lint_testnames = split ' ', $vars{LINT_TARGETS}; delete $vars{LINT_TARGETS}; @@ -227,7 +237,7 @@ for my $testname (@regress_testnames) { print "@mandoc -T ascii $i\n" if $targets{verbose}; sysout $o, @mandoc, qw(-T ascii), $i and fail $subdir, $testname, 'ascii:mandoc'; - system qw(diff -au), $w, $o + system @diff, $w, $o and fail $subdir, $testname, 'ascii:diff'; } my $m = "$subdir/$testname.in_man"; @@ -241,7 +251,7 @@ for my $testname (@regress_testnames) { print "@mandoc -man -T ascii $m\n" if $targets{verbose}; sysout $mo, @mandoc, qw(-man -T ascii -O mdoc), $m and fail $subdir, $testname, 'man:mandoc'; - system qw(diff -au), $w, $mo + system @diff, $w, $mo and fail $subdir, $testname, 'man:diff'; } if ($targets{clean}) { @@ -266,7 +276,7 @@ for my $testname (@utf8_testnames) { print "@mandoc -T utf8 $i\n" if $targets{verbose}; sysout $o, @mandoc, qw(-T utf8), $i and fail $subdir, $testname, 'utf8:mandoc'; - system qw(diff -au), $w, $o + system @diff, $w, $o and fail $subdir, $testname, 'utf8:diff'; } if ($targets{clean}) { @@ -287,7 +297,7 @@ for my $testname (@html_testnames) { print "@mandoc -T html $i\n" if $targets{verbose}; syshtml $o, @mandoc, qw(-T html), $i and fail $subdir, $testname, 'html:mandoc'; - system qw(diff -au), $w, $o + system @diff, $w, $o and fail $subdir, $testname, 'html:diff'; } if ($targets{clean}) { @@ -296,6 +306,27 @@ for my $testname (@html_testnames) { } } +my $count_markdown = 0; +for my $testname (@markdown_testnames) { + next if $onlytest && $testname ne $onlytest; + my $i = "$subdir/$testname.in"; + my $o = "$subdir/$testname.mandoc_markdown"; + my $w = "$subdir/$testname.out_markdown"; + if ($targets{markdown}) { + $count_markdown++; + $count_total++; + print "@mandoc -T markdown $i\n" if $targets{verbose}; + sysout $o, @mandoc, qw(-T markdown), $i + and fail $subdir, $testname, 'markdown:mandoc'; + system @diff, $w, $o + and fail $subdir, $testname, 'markdown:diff'; + } + if ($targets{clean}) { + print "rm $o\n" if $targets{verbose}; + unlink $o; + } +} + my $count_lint = 0; for my $testname (@lint_testnames) { next if $onlytest && $testname ne $onlytest; @@ -308,7 +339,7 @@ for my $testname (@lint_testnames) { print "@mandoc -T lint $i\n" if $targets{verbose}; syslint $o, @mandoc, qw(-T lint), $i and fail $subdir, $testname, 'lint:mandoc'; - system qw(diff -au), $w, $o + system @diff, $w, $o and fail $subdir, $testname, 'lint:diff'; } if ($targets{clean}) { @@ -330,6 +361,7 @@ 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; if (@failures) {