Exemplo n.º 1
0
    def test_determine_architecture_fails(self):
        # Test that we default to 'x86' if the driver doesn't exist.
        port = chromium_linux.ChromiumLinuxPort(MockHost())
        self.assertEquals(port.architecture(), 'x86_64')

        # Test that we default to 'x86' on an unknown architecture.
        host = MockHost()
        host.filesystem.exists = lambda x: True
        host.executive = executive_mock.MockExecutive2('win32')
        port = chromium_linux.ChromiumLinuxPort(host)
        self.assertEquals(port.architecture(), 'x86_64')

        # Test that we raise errors if something weird happens.
        host.executive = executive_mock.MockExecutive2(exception=AssertionError)
        self.assertRaises(AssertionError, chromium_linux.ChromiumLinuxPort, host)
Exemplo n.º 2
0
 def test_cl_description_with_empty_environ(self):
     host = MockHost()
     host.executive = MockExecutive2(output="Last commit message\n")
     updater = DepsUpdater(host)
     description = updater._cl_description()
     self.assertEqual(description, ("Last commit message\n" "[email protected]\n" "NOEXPORT=true"))
     self.assertEqual(host.executive.calls, [["git", "log", "-1", "--format=%B"]])
Exemplo n.º 3
0
 def test_run(self):
     host = MockHost()
     host.executive = MockExecutive2(output='mock-output')
     git_cl = GitCL(host)
     output = git_cl.run(['command'])
     self.assertEqual(output, 'mock-output')
     self.assertEqual(host.executive.calls, [['git', 'cl', 'command']])
    def test_start_cmd(self):
        # Fails on win - see https://bugs.webkit.org/show_bug.cgi?id=84726
        if sys.platform in ("cygwin", "win32"):
            return

        def fake_pid(_):
            host.filesystem.write_text_file("/tmp/WebKit/httpd.pid", "42")
            return True

        host = MockHost()
        host.executive = MockExecutive(should_log=True)
        test_port = test.TestPort(host)
        host.filesystem.write_text_file(test_port._path_to_apache_config_file(), "")

        server = LayoutTestApacheHttpd(test_port, "/mock/output_dir", number_of_servers=4)
        server._check_that_all_ports_are_available = lambda: True
        server._is_server_running_on_all_ports = lambda: True
        server._wait_for_action = fake_pid
        oc = OutputCapture()
        try:
            oc.capture_output()
            server.start()
            server.stop()
        finally:
            _, _, logs = oc.restore_output()
        self.assertIn("StartServers 4", logs)
        self.assertIn("MinSpareServers 4", logs)
        self.assertIn("MaxSpareServers 4", logs)
        self.assertTrue(host.filesystem.exists("/mock/output_dir/httpd.conf"))
Exemplo n.º 5
0
    def test_dry_run_stops_before_creating_pr(self):
        host = MockHost()
        host.executive = MockExecutive2(output='beefcafe')
        wpt_github = MockWPTGitHub(pull_requests=[{'number': 1, 'title': 'abc'}])
        TestExporter(host, wpt_github, dry_run=True).run()

        self.assertEqual(wpt_github.calls, ['in_flight_pull_requests'])
Exemplo n.º 6
0
 def test_import_dir_with_no_tests(self):
     host = MockHost()
     host.executive = MockExecutive2(exception=ScriptError(
         "abort: no repository found in '/Volumes/Source/src/wk/Tools/Scripts/webkitpy/w3c'"))
     host.filesystem = MockFileSystem(files=FAKE_FILES)
     importer = TestImporter(host, FAKE_SOURCE_REPO_DIR, self.options())
     importer.do_import()  # No exception raised.
Exemplo n.º 7
0
    def test_creates_pull_request_for_earliest_commit(self):
        host = MockHost()

        def mock_command(args):
            git_command = args[1]
            if git_command == 'rev-list':
                return 'facebeef\ncafedad5'
            elif git_command == 'footers':
                return 'fake-cr-position'
            elif git_command == 'show':
                if 'cafedad5' in args:
                    return 'newer fake text'
                elif 'facebeef' in args:
                    return 'older fake text'
            else:
                return ''

        host.executive = MockExecutive2(run_command_fn=mock_command)
        wpt_github = MockWPTGitHub(pull_requests=[])

        TestExporter(host, wpt_github).run()

        self.assertEqual(wpt_github.calls, ['in_flight_pull_requests', 'create_pr'])
        self.assertEqual(wpt_github.pull_requests_created,
                         [('chromium-export-try', 'older fake text', 'older fake text')])
Exemplo n.º 8
0
    def test_derives_sha_from_position(self):
        host = MockHost()
        host.executive = MockExecutive2(output="deadbeefcafe")
        pos = "Cr-Commit-Position: refs/heads/master@{#789}"
        chromium_commit = ChromiumCommit(host, position=pos)

        self.assertEqual(chromium_commit.position, "refs/heads/master@{#789}")
        self.assertEqual(chromium_commit.sha, "deadbeefcafe")
Exemplo n.º 9
0
 def test_run_with_auth(self):
     host = MockHost()
     host.executive = MockExecutive2(output='mock-output')
     git_cl = GitCL(host, auth_refresh_token_json='token.json')
     git_cl.run(['upload'])
     self.assertEqual(
         host.executive.calls,
         [['git', 'cl', 'upload', '--auth-refresh-token-json', 'token.json']])
