#!/usr/bin/perl

# This script will run Test::Harness on the tests found under the "t"
# directory.

# First we check to see if we are already in the "t" directory
unless (-d "emaul") {
  # try to move into test directory
  chdir "t" or die "Can't chdir: $!";
  
  # fix all relative library locations
  foreach (@INC) {
    $_ = "../$_" unless m,^/,;
  }
}

# Pick up the library files from the ../blib directory
unshift(@INC, "../blib/lib", "../blib/arch", "..");

use Test::Harness;
$Test::Harness::verbose = shift if $ARGV[0] =~ /^\d+$/ || $ARGV[0] eq "-v";

if (@ARGV) {
  for (@ARGV) {
    if (-d $_) {
      push(@tests, <$_/*.t>);
    } else {
      $_ .= ".t" unless /\.t$/;
      push(@tests, $_);
    }
  }
} else {
  @tests = (<emaul/*.t>, <mbox/*.t>, <maildir/*.t>);
}

runtests @tests;
