summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2021-10-28 19:21:50 +0200
committerLudovic Courtès <ludo@gnu.org>2021-10-28 21:30:27 +0200
commit2015d3f042870860efef10e801b93eacc0742d38 (patch)
treee442da4d986eab8a63c8dca758272768e92f9716 /tests
parent45b251fd045fe47dd65d42a269508ee50f26565d (diff)
downloadguix-2015d3f042870860efef10e801b93eacc0742d38.tar.gz
store: 'map/accumulate-builds' handler checks the store received.
This is a followup to b19250eec6f92308f237a09a43e8e3e2355345b9,
providing a proper fix for <https://issues.guix.gnu.org/46756>.

* guix/remote.scm (remote-eval): Revert b19250eec6f92308f237a09a43e8e3e2355345b9.
* guix/store.scm (build-accumulator): Turn into a procedure.  Call
CONTINUE when the store is not eq? to the initial store.
(map/accumulate-builds): Adjust accordingly.
* tests/store.scm ("map/accumulate-builds and different store"): New test.
Diffstat (limited to 'tests')
-rw-r--r--tests/store.scm28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/store.scm b/tests/store.scm
index 95f47c3af3..2150a0048c 100644
--- a/tests/store.scm
+++ b/tests/store.scm
@@ -490,6 +490,34 @@
             (equal? (map derivation-file-name (drop d 16)) batch3)
             lst)))))
 
+(test-equal "map/accumulate-builds and different store"
+  '(d2)                               ;see <https://issues.guix.gnu.org/46756>
+  (let* ((b  (add-text-to-store %store "build" "echo $foo > $out" '()))
+         (s  (add-to-store %store "bash" #t "sha256"
+                           (search-bootstrap-binary "bash"
+                                                    (%current-system))))
+         (d1 (derivation %store "first"
+                         s `("-e" ,b)
+                         #:env-vars `(("foo" . ,(random-text)))
+                         #:sources (list b s)))
+         (d2 (derivation %store "second"
+                         s `("-e" ,b)
+                         #:env-vars `(("foo" . ,(random-text))
+                                      ("bar" . "baz"))
+                         #:sources (list b s))))
+    (with-store alternate-store
+      (with-build-handler (lambda (continue store things mode)
+                            ;; If this handler is called, it means that
+                            ;; 'map/accumulate-builds' triggered a build,
+                            ;; which it shouldn't since the inner
+                            ;; 'build-derivations' call is for another store.
+                            'failed)
+        (map/accumulate-builds %store
+                               (lambda (drv)
+                                 (build-derivations alternate-store (list d2))
+                                 'd2)
+                               (list d1))))))
+
 (test-assert "mapm/accumulate-builds"
   (let* ((d1 (run-with-store %store
                (gexp->derivation "foo" #~(mkdir #$output))))