Commit fe26b4a
fix(test): create-batch --run without --wait exits 0 on a fully successful dispatch
The no-wait fan-out returns each result with the trigger response's status,
which is `queued` by design (non-terminal — the field is documented as
"Terminal status if --wait; queued if no --wait"). But the exit-code logic
only recognized terminal statuses:
const allPassed = batchRunResults.every(r => r.status === 'passed');
Every no-wait result is `queued`, so `allPassed` was always false and the
command fell through to exit 1 with a misleading "N of N run(s) did not
pass" — even when every trigger was dispatched successfully. This broke the
documented exit-code contract (the DOCUMENTATION.md create-batch example
uses `--run --max-concurrency 4 --output json`, no `--wait`), failed CI on
fully successful dispatches, and was internally inconsistent with single
`test run <id>` without `--wait`, which exits 0 on a successful `queued`
dispatch.
In the no-wait case "success" means every trigger dispatched without error
(statuses are non-terminal by definition). The exit-code block now branches
on `opts.wait`:
const failing = opts.wait
? batchRunResults.filter(r => r.status !== 'passed')
: batchRunResults.filter(r => r.error !== undefined);
if (failing.length === 0) return; // exit 0
Trigger errors in no-wait mode keep today's aggregation (uniform specific
code when shared, else exit 1), and the "did not pass" message becomes
"N of N trigger(s) failed" when `--wait` is absent. The stderr text summary
is likewise corrected for no-wait mode — it now reports "N/N triggered"
instead of misreading a successful dispatch as "0/N passed".
Adds three specs in test.create-batch-run.spec.ts: all-queued (json) →
resolves without error and never polls; all-queued (text) → "N/N triggered"
summary, no "passed"/"did not pass" wording; partial trigger failure → still
exits non-zero with the full results envelope. The two success specs fail
against the pre-fix exit-code block and pass with it. Existing no-wait specs
only exercised error scenarios and never asserted the success exit code,
which is how this slipped through.
Fixes #161
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent e53257d commit fe26b4a
3 files changed
Lines changed: 250 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
274 | | - | |
| 274 | + | |
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
333 | 333 | | |
334 | 334 | | |
335 | 335 | | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
336 | 555 | | |
337 | 556 | | |
338 | 557 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2888 | 2888 | | |
2889 | 2889 | | |
2890 | 2890 | | |
| 2891 | + | |
| 2892 | + | |
| 2893 | + | |
| 2894 | + | |
| 2895 | + | |
| 2896 | + | |
| 2897 | + | |
| 2898 | + | |
| 2899 | + | |
| 2900 | + | |
| 2901 | + | |
2891 | 2902 | | |
2892 | 2903 | | |
2893 | 2904 | | |
| |||
2906 | 2917 | | |
2907 | 2918 | | |
2908 | 2919 | | |
2909 | | - | |
2910 | | - | |
2911 | | - | |
| 2920 | + | |
| 2921 | + | |
| 2922 | + | |
| 2923 | + | |
| 2924 | + | |
| 2925 | + | |
| 2926 | + | |
| 2927 | + | |
| 2928 | + | |
2912 | 2929 | | |
2913 | | - | |
2914 | | - | |
2915 | | - | |
2916 | | - | |
2917 | | - | |
| 2930 | + | |
| 2931 | + | |
2918 | 2932 | | |
2919 | | - | |
| 2933 | + | |
2920 | 2934 | | |
2921 | 2935 | | |
2922 | | - | |
| 2936 | + | |
2923 | 2937 | | |
2924 | 2938 | | |
2925 | 2939 | | |
2926 | 2940 | | |
2927 | 2941 | | |
2928 | 2942 | | |
2929 | 2943 | | |
2930 | | - | |
2931 | | - | |
| 2944 | + | |
| 2945 | + | |
2932 | 2946 | | |
2933 | 2947 | | |
2934 | 2948 | | |
| |||
2937 | 2951 | | |
2938 | 2952 | | |
2939 | 2953 | | |
2940 | | - | |
| 2954 | + | |
2941 | 2955 | | |
2942 | 2956 | | |
2943 | 2957 | | |
2944 | 2958 | | |
2945 | 2959 | | |
2946 | 2960 | | |
2947 | | - | |
| 2961 | + | |
| 2962 | + | |
| 2963 | + | |
2948 | 2964 | | |
2949 | 2965 | | |
2950 | 2966 | | |
| |||
0 commit comments