def test_is_wpt_notify_enabled_error(self): self.host.executive = MockExecutive(output='error') extractor = DirectoryOwnersExtractor(self.host) self.assertFalse( extractor.is_wpt_notify_enabled(ABS_WPT_BASE + '/foo/DIR_METADATA'))
def setUp(self): # We always have an OWNERS file at web_tests/external. self.filesystem = MockFileSystem(files={ MOCK_WEB_TESTS + 'external/OWNERS': '*****@*****.**' }) self.extractor = DirectoryOwnersExtractor(self.filesystem)
def setUp(self): # We always have an OWNERS file at LayoutTests/external. self.filesystem = MockFileSystem( files={ '/mock-checkout/third_party/WebKit/LayoutTests/external/OWNERS': '*****@*****.**' }) self.extractor = DirectoryOwnersExtractor(self.filesystem)
def __init__(self, host, chromium_git, local_wpt): self.host = host self.git = chromium_git self.local_wpt = local_wpt self.default_port = host.port_factory.get() self.finder = PathFinder(host.filesystem) self.owners_extractor = DirectoryOwnersExtractor(host.filesystem) self.new_failures_by_directory = defaultdict(list)
def test_extract_component_with_dir_metadata(self): data = ( '{"dirs":{"a/b":{"monorail":' '{"component":"foo"},"teamEmail":"bar","wpt":{"notify":"YES"}}}}') self.host.executive = MockExecutive(output=data) extractor = DirectoryOwnersExtractor(self.host) self.assertEqual( extractor.extract_component(MOCK_WEB_TESTS + 'a/b/OWNERS'), 'foo')
def test_extract_component(self): data = ( '{"dirs":{"third_party/blink/web_tests/a/b":{"monorail":' '{"component":"foo"},"teamEmail":"bar","wpt":{"notify":"YES"}}}}') self.host.executive = MockExecutive(output=data) extractor = DirectoryOwnersExtractor(self.host) self.assertEqual( extractor.extract_component(MOCK_WEB_TESTS + 'a/b/DIR_METADATA'), 'foo')
def test_is_wpt_notify_enabled_false(self): data = ( '{"dirs":{"third_party/blink/web_tests/a/b":{"monorail":' '{"component":"foo"},"teamEmail":"bar","wpt":{"notify":"NO"}}}}') self.host.executive = MockExecutive(output=data) extractor = DirectoryOwnersExtractor(self.host) self.assertFalse( extractor.is_wpt_notify_enabled(MOCK_WEB_TESTS + 'a/b/DIR_METADATA'))
def test_is_wpt_notify_enabled_true(self): data = ( '{"dirs":{"a/b":{"monorail":' '{"component":"foo"},"teamEmail":"bar","wpt":{"notify":"YES"}}}}') self.host.executive = MockExecutive(output=data) extractor = DirectoryOwnersExtractor(self.host) self.assertTrue( extractor.is_wpt_notify_enabled(MOCK_WEB_TESTS + 'a/b/DIR_METADATA'))
def test_is_wpt_notify_enabled_with_dir_metadata_none(self): self.host.filesystem.files = { ABS_WPT_BASE + '/foo/OWNERS': '# COMPONENT: Blink>Layout\n' '# WPT-NOTIFY: true\n' } self.host.executive = MockExecutive(output='error') extractor = DirectoryOwnersExtractor(self.host) self.assertTrue( extractor.is_wpt_notify_enabled(ABS_WPT_BASE + '/foo/OWNERS'))
def test_read_dir_metadata_none(self): self.host.executive = MockExecutive(output='error') extractor = DirectoryOwnersExtractor(self.host) wpt_dir_metadata = extractor._read_dir_metadata(MOCK_WEB_TESTS + 'a/b/OWNERS') self.assertEqual( self.host.executive.full_calls[0].args, ['dirmd', 'read', '-form', 'sparse', MOCK_WEB_TESTS + 'a/b']) self.assertEqual(wpt_dir_metadata, None)
def __init__(self, host, chromium_git, local_wpt): self.host = host self.git = chromium_git self.local_wpt = local_wpt self._monorail_api = MonorailAPI self.default_port = host.port_factory.get() self.finder = PathFinder(host.filesystem) self.owners_extractor = DirectoryOwnersExtractor(host) self.new_failures_by_directory = defaultdict(list) self.components_for_product = {ANDROID_WEBLAYER: ["Internals>WebLayer"]} self.labels_for_product = { ANDROID_WEBLAYER: ["Project-WebLayer-WebPlatformSupport", "WL-WPT-Compat"] }
def test_is_wpt_notify_enabled_with_dir_metadata(self): self.host.filesystem.files = { ABS_WPT_BASE + '/foo/OWNERS': '# TEAM: [email protected]\n' '# COMPONENT: Blink>Layout\n' '# WPT-NOTIFY: true\n' } data = ( '{"dirs":{"a/b":{"monorail":' '{"component":"foo"},"teamEmail":"bar","wpt":{"notify":"YES"}}}}') self.host.executive = MockExecutive(output=data) extractor = DirectoryOwnersExtractor(self.host) self.assertTrue( extractor.is_wpt_notify_enabled(MOCK_WEB_TESTS + 'a/b/OWNERS'))
def test_read_dir_metadata_success(self): data = ( '{"dirs":{"third_party/blink/web_tests/a/b":{"monorail":' '{"component":"foo"},"teamEmail":"bar","wpt":{"notify":"YES"}}}}') self.host.executive = MockExecutive(output=data) extractor = DirectoryOwnersExtractor(self.host) wpt_dir_metadata = extractor._read_dir_metadata(MOCK_WEB_TESTS + 'a/b/OWNERS') self.assertEqual( self.host.executive.full_calls[0].args, ['dirmd', 'read', '-form', 'sparse', MOCK_WEB_TESTS + 'a/b']) self.assertEqual(wpt_dir_metadata.team_email, 'bar') self.assertEqual(wpt_dir_metadata.should_notify, True) self.assertEqual(wpt_dir_metadata.component, 'foo')
def get_directory_owners(self): """Returns a mapping of email addresses to owners of changed tests.""" _log.info('Gathering directory owners emails to CC.') changed_files = self.chromium_git.changed_files() extractor = DirectoryOwnersExtractor(self.host) return extractor.list_owners(changed_files)