sumlyzer 0.4.0 → 0.5.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.
package/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
  <a href="./LICENSE"><img src="https://img.shields.io/npm/l/sumlyzer.svg" alt="license" /></a>
12
12
  </p>
13
13
 
14
- Run every npm workspace's test script, one by one. Passing workspaces output
14
+ Run every npm workspace's test script, one by one or in concurrence. Passing workspaces output
15
15
  to a single line; failing ones print only the relevant failure detail.
16
16
  Ends with an aggregated pass/fail summary table, so nothing scrolls out of the terminal.
17
17
 
@@ -55,8 +55,8 @@ Options:
55
55
 
56
56
  Exit code is `1` if any workspace fails (or if the project has no
57
57
  workspaces), `0` otherwise, wire it straight into CI without extra parsing.
58
- This also applies when `--junit` can't write its report (e.g. an invalid
59
- `<path>`): the exit code is `1` even if every workspace's tests passed.
58
+ This also applies when `--junit` can't write its report.
59
+ The exit code is `1` even if every workspace's tests passed.
60
60
 
61
61
  ## Features
62
62
 
@@ -99,27 +99,44 @@ running gitlab
99
99
  ✓ gitlab 4.3s (8/8 tests)
100
100
 
101
101
  Summary
102
- ┌─────────┬────────────────┬──────────┬────────────┬────────────────┬─────────┬────────┬────────┐
103
- │ (index) │ workspace │ status │ duration │ testsDuration │ tests │ pass │ fail │
104
- ├─────────┼────────────────┼──────────┼────────────┼────────────────┼─────────┼────────┼────────┤
105
- │ 0 │ 'contact' │ 'PASS' │ '2.6s' │ '0.9s' │ '35' │ '35' │ '0' │
106
- │ 1 │ 'scanner' │ 'PASS' │ '10.1s' │ '8.7s' │ '162' │ '161' │ '0' │
107
- │ 2 │ 'tarball' │ 'PASS' │ '1.8s' │ '0.7s' │ '77' │ '77' │ '0' │
108
- │ 3 │ 'mama' │ 'PASS' │ '1.2s' │ '0.1s' │ '85' │ '85' │ '0' │
109
- │ 4 │ 'tree-walker' │ 'PASS' │ '3.0s' │ '2.0s' │ '26' │ '26' │ '0' │
110
- │ 5 │ 'conformance' │ 'PASS' │ '1.1s' │ '0.1s' │ '35' │ '35' │ '0' │
111
- │ 6 │ 'i18n' │ 'PASS' │ '1.1s' │ '0.2s' │ '19' │ '19' │ '0' │
112
- │ 7 │ 'rc' │ 'PASS' │ '4.1s' │ '0.6s' │ '28' │ '28' │ '0' │
113
- │ 8 │ 'utils' │ 'PASS' │ '1.1s' │ '0.1s' │ '30' │ '30' │ '0' │
114
- │ 9 │ 'flags' │ 'PASS' │ '1.1s' │ '0.1s' │ '9' │ '9' │ '0' │
115
- │ 10 │ 'fs-walk' │ 'PASS' │ '1.1s' │ '0.1s' │ '3' │ '3' │ '0' │
116
- │ 11 │ 'github' │ 'PASS' │ '2.9s' │ '2.0s' │ '8' │ '8' │ '0' │
117
- │ 12 │ 'gitlab' │ 'PASS' │ '4.3s' │ '3.3s' │ '8' │ '8' │ '0' │
118
- └─────────┴────────────────┴──────────┴────────────┴────────────────┴─────────┴────────┴────────┘
102
+ ┌─────────────┬────────┬──────────┬───────────────┬───────┬───────┬──────┬──────┬──────┬───────────┐
103
+ │ (index) │ status │ duration │ testsDuration │ tests │ pass │ fail │ skip │ todo │ cancelled │
104
+ ├─────────────┼────────┼──────────┼───────────────┼───────┼───────┼──────┼──────┼──────┼───────────┤
105
+ │ contact │ 'PASS' │ '2.6s' │ '0.9s' │ '35' │ '35' │ '0' │ '0' │ '0' │ '0' │
106
+ │ scanner │ 'PASS' │ '10.1s' │ '8.7s' │ '162' │ '161' │ '0' │ '1' │ '0' │ '0' │
107
+ │ tarball │ 'PASS' │ '1.8s' │ '0.7s' │ '77' │ '77' │ '0' │ '0' │ '0' │ '0' │
108
+ │ mama │ 'PASS' │ '1.2s' │ '0.1s' │ '85' │ '85' │ '0' │ '0' │ '0' │ '0' │
109
+ │ tree-walker │ 'PASS' │ '3.0s' │ '2.0s' │ '26' │ '26' │ '0' │ '0' │ '0' │ '0' │
110
+ │ conformance │ 'PASS' │ '1.1s' │ '0.1s' │ '35' │ '35' │ '0' │ '0' │ '0' │ '0' │
111
+ │ i18n │ 'PASS' │ '1.1s' │ '0.2s' │ '19' │ '19' │ '0' │ '0' │ '0' │ '0' │
112
+ │ rc │ 'PASS' │ '4.1s' │ '0.6s' │ '28' │ '28' │ '0' │ '0' │ '0' │ '0' │
113
+ │ utils │ 'PASS' │ '1.1s' │ '0.1s' │ '30' │ '30' │ '0' │ '0' │ '0' │ '0' │
114
+ │ flags │ 'PASS' │ '1.1s' │ '0.1s' │ '9' │ '9' │ '0' │ '0' │ '0' │ '0' │
115
+ │ fs-walk │ 'PASS' │ '1.1s' │ '0.1s' │ '3' │ '3' │ '0' │ '0' │ '0' │ '0' │
116
+ │ github │ 'PASS' │ '2.9s' │ '2.0s' │ '8' │ '8' │ '0' │ '0' │ '0' │ '0' │
117
+ │ gitlab │ 'PASS' │ '4.3s' │ '3.3s' │ '8' │ '8' │ '0' │ '0' │ '0' │ '0' │
118
+ └─────────────┴────────┴──────────┴───────────────┴───────┴───────┴──────┴──────┴──────┴───────────┘
119
119
 
