[webkit-changes] cvs commit: WebKitTools/Scripts run-webkit-tests

Darin darin at opensource.apple.com
Sun Sep 11 02:23:54 PDT 2005


darin       05/09/11 02:23:53

  Modified:    .        ChangeLog
               Scripts  run-webkit-tests
  Log:
          Reviewed by Eric.
  
          * Scripts/run-webkit-tests: Sort tests with a new "pathcmp" function that's better in
          two ways: 1) puts all files in a directory before any files in a subdirectory, and
          2) sort file names with numeric digits in them in a logical way, so test-33 will come
          before test-3.
  
  Revision  Changes    Path
  1.97      +9 -0      WebKitTools/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebKitTools/ChangeLog,v
  retrieving revision 1.96
  retrieving revision 1.97
  diff -u -r1.96 -r1.97
  --- ChangeLog	8 Sep 2005 21:38:10 -0000	1.96
  +++ ChangeLog	11 Sep 2005 09:23:53 -0000	1.97
  @@ -1,3 +1,12 @@
  +2005-09-11  Darin Adler  <darin at apple.com>
  +
  +        Reviewed by Eric.
  +
  +        * Scripts/run-webkit-tests: Sort tests with a new "pathcmp" function that's better in
  +        two ways: 1) puts all files in a directory before any files in a subdirectory, and
  +        2) sort file names with numeric digits in them in a logical way, so test-33 will come
  +        before test-3.
  +
   2005-09-08  Justin Garcia  <justin.garcia at apple.com>
   
           Reviewed by darin
  
  
  
  1.23      +51 -2     WebKitTools/Scripts/run-webkit-tests
  
  Index: run-webkit-tests
  ===================================================================
  RCS file: /cvs/root/WebKitTools/Scripts/run-webkit-tests,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- run-webkit-tests	1 Sep 2005 19:41:24 -0000	1.22
  +++ run-webkit-tests	11 Sep 2005 09:23:53 -0000	1.23
  @@ -126,13 +126,13 @@
               push @tests, $test;
           }
       } elsif (-d "$testDirectory/$test") {
  -        push @tests, map { chomp; s-^$testDirectory/--; $_; } `find -Ls $testDirectory/$test $findArguments`;
  +        push @tests, sort pathcmp map { chomp; s-^$testDirectory/--; $_; } `find -Ls $testDirectory/$test $findArguments`;
       } else {
           print "test $test not found\n";
       }
   }
   if (!$foundTestName) {
  -    @tests = map { chomp; s-^$testDirectory/--; $_; } `find -Ls $testDirectory $findArguments`;
  +    @tests = sort pathcmp map { chomp; s-^$testDirectory/--; $_; } `find -Ls $testDirectory $findArguments`;
   }
   
   die "no tests to run\n" if !@tests;
  @@ -548,3 +548,52 @@
           close LEAKS;
       }
   }
  +
  +# Break up a path into the directory (with slash) and base name.
  +sub splitpath($)
  +{
  +    my ($path) = @_;
  +
  +    return ($1, $2) if $path =~ m|^(.*/)([^/]+)$|;
  +    return ("", $path);
  +}
  +
  +# Sort first by directory, then by file, so all paths in one directory are grouped
  +# rather than being interspersed with items from subdirectories.
  +# Use numericcmp to sort directory and filenames to make order logical.
  +sub pathcmp($$)
  +{
  +    my ($patha, $pathb) = @_;
  +
  +    my ($dira, $namea) = splitpath($patha);
  +    my ($dirb, $nameb) = splitpath($pathb);
  +
  +    return numericcmp($dira, $dirb) if $dira ne $dirb;
  +    return numericcmp($namea, $nameb);
  +}
  +
  +# Sort numeric parts of strings as numbers, other parts as strings.
  +# Makes 1.33 come before 1.3, which is cool.
  +sub numericcmp($$)
  +{
  +    my ($aa, $bb) = @_;
  +
  +    my @a = split /(\d+)/, $aa;
  +    my @b = split /(\d+)/, $bb;
  +
  +    # Compare one chunk at a time.
  +    # Each chunk is either all numeric digits, or all not numeric digits.
  +    while (@a && @b) {
  +	my $a = shift @a;
  +	my $b = shift @b;
  +        
  +        # Use numeric comparison if chunks are non-equal numbers.
  +        return $a <=> $b if $a =~ /^\d/ && $b =~ /^\d/ && $a != $b;
  +
  +        # Use string comparison if chunks are any other kind of non-equal string.
  +        return $a cmp $b if $a ne $b;
  +    }
  +    
  +    # One of the two is now empty; compare lengths for result in this case.
  +    return @a <=> @b;
  +}
  
  
  



More information about the webkit-changes mailing list