aboutsummaryrefslogtreecommitdiff
path: root/tests/test-prog-webdev-format.el
Commit message (Collapse)AuthorAgeFilesLines
* refactor(prog): run JSON/YAML/webdev formatters via argv, not a shellCraig Jennings11 days1-31/+66
| | | | | | | | cj/json-format-buffer, cj/yaml-format-buffer, and cj/webdev-format-buffer ran their formatters through shell-command-on-region, which goes via a shell. I moved each to call-process-region with an explicit program and argv list, so a filename or buffer content can't be word-split or read as shell syntax. The webdev path dropped its shell-quote-argument dance once the filename became a plain argv element. Point preservation is unchanged. One deliberate improvement, and it's tested: shell-command-on-region with replace replaced the buffer with the formatter's error text on a non-zero exit. The new per-formatter helper captures output to a temp buffer, checks the exit code, replaces only on success, and otherwise raises a user-error carrying stderr — so a failed format leaves the buffer alone. I kept a small format-region helper in each of the three modules rather than one shared helper. They have no common module to live in short of system-lib, and coupling three unrelated domain modules through it wasn't worth saving sixteen lines.
* test(prog-webdev): cover cj/webdev-format-bufferCraig Jennings2026-05-121-0/+93
I added `tests/test-prog-webdev-format.el` — 7 ERT tests over `cj/--webdev-format-command` (plain path, spaces-quoted, `.tsx`) and `cj/webdev-format-buffer` (prettier present → the region command targets `buffer-file-name`; the `file.ts` fallback when the buffer has no file; point clamps to `point-max` when the format shrinks the buffer; prettier missing → `user-error`). `executable-find` and `shell-command-on-region` are stubbed. `cj/webdev-keybindings` was already covered by `test-prog-webdev--format-wiring.el`.