Repository navigation
Move runtime and Python tests out of src/workerd/server/tests - #8567
Conversation
src/workerd/server/tests holds tests of workerd-only features: the server's own code, its config extensions, the inspector, async traces, containers and the like. Five tests there test runtime code under src/workerd/api and src/workerd/io instead, and downstream builds of the runtime can't tell them apart from the server's tests by path. Move them under src/workerd/api/tests: - weakref: WeakRef and FinalizationRegistry across requests, now a wd-test (weakref-test.wd-test) instead of a Node driver around a workerd process. Each case calls its own target worker through a service binding, so every call is a new request into that target. The target keeps a strong reference to the WeakRef's object until the gc request drops it: V8 may collect a WeakRef's target at any GC once the job that created it ends, and the driver version passed only because no GC ran between its requests. - socket-close: closing a socket with a pipe close in flight - wrapped-binding-serialization: RPC serialization of wrapped bindings - unsafe-eval, unsafe-module: the workerd:unsafe APIs The UDP tests stay: a worker can't send UDP, so they drive the server's UDP listener from Node, which makes them tests of the server. Also bring the list of src/workerd/server/tests subdirectories in src/workerd/server/AGENTS.md up to date. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Python Workers tests exercise the Pyodide runtime in src/pyodide and src/workerd/api/pyodide, not workerd's server code, so they now sit next to the runtime instead of under src/workerd/server/tests. The vendored-package tests generate embed paths that climb from the generated config to the external repositories. The number of `../` was a constant tied to the old package's depth, plus a `level` argument for subpackages. vendored_py_wd_test now derives it from the package path, so the tests don't depend on where they live. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2209beb to
0076965
Compare
There was a problem hiding this comment.
✅ Approved — This pull request moves tests and updates build paths with no defects found. The embed-path depth calculation and the rewritten weakref test both check out.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
This change only moves tests and updates build paths, and has no security impact.
📖 AGENTS.md: ✅ LGTM
The AGENTS.md updates in src/workerd/server and src/pyodide match the new layout.
📋 Code Quality: ✅ LGTM
No issues found. The derived embed-path depth gives the same paths as the old fixed count plus level. The starttls-server.pem path resolves to the exported file. Nothing still points at the old paths. The rewritten weakref test keeps the old test's checks.
⚡ Performance: ✅ LGTM
This change touches only tests and build files, not production code.
📝 Documentation: ✅ LGTM
No issues found.
Reviewed commit: 0076965e
src/workerd/server/testsis meant for tests of workerd-only features: the server's own code, config extensions, the inspector, async traces, containers and the like. Some tests of runtime code that downstream builds also ship ended up there too. That makes the path a poor guide to what a test covers.This moves them next to the code they test, in two commits:
Runtime tests to
src/workerd/api/tests:weakref:WeakRefandFinalizationRegistryacross requests. This was a Node driver around aworkerd serveprocess and is now a plain wd-test (weakref-test.wd-test). Each case calls its own target worker through a service binding, so every call is a new request into that target. The target now holds a strong reference to the WeakRef's object until thegcrequest drops it. V8 may collect a WeakRef's target at any GC once the job that created it ends, and the driver version passed only because no GC ran between its requests.socket-close: closing a socket with a pipe close in flightwrapped-binding-serialization: RPC serialization of wrapped bindingsunsafe-eval,unsafe-module: theworkerd:unsafeAPIsNothing under
src/workerd/apiusesserver-harness.mjs. The UDP tests (udp-connect,udp-connect-ts-streams,udp-datagram-drop) stay insrc/workerd/server/tests: a worker has no API for sending UDP, so they send datagrams from Node to the server's UDP listener, which makes them tests of the server. The commit also brings the subdirectory list insrc/workerd/server/AGENTS.mdup to date.The Python Workers tests to
src/pyodide/tests, next to the Pyodide runtime they exercise. The vendored-package tests generated embed paths with a../count that was a constant tied to the old directory's depth, plus alevelargument for subpackages.vendored_py_wd_testnow derives the count from the package path, andlevelis gone. The 7src/cloudflare/internal/testpackages that loadpy_wd_test.bzl, and the PyodideAGENTS.md, point at the new path.Apart from the weakref rewrite, no test changes what it does, and target names are unchanged under the new packages.
Testing
On bazelflare:
weakref-testpasses in all variants, including@gc-stress.server-harness-testpass.//src/pyodide/...and//src/cloudflare/internal/test/...pass: 302 targets, including every Python variant, the vendored-package tests and the ESLint checks.bazel build --nobuild //...analyzes the whole repo without errors.tools/cross/format.py --checkis clean.Edgeworker's docs mention the old Python path in two places (
docs/python_workers.mdand a comment insrc/edgeworker/tests/python/snapshots/BUILD). Nothing there loads from it, so this doesn't break its build.🤖 Generated with Claude Code