rackunit icon indicating copy to clipboard operation
rackunit copied to clipboard

pretty-printing in test failures does not seem to indent enough

Open rfindler opened this issue 2 years ago • 3 comments

In this program:

#lang racket
(require rackunit)
(check-equal? (make-list 20 'xxxx) #f)

I see this output:

--------------------
. FAILURE
name:       check-equal?
location:   34-unsaved-editor:3:0
actual:
  '(xxxx
  xxxx
  xxxx
  xxxx
  xxxx
  xxxx
  xxxx
  xxxx
  xxxx
  xxxx
  xxxx
  xxxx
  xxxx
  xxxx
  xxxx
  xxxx
  xxxx
  xxxx
  xxxx
  xxxx)
expected:   #f
--------------------

I think the lines with the xxxx in them (except the first one) need to be two more spaces to the right.

rfindler avatar Jul 18 '22 22:07 rfindler

FWIW, here's code that indents exception printing.

https://github.com/racket/rackunit/commit/1c4730dab73354c2afa743213d2f2f7ff640e9f3

I think printing a value would require doing something similar, unless we can specify to racket/pretty directly that it needs to indent text further.

sorawee avatar Jul 18 '22 22:07 sorawee

FWIW, here's code that indents exception printing.

1c4730d

I think printing a value would require doing something similar, unless we can specify to racket/pretty directly that it needs to indent text further.

This code looks okay to me. The problematic code should be the code that calls pretty-print, I think. That is, I expect the issue to be the way racket/pretty is used, as you say.

rfindler avatar Jul 18 '22 23:07 rfindler

The call to pretty-print is in rackunit/private/check-info and there is some configuration of parameters in rackunit/private/format.

samth avatar Jul 19 '22 14:07 samth