Commit dbaedd85 authored by Rakib M. Hasan's avatar Rakib M. Hasan Committed by Commit Bot

blinkpy: Add linter for non WPT tests in Android Override files

Bug: 1050754
Change-Id: Ica13baa307a947362957060551d0984f591b7e67
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2283636Reviewed-by: default avatarRobert Ma <robertma@chromium.org>
Commit-Queue: Robert Ma <robertma@chromium.org>
Commit-Queue: Rakib Hasan <rmhasan@google.com>
Cr-Commit-Position: refs/heads/master@{#786528}
parent d9dd09c1
......@@ -37,6 +37,8 @@ from blinkpy.common.system.log_utils import configure_logging
from blinkpy.web_tests.models.test_expectations import (TestExpectations,
ParseError)
from blinkpy.web_tests.models.typ_types import ResultType
from blinkpy.web_tests.port.android import (
PRODUCTS_TO_EXPECTATION_FILE_PATHS, ANDROID_DISABLED_TESTS)
from blinkpy.web_tests.port.factory import platform_options
_log = logging.getLogger(__name__)
......@@ -70,15 +72,8 @@ def lint(host, options):
port = host.port_factory.get(options.platform)
# Add all extra expectation files to be linted.
options.additional_expectations.extend([
host.filesystem.join(port.web_tests_dir(), 'android',
'ClankWPTOverrideExpectations'),
host.filesystem.join(port.web_tests_dir(), 'android',
'WebviewWPTOverrideExpectations'),
host.filesystem.join(port.web_tests_dir(), 'android',
'WeblayerWPTOverrideExpectations'),
host.filesystem.join(port.web_tests_dir(), 'android',
'AndroidWPTNeverFixTests'),
options.additional_expectations.extend(
PRODUCTS_TO_EXPECTATION_FILE_PATHS.values() + [ANDROID_DISABLED_TESTS] + [
host.filesystem.join(port.web_tests_dir(), 'WPTOverrideExpectations'),
host.filesystem.join(port.web_tests_dir(), 'WebGPUExpectations'),
])
......@@ -301,6 +296,9 @@ def _check_expectations(host, port, path, test_expectations, options):
failures = _check_test_existence(host, port, path, expectations)
failures.extend(_check_directory_glob(host, port, path, expectations))
failures.extend(_check_never_fix_tests(host, port, path, expectations))
if path in PRODUCTS_TO_EXPECTATION_FILE_PATHS.values():
failures.extend(_check_non_wpt_in_android_override(
host, port, path, expectations))
# TODO(crbug.com/1080691): Change this to failures once
# wpt_expectations_updater is fixed.
warnings = []
......@@ -311,6 +309,17 @@ def _check_expectations(host, port, path, test_expectations, options):
return failures, warnings
def _check_non_wpt_in_android_override(host, port, path, expectations):
failures = []
for exp in expectations:
if exp.test and not port.is_wpt_test(exp.test):
error = "{}:{} Expectation '{}' is for a non WPT test".format(
host.filesystem.basename(path), exp.lineno, exp.to_string())
failures.append(error)
_log.error(error)
return failures
def check_virtual_test_suites(host, options):
port = host.port_factory.get(options=options)
fs = host.filesystem
......
......@@ -34,6 +34,7 @@ from blinkpy.common import exit_codes
from blinkpy.common.host_mock import MockHost
from blinkpy.common.system.log_testing import LoggingTestCase
from blinkpy.web_tests import lint_test_expectations
from blinkpy.web_tests.port.android import PRODUCTS_TO_EXPECTATION_FILE_PATHS
from blinkpy.web_tests.port.base import VirtualTestSuite
from blinkpy.web_tests.port.test import WEB_TEST_DIR
......@@ -283,6 +284,25 @@ class LintTest(LoggingTestCase):
self.assertIn('Test does not exist', failures[i])
self.assertIn(expected_non_existence[i], failures[i])
def test_only_wpt_in_android_override_files(self):
options = optparse.Values({
'additional_expectations': [],
'platform': 'test',
'debug_rwt_logging': False
})
host = MockHost()
port = host.port_factory.get(options.platform, options=options)
raw_expectations = ('# results: [ Failure ]\n'
'external/wpt/test.html [ Failure ]\n'
'non-wpt/test.html [ Failure ]\n')
for path in PRODUCTS_TO_EXPECTATION_FILE_PATHS.values():
host.filesystem.write_text_file(path, raw_expectations)
host.port_factory.get = lambda platform, options=None: port
host.port_factory.all_port_names = lambda platform=None: [port.name()]
port.test_exists = lambda _: True
failures, _ = lint_test_expectations.lint(host, options)
self.assertTrue(all('is for a non WPT test' in f for f in failures))
def test_lint_globs(self):
options = optparse.Values({
'additional_expectations': [],
......
......@@ -4789,4 +4789,3 @@ crbug.com/1050754 external/wpt/xhr/setrequestheader-content-type.htm [ Failure ]
crbug.com/1050754 external/wpt/xhr/setrequestheader-header-allowed.htm [ Failure ]
crbug.com/1050754 external/wpt/xhr/sync-no-timeout.any.sharedworker.html [ Failure ]
crbug.com/1050754 external/wpt/xslt/transformToFragment.tentative.window.html [ Failure ]
crbug.com/1050754 printing/print-microtask-after-navigate.html [ Failure ]
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