Exemplo n.º 10
0
    def test_last_wpt_exported_commit_not_found(self):
        host = MockHost()
        host.executive = MockExecutive2(run_command_fn=lambda _: None)
        host.filesystem = MockFileSystem()
        local_wpt = LocalWPT(host)

        commit = local_wpt.most_recent_chromium_commit()
        self.assertEqual(commit, (None, None))
    def test_check_is_functional_cdb_not_found(self):
        host = MockHost()
        host.executive = MockExecutive(should_throw=True)

        build_dir = "/mock-checkout/out/Debug"
        host.filesystem.maybe_make_directory(build_dir)
        dump_reader = DumpReaderWin(host, build_dir)

        self.assertFalse(dump_reader.check_is_functional())
Exemplo n.º 12
0
    def test_has_changes_in_wpt_looks_at_start_of_string(self):
        host = MockHost()

        def run_command_fn(_):
            return ("something/something.html\n"
                    "something/third_party/WebKit/LayoutTests/imported/wpt/something.html\n")

        host.executive = MockExecutive2(run_command_fn=run_command_fn)
        chromium_wpt = ChromiumWPT(host)

        self.assertFalse(chromium_wpt.has_changes_in_wpt('sha'))
Exemplo n.º 13
0
    def test_import_dir_with_no_tests(self):
        host = MockHost()
        host.executive = MockExecutive2(exception=ScriptError("abort: no repository found in '/Volumes/Source/src/wk/Tools/Scripts/webkitpy/w3c' (.hg not found)!"))
        host.filesystem = MockFileSystem(files=FAKE_FILES)

        importer = TestImporter(host, FAKE_SOURCE_DIR, self._parse_options(['-n', '-d', 'w3c', '-t', FAKE_TEST_PATH]))
        oc = OutputCapture()
        oc.capture_output()
        try:
            importer.do_import()
        finally:
            oc.restore_output()
    def test_import_dir_with_no_tests(self):
        host = MockHost()
        host.executive = MockExecutive2(exception=ScriptError("abort: no repository found in '/Volumes/Source/src/wk/Tools/Scripts/webkitpy/w3c' (.hg not found)!"))
        host.filesystem = MockFileSystem(files=FAKE_FILES)

        importer = TestImporter(host, FAKE_SOURCE_DIR, FAKE_REPO_DIR, optparse.Values({"overwrite": False}))
        oc = OutputCapture()
        oc.capture_output()
        try:
            importer.do_import()
        finally:
            oc.restore_output()
Exemplo n.º 15
0
    def test_last_wpt_exported_commit(self):
        host = MockHost()
        return_vals = [
            '123',
            '9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8',
        ]
        host.executive = MockExecutive2(run_command_fn=lambda _: return_vals.pop())
        host.filesystem = MockFileSystem()
        local_wpt = LocalWPT(host, no_fetch=True)

        commit = local_wpt.most_recent_chromium_commit()
        self.assertEqual(commit, ('9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8', '123'))
Exemplo n.º 16
0
    def test_has_changes_in_wpt_does_not_count_expectation_files(self):
        host = MockHost()

        def run_command_fn(_):
            return ("something/something.html\n"
                    "third_party/WebKit/LayoutTests/imported/wpt/something-expected.html\n"
                    "-expected.txt\n")

        host.executive = MockExecutive2(run_command_fn=run_command_fn)
        chromium_wpt = ChromiumWPT(host)

        self.assertFalse(chromium_wpt.has_changes_in_wpt('sha'))
Exemplo n.º 17
0
    def test_import_dir_with_no_tests_and_no_hg(self):
        host = MockHost()
        host.executive = MockExecutive2(exception=OSError())
        host.filesystem = MockFileSystem(files=FAKE_FILES)

        importer = TestImporter(host, FAKE_SOURCE_DIR, self._parse_options(['-n', '-d', 'w3c', '-t', FAKE_TEST_PATH]))

        oc = OutputCapture()
        oc.capture_output()
        try:
            importer.do_import()
        finally:
            oc.restore_output()
    def test_import_dir_with_no_tests_and_no_hg(self):
        host = MockHost()
        host.executive = MockExecutive2(exception=OSError())
        host.filesystem = MockFileSystem(files=FAKE_FILES)

        importer = TestImporter(host, FAKE_SOURCE_DIR, FAKE_REPO_DIR, optparse.Values({"overwrite": False}))

        oc = OutputCapture()
        oc.capture_output()
        try:
            importer.do_import()
        finally:
            oc.restore_output()
Exemplo n.º 19
0
    def test_ignores_commits_that_start_with_import(self):
        host = MockHost()

        return_vals = [
            'Import rutabaga@deadbeef',  # show (message)
            'deadbeefcafe',  # rev-list
            'third_party/WebKit/LayoutTests/imported/wpt',  # rev-parse
        ]
        host.executive = MockExecutive2(run_command_fn=lambda _: return_vals.pop())

        chromium_wpt = ChromiumWPT(host)
        commits = chromium_wpt.exportable_commits_since('3dadcafe')
        self.assertEqual(len(commits), 0)
