5
5
load ("@bazel_skylib//lib:paths.bzl" , "paths" )
6
6
load ("//:build/wd_test.bzl" , "wd_test" )
7
7
8
- def wpt_test (name , wpt_directory , test_config ):
8
+ def wpt_test (name , wpt_directory , config , autogates = [] ):
9
9
"""
10
10
Main entry point.
11
11
1. Generates a workerd test suite in JS. This contains the logic to run
@@ -16,7 +16,7 @@ def wpt_test(name, wpt_directory, test_config):
16
16
"""
17
17
18
18
js_test_gen_rule = "{}@_wpt_js_test_gen" .format (name )
19
- test_config_as_js = test_config .removesuffix (".ts" ) + ".js"
19
+ test_config_as_js = config .removesuffix (".ts" ) + ".js"
20
20
wpt_tsproject = "//src/wpt:wpt-all@tsproject"
21
21
harness_as_js = "//src/wpt:harness/harness.js"
22
22
compat_date = "//src/workerd/io:trimmed-supported-compatibility-date.txt"
@@ -38,6 +38,7 @@ def wpt_test(name, wpt_directory, test_config):
38
38
test_js_generated = js_test_gen_rule ,
39
39
harness = harness_as_js ,
40
40
compat_date = compat_date ,
41
+ autogates = autogates ,
41
42
)
42
43
43
44
wd_test (
@@ -151,6 +152,7 @@ def _wpt_wd_test_gen_impl(ctx):
151
152
bindings = generate_external_bindings (src .owner , ctx .attr .wpt_directory .files ),
152
153
harness = wd_relative_path (src .owner , ctx .file .harness ),
153
154
compat_date = wd_relative_path (src .owner , ctx .file .compat_date ),
155
+ autogates = generate_autogates_field (ctx .attr .autogates ),
154
156
),
155
157
)
156
158
@@ -183,8 +185,20 @@ const unitTests :Workerd.Config = (
183
185
disk = ".",
184
186
)
185
187
],
188
+ {autogates}
186
189
);"""
187
190
191
+ def generate_autogates_field (autogates ):
192
+ """
193
+ Generates a capnproto fragment listing the specified autogates.
194
+ """
195
+
196
+ if not autogates :
197
+ return ""
198
+
199
+ autogate_list = ", " .join (['"{}"' .format (autogate ) for autogate in autogates ])
200
+ return "autogates = [{}]," .format (autogate_list )
201
+
188
202
def wd_relative_path (label , target ):
189
203
"""
190
204
Generates a path that can be used in a .wd-test file to refer to another file. Paths are relative
@@ -243,6 +257,8 @@ _wpt_wd_test_gen = rule(
243
257
"harness" : attr .label (allow_single_file = True ),
244
258
# Target specifying the location of the trimmed-supported-compatibility-date.txt file
245
259
"compat_date" : attr .label (allow_single_file = True ),
260
+ # A list of autogates to specify in the generated wd-test file
261
+ "autogates" : attr .string_list (),
246
262
},
247
263
)
248
264
0 commit comments