3D engine that AI agents drive
Balance the unit test shards from measured timings (#996)
Nguyen Xuan Anda81d856597d
diff --git a/.github/workflows/test.yml b/.github/workflows/test.ymlindex 032a9fb3..0cec5434 100644--- a/.github/workflows/test.yml+++ b/.github/workflows/test.yml@@ -64,20 +64,20 @@ jobs:- run: npm run tool-cost -- --base "$SIZE_BASE_REF"# `node --test` already runs every file in its own process (Node 24 default, --test-isolation=process), so one pass over- # the files is also the isolation check. Eight shards of hashed file names (scripts/shard-test-files.mjs). The light bake tests are heavy, so one shard of three took twice as long as the others.+ # the files is also the isolation check. Twelve shards dealt by measured file time (scripts/shard-test-files.mjs, test-timings.json): the slowest file (about 150 s) is the floor, and 12 shards reach it where 8 stay about 40% above it. Change the matrix and the count in the test command together; tests/shard-test-files.test.js checks they agree.unit:runs-on: ubuntu-latesttimeout-minutes: 15strategy:fail-fast: falsematrix:- shard: [1, 2, 3, 4, 5, 6, 7, 8]+ shard: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]steps:- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1- uses: ./.github/actions/setup# The live MCP tests need build/ and build/mcp.- run: npm run build:lib- - run: mkdir -p coverage && npm run test:coverage -- --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=coverage/shard-${{ matrix.shard }}.info --test-reporter=./scripts/test-timing-reporter.mjs --test-reporter-destination=coverage/timings-${{ matrix.shard }}.json $(node scripts/shard-test-files.mjs ${{ matrix.shard }} 8)+ - run: mkdir -p coverage && npm run test:coverage -- --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=coverage/shard-${{ matrix.shard }}.info --test-reporter=./scripts/test-timing-reporter.mjs --test-reporter-destination=coverage/timings-${{ matrix.shard }}.json $(node scripts/shard-test-files.mjs ${{ matrix.shard }} 12)- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2if: always()with:diff --git a/changes/996-balance-test-shards.md b/changes/996-balance-test-shards.mdnew file mode 100644index 00000000..f7bed91a--- /dev/null+++ b/changes/996-balance-test-shards.md@@ -0,0 +1 @@+- Balanced the unit test shards from measured timings: untimed test files are dealt by the median timing instead of a hash, the timings are refreshed, the unit matrix has 12 shards and `node scripts/shard-test-files.mjs --from-run <run id>` refreshes the timings (#996).diff --git a/scripts/shard-test-files.mjs b/scripts/shard-test-files.mjsindex 03e15908..4c5b6551 100644--- a/scripts/shard-test-files.mjs+++ b/scripts/shard-test-files.mjs@@ -1,11 +1,23 @@-// Prints the test files of one shard, one path per line: node scripts/shard-test-files.mjs <shard 1..count> <count>+// Prints the test files of one shard, one path per line: node scripts/shard-test-files.mjs <shard 1..count> <count> [--untimed=hash]//// Files listed in test-timings.json (milliseconds per file, measured on CI) are dealt out longest first, each to the shard with the-// least time so far, which keeps every shard close to the same length. A file without a timing goes to the shard its name hashes to,-// so adding a test file never moves another file and the merged coverage figures stay steady. Refresh the timings after a change that-// makes tests much slower or faster: download the `timings-*.json` files from a CI run and run `node scripts/shard-test-files.mjs --merge-timings <files>`.+// least time so far, which keeps every shard close to the same length.+//+// A file without a timing (a test file added since the last refresh) is dealt after all timed files, using the median timing as its+// estimate, so it goes to the lightest shard and never moves a timed file. Hashing the name instead (--untimed=hash, the behaviour+// before #996) kept the coverage gate steady, because the gate compared function totals that depended on how files were grouped.+// #993 makes those totals independent of the layout, so the estimate is the default; the hash path stays behind the flag until+// #993 has merged and the flag has no user left.+//+// Refresh the timings after a change that makes tests much slower or faster, from any finished Test run (its shard artifacts hold+// the per-file times):+// node scripts/shard-test-files.mjs --from-run <run id>+// or from timings files you already downloaded (several runs give the median per file):+// node scripts/shard-test-files.mjs --merge-timings <files>import { createHash } from 'node:crypto';-import { readdirSync, readFileSync, writeFileSync } from 'node:fs';+import { execFileSync } from 'node:child_process';+import { mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';import { join } from 'node:path';const rootDirectory = join(import.meta.dirname, '..');@@ -16,22 +28,34 @@ function hashedShard(fileName, count) {return digest.readUInt32BE(0) % count;}-export function assignShards(fileNames, timings, count) {+export function medianOf(numbers) {+ if (numbers.length === 0) return 0;+ const sorted = [...numbers].sort((a, b) => a - b);+ const middle = Math.floor(sorted.length / 2);+ return sorted.length % 2 === 1 ? sorted[middle] : (sorted[middle - 1] + sorted[middle]) / 2;+}++export function assignShards(fileNames, timings, count, { untimed = 'estimate' } = {}) {const shardOfFile = new Map();const shardTotals = new Array(count).fill(0);- const timed = fileNames- .filter(name => timings[name] !== undefined)- .sort((a, b) => timings[b] - timings[a] || a.localeCompare(b));- for (const name of timed) {+ const estimate = medianOf(Object.values(timings));+ const timingOf = name => timings[name] ?? estimate;+ const isTimed = name => timings[name] !== undefined;+ const dealt = untimed === 'hash' ? fileNames.filter(isTimed) : fileNames;+ // Timed files first, then untimed ones: the position of a timed file never depends on which untimed files exist.+ const order = (a, b) => Number(isTimed(b)) - Number(isTimed(a)) || timingOf(b) - timingOf(a) || a.localeCompare(b);+ for (const name of [...dealt].sort(order)) {let lightest = 0;for (let shard = 1; shard < count; shard += 1) {if (shardTotals[shard] < shardTotals[lightest]) lightest = shard;}shardOfFile.set(name, lightest);- shardTotals[lightest] += timings[name];+ shardTotals[lightest] += timingOf(name);}- for (const name of fileNames) {- if (timings[name] === undefined) shardOfFile.set(name, hashedShard(name, count));+ if (untimed === 'hash') {+ for (const name of fileNames) {+ if (!isTimed(name)) shardOfFile.set(name, hashedShard(name, count));+ }}return shardOfFile;}@@ -44,25 +68,48 @@ function listTestFiles() {}function mergeTimings(paths) {- const merged = {};- for (const path of paths) Object.assign(merged, JSON.parse(readFileSync(path, 'utf8')));- const sorted = Object.fromEntries(Object.entries(merged).sort(([a], [b]) => a.localeCompare(b)));+ const measurements = new Map();+ for (const path of paths) {+ for (const [name, milliseconds] of Object.entries(JSON.parse(readFileSync(path, 'utf8')))) {+ measurements.set(name, [...(measurements.get(name) ?? []), milliseconds]);+ }+ }+ const sorted = Object.fromEntries(+ [...measurements.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([name, values]) => [name, Math.round(medianOf(values))])+ );writeFileSync(timingsPath, `${JSON.stringify(sorted, null, 2)}\n`);console.log(`Wrote ${Object.keys(sorted).length} timings to test-timings.json`);}+function mergeTimingsFromRun(runId) {+ const downloadDirectory = mkdtempSync(join(tmpdir(), 'test-timings-'));+ try {+ execFileSync('gh', ['run', 'download', runId, '--pattern', 'lcov-shard-*', '-D', downloadDirectory], { stdio: 'inherit' });+ const timingsFiles = readdirSync(downloadDirectory, { recursive: true })+ .filter(name => /timings-\d+\.json$/.test(name))+ .map(name => join(downloadDirectory, name));+ if (timingsFiles.length === 0) throw new Error(`Run ${runId} has no timings-*.json in its lcov-shard-* artifacts.`);+ mergeTimings(timingsFiles);+ } finally {+ rmSync(downloadDirectory, { recursive: true, force: true });+ }+}+if (process.argv[1] === import.meta.filename) {- if (process.argv[2] === '--merge-timings') {- mergeTimings(process.argv.slice(3));+ const arguments_ = process.argv.slice(2);+ if (arguments_[0] === '--merge-timings') {+ mergeTimings(arguments_.slice(1));+ } else if (arguments_[0] === '--from-run') {+ mergeTimingsFromRun(arguments_[1]);} else {- const shard = Number(process.argv[2]);- const count = Number(process.argv[3]);+ const untimed = arguments_.includes('--untimed=hash') ? 'hash' : 'estimate';+ const [shard, count] = arguments_.filter(argument => !argument.startsWith('--')).map(Number);if (!Number.isInteger(shard) || !Number.isInteger(count) || shard < 1 || shard > count) {- console.error('Usage: node scripts/shard-test-files.mjs <shard 1..count> <count>');+ console.error('Usage: node scripts/shard-test-files.mjs <shard 1..count> <count> [--untimed=hash]');process.exit(2);}const timings = JSON.parse(readFileSync(timingsPath, 'utf8'));- const shardOfFile = assignShards(listTestFiles(), timings, count);+ const shardOfFile = assignShards(listTestFiles(), timings, count, { untimed });for (const [name, assigned] of shardOfFile) {if (assigned === shard - 1) console.log(name);}diff --git a/test-timings.json b/test-timings.jsonindex 8a2d85d6..7e9e3039 100644--- a/test-timings.json+++ b/test-timings.json@@ -1,246 +1,425 @@{- "tests/adaptive-quality.test.js": 4,- "tests/agent-asset-catalog.test.js": 741,- "tests/agent-asset-ik.test.js": 1273,- "tests/agent-asset-layers.test.js": 828,- "tests/agent-asset-mesh.test.js": 982,- "tests/agent-asset-motion.test.js": 111,- "tests/agent-asset-retarget.test.js": 336,- "tests/agent-asset.test.js": 195,- "tests/agent-bake-budget.test.js": 60057,- "tests/agent-bake-cloth-probes-fit.test.js": 33772,- "tests/agent-bake-limits.test.js": 57505,- "tests/agent-bake-materials-lights.test.js": 61513,- "tests/agent-bake.test.js": 36314,- "tests/agent-branches-live.test.js": 2,- "tests/agent-branches.test.js": 5,- "tests/agent-cloth-in-place.test.js": 906,- "tests/agent-combined-asset-limit.test.js": 127,- "tests/agent-drive.test.js": 628,- "tests/agent-floor-sky-trace.test.js": 2055,- "tests/agent-ground.test.js": 4,- "tests/agent-llms-only-check.test.js": 284,+ "tests/actionable-errors-mesh-edits.test.js": 211,+ "tests/actionable-errors-motion.test.js": 1022,+ "tests/actionable-errors-nature.test.js": 47,+ "tests/actionable-errors-scene-core.test.js": 71,+ "tests/actionable-errors.test.js": 473,+ "tests/adaptive-quality.test.js": 5,+ "tests/agent-annotate.test.js": 1168,+ "tests/agent-apply-report.test.js": 6,+ "tests/agent-apply-results.test.js": 364,+ "tests/agent-asset-catalog.test.js": 672,+ "tests/agent-asset-ik.test.js": 1399,+ "tests/agent-asset-layers.test.js": 1264,+ "tests/agent-asset-mesh.test.js": 1526,+ "tests/agent-asset-motion.test.js": 179,+ "tests/agent-asset-retarget.test.js": 514,+ "tests/agent-asset.test.js": 264,+ "tests/agent-bake-budget.test.js": 57342,+ "tests/agent-bake-cloth-probes-fit.test.js": 25265,+ "tests/agent-bake-gpu.test.js": 14,+ "tests/agent-bake-limits.test.js": 60239,+ "tests/agent-bake-materials-lights.test.js": 90574,+ "tests/agent-bake-stale.test.js": 91389,+ "tests/agent-bake.test.js": 92966,+ "tests/agent-bench.test.js": 6430,+ "tests/agent-branches-live.test.js": 1,+ "tests/agent-branches.test.js": 7,+ "tests/agent-cloth-in-place.test.js": 1139,+ "tests/agent-combined-asset-limit.test.js": 159,+ "tests/agent-drive.test.js": 1219,+ "tests/agent-floor-sky-trace.test.js": 4988,+ "tests/agent-ground.test.js": 6,+ "tests/agent-llms-only-check.test.js": 194,"tests/agent-look-lights.test.js": 7,- "tests/agent-look-score.test.js": 3947,- "tests/agent-look.test.js": 13,- "tests/agent-modeling-suite.test.js": 28043,- "tests/agent-motion-constraints.test.js": 77,- "tests/agent-motion-ik-limits.test.js": 421,- "tests/agent-motion-ik.test.js": 126,- "tests/agent-motion.test.js": 29,- "tests/agent-object-reflections.test.js": 609,- "tests/agent-physics.test.js": 875,- "tests/agent-preview-modules.test.js": 803,- "tests/agent-preview.test.js": 291,- "tests/agent-query-asset.test.js": 22,- "tests/agent-render-jobs.test.js": 1524,- "tests/agent-render-limits.test.js": 6,+ "tests/agent-look-score.test.js": 13355,+ "tests/agent-look.test.js": 27,+ "tests/agent-modeling-suite.test.js": 71953,+ "tests/agent-motion-camera-drivers.test.js": 58,+ "tests/agent-motion-constraints-more.test.js": 144,+ "tests/agent-motion-constraints.test.js": 210,+ "tests/agent-motion-ik-limits.test.js": 286,+ "tests/agent-motion-ik.test.js": 186,+ "tests/agent-motion-look.test.js": 994,+ "tests/agent-motion-properties.test.js": 91,+ "tests/agent-motion.test.js": 43,+ "tests/agent-native-trace.test.js": 5,+ "tests/agent-object-reflections.test.js": 1211,+ "tests/agent-physics.test.js": 4854,+ "tests/agent-preview-modules.test.js": 834,+ "tests/agent-preview.test.js": 337,+ "tests/agent-query-asset.test.js": 31,+ "tests/agent-render-jobs.test.js": 580,+ "tests/agent-render-limits.test.js": 7,+ "tests/agent-render-output.test.js": 230,"tests/agent-review.test.js": 3,- "tests/agent-runtime.test.js": 190,- "tests/agent-scene-assets.test.js": 374,- "tests/agent-scene-crowd.test.js": 3282,- "tests/agent-scene-motion.test.js": 53,- "tests/agent-scene-on-demand.test.js": 248,- "tests/agent-scene-vegetation.test.js": 6160,- "tests/agent-scene.test.js": 367,- "tests/agent-suite-aggregate.test.js": 26,- "tests/agent-texture-sequence.test.js": 51,- "tests/agent-threejs-grade.test.js": 401,- "tests/agent-walkmap-recipe.test.js": 89,- "tests/agent-walkmap.test.js": 140,- "tests/animation-mixer.test.js": 22,- "tests/animation.test.js": 114,- "tests/assembly.test.js": 172,- "tests/blender-constraints.test.js": 44,- "tests/blender-curve-text.test.js": 123,- "tests/blender-golden.test.js": 3860,- "tests/budget.test.js": 7,- "tests/cabinet-tasks.test.js": 198,- "tests/camera-path.test.js": 8,- "tests/camera.test.js": 9,- "tests/canvas2d.test.js": 20,- "tests/cascaded-shadows.test.js": 10,- "tests/changelog-data.test.js": 19,- "tests/changelog-fragments.test.js": 28,- "tests/closed-room.test.js": 1735,- "tests/cloth-blender.test.js": 3782,- "tests/cloth-moving.test.js": 55866,- "tests/cloth.test.js": 8377,- "tests/clutter.test.js": 1482,- "tests/compressed-texture.test.js": 7,- "tests/coplanar-overlap.test.js": 78,- "tests/crowd-skinning.test.js": 1202,- "tests/curve-text.test.js": 3078,- "tests/default-look.test.js": 158,- "tests/desk-tasks.test.js": 174,- "tests/docs-pages.test.js": 307,- "tests/easing.test.js": 25,- "tests/effects.test.js": 4,- "tests/environment.test.js": 51,- "tests/export-options.test.js": 5,- "tests/export-roundtrip.test.js": 510,- "tests/export.test.js": 558,- "tests/expression.test.js": 5,- "tests/file-scene-render.test.js": 10,- "tests/film-character.test.js": 318,- "tests/film-physics.test.js": 8656,- "tests/film-timeline.test.js": 562,- "tests/film.test.js": 26619,- "tests/floor-sky-visibility.test.js": 2001,- "tests/fog-bounce.test.js": 955,- "tests/fog-fit.test.js": 1,- "tests/fog-sky-visibility.test.js": 105,+ "tests/agent-runtime.test.js": 257,+ "tests/agent-scene-assets.test.js": 525,+ "tests/agent-scene-crowd.test.js": 3566,+ "tests/agent-scene-motion.test.js": 92,+ "tests/agent-scene-ocean-time.test.js": 287,+ "tests/agent-scene-on-demand.test.js": 421,+ "tests/agent-scene-vegetation.test.js": 18444,+ "tests/agent-scene.test.js": 624,+ "tests/agent-suite-aggregate.test.js": 42,+ "tests/agent-texture-sequence.test.js": 119,+ "tests/agent-threejs-grade.test.js": 609,+ "tests/agent-tool-error-causes.test.js": 456,+ "tests/agent-walkmap-recipe.test.js": 66,+ "tests/agent-walkmap.test.js": 273,+ "tests/animation-fast-path.test.js": 455,+ "tests/animation-foot-slide.test.js": 144,+ "tests/animation-graph.test.js": 20,+ "tests/animation-mixer.test.js": 29,+ "tests/animation-modifiers.test.js": 16,+ "tests/animation-root-motion.test.js": 77,+ "tests/animation.test.js": 182,+ "tests/assembly.test.js": 232,+ "tests/audio.test.js": 16,+ "tests/blender-constraints.test.js": 58,+ "tests/blender-curve-text.test.js": 100,+ "tests/blender-golden.test.js": 2481,+ "tests/budget.test.js": 4,+ "tests/cabinet-tasks.test.js": 282,+ "tests/camera-path.test.js": 11,+ "tests/camera.test.js": 15,+ "tests/canvas2d.test.js": 17,+ "tests/cascaded-shadows.test.js": 7,+ "tests/changelog-data.test.js": 23,+ "tests/changelog-fragments.test.js": 24,+ "tests/claude-plugin.test.js": 4,+ "tests/clip-strips.test.js": 1080,+ "tests/closed-room.test.js": 3181,+ "tests/cloth-bending.test.js": 4574,+ "tests/cloth-blender.test.js": 2845,+ "tests/cloth-friction.test.js": 3866,+ "tests/cloth-moving.test.js": 85863,+ "tests/cloth-self-collision-thickness.test.js": 8473,+ "tests/cloth.test.js": 12068,+ "tests/clutter.test.js": 2353,+ "tests/compressed-texture.test.js": 5,+ "tests/cook-kernel-parity.test.js": 10,+ "tests/cooperative-loading.test.js": 128,+ "tests/coplanar-overlap.test.js": 739,+ "tests/coverage-gate.test.js": 2,+ "tests/crowd-skinning.test.js": 1587,+ "tests/curve-splines.test.js": 214,+ "tests/curve-text.test.js": 2980,+ "tests/cycles-parity-many-lights.test.js": 1526,+ "tests/default-look.test.js": 64,+ "tests/desk-tasks.test.js": 224,+ "tests/docs-pages.test.js": 380,+ "tests/easing.test.js": 63,+ "tests/effects.test.js": 3,+ "tests/environment.test.js": 67,+ "tests/export-mesh.test.js": 395,+ "tests/export-options.test.js": 4,+ "tests/export-roundtrip.test.js": 1030,+ "tests/export.test.js": 486,+ "tests/expression.test.js": 6,+ "tests/field-math.test.js": 22,+ "tests/field-mesh-inputs.test.js": 39,+ "tests/file-scene-render.test.js": 17,+ "tests/film-character.test.js": 152,+ "tests/film-physics.test.js": 6852,+ "tests/film-timeline.test.js": 1797,+ "tests/film.test.js": 32238,+ "tests/flicker-ground-truth.test.js": 184,+ "tests/floor-sky-visibility.test.js": 1037,+ "tests/flush-asset.test.js": 52,+ "tests/flush-clip.test.js": 13,+ "tests/flush-depth-separation.test.js": 3,+ "tests/flush-path-tracer.test.js": 75,+ "tests/flush-resolve.test.js": 145,+ "tests/flush-search.test.js": 69,+ "tests/fog-bounce.test.js": 1293,+ "tests/fog-field.test.js": 12,+ "tests/fog-fit.test.js": 2,+ "tests/fog-shader.test.js": 318,+ "tests/fog-sky-visibility.test.js": 158,"tests/foliage-transmission.test.js": 1,- "tests/frame-diagnostics.test.js": 2,- "tests/gaussian-splats.test.js": 92,+ "tests/force-fields.test.js": 509,+ "tests/frame-checks.test.js": 40854,+ "tests/frame-diagnostics.test.js": 3,+ "tests/game-animation-asset.test.js": 1784,+ "tests/game-animation.test.js": 6593,+ "tests/game-rules.test.js": 51,+ "tests/game-setup.test.js": 286,+ "tests/game-start.test.js": 337,+ "tests/gaussian-splats.test.js": 109,+ "tests/geometry-cone-icosphere-circle.test.js": 176,+ "tests/git-hooks.test.js": 3,"tests/gl-program-lost-context.test.js": 3,- "tests/gltf-extensions.test.js": 72,- "tests/gltf-meshopt.test.js": 192,- "tests/gltf-morph-normals-and-nan.test.js": 13,- "tests/gltf-morph.test.js": 35,- "tests/gltf-node-pose.test.js": 56,- "tests/gltf-optional.test.js": 23,- "tests/gltf-shared-textures.test.js": 109,- "tests/gltf-skeleton-and-bad-primitives.test.js": 29,- "tests/gltf-sketchfab-fallbacks.test.js": 26,+ "tests/gl-program-prepare.test.js": 4,+ "tests/gltf-extensions.test.js": 75,+ "tests/gltf-meshopt.test.js": 176,+ "tests/gltf-morph-normals-and-nan.test.js": 37,+ "tests/gltf-morph.test.js": 64,+ "tests/gltf-node-pose.test.js": 87,+ "tests/gltf-optional.test.js": 49,+ "tests/gltf-shared-textures.test.js": 65,+ "tests/gltf-skeleton-and-bad-primitives.test.js": 46,+ "tests/gltf-sketchfab-fallbacks.test.js": 28,"tests/gltf-tolerance-clip.test.js": 26,- "tests/gltf-tolerance.test.js": 16,- "tests/gltf.test.js": 174,- "tests/grass.test.js": 1565,- "tests/ground-bounce.test.js": 27,- "tests/heightfield.test.js": 35,- "tests/input-key-guards.test.js": 4,- "tests/irradiance-grid.test.js": 1755,- "tests/kernel-offload.test.js": 21715,- "tests/kettle-tasks.test.js": 93,- "tests/large-bounds.test.js": 686,- "tests/layer-textures.test.js": 56,- "tests/light-bake-backends.test.js": 589,- "tests/light-bake-texel-density.test.js": 305,- "tests/light-bake.test.js": 4930,- "tests/light-linking.test.js": 3,+ "tests/gltf-tolerance.test.js": 23,+ "tests/gltf-track-binding.test.js": 37,+ "tests/gltf.test.js": 165,+ "tests/gpu-round-trips.test.js": 5179,+ "tests/grass.test.js": 4424,+ "tests/grid-medium.test.js": 34,+ "tests/ground-bounce.test.js": 17,+ "tests/heightfield.test.js": 48,+ "tests/hero-chipfab-animation.test.js": 11977,+ "tests/hero-first-view-crop.test.js": 6,+ "tests/hero-mode.test.js": 22,+ "tests/hero-port-crane-rear.test.js": 1062,+ "tests/hero-prefetch.test.js": 14,+ "tests/hero-progressive.test.js": 35,+ "tests/incremental-grouping.test.js": 299,+ "tests/input-key-guards.test.js": 6,+ "tests/input-touch-replay.test.js": 91,+ "tests/input.test.js": 14,+ "tests/irradiance-grid-worker.test.js": 1162,+ "tests/irradiance-grid.test.js": 4385,+ "tests/kernel-offload.test.js": 32875,+ "tests/kettle-tasks.test.js": 262,+ "tests/large-bounds.test.js": 923,+ "tests/layer-textures.test.js": 81,+ "tests/license-site-copy.test.js": 5,+ "tests/light-bake-backends.test.js": 1107,+ "tests/light-bake-projected-uv.test.js": 7678,+ "tests/light-bake-texel-density.test.js": 246,+ "tests/light-bake.test.js": 9781,+ "tests/light-linking.test.js": 5,"tests/light-shading.test.js": 3,- "tests/light-units.test.js": 2,+ "tests/light-shapes-render.test.js": 1,+ "tests/light-shapes.test.js": 16,+ "tests/light-units.test.js": 3,+ "tests/lighting-passes.test.js": 54387,"tests/lighting.test.js": 7,- "tests/line-art-reference.test.js": 124,- "tests/line-art.test.js": 243,- "tests/live-cloth.test.js": 1223,- "tests/material-graph.test.js": 14028,- "tests/material-layer-shaders.test.js": 11,- "tests/material-layers.test.js": 63,- "tests/material-patterns.test.js": 12434,- "tests/material-snippet.test.js": 55,- "tests/mcp-environment-schema.test.js": 474,- "tests/mcp-node-fields.test.js": 114,- "tests/mcp-server-job-lock.test.js": 536,- "tests/mcp-tool-count.test.js": 142,- "tests/mcp-tools.test.js": 2036,- "tests/mesh-bevel.test.js": 184,- "tests/mesh-blend.test.js": 97,- "tests/mesh-boolean.test.js": 201,- "tests/mesh-core.test.js": 134,- "tests/mesh-cut-tools.test.js": 104,- "tests/mesh-decimate.test.js": 2424,- "tests/mesh-deform-modifiers.test.js": 32,- "tests/mesh-edit.test.js": 256,- "tests/mesh-fields.test.js": 122,- "tests/mesh-generator-modifiers.test.js": 50,- "tests/mesh-lint-geometry.test.js": 140,- "tests/mesh-loopcut.test.js": 267,- "tests/mesh-modifiers.test.js": 76,- "tests/mesh-normal-modifiers.test.js": 20,- "tests/mesh-query.test.js": 116,- "tests/mesh-sculpt-shrinkwrap.test.js": 1349,- "tests/mesh-stack.test.js": 134,- "tests/mesh-subdivide.test.js": 47,- "tests/mesh-uv.test.js": 275,- "tests/model.test.js": 373,- "tests/modeling-parity.test.js": 56,- "tests/modeling.test.js": 84,- "tests/morph-renderer.test.js": 29,- "tests/morph.test.js": 5,- "tests/nature.test.js": 607,- "tests/navmesh.test.js": 1185,- "tests/other-clients.test.js": 1750,- "tests/parity-ledger.test.js": 18,- "tests/part-relations.test.js": 976,- "tests/particles.test.js": 876,- "tests/path-tracer-denoise-oidn.test.js": 47,- "tests/path-tracer-emissive-fog.test.js": 1593,- "tests/path-tracer-gpu-pack.test.js": 12,- "tests/path-tracer-light-linking.test.js": 735,- "tests/path-tracer-subsurface.test.js": 1346,- "tests/path-tracer.test.js": 2549,- "tests/physics-colliders.test.js": 372,- "tests/physics.test.js": 601,+ "tests/line-art-reference.test.js": 90,+ "tests/line-art.test.js": 125,+ "tests/live-cloth.test.js": 1735,+ "tests/llms-txt.test.js": 161,+ "tests/local-volume-blur.test.js": 41046,+ "tests/local-volume-edge-warp.test.js": 17,+ "tests/local-volume-jitter.test.js": 7,+ "tests/local-volume-mesh-raster.test.js": 1307,+ "tests/local-volume-noise.test.js": 6354,+ "tests/local-volume-parts-raster.test.js": 770,+ "tests/local-volume-parts.test.js": 65,+ "tests/local-volume-scatter.test.js": 22254,+ "tests/local-volume-step-count.test.js": 2,+ "tests/local-volumes-entry-points.test.js": 1062,+ "tests/local-volumes.test.js": 853,+ "tests/look-catalog.test.js": 336,+ "tests/material-graph-fresnel.test.js": 172,+ "tests/material-graph-geometry.test.js": 410,+ "tests/material-graph-image.test.js": 1042,+ "tests/material-graph-mixing.test.js": 2077,+ "tests/material-graph.test.js": 30191,+ "tests/material-layer-shaders.test.js": 12,+ "tests/material-layers.test.js": 139,+ "tests/material-patterns.test.js": 17007,+ "tests/material-snippet.test.js": 74,+ "tests/material-wear.test.js": 118,+ "tests/mcp-annotations.test.js": 159,+ "tests/mcp-ask-user.test.js": 94,+ "tests/mcp-call-log.test.js": 126,+ "tests/mcp-camera-lights.test.js": 779,+ "tests/mcp-curve-schema.test.js": 93,+ "tests/mcp-environment-schema.test.js": 323,+ "tests/mcp-node-fields.test.js": 157,+ "tests/mcp-response-format.test.js": 122,+ "tests/mcp-scene-ids.test.js": 23298,+ "tests/mcp-server-job-lock.test.js": 811,+ "tests/mcp-shadow-only-schema.test.js": 108,+ "tests/mcp-tool-count.test.js": 161,+ "tests/mcp-tools.test.js": 1136,+ "tests/mcp-update-check.test.js": 594,+ "tests/mesh-bevel.test.js": 202,+ "tests/mesh-blend.test.js": 119,+ "tests/mesh-boolean-geometry-cutter.test.js": 2109,+ "tests/mesh-boolean.test.js": 442,+ "tests/mesh-build-modifier.test.js": 24,+ "tests/mesh-core.test.js": 363,+ "tests/mesh-cut-tools.test.js": 83,+ "tests/mesh-decimate.test.js": 2435,+ "tests/mesh-deform-modifiers.test.js": 37,+ "tests/mesh-edit.test.js": 335,+ "tests/mesh-field-surfaces.test.js": 78,+ "tests/mesh-fields.test.js": 2375,+ "tests/mesh-generator-modifiers.test.js": 59,+ "tests/mesh-instance-placement.test.js": 83,+ "tests/mesh-lint-geometry.test.js": 208,+ "tests/mesh-loopcut.test.js": 329,+ "tests/mesh-masks.test.js": 1137,+ "tests/mesh-modifiers.test.js": 95,+ "tests/mesh-normal-modifiers.test.js": 23,+ "tests/mesh-ocean.test.js": 206,+ "tests/mesh-query.test.js": 239,+ "tests/mesh-reshape.test.js": 177,+ "tests/mesh-sculpt-shrinkwrap.test.js": 1596,+ "tests/mesh-shape-keys.test.js": 57,+ "tests/mesh-stack-budget.test.js": 77351,+ "tests/mesh-stack.test.js": 261,+ "tests/mesh-subdivide.test.js": 69,+ "tests/mesh-to-curve.test.js": 402,+ "tests/mesh-uv-project.test.js": 183,+ "tests/mesh-uv.test.js": 486,+ "tests/mesh-vertex-groups.test.js": 147,+ "tests/mesh-volume-pass-geometry.test.js": 4,+ "tests/mesh-wireframe.test.js": 15,+ "tests/mirrored-winding.test.js": 5,+ "tests/model.test.js": 935,+ "tests/modeling-parity.test.js": 105,+ "tests/modeling-sdf.test.js": 2475,+ "tests/modeling.test.js": 58,+ "tests/morph-renderer.test.js": 47,+ "tests/morph.test.js": 10,+ "tests/motion-bake.test.js": 1761,+ "tests/native-bake.test.js": 81,+ "tests/native-fallback-job.test.js": 99586,+ "tests/native-filter.test.js": 10,+ "tests/native-light-tree-kernel.test.js": 2,+ "tests/native-light-tree.test.js": 996,+ "tests/native-pack-input.test.js": 17,+ "tests/native-pack-v2.test.js": 42,+ "tests/native-sampler.test.js": 2,+ "tests/nature.test.js": 981,+ "tests/navmesh.test.js": 1507,+ "tests/near-plane-fit.test.js": 2,+ "tests/netcode-broadcast.test.js": 17,+ "tests/netcode-datachannel.test.js": 34,+ "tests/netcode-sample.test.js": 165,+ "tests/netcode-two-browsers.test.js": 18568,+ "tests/netcode.test.js": 452,+ "tests/npc-follower.test.js": 346,+ "tests/object-motion-blur-stage.test.js": 5,+ "tests/object-motion-blur.test.js": 10,+ "tests/other-clients.test.js": 1582,+ "tests/packaged-looks.test.js": 5423,+ "tests/parity-ledger.test.js": 29,+ "tests/part-relations.test.js": 6541,+ "tests/particle-collision.test.js": 2068,+ "tests/particle-emitter-mesh.test.js": 561,+ "tests/particles.test.js": 1766,+ "tests/path-tracer-denoise-oidn.test.js": 70,+ "tests/path-tracer-denoise.test.js": 30,+ "tests/path-tracer-emissive-fog.test.js": 2942,+ "tests/path-tracer-gpu-kernel-size.test.js": 15,+ "tests/path-tracer-gpu-pack.test.js": 27,+ "tests/path-tracer-light-linking.test.js": 588,+ "tests/path-tracer-light-tree.test.js": 1848,+ "tests/path-tracer-progressive.test.js": 13560,+ "tests/path-tracer-radiance-cache.test.js": 87,+ "tests/path-tracer-realtime-webgpu-device.test.js": 21,+ "tests/path-tracer-realtime-webgpu.test.js": 5,+ "tests/path-tracer-reprojection.test.js": 7,+ "tests/path-tracer-shadow-only.test.js": 320,+ "tests/path-tracer-subsurface.test.js": 1982,+ "tests/path-tracer-texture-pixels.test.js": 1,+ "tests/path-tracer-texture-wrap.test.js": 7,+ "tests/path-tracer-webgpu.test.js": 13,+ "tests/path-tracer.test.js": 4273,+ "tests/physical-sky.test.js": 8621,+ "tests/physics-colliders.test.js": 304,+ "tests/physics-jolt.test.js": 1476,+ "tests/physics-runtime.test.js": 914,+ "tests/physics.test.js": 780,+ "tests/player-rigs.test.js": 65,+ "tests/player.test.js": 37,+ "tests/post-steps.test.js": 39,+ "tests/pr-metadata-check.test.js": 18,+ "tests/preflight.test.js": 6,"tests/preview-transition.test.js": 2,- "tests/ragdoll.test.js": 2162,- "tests/recipe-cascades-linking.test.js": 326,+ "tests/ragdoll.test.js": 2648,+ "tests/recipe-cascades-linking.test.js": 776,+ "tests/recode-glb-textures.test.js": 116,"tests/reference-bake-regression.test.js": 3,- "tests/reference-baseline.test.js": 6,+ "tests/reference-baseline.test.js": 4,"tests/reference-quantisation.test.js": 2,- "tests/reflection-probes.test.js": 3627,- "tests/render-culling.test.js": 73,- "tests/render-passes.test.js": 49,- "tests/render-target-memory.test.js": 4,- "tests/renderer-topology.test.js": 116,- "tests/renderer.test.js": 21,- "tests/replace-textured-parts-import.test.js": 15,- "tests/retarget.test.js": 97,- "tests/reversed-depth.test.js": 6,- "tests/rigging.test.js": 1301,- "tests/room-bounce.test.js": 60,+ "tests/reflection-probes.test.js": 4268,+ "tests/render-culling.test.js": 110,+ "tests/render-flags-scene.test.js": 97,+ "tests/render-flags.test.js": 824,+ "tests/render-passes.test.js": 386,+ "tests/render-skill-examples.test.js": 3,+ "tests/render-target-memory.test.js": 11,+ "tests/renderer-topology.test.js": 205,+ "tests/renderer.test.js": 32,+ "tests/replace-parts-incremental.test.js": 12681,+ "tests/replace-textured-parts-import.test.js": 26,+ "tests/retarget.test.js": 84,+ "tests/reversed-depth.test.js": 8,+ "tests/rigging.test.js": 2001,+ "tests/room-bounce.test.js": 54,"tests/runtime-report.test.js": 3,- "tests/scene-graph.test.js": 21,- "tests/scene-query-obstacles.test.js": 34,- "tests/scene-query.test.js": 11,- "tests/sculpt.test.js": 51,+ "tests/runtime.test.js": 21,+ "tests/scene-graph.test.js": 35,+ "tests/scene-query-obstacles.test.js": 43,+ "tests/scene-query.test.js": 9,+ "tests/sculpt.test.js": 30,+ "tests/seek-mipmap-history.test.js": 2,"tests/shader-features.test.js": 4,- "tests/shader-snippet-validator.test.js": 27,- "tests/shadow-depth-script.test.js": 1,+ "tests/shader-snippet-validator.test.js": 33,+ "tests/shadow-depth-script.test.js": 2,"tests/shadow-hardware-compare.test.js": 1,- "tests/shadow-light.test.js": 4,- "tests/shard-test-files.test.js": 5,- "tests/showcase-port-weight.test.js": 4643,- "tests/shrinkwrap.test.js": 52,- "tests/size-budget.test.js": 32,- "tests/size-growth.test.js": 10491,- "tests/skeleton-pose-asset.test.js": 681,- "tests/skeleton-pose-limits.test.js": 12,- "tests/skeleton-pose.test.js": 40,- "tests/skill-mesh-recipes.test.js": 1749,- "tests/skinning.test.js": 9,- "tests/sky-visibility.test.js": 653,- "tests/splat.test.js": 7,- "tests/spume.test.js": 4,- "tests/studio-floor.test.js": 14,- "tests/subsurface.test.js": 49,- "tests/sun-bounce.test.js": 2438,- "tests/surface-attachment.test.js": 24,- "tests/surface.test.js": 170,- "tests/terrain-holes.test.js": 1096,- "tests/terrain.test.js": 2512,- "tests/texture-set.test.js": 5,- "tests/texture-update.test.js": 4,- "tests/tool-cost-growth.test.js": 218,- "tests/tool-cost.test.js": 1,- "tests/tool-errors.test.js": 20,- "tests/tree-sky-levels.test.js": 782,- "tests/triangulate.test.js": 34,- "tests/update-part-vertices.test.js": 3,- "tests/update-parts-fast-path.test.js": 11,- "tests/vegetation-bark-wind.test.js": 958,- "tests/vegetation-impostors.test.js": 9050,- "tests/vegetation-pop.test.js": 857,- "tests/vegetation.test.js": 2519,- "tests/vehicle-steering-lights.test.js": 129,- "tests/vehicle.test.js": 87,+ "tests/shadow-light.test.js": 3,+ "tests/shard-test-files.test.js": 4,+ "tests/showcase-port-weight.test.js": 3180,+ "tests/shrinkwrap.test.js": 105,+ "tests/size-budget.test.js": 26,+ "tests/size-growth.test.js": 18902,+ "tests/skeleton-pose-asset.test.js": 452,+ "tests/skeleton-pose-limits.test.js": 11,+ "tests/skeleton-pose.test.js": 44,+ "tests/skill-examples.test.js": 6395,+ "tests/skill-mesh-recipes.test.js": 1592,+ "tests/skinning.test.js": 18,+ "tests/sky-visibility.test.js": 418,+ "tests/soft-body-bounce.test.js": 49788,+ "tests/soft-body-film.test.js": 153467,+ "tests/soft-body.test.js": 4731,+ "tests/specular-anti-aliasing.test.js": 8,+ "tests/splat.test.js": 18,+ "tests/spume.test.js": 9,+ "tests/streaming-crossing.test.js": 5636,+ "tests/streaming.test.js": 117,+ "tests/studio-floor.test.js": 45,+ "tests/subsurface.test.js": 97,+ "tests/sun-bounce.test.js": 6775,+ "tests/surface-attachment.test.js": 29,+ "tests/surface.test.js": 322,+ "tests/terrain-holes.test.js": 1245,+ "tests/terrain.test.js": 2187,+ "tests/texture-set.test.js": 4,+ "tests/texture-update.test.js": 7,+ "tests/tinted-shadows.test.js": 11,+ "tests/tool-cost-growth.test.js": 216,+ "tests/tool-cost.test.js": 2,+ "tests/tool-errors.test.js": 13,+ "tests/tool-input-examples.test.js": 471,+ "tests/tree-sky-levels.test.js": 1995,+ "tests/triage-bot-hardening.test.js": 13,+ "tests/triage-bot.test.js": 10,+ "tests/triangulate.test.js": 23,+ "tests/update-part-vertices.test.js": 4,+ "tests/update-parts-fast-path.test.js": 10,+ "tests/vegetation-bark-wind.test.js": 1708,+ "tests/vegetation-impostors.test.js": 11481,+ "tests/vegetation-pop.test.js": 589,+ "tests/vegetation.test.js": 3716,+ "tests/vehicle-steering-lights.test.js": 99,+ "tests/vehicle.test.js": 153,"tests/version.test.js": 1,- "tests/view-transform.test.js": 26,- "tests/volumetric.test.js": 6,- "tests/wall-e-preview-scene.test.js": 652,- "tests/water-reflection.test.js": 843,- "tests/water-shadows-render.test.js": 1,- "tests/water-shadows.test.js": 32,- "tests/world-addon-shader-imports.test.js": 638+ "tests/view-transform.test.js": 58,+ "tests/volumetric.test.js": 9,+ "tests/wall-e-preview-scene.test.js": 693,+ "tests/water-ocean-look.test.js": 75,+ "tests/water-reflection.test.js": 463,+ "tests/water-shadows-render.test.js": 2,+ "tests/water-shadows.test.js": 80,+ "tests/wireframe-pass.test.js": 62,+ "tests/world-addon-shader-imports.test.js": 930}diff --git a/tests/shard-test-files.test.js b/tests/shard-test-files.test.jsindex 6f0ca200..a8130d67 100644--- a/tests/shard-test-files.test.js+++ b/tests/shard-test-files.test.js@@ -1,6 +1,7 @@import assert from 'node:assert/strict';import test from 'node:test';-import { assignShards } from '../scripts/shard-test-files.mjs';+import { readFileSync } from 'node:fs';+import { assignShards, medianOf } from '../scripts/shard-test-files.mjs';const timings = { 'tests/a.test.js': 90, 'tests/b.test.js': 60, 'tests/c.test.js': 50, 'tests/d.test.js': 40, 'tests/e.test.js': 10 };const names = Object.keys(timings);@@ -20,3 +21,30 @@ test('a file without a timing lands in one shard and moves no other file', () =>for (const name of names) assert.equal(after.get(name), before.get(name));assert.ok(after.get('tests/new.test.js') >= 0 && after.get('tests/new.test.js') < 3);});++test('files without a timing go to the lightest shard by the median timing and never move a timed file', () => {+ const before = assignShards(names, timings, 2);+ const withNew = assignShards([...names, 'tests/new-a.test.js', 'tests/new-b.test.js'], timings, 2);+ for (const name of names) assert.equal(withNew.get(name), before.get(name));+ // Median timing is 50; shard 0 holds 130 and shard 1 holds 120, so the first new file goes to shard 1, the second to shard 0.+ assert.equal(withNew.get('tests/new-a.test.js'), 1);+ assert.equal(withNew.get('tests/new-b.test.js'), 0);+});++test('the hash option keeps untimed files on their name hash', () => {+ const first = assignShards([...names, 'tests/new.test.js'], timings, 3, { untimed: 'hash' });+ const second = assignShards([...names, 'tests/new.test.js', 'tests/other.test.js'], timings, 3, { untimed: 'hash' });+ assert.equal(first.get('tests/new.test.js'), second.get('tests/new.test.js'));+});++test('the median of repeated measurements is what the timings keep', () => {+ assert.equal(medianOf([300, 100, 200]), 200);+ assert.equal(medianOf([100, 200]), 150);+});++test('the workflow matrix and the shard count in its test command agree', () => {+ const workflow = readFileSync(new URL('../.github/workflows/test.yml', import.meta.url), 'utf8');+ const matrix = workflow.match(/shard: \[([\d, ]+)\]/)[1].split(',').map(Number);+ const count = Number(workflow.match(/shard-test-files\.mjs \$\{\{ matrix\.shard \}\} (\d+)/)[1]);+ assert.deepEqual(matrix, Array.from({ length: count }, (_, index) => index + 1));+});