Exemplo n.º 20
0
    def test_update_win_future_test_expectations(self):
        host = MockHost()
        host.executive = MockExecutive2(exception=OSError())
        host.filesystem = MockFileSystem(files={
            '/mock-checkout/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location-expected.txt': 'e-wk1',
            '/mock-checkout/LayoutTests/imported/w3c/web-platform-tests/dom/events/EventTarget-dispatchEvent-expected.txt': "g",
            '/mock-checkout/LayoutTests/imported/w3c/web-platform-tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/open-features-tokenization-001-expected.txt': "h",
            '/mock-checkout/LayoutTests/imported/w3c/web-platform-tests/html/browsers/windows/browsing-context-expected.txt': "i",
            '/mock-checkout/LayoutTests/imported/w3c/web-platform-tests/url/interfaces-expected.txt': "j-mac-wk2"})

        mock_zip = MockZip()
        updater = TestExpectationUpdater(host, "123456", True, False, MockBugzilla(include_wk2=False, include_win_future=True), lambda content: mock_zip.unzip(content))
        updater.do_update()
        self.assertTrue(self._is_matching(host, "platform/win/imported/w3c/web-platform-tests/url/interfaces-expected.txt", "j"))
Exemplo n.º 21
0
    def test_when_commit_has_no_position(self):
        host = MockHost()

        def run_command(_):
            raise ScriptError(
                'Unable to infer commit position from footers rutabaga')

        host.executive = MockExecutive(run_command_fn=run_command)
        chromium_commit = ChromiumCommit(
            host, sha='c881563d734a86f7d9cd57ac509653a61c45c240')

        self.assertEqual(chromium_commit.position, 'no-commit-position-yet')
        self.assertEqual(chromium_commit.sha,
                         'c881563d734a86f7d9cd57ac509653a61c45c240')
Exemplo n.º 22
0
    def test_last_wpt_exported_commit(self):
        host = MockHost()
        host.executive = mock_git_commands({
            'rev-list': '9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8',
            'footers': 'Cr-Commit-Position: 123',
            'crrev-parse': 'add087a97844f4b9e307d9a216940582d96db306',
        }, strict=True)
        host.filesystem = MockFileSystem()
        local_wpt = LocalWPT(host, 'token')

        wpt_sha, chromium_commit = local_wpt.most_recent_chromium_commit()
        self.assertEqual(wpt_sha, '9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8')
        self.assertEqual(chromium_commit.position, '123')
        self.assertEqual(chromium_commit.sha, 'add087a97844f4b9e307d9a216940582d96db306')
Exemplo n.º 23
0
    def test_import_dir_with_no_tests(self):
        FAKE_FILES.update(FAKE_REPOSITORIES)

        host = MockHost()
        host.executive = MockExecutive2(exception=ScriptError(
            "abort: no repository found in '/Volumes/Source/src/wk/Tools/Scripts/webkitpy/w3c' (.hg not found)!"
        ))
        host.filesystem = MockFileSystem(files=FAKE_FILES)

        importer = TestImporter(
            host, FAKE_TEST_PATH,
            self._parse_options(['-n', '-d', 'w3c', '-s', FAKE_SOURCE_DIR]))
        with OutputCapture():
            importer.do_import()
Exemplo n.º 24
0
    def test_import_dir_with_no_tests_and_no_hg(self):
        host = MockHost()
        host.executive = MockExecutive2(exception=OSError())
        host.filesystem = MockFileSystem(files=FAKE_FILES)

        importer = TestImporter(host, FAKE_SOURCE_DIR, FAKE_REPO_DIR,
                                optparse.Values({"overwrite": False}))

        oc = OutputCapture()
        oc.capture_output()
        try:
            importer.do_import()
        finally:
            oc.restore_output()
Exemplo n.º 25
0
    def test_dry_run_stops_before_creating_pr(self):
        host = MockHost()
        host.executive = MockExecutive(output='beefcafe')
        test_exporter = TestExporter(host,
                                     'gh-username',
                                     'gh-token',
                                     dry_run=True)
        test_exporter.wpt_github = MockWPTGitHub(pull_requests=[
            PullRequest(title='title1', number=1234),
        ])
        test_exporter.run()

        self.assertEqual(test_exporter.wpt_github.calls,
                         ['in_flight_pull_requests'])
Exemplo n.º 26
0
    def test_commits_in_range(self):
        host = MockHost()
        host.executive = mock_git_commands(
            {
                'rev-list':
                '34ab6c3f5aee8bf05207b674edbcb6affb179545 Fix presubmit errors\n'
                '8c596b820634a623dfd7a2b0f36007ce2f7a0c9f test\n'
            },
            strict=True)
        local_wpt = LocalWPT(host, 'token')

        self.assertTrue(local_wpt.commits_in_range('HEAD~2', 'HEAD'))
        self.assertEqual(
            host.executive.calls,
            [['git', 'rev-list', '--pretty=oneline', 'HEAD~2..HEAD']])
Exemplo n.º 27
0
    def test_exportable_commits_since(self):
        host = MockHost()

        def mock_command(args):
            git_command = args[1]
            if git_command == 'rev-list':
                return 'badbeef8'
            else:
                return ''

        host.executive = MockExecutive2(run_command_fn=mock_command)

        chromium_wpt = ChromiumWPT(host)
        commits = chromium_wpt.exportable_commits_since('3dadcafe')
        self.assertEqual(len(commits), 1)
