sxy-test-runner 2.4.2 → 2.4.4

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 (41) hide show
  1. package/AGENTS.md +55 -9
  2. package/dist/cli/help.js +6 -4
  3. package/dist/cli/help.js.map +1 -1
  4. package/dist/cli/index.js +3 -23
  5. package/dist/cli/index.js.map +1 -1
  6. package/dist/cli/init.js +1 -0
  7. package/dist/cli/init.js.map +1 -1
  8. package/dist/cli/lib/agentReport.d.ts +1 -1
  9. package/dist/cli/lib/agentReport.js +5 -0
  10. package/dist/cli/lib/agentReport.js.map +1 -1
  11. package/dist/cli/lib/defaultConfig.js +1 -0
  12. package/dist/cli/lib/defaultConfig.js.map +1 -1
  13. package/dist/cli/lib/parseCommandLineArguments.d.ts +1 -0
  14. package/dist/cli/lib/parseCommandLineArguments.js +15 -1
  15. package/dist/cli/lib/parseCommandLineArguments.js.map +1 -1
  16. package/dist/cli/lib/resolveCommand.d.ts +8 -0
  17. package/dist/cli/lib/resolveCommand.js +47 -0
  18. package/dist/cli/lib/resolveCommand.js.map +1 -0
  19. package/dist/cli/lib/runDescribe.d.ts +2 -1
  20. package/dist/cli/lib/runDescribe.js +5 -2
  21. package/dist/cli/lib/runDescribe.js.map +1 -1
  22. package/dist/cli/lib/runDescribeRun.d.ts +2 -1
  23. package/dist/cli/lib/runDescribeRun.js +8 -2
  24. package/dist/cli/lib/runDescribeRun.js.map +1 -1
  25. package/dist/cli/lib/runTest.d.ts +2 -1
  26. package/dist/cli/lib/runTest.js +6 -2
  27. package/dist/cli/lib/runTest.js.map +1 -1
  28. package/dist/cli/lib/runTests.js +19 -4
  29. package/dist/cli/lib/runTests.js.map +1 -1
  30. package/dist/cli/lib/showTestResult.js +13 -2
  31. package/dist/cli/lib/showTestResult.js.map +1 -1
  32. package/dist/cli/lib/stopSignal.d.ts +7 -0
  33. package/dist/cli/lib/stopSignal.js +10 -0
  34. package/dist/cli/lib/stopSignal.js.map +1 -0
  35. package/dist/cli/once.js +33 -11
  36. package/dist/cli/once.js.map +1 -1
  37. package/dist/cli/watch.js +3 -0
  38. package/dist/cli/watch.js.map +1 -1
  39. package/dist/types.d.ts +3 -2
  40. package/dist/types.js.map +1 -1
  41. package/package.json +3 -1
package/AGENTS.md CHANGED
@@ -19,8 +19,17 @@ For introductory human-facing usage, also see `readme.md`.
19
19
  4. Import only `describe` from `sxy-test-runner`. Obtain `it`, `test`, and local hooks from
20
20
  the `describe` callback.
21
21
  5. Run `npx sxy-test-runner once` for finite agent or CI work.
22
- 6. Exit codes: `0` all tests passed, `3` test failure, `4` no test files matched the `tests`
23
- pattern, `5` test files ran but `--filter-it`/`--filter-describe` matched nothing.
22
+ 6. Exit codes: `0` all tests passed, `2` an option was not recognised, `3` test failure,
23
+ `4` no test files matched the `tests` pattern, `5` test files ran but
24
+ `--filter-it`/`--filter-describe` matched nothing.
25
+
26
+ An unrecognised option exits `2` before anything runs, rather than warning and carrying on -
27
+ otherwise a typo like `--fitler-it` quietly runs the whole suite and reports a pass. Every
28
+ unrecognised option is listed at once, with a suggestion where the intent is obvious. Options
29
+ are per-command, so `watch --fail-fast` and `once --status-file` are usage errors too.
30
+
31
+ These are process exit codes, and are **not** the status codes used by `--status-file` and
32
+ `--agent`, where `2` means the run died partway. Read the exit code from the process.
24
33
 
25
34
  Do not run a test file directly with `node`. `describe()` requires runner-owned global
26
35
  state and deliberately throws if the framework has not initialized it.
@@ -85,6 +94,9 @@ npx sxy-test-runner once --filter-describe "users"
85
94
  # Run tests whose names contain "creates a user"
86
95
  npx sxy-test-runner once --filter-it "creates a user"
87
96
 
97
+ # Stop at the first failure instead of running the whole suite
98
+ npx sxy-test-runner once --fail-fast
99
+
88
100
  # Watch mode, reporting each run as single agent readable lines
89
101
  npx sxy-test-runner watch --agent
90
102
 
@@ -116,6 +128,29 @@ describes or tests afterward can therefore be much slower than file filtering. P
116
128
  `--filter` when a file glob can narrow the run, then use `--filter-describe` or
117
129
  `--filter-it` only for further narrowing inside those files.
118
130
 
131
+ `--fail-fast` (`-x`) stops the run at the first failure - whether that is a failing test, a
132
+ describe that threw, or a test file that would not load. It is a `once` flag with no config
133
+ equivalent: it describes a single invocation rather than a project, and in watch mode it
134
+ would silently truncate runs that report themselves as having covered everything.
135
+ The failure is reported in full, then nothing further starts: not the rest of the describe,
136
+ the file, or the remaining files. Hooks still unwind normally, so `afterEachTest`,
137
+ `afterEachDescribe`, `afterEachFile` and `teardown` all run for whatever had started.
138
+
139
+ Because the run is cut short, the tallies count only what ran - a suite of 500 tests can
140
+ report `Tests: 0/1`. The summary therefore ends with `stopped at the first failure
141
+ (failFast)`, and the status file's description gains `, stopped at the first failure`. Read
142
+ those before treating a tally as the size of the suite. The exit code is unchanged: `3` for
143
+ a test failure, so CI still fails the job.
144
+
145
+ Under parallel execution it is best-effort: work already in flight finishes, so more than
146
+ one failure can be reported. Sequential execution - the default - stops exactly at the
147
+ first.
148
+
149
+ CI usually wants this **off**, which is the default. A CI run is not interactive, so seeing
150
+ every failure in one round beats fixing one, pushing, and waiting again. It earns its place
151
+ on a slow suite where the first failure is enough to know the build is dead, or in a local
152
+ edit-test loop.
153
+
119
154
  Test discovery uses Node's built-in glob implementation. Patterns are resolved relative to
120
155
  `testsBase`, and ignore patterns are resolved from that same base.
121
156
 
@@ -324,10 +359,12 @@ ever sees a complete status.
324
359
 
325
360
  ### Following a watch session as an agent
326
361
 
327
- `--agent` (or `watch.agent` in the config) replaces watch mode's usual output with one line
328
- per event, for an agent reading the process's stdout rather than a terminal. It applies to
329
- watch mode only - `once` already ends with an exit code, so a config setting it is ignored
330
- there.
362
+ `--agent` (or `watch.agent` in the config, for watch mode) replaces the usual output with
363
+ one line per event, for an agent reading the process's stdout rather than a terminal. It
364
+ works in both modes. In `once` it leaves only the failures and the summary - no per-test
365
+ listing - and the process still exits on its usual code, so `once --agent` is both readable
366
+ and CI-safe. In `once` the flag is the only source: a config setting `watch.agent` is
367
+ ignored there, so the output format cannot change out from under a caller.
331
368
 
