Changeset 285132 in webkit
- Timestamp:
- Nov 1, 2021, 2:30:38 PM (5 years ago)
- Location:
- trunk/Tools
- Files:
-
- 9 edited
-
ChangeLog (modified) (1 diff)
-
Scripts/webkitpy/layout_tests/controllers/single_test_runner.py (modified) (2 diffs)
-
Scripts/webkitpy/layout_tests/run_webkit_tests.py (modified) (1 diff)
-
Scripts/webkitpy/port/driver.py (modified) (3 diffs)
-
TestRunnerShared/TestCommand.cpp (modified) (1 diff)
-
TestRunnerShared/TestCommand.h (modified) (1 diff)
-
TestRunnerShared/TestFeatures.cpp (modified) (3 diffs)
-
TestRunnerShared/TestFeatures.h (modified) (1 diff)
-
WebKitTestRunner/TestController.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r285131 r285132 1 2021-11-01 Tim Horton <timothy_horton@apple.com> 2 3 Add a run-webkit-tests mode to A/B test a given feature 4 https://bugs.webkit.org/show_bug.cgi?id=232553 5 6 Reviewed by Jonathan Bedard. 7 8 Add the argument --self-compare-with-header to run-webkit-tests, which 9 can be used to test the impact of a given feature (or set of features; 10 it accepts the standard test features header format). 11 12 When tests are run in this mode, all tests are run in the ref-test 13 style, but with the `expected` and `actual` results loading the same 14 test file (ignoring the usual -expected.html or whatever); they differ 15 only in the set of features/preferences enabled. 16 17 This is especially useful for testing the impact of e.g. platform 18 graphics features, where the difference between the shipping behavior 19 and in-development behavior is more interesting than whether or not 20 it actually makes the tests, as written, fail. 21 22 * Scripts/webkitpy/layout_tests/controllers/single_test_runner.py: 23 (SingleTestRunner): 24 (SingleTestRunner._run_comparison_test): 25 Add the comparison test runner, and prefer it if requested. 26 27 One note here: the run with the options derived from the given header is 28 considered the "actual" result and the default configuration the "expected". 29 30 * Scripts/webkitpy/layout_tests/run_webkit_tests.py: 31 (parse_args): 32 * Scripts/webkitpy/port/driver.py: 33 (DriverInput.__init__): 34 (DriverInput.__repr__): 35 (Driver._command_from_driver_input): 36 Pass the comparison test header along to the test runner. 37 38 Also, fix a longstanding error where --dump-jsconsolelog-in-stderr 39 could get inserted immediately after --pixel-test, causing the test runner 40 to consume it as the expected image hash! And leave a comment so nobody 41 else has to debug this again... 42 43 * TestRunnerShared/TestCommand.cpp: 44 (WTR::parseInputLine): 45 * TestRunnerShared/TestCommand.h: 46 * TestRunnerShared/TestFeatures.cpp: 47 (WTR::parseTestHeaderString): 48 (WTR::parseTestHeader): 49 (WTR::featureDefaultsFromComparisonTestHeader): 50 Factor out the parsing of the part of the test header inside the [ ], 51 since we use this format for the value of --self-compare-with-header as well. 52 53 * TestRunnerShared/TestFeatures.h: 54 * WebKitTestRunner/Options.h: 55 * WebKitTestRunner/TestController.cpp: 56 (WTR::TestController::testOptionsForTest const): 57 Merge the comparison header's options in to the test options before 58 the test's own header, so that the comparison header wins. 59 1 60 2021-11-01 Jonathan Bedard <jbedard@apple.com> 2 61 -
trunk/Tools/Scripts/webkitpy/layout_tests/controllers/single_test_runner.py
r284987 r285132 112 112 113 113 def run(self): 114 self_comparison_header = self._port.get_option('self_compare_with_header') 115 if self_comparison_header: 116 return self._run_self_comparison_test(self_comparison_header) 114 117 if self._reference_files: 115 118 if self._port.get_option('no_ref_tests') or self._options.reset_results: … … 337 340 return TestResult(self._test_input, test_result.failures, total_test_time + test_result.test_run_time, test_result.has_stderr, reftest_type=reftest_type, pid=test_result.pid, references=reference_test_names) 338 341 342 def _run_self_comparison_test(self, header): 343 driver_input = self._driver_input() 344 driver_input.should_run_pixel_test = True 345 346 reference_output = self._driver.run_test(driver_input, self._stop_when_done) 347 driver_input.self_comparison_header = header 348 test_output = self._driver.run_test(driver_input, self._stop_when_done) 349 350 test_full_path = self._port.abspath_for_test(self._test_name) 351 test_result = self._compare_output_with_reference(reference_output, test_output, test_full_path, False) 352 353 assert(reference_output) 354 test_result_writer.write_test_result(self._filesystem, self._port, self._results_directory, self._test_name, test_output, reference_output, test_result.failures) 355 return TestResult(self._test_input, test_result.failures, test_result.test_run_time, test_result.has_stderr, pid=test_result.pid) 356 339 357 @staticmethod 340 358 def _relative_reference_path(test_full_path, reference_full_path): -
trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py
r281649 r285132 344 344 "--prefer-integrated-gpu", action="store_true", default=False, 345 345 help=("Prefer using the lower-power integrated GPU on a dual-GPU system. Note that other running applications and the tests themselves can override this request.")), 346 optparse.make_option('--show-window', action="store_true", default=False, help="Make the test runner window visible during testing."), 346 optparse.make_option("--show-window", action="store_true", default=False, help="Make the test runner window visible during testing."), 347 optparse.make_option("--self-compare-with-header", help="Run all tests as A/B tests between the default configuration and the given test features header (ignoring expected results)."), 347 348 ])) 348 349 -
trunk/Tools/Scripts/webkitpy/port/driver.py
r282347 r285132 47 47 48 48 class DriverInput(object): 49 def __init__(self, test_name, timeout, image_hash, should_run_pixel_test, should_dump_jsconsolelog_in_stderr=None, args=None ):49 def __init__(self, test_name, timeout, image_hash, should_run_pixel_test, should_dump_jsconsolelog_in_stderr=None, args=None, self_comparison_header=None): 50 50 self.test_name = test_name 51 51 self.timeout = timeout # in ms … … 54 54 self.should_dump_jsconsolelog_in_stderr = should_dump_jsconsolelog_in_stderr 55 55 self.args = args or [] 56 self.self_comparison_header = self_comparison_header 56 57 57 58 def __repr__(self): 58 return "DriverInput(test_name='{}', timeout={}, image_hash={}, should_run_pixel_test={}, should_dump_jsconsolelog_in_stderr={} '".format(self.test_name, self.timeout, self.image_hash, self.should_run_pixel_test, self.should_dump_jsconsolelog_in_stderr)59 return "DriverInput(test_name='{}', timeout={}, image_hash={}, should_run_pixel_test={}, should_dump_jsconsolelog_in_stderr={}, self_comparison_header={}'".format(self.test_name, self.timeout, self.image_hash, self.should_run_pixel_test, self.should_dump_jsconsolelog_in_stderr, self.self_comparison_header) 59 60 60 61 … … 632 633 if self._port.supports_per_test_timeout(): 633 634 command += "'--timeout'%s" % driver_input.timeout 635 if driver_input.should_dump_jsconsolelog_in_stderr: 636 command += "'--dump-jsconsolelog-in-stderr" 637 if driver_input.self_comparison_header: 638 command += "'--self-compare-with-header'%s" % driver_input.self_comparison_header 639 640 # --pixel-test must be the last argument, because the hash is optional, 641 # and any argument put in its place will be incorrectly consumed as the hash. 634 642 if driver_input.should_run_pixel_test: 635 643 command += "'--pixel-test" 636 if driver_input.should_dump_jsconsolelog_in_stderr: 637 command += "'--dump-jsconsolelog-in-stderr" 638 if driver_input.image_hash: 639 command += "'" + driver_input.image_hash 644 if driver_input.image_hash: 645 command += "'" + driver_input.image_hash 640 646 return command + "\n" 641 647 -
trunk/Tools/TestRunnerShared/TestCommand.cpp
r277317 r285132 99 99 if (tokenizer.hasNext()) 100 100 result.expectedPixelHash = tokenizer.next(); 101 } else if (arg == "--self-compare-with-header") { 102 if (tokenizer.hasNext()) 103 result.selfComparisonHeader = tokenizer.next(); 104 else 105 die(inputLine); 101 106 } else if (arg == std::string("--dump-jsconsolelog-in-stderr")) 102 107 result.dumpJSConsoleLogInStdErr = true; -
trunk/Tools/TestRunnerShared/TestCommand.h
r268370 r285132 36 36 std::filesystem::path absolutePath; 37 37 std::string expectedPixelHash; 38 std::string selfComparisonHeader; 38 39 WTF::Seconds timeout; 39 40 bool shouldDumpPixels { false }; -
trunk/Tools/TestRunnerShared/TestFeatures.cpp
r278540 r285132 244 244 } 245 245 246 static TestFeatures parseTestHeader (std::filesystem::path path, const std::unordered_map<std::string, TestHeaderKeyType>& keyTypeMap)246 static TestFeatures parseTestHeaderString(const std::string& pairString, std::filesystem::path path, const std::unordered_map<std::string, TestHeaderKeyType>& keyTypeMap) 247 247 { 248 248 TestFeatures features; 249 std::error_code ec; 250 if (!std::filesystem::exists(path, ec)) 251 return features; 252 253 std::ifstream file(path); 254 if (!file.good()) { 255 LOG_ERROR("Could not open file to inspect test headers in %s", path.c_str()); 256 return features; 257 } 258 259 std::string options; 260 getline(file, options); 261 std::string beginString("webkit-test-runner [ "); 262 std::string endString(" ]"); 263 size_t beginLocation = options.find(beginString); 264 if (beginLocation == std::string::npos) 265 return features; 266 size_t endLocation = options.find(endString, beginLocation); 267 if (endLocation == std::string::npos) { 268 LOG_ERROR("Could not find end of test header in %s", path.c_str()); 269 return features; 270 } 271 std::string pairString = options.substr(beginLocation + beginString.size(), endLocation - (beginLocation + beginString.size())); 249 272 250 size_t pairStart = 0; 273 251 while (pairStart < pairString.size()) { … … 292 270 } 293 271 272 static TestFeatures parseTestHeader(std::filesystem::path path, const std::unordered_map<std::string, TestHeaderKeyType>& keyTypeMap) 273 { 274 std::error_code ec; 275 if (!std::filesystem::exists(path, ec)) 276 return { }; 277 278 std::ifstream file(path); 279 if (!file.good()) { 280 LOG_ERROR("Could not open file to inspect test headers in %s", path.c_str()); 281 return { }; 282 } 283 284 std::string options; 285 getline(file, options); 286 std::string beginString("webkit-test-runner [ "); 287 std::string endString(" ]"); 288 size_t beginLocation = options.find(beginString); 289 if (beginLocation == std::string::npos) 290 return { }; 291 size_t endLocation = options.find(endString, beginLocation); 292 if (endLocation == std::string::npos) { 293 LOG_ERROR("Could not find end of test header in %s", path.c_str()); 294 return { }; 295 } 296 std::string pairString = options.substr(beginLocation + beginString.size(), endLocation - (beginLocation + beginString.size())); 297 return parseTestHeaderString(pairString, path, keyTypeMap); 298 } 299 294 300 TestFeatures featureDefaultsFromTestHeaderForTest(const TestCommand& command, const std::unordered_map<std::string, TestHeaderKeyType>& keyTypeMap) 295 301 { … … 297 303 } 298 304 299 } 305 TestFeatures featureDefaultsFromSelfComparisonHeader(const TestCommand& command, const std::unordered_map<std::string, TestHeaderKeyType>& keyTypeMap) 306 { 307 if (command.selfComparisonHeader.empty()) 308 return { }; 309 return parseTestHeaderString(command.selfComparisonHeader, command.absolutePath, keyTypeMap); 310 } 311 312 } // namespace WTF -
trunk/Tools/TestRunnerShared/TestFeatures.h
r269390 r285132 70 70 }; 71 71 TestFeatures featureDefaultsFromTestHeaderForTest(const TestCommand&, const std::unordered_map<std::string, TestHeaderKeyType>&); 72 TestFeatures featureDefaultsFromSelfComparisonHeader(const TestCommand&, const std::unordered_map<std::string, TestHeaderKeyType>&); 72 73 73 74 } -
trunk/Tools/WebKitTestRunner/TestController.cpp
r284610 r285132 1312 1312 merge(features, hardcodedFeaturesBasedOnPathForTest(command)); 1313 1313 merge(features, platformSpecificFeatureDefaultsForTest(command)); 1314 merge(features, featureDefaultsFromSelfComparisonHeader(command, TestOptions::keyTypeMapping())); 1314 1315 merge(features, featureDefaultsFromTestHeaderForTest(command, TestOptions::keyTypeMapping())); 1315 1316 merge(features, platformSpecificFeatureOverridesDefaultsForTest(command));
Note:
See TracChangeset
for help on using the changeset viewer.