Пример #1
0
    def test_integration(self):
        command = flaky_tests.FlakyTests()
        tool = MockWebKitPatch()
        tool.builders = self.fake_builders_list()
        command.expectations_factory = FakeBotTestExpectationsFactory
        options = optparse.Values({'upload': True})
        expected_stdout = flaky_tests.FlakyTests.OUTPUT % (
            flaky_tests.FlakyTests.HEADER,
            '',
            flaky_tests.FlakyTests.FLAKINESS_DASHBOARD_URL % '') + '\n'

        self.assert_execute_outputs(command, options=options, tool=tool, expected_stdout=expected_stdout)
Пример #2
0
 def setUp(self):
     host = MockWebKitPatch()
     host.port_factory = MockPortFactory(host)
     port = host.port_factory.get()
     base_dir = port.layout_tests_dir()
     host.filesystem.write_text_file(base_dir + '/a/x.html', '<html>')
     host.filesystem.write_text_file(base_dir + '/a/y.html', '<html>')
     host.filesystem.write_text_file(base_dir + '/a/z.html', '<html>')
     host.builders = BuilderList({
         'MOCK Mac10.12': {'port_name': 'test-mac-mac10.12', 'specifiers': ['Mac10.12', 'Release']},
         'MOCK Trusty': {'port_name': 'test-linux-trusty', 'specifiers': ['Trusty', 'Release']},
         'MOCK Win10': {'port_name': 'test-win-win10', 'specifiers': ['Win10', 'Release']},
     })
     self.host = host
Пример #3
0
    def run_test(self,
                 tests,
                 expected_stdout,
                 platform='test-win-win7',
                 **kwargs):
        options_defaults = {
            'all': False,
            'csv': False,
            'full': False,
            'platform': platform,
            'include_keyword': [],
            'exclude_keyword': [],
            'paths': False,
        }
        options_defaults.update(kwargs)
        options = optparse.Values(dict(**options_defaults))
        tool = MockWebKitPatch()
        tool.port_factory.all_port_names = lambda: [
            'test-linux-trusty', 'test-linux-precise', 'test-mac-mac10.11',
            'test-mac-mac10.10', 'test-win-win10', 'test-win-win7'
        ]
        command = PrintExpectations()

        oc = OutputCapture()
        try:
            oc.capture_output()
            command.execute(options, tests, tool)
        finally:
            stdout, _, _ = oc.restore_output()
        self.assertMultiLineEqual(stdout, expected_stdout)
Пример #4
0
 def assert_execute_outputs(self,
                            command,
                            args=None,
                            expected_stdout='',
                            expected_stderr='',
                            expected_exception=None,
                            expected_logs=None,
                            options=optparse.Values(),
                            tool=MockWebKitPatch()):
     args = args or []
     options.blocks = None
     options.cc = 'MOCK cc'
     options.component = 'MOCK component'
     options.confirm = True
     options.email = 'MOCK email'
     options.git_commit = 'MOCK git commit'
     options.obsolete_patches = True
     options.open_bug = True
     options.port = 'MOCK port'
     options.update_changelogs = False
     options.quiet = True
     options.reviewer = 'MOCK reviewer'
     OutputCapture().assert_outputs(self,
                                    command.execute, [options, args, tool],
                                    expected_stdout=expected_stdout,
                                    expected_stderr=expected_stderr,
                                    expected_exception=expected_exception,
                                    expected_logs=expected_logs)
Пример #5
0
 def setUp(self):
     self.oc = None
     self.tool = MockWebKitPatch()
     self.test_port = self.tool.port_factory.get('test-win-win7')
     self.tool.port_factory.get = lambda port_name=None: self.test_port
     self.tool.port_factory.all_port_names = lambda: [
         'test-linux-trusty', 'test-linux-precise', 'test-mac-mac10.11',
         'test-mac-mac10.10', 'test-win-win10', 'test-win-win7'
     ]
Пример #6
0
    def setUp(self):
        self.tool = MockWebKitPatch()
        # Lint warns that command_constructor might not be set, but this is intentional; pylint: disable=not-callable
        self.command = self.command_constructor()
        self.command._tool = self.tool
        self.tool.builders = BuilderList({
            'MOCK Mac10.10 (dbg)': {'port_name': 'test-mac-mac10.10', 'specifiers': ['Mac10.10', 'Debug']},
            'MOCK Mac10.10': {'port_name': 'test-mac-mac10.10', 'specifiers': ['Mac10.10', 'Release']},
            'MOCK Mac10.11 (dbg)': {'port_name': 'test-mac-mac10.11', 'specifiers': ['Mac10.11', 'Debug']},
            'MOCK Mac10.11 ASAN': {'port_name': 'test-mac-mac10.11', 'specifiers': ['Mac10.11', 'Release']},
            'MOCK Mac10.11': {'port_name': 'test-mac-mac10.11', 'specifiers': ['Mac10.11', 'Release']},
            'MOCK Precise': {'port_name': 'test-linux-precise', 'specifiers': ['Precise', 'Release']},
            'MOCK Trusty': {'port_name': 'test-linux-trusty', 'specifiers': ['Trusty', 'Release']},
            'MOCK Win10': {'port_name': 'test-win-win10', 'specifiers': ['Win10', 'Release']},
            'MOCK Win7 (dbg)': {'port_name': 'test-win-win7', 'specifiers': ['Win7', 'Debug']},
            'MOCK Win7 (dbg)(1)': {'port_name': 'test-win-win7', 'specifiers': ['Win7', 'Debug']},
            'MOCK Win7 (dbg)(2)': {'port_name': 'test-win-win7', 'specifiers': ['Win7', 'Debug']},
            'MOCK Win7': {'port_name': 'test-win-win7', 'specifiers': ['Win7', 'Release']},
        })
        self.mac_port = self.tool.port_factory.get_from_builder_name('MOCK Mac10.11')

        self.mac_expectations_path = self.mac_port.path_to_generic_test_expectations_file()
        self.tool.filesystem.write_text_file(
            self.tool.filesystem.join(self.mac_port.layout_tests_dir(), 'VirtualTestSuites'), '[]')

        # In AbstractParallelRebaselineCommand._rebaseline_commands, a default port
        # object is gotten using self.tool.port_factory.get(), which is used to get
        # test paths -- and the layout tests directory may be different for the "test"
        # ports and real ports. Since only "test" ports are used in this class,
        # we can make the default port also a "test" port.
        self.original_port_factory_get = self.tool.port_factory.get
        test_port = self.tool.port_factory.get('test')

        def get_test_port(port_name=None, options=None, **kwargs):
            if not port_name:
                return test_port
            return self.original_port_factory_get(port_name, options, **kwargs)

        self.tool.port_factory.get = get_test_port