332
369
  ```
333
370
  [sxyt] init | pid=16744
@@ -350,7 +387,7 @@ is always exactly one line and a field boundary is always a real one.
350
387
  | --- | --- |
351
388
  | `init` | the process is up, before the config is read - proof it started at all |
352
389
  | `found` | test discovery finished |
353
- | `run` | a run has started. `why` is `startup`, `auto` (a file changed), or `all`/`last`/`failed` from a keyboard command |
390
+ | `run` | a run has started. `why` is `once`, `startup`, `auto` (a file changed), or `all`/`last`/`failed` from a keyboard command |
354
391
  | `fail` | one failure. `describe` is absent when a file would not load, `test` when the describe itself threw |
355
392
  | `done` | the run finished |
356
393
  | `change` | a watched file changed |
@@ -367,7 +404,8 @@ generalises:
367
404
 
368
405
  | covers | the run contained |
369
406
  | --- | --- |
370
- | `all` | every discovered test file - the startup run, `a` from the keyboard, or any change when `watch.dependencyEvaluation` is off |
407
+ | `all` | every discovered test file - a `once` run, the watch startup run, `a` from the keyboard, or any change when `watch.dependencyEvaluation` is off |
408
+ | `until-first-failure` | the run is set up to stop early (`--fail-fast`), so it can only speak for what it reached |
371
409
  | `changed+failing` | the changed files and every file still failing (`watch.reRunFailingTests` on, the default) |
372
410
  | `changed` | only the changed files (`watch.reRunFailingTests` off) |
373
411
  | `last` | the previous run's file set |
@@ -401,7 +439,15 @@ Widening `watch.watchFiles` (for example to `**/*.{js,json,env}`) closes the fir
401
439
  it matters, at the cost of more reruns.
402
440
 
403
441
  Diffs, logs and stack traces are not in the agent stream; errors are reduced to one line.
404
- Use `once` when a finite run and an exit code are all that is needed.
442
+
443
+ In `once`, `code` on the `done` line is the status code above, **not** the process exit
444
+ code - `code=1` accompanies exit `3`. Read the process's exit code for pass/fail; read the
445
+ line for the detail. `watching` and `change` never appear, since there is no watcher.
446
+
447
+ ```sh
448
+ # a finite, agent readable run: failures and a summary, exit code preserved
449
+ npx sxy-test-runner once --agent
450
+ ```
405
451
 
406
452
  ## Configuration reference
407
453
 
package/dist/cli/help.js CHANGED
@@ -24,13 +24,15 @@ export function help() {
24
24
  ' help Show this help',
25
25
  '',
26
26
  'Options:',
27
- ' -c, --config <file> Use a specific configuration file',
28
- ' -t, --test-files <glob> Override the configured test pattern',
29
- ' -f, --filter <glob> Further constrain the configured test pattern',
27
+ ' -c, --config <file> Use a specific configuration file',
28
+ ' -t, --test-files <glob> Override the configured test pattern',
29
+ ' -f, --filter <glob> Further constrain the configured test pattern',
30
30
  ' -d, --filter-describe <substring> Run matching describe blocks',
31
31
  ' -i, --filter-it <substring> Run matching tests',
32
+ ' -x, --fail-fast Stop at the first failure (once mode)',
32
33
  ' -s, --status-file <file> Write the latest watch run status to a file',
33
- ' --agent Report a watch session as single agent readable lines',
34
+ ' --agent Report the run as single agent readable lines',
35
+ ' -h, --help Show this help, for any command',
34
36
  '',
35
37
  'Watch controls:',
36
38
  ' r/l + Enter Re-run the last set of tests',
@@ -1 +1 @@
1
- {"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/cli/help.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,sBAAsB,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACrF,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAElC,MAAM,UAAU,IAAI;IAChB,MAAM,WAAW,GAAG,eAAe;SAC9B,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,eAAe,CAAC;SACnC,IAAI,CAAC,MAAM,CAAC,CAAA;IACjB,MAAM,iBAAiB,GAAG,eAAe;SACpC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,KAAK,EAAE,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,GAAG,QAAQ,GAAG,CAAC;SACtE,IAAI,CAAC,MAAM,CAAC,CAAA;IAEjB,GAAG,CAAC;QACA,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC;QAC7B,EAAE;QACF,QAAQ;QACR,KAAK,OAAO,oBAAoB;QAChC,KAAK,OAAO,iBAAiB;QAC7B,KAAK,OAAO,OAAO;QACnB,KAAK,OAAO,OAAO;QACnB,EAAE;QACF,WAAW;QACX,iEAAiE;QACjE,2CAA2C;QAC3C,+CAA+C;QAC/C,yBAAyB;QACzB,EAAE;QACF,UAAU;QACV,8DAA8D;QAC9D,iEAAiE;QACjE,0EAA0E;QAC1E,mEAAmE;QACnE,yDAAyD;QACzD,kFAAkF;QAClF,4FAA4F;QAC5F,EAAE;QACF,iBAAiB;QACjB,sDAAsD;QACtD,0CAA0C;QAC1C,8CAA8C;QAC9C,qEAAqE;QACrE,EAAE;QACF,WAAW;QACX,KAAK,OAAO,EAAE;QACd,KAAK,OAAO,OAAO;QACnB,KAAK,OAAO,4CAA4C;QACxD,KAAK,OAAO,8BAA8B;QAC1C,KAAK,OAAO,sCAAsC;QAClD,EAAE;QACF,kBAAkB,WAAW,OAAO,iBAAiB,GAAG;QACxD,uBAAuB,OAAO,eAAe,WAAW,GAAG;KAC9D,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;AACjB,CAAC","sourcesContent":["import chalk from '../packages/chalk.js'\nimport { packageName, cliName, configFileNames, configLocations } from '../config.js'\nimport { out } from '../output.js'\n\nexport function help(): void {\n const configNames = configFileNames\n .map(name => `${name}.{js,cjs,mjs}`)\n .join(' or ')\n const configDirectories = configLocations\n .map(location => location === '' ? 'the project root' : `${location}/`)\n .join(' or ')\n\n out([\n chalk.brightblue(packageName),\n '',\n 'Usage:',\n ` ${cliName} [watch] [options]`,\n ` ${cliName} once [options]`,\n ` ${cliName} init`,\n ` ${cliName} help`,\n '',\n 'Commands:',\n ' watch Run tests and watch for related file changes (default)',\n ' once Run the test suite once and exit',\n ' init Create an initial configuration file',\n ' help Show this help',\n '',\n 'Options:',\n ' -c, --config <file> Use a specific configuration file',\n ' -t, --test-files <glob> Override the configured test pattern',\n ' -f, --filter <glob> Further constrain the configured test pattern',\n ' -d, --filter-describe <substring> Run matching describe blocks',\n ' -i, --filter-it <substring> Run matching tests',\n ' -s, --status-file <file> Write the latest watch run status to a file',\n ' --agent Report a watch session as single agent readable lines',\n '',\n 'Watch controls:',\n ' r/l + Enter Re-run the last set of tests',\n ' a + Enter Re-run all tests',\n ' f + Enter Re-run failing tests',\n ' Set watch.ttyActionsOnKeypress to true to run these without Enter',\n '',\n 'Examples:',\n ` ${cliName}`,\n ` ${cliName} once`,\n ` ${cliName} watch --test-files \"**/*.focused.test.js\"`,\n ` ${cliName} once --filter \"**/users/**\"`,\n ` ${cliName} once --config config/sxyt.config.js`,\n '',\n `Configuration: ${configNames} in ${configDirectories}.`,\n `Executable aliases: ${cliName}, sxy-test, ${packageName}.`\n ].join('\\n'))\n}\n"]}
1
+ {"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/cli/help.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,sBAAsB,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACrF,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAElC,MAAM,UAAU,IAAI;IAChB,MAAM,WAAW,GAAG,eAAe;SAC9B,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,eAAe,CAAC;SACnC,IAAI,CAAC,MAAM,CAAC,CAAA;IACjB,MAAM,iBAAiB,GAAG,eAAe;SACpC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,KAAK,EAAE,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,GAAG,QAAQ,GAAG,CAAC;SACtE,IAAI,CAAC,MAAM,CAAC,CAAA;IAEjB,GAAG,CAAC;QACA,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC;QAC7B,EAAE;QACF,QAAQ;QACR,KAAK,OAAO,oBAAoB;QAChC,KAAK,OAAO,iBAAiB;QAC7B,KAAK,OAAO,OAAO;QACnB,KAAK,OAAO,OAAO;QACnB,EAAE;QACF,WAAW;QACX,iEAAiE;QACjE,2CAA2C;QAC3C,+CAA+C;QAC/C,yBAAyB;QACzB,EAAE;QACF,UAAU;QACV,wEAAwE;QACxE,2EAA2E;QAC3E,oFAAoF;QACpF,mEAAmE;QACnE,yDAAyD;QACzD,4EAA4E;QAC5E,kFAAkF;QAClF,oFAAoF;QACpF,sEAAsE;QACtE,EAAE;QACF,iBAAiB;QACjB,sDAAsD;QACtD,0CAA0C;QAC1C,8CAA8C;QAC9C,qEAAqE;QACrE,EAAE;QACF,WAAW;QACX,KAAK,OAAO,EAAE;QACd,KAAK,OAAO,OAAO;QACnB,KAAK,OAAO,4CAA4C;QACxD,KAAK,OAAO,8BAA8B;QAC1C,KAAK,OAAO,sCAAsC;QAClD,EAAE;QACF,kBAAkB,WAAW,OAAO,iBAAiB,GAAG;QACxD,uBAAuB,OAAO,eAAe,WAAW,GAAG;KAC9D,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;AACjB,CAAC","sourcesContent":["import chalk from '../packages/chalk.js'\nimport { packageName, cliName, configFileNames, configLocations } from '../config.js'\nimport { out } from '../output.js'\n\nexport function help(): void {\n const configNames = configFileNames\n .map(name => `${name}.{js,cjs,mjs}`)\n .join(' or ')\n const configDirectories = configLocations\n .map(location => location === '' ? 'the project root' : `${location}/`)\n .join(' or ')\n\n out([\n chalk.brightblue(packageName),\n '',\n 'Usage:',\n ` ${cliName} [watch] [options]`,\n ` ${cliName} once [options]`,\n ` ${cliName} init`,\n ` ${cliName} help`,\n '',\n 'Commands:',\n ' watch Run tests and watch for related file changes (default)',\n ' once Run the test suite once and exit',\n ' init Create an initial configuration file',\n ' help Show this help',\n '',\n 'Options:',\n ' -c, --config <file> Use a specific configuration file',\n ' -t, --test-files <glob> Override the configured test pattern',\n ' -f, --filter <glob> Further constrain the configured test pattern',\n ' -d, --filter-describe <substring> Run matching describe blocks',\n ' -i, --filter-it <substring> Run matching tests',\n ' -x, --fail-fast Stop at the first failure (once mode)',\n ' -s, --status-file <file> Write the latest watch run status to a file',\n ' --agent Report the run as single agent readable lines',\n ' -h, --help Show this help, for any command',\n '',\n 'Watch controls:',\n ' r/l + Enter Re-run the last set of tests',\n ' a + Enter Re-run all tests',\n ' f + Enter Re-run failing tests',\n ' Set watch.ttyActionsOnKeypress to true to run these without Enter',\n '',\n 'Examples:',\n ` ${cliName}`,\n ` ${cliName} once`,\n ` ${cliName} watch --test-files \"**/*.focused.test.js\"`,\n ` ${cliName} once --filter \"**/users/**\"`,\n ` ${cliName} once --config config/sxyt.config.js`,\n '',\n `Configuration: ${configNames} in ${configDirectories}.`,\n `Executable aliases: ${cliName}, sxy-test, ${packageName}.`\n ].join('\\n'))\n}\n"]}
package/dist/cli/index.js CHANGED
@@ -1,27 +1,7 @@
1
1
  #!/usr/bin/env node