Exemplo n.º 28
0
 def test_cl_description_with_environ_variables(self):
     host = MockHost()
     host.executive = MockExecutive(output='Last commit message\n')
     importer = TestImporter(host)
     importer.host.environ['BUILDBOT_MASTERNAME'] = 'my.master'
     importer.host.environ['BUILDBOT_BUILDERNAME'] = 'b'
     importer.host.environ['BUILDBOT_BUILDNUMBER'] = '123'
     description = importer._cl_description(directory_owners={})
     self.assertEqual(description, (
         'Last commit message\n'
         'Build: https://build.chromium.org/p/my.master/builders/b/builds/123\n\n'
         '[email protected]\n'
         'NOEXPORT=true'))
     self.assertEqual(host.executive.calls,
                      [['git', 'log', '-1', '--format=%B']])
Exemplo n.º 29
0
    def test_last_wpt_exported_commit(self):
        host = MockHost()
        return_vals = [
            'deadbeefcafe',
            '123',
            '9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8',
        ]
        host.executive = MockExecutive(run_command_fn=lambda _: return_vals.pop())
        host.filesystem = MockFileSystem()
        local_wpt = LocalWPT(host)

        wpt_sha, chromium_commit = local_wpt.most_recent_chromium_commit()
        self.assertEqual(wpt_sha, '9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8')
        self.assertEqual(chromium_commit.position, '123')
        self.assertEqual(chromium_commit.sha, 'deadbeefcafe')
Exemplo n.º 30
0
    def test_test_patch_empty_diff(self):
        host = MockHost()
        host.executive = mock_git_commands(
            {
                'apply': '',
                'add': '',
                'diff': '',
                'reset': '',
                'clean': '',
                'checkout': '',
            },
            strict=True)
        local_wpt = LocalWPT(host, 'token')

        self.assertEqual(local_wpt.test_patch('dummy patch'), (False, ''))
Exemplo n.º 31
0
    def test_manual_slow_test(self):
        tests_options = '{"a": ["slow"]}'
        FAKE_FILES = {
            '/mock-checkout/WebKitBuild/w3c-tests/csswg-tests/temp': '',
            '/mock-checkout/WebKitBuild/w3c-tests/web-platform-tests/t/new-manual.html': '<!doctype html><meta name="timeout" content="long"><script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>',
            '/mock-checkout/LayoutTests/tests-options.json': tests_options}
        FAKE_FILES.update(FAKE_REPOSITORY)

        host = MockHost()
        host.executive = MockExecutive2()
        host.filesystem = MockFileSystem(files=FAKE_FILES)

        fs = self.import_downloaded_tests(['--no-fetch', '--import-all', '-d', 'w3c'], FAKE_FILES)
        self.assertFalse(fs.exists('/mock-checkout/LayoutTests/w3c/web-platform-tests/t/new-manual.html'))
        self.assertEquals(tests_options, fs.read_text_file('/mock-checkout/LayoutTests/tests-options.json'))
Exemplo n.º 32
0
    def test_import_dir_with_no_tests(self):
        host = MockHost()
        host.executive = MockExecutive2(exception=ScriptError(
            "abort: no repository found in '/Volumes/Source/src/wk/Tools/Scripts/webkitpy/w3c' (.hg not found)!"
        ))
        host.filesystem = MockFileSystem(files=FAKE_FILES)

        importer = TestImporter(host, FAKE_SOURCE_DIR, FAKE_REPO_DIR,
                                optparse.Values({"overwrite": False}))
        oc = OutputCapture()
        oc.capture_output()
        try:
            importer.do_import()
        finally:
            oc.restore_output()
Exemplo n.º 33
0
    def test_import_dir_with_no_tests_and_no_hg(self):
        host = MockHost()
        host.executive = MockExecutive2(exception=OSError())
        host.filesystem = MockFileSystem(files=FAKE_FILES)

        importer = TestImporter(
            host, FAKE_SOURCE_DIR,
            self._parse_options(['-n', '-d', 'w3c', '-t', FAKE_TEST_PATH]))

        oc = OutputCapture()
        oc.capture_output()
        try:
            importer.do_import()
        finally:
            oc.restore_output()
Exemplo n.º 34
0
    def assert_architecture(self, port_name=None, file_output=None, expected_architecture=None):
        host = MockHost()
        host.filesystem.exists = lambda x: 'DumpRenderTree' in x
        if file_output:
            host.executive = executive_mock.MockExecutive2(file_output)

        port = chromium_linux.ChromiumLinuxPort(host, port_name=port_name)
        self.assertEquals(port.architecture(), expected_architecture)
        if expected_architecture == 'x86':
            self.assertTrue(port.baseline_path().endswith('chromium-linux-x86'))
            self.assertTrue(port.baseline_search_path()[0].endswith('chromium-linux-x86'))
            self.assertTrue(port.baseline_search_path()[1].endswith('chromium-linux'))
        else:
            self.assertTrue(port.baseline_path().endswith('chromium-linux'))
            self.assertTrue(port.baseline_search_path()[0].endswith('chromium-linux'))
