Debian Codegraph @

test/T_SubReadings_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_proc = $ARGV[0];
17 $binary_proc =~ s@/vislcg3([^/]*)$@/cg-proc$1@;
18 if (!$binary_proc || $binary_proc eq '' || !(-x $binary_proc)) {
19 die("Error: $binary_proc is not executable!");
20 }
21
22 my $bad = 0;
23
24 `"$binary_comp" grammar.cg3 grammar.cg3b >stdout.txt 2>stderr.txt`;
25
26 if (-s "grammar.cg3b") {
27 print STDERR "Success ";
28 } else {
29 print STDERR "Fail ";
30 $bad = 1;
31 }
32
33 `"$binary_proc" grammar.cg3b input.txt output.txt >>stdout.txt 2>>stderr.txt`;
34 `diff -B expected.txt output.txt >diff.txt`;
35
36 if (-s "diff.txt") {
37 print STDERR "Fail\n";
38 $bad = 1;
39 } else {
40 print STDERR "Success\n";
41 }
42
43 exit($bad);