| 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 $bpath = $ARGV[0]; |
| 11 |
my $binary = $bpath."cg-proc"; |
| 12 |
my $compiler = $bpath."cg-comp"; |
| 13 |
|
| 14 |
`"$compiler" grammar.cg3 grammar.bin >stdout.txt 2>stderr.txt`; |
| 15 |
`"$binary" -d grammar.bin input.txt output.txt >>stdout.txt 2>>stderr.txt`; |
| 16 |
`diff -B expected.txt output.txt >diff.txt`; |
| 17 |
|
| 18 |
if (-s "diff.txt") { |
| 19 |
print STDERR "Fail\n"; |
| 20 |
} else { |
| 21 |
print STDERR "Success\n"; |
| 22 |
} |