@@ -254,7 +254,7 @@ export function spawnText(command, args, options) {
|
254 | 254 | env: options.env, |
255 | 255 | stdio: ["ignore", "pipe", "pipe"], |
256 | 256 | }); |
257 | | -let output = ""; |
| 257 | +let outputBytes = 0; |
258 | 258 | let outputTail = Buffer.alloc(0); |
259 | 259 | let stderrTail = Buffer.alloc(0); |
260 | 260 | let streamedLogBytes = 0; |
@@ -383,7 +383,7 @@ export function spawnText(command, args, options) {
|
383 | 383 | appendTail(buffer); |
384 | 384 | return; |
385 | 385 | } |
386 | | -output += message; |
| 386 | +appendTail(buffer); |
387 | 387 | } |
388 | 388 | const appendOutput = (chunk, streamName) => { |
389 | 389 | if (logFd !== null) { |
@@ -417,10 +417,15 @@ export function spawnText(command, args, options) {
|
417 | 417 | return; |
418 | 418 | } |
419 | 419 | |
420 | | -output += chunk.toString("utf8"); |
421 | | -if (Buffer.byteLength(output) > maxBuffer) { |
| 420 | +const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk), "utf8"); |
| 421 | +outputBytes += buffer.byteLength; |
| 422 | +appendTail(buffer); |
| 423 | +if (streamName === "stderr") { |
| 424 | +appendTail(buffer, "stderr"); |
| 425 | +} |
| 426 | +if (outputBytes > maxBuffer) { |
422 | 427 | outputExceeded = true; |
423 | | -output += `\n[test-group-report] output exceeded ${String(maxBuffer)} bytes\n`; |
| 428 | +appendDiagnostic(`\n[test-group-report] output exceeded ${String(maxBuffer)} bytes\n`); |
424 | 429 | signalChild("SIGTERM"); |
425 | 430 | scheduleKill( |
426 | 431 | "[test-group-report] command did not exit after output limit; sending SIGKILL\n", |
@@ -444,7 +449,7 @@ export function spawnText(command, args, options) {
|
444 | 449 | const result = { |
445 | 450 | status: outputExceeded || timedOut ? 1 : (code ?? 1), |
446 | 451 | signal, |
447 | | -output: logFd === null ? output : streamedOutput(), |
| 452 | +output: streamedOutput(), |
448 | 453 | timedOut, |
449 | 454 | }; |
450 | 455 | if (waitingForKillGrace && processGroupIsAlive()) { |
|