Conversation
For asserting command output, exact string matches are preferred in most cases. In cases when a pattern match is needed, the test can use regexp ad hoc.
|
this means having to deal with escape codes. a lot of the use of regexp is to not have to worry about escape codes, not to deal with dynamic input. i don't see this as urgent technical debt; is there a particular place where regexp testing bit us? |
It used to be, but we never output ANSI escape codes in tests anymore, even those that are in "TTY" mode, since Even if we were outputting ANSI escape codes, I would still suggest that we do exact matching of output after we manually stripped them. So, it would be something like: output = stripansi.Strip(stdout.String())
assert.Equal(t, "...", output)But I'm not sure if there is a single place in the codebase where we would need to apply such an approach right now.
No, it's not an urgent technical debt. I'm trying to get us to the point where we can drop the ambiguously named |
vilmibm
left a comment
There was a problem hiding this comment.
ah, I forgot about the newer iostreams's test instances. I'm fine with this, then.
For asserting command output, exact string matches are preferred in most cases. In cases when a pattern match is needed, the test can use regexp ad hoc.