Browse documentation

The test262 runner runs in UTC and applies the suite corrections itself

Date: 2026-12-02 Area: test262, cli Related: ADR 0120, test262

Context

CI's test262 jobs graded a run under two conditions that lived in the workflows, not in GocciaTest262Runner. GitHub's Linux runners keep their clock in UTC, so every run's local time zone was UTC. A workflow step, scripts/apply-test262-patches.sh, applied the corrections in scripts/test262-patches to the checkout before the run.

A run on a machine whose local zone is Europe/London, of the same commit and the same pinned suite, passed seven runs fewer than CI's. Six were built-ins/Date/prototype/toISOString/15.9.5.43-0-{8,9,10}.js in both modes. The test takes the local offset of 1970 (UTC+1 in London that year) and builds a local date 100 million days earlier, expecting it to land one millisecond past the end of the time value range. London's offset that far back is local mean time, -0:01:15, so the date lands inside the range and toISOString rightly does not throw: the engine is right, and the test holds only where the offset is the same in both years. The seventh was annexB/language/function-code/block-decl-func-skip-arguments.js, which the correction for tc39/test262#5112 changes and the local run had not applied.

The script had a hidden failure of its own: in a suite that is not a git repository of its own but sits inside one, git -C <suite> apply reads the patch's paths against the outer repository's root, applies nothing and exits 0.

Decision

Johannes asked for the runner to pin what it needs (1 December 2026: "the runner (or its wrapper script) pins what it needs (TZ=UTC, suite patch applied) so a local full run matches CI on any machine's timezone").

Every run takes UTC as its local zone. The runner sets the engine's time zone override to UTC for each run, and an agent a run starts ($262.agent.start, an engine of its own on a thread of its own) takes its starting thread's override, so Date, Intl and Temporal.Now read UTC whatever TZ and the machine's zone are. It is the override the engine already has for a deterministic host, so it holds on Windows, where Date reads the system's zone rather than TZ. The console summary names the zone. --eval-host keeps the machine's zone unless --deterministic is given.

The runner applies the corrections itself. build.pas compiles scripts/test262-patches/*.patch into the runner, base64-encoded so that a patch reaches git byte for byte, CR included (test262 commits some tests with CRLF line endings); .gitattributes marks the patches -text, so no checkout of GocciaScript converts them. The coordinator applies each one to --suite-dir with git apply before it discovers a test, and names the outcome in the console summary:

  • applied;
  • already applied, by an earlier run: the working tree has it and the checkout's commit does not;
  • not in this suite, when the suite has none of the directories the correction changes files in, as a synthetic suite in a test does. A directory, not a file, decides it, so a correction that adds a file still applies, and one whose file a new pin removed still stops the run.

A correction stops the run with exit 1, naming it and the suite, when the checkout's HEAD already has it, since the pin then includes its pull request, and when it neither applies nor is already there, since the pinned test has changed under it: either way the patch is due to be deleted. HEAD is checked first, with git apply --check --reverse --cached against a private index read from HEAD (GIT_INDEX_FILE), so neither the working tree nor what the checkout has staged can hide it, and the checkout's own index is not touched. It also stops the run when a file of the correction has no --- a/ or +++ b/ header with an unquoted path, such as a rename with no change: without its paths the runner cannot tell a partial suite. git apply runs with GIT_CEILING_DIRECTORIES set to the suite's physical parent (symbolic links resolved), so a suite inside another repository is corrected too. Runners started at once on one suite take turns, under a lock file in the temporary directory named after the suite's physical path and removed on release. scripts/apply-test262-patches.sh and the workflows' steps that ran it are removed.

The corrections are applied in the checkout, not in memory, because a module test reads its own file, and the files it imports, through the engine's module loader: only the files on disk reach every test that reads them.

Consequences

  • A run of a checkout at the pinned SHA grades as CI does with no step before it, whatever the machine's zone. Settings this decision does not pin, such as the default locale, still follow the machine.
  • The runner needs git on the PATH when the suite has a directory a correction changes files in. A test262 checkout comes from git, so a machine that has one has git.
  • The runner writes to the suite it is given, as the workflow step did: a correction stays applied in a local checkout, and the next run reports it already applied.
  • The corrections are made against test262's committed bytes, so a checkout whose line endings git converted (core.autocrlf on Windows) cannot take them: such a run stops, naming the correction.
  • A test262 test that depends on the local zone is graded in UTC only, as it was in CI. Local time in other zones is exercised by the CLI tests that give the engine a host environment's zone (scripts/test-cli-apps.ts), not by test262.