Debian Codegraph @

test/T_RelabelList_Apertium/run.pl

raw
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4 use Cwd qw(realpath);
5
6 my ($bindir, $sep) = $0 =~ /^(.*)(\\|\/).*/;
7 $bindir = realpath $bindir;
8 chdir $bindir or die("Error: Could not change directory to $bindir !");
9
10 my $binary_comp = $ARGV[0];
11 $binary_comp =~ s@/vislcg3([^/]*)$@/cg-comp$1@;
12 if (!$binary_comp || $binary_comp eq '' || !(-x $binary_comp)) {
13 die("Error: $binary_comp is not executable!");
14 }
15
16 my $binary_relabel = $ARGV[0];
17 $binary_relabel =~ s@/vislcg3([^/]*)$@/cg-relabel$1@;
18 if (!$binary_relabel || $binary_relabel eq '' || !(-x $binary_relabel)) {
19 die("Error: $binary_relabel is not executable!");
20 }
21
22 my $binary_proc = $ARGV[0];
23 $binary_proc =~ s@/vislcg3([^/]*)$@/cg-proc$1@;
24 if (!$binary_proc || $binary_proc eq '' || !(-x $binary_proc)) {
25 die("Error: $binary_proc is not executable!");
26 }
27
28 my @unlinks = (
29 'grammar.cg3b',
30 'grammar-out.cg3b',
31 );
32 for my $u (@unlinks) {
33 if (-e $u) {
34 unlink $u;
35 }
36 }
37
38 my $bad = 0;
39
40 `"$binary_comp" grammar.cg3 grammar.cg3b >stdout.txt 2>stderr.txt`;
41 `"$binary_relabel" grammar.cg3b relabel.cg3r grammar-out.cg3b >>stdout.txt 2>>stderr.txt`;
42
43 if (-s "grammar.cg3b" && -s "grammar-out.cg3b") {
44 print STDERR "Success ";
45 } else {
46 print STDERR "Fail ";
47 $bad = 1;
48 }
49
50 `"$binary_proc" grammar-out.cg3b input.txt output.txt 2>>stderr.txt`;
51 `diff -B expected.txt output.txt >diff.txt`;
52
53 if (-s "diff.txt") {
54 print STDERR "Fail\n";
55 $bad = 1;
56 } else {
57 print STDERR "Success\n";
58 }
59
60 exit($bad);