[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
03/07: store: 'with-store' returns as many values as its body.
From: |
guix-commits |
Subject: |
03/07: store: 'with-store' returns as many values as its body. |
Date: |
Fri, 28 Aug 2020 17:29:33 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit 3d9ea605c8dfb7fc43689e12975218b032b3175a
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Fri Aug 28 15:05:17 2020 +0200
store: 'with-store' returns as many values as its body.
Fixes <https://bugs.gnu.org/42912>.
Reported by Ricardo Wurmus <rekado@elephly.net>.
* guix/store.scm (call-with-store)[thunk]: Wrap call to PROC in
'call-with-values'.
* tests/store.scm ("with-store, multiple values"): New test.
---
guix/store.scm | 7 ++++---
tests/store.scm | 9 +++++++++
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/guix/store.scm b/guix/store.scm
index 683e125..495dc16 100644
--- a/guix/store.scm
+++ b/guix/store.scm
@@ -628,9 +628,10 @@ connection. Use with care."
(define (thunk)
(parameterize ((current-store-protocol-version
(store-connection-version store)))
- (let ((result (proc store)))
- (close-connection store)
- result)))
+ (call-with-values (lambda () (proc store))
+ (lambda results
+ (close-connection store)
+ (apply values results)))))
(cond-expand
(guile-3
diff --git a/tests/store.scm b/tests/store.scm
index ee3e01f..e168d3d 100644
--- a/tests/store.scm
+++ b/tests/store.scm
@@ -141,6 +141,15 @@
(string-append (%store-prefix) "/"
(make-string 32 #\e) "-foobar"))))
+(test-equal "with-store, multiple values" ;<https://bugs.gnu.org/42912>
+ '(1 2 3)
+ (call-with-values
+ (lambda ()
+ (with-store s
+ (add-text-to-store s "foo" "bar")
+ (values 1 2 3)))
+ list))
+
(test-assert "valid-path? error"
(with-store s
(guard (c ((store-protocol-error? c) #t))
- branch master updated (1922811 -> 096f442), guix-commits, 2020/08/28
- 03/07: store: 'with-store' returns as many values as its body.,
guix-commits <=
- 01/07: system: Remove extra line from 'lightweight-desktop.tmpl'., guix-commits, 2020/08/28
- 02/07: doc: Document the 'description' and 'default-value' of <service-type>., guix-commits, 2020/08/28
- 05/07: derivations: Avoid uses of 'display' in 'write-derivation'., guix-commits, 2020/08/28
- 06/07: derivations: Avoid uses of 'write' in 'write-derivation'., guix-commits, 2020/08/28
- 04/07: gnu: chez-srfi: Fix tests., guix-commits, 2020/08/28
- 07/07: gnu: guile-ssh: Update to 0.13.1., guix-commits, 2020/08/28