120
120
  13/13 workspaces passed.
121
121
  ```
122
122
 
123
+ ### Summary columns
124
+
125
+ | Column | Meaning |
126
+ | --------------- | ------------------------------------------------------------------------------------------------ |
127
+ | `(index)` | Workspace name — `console.table` is fed an object keyed by workspace name (via `workspaceName` in [reporter.mjs](./src/reporter.mjs)) instead of an array, so this column carries the name instead of a meaningless row number |
128
+ | `status` | `PASS`, `FAIL`, or `SKIPPED` (only reached when `--ff` stopped scheduling before this workspace ran) |
129
+ | `duration` | Wall-clock time for the whole `npm run <script> --workspace=<path>` process, including npm/spawn overhead |
130
+ | `testsDuration` | `duration_ms` as reported by node's own test runner — the actual test execution time, without the npm overhead |
131
+ | `tests` | Total number of tests node:test ran in that workspace |
132
+ | `pass` | Number of passing tests |
133
+ | `fail` | Number of failing tests |
134
+ | `skip` | Tests reported as skipped (`ℹ skipped`), e.g. `t.skip()` or `{ skip: true }` |
135
+ | `todo` | Tests reported as todo (`ℹ todo`), e.g. `t.todo()` — intentionally not implemented yet, distinct from `skip` |
136
+ | `cancelled` | Tests reported as cancelled (`ℹ cancelled`), e.g. a timeout or a parent suite/hook failure that aborted them — unlike `skip`/`todo` this usually signals a real problem |
137
+
138
+ `duration` and `testsDuration` are deliberately both shown: a gap between them usually means npm/process startup overhead rather than slow tests. `tests` always equals `pass + fail + skip + todo + cancelled`; the last three columns exist so none of those buckets can hide silently behind an all-green `pass`/`fail` pair.
139
+
123
140
  ### On failure
124
141
 
125
142
  Only the failing workspace prints its detail and passing ones stay collapsed to a single line.
@@ -146,14 +163,14 @@ running flags
146
163
  ✓ flags 1.1s (9/9 tests)
147
164
 
148
165
  Summary
149
- ┌─────────┬────────────┬──────────┬────────────┬────────────────┬─────────┬────────┬────────┐
150
- │ (index) │ workspace │ status │ duration │ testsDuration │ tests │ pass │ fail │
151
- ├─────────┼────────────┼──────────┼────────────┼────────────────┼─────────┼────────┼────────┤
152
- │ 0 │ 'contact' │ 'PASS' │ '2.6s' │ '0.9s' │ '35' │ '35' │ '0' │
153
- │ 1 │ 'scanner' │ 'PASS' │ '10.1s' │ '8.7s' │ '162' │ '161' │ '0' │
154
- │ 2 │ 'utils' │ 'FAIL' │ '1.3s' │ '0.1s' │ '30' │ '29' │ '1' │
155
- │ 3 │ 'flags' │ 'PASS' │ '1.1s' │ '0.1s' │ '9' │ '9' │ '0' │
156
- └─────────┴────────────┴──────────┴────────────┴────────────────┴─────────┴────────┴────────┘
166
+ ┌─────────┬────────┬──────────┬───────────────┬───────┬───────┬──────┬──────┬──────┬───────────┐
167
+ │ (index) │ status │ duration │ testsDuration │ tests │ pass │ fail │ skip │ todo │ cancelled │
168
+ ├─────────┼────────┼──────────┼───────────────┼───────┼───────┼──────┼──────┼──────┼───────────┤
169
+ │ contact │ 'PASS' │ '2.6s' │ '0.9s' │ '35' │ '35' │ '0' │ '0' │ '0' │ '0' │
170
+ │ scanner │ 'PASS' │ '10.1s' │ '8.7s' │ '162' │ '161' │ '0' │ '1' │ '0' │ '0' │
171
+ │ utils │ 'FAIL' │ '1.3s' │ '0.1s' │ '30' │ '29' │ '1' │ '0' │ '0' │ '0' │
172
+ │ flags │ 'PASS' │ '1.1s' │ '0.1s' │ '9' │ '9' │ '0' │ '0' │ '0' │ '0' │
173
+ └─────────┴────────┴──────────┴───────────────┴───────┴───────┴──────┴──────┴──────┴───────────┘
157
174
 
158
175
  1/4 workspace(s) failed:
159
176
  utils
@@ -215,6 +232,8 @@ With `--ff`, a failure only stops workspaces that haven't started yet; any
215
232
  workspace already running when the failure is detected runs to completion
216
233
  (sumlyzer doesn't kill in-flight processes).
217
234
 
235
+ ![Concurrent run stopping early on failure](https://github.com/ErwanRaulo/sumlyzer/blob/main/concurrency-failed.png?raw=true)
236
+
218
237
  ## Why
219
238
 
220
239
  `npm run test --workspaces --if-present` runs every workspace but gives you
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sumlyzer",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Run every npm workspace's test script, only show output for the ones that fail, and finish with an aggregated pass/fail summary.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,6 +1,8 @@
1
1
  const COUNT_INDEX = 1;
2
2
  const count = (target, output) => new RegExp(String.raw`ℹ ${target} (\d+)`).exec(output)?.[COUNT_INDEX];
3
3
 
4
+ // skip/todo/cancelled fall back to "0" rather than "?": unlike pass/fail, a missing
5
+ // line here is far more likely to mean "zero" than "parsing went wrong somehow".
4
6
  export function parseTestCounts(output) {
5
7
  const tests = count("tests", output);
6
8
 
@@ -12,6 +14,9 @@ export function parseTestCounts(output) {
12
14
  tests,
13
15
  pass: count("pass", output) ?? "?",
14
16
  fail: count("fail", output) ?? "?",
17
+ skip: count("skipped", output) ?? "0",
18
+ todo: count("todo", output) ?? "0",
19
+ cancelled: count("cancelled", output) ?? "0",
15
20
  durationMs: count("duration_ms", output)
16
21
  };
17
22
  }
package/src/reporter.mjs CHANGED
@@ -57,32 +57,32 @@ export function printWorkspaceResult(name, result, ciGroup) {
57
57
  process.stdout.write(red(`✗ ${name}`) + dim(` ${seconds}, exit code ${result.exitCode}\n\n`));
58
58
  }
59
59
 
60
- function summaryRow(workspace, status, duration, counts) {
60
+ function summaryRow(status, duration, counts) {
61
61
  return {
62
- workspace,
63
62
  status,
64
63
  duration,
65
64
  testsDuration: counts?.durationMs ? formatSeconds(Number(counts.durationMs)) : "-",
66
65
  tests: counts?.tests ?? "-",
67
66
  pass: counts?.pass ?? "-",
68
- fail: counts?.fail ?? "-"
67
+ fail: counts?.fail ?? "-",
68
+ skip: counts?.skip ?? "-",
69
+ todo: counts?.todo ?? "-",
70
+ cancelled: counts?.cancelled ?? "-"
69
71
  };
70
72
  }
71
73
 
72
74
  export function printSummary(results, skipped) {
73
75
  console.log(bold("\nSummary"));
74
- console.table([
75
- ...results.map(({ wsPath, exitCode, durationMs, counts }) => {
76
-
77
- return summaryRow(
78
- workspaceName(wsPath),
79
- exitCode === 0 ? "PASS" : "FAIL",
80
- formatSeconds(durationMs),
81
- counts
82
- );
83
- }),
84
- ...skipped.map((wsPath) => summaryRow(workspaceName(wsPath), "SKIPPED", "-", null))
85
- ]);
76
+
77
+ const rows = {};
78
+ for (const { wsPath, exitCode, durationMs, counts } of results) {
79
+ rows[workspaceName(wsPath)] = summaryRow(exitCode === 0 ? "PASS" : "FAIL", formatSeconds(durationMs), counts);
80
+ }
81
+ for (const wsPath of skipped) {
82
+ rows[workspaceName(wsPath)] = summaryRow("SKIPPED", "-", null);
83
+ }
84
+
85
+ console.table(rows);
86
86
 
87
87
  if (skipped.length > 0) {
88
88
  console.log(dim(`${skipped.length} workspace(s) skipped (--ff): ${skipped.map(workspaceName).join(", ")}`));