4 ms·
How does one go about unit testing those terminal controlling functions?
by jxy 6y ago
How does one go about unit testing those terminal controlling functions?
- neilv 6y agoIf you're not using much system calls, one simple way is to capture the byte sequences that would be sent to the terminal, and simulate the byte sequences that would be received. (A terminal library I wrote, which doesn't do as much as this CL one, uses byte stream I/O almost entirely. https://www.neilvandyke.org/racket/charterm/ https://www.neilvandyke.org/racket/charterm/ ) Another option might be to connect it to `screen` or `tmux`, and scrape the characters and attributes from there, or feed it to a terminal GUI program like `xterm` and scrape the pixels from there. And synthesize the input to the terminal emulator.