Пример #7
0
    def test_format_commit(self):
        tool = MockWebKitPatch()
        bot = CommitAnnouncer(tool, 'test/directory', 'test_password')
        self.assertEqual(
            'https://crrev.com/456789 [email protected] committed "Commit test subject line"',
            bot._format_commit_detail("""\
1234commit1234
[email protected]
Commit test subject line
Multiple
lines
of
description.

BUG=654321

Review URL: https://codereview.chromium.org/123456

Cr-Commit-Position: refs/heads/master@{#456789}
"""))

        self.assertEqual(
            'https://crrev.com/456789 '
            '[email protected] committed "Commit test subject line"',
            bot._format_commit_detail("""\
1234commit1234
[email protected]
Commit test subject line
Multiple
lines
of
description.

BUG=654321

Cr-Commit-Position: refs/heads/master@{#456789}
"""))

        self.assertEqual(
            'https://crrev.com/1234comm [email protected] committed "Commit test subject line"',
            bot._format_commit_detail("""\
1234commit1234
[email protected]
Commit test subject line
Multiple
lines
of
description.

BUG=654321

Review URL: https://codereview.chromium.org/123456
"""))

        self.assertEqual(
            'https://crrev.com/1234comm [email protected] committed "Commit test subject line"',
            bot._format_commit_detail("""\
1234commit1234
[email protected]
Commit test subject line
Multiple
lines
of
description.
"""))

        self.assertEqual(
            'https://crrev.com/456789 [email protected] committed "Commit test subject line"',
            bot._format_commit_detail("""\
1234commit1234
[email protected]
Commit test subject line
Multiple
lines
of
description.
Review URL: http://fake.review.url
Cr-Commit-Position: refs/heads/master@{#000000}

BUG=654321

Review URL: https://codereview.chromium.org/123456

Cr-Commit-Position: refs/heads/master@{#456789}
"""))

        self.assertEqual(
            'https://crrev.com/456789 [email protected] committed "Commit test subject line" '
            '\[email protected]\x03',
            bot._format_commit_detail("""\
1234commit1234
[email protected]
Commit test subject line
Multiple
lines
of
description.

BUG=654321
[email protected]

Review URL: https://codereview.chromium.org/123456

Cr-Commit-Position: refs/heads/master@{#456789}
"""))

        self.assertEqual(
            'https://crrev.com/456789 [email protected] committed "Commit test subject line" '
            '\x037NOTRY=true\x03',
            bot._format_commit_detail("""\
1234commit1234
[email protected]
Commit test subject line
Multiple
lines
of
description.

BUG=654321
NOTRY=true

Review URL: https://codereview.chromium.org/123456

Cr-Commit-Position: refs/heads/master@{#456789}
"""))

        self.assertEqual(
            'https://crrev.com/456789 [email protected] committed "Commit test subject line" '
            '\x037NOTRY=true [email protected]\x03',
            bot._format_commit_detail("""\
1234commit1234
[email protected]
Commit test subject line
Multiple
lines
of
description.

NOTRY=true
BUG=654321
[email protected]

Review URL: https://codereview.chromium.org/123456

Cr-Commit-Position: refs/heads/master@{#456789}
"""))

        self.assertEqual(
            'https://crrev.com/456789 [email protected] committed "Commit test subject line" '
            '\[email protected], [email protected], [email protected] notry=TRUE\x03',
            bot._format_commit_detail("""\
1234commit1234
[email protected]
Commit test subject line
Multiple
lines
of
description.

BUG=654321
[email protected], [email protected], [email protected]
notry=TRUE

Review URL: https://codereview.chromium.org/123456

Cr-Commit-Position: refs/heads/master@{#456789}
"""))
Пример #8
0
 def test_sanitize_string(self):
     bot = CommitAnnouncer(MockWebKitPatch(), 'test/directory',
                           'test_password')
     self.assertEqual('normal ascii', bot._sanitize_string('normal ascii'))
     self.assertEqual('uni\\u0441ode!',
                      bot._sanitize_string(u'uni\u0441ode!'))