Skip to content

Commit

Permalink
Add --save-snapshot variant to all wd_py_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hoodmane committed Jan 28, 2025
1 parent c96bcc9 commit d9b7619
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/workerd/server/tests/python/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ py_wd_test("env-param")
py_wd_test(
"asgi",
skip_python_flags = ["0.27.1"],
# TODO: investigate failure!
snapshot_variant = False,
)

py_wd_test("random")
Expand Down
1 change: 1 addition & 0 deletions src/workerd/server/tests/python/import_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def gen_import_tests(to_test, pkg_skip_versions = {}):
directory = lib,
src = wd_test_fname,
skip_python_flags = pkg_skip_versions.get(lib, []),
snapshot_variant = False,
args = ["--experimental", "--pyodide-package-disk-cache-dir", "../all_pyodide_wheels"],
data = [worker_py_fname, "@all_pyodide_wheels//:whls"],
size = "enormous",
Expand Down
31 changes: 22 additions & 9 deletions src/workerd/server/tests/python/py_wd_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,19 @@ def _py_wd_test_helper(
name,
src,
python_flag,
snapshot,
*,
args = [],
**kwargs):
if snapshot:
args = args + ["--python-save-snapshot"]
name = name + "_snapshot"
name_flag = name + "_" + python_flag
templated_src = name_flag.replace("/", "-") + "@template"
templated_src = "/".join(src.split("/")[:-1] + [templated_src])
flags = FEATURE_FLAGS[python_flag] + ["python_workers"]
feature_flags_txt = ",".join(['"{}"'.format(flag) for flag in flags])

expand_template(
name = name_flag + "@rule",
out = templated_src,
Expand All @@ -27,6 +34,7 @@ def _py_wd_test_helper(
wd_test(
src = templated_src,
name = name_flag + "@",
args = args,
**kwargs
)

Expand All @@ -41,6 +49,7 @@ def py_wd_test(
args = [],
size = "enormous",
tags = [],
snapshot_variant = True,
**kwargs):
if python_flags == "all":
python_flags = FEATURE_FLAGS.keys()
Expand All @@ -61,13 +70,17 @@ def py_wd_test(
data += ["//src/workerd/server/tests/python:pyodide_dev.capnp.bin@rule"]
args = args + ["--pyodide-bundle-disk-cache-dir", "$(location //src/workerd/server/tests/python:pyodide_dev.capnp.bin@rule)/..", "--experimental"]
tags = tags + ["py_wd_test"]
snapshot_variants = [False, True] if snapshot_variant else [False]

for python_flag in python_flags:
_py_wd_test_helper(
name,
src,
python_flag,
data = data,
args = args,
size = size,
tags = tags,
)
for snapshot in snapshot_variants:
_py_wd_test_helper(
name,
src,
python_flag,
snapshot = snapshot,
data = data,
args = args,
# size = size,
# tags = tags,
)

0 comments on commit d9b7619

Please sign in to comment.