Skip to content

Commit

Permalink
Reduce repeated code in Python test setup (#3262)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoodmane authored Dec 20, 2024
1 parent ea52c9a commit e35f34b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 45 deletions.
50 changes: 7 additions & 43 deletions src/workerd/server/tests/python/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,73 +15,37 @@ copy_file(
)

py_wd_test(
src = "hello/hello.wd-test",
"hello",
args = ["--experimental"],
data = glob(
[
"hello/*",
],
exclude = ["**/*.wd-test"],
),
)

py_wd_test(
src = "sdk/sdk.wd-test",
"sdk",
args = ["--experimental"],
data = glob(
[
"sdk/*",
],
exclude = ["**/*.wd-test"],
),
tags = [
# TODO(someday): Fix asan failure for this, see https://github.com/cloudflare/workerd/pull/3140#discussion_r1858273318
"no-asan",
],
)

py_wd_test(
src = "env-param/env.wd-test",
"env-param",
args = ["--experimental"],
data = glob(
[
"env-param/*",
],
exclude = ["**/*.wd-test"],
),
)

py_wd_test(
src = "asgi/asgi.wd-test",
"asgi",
args = ["--experimental"],
data = glob(
[
"asgi/*",
],
exclude = ["**/*.wd-test"],
),
)

py_wd_test(
src = "random/random.wd-test",
"random",
args = ["--experimental"],
data = glob(
[
"random/*",
],
exclude = ["**/*.wd-test"],
),
)

py_wd_test(
src = "subdirectory/subdirectory.wd-test",
"subdirectory",
args = ["--experimental"],
data = glob(
[
"subdirectory/**",
],
exclude = ["**/*.wd-test"],
),
)

gen_import_tests(PYODIDE_IMPORTS_TO_TEST)
# gen_import_tests(PYODIDE_IMPORTS_TO_TEST)
16 changes: 14 additions & 2 deletions src/workerd/server/tests/python/py_wd_test.bzl
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
load("//:build/wd_test.bzl", "wd_test")

def py_wd_test(
src,
data = [],
directory = None,
src = None,
data = None,
name = None,
args = [],
size = "enormous",
tags = [],
**kwargs):
if data == None:
data = native.glob(
[
directory + "/**",
],
exclude = ["**/*.wd-test"],
)
if src == None:
src = native.glob([directory + "/*.wd-test"])[0]
if name == None and directory != None:
name = directory + "@"
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"]

Expand Down

0 comments on commit e35f34b

Please sign in to comment.