Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

test: give Python-shelling suites explicit, nested timeouts (#5856)

Adam Eivy5e3a665c66ae
diff --git a/server/lib/README.md b/server/lib/README.md
index 8cf6f2b37a..f9797f2893 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -517,4 +517,4 @@ pm` default, `NPM_CONFIG_PREFIX`, nvm/Volta) installed `codex` successfully and
| `mirrorParity.js` | Source-comparison primitives for the `*.mirror.test.js` server↔client parity tests: `stripCommentsAndNormalize` (so per-side commentary may diverge but logic may not), `extractDeclaration(src, name)` (balanced `{}`/`()`/`[]` walk over `function` / `async function` / `const`), `compareDeclaration(serverSrc, clientSrc, name)`, and `compareRegexDeclaration(serverSrc, clientSrc, serverName, clientName?)` / `regexAlternationSource(declText)` (for a regex spelled as a `new RegExp([…].join('|'), 'i')` array on one side and an inline `/…/i` literal on the other — compares what it matches, not how it is typeset, and returns `null` rather than a partial read on any shape it can't decode). Use these instead of hand-rolling a brace-walker per mirror. Pure — no `vitest` import — so callers own the assertions. |
| `mockPathsDataRoot.js` | Shared Vitest helpers for `PATHS.data → temp dir` and no-peer record creation guards. |
| `settingsTestUtil.js` | `bindSettingsFile(dataRoot)` → `writeSettingsFile`/`mergeSettingsFile`: direct settings.json disk writes that also drop the `getSettings()` read cache (dynamic-import reset) so a stale cache can't survive a bypass-`save()` write. |
-| `testHelper.js` | Test helpers: `request()` (supertest-style HTTP) + `mockJsonResponse`/`mockTextResponse` (fetch `Response` mocks with `.text()`, `.json()`, and a `headers.get` content-type), `startLoopbackServer(app)`/`closeLoopbackServer(server)`/`waitForAbort(signal)` for tests that need a real socket (raw disconnects, SSE streaming) that `request()`'s run-to-completion fetch harness can't model, plus the source-scan pair `collectServerSources()` / `readServerSource(rel)` (and `SERVER_DIR`) used by the whole-tree guard suites — `spawnCwd.test.js` (#3193) and `cliChildEnv.test.js` (#3194). Those guards overlap deliberately, so they share one definition of "a source file"; change the ignore rules here and both move together. Cross-platform trio: `posixPath(v)` normalizes a RECEIVED path before comparing it to a POSIX-spelled literal (no-op on POSIX — never normalize the expectation, which would hide a genuinely wrong path), and `resolveTestPython()` returns an interpreter that actually runs, probing by execution because Windows ships a `python` Store-alias stub that exists but fails; `null` when there is none, for `describe.skipIf`; `pinPlatform(value)` pins `process.platform` and returns a restore that reinstates the ORIGINAL descriptor (deleting the pin when there was none) — it carries the one hazard every hand-rolled pin had to rediscover: never pin above an import that loads a native addon, which picks its prebuilt binary off the platform at load time (#4085). |
+| `testHelper.js` | Test helpers: `request()` (supertest-style HTTP) + `mockJsonResponse`/`mockTextResponse` (fetch `Response` mocks with `.text()`, `.json()`, and a `headers.get` content-type), `startLoopbackServer(app)`/`closeLoopbackServer(server)`/`waitForAbort(signal)` for tests that need a real socket (raw disconnects, SSE streaming) that `request()`'s run-to-completion fetch harness can't model, plus the source-scan pair `collectServerSources()` / `readServerSource(rel)` (and `SERVER_DIR`) used by the whole-tree guard suites — `spawnCwd.test.js` (#3193) and `cliChildEnv.test.js` (#3194). Those guards overlap deliberately, so they share one definition of "a source file"; change the ignore rules here and both move together. Cross-platform trio: `posixPath(v)` normalizes a RECEIVED path before comparing it to a POSIX-spelled literal (no-op on POSIX — never normalize the expectation, which would hide a genuinely wrong path), and `resolveTestPython()` returns an interpreter that actually runs, probing by execution because Windows ships a `python` Store-alias stub that exists but fails; `null` when there is none, for `describe.skipIf`; `pinPlatform(value)` pins `process.platform` and returns a restore that reinstates the ORIGINAL descriptor (deleting the pin when there was none) — it carries the one hazard every hand-rolled pin had to rediscover: never pin above an import that loads a native addon, which picks its prebuilt binary off the platform at load time (#4085). Python-shelling suites also take their two nested budgets from here: `PY_TEST_TIMEOUT_MS` (vitest per-test, passed as `it()`'s third argument — a real interpreter's wall time tracks machine load, not the assertion, so a ~4s case crosses the tight global 10s `testTimeout` on a contended full-suite worker) and the strictly smaller `PY_SUBPROCESS_TIMEOUT_MS` (every `execFileSync` spawn's own `timeout`, so a hung interpreter trips the spawn guard first and names the command instead of producing a bare vitest timeout; a subprocess allowance ABOVE the vitest budget is dead intent — vitest always wins). |
diff --git a/server/lib/testHelper.js b/server/lib/testHelper.js
index dff5865249..fb01e467d3 100644
--- a/server/lib/testHelper.js
+++ b/server/lib/testHelper.js
@@ -330,6 +330,31 @@ export function pinPlatform(value) {
};
}
+/**
+ * Budget for a vitest test that shells out to a real Python interpreter.
+ *
+ * Pass it as `it()`'s third argument (`it('…', () => { … }, PY_TEST_TIMEOUT_MS)`)
+ * on every case that spawns one. Such a test's wall time tracks how loaded the
+ * machine is, not anything the assertion controls: a case that runs in ~4s alone
+ * crosses the global 10s `testTimeout` on a contended worker during a full-suite
+ * run. Stating the budget where the cost actually is beats loosening the global
+ * default, which is deliberately tight so it still catches genuinely hung async
+ * work across the rest of the tree.
+ */
+export const PY_TEST_TIMEOUT_MS = 120_000;
+
+/**
+ * Budget for the Python subprocess itself — pass it as `execFileSync`'s
+ * `timeout` at every site that spawns an interpreter.
+ *
+ * Deliberately BELOW `PY_TEST_TIMEOUT_MS` so an actually-hung interpreter trips
+ * this guard first and fails with the spawn's own ETIMEDOUT (naming the command)
+ * instead of a bare vitest timeout that says only that the test ran long. A
+ * subprocess allowance above the vitest budget is dead intent — vitest always
+ * wins — so the two must stay nested in this order.
+ */
+export const PY_SUBPROCESS_TIMEOUT_MS = 90_000;
+
/**
* Resolve a Python interpreter that actually RUNS, or `null` when there is
* none — for suites that shell out to one of PortOS's `.py` scripts. Pair it
@@ -372,7 +397,7 @@ export function resolveTestPython() {
return candidates.find((candidate) => {
try {
- execFileSync(candidate, ['-c', 'pass'], { stdio: 'ignore' });
+ execFileSync(candidate, ['-c', 'pass'], { stdio: 'ignore', timeout: PY_SUBPROCESS_TIMEOUT_MS });
return true;
} catch {
return false;
diff --git a/server/services/imageTo3d/trellis2GenerateRunner.test.js b/server/services/imageTo3d/trellis2GenerateRunner.test.js
index bac793c3af..3de3497b70 100644
--- a/server/services/imageTo3d/trellis2GenerateRunner.test.js
+++ b/server/services/imageTo3d/trellis2GenerateRunner.test.js
@@ -5,7 +5,7 @@ import { join } from 'node:path';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { trellis2GenerateRunnerScript } from './trellis2.js';
import { trellis2FillHolesScript } from './trellis2MeshQuality.js';
-import { resolveTestPython } from '../../lib/testHelper.js';
+import { PY_SUBPROCESS_TIMEOUT_MS, PY_TEST_TIMEOUT_MS, resolveTestPython } from '../../lib/testHelper.js';
// Probe for an interpreter that actually runs rather than assuming `python3`:
// on Windows that name is absent and `python` is a Store alias stub that exists
@@ -81,7 +81,12 @@ describe.skipIf(!pyBin)('trellis2GenerateRunner', () => {
const run = (args, { env = {} } = {}) => execFileSync(
pyBin,
[trellis2GenerateRunnerScript(), ...args],
- { encoding: 'utf8', cwd: dir, env: { ...process.env, PYTHONPATH: join(dir, 'stub'), ...env } },
+ {
+ encoding: 'utf8',
+ cwd: dir,
+ env: { ...process.env, PYTHONPATH: join(dir, 'stub'), ...env },
+ timeout: PY_SUBPROCESS_TIMEOUT_MS,
+ },
);
const resultOf = (output) => JSON.parse(
@@ -110,7 +115,7 @@ describe.skipIf(!pyBin)('trellis2GenerateRunner', () => {
expect(run(['--', join(dir, 'generate.py'), '--texture-size', '4096']).trim())
.toBe('local-import-ok:4096');
- });
+ }, PY_TEST_TIMEOUT_MS);
it('sets PYTORCH_ENABLE_MPS_FALLBACK before anything can import torch', () => {
// Regression guard, and the bug it guards is not hypothetical: this adapter
@@ -124,7 +129,7 @@ describe.skipIf(!pyBin)('trellis2GenerateRunner', () => {
const r = resultOf(run(['--decimation-target', '1000000', '--', join(dir, 'generate.py'), 'a.png']));
expect(r.mps_fallback_at_o_voxel_import).toBe('1');
expect(r.mps_fallback_now).toBe('1');
- });
+ }, PY_TEST_TIMEOUT_MS);
it('lets an explicit caller env win over the preamble defaults', () => {
// setdefault, not assignment — otherwise the adapter would silently override a
@@ -135,7 +140,7 @@ describe.skipIf(!pyBin)('trellis2GenerateRunner', () => {
{ env: { PYTORCH_ENABLE_MPS_FALLBACK: '0' } },
));
expect(r.mps_fallback_at_o_voxel_import).toBe('0');
- });
+ }, PY_TEST_TIMEOUT_MS);
it('passes upstream arguments through untouched after the `--` separator', () => {
writeStubs();
@@ -144,7 +149,7 @@ describe.skipIf(!pyBin)('trellis2GenerateRunner', () => {
'--texture-size', '2048', '--seed', '7', '--steps', '24',
]));
expect(r).toMatchObject({ image: 'shoe.png', texture_size: 2048, seed: 7, steps: 24 });
- });
+ }, PY_TEST_TIMEOUT_MS);
it('leaves upstream’s 200K clamp alone when no target is requested', () => {
// Backward compatibility: an install that asks for nothing must render
@@ -153,7 +158,7 @@ describe.skipIf(!pyBin)('trellis2GenerateRunner', () => {
const r = resultOf(run(['--', join(dir, 'generate.py'), 'a.png']));
expect(r.to_glb[0].exported).toBe(200000);
expect(r.to_glb[0].decimation_target).toBe(200000);
- });
+ }, PY_TEST_TIMEOUT_MS);
it('retargets BOTH the simplify ratio and to_glb’s own decimation target', () => {
// The two halves are separately necessary. Patching only the ratio hands
@@ -165,7 +170,7 @@ describe.skipIf(!pyBin)('trellis2GenerateRunner', () => {
expect(r.simplify[0][1]).toBeCloseTo(1 - (1000000 / 22746188), 6);
expect(r.to_glb[0].decimation_target).toBe(1000000);
expect(r.to_glb[0].exported).toBe(1000000);
- });
+ }, PY_TEST_TIMEOUT_MS);
it('raises a retuned upstream clamp instead of silently letting it win', () => {
// An equality check against 200000 would no-op here and to_glb would re-decimate
@@ -176,7 +181,7 @@ describe.skipIf(!pyBin)('trellis2GenerateRunner', () => {
const out = run(['--decimation-target', '1000000', '--', join(dir, 'generate.py'), 'a.png']);
expect(out).toMatch(/not the expected 200,000/);
expect(resultOf(out).to_glb[0].decimation_target).toBe(1000000);
- });
+ }, PY_TEST_TIMEOUT_MS);
it('never lowers a target that is already above ours', () => {
// Only ever raises: a caller asking for MORE than we would must not be cut down.
@@ -185,7 +190,7 @@ describe.skipIf(!pyBin)('trellis2GenerateRunner', () => {
FAKE_GENERATE.replace('min(200000, len(faces))', '5000000'));
const r = resultOf(run(['--decimation-target', '1000000', '--', join(dir, 'generate.py'), 'a.png']));
expect(r.to_glb[0].decimation_target).toBe(5000000);
- });
+ }, PY_TEST_TIMEOUT_MS);
it('no-ops the simplify call when the mesh is already under target', () => {
// The fixture must be SMALLER than the target for this to exercise the
@@ -203,7 +208,7 @@ describe.skipIf(!pyBin)('trellis2GenerateRunner', () => {
// wrapper returned the input untouched rather than decimating.
expect(r.simplify).toEqual([]);
expect(r.to_glb[0].exported).toBe(150000);
- });
+ }, PY_TEST_TIMEOUT_MS);
it('still decimates when the mesh is over target', () => {
// The other side of that branch, so neither direction can regress silently.
@@ -214,7 +219,7 @@ describe.skipIf(!pyBin)('trellis2GenerateRunner', () => {
));
expect(r.simplify).toHaveLength(1);
expect(r.to_glb[0].exported).toBe(100000);
- });
+ }, PY_TEST_TIMEOUT_MS);
it('refuses to raise the target on a degraded install, and says why', () => {
// The KDTree fallback's xatlas unwrap hangs on large meshes, so raising the
@@ -223,7 +228,7 @@ describe.skipIf(!pyBin)('trellis2GenerateRunner', () => {
const out = run(['--decimation-target', '1000000', '--', join(dir, 'generate.py'), 'a.png']);
expect(out).toMatch(/Metal bake backend unavailable/);
expect(resultOf(out).to_glb[0].exported).toBe(200000);
- });
+ }, PY_TEST_TIMEOUT_MS);
it('forwards the exporter knobs upstream never passes', () => {
writeStubs();
@@ -239,14 +244,14 @@ describe.skipIf(!pyBin)('trellis2GenerateRunner', () => {
mesh_cluster_refine_iterations: 2,
mesh_cluster_smooth_strength: 0.5,
});
- });
+ }, PY_TEST_TIMEOUT_MS);
it('passes no exporter knobs at all when none are requested', () => {
writeStubs();
const r = resultOf(run(['--', join(dir, 'generate.py'), 'a.png']));
expect(r.to_glb[0]).not.toHaveProperty('remesh');
expect(r.to_glb[0]).not.toHaveProperty('alpha_mode');
- });
+ }, PY_TEST_TIMEOUT_MS);
it('captures the pre-decimation mesh for the normal bake without --decimation-target', () => {
// --normal-map used to silently no-op unless --decimation-target happened to be
@@ -257,7 +262,7 @@ describe.skipIf(!pyBin)('trellis2GenerateRunner', () => {
expect(out).not.toMatch(/no pre-decimation mesh was captured/);
// Bake runs against the stub's fake mesh and fails; that must not fail the render.
expect(resultOf(out).to_glb).toHaveLength(1);
- });
+ }, PY_TEST_TIMEOUT_MS);
it('never fails the render when the normal bake throws', () => {
// The mesh and its base colour are already correct by then — a normal map is an
@@ -268,7 +273,7 @@ describe.skipIf(!pyBin)('trellis2GenerateRunner', () => {
'--', join(dir, 'generate.py'), 'a.png']);
expect(out).toMatch(/normal map bake failed|normal map:/);
expect(resultOf(out).to_glb[0].exported).toBe(1000000);
- });
+ }, PY_TEST_TIMEOUT_MS);
it('fails loudly when --fill-holes is asked for but the gate is absent', () => {
// Must not degrade to "render without hole filling" — that is exactly the
@@ -281,12 +286,12 @@ describe.skipIf(!pyBin)('trellis2GenerateRunner', () => {
);
expect(() => run(['--fill-holes', '--', join(dir, 'generate.py'), 'a.png']))
.toThrow(/unconditional mps_compat stub|still carries/);
- });
+ }, PY_TEST_TIMEOUT_MS);
it('rejects an invocation with no upstream script', () => {
writeStubs();
expect(() => run(['--decimation-target', '1000'])).toThrow(/requires the upstream generate.py path/);
- });
+ }, PY_TEST_TIMEOUT_MS);
});
describe.skipIf(!pyBin)('trellis2RestoreFillHoles', () => {
@@ -308,7 +313,8 @@ describe.skipIf(!pyBin)('trellis2RestoreFillHoles', () => {
'',
].join('\n');
- const patch = () => execFileSync(pyBin, [trellis2FillHolesScript(), dir], { encoding: 'utf8' });
+ const patch = () => execFileSync(pyBin, [trellis2FillHolesScript(), dir],
+ { encoding: 'utf8', timeout: PY_SUBPROCESS_TIMEOUT_MS });
// Python's `write_text` translates \n to the platform line ending, so the patched
// file is CRLF on Windows while Node's readFileSync returns the raw bytes. A
@@ -333,7 +339,7 @@ describe.skipIf(!pyBin)('trellis2RestoreFillHoles', () => {
// Default-off is the safety property: absent the env var, behaviour is
// identical to the hard stub.
expect(out).toMatch(/if not os\.environ\.get\('PORTOS_TRELLIS2_FILL_HOLES'\):\n\s+return/);
- });
+ }, PY_TEST_TIMEOUT_MS);
it('leaves remove_faces and simplify stubbed', () => {
// Deliberate: neither has the independent at-scale evidence fill_holes has,
@@ -343,7 +349,7 @@ describe.skipIf(!pyBin)('trellis2RestoreFillHoles', () => {
const out = readNormalized();
expect(out).toMatch(/def remove_faces\(self, face_mask\):\n\s+return\n/);
expect(out).toMatch(/def simplify\(self, target=1000000\):\n\s+return\n/);
- });
+ }, PY_TEST_TIMEOUT_MS);
it('finds the stub when the interpreter default codec is not UTF-8', () => {
// The Windows-only failure this pins: UPSTREAM_STUB contains an en dash, and a
@@ -355,10 +361,11 @@ describe.skipIf(!pyBin)('trellis2RestoreFillHoles', () => {
const out = execFileSync(pyBin, [trellis2FillHolesScript(), dir], {
encoding: 'utf8',
env: { ...process.env, PYTHONUTF8: '0', LC_ALL: 'C', LANG: 'C' },
+ timeout: PY_SUBPROCESS_TIMEOUT_MS,
});
expect(out).toMatch(/now gated/);
expect(readNormalized()).toContain('PORTOS_TRELLIS2_FILL_HOLES');
- });
+ }, PY_TEST_TIMEOUT_MS);
it('finds and replaces the stub in a CRLF file', () => {
// The Windows condition, reproduced on any platform. The patcher matches
@@ -369,7 +376,7 @@ describe.skipIf(!pyBin)('trellis2RestoreFillHoles', () => {
patch();
expect(readNormalized()).toContain('PORTOS_TRELLIS2_FILL_HOLES');
expect(readNormalized()).not.toContain('return # Skip');
- });
+ }, PY_TEST_TIMEOUT_MS);
it('is idempotent, so it is safe as a repeated repair step', () => {
writeFileSync(basePath(), STUBBED);
@@ -377,15 +384,15 @@ describe.skipIf(!pyBin)('trellis2RestoreFillHoles', () => {
const once = readNormalized();
expect(patch()).toMatch(/already present/);
expect(readNormalized()).toBe(once);
- });
+ }, PY_TEST_TIMEOUT_MS);
it('fails loudly rather than no-op’ing when upstream’s stub text changes', () => {
// A silent no-op would leave --fill-holes appearing to work and doing nothing.
writeFileSync(basePath(), 'class Mesh:\n def fill_holes(self):\n pass\n');
expect(() => patch()).toThrow(/expected mps_compat's fill_holes stub/);
- });
+ }, PY_TEST_TIMEOUT_MS);
it('fails when the target file is missing entirely', () => {
expect(() => patch()).toThrow(/not found/);
- });
+ }, PY_TEST_TIMEOUT_MS);
});
diff --git a/server/services/imageTo3d/trellis2NormalBake.test.js b/server/services/imageTo3d/trellis2NormalBake.test.js
index 036c99813e..24556de58d 100644
--- a/server/services/imageTo3d/trellis2NormalBake.test.js
+++ b/server/services/imageTo3d/trellis2NormalBake.test.js
@@ -4,7 +4,7 @@ import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { describe, expect, it } from 'vitest';
-import { resolveTestPython } from '../../lib/testHelper.js';
+import { PY_SUBPROCESS_TIMEOUT_MS, PY_TEST_TIMEOUT_MS, resolveTestPython } from '../../lib/testHelper.js';
import { trellis2VenvPython } from './trellis2.js';
// The bake's helpers are numpy-based, and the interpreter `resolveTestPython` finds is
@@ -18,7 +18,7 @@ function resolveNumpyPython() {
for (const bin of candidates) {
if (bin.includes('/') && !existsSync(bin)) continue;
try {
- execFileSync(bin, ['-c', 'import numpy'], { stdio: 'ignore' });
+ execFileSync(bin, ['-c', 'import numpy'], { stdio: 'ignore', timeout: PY_SUBPROCESS_TIMEOUT_MS });
return bin;
} catch {
// Not this one — keep looking.
@@ -38,7 +38,7 @@ function hasMetalStack(bin) {
execFileSync(bin, ['-c',
'import torch, trimesh, o_voxel.postprocess as pp, mtldiffrast.torch;'
+ ' assert getattr(pp, "_HAS_DR", False) and getattr(pp, "_BVH", None)'],
- { stdio: 'ignore' });
+ { stdio: 'ignore', timeout: PY_SUBPROCESS_TIMEOUT_MS });
return true;
} catch {
return false;
@@ -59,7 +59,8 @@ describe.skipIf(!pyBin)('trellis2NormalBake helpers', () => {
'import trellis2NormalBake as nb',
body,
].join('\n'));
- return JSON.parse(execFileSync(pyBin, [script], { encoding: 'utf8' }));
+ return JSON.parse(execFileSync(pyBin, [script],
+ { encoding: 'utf8', timeout: PY_SUBPROCESS_TIMEOUT_MS }));
} finally {
rmSync(dir, { recursive: true, force: true });
}
@@ -76,7 +77,7 @@ pts = np.array([[1, 2, 3], [0, 1, 0], [-1, -2, -3]], dtype=np.float32)
print(json.dumps(nb.decoder_to_export_space(pts).tolist()))
`);
expect(r).toEqual([[1, 3, -2], [0, 0, -1], [-1, -3, 2]]);
- });
+ }, PY_TEST_TIMEOUT_MS);
it('does not mutate its input', () => {
// The source array is reused by the caller for the BVH; an in-place swap would
@@ -89,7 +90,7 @@ print(json.dumps({"input": pts.tolist(), "output": out.tolist()}))
`);
expect(r.input).toEqual([[1, 2, 3]]);
expect(r.output).toEqual([[1, 3, -2]]);
- });
+ }, PY_TEST_TIMEOUT_MS);
it('is length-preserving, as a rotation must be', () => {
const r = run(`
@@ -100,7 +101,7 @@ b = np.linalg.norm(nb.decoder_to_export_space(pts), axis=-1)
print(json.dumps({"max_delta": float(np.abs(a - b).max())}))
`);
expect(r.max_delta).toBeLessThan(1e-5);
- });
+ }, PY_TEST_TIMEOUT_MS);
});
describe('compute_vertex_normals', () => {
@@ -113,7 +114,7 @@ print(json.dumps({"normals": n.tolist(), "lengths": np.linalg.norm(n, axis=-1).t
`);
for (const n of r.normals) expect(n).toEqual([0, 0, 1]);
for (const l of r.lengths) expect(l).toBeCloseTo(1, 5);
- });
+ }, PY_TEST_TIMEOUT_MS);
it('weights by area, so slivers cannot outvote a large face', () => {
// The decoder emits wildly uneven triangle areas; uniform averaging lets a
@@ -124,7 +125,7 @@ f = np.array([[0,1,2],[0,1,3]], dtype=np.int32)
print(json.dumps({"z": float(abs(nb.compute_vertex_normals(v, f)[0][2]))}))
`);
expect(r.z).toBeGreaterThan(0.99);
- });
+ }, PY_TEST_TIMEOUT_MS);
it('yields a finite zero vector for an unreferenced vertex', () => {
// np.add.at leaves it at zero; normalizing must not divide by zero and produce
@@ -137,7 +138,7 @@ print(json.dumps({"finite": bool(np.all(np.isfinite(n))), "orphan": n[3].tolist(
`);
expect(r.finite).toBe(true);
expect(r.orphan).toEqual([0, 0, 0]);
- });
+ }, PY_TEST_TIMEOUT_MS);
});
describe('compute_uv_tangents', () => {
@@ -153,7 +154,7 @@ print(json.dumps({"first": t[0].tolist(), "w": w.tolist()}))
expect(r.first[0]).toBeCloseTo(1, 4);
expect(Math.abs(r.first[1])).toBeLessThan(1e-4);
expect(r.w.every((x) => x === 1)).toBe(true);
- });
+ }, PY_TEST_TIMEOUT_MS);
// The bug this pins was a real defect: `b = cross(n, t)` with no handedness term.
// A UV unwrapper may mirror individual charts (cumesh's does), and on a mirrored
@@ -190,7 +191,7 @@ print(json.dumps({
expect(r.mirrored.w).toBe(-1);
expect(r.mirrored.naive).toBeCloseTo(-1, 3);
expect(r.mirrored.corrected).toBeCloseTo(1, 3);
- });
+ }, PY_TEST_TIMEOUT_MS);
it('breaks a seam-vertex handedness tie deterministically instead of emitting 0', () => {
// A vertex straddling two oppositely-wound charts sums to exactly 0. Returning 0
@@ -204,7 +205,7 @@ print(json.dumps({"w": w.tolist(), "any_zero": bool((w == 0).any())}))
`);
expect(r.any_zero).toBe(false);
for (const x of r.w) expect(Math.abs(x)).toBe(1);
- });
+ }, PY_TEST_TIMEOUT_MS);
it('survives a degenerate UV triangle without NaN', () => {
// Zero-area-in-texture-space faces have no defined tangent. Left unguarded the
@@ -217,7 +218,7 @@ t, w = nb.compute_uv_tangents(v, f, uv)
print(json.dumps({"finite": bool(np.all(np.isfinite(t))) and bool(np.all(np.isfinite(w)))}))
`);
expect(r.finite).toBe(true);
- });
+ }, PY_TEST_TIMEOUT_MS);
});
describe('_extract_mesh', () => {
@@ -234,7 +235,7 @@ except ValueError as e:
print(json.dumps({"raised": str(e)}))
`);
expect(r.raised).toMatch(/requires the exported mesh to carry UVs/);
- });
+ }, PY_TEST_TIMEOUT_MS);
it('refuses an ambiguous multi-mesh scene', () => {
const r = run(`
@@ -246,7 +247,7 @@ except ValueError as e:
print(json.dumps({"raised": str(e)}))
`);
expect(r.raised).toMatch(/expects exactly one mesh, got 2/);
- });
+ }, PY_TEST_TIMEOUT_MS);
});
});
@@ -266,7 +267,8 @@ describe.skipIf(!hasStack)('bake_normal_map attaches a usable normal map', () =>
'import trellis2NormalBake as nb',
body,
].join('\n'));
- return JSON.parse(execFileSync(pyBin, [script], { encoding: 'utf8', timeout: 240000 }));
+ return JSON.parse(execFileSync(pyBin, [script],
+ { encoding: 'utf8', timeout: PY_SUBPROCESS_TIMEOUT_MS }));
} finally {
rmSync(dir, { recursive: true, force: true });
}
@@ -334,7 +336,7 @@ print(json.dumps({
expect(r.mean_z).toBeGreaterThan(0.5);
// And it must actually carry the dome's curvature rather than being flat.
expect(r.tilt_fraction).toBeGreaterThan(0.2);
- });
+ }, PY_TEST_TIMEOUT_MS);
it('exports that texture through a real GLB round-trip', () => {
// trimesh silently dropping normalTexture on export would make the whole feature
@@ -349,5 +351,5 @@ print(json.dumps({"survived": nt is not None, "size": list(nt.size) if nt else N
`);
expect(r.survived).toBe(true);
expect(r.size).toEqual([64, 64]);
- });
+ }, PY_TEST_TIMEOUT_MS);
});