home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 2 / RISC_DISC_2.iso / pd_share / utilities / cli / perl / !Perl / t / TEST < prev   
Encoding:
Text File  |  1995-04-19  |  1.8 KB  |  98 lines

  1. #!./perl
  2.  
  3. # $RCSfile: TEST,v $$Revision: 4.1 $$Date: 92/08/07 18:27:00 $
  4.  
  5. # This is written in a peculiar style, since we're trying to avoid
  6. # most of the constructs we'll be testing for.
  7.  
  8. $| = 1;
  9.  
  10. if ($ARGV[0] eq '-v') {
  11.     $verbose = 1;
  12.     shift;
  13. }
  14.  
  15. chdir 't' if -f 't/TEST';
  16.  
  17. if ($ARGV[0] eq '') {
  18.     @ARGV = split(/[ \n]/,
  19.       `echo base/* comp/* cmd/* io/*; echo op/* lib/*`);
  20. }
  21.  
  22. $bad = 0;
  23. $good = 0;
  24. $total = @ARGV;
  25. while ($test = shift) {
  26.     if ($test =~ /^$/) {
  27.     next;
  28.     }
  29.     $te = $test;
  30.     chop($te);
  31.     print "$te" . '.' x (15 - length($te));
  32.  
  33.     open(script,"$test") || die "Can't run $test.\n";
  34.     $_ = <script>;
  35.     close(script);
  36.     if (/#!..perl(.*)/) {
  37.         $switch = $1;
  38.     } else {
  39.         $switch = '';
  40.     }
  41.     open(results,"./perl$switch $test |") || (print "can't run.\n");
  42.  
  43.     $ok = 0;
  44.     $next = 0;
  45.     while (<results>) {
  46.     if ($verbose) {
  47.         print $_;
  48.     }
  49.     unless (/^#/) {
  50.         if (/^1\.\.([0-9]+)/) {
  51.         $max = $1;
  52.         $totmax += $max;
  53.         $files += 1;
  54.         $next = 1;
  55.         $ok = 1;
  56.         } else {
  57.         $next = $1, $ok = 0, last if /^not ok ([0-9]*)/;
  58.         if (/^ok (.*)/ && $1 == $next) {
  59.             $next = $next + 1;
  60.         } else {
  61.             $ok = 0;
  62.         }
  63.         }
  64.     }
  65.     }
  66.     $next = $next - 1;
  67.     if ($ok && $next == $max) {
  68.     print "ok\n";
  69.     $good = $good + 1;
  70.     } else {
  71.     $next += 1;
  72.     print "FAILED on test $next\n";
  73.     $bad = $bad + 1;
  74.     $_ = $test;
  75.     if (/^base/) {
  76.         die "Failed a basic test--cannot continue.\n";
  77.     }
  78.     }
  79. }
  80.  
  81. if ($bad == 0) {
  82.     if ($ok) {
  83.     print "All tests successful.\n";
  84.     } else {
  85.     die "FAILED--no tests were run for some reason.\n";
  86.     }
  87. } else {
  88.     $pct = sprintf("%.2f", $good / $total * 100);
  89.     if ($bad == 1) {
  90.     warn "Failed 1 test, $pct% okay.\n";
  91.     } else {
  92.     die "Failed $bad/$total tests, $pct% okay.\n";
  93.     }
  94. }
  95. ($user,$sys,$cuser,$csys) = times;
  96. print sprintf("u=%g  s=%g  cu=%g  cs=%g  files=%d  tests=%d\n",
  97.     $user,$sys,$cuser,$csys,$files,$totmax);
  98.