Beispiel #1
0
 def test_is_file_exportable(self):
     self.assertTrue(
         is_file_exportable(CHROMIUM_WPT_DIR + 'html/fake-test.html'))
     self.assertFalse(
         is_file_exportable(CHROMIUM_WPT_DIR +
                            'html/fake-test-expected.txt'))
     self.assertFalse(is_file_exportable(CHROMIUM_WPT_DIR +
                                         'MANIFEST.json'))
     self.assertFalse(is_file_exportable(CHROMIUM_WPT_DIR + 'dom/OWNERS'))
Beispiel #2
0
    def is_exportable(self):
        # TODO(robertma): Consolidate with the related part in chromium_exportable_commits.py.

        try:
            files = list(self.current_revision['files'].keys())
        except KeyError:
            # Empty (deleted) CL is not exportable.
            return False

        # Guard against accidental CLs that touch thousands of files.
        if len(files) > 1000:
            _log.info('Rejecting CL with over 1000 files: %s (ID: %s) ',
                      self.subject, self.change_id)
            return False

        if 'No-Export: true' in self.current_revision['commit_with_footers']:
            return False

        if 'NOEXPORT=true' in self.current_revision['commit_with_footers']:
            return False

        files_in_wpt = [f for f in files if f.startswith(CHROMIUM_WPT_DIR)]
        if not files_in_wpt:
            return False

        exportable_files = [f for f in files_in_wpt if is_file_exportable(f)]

        if not exportable_files:
            return False

        return True
Beispiel #3
0
 def filtered_changed_files(self):
     """Returns a list of modified exportable files."""
     changed_files = self.host.executive.run_command([
         'git', 'diff-tree', '--name-only', '--no-commit-id', '-r', self.sha,
         '--', self.absolute_chromium_wpt_dir
     ], cwd=self.absolute_chromium_dir).splitlines()
     return [f for f in changed_files if is_file_exportable(f)]
Beispiel #4
0
    def _clear_out_dest_path(self):
        """Removes all files that are synced with upstream from Chromium WPT.

        Instead of relying on TestCopier to overwrite these files, cleaning up
        first ensures if upstream deletes some files, we also delete them.
        """
        _log.info('Cleaning out tests from %s.', self.dest_path)
        should_remove = lambda fs, dirname, basename: (
            is_file_exportable(fs.relpath(fs.join(dirname, basename), self.finder.chromium_base())))
        files_to_delete = self.fs.files_under(self.dest_path, file_filter=should_remove)
        for subpath in files_to_delete:
            self.remove(self.finder.path_from_layout_tests('external', subpath))
Beispiel #5
0
 def test_is_file_exportable_asserts_path(self):
     # Rejects basenames.
     with self.assertRaises(AssertionError):
         is_file_exportable('MANIFEST.json')
     # Rejects files not in Chromium WPT.
     with self.assertRaises(AssertionError):
         is_file_exportable('third_party/fake/OWNERS')
     # Rejects absolute paths.
     with self.assertRaises(AssertionError):
         is_file_exportable('/mock-checkout/' + RELATIVE_WEB_TESTS +
                            'external/wpt/OWNERS')
 def test_is_file_exportable(self):
     self.assertTrue(
         is_file_exportable(CHROMIUM_WPT_DIR + 'html/fake-test.html'))
     self.assertFalse(
         is_file_exportable(CHROMIUM_WPT_DIR +
                            'html/fake-test-expected.txt'))
     self.assertFalse(is_file_exportable(CHROMIUM_WPT_DIR +
                                         'MANIFEST.json'))
     self.assertFalse(is_file_exportable(CHROMIUM_WPT_DIR + 'dom/OWNERS'))
     self.assertFalse(
         is_file_exportable(CHROMIUM_WPT_DIR + 'dom/DIR_METADATA'))
     self.assertTrue(
         is_file_exportable(CHROMIUM_WPT_DIR +
                            'tools/wptrunner/wptrunner.default.ini'))
     self.assertFalse(
         is_file_exportable(
             CHROMIUM_WPT_DIR +
             'infrastructure/metadata/infrastructure/expected-fail/timeout.html.ini'
         ))
     self.assertFalse(
         is_file_exportable(CHROMIUM_WPT_DIR + 'dom/historical.html.ini'))
Beispiel #7
0
    def _clear_out_dest_path(self):
        """Removes all files that are synced with upstream from Chromium WPT.

        Instead of relying on TestCopier to overwrite these files, cleaning up
        first ensures if upstream deletes some files, we also delete them.
        """
        _log.info('Cleaning out tests from %s.', self.dest_path)

        # TODO(crbug.com/927187): Temporarily prevent the external/wpt/webdriver folder from deletion.
        # Will delete once starting the two-way sync phase on webdriver/tests.
        webdriver_dir_path = self.fs.join(self.dest_path, 'webdriver')

        should_remove = lambda fs, dirname, basename: (
            is_file_exportable(fs.relpath(fs.join(dirname, basename), self.finder.chromium_base())))
        files_to_delete = self.fs.files_under(self.dest_path, file_filter=should_remove)
        for subpath in files_to_delete:
            remove_path = self.finder.path_from_web_tests('external', subpath)
            if remove_path.startswith(webdriver_dir_path):
                continue
            self.remove(remove_path)