diff options
author | Ludovic Courtès <ludo@gnu.org> | 2013-04-29 23:25:19 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2013-04-29 23:25:19 +0200 |
commit | e0fbbc889d724678e9e310432ad3a3fb8345cf9a (patch) | |
tree | d8a2fdc62f16c285e24d40c041ae80b0247ccab8 /tests | |
parent | dab5d51be739d23d8ce98f15d195c8e3c91bbd7e (diff) | |
download | guix-e0fbbc889d724678e9e310432ad3a3fb8345cf9a.tar guix-e0fbbc889d724678e9e310432ad3a3fb8345cf9a.tar.gz |
substitute-binary: Support decompression from non-file ports.
* guix/scripts/substitute-binary.scm (filtered-port): Move to utils.scm.
(decompressed-port): Upon "none", return '() as the second value.
(guix-substitute-binary): Expect `decompressed-port' to return a list
of PIDs as its second value.
* guix/utils.scm (filtered-port): New procedure. Add case for when
INPUT is not `file-port?'.
* tests/utils.scm ("filtered-port, file", "filtered-port, non-file"):
New tests.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/utils.scm | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/utils.scm b/tests/utils.scm index fa7d7b03fd..2fc8eaec12 100644 --- a/tests/utils.scm +++ b/tests/utils.scm @@ -17,12 +17,14 @@ ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. (define-module (test-utils) + #:use-module ((guix config) #:select (%gzip)) #:use-module (guix utils) #:use-module ((guix store) #:select (%store-prefix store-path-package-name)) #:use-module (srfi srfi-1) #:use-module (srfi srfi-11) #:use-module (srfi srfi-64) #:use-module (rnrs bytevectors) + #:use-module (rnrs io ports) #:use-module (ice-9 match)) (test-begin "utils") @@ -89,6 +91,31 @@ '(0 1 2 3))) list)) +(test-assert "filtered-port, file" + (let ((file (search-path %load-path "guix.scm"))) + (call-with-input-file file + (lambda (input) + (let*-values (((compressed pids1) + (filtered-port `(,%gzip "-c" "--fast") input)) + ((decompressed pids2) + (filtered-port `(,%gzip "-d") compressed))) + (and (every (compose zero? cdr waitpid) + (append pids1 pids2)) + (equal? (get-bytevector-all decompressed) + (call-with-input-file file get-bytevector-all)))))))) + +(test-assert "filtered-port, non-file" + (let ((data (call-with-input-file (search-path %load-path "guix.scm") + get-bytevector-all))) + (let*-values (((compressed pids1) + (filtered-port `(,%gzip "-c" "--fast") + (open-bytevector-input-port data))) + ((decompressed pids2) + (filtered-port `(,%gzip "-d") compressed))) + (and (pk (every (compose zero? cdr waitpid) + (append pids1 pids2))) + (equal? (get-bytevector-all decompressed) data))))) + (test-assert "define-record-type*" (begin (define-record-type* <foo> foo make-foo |