Commit 6f41c004 authored by Luke Zielinski's avatar Luke Zielinski Committed by Commit Bot

Skip importing/export most .ini files in wpt codebase.

This will skip the various metadata .ini files that are currently
checked-in upstream (like for infrastructure tests). It will also avoid
exporting any chromium-specific metadata.ini files that we create in the
near future.

Bug: 1116091
Change-Id: I69389cd8410416d9b0e58789edb3bac84a886397
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2354517
Commit-Queue: Luke Z <lpz@chromium.org>
Reviewed-by: default avatarRobert Ma <robertma@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798680}
parent 11754d3c
......@@ -67,6 +67,37 @@ def is_testharness_baseline(filename):
return filename.endswith('-expected.txt')
def is_disallowed_ini(filename):
"""Checks whether the file is a disallowed (.ini) file.
This is primarily intended to skip WPT metadata .ini files, which are used
in WPT to set expected statuses for tests. Chromium maintains its own list
of such files and we don't want those to be shared with upstream.
There are a few .ini files that we do allow, which are mostly configuration
files for wptrunner.
Args:
filename: the basename of the file to check
"""
if not filename.endswith('.ini'):
return False
allowed_inis = [
# Configuration for mypy support
'mypy.ini',
# Configuration of wpt lint
'py27-flake8.ini',
'py3-flake8.ini',
# Configuration of wpt framework unit tests
'pytest.ini',
'tox.ini',
# Contains default locations of tests and manifest for wptrunner.
# Required for wptrunner to work.
'wptrunner.default.ini',
]
return filename not in allowed_inis
def is_basename_skipped(basename):
"""Checks whether to skip (not sync) a file based on its basename.
......@@ -81,7 +112,7 @@ def is_basename_skipped(basename):
'DIR_METADATA', # https://crbug.com/1103374
]
return (basename in skipped_basenames or is_testharness_baseline(basename)
or basename.startswith('.'))
or basename.startswith('.') or is_disallowed_ini(basename))
def is_file_exportable(path):
......
......@@ -8,8 +8,8 @@ import unittest
from blinkpy.common.host_mock import MockHost
from blinkpy.common.path_finder import RELATIVE_WEB_TESTS
from blinkpy.w3c.common import (read_credentials, is_testharness_baseline,
is_basename_skipped, is_file_exportable,
CHROMIUM_WPT_DIR)
is_disallowed_ini, is_basename_skipped,
is_file_exportable, CHROMIUM_WPT_DIR)
class CommonTest(unittest.TestCase):
......@@ -94,6 +94,12 @@ class CommonTest(unittest.TestCase):
self.assertTrue(is_basename_skipped('.gitignore'))
self.assertFalse(is_basename_skipped('something.json'))
def test_is_disallowed_ini(self):
self.assertFalse(is_disallowed_ini('tox.ini'))
self.assertFalse(is_disallowed_ini("wptrunner.default.ini"))
self.assertTrue(is_disallowed_ini('test.html.ini'))
self.assertTrue(is_disallowed_ini('__dir__.ini'))
def test_is_basename_skipped_asserts_basename(self):
with self.assertRaises(AssertionError):
is_basename_skipped('third_party/fake/OWNERS')
......@@ -109,6 +115,16 @@ class CommonTest(unittest.TestCase):
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'))
def test_is_file_exportable_asserts_path(self):
# Rejects basenames.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment