Are there any good options for checking colored output in your tests that work across julia versions?
I keep coming across this issue where I want to validate that some colored output shows up correctly, but the issue is that the exact escape codes used change between Julia versions, so I end up having ugly switches in my test code with differently-escaped versions of the same text.
I’ve thought about writing about something to normalize strings to some kind of canonical representation that can be compared, but I wanted to check to see if there’s a solution already out there.
I looked at Crayons.jl a little but it wasn’t clear how it would help my testing case.
As a more concrete example, my DeepDiffs.jl package displays diffs of a variety of datatypes, and can pretty-print them with red/green highlighting:
Testing the printing functionality is pretty gnarly and each test case needs multiple expected output samples depending on the Julia version. What I really want is a way to test that the output appears a certain way to the user, without being sensitive to exactly the sequence of escape characters used to do the coloring.
I suppose if I used Crayons.jl to do the coloring than the output wouldn’t change with Julia versions, but then it might change with Crayons versions.
additionally - it would be great if I could refactor how I do the printing (which might change the escaping) without needing to regenerate my example output.