Exemplo n.º 35
0
    def test_exportable_commits_since(self):
        host = MockHost()
        host.executive = mock_git_commands(
            {
                'show': 'fake message',
                'rev-list': 'add087a97844f4b9e307d9a216940582d96db306',
                'rev-parse': 'add087a97844f4b9e307d9a216940582d96db306',
                'crrev-parse': 'add087a97844f4b9e307d9a216940582d96db306',
                'diff': 'fake diff',
                'diff-tree':
                'third_party/WebKit/LayoutTests/external/wpt/some\n'
                'third_party/WebKit/LayoutTests/external/wpt/files',
                'format-patch': 'hey I\'m a patch',
                'footers': 'cr-rev-position',
            },
            strict=True)

        commits, _ = _exportable_commits_since(
            'beefcafe', host, MockLocalWPT(test_patch=[(True, '')]),
            MockWPTGitHub(pull_requests=[]))
        self.assertEqual(len(commits), 1)
        self.assertIsInstance(commits[0], ChromiumCommit)
        self.assertEqual(host.executive.calls, [
            ['git', 'rev-parse', '--show-toplevel'],
            [
                'git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--',
                'add087a97844f4b9e307d9a216940582d96db306/third_party/WebKit/LayoutTests/external/wpt/'
            ],
            [
                'git', 'footers', '--position',
                'add087a97844f4b9e307d9a216940582d96db306'
            ],
            [
                'git', 'show', '--format=%B', '--no-patch',
                'add087a97844f4b9e307d9a216940582d96db306'
            ],
            [
                'git', 'diff-tree', '--name-only', '--no-commit-id', '-r',
                'add087a97844f4b9e307d9a216940582d96db306', '--',
                '/mock-checkout/third_party/WebKit/LayoutTests/external/wpt'
            ],
            [
                'git', 'format-patch', '-1', '--stdout',
                'add087a97844f4b9e307d9a216940582d96db306', '--',
                'third_party/WebKit/LayoutTests/external/wpt/some',
                'third_party/WebKit/LayoutTests/external/wpt/files'
            ],
        ])
Exemplo n.º 36
0
 def test_cl_description_with_empty_environ(self):
     host = MockHost()
     host.executive = MockExecutive(output='Last commit message\n\n')
     importer = TestImporter(host)
     description = importer._cl_description(directory_owners={})
     self.assertEqual(
         description,
         'Last commit message\n\n'
         'Note to sheriffs: This CL imports external tests and adds\n'
         'expectations for those tests; if this CL is large and causes\n'
         'a few new failures, please fix the failures by adding new\n'
         'lines to TestExpectations rather than reverting. See:\n'
         'https://chromium.googlesource.com'
         '/chromium/src/+/master/docs/testing/web_platform_tests.md\n\n'
         'No-Export: true')
     self.assertEqual(host.executive.calls, [['git', 'log', '-1', '--format=%B']])
Exemplo n.º 37
0
 def _assert_search_path(self,
                         search_paths,
                         sys_platform,
                         use_webkit2=False,
                         qt_version='4.8'):
     # FIXME: Port constructors should not "parse" the port name, but
     # rather be passed components (directly or via setters).  Once
     # we fix that, this method will need a re-write.
     host = MockHost()
     host.executive = MockExecutive2(self._qt_version(qt_version))
     port = QtPort(host,
                   sys_platform=sys_platform,
                   options=MockOptions(webkit_test_runner=use_webkit2,
                                       platform='qt'))
     absolute_search_paths = map(port._webkit_baseline_path, search_paths)
     self.assertEquals(port.baseline_search_path(), absolute_search_paths)
Exemplo n.º 38
0
    def test_import_dir_with_no_tests(self):
        host = MockHost()
        host.executive = MockExecutive2(exception=ScriptError(
            "abort: no repository found in '/Volumes/Source/src/wk/Tools/Scripts/webkitpy/w3c' (.hg not found)!"
        ))
        host.filesystem = MockFileSystem(files=FAKE_FILES)

        importer = TestImporter(
            host, FAKE_SOURCE_DIR,
            self._parse_options(['-n', '-d', 'w3c', '-t', FAKE_TEST_PATH]))
        oc = OutputCapture()
        oc.capture_output()
        try:
            importer.do_import()
        finally:
            oc.restore_output()
Exemplo n.º 39
0
 def test_cl_description_with_directory_owners(self):
     host = MockHost()
     host.executive = MockExecutive(output='Last commit message\n\n')
     importer = TestImporter(host)
     description = importer._cl_description(directory_owners={
         ('*****@*****.**',): ['external/wpt/foo', 'external/wpt/bar'],
         ('*****@*****.**', '*****@*****.**'): ['external/wpt/baz'],
     })
     self.assertIn(
         'Directory owners for changes in this CL:\n'
         '[email protected]:\n'
         '  external/wpt/foo\n'
         '  external/wpt/bar\n'
         '[email protected], [email protected]:\n'
         '  external/wpt/baz\n\n',
         description)
 def test_cl_description_with_empty_environ(self):
     host = MockHost()
     host.executive = MockExecutive(output='Last commit message\n\n')
     importer = TestImporter(host)
     description = importer._cl_description(directory_owners={})
     self.assertEqual(
         description,
         'Last commit message\n\n'
         'Background: https://chromium.googlesource.com/'
         'chromium/src/+/master/docs/testing/web_platform_tests.md\n\n'
         'Note to sheriffs: If this CL causes a small number of new layout\n'
         'test failures, it may be easier to add lines to TestExpectations\n'
         'rather than reverting.\n'
         '[email protected]\n'
         'NOEXPORT=true')
     self.assertEqual(host.executive.calls, [['git', 'log', '-1', '--format=%B']])
