Changeset 86511 in webkit
- Timestamp:
- May 15, 2011 3:41:22 PM (13 years ago)
- Location:
- trunk/Tools
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r86505 r86511 1 2011-05-15 Sam Weinig <sam@webkit.org> 2 3 Reviewed by David Levin. 4 5 Make API tester more gtest friendly 6 https://bugs.webkit.org/show_bug.cgi?id=60859 7 8 * Scripts/run-api-tests: 9 Numerous changes: 10 - Remove logic to run tests one at a time. 11 - Remove logic to build up a list of tests, instead just pass --gtest_list_tests to 12 the test runner and allow gtest to print it for us. 13 - Forward stdout from the test tool to stdout, even in non-verbose runs. 14 - Run test tool from the current working directory instead of the root webkit 15 directory. 16 17 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 18 Move plist to be with other bundle sources. 19 20 * TestWebKitAPI/TestsController.cpp: 21 (TestWebKitAPI::TestsController::TestsController): 22 (TestWebKitAPI::TestsController::run): 23 * TestWebKitAPI/TestsController.h: 24 * TestWebKitAPI/mac/main.mm: 25 Simplify TestController down to a single run function. We should consider removing the class 26 entirely at some point. 27 1 28 2011-05-15 Sheriff Bot <webkit.review.bot@gmail.com> 2 29 -
trunk/Tools/Scripts/run-api-tests
r86287 r86511 37 37 use lib $FindBin::Bin; 38 38 use webkitdirs; 39 use Term::ANSIColor qw(:constants);40 39 41 sub dumpAllTests(); 42 sub runAllTests(); 43 sub runAllTestsInSuite($); 44 sub runTest($$); 45 sub populateTests(); 40 sub runTestTool(@); 46 41 sub buildTestTool(); 47 42 … … 72 67 buildTestTool(); 73 68 setPathForRunningWebKitApp(\%ENV); 74 my %testsToRun = populateTests();75 69 76 70 if ($dump) { 77 dumpAllTests(); 78 exit 0; 71 my @dumpArguments = ("--gtest_list_tests"); 72 runTestTool(@dumpArguments); 73 exit(0); 79 74 } 80 75 81 run AllTests();76 runTestTool(); 82 77 83 sub dumpAllTests()78 sub runTestTool(@) 84 79 { 85 print "Dumping test cases\n"; 86 print "------------------\n"; 87 for my $suite (keys %testsToRun) { 88 print $suite . ":\n"; 89 print map { " " . $_ . "\n" } @{ $testsToRun{$suite} }; 90 } 91 print "------------------\n"; 92 } 93 94 sub runAllTests() 95 { 96 my $anyFailures = 0; 97 for my $suite (keys %testsToRun) { 98 my $failed = runAllTestsInSuite($suite); 99 if ($failed) { 100 $anyFailures = 1; 101 } 102 } 103 return $anyFailures; 104 } 105 106 sub runAllTestsInSuite($) 107 { 108 my ($suite) = @_; 109 print "Suite: $suite\n"; 110 111 my $anyFailures = 0; 112 for my $test (@{$testsToRun{$suite}}) { 113 my $failed = runTest($suite, $test); 114 if ($failed) { 115 $anyFailures = 1; 116 } 117 } 118 119 return $anyFailures; 120 } 121 122 sub runTest($$) 123 { 124 my ($suite, $testName) = @_; 125 my $test = $suite . "." . $testName; 126 127 print " Test: $testName -> "; 80 my (@arguments) = @_; 128 81 129 82 my $result = 0; … … 136 89 local *DEVNULL; 137 90 my ($childIn, $childOut, $childErr); 91 92 $childOut = ">&STDOUT"; 138 93 unless ($verbose) { 139 94 open(DEVNULL, ">", File::Spec->devnull()) or die "Failed to open /dev/null"; 140 $childOut = ">&DEVNULL";141 95 $childErr = ">&DEVNULL"; 142 96 } else { 143 $childOut = ">&STDOUT";144 97 $childErr = ">&STDERR"; 145 98 } … … 147 100 my $pid; 148 101 if (architecture()) { 149 $pid = open3($childIn, $childOut, $childErr, "arch", "-" . architecture(), $apiTesterPath, $test, @ARGV) or die "Failed to run test: $test.";102 $pid = open3($childIn, $childOut, $childErr, "arch", "-" . architecture(), $apiTesterPath, @arguments, @ARGV) or die "Failed to run test tool."; 150 103 } else { 151 $pid = open3($childIn, $childOut, $childErr, $apiTesterPath, $test, @ARGV) or die "Failed to run test: $test.";104 $pid = open3($childIn, $childOut, $childErr, $apiTesterPath, @arguments, @ARGV) or die "Failed to run test tool."; 152 105 } 153 106 … … 155 108 close($childOut); 156 109 close($childErr); 157 close(DEVNULL) unless ($verbose);110 close(DEVNULL); 158 111 159 112 waitpid($pid, 0); … … 167 120 } 168 121 my $apiTesterPath = File::Spec->catfile(productDir(), "TestWebKitAPI$apiTesterNameSuffix.exe"); 169 $result = system $apiTesterPath, $test,@ARGV;122 $result = system $apiTesterPath, @ARGV; 170 123 } else { 171 124 die "run-api-tests is not supported on this platform.\n" 172 125 } 173 126 174 if ($result == 0) { 175 print BOLD GREEN, "Passed", RESET, "\n"; 176 } else { 177 print BOLD RED, "Failed", RESET, "\n"; 178 } 179 } 180 181 sub populateTests() 182 { 183 my @tests; 184 185 if (isAppleMacWebKit()) { 186 my $productDir = productDir(); 187 $ENV{DYLD_FRAMEWORK_PATH} = $productDir; 188 $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = "YES"; 189 my $apiTesterPath = "$productDir/TestWebKitAPI"; 190 191 local *DEVNULL; 192 my ($childIn, $childOut, $childErr); 193 unless ($verbose) { 194 open(DEVNULL, ">", File::Spec->devnull()) or die "Failed to open /dev/null"; 195 $childErr = ">&DEVNULL"; 196 } else { 197 $childErr = ">&STDERR"; 198 } 199 200 my $pid; 201 if (architecture()) { 202 $pid = open3($childIn, $childOut, $childErr, "arch", "-" . architecture(), $apiTesterPath, "--dump-tests") or die "Failed to build list of tests!"; 203 } else { 204 $pid = open3($childIn, $childOut, $childErr, $apiTesterPath, "--dump-tests") or die "Failed to build list of tests!"; 205 } 206 207 close($childIn); 208 @tests = <$childOut>; 209 close($childOut); 210 close($childErr); 211 close(DEVNULL) unless ($verbose); 212 213 waitpid($pid, 0); 214 my $result = $?; 215 216 if ($result) { 217 print STDERR "Failed to build list of tests!\n"; 218 exit exitStatus($result); 219 } 220 } elsif (isAppleWinWebKit()) { 221 my $apiTesterNameSuffix; 222 if (configurationForVisualStudio() ne "Debug_All") { 223 $apiTesterNameSuffix = ""; 224 } else { 225 $apiTesterNameSuffix = "_debug"; 226 } 227 my $apiTesterPath = File::Spec->catfile(productDir(), "TestWebKitAPI$apiTesterNameSuffix.exe"); 228 open(TESTS, "-|", $apiTesterPath, "--dump-tests") or die $!; 229 @tests = <TESTS>; 230 close(TESTS) or die $!; 231 } else { 232 die "run-api-tests is not supported on this platform.\n" 233 } 234 235 my %keyedTests = (); 236 for my $test (@tests) { 237 $test =~ s/[\r\n]*$//; 238 my ($suite, $testName) = split(/\./, $test); 239 push @{$keyedTests{$suite}}, $testName; 240 } 241 242 return %keyedTests; 127 return $result; 243 128 } 244 129 245 130 sub buildTestTool() 246 131 { 132 my $originalCwd = getcwd(); 133 247 134 chdirWebKit(); 248 135 … … 277 164 exit exitStatus($buildResult); 278 165 } 166 167 chdir $originalCwd; 279 168 } -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r86354 r86511 207 207 08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */, 208 208 1AB674ADFE9D54B511CA2CBB /* Products */, 209 BC575981126E74AF006F0F12 /* InjectedBundle-Info.plist */,210 209 ); 211 210 name = TestWebKitAPI; … … 254 253 isa = PBXGroup; 255 254 children = ( 255 BC575981126E74AF006F0F12 /* InjectedBundle-Info.plist */, 256 256 BC575946126E7351006F0F12 /* InjectedBundleMain.cpp */, 257 257 BC575A9E126E75FB006F0F12 /* InjectedBundleTest.h */, -
trunk/Tools/TestWebKitAPI/TestsController.cpp
r86287 r86511 26 26 #include "TestsController.h" 27 27 28 #include "Test.h"29 #include <assert.h>30 28 #include <gtest/gtest.h> 31 #include <cstdio>32 29 33 30 namespace TestWebKitAPI { … … 41 38 TestsController::TestsController() 42 39 { 43 int argc = 0;44 ::testing::InitGoogleTest(&argc, (char**)0);45 40 } 46 41 47 void TestsController::dumpTestNames()42 bool TestsController::run(int argc, char** argv) 48 43 { 49 ::testing::UnitTest* unit_test = ::testing::UnitTest::GetInstance(); 50 51 for (int i = 0; i < unit_test->total_test_case_count(); i++) { 52 const ::testing::TestCase* test_case = unit_test->GetTestCase(i); 53 for (int j = 0; j < test_case->total_test_count(); j++) { 54 const ::testing::TestInfo* test_info = test_case->GetTestInfo(j); 55 printf("%s.%s\n", test_case->name(), test_info->name()); 56 } 57 } 58 } 59 60 bool TestsController::runTestNamed(const std::string& identifier) 61 { 62 ::testing::GTEST_FLAG(filter) = identifier; 63 return !RUN_ALL_TESTS(); 64 } 65 66 bool TestsController::runAllTests() 67 { 44 ::testing::InitGoogleTest(&argc, argv); 68 45 return !RUN_ALL_TESTS(); 69 46 } -
trunk/Tools/TestWebKitAPI/TestsController.h
r86287 r86511 27 27 #define TestsController_h 28 28 29 #include <map>30 #include <string>31 32 29 namespace TestWebKitAPI { 33 34 class Test;35 30 36 31 class TestsController { … … 38 33 static TestsController& shared(); 39 34 40 void dumpTestNames(); 41 bool runTestNamed(const std::string&); 42 bool runAllTests(); 35 bool run(int argc, char** argv); 43 36 44 37 private: -
trunk/Tools/TestWebKitAPI/mac/main.mm
r86130 r86511 26 26 #import "TestsController.h" 27 27 28 int main(int argc, c onst char* argv[])28 int main(int argc, char** argv) 29 29 { 30 30 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; … … 32 32 [NSApplication sharedApplication]; 33 33 34 bool passed = true; 35 36 std::string argument(argv[1]); 37 if (argument == "--dump-tests") 38 TestWebKitAPI::TestsController::shared().dumpTestNames(); 39 else 40 passed = TestWebKitAPI::TestsController::shared().runTestNamed(argument); 34 bool passed = TestWebKitAPI::TestsController::shared().run(argc, argv); 41 35 42 36 [pool drain];
Note: See TracChangeset
for help on using the changeset viewer.