Skip to content

Conversation

@lf-
Copy link
Contributor

@lf- lf- commented Feb 5, 2025

Wew. That was a bug.

The reproducer is here: https://github.com/rampion/ghciwatch-bug-demo

After tracing consume_str, I found out that the cause of our problems is that hspec includes the NL in their coloured output before resetting colour.

https://github.com/hspec/hspec/blob/fb9916f07e580f2572220d381e1886e765df95b7/hspec-core/src/Test/Hspec/Core/Formatters/Internal.hs#L297-L306

That means that it is a pain in the ass to parse, since it shoves random ANSI escapes onto the next line. The easiest, and probably most correct, solution to this is to just eat ANSI escapes while looking for markers.

  • Labeled the PR with patch, minor, or major to request a version bump when it's merged.
  • Updated the user manual in docs/.
  • Added integration / regression tests in tests/.

@lf- lf- requested a review from 9999years February 5, 2025 23:21
@linear
Copy link

linear bot commented Feb 5, 2025

@lf- lf- added the patch Bug fixes or non-functional changes label Feb 5, 2025
@lf-
Copy link
Contributor Author

lf- commented Feb 5, 2025

I probably should shove an integration test in there as well, since maybe hspec might do new and creative evil stuff in the future. OTOH this seems like a pain and we have a regression test for the internal logic at least.

Wew. That was a bug.

The reproducer is here: https://github.com/rampion/ghciwatch-bug-demo

After tracing `consume_str`, I found out that the cause of our problems
is that hspec includes the NL in their coloured output before resetting
colour.

https://github.com/hspec/hspec/blob/fb9916f07e580f2572220d381e1886e765df95b7/hspec-core/src/Test/Hspec/Core/Formatters/Internal.hs#L297-L306

That means that it is a pain in the ass to parse, since it shoves random
ANSI escapes onto the next line. The easiest, and probably most correct,
solution to this is to just eat ANSI escapes while looking for markers.
@lf- lf- force-pushed the jadel/dux-3004--color-prevents-tests-from-being-run branch from 29ec75c to 744f6fb Compare February 5, 2025 23:27
Copy link
Member

@9999years 9999years left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is fine? We could also relax the constraint that matches happen at the start of the line, but that's probably a more invasive change. I do wonder if there's other libraries that don't write a trailing newline though.

Actually, I just checked, and putStr "puppy" has the same problem. We probably do need to just fix this so it doesn't require the prompt is on the start of the line.

Happy to merge this as a first-line bugfix, but we should do a more complete fix soon (#346).

@lf- lf- merged commit 600e83e into main Feb 6, 2025
39 checks passed
@lf- lf- deleted the jadel/dux-3004--color-prevents-tests-from-being-run branch February 6, 2025 16:59
@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Bug fixes or non-functional changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants