def _assert_emails_for_test(self, emails): tool = MockTool() reporter = FlakyTestReporter(tool, 'dummy-queue') commit_infos = [MockCommitInfo(email) for email in emails] tool.checkout().recent_commit_infos_for_files = lambda paths: set( commit_infos) self.assertEqual(reporter._author_emails_for_test([]), set(emails))
def test_create_bug_for_flaky_test(self): reporter = FlakyTestReporter(MockTool(), 'dummy-queue') with OutputCapture(level=logging.INFO) as captured: reporter._create_bug_for_flaky_test('foo/bar.html', ['*****@*****.**'], 'FLAKE_MESSAGE') self.assertEqual( captured.root.log.getvalue(), """MOCK create_bug bug_title: Flaky Test: foo/bar.html bug_description: This is an automatically generated bug from the dummy-queue. foo/bar.html has been flaky on the dummy-queue. foo/bar.html was authored by [email protected]. https://trac.webkit.org/browser/trunk/LayoutTests/foo/bar.html FLAKE_MESSAGE The bots will update this with information from each new failure. If you believe this bug to be fixed or invalid, feel free to close. The bots will re-open if the flake re-occurs. If you would like to track this test fix with another bug, please close this bug as a duplicate. The bots will follow the duplicate chain when making future comments. component: Tools / Tests cc: [email protected] blocked: 50856 """, )
def test_bot_information(self): tool = MockTool() tool.status_server = MockStatusServer("MockBotId") reporter = FlakyTestReporter(tool, 'dummy-queue') self.assertEqual( reporter._bot_information(), "Bot: MockBotId Port: MockPort Platform: MockPlatform 1.0")
def test_optional_author_string(self): reporter = FlakyTestReporter(MockTool(), 'dummy-queue') self.assertEqual(reporter._optional_author_string([]), "") self.assertEqual(reporter._optional_author_string(["*****@*****.**"]), " (author: [email protected])") self.assertEqual( reporter._optional_author_string(["*****@*****.**", "*****@*****.**"]), " (authors: [email protected] and [email protected])")
def execute(self, options, args, tool): reporter = FlakyTestReporter(tool, "webkitpy") search_string = args[0] bug = reporter._lookup_bug_for_flaky_test(search_string) if bug: bug = reporter._follow_duplicate_chain(bug) print "%5s %s" % (bug.id(), bug.title()) else: print "No bugs found matching '%s'" % search_string
def test_find_in_archive(self): reporter = FlakyTestReporter(MockTool(), 'dummy-queue') class MockZipFile(object): def namelist(self): return ["tmp/layout-test-results/foo/bar-diffs.txt"] reporter._find_in_archive("foo/bar-diffs.txt", MockZipFile()) # This is not ideal, but its reporter._find_in_archive("txt", MockZipFile())
def test_report_flaky_tests_creating_bug(self): tool = MockTool() tool.filesystem = MockFileSystem( {"/mock-results/foo/bar-diffs.txt": "mock"}) reporter = FlakyTestReporter(tool, 'dummy-queue') reporter._lookup_bug_for_flaky_test = lambda bug_id: None patch = tool.bugs.fetch_attachment(10000) test_results = [self._mock_test_result('foo/bar.html')] class MockZipFile(object): def read(self, path): return "" def namelist(self): return ['foo/bar-diffs.txt'] with OutputCapture(level=logging.INFO) as captured: reporter.report_flaky_tests(patch, test_results, MockZipFile()) self.assertEqual( captured.root.log.getvalue(), """Bug does not already exist for foo/bar.html, creating. MOCK create_bug bug_title: Flaky Test: foo/bar.html bug_description: This is an automatically generated bug from the dummy-queue. foo/bar.html has been flaky on the dummy-queue. foo/bar.html was authored by [email protected]. https://trac.webkit.org/browser/trunk/LayoutTests/foo/bar.html The dummy-queue just saw foo/bar.html flake (text diff) while processing attachment 10000 on bug 50000. Port: MockPort Platform: MockPlatform 1.0 The bots will update this with information from each new failure. If you believe this bug to be fixed or invalid, feel free to close. The bots will re-open if the flake re-occurs. If you would like to track this test fix with another bug, please close this bug as a duplicate. The bots will follow the duplicate chain when making future comments. component: Tools / Tests cc: [email protected] blocked: 50856 MOCK add_attachment_to_bug: bug_id=60001, description=Failure diff from bot filename=failure.diff mimetype=None MOCK bug comment: bug_id=50000, cc=None, see_also=None --- Begin comment --- The dummy-queue encountered the following flaky tests while processing attachment 10000: foo/bar.html bug 60001 (author: [email protected]) The dummy-queue is continuing to process your patch. --- End comment --- """, )
def test_report_flaky_tests_creating_bug(self): tool = MockTool() tool.filesystem = MockFileSystem( {"/mock-results/foo/bar-diffs.txt": "mock"}) tool.status_server = MockStatusServer(bot_id="mock-bot-id") reporter = FlakyTestReporter(tool, 'dummy-queue') reporter._lookup_bug_for_flaky_test = lambda bug_id: None patch = tool.bugs.fetch_attachment(10000) expected_stderr = """MOCK create_bug bug_title: Flaky Test: foo/bar.html bug_description: This is an automatically generated bug from the dummy-queue. foo/bar.html has been flaky on the dummy-queue. foo/bar.html was authored by [email protected]. http://trac.webkit.org/browser/trunk/LayoutTests/foo/bar.html The dummy-queue just saw foo/bar.html flake (Text diff mismatch) while processing attachment 10000 on bug 50000. Bot: mock-bot-id Port: MockPort Platform: MockPlatform 1.0 The bots will update this with information from each new failure. If you believe this bug to be fixed or invalid, feel free to close. The bots will re-open if the flake re-occurs. If you would like to track this test fix with another bug, please close this bug as a duplicate. The bots will follow the duplicate chain when making future comments. component: Tools / Tests cc: [email protected] blocked: 50856 MOCK add_attachment_to_bug: bug_id=50004, description=Failure diff from mock-bot-id filename=failure.diff MOCK bug comment: bug_id=50000, cc=None --- Begin comment --- The dummy-queue encountered the following flaky tests while processing attachment 10000: foo/bar.html bug 50004 (author: [email protected]) The dummy-queue is continuing to process your patch. --- End comment --- """ test_results = [self._mock_test_result('foo/bar.html')] class MockZipFile(object): def read(self, path): return "" def namelist(self): return ['foo/bar-diffs.txt'] OutputCapture().assert_outputs( self, reporter.report_flaky_tests, [patch, test_results, MockZipFile()], expected_stderr=expected_stderr)
def test_report_flaky_tests_creating_bug(self): tool = MockTool() tool.filesystem = MockFileSystem({"/mock-results/foo/bar-diffs.txt": "mock"}) tool.status_server = MockStatusServer(bot_id="mock-bot-id") reporter = FlakyTestReporter(tool, 'dummy-queue') reporter._lookup_bug_for_flaky_test = lambda bug_id: None patch = tool.bugs.fetch_attachment(10000) expected_logs = """Bug does not already exist for foo/bar.html, creating. MOCK create_bug bug_title: Flaky Test: foo/bar.html bug_description: This is an automatically generated bug from the dummy-queue. foo/bar.html has been flaky on the dummy-queue. foo/bar.html was authored by [email protected]. http://trac.webkit.org/browser/trunk/LayoutTests/foo/bar.html The dummy-queue just saw foo/bar.html flake (text diff) while processing attachment 10000 on bug 50000. Bot: mock-bot-id Port: MockPort Platform: MockPlatform 1.0 The bots will update this with information from each new failure. If you believe this bug to be fixed or invalid, feel free to close. The bots will re-open if the flake re-occurs. If you would like to track this test fix with another bug, please close this bug as a duplicate. The bots will follow the duplicate chain when making future comments. component: Tools / Tests cc: [email protected] blocked: 50856 MOCK add_attachment_to_bug: bug_id=60001, description=Failure diff from mock-bot-id filename=failure.diff mimetype=None MOCK bug comment: bug_id=50000, cc=None --- Begin comment --- The dummy-queue encountered the following flaky tests while processing attachment 10000: foo/bar.html bug 60001 (author: [email protected]) The dummy-queue is continuing to process your patch. --- End comment --- """ test_results = [self._mock_test_result('foo/bar.html')] class MockZipFile(object): def read(self, path): return "" def namelist(self): return ['foo/bar-diffs.txt'] OutputCapture().assert_outputs(self, reporter.report_flaky_tests, [patch, test_results, MockZipFile()], expected_logs=expected_logs)
def test_report_flaky_tests_creating_bug(self): tool = MockTool() tool.filesystem = MockFileSystem({"/mock/foo/bar-diffs.txt": "mock"}) tool.status_server = MockStatusServer(bot_id="mock-bot-id") reporter = FlakyTestReporter(tool, 'dummy-queue') reporter._lookup_bug_for_flaky_test = lambda bug_id: None patch = tool.bugs.fetch_attachment(197) expected_stderr = """MOCK create_bug bug_title: Flaky Test: foo/bar.html bug_description: This is an automatically generated bug from the dummy-queue. foo/bar.html has been flaky on the dummy-queue. foo/bar.html was authored by [email protected]. http://trac.webkit.org/browser/trunk/LayoutTests/foo/bar.html The dummy-queue just saw foo/bar.html flake while processing attachment 197 on bug 42. Bot: mock-bot-id Port: MockPort Platform: MockPlatform 1.0 The bots will update this with information from each new failure. If you believe this bug to be fixed or invalid, feel free to close. The bots will re-open if the flake re-occurs. If you would like to track this test fix with another bug, please close this bug as a duplicate. The bots will follow the duplicate chain when making future comments. component: Tools / Tests cc: [email protected] blocked: 50856 MOCK add_attachment_to_bug: bug_id=78, description=Failure diff from mock-bot-id filename=failure.diff MOCK bug comment: bug_id=42, cc=None --- Begin comment --- The dummy-queue encountered the following flaky tests while processing attachment 197: foo/bar.html bug 78 (author: [email protected]) The dummy-queue is continuing to process your patch. --- End comment --- """ OutputCapture().assert_outputs(self, reporter.report_flaky_tests, [['foo/bar.html'], patch], expected_stderr=expected_stderr)
def test_optional_author_string(self): reporter = FlakyTestReporter(MockTool(), 'dummy-queue') self.assertEqual(reporter._optional_author_string([]), "") self.assertEqual(reporter._optional_author_string(["*****@*****.**"]), " (author: [email protected])") self.assertEqual(reporter._optional_author_string(["*****@*****.**", "*****@*****.**"]), " (authors: [email protected] and [email protected])")
def report_flaky_tests(self, patch, flaky_test_results, results_archive=None): reporter = FlakyTestReporter(self._tool, self.name) reporter.report_flaky_tests(patch, flaky_test_results, results_archive)
def test_results_diff_path_for_test(self): reporter = FlakyTestReporter(MockTool(), 'dummy-queue') self.assertEqual(reporter._results_diff_path_for_test("test.html"), "test-diffs.txt")
def test_follow_duplicate_chain(self): tool = MockTool() reporter = FlakyTestReporter(tool, 'dummy-queue') bug = tool.bugs.fetch_bug(78) self.assertEqual(reporter._follow_duplicate_chain(bug).id(), 76)
def test_bot_information(self): tool = MockTool() tool.status_server = MockStatusServer("MockBotId") reporter = FlakyTestReporter(tool, 'dummy-queue') self.assertEqual(reporter._bot_information(), "Bot: MockBotId Port: MockPort Platform: MockPlatform 1.0")
def _assert_emails_for_test(self, emails): tool = MockTool() reporter = FlakyTestReporter(tool, 'dummy-queue') commit_infos = [MockCommitInfo(email) for email in emails] tool.checkout().recent_commit_infos_for_files = lambda paths: set(commit_infos) self.assertEqual(reporter._author_emails_for_test([]), set(emails))
def test_results_diff_path_for_test(self): reporter = FlakyTestReporter(MockTool(), 'dummy-queue') self.assertEqual(reporter._results_diff_path_for_test("test.html"), "/mock/test-diffs.txt")
def report_flaky_tests(self, patch, flaky_tests): reporter = FlakyTestReporter(self._tool, self.name) reporter.report_flaky_tests(flaky_tests, patch)