aboutsummaryrefslogtreecommitdiff
path: root/module/hnh/test/util.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2023-10-16 15:04:30 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2023-10-16 15:04:30 +0200
commit0d600b53df3ab20cc3b9ab84ee5c79e5afe41b96 (patch)
treef7fd385a9a24337e8a302dffe2e9bee0bc180d80 /module/hnh/test/util.scm
parentAdd number of clearifying comments + minor cleanup. (diff)
downloadcalp-0d600b53df3ab20cc3b9ab84ee5c79e5afe41b96.tar.gz
calp-0d600b53df3ab20cc3b9ab84ee5c79e5afe41b96.tar.xz
Better test diffs for strings.
Previously everything was passed through pretty print, meaning that strings would be squashed to one line. Instead handle strings separately, and do a line diff on them, but still pretty print actual scheme structures. Also change display to write to be able to differentiate different forms which prints the same.
Diffstat (limited to 'module/hnh/test/util.scm')
-rw-r--r--module/hnh/test/util.scm14
1 files changed, 12 insertions, 2 deletions
diff --git a/module/hnh/test/util.scm b/module/hnh/test/util.scm
index 3d51e162..b0f3342a 100644
--- a/module/hnh/test/util.scm
+++ b/module/hnh/test/util.scm
@@ -48,8 +48,18 @@
)
(define (diff s1 s2)
- (let ((filename1 (call-with-tmpfile (lambda (p f) (pretty-print s1 p display?: #t) f)))
- (filename2 (call-with-tmpfile (lambda (p f) (pretty-print s2 p display?: #t) f))))
+ (let ((filename1 (call-with-tmpfile
+ (lambda (p f)
+ (if (and (string? s1) (string? s2))
+ (display s1 p)
+ (pretty-print s1 p display?: #f))
+ f)))
+ (filename2 (call-with-tmpfile
+ (lambda (p f)
+ (if (and (string? s1) (string? s2))
+ (display s2 p)
+ (pretty-print s2 p display?: #f))
+ f))))
(let ((pipe (apply open-pipe*
OPEN_READ
(append diff-cmd (list filename1 filename2)))))