Skip to content

Commit

Permalink
Revert "WPT: Add dom/abortsignal tests (#3436)"
Browse files Browse the repository at this point in the history
This reverts commit 75d6a76.
  • Loading branch information
npaun authored Feb 4, 2025
1 parent 2c2b2d0 commit bbe8a96
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 458 deletions.
22 changes: 10 additions & 12 deletions build/BUILD.wpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,19 @@
# Licensed under the Apache 2.0 license found in the LICENSE file or at:
# https://opensource.org/licenses/Apache-2.0

load("@workerd//:build/wpt_test.bzl", "wpt_get_directories")

[filegroup(
name = dir,
srcs = glob(["{}/**/*".format(dir)]),
visibility = ["//visibility:public"],
) for dir in wpt_get_directories(
excludes = [
"dom",
directories = glob(
["*"],
exclude = glob(
["*"],
exclude_directories = 1,
) + [
".*",
],
root = "",
)]
exclude_directories = 0,
)

[filegroup(
name = dir,
srcs = glob(["{}/**/*".format(dir)]),
visibility = ["//visibility:public"],
) for dir in wpt_get_directories(root = "dom")]
) for dir in directories]
60 changes: 16 additions & 44 deletions build/wpt_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ def wpt_test(name, wpt_directory, test_config):

js_test_gen_rule = "{}@_wpt_js_test_gen".format(name)
test_config_as_js = test_config.removesuffix(".ts") + ".js"
harness = "//src/wpt:wpt-test-harness"
compat_date = "//src/workerd/io:trimmed-supported-compatibility-date.txt"

_wpt_js_test_gen(
name = js_test_gen_rule,
Expand All @@ -33,41 +31,22 @@ def wpt_test(name, wpt_directory, test_config):
wpt_directory = wpt_directory,
test_config = test_config_as_js,
test_js_generated = js_test_gen_rule,
harness = harness,
compat_date = compat_date,
)

wd_test(
name = "{}".format(name),
src = wd_test_gen_rule,
args = ["--experimental"],
ts_deps = [harness],
ts_deps = ["//src/wpt:wpt-test-harness"],
data = [
harness,
"//src/wpt:wpt-test-harness",
test_config,
js_test_gen_rule,
wpt_directory,
compat_date,
"//src/workerd/io:trimmed-supported-compatibility-date.txt",
],
)

def wpt_get_directories(root, excludes = []):
"""
Globs for files within a WPT directory structure, starting from root.
In addition to an explicitly provided excludes argument, hidden directories
and top-level files are also excluded as they don't contain test content.
"""

root_pattern = "{}/*".format(root) if root else "*"
return native.glob(
[root_pattern],
exclude = native.glob(
[root_pattern],
exclude_directories = 1,
) + [".*"] + excludes,
exclude_directories = 0,
)

def _wpt_js_test_gen_impl(ctx):
"""
Generates a workerd test suite in JS. This contains the logic to run
Expand Down Expand Up @@ -96,7 +75,7 @@ def generate_external_cases(files):

for file in files.to_list():
if file.extension == "js":
entry = """export const {} = run('{}');""".format(test_case_name(file.basename), file.basename)
entry = """export const {} = run(config, '{}');""".format(test_case_name(file.basename), file.basename)
result.append(entry)

return "\n".join(result)
Expand All @@ -118,11 +97,9 @@ def test_case_name(filename):

WPT_JS_TEST_TEMPLATE = """// This file is autogenerated by wpt_test.bzl
// DO NOT EDIT.
import {{ createRunner }} from 'wpt:harness';
import {{ run }} from 'wpt:harness';
import config from '{test_config}';
const run = createRunner(config);
{cases}
"""

Expand All @@ -132,16 +109,15 @@ def _wpt_wd_test_gen_impl(ctx):
paths to modules needed to run the test: generated test suite, test config
file, WPT test scripts, associated JSON resources.
"""

