@@ -7,6 +7,8 @@ def wd_test(
77 args = [],
88 ts_deps = [],
99 python_snapshot_test = False ,
10+ generate_default_variant = True ,
11+ generate_all_autogates_variant = True ,
1012 ** kwargs ):
1113 """Rule to define tests that run `workerd test` with a particular config.
1214
@@ -17,6 +19,8 @@ def wd_test(
1719 data: Additional files which the .capnp config file may embed. All TypeScript files will be compiled,
1820 their resulting files will be passed to the test as well. Usually TypeScript or Javascript source files.
1921 args: Additional arguments to pass to `workerd`. Typically used to pass `--experimental`.
22+ autogates_variant: If True (default), generate an @all-autogates variant of the test.
23+ default_variant: If True (default), generate the default (non-autogates) variant of the test.
2024 """
2125
2226 # Add workerd binary to "data" dependencies.
@@ -57,14 +61,25 @@ def wd_test(
5761 "$(location {})" .format (src ),
5862 ] + args
5963
60- _wd_test (
61- src = src ,
62- name = name ,
63- data = data ,
64- args = args ,
65- python_snapshot_test = python_snapshot_test ,
66- ** kwargs
67- )
64+ if generate_default_variant :
65+ _wd_test (
66+ src = src ,
67+ name = name + "@" ,
68+ data = data ,
69+ args = args ,
70+ python_snapshot_test = python_snapshot_test ,
71+ ** kwargs
72+ )
73+
74+ if generate_all_autogates_variant :
75+ _wd_test (
76+ src = src ,
77+ name = name + "@all-autogates" ,
78+ data = data ,
79+ args = args + ["--all-autogates" ],
80+ python_snapshot_test = python_snapshot_test ,
81+ ** kwargs
82+ )
6883
6984WINDOWS_TEMPLATE = """
7085@echo off
@@ -192,7 +207,7 @@ def _wd_test_impl(ctx):
192207 # Include all file types that might contain testable code
193208 extensions = ["cc" , "c++" , "cpp" , "cxx" , "c" , "h" , "hh" , "hpp" , "hxx" , "inc" , "js" , "ts" , "mjs" , "wd-test" , "capnp" ],
194209 )
195- environment = {}
210+ environment = dict ( ctx . attr . env )
196211 if ctx .attr .python_snapshot_test :
197212 environment ["PYTHON_SAVE_SNAPSHOT_ARGS" ] = ""
198213 if ctx .attr .load_snapshot :
@@ -272,6 +287,8 @@ _wd_test = rule(
272287 ),
273288 "python_snapshot_test" : attr .bool (),
274289 "load_snapshot" : attr .label (allow_single_file = True ),
290+ # Environment variables to set when running the test
291+ "env" : attr .string_dict (),
275292 # A reference to the Windows platform label, needed for the implementation of wd_test
276293 "_platforms_os_windows" : attr .label (default = "@platforms//os:windows" ),
277294 },
0 commit comments