cliprobe 1.5.0 → 1.5.1

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 (3) hide show
  1. package/README.md +8 -6
  2. package/dist/cli.js +20 -7
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -293,15 +293,17 @@ In the census of the top 100 npm CLIs, 9 of 238 `--help` and `--version` runs fa
293
293
 
294
294
  cliprobe lets the command run for 1 second, then sends SIGINT to its process group, which is what a terminal does when you press Ctrl-C, and gives it 3 seconds to exit. stdin is left open, as a terminal leaves it, so a server that stops at the end of stdin (`esbuild --serve`) keeps running until the Ctrl-C. Results:
295
295
 
296
- | Verdict | Meaning |
297
- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
298
- | `PASS` | Stopped by SIGINT, exited 130 (the convention), or exited with another failure code |
299
- | `FAIL` | Still running 3 seconds later, or printed a stack trace or traceback after the Ctrl-C |
300
- | `WARN` | Exited 0, so a script or an agent can't tell the work was interrupted, or exited but left processes running that ignored the Ctrl-C (the evidence names the first) |
301
- | `SKIP` | Finished before the Ctrl-C, as `--version` and `--help` do: probe a command that keeps running |
296
+ | Verdict | Meaning |
297
+ | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
298
+ | `PASS` | Stopped by SIGINT, exited 130 (the convention), or exited with another failure code |
299
+ | `FAIL` | Still running 3 seconds later, or printed a stack trace or traceback after the Ctrl-C |
300
+ | `WARN` | Exited 0, so a script or an agent can't tell the work was interrupted, or exited but left processes running that ignored the Ctrl-C (the evidence names the first) |
301
+ | `SKIP` | Finished before the Ctrl-C, as `--version` and `--help` do: probe a command that keeps running. With `--bare`, also a command still running after the Ctrl-C that never printed anything, as a REPL does |
302
302
 
303
303
  A stack trace printed before the Ctrl-C doesn't count. Python's default `KeyboardInterrupt` traceback is the classic failure here, so `python3 -c 'import time; time.sleep(30)'` fails. Across 42 watch modes, dev servers and long tasks run offline (vite, webpack, tsc, jest, Next.js, Nuxt, Astro, wrangler, nodemon and more), every one stopped within 60 ms of the Ctrl-C, whether it came after 1, 3 or 6 seconds, so the timing rarely matters. 13 of them exit 0 on purpose, among them `tsc --watch`, webpack, `next dev` and `nuxt dev`: that is a warn, not a fail.
304
304
 
305
+ A REPL run with `--bare` (`npx cliprobe --bare -- python3`) gets a pipe as stdin here, not a terminal, so it waits to read a script and may not stop on Ctrl-C, which nobody at a terminal sees. So with `--bare`, a command that is still running 3 seconds after the Ctrl-C and never printed anything is skipped, as restore skips REPLs, rather than failed. One that printed something first, such as a server's banner, still fails. To check a REPL's Ctrl-C, try it in a terminal.
306
+
305
307
  The verdict is about the program itself: it passes once it exits, even if a child still holds its output open. What it leaves running gets 1 more second to follow, then is listed and killed. A process still there ignored the Ctrl-C, as a shell's background job does (`sh -c 'worker & server'`), so it would outlive the terminal's Ctrl-C too: that is a warn, added in 1.4.
306
308
 
307
309
  ### sigterm
package/dist/cli.js CHANGED
@@ -1710,7 +1710,12 @@ const CTRL_C_GRACE_MS = 3e3;
1710
1710
  const CTRL_C_LEFTOVERS_MS = 1e3;
1711
1711
  /** Lines worth quoting from a trace printed on Ctrl-C, best first. */
1712
1712
  const TRACE_MESSAGES = [/^(KeyboardInterrupt|\w*Error\b|\w*Exception\b|panic:)/, TRACE_RE];
1713
- function judgeCtrlC(r) {
1713
+ /**
1714
+ * `bare` is true for the --bare probe, the command with no arguments. A REPL run that
1715
+ * way (python3) gets a pipe as stdin, reads it as a script and doesn't stop on SIGINT,
1716
+ * which no one at a terminal sees; restore, under a terminal, skips REPLs too (#43).
1717
+ */
1718
+ function judgeCtrlC(r, bare = false) {
1714
1719
  if (r.spawnError) return {
1715
1720
  verdict: "error",
1716
1721
  reason: `could not start: ${r.spawnError}`
@@ -1719,10 +1724,16 @@ function judgeCtrlC(r) {
1719
1724
  verdict: "skip",
1720
1725
  reason: `finished in ${r.durationMs} ms, before Ctrl-C at ${CTRL_C_DELAY_MS} ms; probe a command that keeps running`
1721
1726
  }, r);
1722
- if (r.timedOut) return {
1723
- verdict: "fail",
1724
- reason: `ignored Ctrl-C: still running ${CTRL_C_GRACE_MS / 1e3} s later`
1725
- };
1727
+ if (r.timedOut) {
1728
+ if (bare && r.stdoutBytes === 0 && r.stderr === "") return {
1729
+ verdict: "skip",
1730
+ reason: `still running ${CTRL_C_GRACE_MS / 1e3} s after Ctrl-C without printing anything, as a REPL does when stdin is a pipe (it waits for a script, not a keypress); run it in a terminal to check its Ctrl-C`
1731
+ };
1732
+ return {
1733
+ verdict: "fail",
1734
+ reason: `ignored Ctrl-C: still running ${CTRL_C_GRACE_MS / 1e3} s later`
1735
+ };
1736
+ }
1726
1737
  const after = r.stderr.slice(r.stderrAtSignal ?? 0);
1727
1738
  const ms = `${r.durationMs - r.signalSentMs} ms`;
1728
1739
  if (TRACE_RE.test(after)) return {
@@ -1770,7 +1781,7 @@ async function ctrlC(command, args) {
1770
1781
  return {
1771
1782
  check: "ctrl-c",
1772
1783
  invocation: [command, ...args],
1773
- ...judgeCtrlC(r),
1784
+ ...judgeCtrlC(r, args.length === 0),
1774
1785
  sentAfterMs: sent ?? null,
1775
1786
  exitedAfterMs: sent === void 0 || r.timedOut ? null : r.durationMs - sent,
1776
1787
  exitCode: r.exitCode,
@@ -2802,7 +2813,9 @@ Checks:
2802
2813
  prints a stack trace; warns if it exits 0, or exits and leaves
2803
2814
  processes running that ignored the Ctrl-C. Skipped when the
2804
2815
  command finishes first, so probe a command that keeps running
2805
- (a watcher, a server, a long task), e.g. with --probe "serve".
2816
+ (a watcher, a server, a long task), e.g. with --probe "serve";
2817
+ with --bare, also when a silent command outlives the Ctrl-C,
2818
+ as a REPL reading a pipe does.
2806
2819
  sigterm Sends SIGTERM to the command alone after 1 s, as kill, docker
2807
2820
  stop and process managers do. Warns if it is still running 3 s
2808
2821
  later, prints a stack trace, or exits and leaves child
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cliprobe",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
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": {