UNPKG

@redocly/respect-core

Version:
50 lines 2.1 kB
import { runTestFile } from './modules/flow-runner/index.js'; import { displayErrors, displaySummary, calculateTotals } from './modules/logger-output/index.js'; import { Timer } from './modules/timeout-timer/timer.js'; export async function run(options) { const executedStepsCount = { value: 0 }; const { files, executionTimeout, collectSpecData } = options; // Don't create a timer if executionTimeout is not set if (executionTimeout) { Timer.reset(); Timer.getInstance(executionTimeout); } const testsRunProblemsStatus = []; const runAllFilesResult = []; for (const path of files) { const result = await runFile({ options: { ...options, file: path }, startedAt: performance.now(), collectSpecData, executedStepsCount, }); testsRunProblemsStatus.push(result.hasProblems); runAllFilesResult.push(result); } return runAllFilesResult; } async function runFile({ options, startedAt, executedStepsCount, collectSpecData, }) { const result = await runTestFile({ options, collectSpecData, executedStepsCount }); const { executedWorkflows, ctx } = result; const totals = calculateTotals(executedWorkflows); const hasProblems = totals.workflows.failed > 0; const hasWarnings = totals.workflows.warnings > 0; const hasGlobalTimeoutError = executedWorkflows.some((workflow) => workflow.globalTimeoutError); if (totals.steps.failed > 0 || totals.steps.warnings > 0 || totals.steps.skipped > 0) { displayErrors(executedWorkflows, options.logger); } displaySummary({ startedAt, workflows: executedWorkflows, options }); return { hasProblems, hasWarnings, file: options.file, executedWorkflows, options, ctx, totalTimeMs: performance.now() - startedAt, totalRequests: totals.totalRequests, globalTimeoutError: hasGlobalTimeoutError, ...(ctx.noSecretsMasking && { secretValues: Array.from(ctx.secretsSet) || [] }), }; } //# sourceMappingURL=run.js.map