diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2020-04-04 17:36:31 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2020-04-04 18:52:35 +0200 |
| commit | 8ed597f4a261fe188de82cd1f5daed83dba948eb (patch) | |
| tree | 11a5d45ad494bf6d0244fd3248664c536e9fa333 /tests | |
| parent | d8c8bfcc1f7c2e8226abebc6227261c8617f90d0 (diff) | |
store: 'with-store' doesn't close the store upon abort.
Fixes <https://bugs.gnu.org/40428>.
Reported by Marius Bakke <mbakke@fastmail.com> and 白い熊.
Regression introduced with the first uses of 'with-build-handler' in
commit 62195b9a8fd6846117c5d7698842748300d13e31 and subsequent.
* guix/store.scm (call-with-store): Use 'catch #t' instead of
'dynamic-wind'. This ensures STORE remains open when a non-local exit
other than an exception occurs, such as an abort to the build handler
prompt.
* tests/store.scm ("with-build-handler + with-store"): New test.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/store.scm | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/store.scm b/tests/store.scm index 0458a347465..0e80ccc2393 100644 --- a/tests/store.scm +++ b/tests/store.scm | |||
| @@ -412,6 +412,33 @@ | |||
| 412 | (build-derivations %store (list d2)) | 412 | (build-derivations %store (list d2)) |
| 413 | 'fail))) | 413 | 'fail))) |
| 414 | 414 | ||
| 415 | (test-equal "with-build-handler + with-store" | ||
| 416 | 'success | ||
| 417 | ;; Check that STORE remains valid when the build handler invokes CONTINUE, | ||
| 418 | ;; even though 'with-build-handler' is outside the dynamic extent of | ||
| 419 | ;; 'with-store'. | ||
| 420 | (with-build-handler (lambda (continue store things mode) | ||
| 421 | (match things | ||
| 422 | ((drv) | ||
| 423 | (and (string-suffix? "thingie.drv" drv) | ||
| 424 | (not (port-closed? | ||
| 425 | (store-connection-socket store))) | ||
| 426 | (continue #t))))) | ||
| 427 | (with-store store | ||
| 428 | (let* ((b (add-text-to-store store "build" "echo $foo > $out" '())) | ||
| 429 | (s (add-to-store store "bash" #t "sha256" | ||
| 430 | (search-bootstrap-binary "bash" | ||
| 431 | (%current-system)))) | ||
| 432 | (d (derivation store "thingie" | ||
| 433 | s `("-e" ,b) | ||
| 434 | #:env-vars `(("foo" . ,(random-text))) | ||
| 435 | #:sources (list b s)))) | ||
| 436 | (build-derivations store (list d)) | ||
| 437 | |||
| 438 | ;; Here STORE's socket should still be open. | ||
| 439 | (and (valid-path? store (derivation->output-path d)) | ||
| 440 | 'success))))) | ||
| 441 | |||
| 415 | (test-assert "map/accumulate-builds" | 442 | (test-assert "map/accumulate-builds" |
| 416 | (let* ((b (add-text-to-store %store "build" "echo $foo > $out" '())) | 443 | (let* ((b (add-text-to-store %store "build" "echo $foo > $out" '())) |
| 417 | (s (add-to-store %store "bash" #t "sha256" | 444 | (s (add-to-store %store "bash" #t "sha256" |
