Skip to content

Commit

Permalink
Merge pull request #2495 from cloudflare/ggu/refactor-bazel-test
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettgu10 authored Aug 8, 2024
2 parents 928869a + d24fab8 commit 826743f
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 63 deletions.
42 changes: 18 additions & 24 deletions src/workerd/server/tests/python/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,67 +1,61 @@
load("//:build/wd_test.bzl", "wd_test")

load("//src/workerd/server/tests/python:py_wd_test.bzl", "py_wd_test")

load("@bazel_skylib//rules:copy_file.bzl", "copy_file")

# pyodide-dev.capnp.bin represents a custom pyodide version "dev" that is generated
# at build time using the latest contents of the src/pyodide directory.
# This is used to run tests to ensure that they are always run against the latest build of
# the Pyodide bundle.
copy_file(
name = "pyodide-dev.capnp.bin@rule",
src = "//src/pyodide:pyodide.capnp.bin",
out = "pyodide-bundle-cache/pyodide-dev.capnp.bin"
)

wd_test(
py_wd_test(
src = "hello/hello.wd-test",
args = ["--experimental", "--pyodide-bundle-disk-cache-dir", "$(location pyodide-dev.capnp.bin@rule)/.."],
args = ["--experimental"],
data = glob(
[
"hello/*",
],
exclude = ["**/*.wd-test"],
) + ["pyodide-dev.capnp.bin@rule"],
),
)

wd_test(
py_wd_test(
src = "env-param/env.wd-test",
args = ["--experimental", "--pyodide-bundle-disk-cache-dir", "$(location pyodide-dev.capnp.bin@rule)/.."],
args = ["--experimental"],
data = glob(
[
"env-param/*",
],
exclude = ["**/*.wd-test"],
) + ["pyodide-dev.capnp.bin@rule"],
),
)

wd_test(
py_wd_test(
src = "random/random.wd-test",
args = ["--experimental", "--pyodide-bundle-disk-cache-dir", "$(location pyodide-dev.capnp.bin@rule)/.."],
args = ["--experimental"],
data = glob(
[
"random/*",
],
exclude = ["**/*.wd-test"],
) + ["pyodide-dev.capnp.bin@rule"],
),
)

# Disabled because it tests the same thing as the import test defined in import_tests.bzl
# wd_test(
# src = "langchain/langchain.wd-test",
# args = ["--experimental", "--pyodide-package-disk-cache-dir", "../all_pyodide_wheels", "--pyodide-bundle-disk-cache-dir", "$(location pyodide-dev.capnp.bin@rule)/.."],
# data = glob(
# [
# "langchain/*",
# ],
# exclude = ["**/*.wd-test"],
# ) + ["@all_pyodide_wheels//:whls", "pyodide-dev.capnp.bin@rule"],
# )

wd_test(
py_wd_test(
src = "subdirectory/subdirectory.wd-test",
args = ["--experimental", "--pyodide-bundle-disk-cache-dir", "$(location pyodide-dev.capnp.bin@rule)/.."],
args = ["--experimental"],
data = glob(
[
"subdirectory/**",
],
exclude = ["**/*.wd-test"],
) + ["pyodide-dev.capnp.bin@rule"],
),
)

load("//src/workerd/server/tests/python:import_tests.bzl", "gen_import_tests")
Expand Down
8 changes: 4 additions & 4 deletions src/workerd/server/tests/python/import_tests.bzl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@bazel_skylib//rules:write_file.bzl", "write_file")

load("//:build/wd_test.bzl", "wd_test")
load("//src/workerd/server/tests/python:py_wd_test.bzl", "py_wd_test")

def generate_import_py_file(imports):
res = ""
Expand Down Expand Up @@ -54,9 +54,9 @@ def gen_import_tests(to_test):
tags = ["slow"],
)

wd_test(
py_wd_test(
src = wd_test_fname,
args = ["--experimental", "--pyodide-package-disk-cache-dir", "../all_pyodide_wheels", "--pyodide-bundle-disk-cache-dir", "$(location pyodide-dev.capnp.bin@rule)/.."],
data = [worker_py_fname, "@all_pyodide_wheels//:whls", "pyodide-dev.capnp.bin@rule"],
args = ["--experimental", "--pyodide-package-disk-cache-dir", "../all_pyodide_wheels"],
data = [worker_py_fname, "@all_pyodide_wheels//:whls"],
tags = ["slow"],
)
23 changes: 0 additions & 23 deletions src/workerd/server/tests/python/langchain/langchain.wd-test

This file was deleted.

12 changes: 0 additions & 12 deletions src/workerd/server/tests/python/langchain/worker.py

This file was deleted.

19 changes: 19 additions & 0 deletions src/workerd/server/tests/python/py_wd_test.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
load("//:build/wd_test.bzl", "wd_test")

def py_wd_test(
src,
data = [],
name = None,
args = [],
**kwargs
):
data += ["pyodide-dev.capnp.bin@rule"]
args += ["--pyodide-bundle-disk-cache-dir", "$(location pyodide-dev.capnp.bin@rule)/.."]

wd_test(
src = src,
data = data,
name = name,
args = args,
**kwargs
)

0 comments on commit 826743f

Please sign in to comment.