Skip to content

Commit

Permalink
Convert WPT test harness to TS
Browse files Browse the repository at this point in the history
  • Loading branch information
npaun committed Jan 13, 2025
1 parent 5055345 commit 83a76ce
Show file tree
Hide file tree
Showing 7 changed files with 256 additions and 75 deletions.
2 changes: 1 addition & 1 deletion build/wpt_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const unitTests :Workerd.Config = (
worker = (
modules = [
(name = "worker", esModule = embed "{test_js}"),
(name = "harness", esModule = embed "../../../../../workerd/src/wpt/harness.js"),
(name = "wpt:harness", esModule = embed "../../../../../workerd/src/wpt/harness.js"),
{modules}
],
bindings = [
Expand Down
2 changes: 1 addition & 1 deletion src/workerd/api/wpt/url-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
// https://opensource.org/licenses/Apache-2.0

import { run } from 'harness';
import { run } from 'wpt:harness';

export const idnaTestV2Window = run('IdnaTestV2.window.js');
export const historical = run('historical.any.js', {
Expand Down
2 changes: 1 addition & 1 deletion src/workerd/api/wpt/urlpattern-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
// https://opensource.org/licenses/Apache-2.0

import { run } from 'harness';
import { run } from 'wpt:harness';

export const urlpatternCompareTests = run(
'urlpattern-compare-tests.tentative.js',
Expand Down
45 changes: 40 additions & 5 deletions src/wpt/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,43 @@
filegroup(
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
load("@npm//:eslint/package_json.bzl", eslint_bin = "bin")

srcs = glob(
[
"*.ts",
],
)

ts_project(
name = "wpt-test-harness",
srcs = glob(
include = ["**/*"],
allow_empty = True,
),
testonly = False,
srcs = srcs,
allow_js = True,
declaration = True,
tsconfig = "tsconfig.json",
visibility = ["//visibility:public"],
deps = [
"//:node_modules/@types/node",
],
)

eslint_bin.eslint_test(
name = "wpt-test-harness@eslint",
size = "large",
args = [
"--config $(location {})".format("eslint.config.mjs"),
"--parser-options project:$(location {})".format("tsconfig.json"),
"-f stylish",
"--report-unused-disable-directives",
] + ["$(location " + src + ")" for src in srcs],
data = srcs + [
"eslint.config.mjs",
"tsconfig.json",
"//:prettierrc",
"//tools:base-eslint",
],
tags = ["lint"],
target_compatible_with = select({
"@platforms//os:windows": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
)
3 changes: 3 additions & 0 deletions src/wpt/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { baseConfig } from '../../tools/base.eslint.config.mjs';

export default [...baseConfig({ tsconfigRootDir: import.meta.dirname })];
Loading

0 comments on commit 83a76ce

Please sign in to comment.