src = ctx.actions.declare_file("{}.wd-test".format(ctx.attr.test_name))
ctx.actions.write(
output = src,
content = WPT_WD_TEST_TEMPLATE.format(
test_name = ctx.attr.test_name,
test_config = ctx.file.test_config.basename,
test_js_generated = ctx.file.test_js_generated.basename,
bindings = generate_external_bindings(ctx.file.test_config, ctx.attr.wpt_directory.files),
harness = wd_relative_path(ctx.file.test_config, ctx.file.harness),
compat_date = wd_relative_path(ctx.file.test_config, ctx.file.compat_date),
test_js_generated = wd_relative_path(ctx.file.test_js_generated),
bindings = generate_external_bindings(ctx.attr.wpt_directory.files),
),
)

Expand All @@ -158,14 +134,14 @@ const unitTests :Workerd.Config = (
modules = [
(name = "worker", esModule = embed "{test_js_generated}"),
(name = "{test_config}", esModule = embed "{test_config}"),
(name = "wpt:harness", esModule = embed "{harness}"),
(name = "wpt:harness", esModule = embed "../../../../../workerd/src/wpt/harness.js"),
],
bindings = [
(name = "wpt", service = "wpt"),
(name = "unsafe", unsafeEval = void),
{bindings}
],
compatibilityDate = embed "{compat_date}",
compatibilityDate = embed "../../../../../workerd/src/workerd/io/trimmed-supported-compatibility-date.txt",
compatibilityFlags = ["nodejs_compat", "experimental"],
)
),
Expand All @@ -176,15 +152,15 @@ const unitTests :Workerd.Config = (
],
);"""

def wd_relative_path(origin, target):
def wd_relative_path(file):
"""
Generates a relative path for use in wd-test files.
The origin is the directory containing the wd-test file, and the target is the file that should be referenced from it.
Returns a relative path which can be referenced in the .wd-test file.
This is four directories up from the bazel short_path
"""

return "../" * origin.short_path.count("/") + target.short_path
return "../" * 4 + file.short_path

def generate_external_bindings(origin, files):
def generate_external_bindings(files):
"""
Generates appropriate bindings for each file in the WPT module:
- JS files: text binding to allow code to be evaluated
Expand All @@ -194,7 +170,7 @@ def generate_external_bindings(origin, files):
result = []

for file in files.to_list():
file_path = wd_relative_path(origin, file)
file_path = wd_relative_path(file)
if file.extension == "js":
entry = """(name = "{}", text = embed "{}")""".format(file.basename, file_path)
elif file.extension == "json":
Expand All @@ -219,10 +195,6 @@ _wpt_wd_test_gen = rule(
"test_config": attr.label(allow_single_file = True),
# An auto-generated JS file containing the test logic.
"test_js_generated": attr.label(allow_single_file = True),
# Target specifying the location of the WPT test harness
"harness": attr.label(allow_single_file = True),
# Target specifying the location of the trimmed-supported-compatibility-date.txt file
"compat_date": attr.label(allow_single_file = True),
},
)

Expand Down
2 changes: 1 addition & 1 deletion src/workerd/api/wpt/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
load("@npm//:eslint/package_json.bzl", eslint_bin = "bin")
load("//:build/wpt_test.bzl", "wpt_test")

srcs = glob(["**/*-test.ts"])
srcs = glob(["*-test.ts"])

