Closed emlyn closed 6 years ago
Interesting. Can you provide a test case that I can use to try this out?
Sure, I'll try to put together a minimal case and let you know.
Here's a demo of the issue: https://github.com/emlyn/ultratest
The output (of lein test
) with the current version of ultra looks like:
Notice the output from the long running test (on stderr) between the expected/actual output and the diff output. With this PR it looks like:
There is still some messing up with indenting, so I tried making sure the last output is a println
instead of a print
(instead of flushing), and then I get:
Which looks better, so I'm pushing that change to this PR, but maybe there's a reason that the output doesn't end in a newline, and this breaks something else.
Ping @venantius, in case you didn't see the above.
Hey -- sorry, haven't forgotten this, just a little buried with work. Will try to get you a review this weekend.
Okay I just pulled your patch and did some fussing with it. I'd like to preserve the existing newlines but obviously would prefer to avoid the unusual indentation. I believe this patch, applied to your current work, should suffice:
diff --git a/src/ultra/test/diff.clj b/src/ultra/test/diff.clj
index 0e8746c..d7e1c78 100644
--- a/src/ultra/test/diff.clj
+++ b/src/ultra/test/diff.clj
@@ -71,7 +71,7 @@
[a b actual expected]
(print-expected actual expected)
(print "\n diff:")
- (println (str-diff/clean-difform-str a b)))
+ (print (str-diff/clean-difform-str a b)))
(defmethod prn-diffs ::wrong-class
[a b actual expected]
@@ -86,7 +86,7 @@
(class b)))]
(println (clojure.string/trim (indent a 10)))
(print " was: ")
- (println (indent b 10)))))
+ (print (indent b 10)))))
(defmethod prn-diffs ::diff-vecs
[a b actual expected]
@@ -114,5 +114,5 @@
(when b
(print (ansi/sgr " + " :green))
(let [b (with-out-str (cprint b))]
- (print (indent b 12))))
- (println))
+ (print (s/trimr (indent b 12)))
+ (println))))
That seems to work, thanks! I've applied it to my branch.
When tests take a while to run, the diff output is not displayed immediately on failing tests, because it doesn't end in a newline. I've added a flush in these cases so that the output is visible as soon as the test fails (or maybe it would be better to add a newline at the end?)