Revert "Create AllTestsByDirectories.json for blink_web_tests"
This reverts commit 93e16e0560
.
Reason for revert: <People have concern on this, revert first>
Original change's description:
> Create AllTestsByDirectories.json for blink_web_tests
>
> So that we can speed up collecting test cases. This json file is
> a dictionary with directory names as the key, and test cases under
> the directory in a list as the value. Both keys and values are
> sorted.
>
> Added a presubmit check to ensure this file is updated when
> there is change to test cases.
>
> Bug: 982208
> Change-Id: Ibacaee4b5159a82806d210ce7ec42a84e5f9c531
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3067372
> Commit-Queue: Weizhong Xia <weizhong@google.com>
> Reviewed-by: Dirk Pranke <dpranke@google.com>
> Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#912423}
Bug: 982208
Change-Id: I0c32c81ab4e520ee10630a8ac70e7989ef066465
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3100379
Commit-Queue: Weizhong Xia <weizhong@google.com>
Reviewed-by: Dirk Pranke <dpranke@google.com>
Cr-Commit-Position: refs/heads/master@{#912665}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
3d6f30615d
commit
d33ab307b9
2
BUILD.gn
2
BUILD.gn
@ -1156,7 +1156,6 @@ if (!is_ios) {
|
||||
"//third_party/blink/tools/",
|
||||
"//third_party/blink/web_tests/VirtualTestSuites",
|
||||
"//third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json",
|
||||
"//third_party/blink/web_tests/AllTestsByDirectories.json",
|
||||
"//third_party/blink/web_tests/external/wpt/common/",
|
||||
"//third_party/blink/web_tests/external/wpt/resources/",
|
||||
"//third_party/blink/web_tests/resources/",
|
||||
@ -1211,7 +1210,6 @@ if (!is_ios) {
|
||||
"--seed",
|
||||
"4",
|
||||
"--debug-rwt-logging",
|
||||
"--use-checkedin-list",
|
||||
"--no-show-results",
|
||||
"--zero-tests-executed-ok",
|
||||
"--clobber-old-results",
|
||||
|
@ -175,18 +175,6 @@ to see a full list of options. A few of the most useful options are below:
|
||||
| `--fully-parallel` | Run tests in parallel using as many child processes as the system has cores. |
|
||||
| `--driver-logging` | Print C++ logs (LOG(WARNING), etc). |
|
||||
|
||||
### Collecting Tests
|
||||
|
||||
The test runner collects legacy tests by walking through the folders under
|
||||
web_tests and WPT tests from WPT Manifest. This takes around 40 seconds on a
|
||||
machine with SSD. The file AllTestsByDirectories.json now collects all the
|
||||
test cases before hand. When `--use-checkedin-list` is set, the test runner
|
||||
loads tests from this file. The flag defaults to False, but is set to True for
|
||||
all swarming bots. When the flag is set, it takes less than 2 seconds to load
|
||||
test cases. When uploading or committing a CL, a presubmit check is run to
|
||||
ensure the json file is always up-to-date. And if it is not, the developer will
|
||||
be prompted to update it by running `collect_web_tests.py`.
|
||||
|
||||
## Success and Failure
|
||||
|
||||
A test succeeds when its output matches the pre-defined expected results. If any
|
||||
|
@ -30,8 +30,8 @@ from blinkpy.w3c.local_wpt import LocalWPT
|
||||
from blinkpy.w3c.test_copier import TestCopier
|
||||
from blinkpy.w3c.wpt_expectations_updater import WPTExpectationsUpdater
|
||||
from blinkpy.w3c.wpt_github import WPTGitHub
|
||||
from blinkpy.w3c.wpt_manifest import WPTManifest, BASE_MANIFEST_NAME, MANIFEST_NAME
|
||||
from blinkpy.web_tests.port.base import Port, ALL_TESTS_BY_DIRECTORIES
|
||||
from blinkpy.w3c.wpt_manifest import WPTManifest, BASE_MANIFEST_NAME
|
||||
from blinkpy.web_tests.port.base import Port
|
||||
from blinkpy.web_tests.models.test_expectations import TestExpectations
|
||||
|
||||
# Settings for how often to check try job results and how long to wait.
|
||||
@ -186,8 +186,6 @@ class TestImporter(object):
|
||||
_log.info('Only manifest was updated; skipping the import.')
|
||||
return 0
|
||||
|
||||
self._update_all_tests_list()
|
||||
|
||||
with self._expectations_updater.prepare_smoke_tests(self.chromium_git):
|
||||
self._commit_changes(commit_message)
|
||||
_log.info('Changes imported and committed.')
|
||||
@ -434,26 +432,6 @@ class TestImporter(object):
|
||||
verify_merged_pr=True)
|
||||
return commits
|
||||
|
||||
def _update_all_tests_list(self):
|
||||
"""Update AllTestsByDirectories.json for imported tests.
|
||||
|
||||
Run collect_web_tests.py, then stages the updated json file
|
||||
in the git index, ready to commit.
|
||||
"""
|
||||
_log.info('Updating AllTestsByDirectories.json')
|
||||
all_tests_by_dirs_path = self.fs.normpath(
|
||||
self.fs.join(self.dest_path, '..', '..',
|
||||
ALL_TESTS_BY_DIRECTORIES))
|
||||
script_path = self.fs.normpath(
|
||||
self.fs.join(self.dest_path, '..', '..', '..',
|
||||
'tools', 'collect_web_tests.py'))
|
||||
command = [
|
||||
self.host.port_factory.get().python3_command(),
|
||||
script_path, 'external/wpt'
|
||||
]
|
||||
self.host.executive.run_command(command)
|
||||
self.chromium_git.add_list([all_tests_by_dirs_path])
|
||||
|
||||
def _generate_manifest(self):
|
||||
"""Generates MANIFEST.json for imported tests.
|
||||
|
||||
@ -463,7 +441,7 @@ class TestImporter(object):
|
||||
_log.info('Generating MANIFEST.json')
|
||||
WPTManifest.generate_manifest(self.host.port_factory.get(),
|
||||
self.dest_path)
|
||||
manifest_path = self.fs.join(self.dest_path, MANIFEST_NAME)
|
||||
manifest_path = self.fs.join(self.dest_path, 'MANIFEST.json')
|
||||
assert self.fs.exists(manifest_path)
|
||||
manifest_base_path = self.fs.normpath(
|
||||
self.fs.join(self.dest_path, '..', BASE_MANIFEST_NAME))
|
||||
|
@ -25,17 +25,12 @@ from blinkpy.w3c.wpt_github_mock import MockWPTGitHub
|
||||
from blinkpy.w3c.wpt_manifest import BASE_MANIFEST_NAME
|
||||
from blinkpy.web_tests.port.android import PRODUCTS_TO_EXPECTATION_FILE_PATHS
|
||||
from blinkpy.web_tests.port.android import ANDROID_DISABLED_TESTS
|
||||
from blinkpy.web_tests.port.base import ALL_TESTS_BY_DIRECTORIES
|
||||
|
||||
MOCK_WEB_TESTS = '/mock-checkout/' + RELATIVE_WEB_TESTS
|
||||
MANIFEST_INSTALL_CMD = [
|
||||
'python3', '/mock-checkout/third_party/wpt_tools/wpt/wpt', 'manifest',
|
||||
'-v', '--no-download', '--tests-root', MOCK_WEB_TESTS + 'external/wpt'
|
||||
]
|
||||
UPDATE_TEST_LIST_CMD = [
|
||||
'python3', '/mock-checkout/third_party/blink/tools/collect_web_tests.py',
|
||||
'external/wpt'
|
||||
]
|
||||
|
||||
|
||||
class TestImporterTest(LoggingTestCase):
|
||||
@ -525,15 +520,6 @@ class TestImporterTest(LoggingTestCase):
|
||||
importer.sheriff_email())
|
||||
self.assertLog([])
|
||||
|
||||
def test_update_all_tests_list(self):
|
||||
host = self.mock_host()
|
||||
importer = self._get_test_importer(host)
|
||||
importer._update_all_tests_list()
|
||||
self.assertEqual(host.executive.calls, [MANIFEST_INSTALL_CMD,
|
||||
UPDATE_TEST_LIST_CMD])
|
||||
self.assertEqual(importer.chromium_git.added_paths,
|
||||
{MOCK_WEB_TESTS + ALL_TESTS_BY_DIRECTORIES})
|
||||
|
||||
def test_generate_manifest_successful_run(self):
|
||||
# This test doesn't test any aspect of the real manifest script, it just
|
||||
# asserts that TestImporter._generate_manifest would invoke the script.
|
||||
|
@ -69,8 +69,6 @@ _log = logging.getLogger(__name__)
|
||||
# Path relative to the build directory.
|
||||
CONTENT_SHELL_FONTS_DIR = "test_fonts"
|
||||
|
||||
ALL_TESTS_BY_DIRECTORIES = "AllTestsByDirectories.json"
|
||||
|
||||
FONT_FILES = [
|
||||
[[CONTENT_SHELL_FONTS_DIR], 'Ahem.ttf', None],
|
||||
[[CONTENT_SHELL_FONTS_DIR], 'Arimo-Bold.ttf', None],
|
||||
@ -900,14 +898,6 @@ class Port(object):
|
||||
reftest_list.append((expectation, ref_absolute_path))
|
||||
return reftest_list
|
||||
|
||||
def read_all_tests_by_directories(self):
|
||||
"""Load directory->tests mapping from AllTestsByDirectories.json.
|
||||
"""
|
||||
path = self._filesystem.join(self.web_tests_dir(), ALL_TESTS_BY_DIRECTORIES)
|
||||
content = self._filesystem.read_text_file(path)
|
||||
tests_by_dir = json.loads(content)
|
||||
return tests_by_dir
|
||||
|
||||
def tests(self, paths=None):
|
||||
"""Returns all tests or tests matching supplied paths.
|
||||
|
||||
@ -921,10 +911,9 @@ class Port(object):
|
||||
for instance a file path test.any.js could correspond to two test
|
||||
names: test.any.html and test.any.worker.html.
|
||||
"""
|
||||
tests = self.real_tests(paths)
|
||||
|
||||
if paths:
|
||||
tests = self.real_tests(paths)
|
||||
|
||||
tests.extend(self._virtual_tests_matching_paths(paths))
|
||||
if (any(wpt_path in path for wpt_path in self.WPT_DIRS
|
||||
for path in paths)
|
||||
@ -932,45 +921,35 @@ class Port(object):
|
||||
or any('external' in path for path in paths)):
|
||||
tests.extend(self._wpt_test_urls_matching_paths(paths))
|
||||
else:
|
||||
if self.get_option('use_checkedin_list', False):
|
||||
tests_by_dir = self.read_all_tests_by_directories()
|
||||
tests = self.real_tests_from_dict(tests_by_dir)
|
||||
else:
|
||||
tests = self.real_tests(paths)
|
||||
# '/' is used instead of filesystem.sep as the WPT manifest always
|
||||
# uses '/' for paths (it is not OS dependent).
|
||||
wpt_tests = [
|
||||
wpt_path + '/' + test for wpt_path in self.WPT_DIRS
|
||||
for test in self.wpt_manifest(wpt_path).all_urls()
|
||||
]
|
||||
tests_by_dir = defaultdict(list)
|
||||
for test in tests + wpt_tests:
|
||||
dirname = os.path.dirname(test) + '/'
|
||||
tests_by_dir[dirname].append(test)
|
||||
tests.extend(wpt_tests)
|
||||
# '/' is used instead of filesystem.sep as the WPT manifest always
|
||||
# uses '/' for paths (it is not OS dependent).
|
||||
wpt_tests = [
|
||||
wpt_path + '/' + test for wpt_path in self.WPT_DIRS
|
||||
for test in self.wpt_manifest(wpt_path).all_urls()
|
||||
]
|
||||
tests_by_dir = defaultdict(list)
|
||||
for test in tests + wpt_tests:
|
||||
dirname = os.path.dirname(test) + '/'
|
||||
tests_by_dir[dirname].append(test)
|
||||
|
||||
tests.extend(self._all_virtual_tests(tests_by_dir))
|
||||
tests.extend(wpt_tests)
|
||||
return tests
|
||||
|
||||
def real_tests_from_dict(self, tests_by_dir, paths=None):
|
||||
def real_tests_from_dict(self, paths, tests_by_dir):
|
||||
"""Find all real tests in paths, using results saved in dict."""
|
||||
tests = []
|
||||
if paths:
|
||||
for path in paths:
|
||||
if self._has_supported_extension_for_all(path):
|
||||
tests.append(path)
|
||||
continue
|
||||
path = path + '/' if path[-1] != '/' else path
|
||||
for key, value in tests_by_dir.items():
|
||||
if key.startswith(path):
|
||||
tests.extend(value)
|
||||
return tests
|
||||
else:
|
||||
for _, v in tests_by_dir.items():
|
||||
tests.extend(v)
|
||||
return tests
|
||||
files = []
|
||||
for path in paths:
|
||||
if self._has_supported_extension_for_all(path):
|
||||
files.append(path)
|
||||
continue
|
||||
path = path + '/' if path[-1] != '/' else path
|
||||
for key, value in tests_by_dir.items():
|
||||
if key.startswith(path):
|
||||
files.extend(value)
|
||||
return files
|
||||
|
||||
def real_tests(self, paths=None):
|
||||
def real_tests(self, paths):
|
||||
"""Find all real tests in paths except WPT."""
|
||||
# When collecting test cases, skip these directories.
|
||||
skipped_directories = set([
|
||||
@ -2020,7 +1999,7 @@ class Port(object):
|
||||
for suite in self.virtual_test_suites():
|
||||
if suite.bases:
|
||||
tests.extend(map(lambda x: suite.full_prefix + x,
|
||||
self.real_tests_from_dict(tests_by_dir, suite.bases)))
|
||||
self.real_tests_from_dict(suite.bases, tests_by_dir)))
|
||||
return tests
|
||||
|
||||
def _get_bases_for_suite_with_paths(self, suite, paths):
|
||||
|
@ -29,13 +29,11 @@
|
||||
import base64
|
||||
import json
|
||||
import time
|
||||
from collections import defaultdict
|
||||
|
||||
from blinkpy.common import exit_codes
|
||||
from blinkpy.common.system.crash_logs import CrashLogs
|
||||
from blinkpy.web_tests.models.test_configuration import TestConfiguration
|
||||
from blinkpy.web_tests.port.base import (Port, VirtualTestSuite,
|
||||
ALL_TESTS_BY_DIRECTORIES)
|
||||
from blinkpy.web_tests.port.base import Port, VirtualTestSuite
|
||||
from blinkpy.web_tests.port.driver import DeviceFailure, Driver, DriverOutput
|
||||
from blinkpy.w3c.wpt_manifest import BASE_MANIFEST_NAME
|
||||
|
||||
@ -493,13 +491,10 @@ passes/slow.html [ Slow ]
|
||||
filesystem.write_binary_file(
|
||||
filesystem.join(dirname, base + suffix), contents)
|
||||
|
||||
tests_by_dir = defaultdict(list)
|
||||
|
||||
# Add each test and the expected output, if any.
|
||||
test_list = unit_test_list()
|
||||
for test in test_list.tests.values():
|
||||
add_file(test, test.name[test.name.rfind('.'):], b'')
|
||||
tests_by_dir[test.name[0:test.name.rfind('/') + 1]].append(test.name)
|
||||
if test.expected_audio:
|
||||
add_file(test, '-expected.wav', test.expected_audio)
|
||||
if test.expected_text:
|
||||
@ -507,11 +502,6 @@ passes/slow.html [ Slow ]
|
||||
if test.expected_image:
|
||||
add_file(test, '-expected.png', test.expected_image)
|
||||
|
||||
all_tests_by_dir_path = filesystem.join(WEB_TEST_DIR,
|
||||
ALL_TESTS_BY_DIRECTORIES)
|
||||
filesystem.write_text_file(all_tests_by_dir_path,
|
||||
json.dumps(tests_by_dir, indent=2, sort_keys=True))
|
||||
|
||||
filesystem.write_text_file(
|
||||
filesystem.join(WEB_TEST_DIR, 'virtual', 'virtual_passes', 'passes',
|
||||
'args-expected.txt'), 'args-txt --virtual-arg')
|
||||
@ -624,16 +614,6 @@ def add_manifest_to_mock_filesystem(port):
|
||||
filesystem.write_text_file(WEB_TEST_DIR + '/wpt_internal/dom/bar.html',
|
||||
'baz')
|
||||
|
||||
all_tests_by_dir_path = filesystem.join(WEB_TEST_DIR, ALL_TESTS_BY_DIRECTORIES)
|
||||
tests_by_dir = json.loads(filesystem.read_text_file(all_tests_by_dir_path))
|
||||
tests_by_dir['external/wpt/dom/ranges/'] = ['external/wpt/dom/ranges/Range-attributes.html',
|
||||
'external/wpt/dom/ranges/Range-attributes-slow.html']
|
||||
tests_by_dir['external/wpt/console/'] = ['external/wpt/console/console-is-a-namespace.any.html',
|
||||
'external/wpt/console/console-is-a-namespace.any.worker.html']
|
||||
tests_by_dir['wpt_internal/dom/'] = ['wpt_internal/dom/bar.html']
|
||||
filesystem.write_text_file(all_tests_by_dir_path, json.dumps(tests_by_dir, indent=2, sort_keys=True))
|
||||
|
||||
|
||||
|
||||
class TestPort(Port):
|
||||
port_name = 'test'
|
||||
|
@ -534,14 +534,6 @@ def parse_args(args):
|
||||
help=
|
||||
'read list of tests to run from file, as if they were specified on the command line'
|
||||
),
|
||||
optparse.make_option(
|
||||
'--use-checkedin-list',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help=
|
||||
("Load tests from AllTestsByDirectories.json. Use it if you don't have"
|
||||
" any unchecked in tests. This can save about 30 seconds by not"
|
||||
" searching the file system.")),
|
||||
optparse.make_option(
|
||||
'--isolated-script-test-filter',
|
||||
action='append',
|
||||
|
@ -1,87 +0,0 @@
|
||||
# Copyright 2021 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from collections import defaultdict
|
||||
|
||||
from blinkpy.common.host import Host
|
||||
from blinkpy.common.path_finder import RELATIVE_WEB_TESTS
|
||||
from blinkpy.w3c.wpt_manifest import WPTManifest
|
||||
from blinkpy.web_tests.port.base import ALL_TESTS_BY_DIRECTORIES
|
||||
from blinkpy.web_tests.port.factory import PortFactory
|
||||
|
||||
|
||||
class WebTestsCollector(object):
|
||||
def __init__(self, host):
|
||||
self.host = host
|
||||
self.fs = host.filesystem
|
||||
self.port = PortFactory(host).get()
|
||||
|
||||
def main(self, argv=None):
|
||||
usage = 'Precollects web tests and save the result to AllTestsByDirectories.json.'
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.description = usage
|
||||
parser.add_argument('--out', '-o', required=False, default=None,
|
||||
help='Path for the output list file')
|
||||
parser.add_argument('paths', nargs='*',
|
||||
help='Paths for which to update test cases')
|
||||
options = parser.parse_args(argv)
|
||||
all_tests_by_dir_path = self.fs.join(self.port.web_tests_dir(),
|
||||
ALL_TESTS_BY_DIRECTORIES)
|
||||
return self.collect_tests(options.out if options.out else all_tests_by_dir_path,
|
||||
options.paths)
|
||||
|
||||
def collect_tests(self, out, paths):
|
||||
all_tests_by_dir_path = self.fs.join(self.port.web_tests_dir(),
|
||||
ALL_TESTS_BY_DIRECTORIES)
|
||||
|
||||
if self.fs.exists(all_tests_by_dir_path):
|
||||
old_data = self.fs.read_text_file(all_tests_by_dir_path)
|
||||
else:
|
||||
old_data = '{}'
|
||||
|
||||
if paths and self.fs.exists(all_tests_by_dir_path):
|
||||
# do a partial update for this case
|
||||
tests = self.port.real_tests(paths)
|
||||
if 'external/wpt' in paths:
|
||||
WPTManifest.ensure_manifest(self.port)
|
||||
tests.extend([
|
||||
'external/wpt/' + test
|
||||
for test in self.port.wpt_manifest('external/wpt').all_urls()
|
||||
])
|
||||
if 'wpt_internal' in paths:
|
||||
WPTManifest.ensure_manifest(self.port, 'wpt_internal')
|
||||
tests.extend([
|
||||
'wpt_internal/' + test
|
||||
for test in self.port.wpt_manifest('wpt_internal').all_urls()
|
||||
])
|
||||
tests_by_dir = self.port.read_all_tests_by_directories()
|
||||
else:
|
||||
tests = self.port.real_tests(None)
|
||||
WPTManifest.ensure_manifest(self.port)
|
||||
WPTManifest.ensure_manifest(self.port, 'wpt_internal')
|
||||
tests.extend([
|
||||
wpt_path + '/' + test for wpt_path in self.port.WPT_DIRS
|
||||
for test in self.port.wpt_manifest(wpt_path).all_urls()
|
||||
])
|
||||
tests_by_dir = {}
|
||||
|
||||
for key in list(tests_by_dir):
|
||||
if any(key.startswith(path + '/') for path in paths):
|
||||
tests_by_dir.pop(key, None)
|
||||
|
||||
newdict = defaultdict(list)
|
||||
for test in tests:
|
||||
dirname = self.fs.dirname(test) + '/'
|
||||
newdict[dirname].append(test)
|
||||
|
||||
for _, v in newdict.items():
|
||||
v.sort()
|
||||
|
||||
tests_by_dir.update(newdict)
|
||||
new_data = json.dumps(tests_by_dir, indent=2, sort_keys=True)
|
||||
self.fs.write_text_file(out, new_data)
|
||||
|
||||
return 0 if old_data == new_data else 1
|
@ -1,92 +0,0 @@
|
||||
# Copyright 2021 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import unittest
|
||||
|
||||
from blinkpy.common.path_finder import RELATIVE_WEB_TESTS
|
||||
from blinkpy.common.system.log_testing import LoggingTestCase
|
||||
from blinkpy.common.system.system_host_mock import MockSystemHost
|
||||
from blinkpy.web_tests.port.base import ALL_TESTS_BY_DIRECTORIES
|
||||
from blinkpy.web_tests.port.factory import PortFactory
|
||||
from blinkpy.web_tests.web_tests_collector import WebTestsCollector
|
||||
from blinkpy.w3c.wpt_manifest import BASE_MANIFEST_NAME
|
||||
|
||||
MOCK_WEB_TESTS = '/mock-checkout/' + RELATIVE_WEB_TESTS
|
||||
|
||||
class WebTestsCollectorTest(LoggingTestCase):
|
||||
|
||||
def mock_host(self):
|
||||
host = MockSystemHost()
|
||||
host.port_factory = PortFactory(host)
|
||||
fs = host.filesystem
|
||||
fs.write_text_file(MOCK_WEB_TESTS + 'http/pass/foo.html', ' ')
|
||||
fs.write_text_file(MOCK_WEB_TESTS + 'http/pass/bar.html', ' ')
|
||||
fs.write_text_file(MOCK_WEB_TESTS + 'dom/dom1.html', ' ')
|
||||
fs.write_text_file(MOCK_WEB_TESTS + 'dom/dom2.html', ' ')
|
||||
fs.write_text_file(MOCK_WEB_TESTS + 'external/wpt/css/foo.html', ' ')
|
||||
fs.write_text_file(fs.join(MOCK_WEB_TESTS, 'external', BASE_MANIFEST_NAME),
|
||||
'{"manifest": "base"}')
|
||||
data = ('{\n'
|
||||
' "dom/": [\n'
|
||||
' "dom/dom1.html", \n'
|
||||
' "dom/dom2.html"\n'
|
||||
' ], \n'
|
||||
' "external/wpt/css/": [\n'
|
||||
' "external/wpt/css/foo.html"\n'
|
||||
' ], \n'
|
||||
' "http/pass/": [\n'
|
||||
' "http/pass/bar.html", \n'
|
||||
' "http/pass/foo.html"\n'
|
||||
' ]\n'
|
||||
'}')
|
||||
fs.write_text_file(MOCK_WEB_TESTS + ALL_TESTS_BY_DIRECTORIES, data)
|
||||
return host
|
||||
|
||||
def test_add_test(self):
|
||||
host = self.mock_host()
|
||||
fs = host.filesystem
|
||||
fs.write_text_file(MOCK_WEB_TESTS + 'dom/dom3.html', ' ')
|
||||
fs.write_text_file(MOCK_WEB_TESTS + 'css/bar.html', ' ')
|
||||
collector = WebTestsCollector(host)
|
||||
collector.port.web_tests_dir = lambda: MOCK_WEB_TESTS
|
||||
path = MOCK_WEB_TESTS + ALL_TESTS_BY_DIRECTORIES
|
||||
collector.collect_tests(path, ['css', 'dom'])
|
||||
data = ('{\n'
|
||||
' "css/": [\n'
|
||||
' "css/bar.html"\n'
|
||||
' ], \n'
|
||||
' "dom/": [\n'
|
||||
' "dom/dom1.html", \n'
|
||||
' "dom/dom2.html", \n'
|
||||
' "dom/dom3.html"\n'
|
||||
' ], \n'
|
||||
' "external/wpt/css/": [\n'
|
||||
' "external/wpt/css/foo.html"\n'
|
||||
' ], \n'
|
||||
' "http/pass/": [\n'
|
||||
' "http/pass/bar.html", \n'
|
||||
' "http/pass/foo.html"\n'
|
||||
' ]\n'
|
||||
'}')
|
||||
self.assertEqual(fs.read_text_file(path), data)
|
||||
|
||||
def test_remove_test(self):
|
||||
host = self.mock_host()
|
||||
fs = host.filesystem
|
||||
fs.remove(MOCK_WEB_TESTS + 'dom/dom2.html')
|
||||
fs.remove(MOCK_WEB_TESTS + 'http/pass/foo.html')
|
||||
fs.remove(MOCK_WEB_TESTS + 'http/pass/bar.html')
|
||||
collector = WebTestsCollector(host)
|
||||
collector.port.web_tests_dir = lambda: MOCK_WEB_TESTS
|
||||
path = fs.join(MOCK_WEB_TESTS, ALL_TESTS_BY_DIRECTORIES)
|
||||
collector.collect_tests(path, ['dom', 'http'])
|
||||
data = ('{\n'
|
||||
' "dom/": [\n'
|
||||
' "dom/dom1.html"\n'
|
||||
' ], \n'
|
||||
' "external/wpt/css/": [\n'
|
||||
' "external/wpt/css/foo.html"\n'
|
||||
' ]\n'
|
||||
'}')
|
||||
self.assertEqual(fs.read_text_file(path), data)
|
25
third_party/blink/tools/collect_web_tests.py
vendored
25
third_party/blink/tools/collect_web_tests.py
vendored
@ -1,25 +0,0 @@
|
||||
#!/usr/bin/env vpython3
|
||||
# Copyright 2021 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
"""Pre-collects web tests and save the result to AllTestsByDirectories.json"""
|
||||
|
||||
import sys
|
||||
|
||||
from blinkpy.common import exit_codes
|
||||
from blinkpy.common.host import Host
|
||||
from blinkpy.web_tests.web_tests_collector import WebTestsCollector
|
||||
|
||||
|
||||
def main():
|
||||
host = Host()
|
||||
collector = WebTestsCollector(host)
|
||||
try:
|
||||
return collector.main(sys.argv[1:])
|
||||
except KeyboardInterrupt:
|
||||
print("Interrupted, exiting")
|
||||
return exit_codes.INTERRUPTED_EXIT_STATUS
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
83523
third_party/blink/web_tests/AllTestsByDirectories.json
vendored
83523
third_party/blink/web_tests/AllTestsByDirectories.json
vendored
File diff suppressed because it is too large
Load Diff
70
third_party/blink/web_tests/PRESUBMIT.py
vendored
70
third_party/blink/web_tests/PRESUBMIT.py
vendored
@ -143,74 +143,6 @@ def _CheckRunAfterLayoutAndPaintJS(input_api, output_api):
|
||||
break
|
||||
return []
|
||||
|
||||
def _check(input_api, dirs_changed):
|
||||
with input_api.CreateTemporaryFile() as f:
|
||||
f.close()
|
||||
script_path = input_api.os_path.join(
|
||||
input_api.change.RepositoryRoot(), 'third_party',
|
||||
'blink', 'tools', 'collect_web_tests.py')
|
||||
command = ['vpython3', script_path,
|
||||
'--out', f.name]
|
||||
match = True
|
||||
try:
|
||||
input_api.subprocess.check_output(command + dirs_changed)
|
||||
except input_api.subprocess.CalledProcessError:
|
||||
match = False
|
||||
return match
|
||||
|
||||
def _EnsureAllTestsByDirectories(input_api, output_api):
|
||||
this_dir = input_api.PresubmitLocalPath()
|
||||
all_tests_by_dir_path = input_api.os_path.join(
|
||||
this_dir, 'AllTestsByDirectories.json')
|
||||
|
||||
'''
|
||||
if input_api.is_committing and all_tests_by_dir_path in input_api.AbsoluteLocalPaths():
|
||||
# always do a full check in this case
|
||||
if not _check(input_api, []):
|
||||
error_message = (
|
||||
'This CL changes AllTestsByDirectories.json or web test cases, but\n'
|
||||
'AllTestsByDirectories.json is not up-to-date. Please run:\n'
|
||||
' third_party/blink/tools/collect_web_tests.py\nto update it.\n')
|
||||
return [output_api.PresubmitError(error_message)]
|
||||
else:
|
||||
return []
|
||||
'''
|
||||
|
||||
skipped_dirs = set(['FlagExpectations', 'platform', 'resources'])
|
||||
dirs_to_check = []
|
||||
for f in input_api.os_listdir(this_dir):
|
||||
if f in skipped_dirs:
|
||||
continue
|
||||
if input_api.os_path.isdir(
|
||||
input_api.os_path.join(this_dir, f)):
|
||||
dirs_to_check.append(f)
|
||||
|
||||
dirs_changed = []
|
||||
for af in input_api.AffectedFiles():
|
||||
for d in set(dirs_to_check)-set(dirs_changed):
|
||||
path = input_api.os_path.join(this_dir, d)
|
||||
if af.AbsoluteLocalPath().startswith(path):
|
||||
dirs_changed.append(d)
|
||||
break
|
||||
if 'external' in dirs_changed:
|
||||
dirs_changed.remove('external')
|
||||
dirs_changed.append('external/wpt')
|
||||
|
||||
if dirs_changed:
|
||||
match = _check(input_api, dirs_changed)
|
||||
if not match:
|
||||
error_message = (
|
||||
'This CL changes web test cases, but '
|
||||
'AllTestsByDirectories.json is not updated.\n'
|
||||
'Please run:\n third_party/blink/tools/'
|
||||
'collect_web_tests.py %s\nto update it.\n' %
|
||||
' '.join(dirs_changed))
|
||||
if input_api.is_committing:
|
||||
return [output_api.PresubmitError(error_message)]
|
||||
else:
|
||||
return [output_api.PresubmitPromptWarning(error_message)]
|
||||
return []
|
||||
|
||||
def CheckChangeOnUpload(input_api, output_api):
|
||||
results = []
|
||||
results.extend(_CheckTestharnessResults(input_api, output_api))
|
||||
@ -219,7 +151,6 @@ def CheckChangeOnUpload(input_api, output_api):
|
||||
results.extend(_CheckForJSTest(input_api, output_api))
|
||||
results.extend(_CheckForInvalidPreferenceError(input_api, output_api))
|
||||
results.extend(_CheckRunAfterLayoutAndPaintJS(input_api, output_api))
|
||||
results.extend(_EnsureAllTestsByDirectories(input_api, output_api))
|
||||
return results
|
||||
|
||||
|
||||
@ -228,5 +159,4 @@ def CheckChangeOnCommit(input_api, output_api):
|
||||
results.extend(_CheckTestharnessResults(input_api, output_api))
|
||||
results.extend(_CheckFilesUsingEventSender(input_api, output_api))
|
||||
results.extend(_CheckTestExpectations(input_api, output_api))
|
||||
results.extend(_EnsureAllTestsByDirectories(input_api, output_api))
|
||||
return results
|
||||
|
Reference in New Issue
Block a user