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'))
 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)]
Exemple #3
0
    def filter_transform_patch(self, patch):
        """Filters a patch for only exportable changes.

        This method expects a `git diff`-formatted patch.
        """
        filtered_patch = []
        diff_re = re.compile(r'^diff --git a/(.*) b/(.*)$')

        # Patch begins with message, always applicable.
        in_exportable_diff = True

        for line in patch.splitlines():
            # If we're not changing files, continue same behavior.
            if not line.startswith('diff --git'):
                if in_exportable_diff:
                    filtered_patch.append(line)
                continue

            # File is being changed, detect if it's exportable.
            match = diff_re.match(line)
            assert match, "%s is not an expected git diff header" % line
            _, new_file = match.groups()
            if CHROMIUM_WPT_DIR in new_file and is_file_exportable(new_file):
                in_exportable_diff = True
                filtered_patch.append(line)
            else:
                in_exportable_diff = False

        # Join into string; the newline at the end is required.
        if not filtered_patch[-1].strip():
            filtered_patch = filtered_patch[:-1]
        patch = '\n'.join(filtered_patch) + '\n'
        return patch.replace(CHROMIUM_WPT_DIR, '')
Exemple #4
0
    def is_exportable(self):
        files = self.current_revision['files'].keys()

        # 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 self.subject.startswith('Import wpt@'):
            return False

        if 'Import' in self.subject:
            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
Exemple #5
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))
 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/third_party/WebKit/LayoutTests/external/wpt/OWNERS'
         )
Exemple #7
0
    def is_exportable(self):
        # TODO(robertma): Consolidate with the related part in chromium_exportable_commits.py.

        try:
            files = 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 self.subject.startswith('Import wpt@'):
            return False

        if 'Import' in self.subject:
            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