I've started adding some coloring and other functionality (line resets, etc.) to my application and would like to have some unit tests covering the behavior.
I know I could just assert that the output contains the appropriate \e[...
codes, but that's brittle. For one, it would fail if it were swapped to \033
or otherwise refactored in trivial but not identical ways.
More to the point however, testing the sequence of characters doesn't really do what I want. I want to assert or verify that the behavior hasn't changed (or even works at all in a particular environment).
Is there any reasonable way to test the result of an ANSI escape sequence? For instance, can I programatically inspect the contents of a terminal / tty?
Aucun commentaire:
Enregistrer un commentaire