From 12024bf23260f872b873cd91ae0f89bcf0c676b2 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Tue, 29 Aug 2017 14:55:48 +0100 Subject: [PATCH] [functional-tests/thin] Factor out with-empty-metadata --- functional-tests/thin-functional-tests.scm | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/functional-tests/thin-functional-tests.scm b/functional-tests/thin-functional-tests.scm index 75c76f4..8767391 100644 --- a/functional-tests/thin-functional-tests.scm +++ b/functional-tests/thin-functional-tests.scm @@ -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)))))