all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: 45460@debbugs.gnu.org
Subject: [bug#45460] [PATCH 1/5] utils: Remove 'compressed-output-port'.
Date: Sun, 27 Dec 2020 15:38:05 +0100	[thread overview]
Message-ID: <20201227143809.18554-1-ludo@gnu.org> (raw)
In-Reply-To: <20201227141327.10827-1-ludo@gnu.org>

This procedure was unused except in one test.

* guix/utils.scm (compressed-port): Remove.
* tests/utils.scm (test-compression/decompression): Rewrite to use
'compressed-output-port' instead.
---
 guix/utils.scm  | 13 -------------
 tests/utils.scm | 43 +++++++++++++++++++++++++++++--------------
 2 files changed, 29 insertions(+), 27 deletions(-)

diff --git a/guix/utils.scm b/guix/utils.scm
index a591b62f30..e3c78959ed 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -109,7 +109,6 @@
             edit-expression
 
             filtered-port
-            compressed-port
             decompressed-port
             call-with-decompressed-port
             compressed-output-port
@@ -224,18 +223,6 @@ a symbol such as 'xz."
                            '()))
     (_             (error "unsupported compression scheme" compression))))
 
-(define (compressed-port compression input)
-  "Return an input port where INPUT is compressed according to COMPRESSION,
-a symbol such as 'xz."
-  (match compression
-    ((or #f 'none) (values input '()))
-    ('bzip2        (filtered-port `(,%bzip2 "-c") input))
-    ('xz           (filtered-port `(,%xz "-c") input))
-    ('gzip         (filtered-port `(,%gzip "-c") input))
-    ('lzip         (values (lzip-port 'make-lzip-input-port/compressed input)
-                           '()))
-    (_             (error "unsupported compression scheme" compression))))
-
 (define (call-with-decompressed-port compression port proc)
   "Call PROC with a wrapper around PORT, a file port, that decompresses data
 read from PORT according to COMPRESSION, a symbol such as 'xz."
diff --git a/tests/utils.scm b/tests/utils.scm
index 009e2121ab..c278b2a277 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
 ;;; Copyright © 2016 Mathieu Lirzin <mthl@gnu.org>
 ;;;
@@ -182,19 +182,34 @@ skip these tests."
                        method)
     (let ((data (call-with-input-file (search-path %load-path "guix.scm")
                   get-bytevector-all)))
-      (let*-values (((compressed pids1)
-                     (compressed-port method (open-bytevector-input-port data)))
-                    ((decompressed pids2)
-                     (decompressed-port method compressed)))
-        (and (every (compose zero? cdr waitpid)
-                    (pk 'pids method (append pids1 pids2)))
-             (let ((result (get-bytevector-all decompressed)))
-               (pk 'len method
-                   (if (bytevector? result)
-                       (bytevector-length result)
-                       result)
-                   (bytevector-length data))
-               (equal? result data))))))
+      (call-with-temporary-output-file
+       (lambda (output port)
+         (close-port port)
+         (let*-values (((compressed pids)
+                        ;; Note: 'compressed-output-port' only supports file
+                        ;; ports.
+                        (compressed-output-port method
+                                                (open-file output "w0"))))
+           (put-bytevector compressed data)
+           (close-port compressed)
+           (and (every (compose zero? cdr waitpid)
+                       (pk 'pids method pids))
+                (let*-values (((decompressed pids)
+                               (decompressed-port method
+                                                  (open-bytevector-input-port
+                                                   (call-with-input-file output
+                                                     get-bytevector-all))))
+                              ((result)
+                               (get-bytevector-all decompressed)))
+                  (close-port decompressed)
+                  (pk 'len method
+                      (if (bytevector? result)
+                          (bytevector-length result)
+                          result)
+                      (bytevector-length data))
+                  (and (every (compose zero? cdr waitpid)
+                              (pk 'pids method pids))
+                       (equal? result data)))))))))
 
   (false-if-exception (delete-file temp-file))
   (unless (run?) (test-skip 1))
-- 
2.29.2





  reply	other threads:[~2020-12-27 14:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-27 14:13 [bug#45460] [PATCH 0/5] Zstd support for 'guix publish' and 'guix substitute' Ludovic Courtès
2020-12-27 14:38 ` Ludovic Courtès [this message]
2020-12-27 14:38   ` [bug#45460] [PATCH 2/5] utils: Support zstd compression via Guile-zstd Ludovic Courtès
2020-12-27 14:38   ` [bug#45460] [PATCH 3/5] publish: Add support for zstd compression Ludovic Courtès
2020-12-28  9:17     ` Jonathan Brielmaier
2021-01-03 15:18       ` Ludovic Courtès
2020-12-27 14:38   ` [bug#45460] [PATCH 4/5] substitute: Add zstd support Ludovic Courtès
2020-12-27 14:38   ` [bug#45460] [PATCH 5/5] doc: Mention optional dependency on Guile-zstd Ludovic Courtès
2020-12-30  9:30 ` [bug#45460] [PATCH 0/5] Zstd support for 'guix publish' and 'guix substitute' Mathieu Othacehe
2021-01-03 15:17   ` Ludovic Courtès
2021-01-13 22:08   ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201227143809.18554-1-ludo@gnu.org \
    --to=ludo@gnu.org \
    --cc=45460@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.