Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

tests.loadHttp

Fetch the engine's test content over HTTP and materialize it into the @builtin library so tests.list and tests.run can discover and run the suites.

The engine's test content (its .testSuite assets, and the fixtures and packages only they use) is embedded in no build and reaches no end user. A --dev engine reads it off disk; every other engine (the WASM engine in a browser, an Android app, a native engine reading its library from ZeroMind) uses this tool at test time, fetching from an HTTP root (base) that serves a checkout's src/lua/lib. The browser bundle serves src/lua/* as static files under /lua/ of the page's own origin, so a browser engine's default base is /lua/lib. An engine outside a browser has no origin to resolve a path against: it takes base as an absolute URL and refuses a load that names none. The proxy's luau_test { instance } serves the instance's worktree on a loopback port (an Android device reaches it through adb reverse) and passes that root to tests.run as contentBase. A generated suites-manifest.json lists each suite's files (suites) and the files the suites share (support, such as tests/fixtures/ and pkgtest/). Every load materializes the shared files along with the suites it picks. A suite that reads other suites (their sources, or runs them) names the library folder that holds them on a --!needs <folder> line of its init.luau, such as --!needs systems/procgen.package; a load that picks it picks every suite under that folder as well, so the suites it reads are in the engine wherever it runs. Every file is written under /zero/source/libs/@builtin/<rel>, which registers it as a @builtin:: asset (a suite as @builtin::tests.suites.<name>) with the same identity, origin, and internal-require resolution as a --dev boot.

The HTTP fetch is asynchronous, so by default the work runs as a scheduler task and the call returns { taskId } to watch; the browser harness polls it to completion before discovering suites. Pass { async = false } to block and return { suites, support, files, base }.

A request that is not answered with a 2xx (a URL that cannot be sent, a refused connection, a 404) raises naming the URL and what it answered, and the load materializes none of its files.