Exemplo n.º 41
0
 def test_wait_for_closed_status_timeout(self):
     host = MockHost()
     host.executive = MockExecutive(output='commit')
     git_cl = GitCL(host)
     self.assertIsNone(git_cl.wait_for_closed_status())
     self.assertEqual(
         host.stdout.getvalue(),
         'Waiting for closed status, timeout: 1800 seconds.\n'
         'Waiting for closed status. 120 seconds passed.\n'
         'Waiting for closed status. 360 seconds passed.\n'
         'Waiting for closed status. 600 seconds passed.\n'
         'Waiting for closed status. 840 seconds passed.\n'
         'Waiting for closed status. 1080 seconds passed.\n'
         'Waiting for closed status. 1320 seconds passed.\n'
         'Waiting for closed status. 1560 seconds passed.\n'
         'Waiting for closed status. 1800 seconds passed.\n'
         'Timed out waiting for closed status.\n')
Exemplo n.º 42
0
    def test_initpy_generation(self):
        FAKE_FILES = {
            '/mock-checkout/WebKitBuild/w3c-tests/csswg-tests/.gitmodules': '[submodule "tools/resources"]\n	path = tools/resources\n	url = https://github.com/w3c/testharness.js.git\n  ignore = dirty\n',
            '/mock-checkout/WebKitBuild/w3c-tests/web-platform-tests/.gitmodules': '[submodule "tools/resources"]\n	path = tools/resources\n	url = https://github.com/w3c/testharness.js.git\n  ignore = dirty\n',
        }

        FAKE_FILES.update(FAKE_REPOSITORY)

        host = MockHost()
        host.executive = MockExecutive2()
        host.filesystem = MockFileSystem(files=FAKE_FILES)

        fs = self.import_downloaded_tests(['--no-fetch', '--import-all', '-d', 'w3c'], FAKE_FILES)

        self.assertFalse(fs.exists('/mock-checkout/LayoutTests/w3c/csswg-tests/__init__.py'))
        self.assertTrue(fs.exists('/mock-checkout/LayoutTests/w3c/web-platform-tests/__init__.py'))
        self.assertTrue(fs.getsize('/mock-checkout/LayoutTests/w3c/web-platform-tests/__init__.py') > 0)
Exemplo n.º 43
0
    def test_initpy_generation(self):
        FAKE_FILES = {
            '/mock-checkout/WebKitBuild/w3c-tests/csswg-tests/.gitmodules': '[submodule "tools/resources"]\n	path = tools/resources\n	url = https://github.com/w3c/testharness.js.git\n  ignore = dirty\n',
            '/mock-checkout/WebKitBuild/w3c-tests/web-platform-tests/.gitmodules': '[submodule "tools/resources"]\n	path = tools/resources\n	url = https://github.com/w3c/testharness.js.git\n  ignore = dirty\n',
        }

        FAKE_FILES.update(FAKE_REPOSITORY)

        host = MockHost()
        host.executive = MockExecutive2()
        host.filesystem = MockFileSystem(files=FAKE_FILES)

        fs = self.import_downloaded_tests(['--no-fetch', '--import-all', '-d', 'w3c'], FAKE_FILES)

        self.assertFalse(fs.exists('/mock-checkout/LayoutTests/w3c/csswg-tests/__init__.py'))
        self.assertTrue(fs.exists('/mock-checkout/LayoutTests/w3c/web-platform-tests/__init__.py'))
        self.assertTrue(fs.getsize('/mock-checkout/LayoutTests/w3c/web-platform-tests/__init__.py') > 0)
Exemplo n.º 44
0
 def test_cl_description_with_environ_variables(self):
     host = MockHost()
     host.executive = MockExecutive2(output="Last commit message\n")
     updater = DepsUpdater(host)
     updater.host.environ["BUILDBOT_MASTERNAME"] = "my.master"
     updater.host.environ["BUILDBOT_BUILDERNAME"] = "b"
     updater.host.environ["BUILDBOT_BUILDNUMBER"] = "123"
     description = updater._cl_description()
     self.assertEqual(
         description,
         (
             "Last commit message\n"
             "Build: https://build.chromium.org/p/my.master/builders/b/builds/123\n\n"
             "[email protected]\n"
             "NOEXPORT=true"
         ),
     )
     self.assertEqual(host.executive.calls, [["git", "log", "-1", "--format=%B"]])
Exemplo n.º 45
0
    def test_fetch_current_revision_commit(self):
        host = MockHost()
        host.executive = mock_git_commands(
            {
                'fetch': '',
                'rev-parse': '4de71d0ce799af441c1f106c5432c7fa7256be45',
                'footers': 'no-commit-position-yet'
            },
            strict=True)
        data = {
            'change_id': 'Ib58c7125d85d2fd71af711ea8bbd2dc927ed02cb',
            'subject': 'fake subject',
            '_number': 638250,
            'current_revision': '1',
            'revisions': {
                '1': {
                    'fetch': {
                        'http': {
                            'url':
                            'https://chromium.googlesource.com/chromium/src',
                            'ref': 'refs/changes/50/638250/1'
                        }
                    }
                }
            },
            'owner': {
                'email': '*****@*****.**'
            },
        }
        gerrit_cl = GerritCL(data, MockGerritAPI())
        commit = gerrit_cl.fetch_current_revision_commit(host)

        self.assertEqual(commit.sha,
                         '4de71d0ce799af441c1f106c5432c7fa7256be45')
        self.assertEqual(host.executive.calls,
                         [[
                             'git', 'fetch',
                             'https://chromium.googlesource.com/chromium/src',
                             'refs/changes/50/638250/1'
                         ], ['git', 'rev-parse', 'FETCH_HEAD'],
                          [
                              'git', 'footers', '--position',
                              '4de71d0ce799af441c1f106c5432c7fa7256be45'
                          ]])
    def test_exportable_commits_since_require_clean_by_default(self):
        host = MockHost()
        host.executive = mock_git_commands({
            'diff-tree': 'third_party/WebKit/LayoutTests/external/wpt/some_files',
            'footers': 'cr-rev-position',
            'format-patch': 'hey I\'m a patch',
            'rev-list': 'add087a97844f4b9e307d9a216940582d96db306\n'
                        'add087a97844f4b9e307d9a216940582d96db307\n'
                        'add087a97844f4b9e307d9a216940582d96db308\n'
        })
        local_wpt = MultiResponseMockLocalWPT([
            (True, ''),
            (False, 'patch failure'),
            (True, ''),
        ])

        commits, _ = _exportable_commits_since(
            'beefcafe', host, local_wpt, MockWPTGitHub(pull_requests=[]))
        self.assertEqual(len(commits), 2)
Exemplo n.º 47
0
    def import_downloaded_tests(self, args, files):
        # files are passed as parameter as we cannot clone/fetch/checkout a repo in mock system.

        class TestDownloaderMock(TestDownloader):
            def __init__(self, repository_directory, host, options):
                TestDownloader.__init__(self, repository_directory, host, options)

            def _git_submodules_status(self, repository_directory):
                return 'adb4d391a69877d4a1eaaf51d1725c99a5b8ed84 tools/resources'

        host = MockHost()
        host.executive = MockExecutive2()
        host.filesystem = MockFileSystem(files=files)

        options, args = parse_args(args)
        importer = TestImporter(host, None, options)
        importer._test_downloader = TestDownloaderMock(importer.tests_download_path, importer.host, importer.options)
        importer.do_import()
        return host.filesystem
Exemplo n.º 48
0
    def import_downloaded_tests(self, args, files):
        # files are passed as parameter as we cannot clone/fetch/checkout a repo in mock system.

        class TestDownloaderMock(TestDownloader):
            def __init__(self, repository_directory, host, options):
                TestDownloader.__init__(self, repository_directory, host, options)

            def _git_submodules_status(self, repository_directory):
                return 'adb4d391a69877d4a1eaaf51d1725c99a5b8ed84 tools/resources'

        host = MockHost()
        host.executive = MockExecutive2()
        host.filesystem = MockFileSystem(files=files)

        options, args = parse_args(args)
        importer = TestImporter(host, None, options)
        importer._test_downloader = TestDownloaderMock(importer.tests_download_path, importer.host, importer.options)
        importer.do_import()
        return host.filesystem
Exemplo n.º 49
0
    def test_ignores_commits_with_noexport_true(self):
        host = MockHost()
        host.executive = mock_git_commands({
            'show': 'Commit message\nNOEXPORT=true',
            'rev-list': 'add087a97844f4b9e307d9a216940582d96db306',
            'rev-parse': 'add087a97844f4b9e307d9a216940582d96db306',
            'footers': 'cr-rev-position',
        })

        commits = exportable_commits_since('add087a97844f4b9e307d9a216940582d96db306', host, MockLocalWPT())
        self.assertEqual(commits, [])
        self.assertEqual(host.executive.calls, [
            ['git', 'rev-parse', '--show-toplevel'],
            ['git', 'rev-list', 'add087a97844f4b9e307d9a216940582d96db306..HEAD', '--reverse', '--',
             'add087a97844f4b9e307d9a216940582d96db306/third_party/WebKit/LayoutTests/external/wpt/'],
            ['git', 'footers', '--position', 'add087a97844f4b9e307d9a216940582d96db306'],
            ['git', 'diff-tree', '--name-only', '--no-commit-id', '-r', 'add087a97844f4b9e307d9a216940582d96db306', '--',
             '/mock-checkout/third_party/WebKit/LayoutTests/external/wpt'],
            ['git', 'show', '--format=%B', '--no-patch', 'add087a97844f4b9e307d9a216940582d96db306']
        ])
