-
Notifications
You must be signed in to change notification settings - Fork 6
/
pdmd-spectest.pl
executable file
·69 lines (62 loc) · 1.65 KB
/
pdmd-spectest.pl
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
61
62
63
64
65
66
67
68
69
#!/usr/bin/perl
#
# John Gabriele, 2012
# Distributed under the MIT license. See the LICENSE file
# details.
use Modern::Perl;
use autodie qw/:all/;
if (@ARGV < 1 or @ARGV > 2) {
say "Usage:\n";
say " ./pdmd-spectest <mkdn-impl>";
say " ./pdmd-spectest <mkdn-impl> <particular-test>\n";
say "Where <particular-test> is one of the filenames in";
say "input-md, sans the .md filename extension.";
exit;
}
my $md_processor = $ARGV[0];
print "For Markdown processor: ", `which $md_processor`;
my $specific_test = 0;
if (@ARGV == 2) {
$specific_test = $ARGV[1];
my $fn = "input-md/$specific_test.md";
if (! -e $fn) {
say "Unable to locate $fn file. Exiting.";
exit;
}
}
chdir 'input-md';
sub get_output_for {
my ($md_proc, $fn) = @_;
my $output = `$md_proc $fn`;
$output =~ s/\s+/ /g;
return $output;
}
if ($specific_test) {
my $fn = "$specific_test.md";
say "Checking output for ", $fn;
my $pandoc_output = get_output_for('pandoc', $fn);
my $other_output = get_output_for($md_processor, $fn);
if ($pandoc_output eq $other_output) {
say "OK";
}
else {
say "Not the same. Here are both outputs (pandoc first):";
say $pandoc_output;
say $other_output;
}
}
else {
for my $fn (glob '*.md') {
my $pandoc_output = get_output_for('pandoc', $fn);
my $other_output = get_output_for($md_processor, $fn);
my $fn2 = $fn;
$fn2 =~ s/\.md$//;
print $fn2, " ...\t";
if ($pandoc_output eq $other_output) {
say "OK";
}
else {
say "-- not the same --";
}
}
}