Skip to content

Move runtime and Python tests out of src/workerd/server/tests - #8567

Merged
danlapid merged 2 commits into
mainfrom
dlapid/rehome-server-tests
Nov 18, 2026
Merged

danlapid merged 2 commits into
mainfrom
dlapid/rehome-server-tests

Conversation

@danlapid

@danlapid danlapid commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

src/workerd/server/tests is 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:

  1. Runtime tests to src/workerd/api/tests:

    • weakref: WeakRef and FinalizationRegistry across requests. This was a Node driver around a workerd serve process 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 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

    Nothing under src/workerd/api uses server-harness.mjs. The UDP tests (udp-connect, udp-connect-ts-streams, udp-datagram-drop) stay in src/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 in src/workerd/server/AGENTS.md up to date.

  2. 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 a level argument for subpackages. vendored_py_wd_test now derives the count from the package path, and level is gone. The 7 src/cloudflare/internal/test packages that load py_wd_test.bzl, and the Pyodide AGENTS.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-test passes in all variants, including @gc-stress.
  • The other moved runtime tests, the three UDP tests and server-harness-test pass.
  • //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 --check is clean.

Edgeworker's docs mention the old Python path in two places (docs/python_workers.md and a comment in src/edgeworker/tests/python/snapshots/BUILD). Nothing there loads from it, so this doesn't break its build.

🤖 Generated with Claude Code

danlapid and others added 2 commits November 17, 2026 20:37
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>
@danlapid
danlapid force-pushed the dlapid/rehome-server-tests branch from 2209beb to 0076965 Compare November 18, 2026 01:38
@danlapid
danlapid marked this pull request as ready for review November 18, 2026 01:50
@danlapid
danlapid requested review from a team as code owners November 18, 2026 01:50

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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

@danlapid
danlapid merged commit 11bee9d into main Nov 18, 2026
24 of 25 checks passed
@danlapid
danlapid deleted the dlapid/rehome-server-tests branch November 18, 2026 03:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants