home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / PERL4036.ZIP / t / TEST < prev   
Text File  |  1993-02-26  |  2KB  |  103 lines

  1. #!./perl
  2.  
  3. # $RCSfile: TEST,v $$Revision: 4.0.1.1 $$Date: 91/06/07 11:59:30 $
  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.       `ls base/*.t comp/*.t cmd/*.t io/*.t op/*.t lib/*.t`);
  20. }
  21.  
  22. open(CONFIG,"../config.sh");
  23. while (<CONFIG>) {
  24.     if (/sharpbang='(.*)'/) {
  25.     $sharpbang = ($1 eq '#!');
  26.     last;
  27.     }
  28. }
  29. $bad = 0;
  30. while ($test = shift) {
  31.     if ($test =~ /^$/) {
  32.     next;
  33.     }
  34.     $te = $test;
  35.     chop($te);
  36.     print "$te" . '.' x (15 - length($te));
  37.     if ($sharpbang) {
  38.     open(results,"$test|") || (print "can't run.\n");
  39.     } else {
  40.     open(script,"$test") || die "Can't run $test.\n";
  41.     $_ = <script>;
  42.     close(script);
  43.     if (/#!..perl(.*)/) {
  44.         $switch = $1;
  45.     } else {
  46.         $switch = '';
  47.     }
  48.     open(results,"perl$switch $test|") || (print "can't run.\n");
  49.     }
  50.     $ok = 0;
  51.     $next = 0;
  52.     while (<results>) {
  53.     if ($verbose) {
  54.         print $_;
  55.     }
  56.     unless (/^#/) {
  57.         if (/^1\.\.([0-9]+)/) {
  58.         $max = $1;
  59.         $totmax += $max;
  60.         $files += 1;
  61.         $next = 1;
  62.         $ok = 1;
  63.         } else {
  64.         $next = $1, $ok = 0, last if /^not ok ([0-9]*)/;
  65.         if (/^ok (.*)/ && $1 == $next) {
  66.             $next = $next + 1;
  67.         } else {
  68.             $ok = 0;
  69.         }
  70.         }
  71.     }
  72.     }
  73.     $next = $next - 1;
  74.     if ($ok && $next == $max) {
  75.     print "ok\n";
  76.     } else {
  77.     $next += 1;
  78.     print "FAILED on test $next\n";
  79.     $bad = $bad + 1;
  80.     $_ = $test;
  81.     if (/^base/) {
  82.         die "Failed a basic test--cannot continue.\n";
  83.     }
  84.     }
  85. }
  86.  
  87. if ($bad == 0) {
  88.     if ($ok) {
  89.     print "All tests successful.\n";
  90.     } else {
  91.     die "FAILED--no tests were run for some reason.\n";
  92.     }
  93. } else {
  94.     if ($bad == 1) {
  95.     die "Failed 1 test.\n";
  96.     } else {
  97.     die "Failed $bad tests.\n";
  98.     }
  99. }
  100. ($user,$sys,$cuser,$csys) = times;
  101. print sprintf("u=%g  s=%g  cu=%g  cs=%g  files=%d  tests=%d\n",
  102.     $user,$sys,$cuser,$csys,$files,$totmax);
  103.