Skip to content

Commit 8fdaa29

Browse files
anonrignpaun
authored andcommitted
auto generate dates
1 parent 37e8864 commit 8fdaa29

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

src/workerd/api/wpt/generate-tests.bzl

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ load("//:build/wd_test.bzl", "wd_test")
44
# 0 - name of the service
55
# 1 - es module file path (ex: url-test for url-test.js)
66
# 2 - external modules required for the test suite to succeed
7+
# 3 - current date in YYYY-MM-DD format
78
WPT_TEST_TEMPLATE = """
89
using Workerd = import "/workerd/workerd.capnp";
910
@@ -19,8 +20,8 @@ const unitTests :Workerd.Config = (
1920
bindings = [
2021
(name = "wpt", service = "wpt"),
2122
],
22-
compatibilityDate = "2024-07-01",
23-
compatibilityFlags = ["nodejs_compat_v2"],
23+
compatibilityDate = "{}",
24+
compatibilityFlags = ["nodejs_compat_v2", "experimental"],
2425
)
2526
),
2627
(
@@ -30,9 +31,24 @@ const unitTests :Workerd.Config = (
3031
],
3132
);"""
3233

34+
def _current_date_impl(repository_ctx):
35+
result = repository_ctx.execute(["date", "+%Y-%m-%d"])
36+
if result.return_code != 0:
37+
fail("Failed to get current date")
38+
39+
current_date = result.stdout.strip()
40+
41+
repository_ctx.file("BUILD", "")
42+
repository_ctx.file("date.bzl", "CURRENT_DATE = '%s'" % current_date)
43+
44+
current_date = repository_rule(
45+
implementation = _current_date_impl,
46+
local = True,
47+
)
48+
3349
# Example: generate_wd_test_file("url-test")
3450
def generate_wd_test_file(name, modules = ""):
35-
return WPT_TEST_TEMPLATE.format(name, name, modules)
51+
return WPT_TEST_TEMPLATE.format(name, name, modules, current_date())
3652

3753
def generate_external_modules(directory):
3854
"""

0 commit comments

Comments
 (0)