okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge main (87dfca0e7) into f-own-int: the 0.2.14 app branch, fixtures and CI fixes, the Qwen4-readiness tools, the shape-engine build scriptsffb3d9b31

main
2.1 KiB21 linesraw
1#!/usr/bin/env node
2/** Enumerate test files explicitly so npm test works without shell glob expansion. */
3import {readdirSync} from 'node:fs';
4import {spawn} from 'node:child_process';
5import {resolve} from 'node:path';
6const root=resolve(import.meta.dirname,'..');
7const files=readdirSync(resolve(root,'tests')).filter(name=>name.endsWith('.test.mjs')).sort().map(name=>resolve(root,'tests',name));
8/* Every test file runs against scratch copies of the per-user places the host writes to (the owner's real profile is never touched). */
9import {mkdtempSync} from 'node:fs';
10import {tmpdir} from 'node:os';
11import {join} from 'node:path';
12const scratch=mkdtempSync(join(tmpdir(),'strata-host-suite-profile-'));
13const 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')};
14/* Run from PowerShell 7 (GitHub's Windows runners), PSModulePath names PowerShell 7's module folders first and a Windows PowerShell 5.1 child
15   that a test starts cannot load Get-Acl / Get-FileHash from them: keep only the folders that are not PowerShell 7's. */
16if(process.platform==='win32'&&env.PSModulePath){const ps7=p=>{const l=p.toLowerCase().replace(/\//g,'\\');return l.includes('\\powershell\\')&&!l.includes('\\windowspowershell\\');};env.PSModulePath=env.PSModulePath.split(';').filter(p=>p&&!ps7(p)).join(';');}
17/* 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. */
18const timeout=Number(process.env.STRATA_TEST_TIMEOUT_MS)||600000;
19const child=spawn(process.execPath,['--test',`--test-timeout=${timeout}`,...process.argv.slice(2),...files],{cwd:root,stdio:'inherit',env});
20child.on('error',error=>{console.error(error.message);process.exitCode=1;});
21child.on('exit',(code,signal)=>{process.exitCode=code??(signal?1:0);});