Files
Strata/apps/host/scripts/test.mjs
T
Niko1221 b6f585164c tools/check: one command for the fast suites, with an explicit not-run for a missing tool
python tools/check runs the CPU CMake preset (configure, build, CTest), the Python suites (tests/, serve/, tools/test_*.py, and the torch-only tools folders when torch is installed), the host's typecheck, test and build, and the config snapshot. Each step has its own timeout, runs with temp files, build tree and logs in a scratch folder, and the table lists passed / failed / skipped / not run with the reason for every skip and every not-run step. Exit 1 on a failure or a timeout; --strict also fails on a step that could not run.

requirements-dev.txt pins pytest and textual apart from the runtime requirements. apps/host/scripts/test.mjs gives node --test a per-test timeout (STRATA_TEST_TIMEOUT_MS, default 10 minutes) and passes extra arguments (a reporter) through.
2026-11-07 13:24:50 +01:00

19 lines
1.6 KiB
JavaScript

#!/usr/bin/env node
/** Enumerate test files explicitly so npm test works without shell glob expansion. */
import {readdirSync} from 'node:fs';
import {spawn} from 'node:child_process';
import {resolve} from 'node:path';
const root=resolve(import.meta.dirname,'..');
const files=readdirSync(resolve(root,'tests')).filter(name=>name.endsWith('.test.mjs')).sort().map(name=>resolve(root,'tests',name));
/* Every test file runs against scratch copies of the per-user places the host writes to (the owner's real profile is never touched). */
import {mkdtempSync} from 'node:fs';
import {tmpdir} from 'node:os';
import {join} from 'node:path';
const scratch=mkdtempSync(join(tmpdir(),'strata-host-suite-profile-'));
const env={...process.env,STRATA_SETTINGS_FILE:join(scratch,'app-settings.json'),STRATA_COMPONENTS_DIR:join(scratch,'components'),LOCALAPPDATA:join(scratch,'Local'),APPDATA:join(scratch,'Roaming'),XDG_DATA_HOME:join(scratch,'xdg-data'),XDG_STATE_HOME:join(scratch,'xdg-state'),XDG_CONFIG_HOME:join(scratch,'xdg-config')};
/* A test that never finishes fails after STRATA_TEST_TIMEOUT_MS (default 10 minutes) instead of holding the whole run for ever; extra arguments (a reporter, --test-name-pattern) go to node --test. */
const timeout=Number(process.env.STRATA_TEST_TIMEOUT_MS)||600000;
const child=spawn(process.execPath,['--test',`--test-timeout=${timeout}`,...process.argv.slice(2),...files],{cwd:root,stdio:'inherit',env});
child.on('error',error=>{console.error(error.message);process.exitCode=1;});
child.on('exit',(code,signal)=>{process.exitCode=code??(signal?1:0);});