Skip to content

Commit

Permalink
Merge pull request #3203 from cloudflare/dlapid/test_python_workers_c…
Browse files Browse the repository at this point in the history
…ompat_flag

Test python_workers compat flag in imports test
  • Loading branch information
danlapid authored Dec 5, 2024
2 parents 401c665 + 890243a commit dabfcd3
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 32 deletions.
6 changes: 1 addition & 5 deletions build/ci.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test:ci --test_output=errors
build:ci --disk_cache=~/bazel-disk-cache

# test CI jobs don't need any top-level artifacts and just verify things
build:ci-test --remote_download_outputs=minimal
build:ci-test --remote_download_outputs=minimal --test_size_filters=small,medium,large,enormous

# limit storage usage on ci
# Exclude large benchmarking binaries created in debug and asan configurations to avoid
Expand Down Expand Up @@ -52,10 +52,6 @@ build:ci-linux-common --action_env=CC=/usr/lib/llvm-16/bin/clang --action_env=CX
build:ci-linux-common --host_action_env=CC=/usr/lib/llvm-16/bin/clang --host_action_env=CXX=/usr/lib/llvm-16/bin/clang++

build:ci-linux --config=ci-linux-common
# Some tests (like Python import tests) take a long time to run and don't benefit much
# from multi-platform testing. For that reason, we only run them in a single configuration
# to minimize effect on CI pipeline runtime.
test:ci-linux --test_size_filters=small,medium,large,enormous

build:ci-linux-debug --config=ci-linux-common --config=ci-limit-storage
build:ci-linux-debug --config=debug --config=rust-debug
Expand Down
8 changes: 4 additions & 4 deletions build/deps/gen/dep_capnp_cpp.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

load("@//:build/http.bzl", "http_archive")

URL = "https://github.com/capnproto/capnproto/tarball/14132442b125d0383285e36809e467c6b6a759aa"
STRIP_PREFIX = "capnproto-capnproto-1413244/c++"
SHA256 = "d1e1ff677a53aaf840a8ae624af4e2fed2b08e324ad82b0efd821926d16d6ce6"
URL = "https://github.com/capnproto/capnproto/tarball/327a56b51f50aaf762d85af501807dce96d9bbcb"
STRIP_PREFIX = "capnproto-capnproto-327a56b/c++"
SHA256 = "d22adc3479740024036497bbf79adeffe0d15c98271869d1a7808fc42882fa1a"
TYPE = "tgz"
COMMIT = "14132442b125d0383285e36809e467c6b6a759aa"
COMMIT = "327a56b51f50aaf762d85af501807dce96d9bbcb"

def dep_capnp_cpp():
http_archive(
Expand Down
4 changes: 4 additions & 0 deletions src/workerd/server/tests/python/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ py_wd_test(
],
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(
Expand Down
43 changes: 22 additions & 21 deletions src/workerd/server/tests/python/import_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,35 @@ const unitTests :Workerd.Config = (
(name = "{}", pythonRequirement = ""),
],
compatibilityDate = "2024-05-02",
compatibilityFlags = ["python_workers_development"],
compatibilityFlags = ["{}"],
)
),
]
);"""

def generate_wd_test_file(requirement):
return WD_FILE_TEMPLATE.format(requirement, requirement)
def generate_wd_test_file(requirement, compatFlag):
return WD_FILE_TEMPLATE.format(requirement, requirement, compatFlag)

# to_test is a dictionary from library name to list of imports
def gen_import_tests(to_test):
for lib in to_test.keys():
worker_py_fname = "import/{}/worker.py".format(lib)
wd_test_fname = "import/{}/import.wd-test".format(lib)
write_file(
name = worker_py_fname + "@rule",
out = worker_py_fname,
content = [generate_import_py_file(to_test[lib])],
)
write_file(
name = wd_test_fname + "@rule",
out = wd_test_fname,
content = [generate_wd_test_file(lib)],
)
for compatFlag in ["python_workers", "python_workers_development"]:
worker_py_fname = "import/{}@{}/worker.py".format(lib, compatFlag)
wd_test_fname = "import/{}@{}/import.wd-test".format(lib, compatFlag)
write_file(
name = worker_py_fname + "@rule",
out = worker_py_fname,
content = [generate_import_py_file(to_test[lib])],
)
write_file(
name = wd_test_fname + "@rule",
out = wd_test_fname,
content = [generate_wd_test_file(lib, compatFlag)],
)

py_wd_test(
src = wd_test_fname,
args = ["--experimental", "--pyodide-package-disk-cache-dir", "../all_pyodide_wheels"],
data = [worker_py_fname, "@all_pyodide_wheels//:whls"],
size = "enormous",
)
py_wd_test(
src = wd_test_fname,
args = ["--experimental", "--pyodide-package-disk-cache-dir", "../all_pyodide_wheels"],
data = [worker_py_fname, "@all_pyodide_wheels//:whls"],
size = "enormous",
)
4 changes: 2 additions & 2 deletions src/workerd/server/workerd-api.c++
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,8 @@ void writePyodideBundleFileToDisk(const kj::Maybe<kj::Own<const kj::Directory>>&

kj::Maybe<jsg::Bundle::Reader> fetchPyodideBundle(
const api::pyodide::PythonConfig& pyConfig, kj::StringPtr version) {
KJ_IF_SOME(version, pyConfig.pyodideBundleManager.getPyodideBundle(version)) {
return version;
if (pyConfig.pyodideBundleManager.getPyodideBundle(version) != kj::none) {
return pyConfig.pyodideBundleManager.getPyodideBundle(version);
}

auto maybePyodideBundleFile = getPyodideBundleFile(pyConfig.pyodideDiskCacheRoot, version);
Expand Down

0 comments on commit dabfcd3

Please sign in to comment.