Exemplo n.º 50
0
    def test_remove_obsolete_content(self):
        FAKE_FILES = {
            '/mock-checkout/WebKitBuild/w3c-tests/csswg-tests/temp': '',
            '/mock-checkout/WebKitBuild/w3c-tests/web-platform-tests/t/new.html': '<!doctype html><script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>',
            '/mock-checkout/WebKitBuild/w3c-tests/web-platform-tests/t/w3c-import.log': 'List of files:\n/LayoutTests/w3c/web-platform-tests/t/obsolete.html',
            '/mock-checkout/LayoutTests/w3c/web-platform-tests/t/obsolete.html': 'obsoleted content',
            '/mock-checkout/LayoutTests/w3c/web-platform-tests/t/obsolete-expected.txt': 'PASS',
        }

        FAKE_FILES.update(FAKE_REPOSITORY)

        host = MockHost()
        host.executive = MockExecutive2()
        host.filesystem = MockFileSystem(files=FAKE_FILES)

        fs = self.import_downloaded_tests(['--no-fetch', '--import-all', '-d', 'w3c'], FAKE_FILES)

        self.assertFalse(fs.exists('/mock-checkout/LayoutTests/w3c/web-platform-tests/t/obsolete.html'))
        self.assertFalse(fs.exists('/mock-checkout/LayoutTests/w3c/web-platform-tests/t/obsolete-expected.txt'))
        self.assertTrue(fs.exists('/mock-checkout/LayoutTests/w3c/web-platform-tests/t/new.html'))
Exemplo n.º 51
0
    def test_filtered_changed_files_blacklist(self):
        host = MockHost()

        fake_files = ['file1', 'MANIFEST.json', 'file3']
        qualified_fake_files = [CHROMIUM_WPT_DIR + f for f in fake_files]

        host.executive = mock_command_exec({
            'diff-tree': '\n'.join(qualified_fake_files),
            'crrev-parse': 'fake rev',
        })

        position_footer = 'Cr-Commit-Position: refs/heads/master@{#789}'
        chromium_commit = ChromiumCommit(host, position=position_footer)

        files = chromium_commit.filtered_changed_files()

        expected_files = ['file1', 'file3']
        qualified_expected_files = [CHROMIUM_WPT_DIR + f for f in expected_files]

        self.assertEqual(files, qualified_expected_files)
Exemplo n.º 52
0
 def test_wait_for_try_jobs_done(self):
     host = MockHost()
     host.executive = MockExecutive(output='lgtm')
     git_cl = GitCL(host)
     git_cl.fetch_raw_try_job_results = lambda **_: [
         {
             'builder_name': 'some-builder',
             'status': 'COMPLETED',
             'result': 'FAILURE',
             'url': 'http://ci.chromium.org/master/some-builder/100',
         },
     ]
     self.assertEqual(
         git_cl.wait_for_try_jobs(),
         CLStatus(status='lgtm',
                  try_job_results={
                      Build('some-builder', 100):
                      TryJobStatus('COMPLETED', 'FAILURE'),
                  }))
     self.assertEqual(host.stdout.getvalue(),
                      'Waiting for try jobs, timeout: 7200 seconds.\n')
    def assert_architecture(self,
                            port_name=None,
                            file_output=None,
                            expected_architecture=None):
        host = MockHost()
        host.filesystem.exists = lambda x: 'DumpRenderTree' in x
        if file_output:
            host.executive = executive_mock.MockExecutive2(file_output)

        port = chromium_linux.ChromiumLinuxPort(host, port_name=port_name)
        self.assertEquals(port.architecture(), expected_architecture)
        if expected_architecture == 'x86':
            self.assertTrue(
                port.baseline_path().endswith('chromium-linux-x86'))
            self.assertTrue(
                port.baseline_search_path()[0].endswith('chromium-linux-x86'))
            self.assertTrue(
                port.baseline_search_path()[1].endswith('chromium-linux'))
        else:
            self.assertTrue(port.baseline_path().endswith('chromium-linux'))
            self.assertTrue(
                port.baseline_search_path()[0].endswith('chromium-linux'))
Exemplo n.º 54
0
 def test_wait_for_try_jobs_cl_closed(self):
     host = MockHost()
     host.executive = MockExecutive(output='closed')
     git_cl = GitCL(host)
     git_cl.fetch_raw_try_job_results = lambda **_: [
         {
             'builder_name': 'some-builder',
             'status': 'STARTED',
             'result': None,
             'url': None,
         },
     ]
     self.assertEqual(
         git_cl.wait_for_try_jobs(),
         CLStatus(
             status='closed',
             try_job_results={
                 Build('some-builder', None): TryJobStatus('STARTED', None),
             },
         ))
     self.assertEqual(host.stdout.getvalue(),
                      'Waiting for try jobs, timeout: 7200 seconds.\n')
Exemplo n.º 55
0
 def test_some_commands_not_run_with_auth(self):
     host = MockHost()
     host.executive = MockExecutive2(output='mock-output')
     git_cl = GitCL(host, auth_refresh_token_json='token.json')
     git_cl.run(['issue'])
     self.assertEqual(host.executive.calls, [['git', 'cl', 'issue']])
Exemplo n.º 56
0
 def test_get_issue_number_none(self):
     host = MockHost()
     host.executive = MockExecutive2(output='Issue number: None (None)')
     git_cl = GitCL(host)
     self.assertEqual(git_cl.get_issue_number(), 'None')
Exemplo n.º 57
0
 def test_get_issue_number(self):
     host = MockHost()
     host.executive = MockExecutive2(output='Issue number: 12345 (http://crrev.com/12345)')
     git_cl = GitCL(host)
     self.assertEqual(git_cl.get_issue_number(), '12345')