def mock_host(self):
        """Returns a mock host with fake values set up for testing."""
        host = MockHost()
        host.port_factory = MockPortFactory(host)

        # Set up a fake list of try builders.
        host.builders = BuilderList({
            'MOCK Try Mac10.10': {
                'port_name': 'test-mac-mac10.10',
                'specifiers': ['Mac10.10', 'Release'],
                'is_try_builder': True,
            },
            'MOCK Try Mac10.11': {
                'port_name': 'test-mac-mac10.11',
                'specifiers': ['Mac10.11', 'Release'],
                'is_try_builder': True,
            },
            'MOCK Try Trusty': {
                'port_name': 'test-linux-trusty',
                'specifiers': ['Trusty', 'Release'],
                'is_try_builder': True,
            },
            'MOCK Try Precise': {
                'port_name': 'test-linux-precise',
                'specifiers': ['Precise', 'Release'],
                'is_try_builder': True,
            },
            'MOCK Try Win10': {
                'port_name': 'test-win-win10',
                'specifiers': ['Win10', 'Release'],
                'is_try_builder': True,
            },
            'MOCK Try Win7': {
                'port_name': 'test-win-win7',
                'specifiers': ['Win7', 'Release'],
                'is_try_builder': True,
            },
        })

        # Write a dummy manifest file, describing what tests exist.
        host.filesystem.write_text_file(
            host.port_factory.get().layout_tests_dir() +
            '/external/wpt/MANIFEST.json',
            json.dumps({
                'items': {
                    'reftest': {
                        'reftest.html':
                        [['/reftest.html', [['/reftest-ref.html', '==']], {}]]
                    },
                    'testharness': {
                        'test/path.html': [['/test/path.html', {}]],
                        'test/zzzz.html': [['/test/zzzz.html', {}]],
                    },
                    'manual': {
                        'x-manual.html': [['/x-manual.html', {}]],
                    },
                },
            }))

        return host
示例#2
0
    def _setup_host(self):
        """Returns a mock host with fake values set up for testing."""
        self.set_logging_level(logging.DEBUG)
        host = MockHost()
        host.port_factory = MockPortFactory(host)

        # Set up a fake list of try builders.
        host.builders = BuilderList({
            'MOCK Try Precise': {
                'port_name': 'test-linux-precise',
                'specifiers': ['Precise', 'Release'],
                'is_try_builder': True,
            },
            'MOCK Android Weblayer - Pie': {
                'port_name': 'test-android-pie',
                'specifiers': ['Precise', 'Release',
                               'anDroid', 'android_Weblayer'],
                'is_try_builder': True,
            },
            'MOCK Android Pie': {
                'port_name': 'test-android-pie',
                'specifiers': ['Precise', 'Release', 'anDroid',
                               'Android_Webview', 'Chrome_Android'],
                'is_try_builder': True,
            },
        })
        # Write dummy expectations
        for path in PRODUCTS_TO_EXPECTATION_FILE_PATHS.values():
            host.filesystem.write_text_file(
                path, self._raw_android_expectations)
        return host
示例#3
0
    def test_harness_no_expectations(self):
        """Tests behavior when TestExpectations file doesn't exist.

        Tests that a warning is outputted if the TestExpectations file
        doesn't exist.
        """

        # Set up the mock host and port.
        host = MockHost()
        host.port_factory = FakePortFactory(host)

        # Write the test file but not the TestExpectations file.
        test_expectation_path = (
            host.port_factory.get().path_to_generic_test_expectations_file())
        host.filesystem = MockFileSystem()
        self._write_tests_into_filesystem(host.filesystem)

        # Write out the fake builder bot results.
        expectation_factory = FakeBotTestExpectationsFactory()
        expectation_factory.all_results_by_builder = {}

        self.assertFalse(host.filesystem.isfile(test_expectation_path))

        return_code = main(host, expectation_factory, [])

        self.assertEqual(return_code, 1)

        self.assertLog([
            "WARNING: Didn't find generic expectations file at: %s\n" % test_expectation_path
        ])
        self.assertFalse(host.filesystem.isfile(test_expectation_path))
示例#4
0
    def test_all_configurations(self):
        host = MockHost()
        host.ports_parsed = []
        host.port_factory = FakeFactory(
            host,
            (FakePort(host, 'a', 'path-to-a'), FakePort(
                host, 'b', 'path-to-b'), FakePort(host, 'b-win', 'path-to-b')))

        options = optparse.Values({'platform': None})
        res = lint_test_expectations.lint(host, options)
        self.assertEqual(res, [])
        self.assertEqual(host.ports_parsed, ['a', 'b', 'b-win'])
    def _setup_host(self):
        """Returns a mock host with fake values set up for testing."""
        self.set_logging_level(logging.DEBUG)
        host = MockHost()
        host.port_factory = MockPortFactory(host)
        host.executive._output = ''

        # Set up a fake list of try builders.
        host.builders = BuilderList({
            'MOCK Try Precise': {
                'port_name': 'test-linux-precise',
                'specifiers': ['Precise', 'Release'],
                'is_try_builder': True,
            },
            'MOCK Android Weblayer - Pie': {
                'port_name': 'test-android-pie',
                'specifiers': ['Precise', 'Release',
                               'anDroid', 'android_Weblayer'],
                'is_try_builder': True,
            },
            'MOCK Android Pie': {
                'port_name': 'test-android-pie',
                'specifiers': ['Precise', 'Release', 'anDroid',
                               'Android_Webview', 'Chrome_Android'],
                'is_try_builder': True,
            },
        })
        host.filesystem.write_text_file(
            host.port_factory.get().web_tests_dir() + '/external/' +
            BASE_MANIFEST_NAME,
            json.dumps({
                'items': {
                    'testharness': {
                        'ghi.html': ['abcdef123', [None, {}]],
                        'van.html': ['abcdef123', [None, {}]],
                    },
                },
            }))

        # Write dummy expectations
        for path in PRODUCTS_TO_EXPECTATION_FILE_PATHS.values():
            host.filesystem.write_text_file(
                path, self._raw_android_expectations)

        host.filesystem.write_text_file(
            ANDROID_DISABLED_TESTS, self._raw_android_never_fix_tests)
        return host