[wpt_test(
name = file.replace("-test.ts", ""),
Expand Down
29 changes: 0 additions & 29 deletions src/workerd/api/wpt/dom/abort-test.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/workerd/api/wpt/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { baseConfig } from '../../../../tools/base.eslint.config.mjs';
export default [
...baseConfig({ tsconfigRootDir: import.meta.dirname }),
{
files: ['src/workerd/api/wpt/**/*-test.ts'],
files: ['src/workerd/api/wpt/*-test.js'],
rules: {
'sort-keys': 'error',
},
Expand Down
2 changes: 1 addition & 1 deletion src/workerd/api/wpt/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
"wpt:*": ["../../../wpt/*"]
}
},
"include": ["**/*.ts"],
"include": ["**/*.ts", "../../../wpt/*.ts"],
"exclude": []
}
21 changes: 2 additions & 19 deletions src/workerd/api/wpt/url-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import { type TestRunnerConfig } from 'wpt:harness';

export default {
'IdnaTestV2.window.js': {},
'a-element-origin.js': {
comment: 'Implement globalThis.document',
skipAllTests: true,
Expand All @@ -17,6 +16,7 @@ export default {
'historical.any.js': {
comment: 'Fix this eventually',
expectedFailures: [
'Constructor only takes strings',
'URL: no structured serialize/deserialize support',
'URLSearchParams: no structured serialize/deserialize support',
],
Expand All @@ -36,8 +36,7 @@ export default {
],
},
'percent-encoding.window.js': {
comment:
'Implement test code modification feature to allow running this test without document',
comment: 'Implement `async_test`',
skipAllTests: true,
},
'toascii.window.js': {
Expand All @@ -50,17 +49,10 @@ export default {
'Parsing: <http://example.com/\uD800\uD801\uDFFE\uDFFF\uFDD0\uFDCF\uFDEF\uFDF0\uFFFE\uFFFF?\uD800\uD801\uDFFE\uDFFF\uFDD0\uFDCF\uFDEF\uFDF0\uFFFE\uFFFF> without base',
],
},
'url-origin.any.js': {},
'url-searchparams.any.js': {},
'url-setters-a-area.window.js': {
comment: 'Implement globalThis.document',
skipAllTests: true,
},
'url-setters-stripping.any.js': {},
'url-setters.any.js': {},
'url-statics-canparse.any.js': {},
'url-statics-parse.any.js': {},
'url-tojson.any.js': {},
'urlencoded-parser.any.js': {
comment:
'Requests fail due to HTTP method "LADIDA", responses fail due to shift_jis encoding',
Expand Down Expand Up @@ -137,7 +129,6 @@ export default {
'response.formData() with input: b=%%2a',
],
},
'urlsearchparams-append.any.js': {},
'urlsearchparams-constructor.any.js': {
comment: 'Fix this eventually',
expectedFailures: [
Expand All @@ -147,16 +138,8 @@ export default {
'Construct with object with NULL, non-ASCII, and surrogate keys',
],
},
'urlsearchparams-delete.any.js': {},
'urlsearchparams-foreach.any.js': {},
'urlsearchparams-get.any.js': {},
'urlsearchparams-getall.any.js': {},
'urlsearchparams-has.any.js': {},
'urlsearchparams-set.any.js': {},
'urlsearchparams-size.any.js': {},
'urlsearchparams-sort.any.js': {
comment: 'Investigate url_search_params::sort in ada-url',
expectedFailures: ['Parse and sort: ffi&🌈', 'URL parse and sort: ffi&🌈'],
},
'urlsearchparams-stringifier.any.js': {},
} satisfies TestRunnerConfig;
5 changes: 0 additions & 5 deletions src/workerd/api/wpt/urlpattern-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ export default {
'Component: hash Left: {"hash":"a"} Right: {"hash":"b"}',
],
},
'urlpattern-compare.tentative.any.js': {},
'urlpattern-compare.tentative.https.any.js': {},
'urlpattern-hasregexpgroups-tests.js': {
comment: 'urlpattern implementation will soon be replaced with ada-url',
expectedFailures: [
Expand All @@ -47,9 +45,6 @@ export default {
'', // This file consists of one unnamed subtest
],
},
'urlpattern-hasregexpgroups.any.js': {},
'urlpattern.any.js': {},
'urlpattern.https.any.js': {},
'urlpatterntests.js': {
comment: 'urlpattern implementation will soon be replaced with ada-url',
expectedFailures: [
Expand Down
Loading

0 comments on commit bbe8a96

Please # to comment.