cliprobe 1.4.2 → 1.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.
- package/README.md +35 -13
- package/dist/cli.js +74 -29
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ npx cliprobe -- tsx
|
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
```
|
|
34
|
-
cliprobe 1.
|
|
34
|
+
cliprobe 1.4.3: closed-pipe, color, pipe-escapes, stdin, ctrl-c, sigterm, restore, control-chars checks for tsx
|
|
35
35
|
|
|
36
36
|
closed-pipe
|
|
37
37
|
FAIL tsx --version crashed when stdout was closed (exit 0 -> 1)
|
|
@@ -101,7 +101,9 @@ The other checks cover the rest of what goes wrong between a program and the thi
|
|
|
101
101
|
|
|
102
102
|
## Installation
|
|
103
103
|
|
|
104
|
-
Requires Node.js 22.12 or later, on macOS or Linux (including Alpine). Windows isn't supported yet.
|
|
104
|
+
Requires Node.js 22.12 or later, on macOS or Linux (including Alpine). Windows isn't supported yet. The terminal checks (color, restore and control-chars) also need the system's `script` command, which macOS has and most Linux distributions install by default. Without it they're skipped, and each skip says so. If it's missing, install the package that has it: `bsdutils` on Debian and Ubuntu, `util-linux-script` on Fedora, `util-linux-misc` on Alpine.
|
|
105
|
+
|
|
106
|
+
Run it without installing:
|
|
105
107
|
|
|
106
108
|
```sh
|
|
107
109
|
npx cliprobe -- <command>
|
|
@@ -131,7 +133,7 @@ npx cliprobe --strict --skip restore -- node ./dist/cli.js server # warnings f
|
|
|
131
133
|
| Option | Meaning |
|
|
132
134
|
| ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
133
135
|
| `--bare` | Probe the command with no arguments instead of `--version` and `--help`, as a probe you wrote |
|
|
134
|
-
| `--probe <args>` | Also probe `<command> <args>`; repeat it for several. Split like a shell command line (quotes and backslashes, no variables or wildcards)
|
|
136
|
+
| `--probe <args>` | Also probe `<command> <args>`; repeat it for several. Split like a shell command line (quotes and backslashes, no variables or wildcards). The args after `<command>` aren't kept: with `-- node ./cli.js`, write `--probe "./cli.js watch"` |
|
|
135
137
|
| `--check <name>` | Run only this check; repeat it or use commas for several |
|
|
136
138
|
| `--skip <name>` | Leave this check out; repeat it or use commas for several |
|
|
137
139
|
| `--strict` | Exit 1 on a warning too, not only on a failure |
|
|
@@ -144,6 +146,8 @@ npx cliprobe --strict --skip restore -- node ./dist/cli.js server # warnings f
|
|
|
144
146
|
|
|
145
147
|
An option's value follows it or comes after `=` (`--format=json`). A value that is another option, as in `-o --strict`, is a usage error rather than a file named `--strict`. `--probe` is the exception: its value may start with `-`, to probe a flag (`--probe --json`).
|
|
146
148
|
|
|
149
|
+
A probe runs `<command>` with its own args, in place of the args after the command, not after them. So when the command is an interpreter, name the script in every probe: `npx cliprobe --probe "./dist/cli.js watch" -- node ./dist/cli.js` probes `node ./dist/cli.js` and `node ./dist/cli.js watch`, while `--probe watch` would run `node watch`. A probe that exits with a failure code and is skipped says so in its reason, with the error line from stderr as evidence, so a probe that never ran as intended doesn't pass for a quiet skip.
|
|
150
|
+
|
|
147
151
|
## Exit codes
|
|
148
152
|
|
|
149
153
|
| Code | Meaning |
|
|
@@ -207,7 +211,7 @@ In JUnit, each check is a test suite and each probe a test case: `FAIL` is a fai
|
|
|
207
211
|
}
|
|
208
212
|
```
|
|
209
213
|
|
|
210
|
-
`strict` says whether `--strict` was given (added in 1.1). Every result has the same five fields: `check`, `invocation` (the command and arguments that ran), `verdict` (`pass`, `fail`, `warn`, `skip`, `error` for could-not-run, or `info`), `reason` (a sentence for a person) and `details`, plus `evidence` when there is a line to quote. `details` holds the check's own measurements, such as exit codes, timings, the terminal modes left on or the processes left running; the schema describes each check's. Text from the program under test is escaped: control characters, line separators and bidi overrides appear as `\u` escapes, so the report can't drive a terminal when printed.
|
|
214
|
+
`strict` says whether `--strict` was given (added in 1.1). Every result has the same five fields: `check`, `invocation` (the command and arguments that ran), `verdict` (`pass`, `fail`, `warn`, `skip`, `error` for could-not-run, or `info`), `reason` (a sentence for a person) and `details`, plus `evidence` when there is a line to quote. `details` holds the check's own measurements, such as exit codes, timings, the terminal modes left on or the processes left running; the schema describes each check's. Text from the program under test is escaped: control characters, line separators and bidi overrides appear as `\u` escapes, so the report can't drive a terminal when printed. The human report shows them as `\x1b`-style escapes and doubles a backslash the program printed, so `\\x1b` is text and `\x1b` a real escape character; it cuts evidence longer than 200 characters, which the JSON has in full.
|
|
211
215
|
|
|
212
216
|
## Stability
|
|
213
217
|
|
|
@@ -248,12 +252,12 @@ Servers and watchers crash the same way. Among 38 watch and serve modes of popul
|
|
|
248
252
|
|
|
249
253
|
cliprobe runs the command up to three times: into a pipe, under a real terminal (a pseudo-terminal through the system's `script` command, 80×24), and under a terminal with `NO_COLOR=1`. Every run gets `TERM=xterm-256color` and no `CI` variable, so a program can't pass just because the terminal type looks colorless, and color libraries that force color in CI don't fail it. Color codes in piped output end up in log files and agent transcripts as `\x1b[31m` noise. Results:
|
|
250
254
|
|
|
251
|
-
| Verdict | Meaning
|
|
252
|
-
| ------- |
|
|
253
|
-
| `PASS` | No color in a pipe; in a terminal, either no color at all or color that `NO_COLOR` turns off
|
|
254
|
-
| `FAIL` | Printed color or style codes (bold counts, a bare reset doesn't) to stdout in a pipe
|
|
255
|
-
| `WARN` | Printed color to stderr in a pipe, or kept printing color under `NO_COLOR`
|
|
256
|
-
| `SKIP` | Printed nothing, waited for input in a terminal, or no `script` command (
|
|
255
|
+
| Verdict | Meaning |
|
|
256
|
+
| ------- | ----------------------------------------------------------------------------------------------------------- |
|
|
257
|
+
| `PASS` | No color in a pipe; in a terminal, either no color at all or color that `NO_COLOR` turns off |
|
|
258
|
+
| `FAIL` | Printed color or style codes (bold counts, a bare reset doesn't) to stdout in a pipe |
|
|
259
|
+
| `WARN` | Printed color to stderr in a pipe, or kept printing color under `NO_COLOR` |
|
|
260
|
+
| `SKIP` | Printed nothing, waited for input in a terminal, or no `script` command (see [Installation](#installation)) |
|
|
257
261
|
|
|
258
262
|
Many classic tools (git, BSD `ls` and `grep`) color correctly but don't implement [`NO_COLOR`](https://no-color.org), so they get a `WARN`, never a `FAIL`. Probe a command that prints color in normal use: almost no CLI colors its `--help`.
|
|
259
263
|
|
|
@@ -435,15 +439,33 @@ Then ask in your own words, for example "check my CLI for pipe and Ctrl-C bugs b
|
|
|
435
439
|
|
|
436
440
|
## Safety
|
|
437
441
|
|
|
438
|
-
cliprobe runs the target in your current directory without a shell, with stdin closed (`/dev/null`; the stdin, ctrl-c and sigterm checks use a pipe that they never write to), a temporary `HOME`, and a minimal environment (no tokens from your shell). It still executes the program, so only probe programs you trust. By default cliprobe passes only the arguments you give, after the command or with `--probe`, or `--version` and `--help`, or none with `--bare`; only the baseline check, when you name it, adds an unknown flag. The only input it ever sends is Ctrl-C, from the ctrl-c and restore checks, and SIGTERM, from the sigterm check, to probes you write. It kills each run's whole process group on timeout, including under a pseudo-terminal, and when a program exits it kills whatever it left running, in its group or started in another one, in every check. If cliprobe itself is stopped by Ctrl-C, SIGTERM or SIGHUP, it first kills the probe it is running and removes its temporary directories and any half-written report file, then exits by the same signal (130, 143 or 129). It runs on macOS and Linux, including Alpine; the terminal checks need the `script` command
|
|
442
|
+
cliprobe runs the target in your current directory without a shell, with stdin closed (`/dev/null`; the stdin, ctrl-c and sigterm checks use a pipe that they never write to), a temporary `HOME`, and a minimal environment (no tokens from your shell; see [the probe's environment](#the-probes-environment)). It still executes the program, so only probe programs you trust. By default cliprobe passes only the arguments you give, after the command or with `--probe`, or `--version` and `--help`, or none with `--bare`; only the baseline check, when you name it, adds an unknown flag. The only input it ever sends is Ctrl-C, from the ctrl-c and restore checks, and SIGTERM, from the sigterm check, to probes you write. It kills each run's whole process group on timeout, including under a pseudo-terminal, and when a program exits it kills whatever it left running, in its group or started in another one, in every check. If cliprobe itself is stopped by Ctrl-C, SIGTERM or SIGHUP, it first kills the probe it is running and removes its temporary directories and any half-written report file, then exits by the same signal (130, 143 or 129). It runs on macOS and Linux, including Alpine; the terminal checks need the `script` command (see [Installation](#installation)). Windows isn't supported yet.
|
|
443
|
+
|
|
444
|
+
### The probe's environment
|
|
445
|
+
|
|
446
|
+
A probe gets only these variables. Nothing else from your shell reaches it, not even `LC_ALL` or the other `LC_*` variables, so only `LANG` sets the locale:
|
|
447
|
+
|
|
448
|
+
| Variable | Value |
|
|
449
|
+
| -------------------- | --------------------------------------------------------------------------------------------------------- |
|
|
450
|
+
| `PATH` | Yours |
|
|
451
|
+
| `LANG` | Yours, or `C.UTF-8` if you have none |
|
|
452
|
+
| `HOME`, `TMPDIR` | A new temporary directory for each run, removed afterwards |
|
|
453
|
+
| `TERM` | `dumb`; `xterm-256color` in color, pipe-escapes and control-chars, and in every run under a terminal |
|
|
454
|
+
| `CI` | `1`; unset in color, pipe-escapes and control-chars, so color libraries that force color in CI don't fail |
|
|
455
|
+
| `NO_UPDATE_NOTIFIER` | `1`, so update checks stay quiet |
|
|
456
|
+
| `NO_COLOR` | `1` in the color check's last run only |
|
|
457
|
+
| `SHELL` | `/bin/sh` in runs under a terminal, which `script` needs |
|
|
458
|
+
| `SCRIPT` | `/dev/null` in runs under a terminal on macOS, set by `script` itself |
|
|
459
|
+
|
|
460
|
+
The runs under a terminal are color's second and third, restore's, and control-chars'.
|
|
439
461
|
|
|
440
462
|
## FAQ
|
|
441
463
|
|
|
442
|
-
**Why were ctrl-c, sigterm and control-chars skipped?** They need probes that a plain `--version` and `--help` run doesn't have: ctrl-c and sigterm need a command that keeps running, such as a server or a watcher, and control-chars needs one that prints file names from `{fixture}`. Add them with `--probe`, so one run covers every check: `npx cliprobe --probe "serve --port 0" --probe "list {fixture}" -- my-cli`.
|
|
464
|
+
**Why were ctrl-c, sigterm and control-chars skipped?** They need probes that a plain `--version` and `--help` run doesn't have: ctrl-c and sigterm need a command that keeps running, such as a server or a watcher, and control-chars needs one that prints file names from `{fixture}`. Add them with `--probe`, so one run covers every check: `npx cliprobe --probe "serve --port 0" --probe "list {fixture}" -- my-cli`. If the reason adds that the probe exited with a failure code, it never ran as intended: check its arguments, and with `-- node ./cli.js`, name the script in the probe (`--probe "./cli.js serve"`).
|
|
443
465
|
|
|
444
466
|
**My program works when I run it, so why does a check fail?** cliprobe sets up conditions that are rare by hand: stdout closed before the program starts, output into a pipe, stdin that nobody writes to, a minimal environment. Reproduce the failure the way the check's section shows, for example `my-cli --help | head -n 1` for closed-pipe or `my-cli --help | cat -v` for color, and read the evidence in `--json`. If you still believe the verdict is wrong, [open a wrong verdict issue](https://github.com/KhaledSaeed18/cliprobe/issues/new?template=wrong_verdict.yml).
|
|
445
467
|
|
|
446
|
-
**Why does my program behave differently under cliprobe?** It runs without your shell's variables or your home directory
|
|
468
|
+
**Why does my program behave differently under cliprobe?** It runs without your shell's variables or your home directory, with `TERM=dumb` and `CI=1` in most checks: [the probe's environment](#the-probes-environment) lists every variable. A program that needs a token or a config file from your home directory sees neither, as on a fresh CI runner.
|
|
447
469
|
|
|
448
470
|
**Does a pass mean my CLI has no terminal bugs?** No. Each check tests one behavior, on the probes that ran; a subcommand that wasn't probed wasn't checked. cliprobe reports evidence, not a score, so add a `--probe` for each command your users pipe or interrupt.
|
|
449
471
|
|
package/dist/cli.js
CHANGED
|
@@ -583,7 +583,10 @@ function describeVersion(r) {
|
|
|
583
583
|
function describeHelp(r) {
|
|
584
584
|
const out = lines(r.stdout.toString("utf8"));
|
|
585
585
|
const err = lines(r.stderr);
|
|
586
|
-
if (out.length && r.exitCode === 0)
|
|
586
|
+
if (out.length && r.exitCode === 0) {
|
|
587
|
+
const noun = out.length === 1 ? "line" : "lines";
|
|
588
|
+
return { reason: `printed ${out.length} ${noun} to stdout and exited 0` };
|
|
589
|
+
}
|
|
587
590
|
if (out.length) return { reason: `printed help to stdout but ${exitText(r)}` };
|
|
588
591
|
if (err.length) return { reason: `printed help to stderr and ${exitText(r)}, so "--help | less" and agents reading stdout get nothing` };
|
|
589
592
|
return { reason: `printed nothing and ${exitText(r)}` };
|
|
@@ -667,6 +670,20 @@ function crashEvidence(stderr, messages = CRASH_MESSAGES) {
|
|
|
667
670
|
const cwd = process.cwd() + "/";
|
|
668
671
|
return `${message} (at ${frame.startsWith(cwd) ? frame.slice(cwd.length) : frame})`;
|
|
669
672
|
}
|
|
673
|
+
/**
|
|
674
|
+
* Adds to a SKIP that a probe exited with a failure code, so a probe that never ran
|
|
675
|
+
* as intended (a typo, `--probe watch` running `node watch`) doesn't pass for a quiet
|
|
676
|
+
* skip. The evidence is the error line from stderr, when there is one.
|
|
677
|
+
*/
|
|
678
|
+
function noteFailedExit(judgement, r) {
|
|
679
|
+
if (judgement.verdict !== "skip" || r.exitCode === null || r.exitCode === 0) return judgement;
|
|
680
|
+
const message = crashEvidence(r.stderr);
|
|
681
|
+
return {
|
|
682
|
+
...judgement,
|
|
683
|
+
reason: `${judgement.reason}; it exited ${r.exitCode}, so the probe may not have run as intended`,
|
|
684
|
+
...message && judgement.evidence === void 0 ? { evidence: `stderr: ${message}` } : {}
|
|
685
|
+
};
|
|
686
|
+
}
|
|
670
687
|
// src/core/long-running.ts
|
|
671
688
|
/**
|
|
672
689
|
* Once one check has seen a probe still running at the timeout (a server, a
|
|
@@ -729,10 +746,10 @@ function judge(base, closed) {
|
|
|
729
746
|
reason: `could not start: ${base.spawnError}`
|
|
730
747
|
};
|
|
731
748
|
if (base.timedOut) return judgeLongRunning(base, closed);
|
|
732
|
-
if (base.stdoutBytes === 0) return {
|
|
749
|
+
if (base.stdoutBytes === 0) return noteFailedExit({
|
|
733
750
|
verdict: "skip",
|
|
734
751
|
reason: "wrote nothing to stdout, so a closed stdout is never touched"
|
|
735
|
-
};
|
|
752
|
+
}, base);
|
|
736
753
|
if (closed.timedOut) return {
|
|
737
754
|
verdict: "fail",
|
|
738
755
|
reason: "hung after stdout was closed"
|
|
@@ -1025,7 +1042,7 @@ function detect() {
|
|
|
1025
1042
|
} catch (error) {
|
|
1026
1043
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") return {
|
|
1027
1044
|
ok: false,
|
|
1028
|
-
reason: "script(1) not found; install
|
|
1045
|
+
reason: "script(1) not found; install the package that has it (Debian and Ubuntu: bsdutils; Fedora: util-linux-script; Alpine: util-linux-misc)"
|
|
1029
1046
|
};
|
|
1030
1047
|
}
|
|
1031
1048
|
return {
|
|
@@ -1234,10 +1251,10 @@ function judgeColor(runs) {
|
|
|
1234
1251
|
reason: "no color in a pipe; in a terminal it waited for input, so it was not compared"
|
|
1235
1252
|
};
|
|
1236
1253
|
if (!findStyle(tty.output)) {
|
|
1237
|
-
if (!(runs.pipe.stdoutBytes > 0 || runs.pipe.stderr.length > 0 || tty.output)) return {
|
|
1254
|
+
if (!(runs.pipe.stdoutBytes > 0 || runs.pipe.stderr.length > 0 || tty.output)) return noteFailedExit({
|
|
1238
1255
|
verdict: "skip",
|
|
1239
1256
|
reason: "printed nothing, so there is no color to check"
|
|
1240
|
-
};
|
|
1257
|
+
}, runs.pipe);
|
|
1241
1258
|
return {
|
|
1242
1259
|
verdict: "pass",
|
|
1243
1260
|
reason: "no color in a pipe or in a terminal"
|
|
@@ -1472,10 +1489,13 @@ function judgeControlChars(runs) {
|
|
|
1472
1489
|
verdict: "skip",
|
|
1473
1490
|
reason: "still running in a terminal at the timeout, and had not printed the file names in {fixture}"
|
|
1474
1491
|
};
|
|
1475
|
-
if (!tty.output.includes("plain.txt"))
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1492
|
+
if (!tty.output.includes("plain.txt")) {
|
|
1493
|
+
const skip = {
|
|
1494
|
+
verdict: "skip",
|
|
1495
|
+
reason: "did not print the file names in {fixture}, so there was nothing to escape"
|
|
1496
|
+
};
|
|
1497
|
+
return pipe ? noteFailedExit(skip, pipe) : skip;
|
|
1498
|
+
}
|
|
1479
1499
|
const raw = rawNames(tty.output);
|
|
1480
1500
|
const failing = raw.filter((h) => h.severity === "fail");
|
|
1481
1501
|
if (failing.length) return {
|
|
@@ -1539,13 +1559,16 @@ const controlCharsCheck = {
|
|
|
1539
1559
|
kind: "check",
|
|
1540
1560
|
summary: "prints control characters from file names raw to the terminal",
|
|
1541
1561
|
async run(target, ctx) {
|
|
1542
|
-
if (target.fixtureDir === void 0)
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1562
|
+
if (target.fixtureDir === void 0) {
|
|
1563
|
+
const own = target.probes.filter((p) => p.own);
|
|
1564
|
+
return (own.length ? own.map((p) => [target.command, ...p.args]) : [[target.command]]).map((invocation) => ({
|
|
1565
|
+
check: "control-chars",
|
|
1566
|
+
invocation,
|
|
1567
|
+
...judgeControlChars({ usesFixture: false }),
|
|
1568
|
+
terminalRaw: [],
|
|
1569
|
+
pipeRaw: []
|
|
1570
|
+
}));
|
|
1571
|
+
}
|
|
1549
1572
|
const dir = target.fixtureDir;
|
|
1550
1573
|
const results = [];
|
|
1551
1574
|
for (const { args } of target.probes.filter((p) => p.args.some((a) => a.includes(dir)))) results.push(await controlChars(target.command, args, dir, ctx));
|
|
@@ -1576,10 +1599,10 @@ function judgeSigterm(r) {
|
|
|
1576
1599
|
verdict: "error",
|
|
1577
1600
|
reason: `could not start: ${r.spawnError}`
|
|
1578
1601
|
};
|
|
1579
|
-
if (r.signalSentMs === void 0) return {
|
|
1602
|
+
if (r.signalSentMs === void 0) return noteFailedExit({
|
|
1580
1603
|
verdict: "skip",
|
|
1581
1604
|
reason: `finished in ${r.durationMs} ms, before SIGTERM at ${SIGTERM_DELAY_MS} ms; probe a command that keeps running`
|
|
1582
|
-
};
|
|
1605
|
+
}, r);
|
|
1583
1606
|
if (r.timedOut) return {
|
|
1584
1607
|
verdict: "warn",
|
|
1585
1608
|
reason: `ignored SIGTERM: still running ${SIGTERM_GRACE_MS / 1e3} s later, so docker stop or a process manager has to kill it`
|
|
@@ -1666,10 +1689,10 @@ function judgeCtrlC(r) {
|
|
|
1666
1689
|
verdict: "error",
|
|
1667
1690
|
reason: `could not start: ${r.spawnError}`
|
|
1668
1691
|
};
|
|
1669
|
-
if (r.signalSentMs === void 0) return {
|
|
1692
|
+
if (r.signalSentMs === void 0) return noteFailedExit({
|
|
1670
1693
|
verdict: "skip",
|
|
1671
1694
|
reason: `finished in ${r.durationMs} ms, before Ctrl-C at ${CTRL_C_DELAY_MS} ms; probe a command that keeps running`
|
|
1672
|
-
};
|
|
1695
|
+
}, r);
|
|
1673
1696
|
if (r.timedOut) return {
|
|
1674
1697
|
verdict: "fail",
|
|
1675
1698
|
reason: `ignored Ctrl-C: still running ${CTRL_C_GRACE_MS / 1e3} s later`
|
|
@@ -1795,10 +1818,10 @@ function judgePipeEscapes(r) {
|
|
|
1795
1818
|
if (!stdout && !r.stderr) return r.timedOut ? {
|
|
1796
1819
|
verdict: "skip",
|
|
1797
1820
|
reason: `${stillRunning(r.durationMs)} and printed nothing so far`
|
|
1798
|
-
} : {
|
|
1821
|
+
} : noteFailedExit({
|
|
1799
1822
|
verdict: "skip",
|
|
1800
1823
|
reason: "printed nothing, so there is nothing to check"
|
|
1801
|
-
};
|
|
1824
|
+
}, r);
|
|
1802
1825
|
if (r.timedOut) return {
|
|
1803
1826
|
verdict: "pass",
|
|
1804
1827
|
reason: `no cursor, erase, hyperlink, title or redraw codes in a pipe (${stillRunning(r.durationMs)})`
|
|
@@ -1846,7 +1869,6 @@ function listLabels(modes) {
|
|
|
1846
1869
|
const WRAPPER_EXEC_FAILED = /^sh: [^\n]*(cannot execute|exec format error)/i;
|
|
1847
1870
|
/** What the Ctrl-C key sends to a terminal. */
|
|
1848
1871
|
const CTRL_C_KEY = "";
|
|
1849
|
-
const showSequence = (sequence) => sequence.replaceAll("\x1B", "ESC");
|
|
1850
1872
|
function judgeRestore(r) {
|
|
1851
1873
|
if (r.spawnError) return {
|
|
1852
1874
|
verdict: "error",
|
|
@@ -1866,7 +1888,7 @@ function judgeRestore(r) {
|
|
|
1866
1888
|
if (open.length > 0) return {
|
|
1867
1889
|
verdict: "warn",
|
|
1868
1890
|
reason: `left the terminal with ${listLabels(open)} ${when}`,
|
|
1869
|
-
evidence: open.map((m) => `${
|
|
1891
|
+
evidence: open.map((m) => `${m.sequence} on line ${m.line}, never undone`).join("; ")
|
|
1870
1892
|
};
|
|
1871
1893
|
return {
|
|
1872
1894
|
verdict: "pass",
|
|
@@ -2274,20 +2296,41 @@ const COLORS = {
|
|
|
2274
2296
|
error: 35,
|
|
2275
2297
|
info: 36
|
|
2276
2298
|
};
|
|
2299
|
+
const CUT = " ... (--json has the rest)";
|
|
2300
|
+
/**
|
|
2301
|
+
* Evidence for one line of the report: escaped as safe() does, with a backslash from
|
|
2302
|
+
* the program doubled, so the text `\x1b` can't pass for a real escape. Past the limit
|
|
2303
|
+
* it ends at a word, or between two escapes, never inside one, and says it was cut.
|
|
2304
|
+
*/
|
|
2305
|
+
function showEvidence(evidence, limit = 200) {
|
|
2306
|
+
const pieces = Array.from(evidence, (c) => c === "\\" ? "\\\\" : safe(c));
|
|
2307
|
+
let shown = "";
|
|
2308
|
+
let wordEnd = 0;
|
|
2309
|
+
for (const piece of pieces) {
|
|
2310
|
+
if (shown.length + piece.length > limit) return (wordEnd > limit * .6 ? shown.slice(0, wordEnd) : shown) + CUT;
|
|
2311
|
+
if (piece === " ") wordEnd = shown.length;
|
|
2312
|
+
shown += piece;
|
|
2313
|
+
}
|
|
2314
|
+
return shown;
|
|
2315
|
+
}
|
|
2277
2316
|
function formatHuman({ version, command, checks, strict, results }, { color }) {
|
|
2278
2317
|
const paint = (verdict) => {
|
|
2279
2318
|
const label = verdict.toUpperCase().padEnd(5);
|
|
2280
2319
|
return color ? `\x1b[${COLORS[verdict]}m${label}\x1b[0m` : label;
|
|
2281
2320
|
};
|
|
2282
|
-
const
|
|
2321
|
+
const shownInvocation = (invocation) => safe(shellJoin(invocation));
|
|
2322
|
+
const width = Math.max(0, ...results.map((r) => shownInvocation(r.invocation).length).filter((length) => length <= 40));
|
|
2323
|
+
const indent = ` ${" ".repeat(5)} ${" ".repeat(width)} `;
|
|
2283
2324
|
const noun = checks.length === 1 ? "check" : "checks";
|
|
2284
2325
|
const lines = [`cliprobe ${version}: ${checks.join(", ")} ${noun} for ${safe(command)}`];
|
|
2285
2326
|
for (const check of checks) {
|
|
2286
2327
|
lines.push("");
|
|
2287
2328
|
if (checks.length > 1) lines.push(check);
|
|
2288
2329
|
for (const r of results.filter((result) => result.check === check)) {
|
|
2289
|
-
|
|
2290
|
-
if (
|
|
2330
|
+
const invocation = shownInvocation(r.invocation);
|
|
2331
|
+
if (invocation.length > width) lines.push(` ${paint(r.verdict)} ${invocation}`, `${indent}${safe(r.reason)}`);
|
|
2332
|
+
else lines.push(` ${paint(r.verdict)} ${invocation.padEnd(width)} ${safe(r.reason)}`);
|
|
2333
|
+
if (r.evidence) lines.push(`${indent}${showEvidence(r.evidence)}`);
|
|
2291
2334
|
}
|
|
2292
2335
|
}
|
|
2293
2336
|
lines.push("", summaryLine(countVerdicts(results), strict));
|
|
@@ -2748,7 +2791,9 @@ Options:
|
|
|
2748
2791
|
program, a server) instead of --version and --help
|
|
2749
2792
|
--probe <args> Also probe "<command> <args>"; repeat it for several. Split
|
|
2750
2793
|
like a shell command line: quotes and backslashes work,
|
|
2751
|
-
variables and wildcards are not expanded
|
|
2794
|
+
variables and wildcards are not expanded. The args after
|
|
2795
|
+
<command> are not kept, so name the script in each probe:
|
|
2796
|
+
cliprobe --probe "./cli.js watch" -- node ./cli.js
|
|
2752
2797
|
--check <name> Run only this check; repeat it or use commas for several
|
|
2753
2798
|
--skip <name> Leave this check out; repeat it or use commas for several
|
|
2754
2799
|
--strict Exit 1 on a warning too, not only on a failure
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cliprobe",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4",
|
|
4
4
|
"description": "Black-box test any command-line program for terminal-edge bugs: crashes on a closed pipe (| head), color and control codes leaking into pipes, hangs waiting on stdin, broken Ctrl-C handling, child processes left running after SIGTERM, a terminal left broken after Ctrl-C, and control characters from file names reaching your terminal.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"oxlint-tsgolint": "^7.0.2007",
|
|
98
98
|
"prettier": "^3.10.1",
|
|
99
99
|
"publint": "^0.3.25",
|
|
100
|
-
"semantic-release": "^
|
|
100
|
+
"semantic-release": "^26.0.1",
|
|
101
101
|
"tsdown": "^0.23.1",
|
|
102
102
|
"typescript": "^7.0.2",
|
|
103
103
|
"vitest": "^5.1.0"
|