File: filter-test

package info (click to toggle)
aspell 0.60.8.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,336 kB
  • sloc: cpp: 24,378; sh: 12,340; perl: 1,924; ansic: 1,661; makefile: 852; sed: 16
file content (94 lines) | stat: -rwxr-xr-x 1,758 bytes parent folder | download | duplicates (5)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/perl

use strict;
use warnings;
use autodie qw(:all);

my $parms;
my @tests;

if (@ARGV != 1) {
    die("usage $0 <aspell-binary>\n");
}

my $ASPELL=$ARGV[0];

sub sys($) {
    #print "@_\n";
    system "@_";
}

my $passed = 0;
my $failed = 0;
my $skipped = 0;

while (<STDIN>) {
    next if /^\s+$/;
    #print ">>$_";
    if (/^-/) {
        chomp;
        $parms = $_;
        next;
    }
    chomp;
    my $desc = $_;
    my $in = '';
    my $out = '';
    $_ = <STDIN>;
    my $skip = 0;
    if (/^\! (.+)/) {
        die "Unknown directive: $1" unless $1 eq 'SKIP';
        $skip = 1;
        $_ = <STDIN>;
    }
    if (/^-/) {
        my $sep = $_;
        while (<STDIN>) {
            #print ">$sep>$_";
            last if $_ eq $sep;
            $in .= $_;
        }
        while (<STDIN>) {
            last if $_ eq $sep;
            $out .= $_;
        }
    } else {
        $in = $_;
        $out = <STDIN>;
    }
    #print "$parms\n";
    #print ">>>IN>>>\n";
    #print $in;
    #print ">>>OUT>>>\n";
    #print $out;
    #print "^^^^^^^^^\n";

    if ($skip) {
        $skipped++;
        next;
    }

    open F, ">tmp/test-data.in";
    print F $in;
    open F, ">tmp/test-data.expect";
    print F $out;
    eval {
        sys "$ASPELL filter --mode=none $parms < tmp/test-data.in > tmp/test-data.out";
        sys "diff -u -Z tmp/test-data.expect tmp/test-data.out";
    };
    if ($@) {
        $failed++;
        print STDERR "FAILED: $desc: $@\n";
    } else {
        $passed++;
        #print STDERR "passed: $desc\n";
    }
}

if ($failed > 0) {
    printf("FAILED %d/%d tests (%d skipped)\n", $failed, $failed + $passed, $skipped);
    exit 1;
} else {
    printf("all ok (%d skipped)\n", $skipped);
    exit 0;
}