Idris2
Idris2 copied to clipboard
[ golden ] Truncate long test names when printing the results
or else they are printed together with no space and this does not look beautiful:

Can we not munch some of the prefix instead and print e.g.
(...)derivation/core/norec t-pi->.. w_ext 003-neg: success NN.NNNs
Yes, we can. It's not terrifyingly beautiful, but anyway better than status-quo

To be clear, I added this munching functionality to this PR
:+1: Let's see if someone has a suggestion for a better name for these strange padding functions.
Edit: I guess we could right-align the success/FAILURE too to make things neater
Edit: I guess we could right-align the success/FAILURE too to make things neater
I thought about it too, but decided that it may be inconvenient in the case when test names are short :shrug:
RE naming the new functions: no strong preference from me, but if you use the word “truncate” somewhere in the documentation (if not the function name) then I think it will be more discoverable. That’s the word I’d search for.
To be clear, I renamed functions to contain truncate as Mathew suggested
"munch" more or less means the same as "truncate" but is more colloquial so I think we could keep "truncate". But I wouldn't expect a truncate function to introduce a (pre/suf)fix. So maybe a refactoring with
truncateLeft : (width : Nat) -> String -> Stringpath = "(...)" ++ truncateLeft (widthminus(5 + msgl + length time)) path
?
So maybe a refactoring with
Well, I put it in a separate function because I thought it could be valuable to others in a similar situation, when one needs to fit a string to a particular length while printing some prefix or suffix in case of truncation. And the original name was (for me) saying `fit the string to a particular length while munching it left if it was not fit".
I'd rather, then, split functions to a pair of truncateLeft with a signature you say and the original fitMunchLeft implemented through truncateLeft. WDYT?
- truncateLeft : (width : Nat) -> String -> String
Hmmm, we already have in the same module functions take and takeLast with meanings of truncateRight and truncateLeft correspondingly...
So maybe a refactoring with
truncateLeft : (width : Nat) -> String -> Stringpath = "(...)" ++ truncateLeft (widthminus(5 + msgl + length time)) path
By the way, this would lead to printing (...) even on short strings. All the meaning of my truncateMunchLeft (or fitMunchLeft) was to add prefix only when it's needed
Is this ready for merging, or is there still work to be done? : )
It's mostly a naming issue. :(
How about (left/right)Ellipsis? Because that's effectively what we are doing here!
How about
(left/right)Ellipsis? Because that's effectively what we are doing here!
Why not. I've renamed and rebased using this