[functional-tests/thin] Factor out with-empty-metadata

This commit is contained in:
Joe Thornber 2017-08-29 14:55:48 +01:00
parent 33f0c23ca1
commit 12024bf232

View File

@ -42,6 +42,12 @@
(with-temp-file-sized ((md "thin.bin" (meg 4)))
b1 b2 ...))))
(define-syntax with-empty-metadata
(syntax-rules ()
((_ (md) b1 b2 ...)
(with-temp-file-sized ((md "thin.bin" (meg 4)))
b1 b2 ...))))
;; We have to export something that forces all the initialisation expressions
;; to run.
(define (register-thin-tests) #t)
@ -132,13 +138,13 @@
(define-scenario (thin-restore no-input-file)
"forget to specify an input file"
(with-temp-file-sized ((md "thin.bin" (meg 4)))
(with-empty-metadata (md)
(receive (_ stderr) (run-fail "thin_restore" "-o" md)
(assert-starts-with "No input file provided." stderr))))
(define-scenario (thin-restore missing-input-file)
"the input file can't be found"
(with-temp-file-sized ((md "thin.bin" (meg 4)))
(with-empty-metadata (md)
(receive (_ stderr) (run-fail "thin_restore -i no-such-file -o" md)
(assert-starts-with "Couldn't stat file" stderr))))
@ -150,21 +156,21 @@
(define-scenario (thin-restore tiny-output-file)
"Fails if the output file is too small."
(with-temp-file-sized ((md "thin.bin" (* 1024 4)))
(with-temp-file-sized ((md "thin.bin" 4096))
(with-thin-xml (xml)
(receive (_ stderr) (run-fail "thin_restore" "-i" xml "-o" md)
(assert-starts-with thin-restore-outfile-too-small-text stderr)))))
(define-scenario (thin-restore q)
"thin_restore accepts -q"
(with-temp-file-sized ((md "thin.bin" (meg 4)))
(with-empty-metadata (md)
(with-thin-xml (xml)
(receive (stdout _) (thin-restore "-i" xml "-o" md "-q")
(assert-eof stdout)))))
(define-scenario (thin-restore quiet)
"thin_restore accepts --quiet"
(with-temp-file-sized ((md "thin.bin" (meg 4)))
(with-empty-metadata (md)
(with-thin-xml (xml)
(receive (stdout _) (thin-restore "-i" xml "-o" md "--quiet")
(assert-eof stdout)))))