vesln / nixt

Simple and elegant end-to-end testing for command-line apps
MIT License
310 stars 19 forks source link

Update regexes so that it doesn't strip first \n #4

Closed tivac closed 10 years ago

tivac commented 10 years ago

I started trying to use nixt on a project and while I love the API, it was weirdly stripping the very first \n in my stdout/stderr strings. I did some digging around and I'm pretty sure I tracked down why.

It has to do with operator precedence inside regexes, here's an example of what is happening. You can fix it in a couple of ways, either by using a non-capturing group or just by dropping the OR entirely since I don't think a \r by itself should be appearing anywhere. I chose to drop the OR entirely, but it'd be trivial to add back in & use a group instead.

For my own sanity I fleshed out the newline tests a bit by adding \r\n tests & a fixture as well, just to make sure I wasn't regressing anything.

coveralls commented 10 years ago

Coverage Status

Coverage remained the same when pulling c5e8278b84015adc3bf1e543055219cdef756459 on tivac:formatter-newlines into daa9eb154a8fdf7fe291ef0408279df307cf255a on vesln:master.

vesln commented 10 years ago

Thanks!