diff --git a/functional-tests/era-functional-tests.scm b/functional-tests/era-functional-tests.scm index 161fda9..1e21c35 100644 --- a/functional-tests/era-functional-tests.scm +++ b/functional-tests/era-functional-tests.scm @@ -25,9 +25,9 @@ (syntax-rules () ((_ (md) b1 b2 ...) (with-temp-file-sized ((md "era.bin" (meg 4))) - (with-cache-xml (xml) - (era-restore "-i" xml "-o" md) - b1 b2 ...))))) + (with-era-xml (xml) + (era-restore "-i" xml "-o" md) + b1 b2 ...))))) (define-syntax with-corrupt-metadata (syntax-rules () @@ -106,4 +106,86 @@ (receive (stdout stderr) (run-fail "era_check -q" md) (assert-eof stdout) (assert-eof stderr)))) + + ;;;----------------------------------------------------------- + ;;; era_restore scenarios + ;;;----------------------------------------------------------- + (define-scenario (era-restore v) + "era_restore -V" + (receive (stdout _) (era-restore "-V") + (assert-equal tools-version stdout))) + + (define-scenario (era-restore version) + "era_restore --version" + (receive (stdout _) (era-restore "--version") + (assert-equal tools-version stdout))) + + (define-scenario (era-restore h) + "era_restore -h" + (receive (stdout _) (era-restore "-h") + (assert-equal era-restore-help stdout))) + + (define-scenario (era-restore help) + "era_restore --help" + (receive (stdout _) (era-restore "--help") + (assert-equal era-restore-help stdout))) + + (define-scenario (era-restore input-unspecified) + "Fails if no xml specified" + (with-empty-metadata (md) + (receive (_ stderr) (run-fail "era_restore" "-o" md) + (assert-starts-with "No input file provided." stderr)))) + + (define-scenario (era-restore output-unspecified) + "Fails if no metadata dev specified" + (with-era-xml (xml) + (receive (_ stderr) (run-fail "era_restore" "-i" xml) + (assert-starts-with "No output file provided." stderr)))) + + (define-scenario (era-restore success) + "Succeeds with xml and metadata" + (with-era-xml (xml) + (with-empty-metadata (md) + (era-restore "-i" xml "-o" md)))) + + (define-scenario (era-restore quiet) + "No output with --quiet (succeeding)" + (with-era-xml (xml) + (with-empty-metadata (md) + (receive (stdout stderr) (era-restore "--quiet" "-i" xml "-o" md) + (assert-eof stdout) + (assert-eof stderr))))) + + (define-scenario (era-restore q) + "No output with -q (succeeding)" + (with-era-xml (xml) + (with-empty-metadata (md) + (receive (stdout stderr) (era-restore "-q" "-i" xml "-o" md) + (assert-eof stdout) + (assert-eof stderr))))) + + (define-scenario (era-restore quiet-fail) + "No output with --quiet (failing)" + (with-temp-file ((bad-xml "era.xml")) + (with-empty-metadata (md) + (receive (stdout stderr) (run-fail "era_restore" "--quiet" "-i" bad-xml "-o" md) + (assert-eof stdout) + (assert-eof stderr))))) + + (define-scenario (era-restore q-fail) + "No output with --q(failing)" + (with-temp-file ((bad-xml "era.xml")) + (with-empty-metadata (md) + (receive (stdout stderr) (run-fail "era_restore" "-q" "-i" bad-xml "-o" md) + (assert-eof stdout) + (assert-eof stderr))))) + + (define-scenario (era-dump restore-is-noop) + "era_dump followed by era_restore is a noop." + (with-valid-metadata (md) + (receive (d1-stdout _) (era-dump md) + (with-temp-file-containing ((xml "era.xml" d1-stdout)) + (era-restore "-i" xml "-o" md) + (receive (d2-stdout _) (era-dump md) + (assert-equal d1-stdout d2-stdout)))))) ) diff --git a/functional-tests/scenario-string-constants.scm b/functional-tests/scenario-string-constants.scm index dad0ca2..eb8e352 100644 --- a/functional-tests/scenario-string-constants.scm +++ b/functional-tests/scenario-string-constants.scm @@ -14,6 +14,7 @@ cache-metadata-size-help era-check-help + era-restore-help ) (import (rnrs)) @@ -126,4 +127,13 @@ Options: {-h|--help} {-V|--version} {--super-block-only}") + + (define era-restore-help + "Usage: era_restore [options] +Options: + {-h|--help} + {-i|--input} + {-o|--output} + {-q|--quiet} + {-V|--version}") )