2
- const args = process.argv.slice(2);
3
- if (args.length > 0) {
4
- const command = args[0];
5
- switch (command) { // eslint-disable-line @typescript-eslint/switch-exhaustiveness-check
6
- case 'init':
7
- case 'once':
8
- case 'watch':
9
- case 'help':
10
- await doCommand(command, args.slice(1));
11
- break;
12
- case '--init':
13
- case '--once':
14
- case '--watch':
15
- case '--help':
16
- await doCommand(command.substring(2), args.slice(1));
17
- break;
18
- default:
19
- await doCommand('watch', args);
20
- }
21
- }
22
- else {
23
- await doCommand('watch', args);
24
- }
2
+ const { resolveCommand } = await import('./lib/resolveCommand.js');
3
+ const { command, commandArgs } = resolveCommand(process.argv.slice(2));
4
+ await doCommand(command, commandArgs);
25
5
  async function doCommand(command, args) {
26
6
  global.__sxyt_commandLineArguments = args;
27
7
  // command-named dynamic import - no static type can express "a module matching an unknown command string"
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AAEA,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AAElC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;IAClB,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;IACvB,QAAQ,OAAO,EAAE,CAAC,CAAC,qEAAqE;QACpF,KAAK,MAAM,CAAC;QACZ,KAAK,MAAM,CAAC;QACZ,KAAK,OAAO,CAAC;QACb,KAAK,MAAM;YACP,MAAM,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;YACvC,MAAK;QACT,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,SAAS,CAAC;QACf,KAAK,QAAQ;YACT,MAAM,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;YACpD,MAAK;QACT;YACI,MAAM,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;IACtC,CAAC;AACL,CAAC;KAAM,CAAC;IACJ,MAAM,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AAClC,CAAC;AAED,KAAK,UAAU,SAAS,CAAC,OAAe,EAAE,IAAc;IACpD,MAAM,CAAC,2BAA2B,GAAG,IAAI,CAAA;IACzC,0GAA0G;IAC1G,mEAAmE;IACnE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,KAAK,OAAO,KAAK,CAAC,CAAA;IAC9C,yGAAyG;IACzG,MAAM,MAAM,CAAC,OAAO,CAAC,EAAE,CAAA;IACvB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACnB,CAAC","sourcesContent":["#!/usr/bin/env node\n\nconst args = process.argv.slice(2)\n\nif (args.length > 0) {\n const command = args[0]\n switch (command) { // eslint-disable-line @typescript-eslint/switch-exhaustiveness-check\n case 'init':\n case 'once':\n case 'watch':\n case 'help':\n await doCommand(command, args.slice(1))\n break\n case '--init':\n case '--once':\n case '--watch':\n case '--help':\n await doCommand(command.substring(2), args.slice(1))\n break\n default:\n await doCommand('watch', args)\n }\n} else {\n await doCommand('watch', args)\n}\n\nasync function doCommand(command: string, args: string[]): Promise<void> {\n global.__sxyt_commandLineArguments = args\n // command-named dynamic import - no static type can express \"a module matching an unknown command string\"\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const module = await import(`./${command}.js`)\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access\n await module[command]()\n process.exit(0)\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AAEA,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC,yBAAyB,CAAC,CAAA;AAElE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;AAEtE,MAAM,SAAS,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;AAErC,KAAK,UAAU,SAAS,CAAC,OAAe,EAAE,IAAc;IACpD,MAAM,CAAC,2BAA2B,GAAG,IAAI,CAAA;IACzC,0GAA0G;IAC1G,mEAAmE;IACnE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,KAAK,OAAO,KAAK,CAAC,CAAA;IAC9C,yGAAyG;IACzG,MAAM,MAAM,CAAC,OAAO,CAAC,EAAE,CAAA;IACvB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACnB,CAAC","sourcesContent":["#!/usr/bin/env node\n\nconst { resolveCommand } = await import('./lib/resolveCommand.js')\n\nconst { command, commandArgs } = resolveCommand(process.argv.slice(2))\n\nawait doCommand(command, commandArgs)\n\nasync function doCommand(command: string, args: string[]): Promise<void> {\n global.__sxyt_commandLineArguments = args\n // command-named dynamic import - no static type can express \"a module matching an unknown command string\"\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const module = await import(`./${command}.js`)\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access\n await module[command]()\n process.exit(0)\n}\n"]}
package/dist/cli/init.js CHANGED
@@ -64,6 +64,7 @@ export default {
64
64
  // whether to show the full error trace when an error occurs in a test file
65
65
  showErrorTrace: false,
66
66
 
67
+
67
68
  // tasks to run on startup
68
69
  // accepts a function, file location (relative to project base), or array of functions and or files
69
70
  setup: undefined,
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,KAAK,MAAM,sBAAsB,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACrF,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAClC,OAAO,EAAE,MAAM,IAAI,CAAA;AAEnB,MAAM,UAAU,IAAI;IAChB,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;IAEhC,KAAK,MAAM,cAAc,IAAI,eAAe,EAAE,CAAC;QAC3C,KAAK,MAAM,cAAc,IAAI,eAAe,EAAE,CAAC;YAC3C,IAAI,GAAG,CAAA;YACP,GAAG,GAAG,IAAI,CAAC,UAAU,EAAE,cAAc,EAAE,cAAc,GAAG,KAAK,CAAC,CAAA;YAC9D,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBACrB,mBAAmB,CAAC,GAAG,CAAC,CAAA;YAC5B,CAAC;YACD,GAAG,GAAG,IAAI,CAAC,UAAU,EAAE,cAAc,EAAE,cAAc,GAAG,MAAM,CAAC,CAAA;YAC/D,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBACrB,mBAAmB,CAAC,GAAG,CAAC,CAAA;YAC5B,CAAC;YACD,GAAG,GAAG,IAAI,CAAC,UAAU,EAAE,cAAc,EAAE,cAAc,GAAG,MAAM,CAAC,CAA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AAC,aAAa,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAA;IAEjD,GAAG,CAAC,KAAK,CAAC,WAAW,CAAA,IAAI,WAAW,sBAAsB,GAAG,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAA;AAC9F,CAAC","sourcesContent":["import { join } from 'path'\nimport chalk from '../packages/chalk.js'\nimport { packageName, cliName, configFileNames, configLocations } from '../config.js'\nimport { out } from '../output.js'\nimport fs from 'fs'\n\nexport function init(): void {\n const projectDir = process.cwd()\n\n for (const configLocation of configLocations) {\n for (const configFileName of configFileNames) {\n let loc\n loc = join(projectDir, configLocation, configFileName + '.js')\n if (fs.existsSync(loc)) {\n configAlreadyExists(loc)\n }\n loc = join(projectDir, configLocation, configFileName + '.cjs')\n if (fs.existsSync(loc)) {\n configAlreadyExists(loc)\n }\n loc = join(projectDir, configLocation, configFileName + '.mjs')\n if (fs.existsSync(loc)) {\n configAlreadyExists(loc)\n }\n }\n }\n\n function configAlreadyExists(loc: string): void {\n out(chalk.orange`[${packageName}] A matching config already exists at ${loc}`\n + `\\nPlease remove this config before generating a new one with \\`${cliName} init\\``)\n }\n\n const projectPackageJsonLocation = join(projectDir, 'package.json')\n if (!fs.existsSync(projectPackageJsonLocation)) {\n out(chalk.orange`[${packageName}] No package.json exists in this location`\n + '\\nPlease initialise the package with `yarn init` on `npm init`'\n + ' before running this command, and run this command from the project root folder')\n }\n\n const packageJsonRaw = fs.readFileSync(projectPackageJsonLocation, 'utf8')\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const packageJson: { type?: string } = JSON.parse(packageJsonRaw)\n\n const targetConfigName = (packageJson.type === 'module')\n // ES6 module\n ? join(projectDir, configLocations[0] ?? '', configFileNames[0] + '.js')\n // common\n : join(projectDir, configLocations[0] ?? '', configFileNames[0] + '.mjs')\n\n const defaultConfig =\n`\n// @ts-check\n\n/** @satisfies {import('sxy-test-runner').Config} */\nexport default {\n\n // base folder for tests match and ignore patterns\n testsBase: '.',\n\n // glob pattern or array of glob patterns of test files\n tests: [\n '**/*.sxyt.{js,mjs,jsx}',\n '**/*.test.{js,mjs,jsx}',\n '**/*.spec.{js,mjs,jsx}',\n '**/tests?/*.{js,mjs,jsx}',\n '**/__tests?__/*.{js,mjs,jsx}'\n ],\n\n // glob pattern or array of patterns of test files to ignore\n testsIgnore: ['**/node_modules/**'],\n\n // whether to show the full error trace when an error occurs in a test file\n showErrorTrace: false,\n\n // tasks to run on startup\n // accepts a function, file location (relative to project base), or array of functions and or files\n setup: undefined,\n\n // tasks to run before each test file is run\n beforeEachFile: undefined,\n\n // tasks to run after each test file is run\n afterEachFile: undefined,\n\n // tasks to run before each describe block is processed\n // if the function returns an object with named properties, or the file exports named exports,\n // these will be passed to the callback function in argument 0, and can be access by destructruing e.g.\n // describe('thing', ({exportA, exportB}) => { it('should', ...) })\n beforeEachDescribe: undefined,\n\n // tasks to run after each describe block\n afterEachDescribe: undefined,\n\n // tasks to run before each it/test block\n // function returns and file exports will be passed to the it/test block as with describe above, e.g.\n // it('should', ({exportA, exportB}) => { assert('something') })\n beforeEachTest: undefined,\n\n // tasks to run after each it/test block\n afterEachTest: undefined,\n\n // how to execute the different parts of test files\n execution: {\n\n // run test files in 'parallel' or 'sequential'ly\n files: 'sequential',\n\n // run describe blocks within a test file in 'parallel' or 'sequential'ly\n describes: 'sequential',\n\n // run it/test blocks within a describe blocks in 'parallel' or 'sequential'ly\n tests: 'sequential'\n\n },\n\n // watch mode configurations\n watch: {\n\n //// the base directory to watch files in\n watchFilesBase: '.',\n\n //// glob filter or array of glob filters of files to watch\n watchFiles: '**/*.js',\n\n //// glob filter or array of globl filters of files to ignore\n watchFilesIgnore: '**/node_modules/**',\n\n // run all tests when starting the watcher\n runAllOnStartup: true,\n\n // re run all previously failed tests on each test run, until they pass\n reRunFailingTests: true,\n\n // evaluate the dependencies of each test file, and re-run that test file only when they change. \n // Set this to false to re-run everything on any change\n dependencyEvaluation: true,\n\n // run watch mode keyboard commands immediately, without waiting for Enter\n ttyActionsOnKeypress: false,\n\n // file to write the latest run status to, or false for none\n statusFile: false,\n\n // report the session as single agent readable lines instead of the usual output\n agent: false,\n\n },\n\n}`\n\n fs.writeFileSync(targetConfigName, defaultConfig)\n\n out(chalk.mediumgreen`[${packageName}] Created config at ` + chalk.blue(targetConfigName))\n}\n"]}
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,KAAK,MAAM,sBAAsB,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACrF,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAClC,OAAO,EAAE,MAAM,IAAI,CAAA;AAEnB,MAAM,UAAU,IAAI;IAChB,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;IAEhC,KAAK,MAAM,cAAc,IAAI,eAAe,EAAE,CAAC;QAC3C,KAAK,MAAM,cAAc,IAAI,eAAe,EAAE,CAAC;YAC3C,IAAI,GAAG,CAAA;YACP,GAAG,GAAG,IAAI,CAAC,UAAU,EAAE,cAAc,EAAE,cAAc,GAAG,KAAK,CAAC,CAAA;YAC9D,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBACrB,mBAAmB,CAAC,GAAG,CAAC,CAAA;YAC5B,CAAC;YACD,GAAG,GAAG,IAAI,CAAC,UAAU,EAAE,cAAc,EAAE,cAAc,GAAG,MAAM,CAAC,CAAA;YAC/D,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBACrB,mBAAmB,CAAC,GAAG,CAAC,CAAA;YAC5B,CAAC;YACD,GAAG,GAAG,IAAI,CAAC,UAAU,EAAE,cAAc,EAAE,cAAc,GAAG,MAAM,CAAC,CAAA;YAC/D,IAAI,EA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gBAAgB,EAAE,aAAa,CAAC,CAAA;IAEjD,GAAG,CAAC,KAAK,CAAC,WAAW,CAAA,IAAI,WAAW,sBAAsB,GAAG,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAA;AAC9F,CAAC","sourcesContent":["import { join } from 'path'\nimport chalk from '../packages/chalk.js'\nimport { packageName, cliName, configFileNames, configLocations } from '../config.js'\nimport { out } from '../output.js'\nimport fs from 'fs'\n\nexport function init(): void {\n const projectDir = process.cwd()\n\n for (const configLocation of configLocations) {\n for (const configFileName of configFileNames) {\n let loc\n loc = join(projectDir, configLocation, configFileName + '.js')\n if (fs.existsSync(loc)) {\n configAlreadyExists(loc)\n }\n loc = join(projectDir, configLocation, configFileName + '.cjs')\n if (fs.existsSync(loc)) {\n configAlreadyExists(loc)\n }\n loc = join(projectDir, configLocation, configFileName + '.mjs')\n if (fs.existsSync(loc)) {\n configAlreadyExists(loc)\n }\n }\n }\n\n function configAlreadyExists(loc: string): void {\n out(chalk.orange`[${packageName}] A matching config already exists at ${loc}`\n + `\\nPlease remove this config before generating a new one with \\`${cliName} init\\``)\n }\n\n const projectPackageJsonLocation = join(projectDir, 'package.json')\n if (!fs.existsSync(projectPackageJsonLocation)) {\n out(chalk.orange`[${packageName}] No package.json exists in this location`\n + '\\nPlease initialise the package with `yarn init` on `npm init`'\n + ' before running this command, and run this command from the project root folder')\n }\n\n const packageJsonRaw = fs.readFileSync(projectPackageJsonLocation, 'utf8')\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const packageJson: { type?: string } = JSON.parse(packageJsonRaw)\n\n const targetConfigName = (packageJson.type === 'module')\n // ES6 module\n ? join(projectDir, configLocations[0] ?? '', configFileNames[0] + '.js')\n // common\n : join(projectDir, configLocations[0] ?? '', configFileNames[0] + '.mjs')\n\n const defaultConfig =\n`\n// @ts-check\n\n/** @satisfies {import('sxy-test-runner').Config} */\nexport default {\n\n // base folder for tests match and ignore patterns\n testsBase: '.',\n\n // glob pattern or array of glob patterns of test files\n tests: [\n '**/*.sxyt.{js,mjs,jsx}',\n '**/*.test.{js,mjs,jsx}',\n '**/*.spec.{js,mjs,jsx}',\n '**/tests?/*.{js,mjs,jsx}',\n '**/__tests?__/*.{js,mjs,jsx}'\n ],\n\n // glob pattern or array of patterns of test files to ignore\n testsIgnore: ['**/node_modules/**'],\n\n // whether to show the full error trace when an error occurs in a test file\n showErrorTrace: false,\n\n\n // tasks to run on startup\n // accepts a function, file location (relative to project base), or array of functions and or files\n setup: undefined,\n\n // tasks to run before each test file is run\n beforeEachFile: undefined,\n\n // tasks to run after each test file is run\n afterEachFile: undefined,\n\n // tasks to run before each describe block is processed\n // if the function returns an object with named properties, or the file exports named exports,\n // these will be passed to the callback function in argument 0, and can be access by destructruing e.g.\n // describe('thing', ({exportA, exportB}) => { it('should', ...) })\n beforeEachDescribe: undefined,\n\n // tasks to run after each describe block\n afterEachDescribe: undefined,\n\n // tasks to run before each it/test block\n // function returns and file exports will be passed to the it/test block as with describe above, e.g.\n // it('should', ({exportA, exportB}) => { assert('something') })\n beforeEachTest: undefined,\n\n // tasks to run after each it/test block\n afterEachTest: undefined,\n\n // how to execute the different parts of test files\n execution: {\n\n // run test files in 'parallel' or 'sequential'ly\n files: 'sequential',\n\n // run describe blocks within a test file in 'parallel' or 'sequential'ly\n describes: 'sequential',\n\n // run it/test blocks within a describe blocks in 'parallel' or 'sequential'ly\n tests: 'sequential'\n\n },\n\n // watch mode configurations\n watch: {\n\n //// the base directory to watch files in\n watchFilesBase: '.',\n\n //// glob filter or array of glob filters of files to watch\n watchFiles: '**/*.js',\n\n //// glob filter or array of globl filters of files to ignore\n watchFilesIgnore: '**/node_modules/**',\n\n // run all tests when starting the watcher\n runAllOnStartup: true,\n\n // re run all previously failed tests on each test run, until they pass\n reRunFailingTests: true,\n\n // evaluate the dependencies of each test file, and re-run that test file only when they change. \n // Set this to false to re-run everything on any change\n dependencyEvaluation: true,\n\n // run watch mode keyboard commands immediately, without waiting for Enter\n ttyActionsOnKeypress: false,\n\n // file to write the latest run status to, or false for none\n statusFile: false,\n\n // report the session as single agent readable lines instead of the usual output\n agent: false,\n\n },\n\n}`\n\n fs.writeFileSync(targetConfigName, defaultConfig)\n\n out(chalk.mediumgreen`[${packageName}] Created config at ` + chalk.blue(targetConfigName))\n}\n"]}
@@ -2,7 +2,7 @@ import type { FinalConfig, TestsResultsSummary } from '../../types.js';
2
2
  import type { FailureEntry } from './failureEntries.js';
3
3
  import type { RunType } from './reRunManager.js';
4
4
  import type { StatusCode } from './statusFile.js';
5
- export type RunReason = RunType | 'startup';
5
+ export type RunReason = RunType | 'startup' | 'once';
6
6
  export declare function agentEnabled(config: FinalConfig): boolean;
7
7
  export declare function agentInit(enabled: boolean): void;
8
8
  export declare function agentFound(config: FinalConfig, files: number): void;
@@ -56,8 +56,13 @@ export function agentRunStart(config, files) {
56
56
  // what the run was built from. A reader needs this to know how far the run's own `code`
57
57
  // generalises - only a run covering everything can speak for the whole suite.
58
58
  function runScope(config) {
59
+ // known before the run starts: fail fast means it is built to stop early, so it cannot
60
+ // promise to have covered anything beyond the first failure
61
+ if (config.failFast)
62
+ return 'until-first-failure';
59
63
  switch (nextRunReason) {
60
64
  case 'startup':
65
+ case 'once':
61
66
  case 'all': return 'all';
62
67
  case 'last': return 'last';
63
68
  case 'failed': return 'failing';
@@ -1 +1 @@
1
- {"version":3,"file":"agentReport.js","sourceRoot":"","sources":["../../../src/cli/lib/agentReport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAOhD,2FAA2F;AAC3F,+EAA+E;AAC/E,EAAE;AACF,mDAAmD;AACnD,EAAE;AACF,4FAA4F;AAC5F,kFAAkF;AAElF,MAAM,MAAM,GAAG,QAAQ,CAAA;AAIvB,IAAI,UAAU,GAAG,CAAC,CAAA;AAClB,4FAA4F;AAC5F,+CAA+C;AAC/C,IAAI,aAAa,GAAc,SAAS,CAAA;AAIxC,SAA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,CAAC,MAAmB,EAAE,KAAa;IAC5D,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;QAAE,OAAM;IACjC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAA;AACxC,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,MAAmB,EAAE,IAAY,EAAE,KAAa;IACxE,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;QAAE,OAAM;IACjC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;AACxE,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,cAAc;IAC1B,8DAA8D;AAClE,CAAC","sourcesContent":["import { out as mainOut } from '../../output.js'\n\nimport type { FinalConfig, TestsResultsSummary } from '../../types.js'\nimport type { FailureEntry } from './failureEntries.js'\nimport type { RunType } from './reRunManager.js'\nimport type { StatusCode } from './statusFile.js'\n\n// Agent mode reports a watch session as a stream of single lines, for a reader tailing the\n// process rather than watching the terminal. Every line is one complete event:\n//\n// [sxyt] <event> | <key>=<value> | <key>=<value>\n//\n// Values are never quoted, so free text is flattened to keep the grammar intact - one event\n// can never span two lines, and a stray `|` can never look like a field boundary.\n\nconst prefix = '[sxyt]'\n\nexport type RunReason = RunType | 'startup'\n\nlet runCounter = 0\n// requestRun sets this before handing a run to runTests; the initial run never goes through\n// the queue, so 'startup' is the right default\nlet nextRunReason: RunReason = 'startup'\n\ntype Field = [string, string | number]\n\nfunction emit(event: string, fields: Field[] = []): void {\n mainOut(prefix + ` ${event}` + fields.map(([key, value]) => ` | ${key}=${value}`).join(''))\n}\n\n// newlines would split one event across two lines, and a `|` would read as a field boundary\nfunction flatten(text: string): string {\n return text.replace(/\\s*[\\r\\n]+\\s*/g, ' ').replace(/\\|/g, '/').trim()\n}\n\nexport function agentEnabled(config: FinalConfig): boolean {\n return config.watch.agent\n}\n\n// the process is up, before the config is even loaded - so a slow startup is\n// distinguishable from one that never began. Takes the flag rather than the config for that\n// reason, and resets the counters so repeated in process sessions start from 1.\nexport function agentInit(enabled: boolean): void {\n runCounter = 0\n nextRunReason = 'startup'\n if (!enabled) return\n emit('init', [['pid', process.pid]])\n}\n\nexport function agentFound(config: FinalConfig, files: number): void {\n if (!agentEnabled(config)) return\n emit('found', [['files', files]])\n}\n\nexport function agentSetRunReason(reason: RunReason): void {\n nextRunReason = reason\n}\n\n// claims the next run number and announces the run, so a reader knows work is in flight\n// before any result arrives\nexport function agentRunStart(config: FinalConfig, files: number): number {\n if (!agentEnabled(config)) return 0\n runCounter++\n emit('run', [\n ['n', runCounter],\n ['files', files],\n ['why', nextRunReason],\n ['covers', runScope(config)]\n ])\n return runCounter\n}\n\n// what the run was built from. A reader needs this to know how far the run's own `code`\n// generalises - only a run covering everything can speak for the whole suite.\nfunction runScope(config: FinalConfig): string {\n switch (nextRunReason) {\n case 'startup':\n case 'all': return 'all'\n case 'last': return 'last'\n case 'failed': return 'failing'\n case 'auto': {\n // with dependency evaluation off a change runs the whole suite, so an auto run\n // carries the same weight as a startup one\n if (!config.watch.dependencyEvaluation) return 'all'\n // the reRunFailingTests case is the one worth spelling out: without it a run says\n // nothing about files that were already failing\n return (config.watch.reRunFailingTests) ? 'changed+failing' : 'changed'\n }\n default: return 'changed'\n }\n}\n\n// failures are emitted before the run's done line, so done is a complete end of run marker\nexport function agentFailure(config: FinalConfig, run: number, entry: FailureEntry): void {\n if (!agentEnabled(config)) return\n emit('fail', [\n ['n', run],\n ['file', flatten(entry.file)],\n ...(entry.describe === undefined)\n ? []\n : [['describe', flatten(entry.describe)] as Field],\n ...(entry.test === undefined) ? [] : [['test', flatten(entry.test)] as Field],\n ['error', flatten(entry.error)]\n ])\n}\n\n// `failing` counts the test files still failing across the whole session, not just this\n// run. A watch re-run usually covers only the changed files, so its own tallies can read as\n// a clean pass while the suite is still broken elsewhere.\nexport function agentDone(\n config: FinalConfig,\n run: number,\n code: StatusCode,\n description: string,\n summary: TestsResultsSummary | null,\n durationMs: number,\n failingFiles: number\n): void {\n if (!agentEnabled(config)) return\n emit('done', [\n ['n', run],\n ['code', code],\n ['desc', flatten(description)],\n ...(summary === null) ? [] : [\n ['tests', `${summary.itsPasses}/${summary.itsTotal}`] as Field,\n ['items', `${summary.describesPasses}/${summary.describesTotal}`] as Field,\n ['files', `${summary.passes}/${summary.total}`] as Field\n ],\n ['failing', failingFiles],\n ['ms', durationMs]\n ])\n}\n\nexport function agentWatching(config: FinalConfig, files: number): void {\n if (!agentEnabled(config)) return\n emit('watching', [['files', files]])\n}\n\nexport function agentChange(config: FinalConfig, file: string, event: string): void {\n if (!agentEnabled(config)) return\n emit('change', [['file', flatten(file)], ['event', flatten(event)]])\n}\n\n// agent mode owns stdout, so the ordinary coloured output is routed into a sink\nexport function agentSilentOut(): void {\n // deliberately nothing - the agent lines are the whole stream\n}\n"]}
1
+ {"version":3,"file":"agentReport.js","sourceRoot":"","sources":["../../../src/cli/lib/agentReport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAOhD,2FAA2F;AAC3F,+EAA+E;AAC/E,EAAE;AACF,mDAAmD;AACnD,EAAE;AACF,4FAA4F;AAC5F,kFAAkF;AAElF,MAAM,MAAM,GAAG,QAAQ,CAAA;AAIvB,IAAI,UAAU,GAAG,CAAC,CAAA;AAClB,4FAA4F;AAC5F,+CAA+C;AAC/C,IAAI,aAAa,GAAc,SAAS,CAAA;AAIxC,SAAS,IAAI,CAAC,KAAa,EAAE,SAAkB,EAAE;IAC7C,OAAO,CAAC,MAAM,GAAG,IAAI,KAAK,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC,CAAC,I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U,EAAE,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAA;AACxC,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,MAAmB,EAAE,IAAY,EAAE,KAAa;IACxE,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;QAAE,OAAM;IACjC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;AACxE,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,cAAc;IAC1B,8DAA8D;AAClE,CAAC","sourcesContent":["import { out as mainOut } from '../../output.js'\n\nimport type { FinalConfig, TestsResultsSummary } from '../../types.js'\nimport type { FailureEntry } from './failureEntries.js'\nimport type { RunType } from './reRunManager.js'\nimport type { StatusCode } from './statusFile.js'\n\n// Agent mode reports a watch session as a stream of single lines, for a reader tailing the\n// process rather than watching the terminal. Every line is one complete event:\n//\n// [sxyt] <event> | <key>=<value> | <key>=<value>\n//\n// Values are never quoted, so free text is flattened to keep the grammar intact - one event\n// can never span two lines, and a stray `|` can never look like a field boundary.\n\nconst prefix = '[sxyt]'\n\nexport type RunReason = RunType | 'startup' | 'once'\n\nlet runCounter = 0\n// requestRun sets this before handing a run to runTests; the initial run never goes through\n// the queue, so 'startup' is the right default\nlet nextRunReason: RunReason = 'startup'\n\ntype Field = [string, string | number]\n\nfunction emit(event: string, fields: Field[] = []): void {\n mainOut(prefix + ` ${event}` + fields.map(([key, value]) => ` | ${key}=${value}`).join(''))\n}\n\n// newlines would split one event across two lines, and a `|` would read as a field boundary\nfunction flatten(text: string): string {\n return text.replace(/\\s*[\\r\\n]+\\s*/g, ' ').replace(/\\|/g, '/').trim()\n}\n\nexport function agentEnabled(config: FinalConfig): boolean {\n return config.watch.agent\n}\n\n// the process is up, before the config is even loaded - so a slow startup is\n// distinguishable from one that never began. Takes the flag rather than the config for that\n// reason, and resets the counters so repeated in process sessions start from 1.\nexport function agentInit(enabled: boolean): void {\n runCounter = 0\n nextRunReason = 'startup'\n if (!enabled) return\n emit('init', [['pid', process.pid]])\n}\n\nexport function agentFound(config: FinalConfig, files: number): void {\n if (!agentEnabled(config)) return\n emit('found', [['files', files]])\n}\n\nexport function agentSetRunReason(reason: RunReason): void {\n nextRunReason = reason\n}\n\n// claims the next run number and announces the run, so a reader knows work is in flight\n// before any result arrives\nexport function agentRunStart(config: FinalConfig, files: number): number {\n if (!agentEnabled(config)) return 0\n runCounter++\n emit('run', [\n ['n', runCounter],\n ['files', files],\n ['why', nextRunReason],\n ['covers', runScope(config)]\n ])\n return runCounter\n}\n\n// what the run was built from. A reader needs this to know how far the run's own `code`\n// generalises - only a run covering everything can speak for the whole suite.\nfunction runScope(config: FinalConfig): string {\n // known before the run starts: fail fast means it is built to stop early, so it cannot\n // promise to have covered anything beyond the first failure\n if (config.failFast) return 'until-first-failure'\n\n switch (nextRunReason) {\n case 'startup':\n case 'once':\n case 'all': return 'all'\n case 'last': return 'last'\n case 'failed': return 'failing'\n case 'auto': {\n // with dependency evaluation off a change runs the whole suite, so an auto run\n // carries the same weight as a startup one\n if (!config.watch.dependencyEvaluation) return 'all'\n // the reRunFailingTests case is the one worth spelling out: without it a run says\n // nothing about files that were already failing\n return (config.watch.reRunFailingTests) ? 'changed+failing' : 'changed'\n }\n default: return 'changed'\n }\n}\n\n// failures are emitted before the run's done line, so done is a complete end of run marker\nexport function agentFailure(config: FinalConfig, run: number, entry: FailureEntry): void {\n if (!agentEnabled(config)) return\n emit('fail', [\n ['n', run],\n ['file', flatten(entry.file)],\n ...(entry.describe === undefined)\n ? []\n : [['describe', flatten(entry.describe)] as Field],\n ...(entry.test === undefined) ? [] : [['test', flatten(entry.test)] as Field],\n ['error', flatten(entry.error)]\n ])\n}\n\n// `failing` counts the test files still failing across the whole session, not just this\n// run. A watch re-run usually covers only the changed files, so its own tallies can read as\n// a clean pass while the suite is still broken elsewhere.\nexport function agentDone(\n config: FinalConfig,\n run: number,\n code: StatusCode,\n description: string,\n summary: TestsResultsSummary | null,\n durationMs: number,\n failingFiles: number\n): void {\n if (!agentEnabled(config)) return\n emit('done', [\n ['n', run],\n ['code', code],\n ['desc', flatten(description)],\n ...(summary === null) ? [] : [\n ['tests', `${summary.itsPasses}/${summary.itsTotal}`] as Field,\n ['items', `${summary.describesPasses}/${summary.describesTotal}`] as Field,\n ['files', `${summary.passes}/${summary.total}`] as Field\n ],\n ['failing', failingFiles],\n ['ms', durationMs]\n ])\n}\n\nexport function agentWatching(config: FinalConfig, files: number): void {\n if (!agentEnabled(config)) return\n emit('watching', [['files', files]])\n}\n\nexport function agentChange(config: FinalConfig, file: string, event: string): void {\n if (!agentEnabled(config)) return\n emit('change', [['file', flatten(file)], ['event', flatten(event)]])\n}\n\n// agent mode owns stdout, so the ordinary coloured output is routed into a sink\nexport function agentSilentOut(): void {\n // deliberately nothing - the agent lines are the whole stream\n}\n"]}
@@ -10,6 +10,7 @@ export const defaultConfig = {
10
10
  testsIgnore: ['**/node_modules/**'],
11
11
  showErrorTrace: false,
12
12
  compact: false,
13
+ failFast: false,
13
14
  execution: {
14
15
  files: 'sequential',
15
16
  describes: 'sequential',
@@ -1 +1 @@
1
- {"version":3,"file":"defaultConfig.js","sourceRoot":"","sources":["../../../src/cli/lib/defaultConfig.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAAgB;IACtC,SAAS,EAAE,GAAG;IACd,KAAK,EAAE;QACH,wBAAwB;QACxB,wBAAwB;QACxB,wBAAwB;QACxB,0BAA0B;QAC1B,8BAA8B;KACjC;IACD,WAAW,EAAE,CAAC,oBAAoB,CAAC;IACnC,cAAc,EAAE,KAAK;IACrB,OAAO,EAAE,KAAK;IACd,SAAS,EAAE;QACP,KAAK,EAAE,YAAY;QACnB,SAAS,EAAE,YAAY;QACvB,KAAK,EAAE,YAAY;KACtB;IACD,KAAK,EAAE;QACH,cAAc,EAAE,GAAG;QACnB,UAAU,EAAE,SAAS;QACrB,gBAAgB,EAAE,oBAAoB;QACtC,eAAe,EAAE,IAAI;QACrB,iBAAiB,EAAE,IAAI;QACvB,oBAAoB,EAAE,IAAI;QAC1B,oBAAoB,EAAE,KAAK;QAC3B,UAAU,EAAE,KAAK;QACjB,KAAK,EAAE,KAAK;KACf;CACJ,CAAA","sourcesContent":["import type { FinalConfig } from '../../types.js'\n\nexport const defaultConfig: FinalConfig = {\n testsBase: '.',\n tests: [\n '**/*.sxyt.{js,mjs,jsx}',\n '**/*.test.{js,mjs,jsx}',\n '**/*.spec.{js,mjs,jsx}',\n '**/tests?/*.{js,mjs,jsx}',\n '**/__tests?__/*.{js,mjs,jsx}'\n ],\n testsIgnore: ['**/node_modules/**'],\n showErrorTrace: false,\n compact: false,\n execution: {\n files: 'sequential',\n describes: 'sequential',\n tests: 'sequential'\n },\n watch: {\n watchFilesBase: '.',\n watchFiles: '**/*.js',\n watchFilesIgnore: '**/node_modules/**',\n runAllOnStartup: true,\n reRunFailingTests: true,\n dependencyEvaluation: true,\n ttyActionsOnKeypress: false,\n statusFile: false,\n agent: false\n }\n}\n"]}
1
+ {"version":3,"file":"defaultConfig.js","sourceRoot":"","sources":["../../../src/cli/lib/defaultConfig.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAAgB;IACtC,SAAS,EAAE,GAAG;IACd,KAAK,EAAE;QACH,wBAAwB;QACxB,wBAAwB;QACxB,wBAAwB;QACxB,0BAA0B;QAC1B,8BAA8B;KACjC;IACD,WAAW,EAAE,CAAC,oBAAoB,CAAC;IACnC,cAAc,EAAE,KAAK;IACrB,OAAO,EAAE,KAAK;IACd,QAAQ,EAAE,KAAK;IACf,SAAS,EAAE;QACP,KAAK,EAAE,YAAY;QACnB,SAAS,EAAE,YAAY;QACvB,KAAK,EAAE,YAAY;KACtB;IACD,KAAK,EAAE;QACH,cAAc,EAAE,GAAG;QACnB,UAAU,EAAE,SAAS;QACrB,gBAAgB,EAAE,oBAAoB;QACtC,eAAe,EAAE,IAAI;QACrB,iBAAiB,EAAE,IAAI;QACvB,oBAAoB,EAAE,IAAI;QAC1B,oBAAoB,EAAE,KAAK;QAC3B,UAAU,EAAE,KAAK;QACjB,KAAK,EAAE,KAAK;KACf;CACJ,CAAA","sourcesContent":["import type { FinalConfig } from '../../types.js'\n\nexport const defaultConfig: FinalConfig = {\n testsBase: '.',\n tests: [\n '**/*.sxyt.{js,mjs,jsx}',\n '**/*.test.{js,mjs,jsx}',\n '**/*.spec.{js,mjs,jsx}',\n '**/tests?/*.{js,mjs,jsx}',\n '**/__tests?__/*.{js,mjs,jsx}'\n ],\n testsIgnore: ['**/node_modules/**'],\n showErrorTrace: false,\n compact: false,\n failFast: false,\n execution: {\n files: 'sequential',\n describes: 'sequential',\n tests: 'sequential'\n },\n watch: {\n watchFilesBase: '.',\n watchFiles: '**/*.js',\n watchFilesIgnore: '**/node_modules/**',\n runAllOnStartup: true,\n reRunFailingTests: true,\n dependencyEvaluation: true,\n ttyActionsOnKeypress: false,\n statusFile: false,\n agent: false\n }\n}\n"]}
@@ -1,3 +1,4 @@
1
1
  import type { AllowedArguments, ParsedArguments } from '../../types.js';
2
+ export declare const usageErrorExitCode = 2;
2
3
  export declare function parseCommandLineArguments(allowedArguments: AllowedArguments): ParsedArguments;
3
4
  //# sourceMappingURL=parseCommandLineArguments.d.ts.map
@@ -2,13 +2,19 @@
2
2
  // once:
3
3
  // // --config configLocation
4
4
  import { reduce as objectReduce } from 'sxy-lib/objects.js';
5
- import { packageName } from '../../config.js';
5
+ import { packageName, cliName } from '../../config.js';
6
6
  import { log } from '../../output.js';
7
7
  import { getAllowedFlags } from './getAllowedFlags.js';
8
8
  import chalk from '../../packages/chalk.js';
9
+ // exit code for a usage error - distinct from the run's own 0/3/4/5, so a caller can tell
10
+ // "you asked for something I do not understand" from "the tests failed"
11
+ export const usageErrorExitCode = 2;
9
12
  export function parseCommandLineArguments(allowedArguments) {
10
13
  const allowedFlags = getAllowedFlags(allowedArguments);
11
14
  const returnArgs = {};
15
+ // collected rather than reported one at a time, so a mistyped command line is fixed in
16
+ // one go rather than one option per run
17
+ const unknownArgs = [];
12
18
  for (let position = 0; position < __sxyt_commandLineArguments.length; position++) {
13
19
  const arg = __sxyt_commandLineArguments[position];
14
20
  if (arg === undefined)
@@ -27,6 +33,7 @@ export function parseCommandLineArguments(allowedArguments) {
27
33
  }
28
34
  }
29
35
  else {
36
+ unknownArgs.push(`--${longFlag}`);
30
37
  log(chalk.mediumred(`[${packageName}] Unknown option --${longFlag}`));
31
38
  if (longFlag.length === 1
32
39
  && objectReduce(allowedArguments, (prev, _key, value) => {
@@ -56,6 +63,7 @@ export function parseCommandLineArguments(allowedArguments) {
56
63
  }
57
64
  }
58
65
  else {
66
+ unknownArgs.push(`-${shortFlag}`);
59
67
  log(chalk.mediumred(`[${packageName}] Unknown flag -${shortFlag}`));
60
68
  if (shortFlag.length > 1 && shortFlag in allowedArguments) {
61
69
  log(chalk.mediumred(`I think you meant --${shortFlag}`));
@@ -63,6 +71,12 @@ export function parseCommandLineArguments(allowedArguments) {
63
71
  }
64
72
  }
65
73
  }
74
+ // stop rather than run something other than what was asked for: an ignored option can
75
+ // mean the wrong tests, or a whole suite where a single filtered test was wanted
76
+ if (unknownArgs.length > 0) {
77
+ log(chalk.orange(`Run \`${cliName} help\` to see the available options.`));
78
+ process.exit(usageErrorExitCode);
79
+ }
66
80
  return returnArgs;
67
81
  }
68
82
  //# sourceMappingURL=parseCommandLineArguments.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parseCommandLineArguments.js","sourceRoot":"","sources":["../../../src/cli/lib/parseCommandLineArguments.ts"],"names":[],"mappings":"AAAA,SAAS;AACT,QAAQ;AACR,6BAA6B;AAG7B,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,G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D,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,uBAAuB,SAAS,EAAE,CAAC,CAAC,CAAA;gBAC5D,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IAED,OAAO,UAAU,CAAA;AACrB,CAAC","sourcesContent":["// watch:\n// once:\n// // --config configLocation\n\n\nimport { reduce as objectReduce } from 'sxy-lib/objects.js'\nimport { packageName } from '../../config.js'\nimport { log } from '../../output.js'\nimport type { AllowedArguments, ParsedArguments } from '../../types.js'\n\nimport { getAllowedFlags } from './getAllowedFlags.js'\nimport chalk from '../../packages/chalk.js'\n\nexport function parseCommandLineArguments(allowedArguments: AllowedArguments): ParsedArguments {\n const allowedFlags = getAllowedFlags(allowedArguments)\n\n const returnArgs: ParsedArguments = {}\n\n for (let position = 0; position < __sxyt_commandLineArguments.length; position++) {\n const arg = __sxyt_commandLineArguments[position]\n if (arg === undefined) continue\n if (arg.slice(0, 2) === '--') {\n const longFlag = arg.slice(2)\n const allowedArgument = allowedArguments[longFlag]\n if (allowedArgument) {\n if (allowedArgument.hasValue) {\n const value = __sxyt_commandLineArguments[++position]\n if (value !== undefined) returnArgs[longFlag] = value\n } else {\n returnArgs[longFlag] = true\n }\n } else {\n log(chalk.mediumred(`[${packageName}] Unknown option --${longFlag}`))\n if (\n longFlag.length === 1\n && objectReduce(\n allowedArguments,\n (prev: boolean, _key: string, value: {\n flag?: string\n hasValue: boolean\n }) => {\n if (value.flag === longFlag) return true\n return prev\n },\n false\n )\n ) {\n log(chalk.mediumred(`I think you meant -${longFlag}`))\n }\n }\n } else if (arg.slice(0, 1) === '-') {\n const shortFlag = arg.slice(1)\n const longFlag = allowedFlags[shortFlag]\n if (longFlag !== undefined) {\n if (longFlag in returnArgs) {\n log(chalk.orange(\n `[${packageName}] Option --${longFlag} already set, being overwritten by -${shortFlag}`\n ))\n }\n\n const allowedArgument = allowedArguments[longFlag]\n if (allowedArgument?.hasValue === true) {\n const value = __sxyt_commandLineArguments[++position]\n if (value !== undefined) returnArgs[longFlag] = value\n } else {\n returnArgs[longFlag] = true\n }\n } else {\n log(chalk.mediumred(`[${packageName}] Unknown flag -${shortFlag}`))\n if (shortFlag.length > 1 && shortFlag in allowedArguments) {\n log(chalk.mediumred(`I think you meant --${shortFlag}`))\n }\n }\n }\n }\n\n return returnArgs\n}\n"]}
1
+ {"version":3,"file":"parseCommandLineArguments.js","sourceRoot":"","sources":["../../../src/cli/lib/parseCommandLineArguments.ts"],"names":[],"mappings":"AAAA,SAAS;AACT,QAAQ;AACR,6BAA6B;AAG7B,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAGrC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,MAAM,yBAAyB,CAAA;AAE3C,0FAA0F;AAC1F,wEAAwE;AACxE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAA;AAEnC,MAAM,UAAU,yBAAyB,CAAC,gBAAkC;IACxE,MAAM,YAAY,GAAG,eAAe,CAAC,gBAAgB,CAAC,CAAA;IAEtD,MAAM,UAAU,GAAoB,EAAE,CAAA;IACtC,uFAAuF;IACvF,wCAAwC;IACxC,MAAM,WAAW,GAAa,EAAE,CAAA;IAEhC,KAAK,IAAI,QAAQ,GAAG,CAAC,EAAE,QAAQ,GAAG,2BAA2B,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,CAAC;QAC/E,MAAM,GAAG,GAAG,2BAA2B,CAAC,QAAQ,CAAC,CAAA;QACjD,IAAI,GAAG,KAAK,SAAS;YAAE,SAAQ;QAC/B,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YAC3B,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,C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AE,CAAC;oBACzB,GAAG,CAAC,KAAK,CAAC,MAAM,CACZ,IAAI,WAAW,cAAc,QAAQ,uCAAuC,SAAS,EAAE,CAC1F,CAAC,CAAA;gBACN,CAAC;gBAED,MAAM,eAAe,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAA;gBAClD,IAAI,eAAe,EAAE,QAAQ,KAAK,IAAI,EAAE,CAAC;oBACrC,MAAM,KAAK,GAAG,2BAA2B,CAAC,EAAE,QAAQ,CAAC,CAAA;oBACrD,IAAI,KAAK,KAAK,SAAS;wBAAE,UAAU,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAA;gBACzD,CAAC;qBAAM,CAAC;oBACJ,UAAU,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAA;gBAC/B,CAAC;YACL,CAAC;iBAAM,CAAC;gBACJ,WAAW,CAAC,IAAI,CAAC,IAAI,SAAS,EAAE,CAAC,CAAA;gBACjC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,WAAW,mBAAmB,SAAS,EAAE,CAAC,CAAC,CAAA;gBACnE,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,SAAS,IAAI,gBAAgB,EAAE,CAAC;oBACxD,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,uBAAuB,SAAS,EAAE,CAAC,CAAC,CAAA;gBAC5D,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IAED,sFAAsF;IACtF,iFAAiF;IACjF,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzB,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,OAAO,uCAAuC,CAAC,CAAC,CAAA;QAC1E,OAAO,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;IACpC,CAAC;IAED,OAAO,UAAU,CAAA;AACrB,CAAC","sourcesContent":["// watch:\n// once:\n// // --config configLocation\n\n\nimport { reduce as objectReduce } from 'sxy-lib/objects.js'\nimport { packageName, cliName } from '../../config.js'\nimport { log } from '../../output.js'\nimport type { AllowedArguments, ParsedArguments } from '../../types.js'\n\nimport { getAllowedFlags } from './getAllowedFlags.js'\nimport chalk from '../../packages/chalk.js'\n\n// exit code for a usage error - distinct from the run's own 0/3/4/5, so a caller can tell\n// \"you asked for something I do not understand\" from \"the tests failed\"\nexport const usageErrorExitCode = 2\n\nexport function parseCommandLineArguments(allowedArguments: AllowedArguments): ParsedArguments {\n const allowedFlags = getAllowedFlags(allowedArguments)\n\n const returnArgs: ParsedArguments = {}\n // collected rather than reported one at a time, so a mistyped command line is fixed in\n // one go rather than one option per run\n const unknownArgs: string[] = []\n\n for (let position = 0; position < __sxyt_commandLineArguments.length; position++) {\n const arg = __sxyt_commandLineArguments[position]\n if (arg === undefined) continue\n if (arg.slice(0, 2) === '--') {\n const longFlag = arg.slice(2)\n const allowedArgument = allowedArguments[longFlag]\n if (allowedArgument) {\n if (allowedArgument.hasValue) {\n const value = __sxyt_commandLineArguments[++position]\n if (value !== undefined) returnArgs[longFlag] = value\n } else {\n returnArgs[longFlag] = true\n }\n } else {\n unknownArgs.push(`--${longFlag}`)\n log(chalk.mediumred(`[${packageName}] Unknown option --${longFlag}`))\n if (\n longFlag.length === 1\n && objectReduce(\n allowedArguments,\n (prev: boolean, _key: string, value: {\n flag?: string\n hasValue: boolean\n }) => {\n if (value.flag === longFlag) return true\n return prev\n },\n false\n )\n ) {\n log(chalk.mediumred(`I think you meant -${longFlag}`))\n }\n }\n } else if (arg.slice(0, 1) === '-') {\n const shortFlag = arg.slice(1)\n const longFlag = allowedFlags[shortFlag]\n if (longFlag !== undefined) {\n if (longFlag in returnArgs) {\n log(chalk.orange(\n `[${packageName}] Option --${longFlag} already set, being overwritten by -${shortFlag}`\n ))\n }\n\n const allowedArgument = allowedArguments[longFlag]\n if (allowedArgument?.hasValue === true) {\n const value = __sxyt_commandLineArguments[++position]\n if (value !== undefined) returnArgs[longFlag] = value\n } else {\n returnArgs[longFlag] = true\n }\n } else {\n unknownArgs.push(`-${shortFlag}`)\n log(chalk.mediumred(`[${packageName}] Unknown flag -${shortFlag}`))\n if (shortFlag.length > 1 && shortFlag in allowedArguments) {\n log(chalk.mediumred(`I think you meant --${shortFlag}`))\n }\n }\n }\n }\n\n // stop rather than run something other than what was asked for: an ignored option can\n // mean the wrong tests, or a whole suite where a single filtered test was wanted\n if (unknownArgs.length > 0) {\n log(chalk.orange(`Run \\`${cliName} help\\` to see the available options.`))\n process.exit(usageErrorExitCode)\n }\n\n return returnArgs\n}\n"]}
@@ -0,0 +1,8 @@
1
+ export declare const commands: readonly ["init", "once", "watch", "help"];
2
+ export type Command = typeof commands[number];
3
+ export interface ResolvedCommand {
4
+ command: Command;
5
+ commandArgs: string[];
6
+ }
7
+ export declare function resolveCommand(args: string[]): ResolvedCommand;
8
+ //# sourceMappingURL=resolveCommand.d.ts.map
@@ -0,0 +1,47 @@
1
+ export const commands = ['init', 'once', 'watch', 'help'];
2
+ function isCommand(value) {
3
+ return commands.includes(value);
4
+ }
5
+ // The options that consume the next argument, so `--filter-it -h` is understood as a filter
6
+ // for "-h" rather than a request for help. Worst case if this drifts from the option lists
7
+ // in watch.ts and once.ts is that such an argument shows help instead.
8
+ const valueTakingFlags = new Set([
9
+ '--config', '-c',
10
+ '--test-files', '-t',
11
+ '--filter', '-f',
12
+ '--filter-it', '-i',
13
+ '--filter-describe', '-d',
14
+ '--status-file', '-s'
15
+ ]);
16
+ function wantsHelp(commandArgs) {
17
+ for (let position = 0; position < commandArgs.length; position++) {
18
+ const arg = commandArgs[position];
19
+ if (arg === undefined)
20
+ continue;
21
+ if (valueTakingFlags.has(arg)) {
22
+ position++; // skip the value, whatever it looks like
23
+ continue;
24
+ }
25
+ if (arg === '--help' || arg === '-h')
26
+ return true;
27
+ }
28
+ return false;
29
+ }
30
+ // Routes the raw argv tail to a command. Extracted from the entry module so the routing can
31
+ // be tested without running a command as a side effect of importing it.
32
+ export function resolveCommand(args) {
33
+ const first = args[0];
34
+ if (first !== undefined && isCommand(first)) {
35
+ const commandArgs = args.slice(1);
36
+ // asking a command for help describes it rather than running it
37
+ return { command: (wantsHelp(commandArgs)) ? 'help' : first, commandArgs };
38
+ }
39
+ if (first !== undefined && first.startsWith('--') && isCommand(first.slice(2))) {
40
+ const commandArgs = args.slice(1);
41
+ const command = first.slice(2);
42
+ return { command: (wantsHelp(commandArgs)) ? 'help' : command, commandArgs };
43
+ }
44
+ // no command given - everything is an argument to the default
45
+ return { command: (wantsHelp(args)) ? 'help' : 'watch', commandArgs: args };
46
+ }
47
+ //# sourceMappingURL=resolveCommand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveCommand.js","sourceRoot":"","sources":["../../../src/cli/lib/resolveCommand.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAU,CAAA;AASlE,SAAS,SAAS,CAAC,KAAa;IAC5B,OAAQ,QAA8B,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;AAC1D,CAAC;AAED,4FAA4F;AAC5F,2FAA2F;AAC3F,uEAAuE;AACvE,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC;IAC7B,UAAU,EAAE,IAAI;IAChB,cAAc,EAAE,IAAI;IACpB,UAAU,EAAE,IAAI;IAChB,aAAa,EAAE,IAAI;IACnB,mBAAmB,EAAE,IAAI;IACzB,eAAe,EAAE,IAAI;CACxB,CAAC,CAAA;AAEF,SAAS,SAAS,CAAC,WAAqB;IACpC,KAAK,IAAI,QAAQ,GAAG,CAAC,EAAE,QAAQ,GAAG,WAAW,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,CAAC;QAC/D,MAAM,GAAG,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAA;QACjC,IAAI,GAAG,KAAK,SAAS;YAAE,SAAQ;QAC/B,IAAI,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YAC5B,QAAQ,EAAE,C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'help'] as const\n\nexport type Command = typeof commands[number]\n\nexport interface ResolvedCommand {\n command: Command\n commandArgs: string[]\n}\n\nfunction isCommand(value: string): value is Command {\n return (commands as readonly string[]).includes(value)\n}\n\n// The options that consume the next argument, so `--filter-it -h` is understood as a filter\n// for \"-h\" rather than a request for help. Worst case if this drifts from the option lists\n// in watch.ts and once.ts is that such an argument shows help instead.\nconst valueTakingFlags = new Set([\n '--config', '-c',\n '--test-files', '-t',\n '--filter', '-f',\n '--filter-it', '-i',\n '--filter-describe', '-d',\n '--status-file', '-s'\n])\n\nfunction wantsHelp(commandArgs: string[]): boolean {\n for (let position = 0; position < commandArgs.length; position++) {\n const arg = commandArgs[position]\n if (arg === undefined) continue\n if (valueTakingFlags.has(arg)) {\n position++ // skip the value, whatever it looks like\n continue\n }\n if (arg === '--help' || arg === '-h') return true\n }\n return false\n}\n\n// Routes the raw argv tail to a command. Extracted from the entry module so the routing can\n// be tested without running a command as a side effect of importing it.\nexport function resolveCommand(args: string[]): ResolvedCommand {\n const first = args[0]\n\n if (first !== undefined && isCommand(first)) {\n const commandArgs = args.slice(1)\n // asking a command for help describes it rather than running it\n return { command: (wantsHelp(commandArgs)) ? 'help' : first, commandArgs }\n }\n\n if (first !== undefined && first.startsWith('--') && isCommand(first.slice(2))) {\n const commandArgs = args.slice(1)\n const command = first.slice(2) as Command\n return { command: (wantsHelp(commandArgs)) ? 'help' : command, commandArgs }\n }\n\n // no command given - everything is an argument to the default\n return { command: (wantsHelp(args)) ? 'help' : 'watch', commandArgs: args }\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import { type StopSignal } from './stopSignal.js';
1
2
  import type { FinalConfig, Describe, DescribeResult } from '../../types.js';
2
- export declare function runDescribe(config: FinalConfig, describe: Describe, itFilter?: string): Promise<DescribeResult>;
3
+ export declare function runDescribe(config: FinalConfig, describe: Describe, itFilter?: string, stop?: StopSignal): Promise<DescribeResult>;
3
4
  //# sourceMappingURL=runDescribe.d.ts.map
@@ -2,6 +2,7 @@ import { timeProfileAsync } from './timeProfier.js';
2
2
  import { parseDescribe } from './parseDescribe.js';
3
3
  import { runDescribeRun } from './runDescribeRun.js';
4
4
  import { captureLogs } from './consoleCapture.js';
5
+ import { makeStopSignal, stopIfFailFast } from './stopSignal.js';
5
6
  function createDescribeErrorResult(describe, error) {
6
7
  return {
7
8
  counter: describe.counter,
@@ -16,7 +17,7 @@ function createDescribeErrorResult(describe, error) {
16
17
  error
17
18
  };
18
19
  }
19
- export function runDescribe(config, describe, itFilter) {
20
+ export function runDescribe(config, describe, itFilter, stop = makeStopSignal()) {
20
21
  return timeProfileAsync(`run describe ${describe.thing}`, async () => {
21
22
  const logs = [];
22
23
  const startTime = new Date().getTime();
@@ -25,7 +26,7 @@ export function runDescribe(config, describe, itFilter) {
25
26
  const parsedDescribe = await parseDescribe(config, describe, itFilter);
26
27
  return parsedDescribe.error !== undefined
27
28
  ? createDescribeErrorResult(describe, parsedDescribe.error)
28
- : await runDescribeRun(config, describe, parsedDescribe);
29
+ : await runDescribeRun(config, describe, parsedDescribe, stop);
29
30
  }
30
31
  catch (e) {
31
32
  return createDescribeErrorResult(describe, e);
@@ -33,6 +34,8 @@ export function runDescribe(config, describe, itFilter) {
33
34
  });
34
35
  describeResult.time = new Date().getTime() - startTime;
35
36
  describeResult.logs = logs;
37
+ // a describe that threw stops the run just as a failing test does
38
+ stopIfFailFast(config, stop, describeResult.error !== undefined);
36
39
  return describeResult;
37
40
  });
38
41
  }
@@ -1 +1 @@
1
- {"version":3,"file":"runDescribe.js","sourceRoot":"","sources":["../../../src/cli/lib/runDescribe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAIjD,SAAS,yBAAyB,CAAC,Q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N,CAAC","sourcesContent":["import { timeProfileAsync } from './timeProfier.js'\nimport { parseDescribe } from './parseDescribe.js'\nimport { runDescribeRun } from './runDescribeRun.js'\nimport { captureLogs } from './consoleCapture.js'\n\nimport type { FinalConfig, Describe, DescribeResult } from '../../types.js'\n\nfunction createDescribeErrorResult(describe: Describe, error: unknown): DescribeResult {\n return {\n counter: describe.counter,\n thing: describe.thing,\n success: false,\n time: 0, // overwritten by runDescribe\n itResults: [],\n itResultsSummary: {\n total: 0,\n passes: 0\n },\n error\n }\n}\n\nexport function runDescribe(\n config: FinalConfig,\n describe: Describe,\n itFilter?: string\n): Promise<DescribeResult> {\n return timeProfileAsync(`run describe ${describe.thing}`, async () => {\n const logs: unknown[][] = []\n\n const startTime = new Date().getTime()\n\n const describeResult = await captureLogs(logs, async () => {\n try {\n const parsedDescribe = await parseDescribe(config, describe, itFilter)\n return parsedDescribe.error !== undefined\n ? createDescribeErrorResult(describe, parsedDescribe.error)\n : await runDescribeRun(config, describe, parsedDescribe)\n } catch (e) {\n return createDescribeErrorResult(describe, e)\n }\n })\n\n describeResult.time = new Date().getTime() - startTime\n describeResult.logs = logs\n\n return describeResult\n })\n}\n"]}
1
+ {"version":3,"file":"runDescribe.js","sourceRoot":"","sources":["../../../src/cli/lib/runDescribe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAEjD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAmB,MAAM,iBAAiB,CAAA;AAIjF,SAAS,yBAAyB,CAAC,QAAkB,EAAE,KAAc;IACjE,OAAO;QACH,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,OAAO,EAAE,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,CAAC,CAAA;AACN,CAAC","sourcesContent":["import { timeProfileAsync } from './timeProfier.js'\nimport { parseDescribe } from './parseDescribe.js'\nimport { runDescribeRun } from './runDescribeRun.js'\nimport { captureLogs } from './consoleCapture.js'\n\nimport { makeStopSignal, stopIfFailFast, type StopSignal } from './stopSignal.js'\n\nimport type { FinalConfig, Describe, DescribeResult } from '../../types.js'\n\nfunction createDescribeErrorResult(describe: Describe, error: unknown): DescribeResult {\n return {\n counter: describe.counter,\n thing: describe.thing,\n success: false,\n time: 0, // overwritten by runDescribe\n itResults: [],\n itResultsSummary: {\n total: 0,\n passes: 0\n },\n error\n }\n}\n\nexport function runDescribe(\n config: FinalConfig,\n describe: Describe,\n itFilter?: string,\n stop: StopSignal = makeStopSignal()\n): Promise<DescribeResult> {\n return timeProfileAsync(`run describe ${describe.thing}`, async () => {\n const logs: unknown[][] = []\n\n const startTime = new Date().getTime()\n\n const describeResult = await captureLogs(logs, async () => {\n try {\n const parsedDescribe = await parseDescribe(config, describe, itFilter)\n return parsedDescribe.error !== undefined\n ? createDescribeErrorResult(describe, parsedDescribe.error)\n : await runDescribeRun(config, describe, parsedDescribe, stop)\n } catch (e) {\n return createDescribeErrorResult(describe, e)\n }\n })\n\n describeResult.time = new Date().getTime() - startTime\n describeResult.logs = logs\n\n // a describe that threw stops the run just as a failing test does\n stopIfFailFast(config, stop, describeResult.error !== undefined)\n\n return describeResult\n })\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import { type StopSignal } from './stopSignal.js';
1
2
  import type { FinalConfig, Describe, DescribeResult, ParsedDescribe } from '../../types.js';
2
- export declare function runDescribeRun(config: FinalConfig, describe: Describe, parsedIts: ParsedDescribe): Promise<DescribeResult>;
3
+ export declare function runDescribeRun(config: FinalConfig, describe: Describe, parsedIts: ParsedDescribe, stop?: StopSignal): Promise<DescribeResult>;
3
4
  //# sourceMappingURL=runDescribeRun.d.ts.map
@@ -2,7 +2,8 @@ import { timeProfileAsync } from './timeProfier.js';
2
2
  import { runTasks } from './runTasks.js';
3
3
  import { debug } from '../../output.js';
4
4
  import { runIt } from './runIt.js';
5
- export function runDescribeRun(config, describe, parsedIts) {
5
+ import { makeStopSignal, stopIfFailFast } from './stopSignal.js';
6
+ export function runDescribeRun(config, describe, parsedIts, stop = makeStopSignal()) {
6
7
  return timeProfileAsync(`run describe, run its ${describe.thing}`, async () => {
7
8
  const { its, beforeDescribeExports, afterDescribeFunc, beforeEachTestFunc, afterEachTestFunc } = parsedIts;
8
9
  const parallelOverride = describe.meta === undefined
@@ -11,12 +12,17 @@ export function runDescribeRun(config, describe, parsedIts) {
11
12
  const isParallel = parallelOverride ?? config.execution.tests === 'parallel';
12
13
  const itPromises = [];
13
14
  for (const it of its) {
15
+ // checked before starting, so the failing test is the last one that runs
16
+ if (stop.stopped)
17
+ break;
14
18
  const itPromise = runIt(config, it, beforeEachTestFunc, afterEachTestFunc);
15
19
  itPromises.push(itPromise);
16
20
  if (!isParallel)
17
- await itPromise;
21
+ stopIfFailFast(config, stop, (await itPromise).success === false);
18
22
  }
19
23
  const itResults = await Promise.all(itPromises);
24
+ // in parallel mode the tests are already in flight, so this only stops later work
25
+ stopIfFailFast(config, stop, itResults.some(itResult => itResult.success === false));
20
26
  const itResultsSummary = {
21
27
  total: 0,
22
28
  passes: 0