MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / runScenario

Function runScenario

packages/server-e2e/scripts/run-scenarios.ts:60–95  ·  view source on GitHub ↗
(
  file: string,
  caseName: string,
  reportDir: string,
)

Source from the content-addressed store, hash-verified

58}
59
60async function runScenario(
61 file: string,
62 caseName: string,
63 reportDir: string,
64): Promise<{ exitCode: number }> {
65 const child = spawn(tsxBin, [join('scenarios', file)], {
66 cwd: packageRoot,
67 env: {
68 ...process.env,
69 KIMI_SERVER_E2E_CASE_NAME: caseName,
70 KIMI_SERVER_E2E_REPORT_DIR: reportDir,
71 },
72 stdio: ['ignore', 'pipe', 'pipe'],
73 });
74
75 captureLines(child.stdout, caseName, 'stdout', reportDir);
76 captureLines(child.stderr, caseName, 'stderr', reportDir);
77
78 return new Promise((resolveScenario) => {
79 child.on('error', (error) => {
80 recordReportEvent(
81 {
82 kind: 'log',
83 caseName,
84 label: 'spawn error',
85 value: { name: error.name, message: error.message },
86 },
87 { reportDir },
88 );
89 resolveScenario({ exitCode: 1 });
90 });
91 child.on('close', (code) => {
92 resolveScenario({ exitCode: code ?? 1 });
93 });
94 });
95}
96
97function captureLines(
98 stream: NodeJS.ReadableStream,

Callers 1

mainFunction · 0.85

Calls 4

captureLinesFunction · 0.85
recordReportEventFunction · 0.85
onMethod · 0.65
spawnFunction · 0.50

Tested by

no test coverage detected