#!/usr/bin/perl
# Compare all files enlisted in "FILES". Return 1 if everything checks,
# 0 otherwise.
# Part of "NRG Ljubljana".
# Rok Zitko, rok.zitko@ijs.si, Aug, Dec 2006
# $Id: compare 49 2007-03-08 11:11:38Z zitko $

use warnings;
use strict;

my $verbose = 1;

my $error = 0;
my $success = 0;

open(FILES, "<FILES") or die "Can't open FILES\n";

while (<FILES>) {
  chomp;
  my $f = $_;

  # -b : ignore whitespace
  # -I <regex> : ignore changes that just insert or delete lines that match regex.
  # Lines starting with # are ignored (comments!).
#    system("diff -b -I ^# $f $f.test");
    
  if ($verbose == 1) {
     print "$f\n";
  }
  my $return = system("./mycomp.pl $f $f.test");
    
  if ($return != 0) {
      if ($verbose) {
	  print "FAILED - $f\n";
      }
      $error += 1;
  } else {
      $success += 1;
  }
}

if ($error == 0) {
    print "PASSED.\n";
} else {
    print "FAILED. [$success passed, $error failed.]\n";
}

exit($error);
