gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
MJ compiler jar update
[mjc2wsl.git] / lib / compare-w-wt.pl
1 #!/usr/bin/perl
2 #
3 # test if the outputs are the same from two versions of
4 # WSL programs - the original and the transformation
6 sub read_file($) {
7 my ($file) = @_;
8 my $in;
9 open($in, $file) or die "Cannot read $file: $!\n";
10 my $data = join("", <$in>);
11 close($in);
12 return($data);
13 }
15 # quit unless we have the correct number of command-line args
16 $num_args = $#ARGV + 1;
17 if ($num_args != 2) {
18 print "\nUsage: compare-w-wt.pl directory base_filename \n";
19 exit;
20 }
22 $dir=@ARGV[0];
23 $base=@ARGV[1];
25 $outw = read_file("$dir/$base.outwsl");
26 $outwt = read_file("$dir/$base.outwslt");
28 #print "inputs:\n";
29 #print "$outm\n--\n$outw\n\n";
31 #process the WSL output to remove comments
32 for ($outw, $outwt) {
33 s/^.*Starting Execution...//s;
34 s/^.*?\n.*?\n//s;
35 s/Execution time:.*//s;
36 }
38 if ($outw eq $outwt) {
39 print "$base - OK\n";
40 } else {
41 print "$base - difference detected!:\n";
42 print "$outw###\n--\n$outwt###\n";
43 die();
44 }
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner