Changeset 275211 in webkit
- Timestamp:
- Mar 30, 2021, 10:13:57 AM (4 years ago)
- Location:
- trunk/Tools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/CISupport/ews-build/steps.py
r274496 r275211 334 334 335 335 336 class CheckPatchRelevance(buildstep.BuildStep): 336 class AnalyzePatch(buildstep.BuildStep): 337 flunkOnFailure = True 338 haltOnFailure = True 339 340 def _get_patch(self): 341 sourcestamp = self.build.getSourceStamp(self.getProperty('codebase', '')) 342 if not sourcestamp or not sourcestamp.patch: 343 return None 344 return sourcestamp.patch[1] 345 346 @defer.inlineCallbacks 347 def _addToLog(self, logName, message): 348 try: 349 log = self.getLog(logName) 350 except KeyError: 351 log = yield self.addLog(logName) 352 log.addStdout(message) 353 354 def getResultSummary(self): 355 if self.results == FAILURE: 356 return {'step': 'Patch doesn\'t have relevant changes'} 357 if self.results == SUCCESS: 358 return {'step': 'Patch contains relevant changes'} 359 return buildstep.BuildStep.getResultSummary(self) 360 361 362 class CheckPatchRelevance(AnalyzePatch): 337 363 name = 'check-patch-relevance' 338 364 description = ['check-patch-relevance running'] 339 365 descriptionDone = ['Patch contains relevant changes'] 340 flunkOnFailure = True341 haltOnFailure = True342 366 343 367 bindings_paths = [ … … 416 440 return False 417 441 418 def _get_patch(self):419 sourcestamp = self.build.getSourceStamp(self.getProperty('codebase', ''))420 if not sourcestamp or not sourcestamp.patch:421 return None422 return sourcestamp.patch[1]423 424 @defer.inlineCallbacks425 def _addToLog(self, logName, message):426 try:427 log = self.getLog(logName)428 except KeyError:429 log = yield self.addLog(logName)430 log.addStdout(message)431 432 442 def start(self): 433 443 patch = self._get_patch() … … 448 458 return None 449 459 450 def getResultSummary(self): 451 if self.results == FAILURE: 452 return {'step': 'Patch doesn\'t have relevant changes'} 453 return super(CheckPatchRelevance, self).getResultSummary() 460 461 class FindModifiedLayoutTests(AnalyzePatch): 462 name = 'find-modified-layout-tests' 463 RE_LAYOUT_TEST = b'^(\+\+\+).*(LayoutTests.*\.html)' 464 DIRECTORIES_TO_IGNORE = ['reference', 'reftest', 'resources', 'support', 'script-tests', 'tools'] 465 SUFFIXES_TO_IGNORE = ['-expected', '-expected-mismatch', '-ref', '-notref'] 466 467 def find_test_names_from_patch(self, patch): 468 tests = [] 469 for line in patch.splitlines(): 470 match = re.search(self.RE_LAYOUT_TEST, line, re.IGNORECASE) 471 if match: 472 if any((suffix + '.html').encode('utf-8') in line for suffix in self.SUFFIXES_TO_IGNORE): 473 continue 474 test_name = match.group(2).decode('utf-8') 475 if any(directory in test_name.split('/') for directory in self.DIRECTORIES_TO_IGNORE): 476 continue 477 tests.append(test_name) 478 return list(set(tests)) 479 480 def start(self): 481 patch = self._get_patch() 482 if not patch: 483 self.finished(SUCCESS) 484 return None 485 486 tests = self.find_test_names_from_patch(patch) 487 488 if tests: 489 self._addToLog('stdio', 'This patch modifies following tests: {}'.format(tests)) 490 self.setProperty('modified_tests', tests) 491 self.finished(SUCCESS) 492 return None 493 494 self._addToLog('stdio', 'This patch does not modify any layout tests') 495 self.finished(FAILURE) 496 self.build.results = SKIPPED 497 self.build.buildFinished(['Patch {} doesn\'t have relevant changes'.format(self.getProperty('patch_id', ''))], SKIPPED) 498 return None 454 499 455 500 -
trunk/Tools/CISupport/ews-build/steps_unittest.py
r274494 r275211 47 47 CompileWebKitWithoutPatch, ConfigureBuild, CreateLocalGITCommit, 48 48 DownloadBuiltProduct, DownloadBuiltProductFromMaster, EWS_BUILD_HOSTNAME, ExtractBuiltProduct, ExtractTestResults, 49 FetchBranches, FindModifiedChangeLogs, InstallGtkDependencies, InstallWpeDependencies, KillOldProcesses,50 PrintConfiguration, PushCommitToWebKitRepo, ReRunAPITests, ReRunJavaScriptCoreTests, ReRunWebKitPerlTests,49 FetchBranches, FindModifiedChangeLogs, FindModifiedLayoutTests, InstallGtkDependencies, InstallWpeDependencies, 50 KillOldProcesses, PrintConfiguration, PushCommitToWebKitRepo, ReRunAPITests, ReRunJavaScriptCoreTests, ReRunWebKitPerlTests, 51 51 ReRunWebKitTests, RunAPITests, RunAPITestsWithoutPatch, RunBindingsTests, RunBuildWebKitOrgUnitTests, 52 52 RunBuildbotCheckConfigForBuildWebKit, RunBuildbotCheckConfigForEWS, RunEWSUnitTests, RunResultsdbpyTests, … … 2635 2635 self.expectOutcome(result=FAILURE, state_string='Patch doesn\'t have relevant changes') 2636 2636 rc = self.runStep() 2637 return rc 2638 2639 2640 class TestFindModifiedLayoutTests(BuildStepMixinAdditions, unittest.TestCase): 2641 def setUp(self): 2642 self.longMessage = True 2643 return self.setUpBuildStep() 2644 2645 def tearDown(self): 2646 return self.tearDownBuildStep() 2647 2648 def test_relevant_patch(self): 2649 self.setupStep(FindModifiedLayoutTests()) 2650 self.assertEqual(FindModifiedLayoutTests.haltOnFailure, True) 2651 self.assertEqual(FindModifiedLayoutTests.flunkOnFailure, True) 2652 FindModifiedLayoutTests._get_patch = lambda x: b'+++ LayoutTests/http/tests/events/device-orientation-motion-insecure-context.html' 2653 self.expectOutcome(result=SUCCESS, state_string='Patch contains relevant changes') 2654 rc = self.runStep() 2655 self.assertEqual(self.getProperty('modified_tests'), ['LayoutTests/http/tests/events/device-orientation-motion-insecure-context.html']) 2656 return rc 2657 2658 def test_ignore_certain_directories(self): 2659 self.setupStep(FindModifiedLayoutTests()) 2660 dir_names = ['reference', 'reftest', 'resources', 'support', 'script-tests', 'tools'] 2661 for dir_name in dir_names: 2662 FindModifiedLayoutTests._get_patch = lambda x: '+++ LayoutTests/{}/test-name.html'.format(dir_name).encode('utf-8') 2663 self.expectOutcome(result=FAILURE, state_string='Patch doesn\'t have relevant changes') 2664 rc = self.runStep() 2665 self.assertEqual(self.getProperty('modified_tests'), None) 2666 return rc 2667 2668 def test_ignore_certain_suffixes(self): 2669 self.setupStep(FindModifiedLayoutTests()) 2670 suffixes = ['-expected', '-expected-mismatch', '-ref', '-notref'] 2671 for suffix in suffixes: 2672 FindModifiedLayoutTests._get_patch = lambda x: '+++ LayoutTests/http/tests/events/device-motion-{}.html'.format(suffix).encode('utf-8') 2673 self.expectOutcome(result=FAILURE, state_string='Patch doesn\'t have relevant changes') 2674 rc = self.runStep() 2675 self.assertEqual(self.getProperty('modified_tests'), None) 2676 return rc 2677 2678 def test_ignore_non_layout_test_in_html_directory(self): 2679 self.setupStep(FindModifiedLayoutTests()) 2680 FindModifiedLayoutTests._get_patch = lambda x: '+++ LayoutTests/html/test.txt'.encode('utf-8') 2681 self.expectOutcome(result=FAILURE, state_string='Patch doesn\'t have relevant changes') 2682 rc = self.runStep() 2683 self.assertEqual(self.getProperty('modified_tests'), None) 2684 return rc 2685 2686 def test_non_relevant_patch(self): 2687 self.setupStep(FindModifiedLayoutTests()) 2688 FindModifiedLayoutTests._get_patch = lambda x: b'Sample patch which does not modify any layout test' 2689 self.expectOutcome(result=FAILURE, state_string='Patch doesn\'t have relevant changes') 2690 rc = self.runStep() 2691 self.assertEqual(self.getProperty('modified_tests'), None) 2637 2692 return rc 2638 2693 -
trunk/Tools/ChangeLog
r275196 r275211 1 2021-03-30 Aakash Jain <aakash_jain@apple.com> 2 3 [ews] Add build step to find list of layout tests modified by a patch 4 https://bugs.webkit.org/show_bug.cgi?id=223890 5 6 Reviewed by Jonathan Bedard. 7 8 * CISupport/ews-build/steps.py: 9 (AnalyzePatch): Created common base class for CheckPatchRelevance and FindModifiedLayoutTests. 10 (AnalyzePatch._get_patch): Moved to base class. 11 (AnalyzePatch._addToLog): Ditto. 12 (AnalyzePatch.getResultSummary): Ditto. 13 (CheckPatchRelevance): 14 (FindModifiedLayoutTests): Build step to find list of layout tests modified by the patch being processed. 15 (FindModifiedLayoutTests.find_test_names_from_patch): 16 (FindModifiedLayoutTests.start): 17 * CISupport/ews-build/steps_unittest.py: Added unit-tests. 18 1 19 2021-03-29 Cameron McCormack <heycam@apple.com> 2 20
Note:
See TracChangeset
for help on using the changeset viewer.