소스 검색

Enable tests in tests/ subdirs

Thomas Guyot-Sionnest 12 년 전
부모
커밋
1368b561c6
2개의 변경된 파일29개의 추가작업 그리고 17개의 파일을 삭제
  1. 21 12
      NPTest.pm
  2. 8 5
      plugins/tests/check_procs.t

+ 21 - 12
NPTest.pm

@@ -494,26 +494,35 @@ sub SetCacheFilename
 
 
 sub DetermineTestHarnessDirectory
 sub DetermineTestHarnessDirectory
 {
 {
-  my( $userSupplied ) = @_;
+  my( @userSupplied ) = @_;
+  my @dirs;
 
 
   # User Supplied
   # User Supplied
-  if ( defined( $userSupplied ) && $userSupplied )
+  if ( @userSupplied > 0 )
   {
   {
-    if ( -d $userSupplied )
+    for my $u ( @userSupplied )
     {
     {
-      return $userSupplied;
-    }
-    else
-    {
-      return undef; # userSupplied is invalid -> FAIL
+      if ( -d $u )
+      {
+        push ( @dirs, $u );
+      }
     }
     }
   }
   }
 
 
-  # Simple Case : "t" is a subdirectory of the current directory
+  # Simple Cases: "t" and tests are subdirectories of the current directory
   if ( -d "./t" )
   if ( -d "./t" )
   {
   {
-    return "./t";
+    push ( @dirs, "./t");
   }
   }
+  if ( -d "./tests" )
+  {
+    push ( @dirs, "./tests");
+  }
+
+	if ( @dirs > 0 )
+	{
+		return @dirs;
+	}
 
 
   # To be honest I don't understand which case satisfies the
   # To be honest I don't understand which case satisfies the
   # original code in test.pl : when $tstdir == `pwd` w.r.t.
   # original code in test.pl : when $tstdir == `pwd` w.r.t.
@@ -526,7 +535,7 @@ sub DetermineTestHarnessDirectory
 
 
   if ( $pwd =~ m|/t$| )
   if ( $pwd =~ m|/t$| )
   {
   {
-    return $pwd;
+    push ( @dirs, $pwd );
 
 
     # The alternate that might work better is
     # The alternate that might work better is
     # chdir( ".." );
     # chdir( ".." );
@@ -535,7 +544,7 @@ sub DetermineTestHarnessDirectory
     # to be tested is in the current directory (ie "./check_disk ....")
     # to be tested is in the current directory (ie "./check_disk ....")
   }
   }
 
 
-  return undef;
+  return @dirs;
 }
 }
 
 
 sub TestsFrom
 sub TestsFrom

+ 8 - 5
plugins/tests/check_procs.t

@@ -9,9 +9,9 @@ use Getopt::Long;
 
 
 use NPTest qw(DetermineTestHarnessDirectory TestsFrom);
 use NPTest qw(DetermineTestHarnessDirectory TestsFrom);
 
 
-my $tstdir;
+my @tstdir;
 
 
-if ( ! GetOptions( "testdir:s" => \$tstdir ) )
+if ( ! GetOptions( "testdir:s" => \@tstdir ) )
 {
 {
   print "Usage: ${0} [--testdir=<directory>] [<test_harness.t> ...]\n";
   print "Usage: ${0} [--testdir=<directory>] [<test_harness.t> ...]\n";
   exit 1;
   exit 1;
@@ -25,15 +25,18 @@ if ( scalar( @ARGV ) )
 }
 }
 else
 else
 {
 {
-  my $directory = DetermineTestHarnessDirectory( $tstdir );
+  my @directory = DetermineTestHarnessDirectory( @tstdir );
 
 
-  if ( !defined( $directory ) )
+  if ( @directory == 0 )
   {
   {
     print STDERR "$0: Unable to determine the test harness directory - ABORTING\n";
     print STDERR "$0: Unable to determine the test harness directory - ABORTING\n";
     exit 2;
     exit 2;
   }
   }
 
 
-  @tests = TestsFrom( $directory, 1 );
+  for my $d ( @directory )
+  {
+    push (@tests, TestsFrom( $d, 1 ));
+  }
 }
 }
 
 
 if ( ! scalar( @tests ) )
 if ( ! scalar( @tests ) )