Changeset 86907 in webkit


Ignore:
Timestamp:
May 19, 2011 5:12:31 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-05-19 Dmitry Lomov <dslomov@google.com>

Reviewed by Adam Roben.

run-api-tests should run one test per process
https://bugs.webkit.org/show_bug.cgi?id=61088

  • Scripts/run-api-tests: Resurrecting the previous revison of this file, with fixes to system call under Windows, return code, and parsing GTest output format.
Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r86887 r86907  
     12011-05-19  Dmitry Lomov  <dslomov@google.com>
     2
     3        Reviewed by Adam Roben.
     4
     5        run-api-tests should run one test per process
     6        https://bugs.webkit.org/show_bug.cgi?id=61088
     7
     8        * Scripts/run-api-tests: Resurrecting the previous revison of this file, with fixes to system call under Windows,
     9        return code, and parsing GTest output format.
     10
    1112011-05-15  Robert Hogan  <robert@webkit.org>
    212
  • trunk/Tools/Scripts/run-api-tests

    r86671 r86907  
    3737use lib $FindBin::Bin;
    3838use webkitdirs;
    39 
    40 sub runTestTool(@);
     39use Term::ANSIColor qw(:constants);
     40
    4141sub buildTestTool();
     42sub dumpAllTests();
     43sub populateTests();
     44sub runAllTests();
     45sub runAllTestsInSuite($);
     46sub runTest($$);
    4247
    4348my $showHelp = 0;
     
    6772buildTestTool();
    6873setPathForRunningWebKitApp(\%ENV);
     74my %testsToRun = populateTests();
    6975
    7076if ($dump) {
    71     my @dumpArguments = ("--gtest_list_tests");
    72     runTestTool(@dumpArguments);
    73     exit(0);
    74 }
    75 
    76 runTestTool();
    77 
    78 sub runTestTool(@)
    79 {
    80     my (@arguments) = @_;
     77    dumpAllTests();
     78    exit 0;
     79}
     80
     81if (runAllTests()) {
     82    exit 1;
     83}
     84
     85sub dumpAllTests()
     86{
     87    print "Dumping test cases\n";
     88    print "------------------\n";
     89    for my $suite (keys %testsToRun) {
     90        print $suite . ":\n";
     91        print map { "   " . $_ . "\n" } @{ $testsToRun{$suite} };
     92    }
     93    print "------------------\n";
     94}
     95
     96sub runAllTests()
     97{
     98    my $anyFailures = 0;
     99    for my $suite (keys %testsToRun) {
     100        my $failed = runAllTestsInSuite($suite);
     101        if ($failed) {
     102            $anyFailures = 1;
     103        }
     104    }
     105    return $anyFailures;
     106}
     107
     108sub runAllTestsInSuite($)
     109{
     110    my ($suite) = @_;
     111    print "Suite: $suite\n";
     112
     113    my $anyFailures = 0;
     114    for my $test (@{$testsToRun{$suite}}) {
     115        my $failed = runTest($suite, $test);
     116        if ($failed) {
     117            $anyFailures = 1;
     118        }
     119    }
     120   
     121    return $anyFailures;
     122}
     123
     124sub runTest($$)
     125{
     126    my ($suite, $testName) = @_;
     127    my $test = $suite . "." . $testName;
     128
     129    my $gtestArg = "--gtest_filter=" . $test;
     130
     131    print "    Test: $testName -> ";
    81132
    82133    my $result = 0;
     
    89140        local *DEVNULL;
    90141        my ($childIn, $childOut, $childErr);
    91 
    92         $childOut = ">&STDOUT";
    93         unless ($verbose) {
     142        if ($verbose) {
     143            $childOut = ">&STDOUT";
     144            $childErr = ">&STDERR";
     145        } else {
    94146            open(DEVNULL, ">", File::Spec->devnull()) or die "Failed to open /dev/null";
     147            $childOut = ">&DEVNULL";
    95148            $childErr = ">&DEVNULL";
    96         } else {
    97             $childErr = ">&STDERR";
    98149        }
    99150
    100151        my $pid;
    101152        if (architecture()) {
    102             $pid = open3($childIn, $childOut, $childErr, "arch", "-" . architecture(), $apiTesterPath, @arguments, @ARGV) or die "Failed to run test tool.";
    103         } else {
    104             $pid = open3($childIn, $childOut, $childErr, $apiTesterPath, @arguments, @ARGV) or die "Failed to run test tool.";
     153            $pid = open3($childIn, $childOut, $childErr, "arch", "-" . architecture(), $apiTesterPath, $gtestArg, @ARGV) or die "Failed to run test: $test.";
     154        } else {
     155            $pid = open3($childIn, $childOut, $childErr, $apiTesterPath, $gtestArg, @ARGV) or die "Failed to run test: $test.";
    105156        }
    106157
     
    108159        close($childOut);
    109160        close($childErr);
    110         close(DEVNULL);
     161        close(DEVNULL) unless ($verbose);
    111162
    112163        waitpid($pid, 0);
     
    120171        }
    121172        my $apiTesterPath = File::Spec->catfile(productDir(), "TestWebKitAPI$apiTesterNameSuffix.exe");
    122         $result = system { $apiTesterPath } $apiTesterPath, @ARGV;
     173        $result = system { $apiTesterPath } $apiTesterPath, $gtestArg, @ARGV;
    123174    } else {
    124175        die "run-api-tests is not supported on this platform.\n"
    125176    }
    126    
     177   
     178    if (!$result) {
     179        print BOLD GREEN, "Passed", RESET, "\n";
     180    } else {
     181        print BOLD RED, "Failed", RESET, "\n";
     182    }
    127183    return $result;
    128184}
     185
     186sub populateTests()
     187{
     188    my @tests;
     189    my $timedOut;
     190
     191    if (isAppleMacWebKit()) {
     192        my $productDir = productDir();
     193        $ENV{DYLD_FRAMEWORK_PATH} = $productDir;
     194        $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = "YES";
     195        my $apiTesterPath = "$productDir/TestWebKitAPI";
     196
     197        local *DEVNULL;
     198        my ($childIn, $childOut, $childErr);
     199        if ($verbose) {
     200            $childErr = ">&STDERR";
     201        } else {
     202            open(DEVNULL, ">", File::Spec->devnull()) or die "Failed to open /dev/null";
     203            $childErr = ">&DEVNULL";
     204        }
     205
     206        my $pid;
     207        if (architecture()) {
     208            $pid = open3($childIn, $childOut, $childErr, "arch", "-" . architecture(), $apiTesterPath, "--gtest_list_tests") or die "Failed to build list of tests!";
     209        } else {
     210            $pid = open3($childIn, $childOut, $childErr, $apiTesterPath, "--gtest_list_tests") or die "Failed to build list of tests!";
     211        }
     212
     213        close($childIn);
     214        @tests = <$childOut>;
     215        close($childOut);
     216        close($childErr);
     217        close(DEVNULL) unless ($verbose);
     218
     219        waitpid($pid, 0);
     220        my $result = $?;
     221
     222        if ($result) {
     223            print STDERR "Failed to build list of tests!\n";
     224            exit exitStatus($result);
     225        }
     226    } elsif (isAppleWinWebKit()) {
     227        my $apiTesterNameSuffix;
     228        if (configurationForVisualStudio() ne "Debug_All") {
     229            $apiTesterNameSuffix = "";
     230        } else {
     231            $apiTesterNameSuffix = "_debug";
     232        }
     233        my $apiTesterPath = File::Spec->catfile(productDir(), "TestWebKitAPI$apiTesterNameSuffix.exe");
     234        open(TESTS, "-|", $apiTesterPath, "--dump-tests") or die $!;
     235        @tests = <TESTS>;
     236        close(TESTS) or die $!;
     237    } else {
     238        die "run-api-tests is not supported on this platform.\n"
     239    }
     240
     241    my %keyedTests = ();
     242    my $suite;
     243    for my $test (@tests) {
     244       $test =~ s/[\r\n]*$//;
     245       if ($test =~ m/\.$/) {
     246          $test =~ s/\.$//;
     247          $suite = $test;
     248       } else {
     249          $test =~ s/^\s*//;
     250          push @{$keyedTests{$suite}}, $test;
     251        }
     252    }
     253 
     254    return %keyedTests;
     255}
     256
    129257
    130258sub buildTestTool()
     
    139267    local *DEVNULL;
    140268    my ($childIn, $childOut, $childErr);
    141     unless ($verbose) {
     269    if ($verbose) {
     270        # When not quiet, let the child use our stdout/stderr.
     271        $childOut = ">&STDOUT";
     272        $childErr = ">&STDERR";
     273    } else {
    142274        open(DEVNULL, ">", File::Spec->devnull()) or die "Failed to open /dev/null";
    143275        $childOut = ">&DEVNULL";
    144276        $childErr = ">&DEVNULL";
    145     } else {
    146         # When not quiet, let the child use our stdout/stderr.
    147         $childOut = ">&STDOUT";
    148         $childErr = ">&STDERR";
    149277    }
    150278
Note: See TracChangeset for help on using the changeset viewer.