@testsprite/testsprite-cli 0.17.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +5 -4
  2. package/dist/commands/auth.js +2 -2
  3. package/dist/commands/conversation.js +52 -13
  4. package/dist/commands/project-env.js +48 -8
  5. package/dist/commands/project.d.ts +4 -0
  6. package/dist/commands/project.js +19 -2
  7. package/dist/commands/result.js +2 -1
  8. package/dist/commands/test.d.ts +9 -31
  9. package/dist/commands/test.js +73 -159
  10. package/dist/commands/testlist.d.ts +4 -2
  11. package/dist/commands/testlist.js +32 -4
  12. package/dist/commands/tunnel.d.ts +3 -3
  13. package/dist/commands/tunnel.js +3 -4
  14. package/dist/index.js +9 -6
  15. package/dist/lib/client-factory.d.ts +2 -2
  16. package/dist/lib/client-factory.js +3 -4
  17. package/dist/lib/conversation/api.d.ts +4 -0
  18. package/dist/lib/conversation/api.js +1 -0
  19. package/dist/lib/conversation/context.d.ts +10 -0
  20. package/dist/lib/conversation/context.js +17 -5
  21. package/dist/lib/conversation/environment.d.ts +3 -2
  22. package/dist/lib/conversation/environment.js +5 -17
  23. package/dist/lib/conversation/render.js +3 -0
  24. package/dist/lib/conversation/types.d.ts +2 -0
  25. package/dist/lib/download.d.ts +30 -1
  26. package/dist/lib/download.js +205 -71
  27. package/dist/lib/environment-tunnel.d.ts +3 -3
  28. package/dist/lib/environment-tunnel.js +9 -50
  29. package/dist/lib/first-suite-hint.d.ts +9 -13
  30. package/dist/lib/first-suite-hint.js +29 -35
  31. package/dist/lib/http.d.ts +1 -1
  32. package/dist/lib/http.js +5 -5
  33. package/dist/lib/local-target.d.ts +5 -4
  34. package/dist/lib/local-target.js +11 -10
  35. package/dist/lib/output.d.ts +1 -1
  36. package/dist/lib/output.js +2 -2
  37. package/dist/lib/presigned-url.js +2 -2
  38. package/dist/lib/removed-commands.js +17 -1
  39. package/dist/lib/result/evidence.d.ts +2 -0
  40. package/dist/lib/result/evidence.js +2 -0
  41. package/dist/lib/run-output.d.ts +3 -3
  42. package/dist/lib/target-url.d.ts +7 -7
  43. package/dist/lib/target-url.js +8 -8
  44. package/dist/lib/telemetry.d.ts +4 -4
  45. package/dist/lib/telemetry.js +1 -1
  46. package/dist/lib/transport-failure.js +2 -2
  47. package/dist/lib/tunnel-session.d.ts +1 -1
  48. package/dist/lib/tunnel-session.js +2 -2
  49. package/dist/version.d.ts +1 -1
  50. package/dist/version.js +1 -1
  51. package/package.json +1 -1
  52. package/skills/testsprite-ci.skill.md +4 -5
  53. package/skills/testsprite-onboard.skill.md +14 -12
  54. package/skills/testsprite-verify.codex.md +12 -14
  55. package/skills/testsprite-verify.skill.md +19 -21
@@ -22,7 +22,6 @@ import { resolveCiRunFailure } from '../lib/ci-run.js';
22
22
  import { isProxyAgentActive } from '../lib/proxy.js';
23
23
  import { assertNotLocal } from '../lib/target-url.js';
24
24
  import { assertTargetUrlReachable } from '../lib/target-url-preflight.js';
25
- import { DEFAULT_LOCAL_HOST, LOOPBACK_HOSTS, normalizeLocalHost, parseLocalPort, } from '../lib/local-target.js';
26
25
  import { TunnelLostError } from '../lib/tunnel-session.js';
27
26
  import { renderTextTable, resolveTextColumns } from '../lib/text-table.js';
28
27
  import { markRunWaitInterrupt } from '../lib/render-error.js';
