MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:msvensson Date:October 5 2007 12:42pm
Subject:bk commit into 5.1 tree (msvensson:1.2572) BUG#31400
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of msvensson. When msvensson does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-10-05 14:42:38+02:00, msvensson@shellback.(none) +1 -0
  Bug#31400 mysql-test-run inconvenience problems running a certain test
   - Allow test case names to be specied in various different ways

  mysql-test/lib/mtr_cases.pl@stripped, 2007-10-05 14:42:34+02:00, msvensson@shellback.(none) +83 -63
    Allow test name to be specified in all sorts of ways:
    mysql-test-run alias
    mysql-test-run alias.test
    mysql-test-run main.alias
    mysql-test-run main.alias.test
    mysql-test-run t/alias
    mysql-test-run t/alias.test

diff -Nrup a/mysql-test/lib/mtr_cases.pl b/mysql-test/lib/mtr_cases.pl
--- a/mysql-test/lib/mtr_cases.pl	2007-09-11 15:00:50 +02:00
+++ b/mysql-test/lib/mtr_cases.pl	2007-10-05 14:42:34 +02:00
@@ -48,13 +48,14 @@ sub collect_test_cases ($) {
   {
     # Check that the tests specified was found
     # in at least one suite
-    foreach my $tname ( @::opt_cases )
+    foreach my $test_name_spec ( @::opt_cases )
     {
       my $found= 0;
+      my ($sname, $tname, $extension)= split_testname($test_name_spec);
       foreach my $test ( @$cases )
       {
-	if ( $test->{'name'} eq $tname ||
-	     mtr_match_extension($test->{'name'}, $tname) )
+	# test->{name} is always in suite.name format
+	if ( $test->{name} =~ /.*\.$tname/ )
 	{
 	  $found= 1;
 	}
@@ -144,6 +145,45 @@ sub collect_test_cases ($) {
 
 }
 
+# Valid extensions and their corresonding component id
+my %exts = ( 'test' => 'mysqld',
+	     'imtest' => 'im'
+	   );
+
+
+# Returns (suitename, testname, extension)
+sub split_testname {
+  my ($test_name)= @_;
+
+  # Get rid of directory part and split name on .'s
+  my @parts= split(/\./, basename($test_name));
+
+  if (@parts == 1){
+    # Only testname given, ex: alias
+    return (undef , $parts[0], undef);
+  } elsif (@parts == 2) {
+    # Either testname.test or suite.testname given
+    # Ex. main.alias or alias.test
+
+    if (defined $exts{$parts[1]})
+    {
+      return (undef , $parts[0], $parts[1]);
+    }
+    else
+    {
+      return ($parts[0], $parts[1], undef);
+    }
+
+  } elsif (@parts == 3) {
+    # Fully specified suitename.testname.test
+    # ex main.alias.test
+    return ( $parts[0], $parts[1], $parts[2]);
+  }
+
+  mtr_error("Illegal format of test name: $test_name");
+}
+
+
 sub collect_one_suite($$)
 {
   my $suite= shift;  # Test suite name
@@ -189,77 +229,55 @@ sub collect_one_suite($$)
 
   if ( @::opt_cases )
   {
-    # Collect in specified order, no sort
-    foreach my $tname2 ( @::opt_cases )
+    # Collect in specified order
+    foreach my $test_name_spec ( @::opt_cases )
     {
-      my $tname= $tname2; # Don't modify @::opt_cases !
-      my $elem= undef;
-      my $component_id= undef;
-
-      # Get rid of directory part (path). Leave the extension since it is used
-      # to understand type of the test.
-
-      $tname = basename($tname);
-
-      # Get rid of suite part
-      $tname =~ s/^(.*)\.//;
+      my ($sname, $tname, $extension)= split_testname($test_name_spec);
 
-      # Check if the extenstion has been specified.
-
-      if ( mtr_match_extension($tname, "test") )
-      {
-        $elem= $tname;
-        $tname=~ s/\.test$//;
-        $component_id= 'mysqld';
-      }
-      elsif ( mtr_match_extension($tname, "imtest") )
-      {
-        $elem= $tname;
-        $tname =~ s/\.imtest$//;
-        $component_id= 'im';
-      }
-
-      # If target component is known, check that the specified test case
-      # exists.
-      #
-      # Otherwise, try to guess the target component.
-
-      if ( $component_id )
-      {
-        if ( ! -f "$testdir/$elem")
+      # The test name parts have now been defined
+      #print "  suite_name: $sname\n";
+      #print "  tname:      $tname\n";
+      #print "  extension:  $extension\n";
+
+      # Check cirrect suite if suitename is defined
+      next if (defined $sname and $suite ne $sname);
+
+      my $component_id;
+      if ( defined $extension )
+      {
+	my $full_name= "$testdir/$tname.$extension";
+	# Extension was specified, check if the test exists
+        if ( ! -f $full_name)
         {
-          mtr_error("Test case $tname ($testdir/$elem) is not found");
+	  # This is only an error if suite was specified, otherwise it
+	  # could exist in another suite
+          mtr_error("Test '$full_name' was not found in suite '$sname'")
+	    if $sname;
+
+	  next;
         }
+	$component_id= $exts{$extension};
       }
       else
       {
-        my $mysqld_test_exists = -f "$testdir/$tname.test";
-        my $im_test_exists = -f "$testdir/$tname.imtest";
+	# No extension was specified
+	my ($ext, $component);
+	while (($ext, $component)= each %exts) {
+	  my $full_name= "$testdir/$tname.$ext";
 
-        if ( $mysqld_test_exists and $im_test_exists )
-        {
-          mtr_error("Ambiguous test case name ($tname)");
-        }
-        elsif ( ! $mysqld_test_exists and ! $im_test_exists )
-        {
-	  # Silently skip, could exist in another suite
-	  next;
-        }
-        elsif ( $mysqld_test_exists )
-        {
-          $elem= "$tname.test";
-          $component_id= 'mysqld';
-        }
-        elsif ( $im_test_exists )
-        {
-          $elem= "$tname.imtest";
-          $component_id= 'im';
-        }
+	  if ( ! -f $full_name ) {
+	    next;
+	  }
+	  $component_id= $component;
+	  $extension= $ext;
+	}
+	# Test not found here, could exist in other suite
+	next unless $component_id;
       }
 
       collect_one_test_case($testdir,$resdir,$suite,$tname,
-                            $elem,$cases,\%disabled,$component_id,
-			    $suite_opts);
+                            "$tname.$extension",$cases,\%disabled,
+			    $component_id,$suite_opts);
     }
   }
   else
@@ -319,6 +337,8 @@ sub collect_one_test_case($$$$$$$$$) {
 
   my $path= "$testdir/$elem";
 
+
+  print "collect_one_test_case\n";
   # ----------------------------------------------------------------------
   # Skip some tests silently
   # ----------------------------------------------------------------------
Thread
bk commit into 5.1 tree (msvensson:1.2572) BUG#31400msvensson5 Oct