mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-06-15 18:34:57 +03:00
65ea06ab6e
Внутренности move в cli/:
- util.mjs — out/die/json/readBody/readStdin/elapsed/elapsed2/slugify/formatDuration/xmlEscape/interpolate/printSteps/usage
- session.mjs — SESSION_FILE, loadSession, cleanup
- exec-context.mjs — buildContext, buildScopedContext, executeScript
- server.mjs — handleRequest (HTTP сервер в процессе start)
- commands/{start,run,exec,shot,stop,status,test}.mjs — по одной команде на файл
- test-runner/assertions.mjs — createAssertions (ctx.assert API)
- test-runner/severity.mjs — SEVERITY_RANK/LEVELS, buildSeverityIndex, resolveSeverity
- test-runner/reporters.mjs — writeAllure, allureStep, syncAllureExtras, buildJUnit
- test-runner/discover.mjs — discoverTests, resetState
run.mjs остался публичным entry-point с CLI-парсингом и dispatcher'ом.
Регресс tests/web-test/ зелёный (19/19, 9m 28s).
33 lines
1.2 KiB
JavaScript
33 lines
1.2 KiB
JavaScript
// web-test cli/test-runner/discover v1.0 — test file discovery + state reset between tests
|
|
// Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
|
import { existsSync, readdirSync } from 'fs';
|
|
import { resolve } from 'path';
|
|
|
|
export function discoverTests(testPath) {
|
|
if (testPath.endsWith('.test.mjs')) return existsSync(testPath) ? [testPath] : [];
|
|
const files = [];
|
|
function walk(dir) {
|
|
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
if (entry.name.startsWith('_') || entry.name.startsWith('.')) continue;
|
|
const full = resolve(dir, entry.name);
|
|
if (entry.isDirectory()) walk(full);
|
|
else if (entry.name.endsWith('.test.mjs')) files.push(full);
|
|
}
|
|
}
|
|
walk(testPath);
|
|
return files.sort();
|
|
}
|
|
|
|
export async function resetState(ctx) {
|
|
try { if (typeof ctx.dismissPendingErrors === 'function') await ctx.dismissPendingErrors(); } catch {}
|
|
for (let i = 0; i < 10; i++) {
|
|
try {
|
|
const state = await ctx.getFormState();
|
|
// form === null means no form open (desktop). form === 0 is a real background form
|
|
// 1C exposes in some states — must still close it to fully reset.
|
|
if (state.form == null) break;
|
|
await ctx.closeForm({ save: false });
|
|
} catch { break; }
|
|
}
|
|
}
|