test (driven development) frameworks for completion scripts
Paul Seyfert <[email protected]> Sun, 28 Dec 2025 22:02:11 +0100
| Newsgroups | gmane.comp.shells.zsh.devel,gmane.comp.shells.zsh.user |
|---|---|
| Message-ID | <[email protected]> |
Hi now and then i write / bodge zsh completion scripts into a "good enough for me" state. And because too much time passes between these hacks, I always forget all the details in between and re-read the zshcompsys man page and try&error around. usually the workflow is: open editor with the script + an open terminal, and after every save in the editor i start another zsh in the terminal, test my change by copy&pasting a half written command and hit tab to see what completions I get offered. (and then close the zsh again, such that i'm constantly going up and down one SHLVL). But that seems a bit repetitive and i'm wondering if there's a unit test framework for completion functions? That would allow doing some test driven development. Like, I could say `main_command subcommand --flag A --<TAB>` should suggest `--otherflag`, `--flag`, but not `--yet_another_flag` (with which i'm testing if i got _arguments "(--yet_another_flag)*--flag=[…]:X:` spelled out correctly). No need for anything crazy fancy, just to ease the manual iterations, no need to worry about portability or long term stability (what if i call `main_command --list-formats` and get a new version of `main_command`? doesn't matter. what if on a different device a user has different `zstyle`? doesn't matter, it should speed things up now and here and if a different user wants different output, they can have it) Maybe I'm just missing how to get the completion suggestions into a different shell function instead of displayed to me. Anyways, somebody must have thought of this before. Any pointers / suggestions? Thanks, Paul