@@ -48,10 +47,6 @@ function tunnelInterruptOptOutConsequence(detach, refs) {
48
47
  function tunnelRerunCommand(detach) {
49
48
  return (`testsprite run ${terminalSafeLine(detach.testId)}` +
50
49
  (detach.environment ? ` --env ${quoteEnvironmentName(detach.environment)}` : '') +
51
- (detach.automatic
52
- ? ''
53
- : ` --local ${detach.localPort}` +
54
- (detach.localHost !== DEFAULT_LOCAL_HOST ? ` --local-host ${detach.localHost}` : '')) +
55
50
  (detach.reason === 'timeout' ? ' --timeout 1800' : ''));
56
51
  }
57
52
  /**
@@ -867,10 +862,13 @@ async function finishZeroDispatchBatch(params) {
867
862
  return;
868
863
  }
869
864
  // The pointer rides inside the message so it prints AFTER "Error:", in
870
- // reading order — a CLIError has no nextAction slot of its own.
871
- throw new CLIError(`No tests were dispatched — ${reason}. A CI gate that passes on zero tests is unsafe; ` +
872
- `pass --allow-empty to exit 0 intentionally.` +
873
- (nextStep !== undefined ? ` ${nextStep}` : ''), 5);
865
+ // reading order — a CLIError has no nextAction slot of its own. A project
866
+ // with no tests leads with where a first set comes from; the gate is a
867
+ // footnote there.
868
+ throw new CLIError(nextStep !== undefined
869
+ ? `${nextStep}. (Nothing ran; --allow-empty exits 0 on an empty run.)`
870
+ : `No tests were dispatched — ${reason}. A CI gate that passes on zero tests is unsafe; ` +
871
+ `pass --allow-empty to exit 0 intentionally.`, 5);
874
872
  }
875
873
  function refuseCiLoopbackTarget(deps, validationError) {
876
874
  recordTelemetryExtras({ ciRunOutcome: 'refused_loopback' });
@@ -891,23 +889,20 @@ export async function runTestRunAll(opts, deps = {}) {
891
889
  if (opts.wait || opts.report === undefined)
892
890
  assertJUnitReportOptions({ ...opts, batchPath: true });
893
891
  const environment = normalizeEnvironmentName(opts.environment);
892
+ // Only `ci run` passes a target: a preview the cloud runner must reach. A
893
+ // loopback one is refused below, with the rest of its outputs.
894
894
  try {
895
895
  if (opts.targetUrl !== undefined && !parseLoopbackTargetUrl(opts.targetUrl))
896
896
  assertNotLocal(opts.targetUrl, {
897
897
  field: 'target-url',
898
- helpCommand: 'testsprite run',
898
+ helpCommand: 'testsprite ci run',
899
899
  hintContext: 'runtime',
900
900
  });
901
901
  }
902
902
  catch (err) {
903
- if (opts.ci)
904
- refuseCiLoopbackTarget(deps, err);
905
- throw err;
903
+ refuseCiLoopbackTarget(deps, err);
906
904
  }
907
- if (!opts.wait &&
908
- opts.localPort === undefined &&
909
- !opts.targetUrl &&
910
- (opts.ghOutput || opts.summaryFile))
905
+ if (!opts.wait && !opts.targetUrl && (opts.ghOutput || opts.summaryFile))
911
906
  throw localValidationError('wait', '--gh-output and --summary-file require --wait');
912
907
  const stderr = terminalSafeWriter(deps.stderr);
913
908
  const shutdown = shutdownOf(deps);
@@ -915,10 +910,7 @@ export async function runTestRunAll(opts, deps = {}) {
915
910
  opts.maxConcurrency < 1 ||
916
911
  opts.maxConcurrency > 100)
917
912
  throw localValidationError('max-concurrency', 'must be an integer between 1 and 100');
918
- if (opts.localPort !== undefined && opts.targetUrl !== undefined)
919
- throw localValidationError('local', '--local and --target-url are mutually exclusive');
920
- if (opts.ci &&
921
- (opts.localPort !== undefined || (opts.targetUrl && parseLoopbackTargetUrl(opts.targetUrl))))
913
+ if (opts.targetUrl && parseLoopbackTargetUrl(opts.targetUrl))
922
914
  refuseCiLoopbackTarget(deps);
923
915
  const client = makeClient({ ...opts, requestTimeoutMs: resolveWaitRequestTimeoutMs(opts) }, opts.dryRun ? { ...deps, fetchImpl: undefined } : deps);
924
916
  let discoveryClient = client;
@@ -944,8 +936,6 @@ export async function runTestRunAll(opts, deps = {}) {
944
936
  opts.knownTests?.get(id)?.projectId ?? opts.projectId ?? '<project-id>',
945
937
  ]))
946
938
  : await resolveTestProjects(client, ids, knownTests);
947
- if (opts.localPort !== undefined && ids.some(id => knownTests.get(id)?.type === 'backend'))
948
- throw localValidationError('local', `explicit backend tests do not use a tunnel; run without --local: testsprite run ${ids.join(' ')}`);
949
939
  for (const id of ids) {
950
940
  const projectId = projectIdByTestId.get(id);
951
941
  if (!projectId)
@@ -959,8 +949,8 @@ export async function runTestRunAll(opts, deps = {}) {
959
949
  const projectId = resolveProjectId(opts.projectId, deps);
960
950
  requireProjectId(projectId);
961
951
  opts = { ...opts, projectId };
962
- if (!opts.dryRun && (opts.nameFilter || opts.localPort !== undefined)) {
963
- let tests = await resolveAllProjectTests({
952
+ if (!opts.dryRun && opts.nameFilter) {
953
+ const tests = await resolveAllProjectTests({
964
954
  client,
965
955
  projectId,
966
956
  nameFilter: opts.nameFilter,
@@ -968,12 +958,6 @@ export async function runTestRunAll(opts, deps = {}) {
968
958
  });
969
959
  for (const test of tests)
970
960
  knownTests.set(test.id, { type: test.type, projectId: test.projectId ?? projectId });
971
- if (opts.localPort !== undefined) {
972
- for (const test of tests)
973
- if (test.type === 'backend')
974
- skippedSelection.push({ testId: test.id, reason: 'backend-test' });
975
- tests = tests.filter(test => test.type !== 'backend');
976
- }
977
961
  ids = tests.map(test => test.id);
978
962
  if (ids.length === 0 && opts.ci) {
979
963
  const summary = {
@@ -1022,10 +1006,7 @@ export async function runTestRunAll(opts, deps = {}) {
1022
1006
  throw localValidationError('test-id', 'a project request accepts at most 5000 named test IDs; narrow the selection or use --project <id> without --filter');
1023
1007
  }
1024
1008
  const backendProjects = new Set();
1025
- if (opts.targetUrl &&
1026
- !opts.previewName &&
1027
- !parseLoopbackTargetUrl(opts.targetUrl) &&
1028
- !opts.dryRun) {
1009
+ if (opts.targetUrl && !opts.previewName && !opts.dryRun) {
1029
1010
  for (const [projectId, selection] of projects) {
1030
1011
  let type = selection?.length &&
1031
1012
  selection.every(id => knownTests.get(id)?.type === knownTests.get(selection[0])?.type)
@@ -1047,29 +1028,37 @@ export async function runTestRunAll(opts, deps = {}) {
1047
1028
  }
1048
1029
  }
1049
1030
  const targets = new Map();
1031
+ // What resolving a project's local environment says ("opening a tunnel"),
1032
+ // held until the project is known to keep its tunnel: one with no tests, or
1033
+ // only backend tests, drops it below.
1034
+ const tunnelNotes = new Map();
1050
1035
  if (!opts.environmentResolutionComplete) {
1051
1036
  for (const [projectId, selection] of projects) {
1052
1037
  const firstId = selection?.find(id => knownTests.get(id)?.type === 'frontend') ?? selection?.[0];
1038
+ const notes = [];
1053
1039
  const target = opts.resolvedTarget ??
1054
1040
  (await resolveEnvironmentRunTarget({
1055
- client: opts.dryRun && opts.localPort !== undefined ? client : discoveryClient,
1041
+ client: discoveryClient,
1056
1042
  projectId,
1057
1043
  dryRun: opts.dryRun,
1058
1044
  testId: opts.dryRun ? undefined : firstId,
1059
1045
  knownTest: firstId ? opts.knownTests?.get(firstId) : undefined,
1060
1046
  skipTestLookup: !firstId,
1061
1047
  environment,
1062
- localPort: opts.localPort,
1063
- localHost: opts.localHost,
1064
1048
  targetUrl: opts.targetUrl,
1065
1049
  tunnelClientId: opts.tunnelClientId,
1066
1050
  noWait: opts.noWait,
1067
1051
  cache: deps.environmentCache,
1068
1052
  verbose: opts.verbose || opts.debug,
1069
- stderr: opts.ci ? () => { } : stderr,
1053
+ stderr: opts.ci ? () => { } : line => notes.push(line),
1070
1054
  }));
1071
- if (target)
1055
+ if (target) {
1072
1056
  targets.set(projectId, target);
1057
+ tunnelNotes.set(projectId, notes);
1058
+ }
1059
+ else
1060
+ for (const line of notes)
1061
+ stderr(line);
1073
1062
  }
1074
1063
  }
1075
1064
  if (targets.size && opts.ci)
@@ -1080,13 +1069,37 @@ export async function runTestRunAll(opts, deps = {}) {
1080
1069
  const tests = await resolveAllProjectTests({ client, projectId, stderr });
1081
1070
  for (const test of tests)
1082
1071
  knownTests.set(test.id, { type: test.type, projectId: test.projectId ?? projectId });
1072
+ if (tests.length === 0) {
1073
+ // Nothing to run: say where a first set comes from, through the tunnel,
1074
+ // rather than send a run that the server refuses for want of one.
1075
+ const target = targets.get(projectId);
1076
+ await finishZeroDispatchBatch({
1077
+ reason: 'project has no tests',
1078
+ skipped: [],
1079
+ allowEmpty: opts.allowEmpty === true,
1080
+ opts,
1081
+ deps,
1082
+ stderrFn: stderr,
1083
+ emptyProject: true,
1084
+ projectId,
1085
+ local: {
1086
+ ...(target.environmentName !== undefined
1087
+ ? { environment: target.environmentName }
1088
+ : {}),
1089
+ ...(target.environmentIsDefault !== undefined
1090
+ ? { isDefault: target.environmentIsDefault }
1091
+ : {}),
1092
+ },
1093
+ });
1094
+ return { runs: [] };
1095
+ }
1083
1096
  if (tests.every(test => test.type === 'backend')) {
1084
1097
  targets.delete(projectId);
1085
1098
  continue;
1086
1099
  }
1087
1100
  selection = tests.map(test => test.id);
1088
1101
  }
1089
- if (!selection || opts.localPort !== undefined)
1102
+ if (!selection)
1090
1103
  continue;
1091
1104
  const kept = selection.filter(id => knownTests.get(id)?.type !== 'backend');
1092
1105
  if (kept.length > 5000)
@@ -1101,6 +1114,10 @@ export async function runTestRunAll(opts, deps = {}) {
1101
1114
  targets.delete(projectId);
1102
1115
  }
1103
1116
  }
1117
+ for (const [projectId, notes] of tunnelNotes)
1118
+ if (targets.has(projectId))
1119
+ for (const line of notes)
1120
+ stderr(line);
1104
1121
  if (opts.timeoutIsDefault)
1105
1122
  opts = {
1106
1123
  ...opts,
@@ -1114,10 +1131,10 @@ export async function runTestRunAll(opts, deps = {}) {
1114
1131
  throw localValidationError('wait', '--gh-output and --summary-file require --wait');
1115
1132
  if (!targets.size)
1116
1133
  assertNoTunnelOptions(opts);
1117
- if (opts.targetUrl && !parseLoopbackTargetUrl(opts.targetUrl)) {
1134
+ if (opts.targetUrl) {
1118
1135
  assertNotLocal(opts.targetUrl, {
1119
1136
  field: 'target-url',
1120
- helpCommand: 'testsprite run',
1137
+ helpCommand: 'testsprite ci run',
1121
1138
  hintContext: 'runtime',
1122
1139
  });
1123
1140
  if (!opts.dryRun)
@@ -1232,7 +1249,7 @@ export async function runTestRunAll(opts, deps = {}) {
1232
1249
  shutdown.signal.throwIfAborted();
1233
1250
  const body = bodyFor(projectId, selection, tunnel);
1234
1251
  if (opts.targetUrl && body.targetUrl === undefined && !opts.previewName)
1235
- stderr('[advisory] --target-url is not applied to a single backend run; backend code uses its selected environment. Use ci run --env <name> --target-url <url> in a pull request preview to clone that environment.');
1252
+ stderr("[advisory] --target-url is not applied to a backend project outside a pull request; its tests use the selected environment's URL. In a pull request, ci run --env <name> --target-url <url> clones that environment at the preview.");
1236
1253
  const key = projects.size === 1 ? idempotencyKey : suffixedIdempotencyKey(idempotencyKey, projectId);
1237
1254
  let launched;
1238
1255
  try {
@@ -1416,8 +1433,6 @@ export async function runTestRunAll(opts, deps = {}) {
1416
1433
  runId: launched.runId,
1417
1434
  resultId: outcome?.results[0]?.resultId,
1418
1435
  testId: opts.single ? ids[0] : `--project ${launched.projectId}`,
1419
- localPort: target.port,
1420
- localHost: target.host,
1421
1436
  automatic: target.automatic,
1422
1437
  environment,
1423
1438
  ownerGone,
@@ -1579,16 +1594,7 @@ function tunnelRunConcurrency(opts) {
1579
1594
  export async function runTestRunLocalBatch(opts, deps = {}) {
1580
1595
  return runTestRunAll({ ...opts, wait: opts.wait === true, testIds: opts.all ? undefined : opts.testIds }, deps);
1581
1596
  }
1582
- /**
1583
- * `--skip-preflight` help text for `run` with a `--target-url`
1584
- * override. States the honest limitation up front: this CLI
1585
- * probes from wherever it runs, not from the Lambda that executes the
1586
- * test, so the probe is a heuristic, not a guarantee — hence the full
1587
- * opt-out.
1588
- */
1589
- const SKIP_PREFLIGHT_HELP = 'skip the pre-charge reachability probe of the target URL (it runs from this machine, not the ' +
1590
- 'cloud, so it can be wrong, e.g. behind an IP allowlist)';
1591
- const TARGET_URL_HELP = "frontend tests only: run against this URL, using the environment for its origin (else a temporary one deleted after the run); with --env, that environment's settings; loopback URLs open a tunnel";
1597
+ const SKIP_PREFLIGHT_HELP = "skip the check that a local environment's app is listening before its tunnel opens";
1592
1598
  export function createTestCommand(deps = {}) {
1593
1599
  const test = new Command('test').description('List and inspect tests');
1594
1600
  test
@@ -1660,7 +1666,7 @@ export function createRunCommand(deps = {}) {
1660
1666
  ' 10 transport/network failure (UNAVAILABLE). If it printed a runId with status\n' +
1661
1667
  ' running, that run is still executing: check it with testsprite run wait\n' +
1662
1668
  ' <run-id> (running this command again triggers and bills a new run).\n' +
1663
- ' With --local or a local environment, the tunnel closed with this command\n' +
1669
+ ' With a local environment, the tunnel closed with this command\n' +
1664
1670
  ' and run wait cannot reopen it: follow the printed next step. If its\n' +
1665
1671
  ' cancellation was skipped, the run can still finish, but steps that need\n' +
1666
1672
  ' your machine can fail. Otherwise retry the command\n' +
@@ -1675,14 +1681,8 @@ export function createRunCommand(deps = {}) {
1675
1681
  '\nCtrl-C during an ordinary --wait detaches; an owned tunnel cancels unfinished runs by default.\n' +
1676
1682
  'Stop a detached run with: testsprite run cancel <run-id>\n' +
1677
1683
  'Dev servers can take a minute per page through a tunnel; prefer a built server (npm run build, then start).')
1678
- .option('--target-url <url>', TARGET_URL_HELP)
1679
1684
  .option('--skip-preflight', SKIP_PREFLIGHT_HELP, false)
1680
- .option('--local <port>', 'run against an app on THIS machine through a TestSprite tunnel (the runner opens ' +
1681
- 'http://localhost:<port>). Implies --wait. Frontend tests only; several ids or --project start one ' +
1682
- 'run per project through one tunnel (see --max-concurrency). A dead port is refused before anything is billed.')
1683
- .option('--local-host <host>', `with --local, loopback address in the target URL: ${LOOPBACK_HOSTS.join(', ')} ` +
1684
- `(default: saved matching host, else ${DEFAULT_LOCAL_HOST}). Use localhost if your app only answers on that name, ::1 for IPv6-only.`)
1685
- .option('--tunnel-client <id>', 'for a loopback environment or --local, attach to a tunnel already running under `testsprite tunnel start` ' +
1685
+ .option('--tunnel-client <id>', 'for a local environment, attach to a tunnel already running under `testsprite tunnel start` ' +
1686
1686
  '(use the id it prints) instead of opening one; that process keeps the tunnel open afterwards.')
1687
1687
  .option('--no-cancel-on-interrupt', 'with a tunnel, do not auto-cancel runs when an owned tunnel closes or a ' +
1688
1688
  "borrowed tunnel's owner disappears")
@@ -1702,12 +1702,12 @@ export function createRunCommand(deps = {}) {
1702
1702
  .option('--report-suite-name <name>', 'optional JUnit suite name (default: testsprite:<projectId>, or testsprite:testlist:<listId>)')
1703
1703
  .option('--gh-output', 'with --wait: emit GitHub annotations (::error:: failed/timed-out, ::warning:: never dispatched) and a job-summary table when $GITHUB_STEP_SUMMARY is set; auto-enabled when GITHUB_ACTIONS=true')
1704
1704
  .option('--summary-file <path>', 'with --wait: also write summary JSON {total, passed, failed, blocked?, cancelled?, errors?, skipped, timedOut, results[]} to this file')
1705
- .option('--allow-empty', 'with a project or multi-ID batch: exit 0 when ZERO test cases are dispatched (default: exit 5, so an empty run is not a CI false-green)')
1705
+ .option('--allow-empty', 'with a project, a test list or a multi-ID batch: exit 0 when ZERO test cases are dispatched (default: exit 5, so an empty run is not a CI false-green)')
1706
1706
  .option('--skip-dependencies', 'Backend test cases only: run without the test cases they depend on', false)
1707
1707
  .addHelpText('after', '\nExamples:\n' +
1708
1708
  ' testsprite run --project <id> all test cases in the project, in wave order\n' +
1709
1709
  ' testsprite run <id> <id> <id> several test cases in one run (one request per project; at most 5000 named IDs per project)\n' +
1710
- ' testsprite run <id> <id> --local 3000 several local test cases, one tunnel\n' +
1710
+ ' testsprite run <id> <id> --env local several test cases on a local environment, one tunnel\n' +
1711
1711
  ' testsprite run --project <id> --env staging all test cases in the project, run in staging\n' +
1712
1712
  ' testsprite run --project <id> --filter <substr> --wait --report junit --report-file ./results.xml\n' +
1713
1713
  ' testsprite run --testlist <list-id> --wait all saved list cases, using pinned environments\n' +
@@ -1715,7 +1715,7 @@ export function createRunCommand(deps = {}) {
1715
1715
  ' testsprite run wait <run-id...> --timeout 600 resume without starting a new run\n' +
1716
1716
  ' testsprite run cancel <run-id...> cancel whole executions\n' +
1717
1717
  '\nList mode: concurrency defaults to 10 (1-50), or 5 through a tunnel (1-10); timeout defaults to 600 even through a tunnel.\n' +
1718
- 'List environments come from saved project mappings; --env, --target-url, --local and other project-only launch flags are refused.\n' +
1718
+ 'List environments come from saved project mappings; --env and other project-only launch flags are refused.\n' +
1719
1719
  '\nQueueing and limits:\n' +
1720
1720
  ' - Each request starts one run; its results show queued until they start,\n' +
1721
1721
  ' as in the Portal.\n' +
@@ -1751,14 +1751,10 @@ export function createRunCommand(deps = {}) {
1751
1751
  if (explicitList) {
1752
1752
  for (const name of [
1753
1753
  'env',
1754
- 'targetUrl',
1755
- 'local',
1756
- 'localHost',
1757
1754
  'tunnelClient',
1758
1755
  'cancelOnInterrupt',
1759
1756
  'skipDependencies',
1760
1757
  'filter',
1761
- 'allowEmpty',
1762
1758
  ]) {
1763
1759
  if (command.getOptionValueSource(name) === 'cli') {
1764
1760
  const flag = command.options.find(option => option.attributeName() === name).long;
@@ -1773,67 +1769,25 @@ export function createRunCommand(deps = {}) {
1773
1769
  if (isAll)
1774
1770
  requireProjectId(projectId, 'provide test IDs, --testlist <id>, or --project <id> (or set TESTSPRITE_PROJECT_ID)');
1775
1771
  const nameFilter = parseNameFilter(cmdOpts.filter);
1776
- const stderrFn = terminalSafeWriter(deps.stderr);
1777
1772
  if (nameFilter !== undefined && !isAll) {
1778
1773
  throw localValidationError('filter', '--filter only applies to a whole-project run; use --project <id> or TESTSPRITE_PROJECT_ID without test IDs');
1779
1774
  }
1780
- // --local resolution. Every one of these refuses BEFORE any network
1781
- // call, which is the contract `--local` is sold on: a mistake in the
1775
+ // Every refusal here happens BEFORE any network call: a mistake in the
1782
1776
  // invocation must never reach a run row, a credit spend, or a minted
1783
1777
  // tunnel credential.
1784
- const localPort = cmdOpts.local !== undefined ? parseLocalPort(cmdOpts.local) : undefined;
1785
- const usingLocal = localPort !== undefined;
1786
- const effectiveWait = usingLocal ||
1787
- (cmdOpts.targetUrl !== undefined &&
1788
- parseLoopbackTargetUrl(cmdOpts.targetUrl) !== undefined) ||
1789
- cmdOpts.wait === true;
1778
+ const effectiveWait = cmdOpts.wait === true;
1790
1779
  const canAutoWait = !resolveCommonOptions(command, deps.env).dryRun &&
1791
1780
  !(command.getOptionValueSource('wait') === 'cli' && cmdOpts.wait === false);
1792
- const explicitLoopbackTarget = cmdOpts.targetUrl !== undefined && parseLoopbackTargetUrl(cmdOpts.targetUrl) !== undefined;
1793
- if (!usingLocal &&
1794
- !explicitLoopbackTarget &&
1795
- ((command.getOptionValueSource('wait') === 'cli' && cmdOpts.wait === false) ||
1796
- cmdOpts.targetUrl !== undefined)) {
1781
+ if (command.getOptionValueSource('wait') === 'cli' && cmdOpts.wait === false) {
1797
1782
  assertNoTunnelOptions({
1798
1783
  tunnelClientId: cmdOpts.tunnelClient,
1799
1784
  cancelOnInterrupt: cmdOpts.cancelOnInterrupt,
1800
1785
  });
1801
1786
  }
1802
1787
  const maxConcurrency = cmdOpts.maxConcurrency === undefined
1803
- ? usingLocal
1804
- ? DEFAULT_TUNNEL_RUN_CONCURRENCY
1805
- : DEFAULT_BATCH_RUN_CONCURRENCY
1788
+ ? DEFAULT_BATCH_RUN_CONCURRENCY
1806
1789
  : Number(cmdOpts.maxConcurrency);
1807
- if (usingLocal) {
1808
- tunnelRunConcurrency({
1809
- maxConcurrency,
1810
- concurrencyIsDefault: cmdOpts.maxConcurrency === undefined,
1811
- });
1812
- }
1813
1790
  const testIds = [...new Set(testIdArgs)];
1814
- if (usingLocal) {
1815
- const seen = new Set();
1816
- for (const id of testIdArgs) {
1817
- if (seen.has(id))
1818
- stderrFn(`[advisory] ignoring duplicate test id ${id}`);
1819
- seen.add(id);
1820
- }
1821
- }
1822
- if (usingLocal && cmdOpts.targetUrl !== undefined && cmdOpts.targetUrl !== '') {
1823
- throw localValidationError('local', '--local and --target-url are mutually exclusive: --local runs against your own ' +
1824
- 'machine through a tunnel, --target-url runs against an address the test runner can ' +
1825
- 'already reach. Pass one');
1826
- }
1827
- // A host override is meaningful only for the port shorthand. Silently ignoring
1828
- // them would leave the caller believing something is in effect that is
1829
- // not — the same rule --filter and the JUnit flags already follow.
1830
- if (!usingLocal && cmdOpts.localHost !== undefined) {
1831
- throw localValidationError('local-host', '--local-host only applies with --local (it names the loopback address the tunnel run ' +
1832
- 'targets). Add --local <port>, or remove --local-host');
1833
- }
1834
- const localHost = usingLocal && cmdOpts.localHost !== undefined
1835
- ? normalizeLocalHost(cmdOpts.localHost)
1836
- : undefined;
1837
1791
  const report = parseJUnitReportFormat(cmdOpts.report);
1838
1792
  assertJUnitReportOptions({
1839
1793
  report,
@@ -1858,20 +1812,9 @@ export function createRunCommand(deps = {}) {
1858
1812
  reportFile: cmdOpts.reportFile,
1859
1813
  summaryFile: cmdOpts.summaryFile,
1860
1814
  });
1861
- if (isAll && !usingLocal && cmdOpts.tunnelClient === undefined) {
1815
+ if (isAll && cmdOpts.tunnelClient === undefined) {
1862
1816
  // Project path: wave-ordered fresh batch run.
1863
1817
  requireProjectId(projectId, 'pass --project <id> or set TESTSPRITE_PROJECT_ID');
1864
- // A batch target URL applies to frontend tests in the batch.
1865
- // Server-side it rides the same per-run override field a single fresh
1866
- // FE run uses, so FE cases honor it; a BE case's `VAR_{url}` resolves
1867
- // to the run's environment URL, so it follows the target only when the
1868
- // run's environment is at that address (a pull request's clone, or no
1869
- // --env), which the advisory after dispatch states from the server's
1870
- // answer rather than leaving the caller to infer. An empty value is
1871
- // the flag with no argument — still a mistake, still rejected.
1872
- if (cmdOpts.targetUrl !== undefined && cmdOpts.targetUrl === '') {
1873
- throw localValidationError('target-url', '--target-url needs a URL (e.g. --target-url https://pr-42.preview.example.com).');
1874
- }
1875
1818
  await runTestRunAll({
1876
1819
  ...resolveCommonOptions(command, deps.env),
1877
1820
  projectId,
@@ -1892,33 +1835,12 @@ export function createRunCommand(deps = {}) {
1892
1835
  summaryFile: cmdOpts.summaryFile,
1893
1836
  allowEmpty: cmdOpts.allowEmpty === true,
1894
1837
  environment: cmdOpts.env,
1895
- ...(cmdOpts.targetUrl !== undefined && cmdOpts.targetUrl !== ''
1896
- ? { targetUrl: cmdOpts.targetUrl }
1897
- : {}),
1898
1838
  skipPreflight: cmdOpts.skipPreflight === true,
1899
1839
  ...(cmdOpts.skipDependencies === true ? { skipDependencies: true } : {}),
1900
1840
  }, deps);
1901
1841
  return;
1902
1842
  }
1903
- // `--local` implies `--wait`: for a self-minted tunnel the tunnel's
1904
- // lifetime is this process's lifetime, so returning early would doom the
1905
- // run it just started. Announced rather than assumed — a caller who did
1906
- // not type --wait should learn why the command is now blocking.
1907
- //
1908
- // The reason splits on how the tunnel was obtained. An adopted one
1909
- // (--tunnel-client) outlives this process, so "the tunnel closes when
1910
- // this command exits" is simply false there, and it is the sentence a
1911
- // reader would act on: told that, someone deciding whether to background
1912
- // this command concludes the wrong thing about their own tunnel.
1913
1843
  const commonOpts = resolveCommonOptions(command, deps.env);
1914
- if (usingLocal && cmdOpts.wait !== true && commonOpts.output !== 'json') {
1915
- const adopted = cmdOpts.tunnelClient !== undefined;
1916
- terminalSafeWriter(deps.stderr)(adopted
1917
- ? '[advisory] --local implies --wait: the run is followed to a verdict rather than ' +
1918
- 'detached. The tunnel you attached to stays open — this command does not close it.'
1919
- : '[advisory] --local implies --wait: the tunnel closes when this command exits, so ' +
1920
- 'the run is followed to a verdict rather than detached.');
1921
- }
1922
1844
  if (isAll || testIds.length > 1) {
1923
1845
  await runTestRunLocalBatch({
1924
1846
  ...commonOpts,
@@ -1927,9 +1849,6 @@ export function createRunCommand(deps = {}) {
1927
1849
  all: isAll,
1928
1850
  projectId,
1929
1851
  nameFilter,
1930
- localPort,
1931
- localHost,
1932
- targetUrl: cmdOpts.targetUrl,
1933
1852
  noWait: command.getOptionValueSource('wait') === 'cli' && cmdOpts.wait === false,
1934
1853
  concurrencyIsDefault: cmdOpts.maxConcurrency === undefined,
1935
1854
  timeoutIsDefault: cmdOpts.timeout === undefined,
@@ -1956,17 +1875,12 @@ export function createRunCommand(deps = {}) {
1956
1875
  await runTestRun({
1957
1876
  ...commonOpts,
1958
1877
  testId: testIds[0],
1959
- targetUrl: cmdOpts.targetUrl,
1960
1878
  skipPreflight: cmdOpts.skipPreflight === true,
1961
- ...(localPort !== undefined ? { localPort } : {}),
1962
- ...(localHost !== undefined ? { localHost } : {}),
1963
1879
  ...(cmdOpts.tunnelClient !== undefined ? { tunnelClientId: cmdOpts.tunnelClient } : {}),
1964
1880
  cancelOnInterrupt: cmdOpts.cancelOnInterrupt !== false,
1965
1881
  wait: effectiveWait,
1966
1882
  noWait: command.getOptionValueSource('wait') === 'cli' && cmdOpts.wait === false,
1967
- timeoutSeconds: usingLocal && cmdOpts.timeout === undefined
1968
- ? DEFAULT_LOCAL_RUN_TIMEOUT_SECONDS
1969
- : parseTimeoutFlag(cmdOpts.timeout, 'timeout'),
1883
+ timeoutSeconds: parseTimeoutFlag(cmdOpts.timeout, 'timeout'),
1970
1884
  // B2(c): tell runTestRun whether --timeout was explicitly provided.
1971
1885
  timeoutIsDefault: cmdOpts.timeout === undefined,
1972
1886
  idempotencyKey: cmdOpts.idempotencyKey,
@@ -88,6 +88,8 @@ export interface RunTestlistRunOptions extends CommonOptions {
88
88
  ghOutput?: boolean;
89
89
  /** --summary-file: also write the reduced machine summary JSON to this path. */
90
90
  summaryFile?: string;
91
+ /** --allow-empty: exit 0 when the list dispatches nothing (default: exit 5). */
92
+ allowEmpty?: boolean;
91
93
  }
92
94
  export declare function runTestlistRun(opts: RunTestlistRunOptions, deps?: TestListDeps): Promise<{
93
95
  thenPoll?: string | undefined;
@@ -136,9 +138,9 @@ export declare function runTestlistRun(opts: RunTestlistRunOptions, deps?: TestL
136
138
  message?: string;
137
139
  }[] | undefined;
138
140
  environment?: import("../lib/runs.types.js").RunEnvironmentRef | null | undefined;
139
- enqueuedAt?: string | undefined;
140
141
  total?: number | undefined;
141
142
  autoHeal?: boolean | undefined;
143
+ enqueuedAt?: string | undefined;
142
144
  maxConcurrency?: number | undefined;
143
145
  tunnelClientId?: string | undefined;
144
146
  held?: {
@@ -196,9 +198,9 @@ export declare function runTestlistRun(opts: RunTestlistRunOptions, deps?: TestL
196
198
  message?: string;
197
199
  }[] | undefined;
198
200
  environment?: import("../lib/runs.types.js").RunEnvironmentRef | null | undefined;
199
- enqueuedAt?: string | undefined;
200
201
  total?: number | undefined;
201
202
  autoHeal?: boolean | undefined;
203
+ enqueuedAt?: string | undefined;
202
204
  maxConcurrency?: number | undefined;
203
205
  tunnelClientId?: string | undefined;
204
206
  held?: {
@@ -266,6 +266,27 @@ function parseTestlistConcurrencyFlag(raw) {
266
266
  }
267
267
  return n;
268
268
  }
269
+ /**
270
+ * A list that started nothing and refused nothing (an empty list, or one whose
271
+ * every case was left out) is exit 5, as on `run --project`: a CI gate that is
272
+ * green on zero tests is worse than no gate. `--allow-empty` keeps exit 0.
273
+ * Checked last, so a rate-deferred (7) or unknown (4) case is reported first.
274
+ */
275
+ function assertDispatched(resp, allowEmpty, stderrFn) {
276
+ if (resp.accepted.length > 0 || resp.conflicts.length > 0)
277
+ return;
278
+ const reason = resp.reason === 'empty_list'
279
+ ? 'the list is empty'
280
+ : resp.reason === 'no_matching_cases'
281
+ ? 'no test in the list matched'
282
+ : 'the list started no test';
283
+ if (allowEmpty) {
284
+ stderrFn(`[run] 0 tests dispatched (${reason}); --allow-empty set — exiting 0.`);
285
+ return;
286
+ }
287
+ throw new CLIError(`No tests were dispatched — ${reason}. A CI gate that passes on zero tests is unsafe; ` +
288
+ 'pass --allow-empty to exit 0 intentionally.', 5);
289
+ }
269
290
  /**
270
291
  * Rate-deferred members were never dispatched → the batch is incomplete (exit 7),
271
292
  * mirroring `run --project`. The backend applies the same per-key run-rate
@@ -506,8 +527,8 @@ async function runTestlistRunCore(opts, deps = {}) {
506
527
  // All-conflict: nothing new dispatched because every targeted case is already
507
528
  // in flight → exit 6, for BOTH --wait and non-wait (a --wait over zero accepted
508
529
  // would otherwise no-op straight to exit 0). Distinct from the empty/no-match
509
- // case (accepted AND conflicts both empty), which is a legitimate success and
510
- // flows through the tail below so its CI artifacts are still emitted.
530
+ // case (accepted AND conflicts both empty), which flows through the tail
531
+ // below so its CI artifacts are still emitted before `assertDispatched`.
511
532
  if (resp.accepted.length === 0 && resp.conflicts.length > 0) {
512
533
  const { output, summary } = buildRunOutput(outputOptions);
513
534
  out.print({ ...output, ...dispatchMetadata }, () => renderRunResults(output.runs, output.results, opts.wait ? summary : undefined, conflictRows(resp.conflicts)));
@@ -562,7 +583,7 @@ async function runTestlistRunCore(opts, deps = {}) {
562
583
  billingConflictLink(resp.conflicts, client.resolvedBaseUrl), 6);
563
584
  }
564
585
  if (!opts.wait) {
565
- // Print what dispatched, or the empty/no-match reason. Exit 0.
586
+ // Print what dispatched, or the empty/no-match reason.
566
587
  const { output } = buildRunOutput(outputOptions);
567
588
  const launch = { ...output, ...dispatchMetadata };
568
589
  out.print(launch, () => resp.accepted.length > 0
@@ -576,6 +597,7 @@ async function runTestlistRunCore(opts, deps = {}) {
576
597
  });
577
598
  assertNoDeferred(resp);
578
599
  assertNoNotFound(resp);
600
+ assertDispatched(resp, opts.allowEmpty === true, stderrFn);
579
601
  return launch;
580
602
  }
581
603
  for (const runId of runIds)
@@ -670,7 +692,11 @@ async function runTestlistRunCore(opts, deps = {}) {
670
692
  stdout: deps.stdout ?? (line => process.stdout.write(`${line}\n`)),
671
693
  stderr: stderrFn,
672
694
  }, 'run');
673
- const owesExit = failure !== undefined || resp.deferred.length > 0 || (resp.notFound?.length ?? 0) > 0;
695
+ const empty = resp.accepted.length === 0 && resp.conflicts.length === 0;
696
+ const owesExit = failure !== undefined ||
697
+ resp.deferred.length > 0 ||
698
+ (resp.notFound?.length ?? 0) > 0 ||
699
+ (empty && opts.allowEmpty !== true);
674
700
  if (opts.report === 'junit' && opts.reportFile) {
675
701
  const file = opts.reportFile;
676
702
  await writeReportOwing(owesExit, () => writeJUnitReportFile(file, buildJUnitReport({
@@ -692,6 +718,7 @@ async function runTestlistRunCore(opts, deps = {}) {
692
718
  throw failure;
693
719
  assertNoDeferred(resp);
694
720
  assertNoNotFound(resp);
721
+ assertDispatched(resp, opts.allowEmpty === true, stderrFn);
695
722
  return launch;
696
723
  }
697
724
  /** One line per refused member: `<in-flight result or (none)> <testId> <reason>`. */
@@ -884,6 +911,7 @@ export async function runTestlistRunFromCommand(command, listId, testIds, deps =
884
911
  reportSuiteName: opts.reportSuiteName,
885
912
  ghOutput: opts.ghOutput,
886
913
  summaryFile: opts.summaryFile,
914
+ allowEmpty: opts.allowEmpty === true,
887
915
  }, deps);
888
916
  }
889
917
  //# sourceMappingURL=testlist.js.map
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * `testsprite tunnel start | list | status | stop`.
3
3
  *
4
- * The out-of-band primitive under `run --local`, which is sugar over it.
5
- * Two things it buys that the sugar cannot:
4
+ * The out-of-band primitive under a run on a local environment, which opens
5
+ * its own tunnel otherwise. Two things it buys that the automatic one cannot:
6
6
  *
7
7
  * - **One tunnel, many runs.** `tunnel start` in one terminal, then
8
- * `run <id> --local <port> --tunnel-client <id>` as many times as you
8
+ * `run <id> --env <name> --tunnel-client <id>` as many times as you
9
9
  * like in another. Each run would otherwise mint and tear down its own
10
10
  * credential, and the per-principal live-binding cap is small.
11
11
  * - **A place to look when a run says the tunnel is down.** `tunnel status`
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * `testsprite tunnel start | list | status | stop`.
3
3
  *
4
- * The out-of-band primitive under `run --local`, which is sugar over it.
5
- * Two things it buys that the sugar cannot:
4
+ * The out-of-band primitive under a run on a local environment, which opens
5
+ * its own tunnel otherwise. Two things it buys that the automatic one cannot:
6
6
  *
7
7
  * - **One tunnel, many runs.** `tunnel start` in one terminal, then
8
- * `run <id> --local <port> --tunnel-client <id>` as many times as you
8
+ * `run <id> --env <name> --tunnel-client <id>` as many times as you
9
9
  * like in another. Each run would otherwise mint and tear down its own
10
10
  * credential, and the per-principal live-binding cap is small.
11
11
  * - **A place to look when a run says the tunnel is down.** `tunnel status`
@@ -562,7 +562,6 @@ export function createTunnelCommand(deps = {}) {
562
562
  '\nExamples:\n' +
563
563
  ' testsprite tunnel start # hold a tunnel open (Ctrl-C to stop)\n' +
564
564
  ' testsprite run <test-id> --env <name> --tunnel-client <client-id>\n' +
565
- ' testsprite run <test-id> --local 3000 --tunnel-client <client-id>\n' +
566
565
  ' testsprite tunnel stop --all --confirm\n');
567
566
  tunnel
568
567
  .command('start')