Idris2 icon indicating copy to clipboard operation
Idris2 copied to clipboard

[ golden ] Truncate long test names when printing the results

Open buzden opened this issue 3 years ago • 11 comments

or else they are printed together with no space and this does not look beautiful:

no-gap

buzden avatar Jun 21 '22 14:06 buzden

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

gallais avatar Jun 21 '22 17:06 gallais

Yes, we can. It's not terrifyingly beautiful, but anyway better than status-quo

munched

buzden avatar Jun 21 '22 19:06 buzden

To be clear, I added this munching functionality to this PR

buzden avatar Jun 22 '22 09:06 buzden

:+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

gallais avatar Jun 22 '22 09:06 gallais

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:

buzden avatar Jun 22 '22 09:06 buzden

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.

mattpolzin avatar Jun 22 '22 14:06 mattpolzin

To be clear, I renamed functions to contain truncate as Mathew suggested

buzden avatar Jun 27 '22 08:06 buzden

"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

  1. truncateLeft : (width : Nat) -> String -> String
  2. path = "(...)" ++ truncateLeft (width minus (5 + msgl + length time)) path

?

gallais avatar Jun 27 '22 10:06 gallais

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?

buzden avatar Jun 27 '22 10:06 buzden

  1. truncateLeft : (width : Nat) -> String -> String

Hmmm, we already have in the same module functions take and takeLast with meanings of truncateRight and truncateLeft correspondingly...

buzden avatar Jun 27 '22 11:06 buzden

So maybe a refactoring with

  1. truncateLeft : (width : Nat) -> String -> String
  2. path = "(...)" ++ truncateLeft (width minus (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

buzden avatar Jun 27 '22 11:06 buzden

Is this ready for merging, or is there still work to be done? : )

CodingCellist avatar Oct 06 '22 07:10 CodingCellist

It's mostly a naming issue. :(

gallais avatar Oct 06 '22 08:10 gallais

How about (left/right)Ellipsis? Because that's effectively what we are doing here!

gallais avatar Oct 06 '22 14:10 gallais

How about (left/right)Ellipsis? Because that's effectively what we are doing here!

Why not. I've renamed and rebased using this

buzden avatar Oct 06 '22 16:10 buzden