Exemplo n.º 1
0
 def setUp(self):
     host = MockBlinkTool()
     host.port_factory = MockPortFactory(host)
     port = host.port_factory.get()
     base_dir = port.web_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']
         },
         'some-wpt-bot': {
             'port_name': 'linux-trusty',
             'specifiers': ['Trusty', 'Release']
         },
     })
     self.host = host
    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 = MockBlinkTool()
        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)
Exemplo n.º 3
0
 def assert_execute_outputs(self,
                            command,
                            args=None,
                            expected_stdout='',
                            expected_stderr='',
                            expected_exception=None,
                            expected_logs=None,
                            options=optparse.Values(),
                            tool=MockBlinkTool()):
     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)
 def setUp(self):
     self.oc = None
     self.tool = MockBlinkTool()
     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'
     ]
Exemplo n.º 5
0
    def test_integration(self):
        command = flaky_tests.FlakyTests()
        tool = MockBlinkTool()
        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)
Exemplo n.º 6
0
    def setUp(self):
        self.tool = MockBlinkTool()
        self.command = self.command_constructor()
        self.command._tool = self.tool   # pylint: disable=protected-access
        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.test_expectations_path = self.mac_port.path_to_generic_test_expectations_file()

        # This file must exist for Port classes to function properly.
        self._write('VirtualTestSuites', '[]')
        # Create some dummy tests (note _setup_mock_build_data uses the same test names).
        self._write('userscripts/first-test.html', 'Dummy test contents')
        self._write('userscripts/second-test.html', 'Dummy test contents')

        # 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