hspec / hspec-hedgehog

A library to integrate hedgehog tests into your hspec test suite.
https://hackage.haskell.org/package/hspec-hedgehog
Other
28 stars 6 forks source link

Regard `--color` / `--no-color` #24

Closed sol closed 1 year ago

sol commented 1 year ago

(relies on https://github.com/hspec/hspec/blob/main/CHANGES.markdown#changes-in-2110-2023-04-21)

sol commented 1 year ago

@parsonsmatt this is ready to go.

sol commented 1 year ago

Just so I understand correctly - this skips the hedgehog color check and instead uses the hspec --color and --no-color options, where --no-color strips out the ANSI codes.

Correct.

Hedgehog's detectColor function does some other logic, though, like HEDGEHOG_COLOR env var check and ensuring the logged in user isn't mth lol.

I feel like we can retain the functionality here with a much broader range of hspec versions by detecting color as-is, and then use CPP to use either Reason or ColorizedReason.

If I understand you correctly, then no, I don't think that would solve my use case. If I specify --color and e.g. redirect stdout then detectColor will return False. As a consequence I will end up without colors, even though I requested them.

I'm hesitant to force consumers to upgrade to the latest hspec versions only for this

Do you think there is any tangible benefit from doing this, that is relevant enough to offsets the additional complexity? Note that existing users can continue to use 0.0.1.2 with older versions of hspec.

sol commented 1 year ago

@parsonsmatt any chance to get this merged sometime soon? Maintaining and using my private fork, which is not on Hackage, will eventually be too much overhead for me.

parsonsmatt commented 1 year ago

Sure - please make a version bump and changelog entry and I'll have it released asap. Thanks!

sol commented 1 year ago

Sure - please make a version bump and changelog entry and I'll have it released asap. Thanks!

Done as a separate PR (#27) to not unnecessarily cause conflicts.