tests: Use 'with-store' as appropriate.
* tests/store.scm ("no substitutes", "substitute query", "substitute", "substitute, corrupt output hash", "substitute --fallback"): Use 'with-store' instead of 'open-connection'.
This commit is contained in:
parent
1af50c224d
commit
2d53df66de
1 changed files with 168 additions and 168 deletions
|
@ -296,21 +296,21 @@
|
||||||
(log-file %store o)))))
|
(log-file %store o)))))
|
||||||
|
|
||||||
(test-assert "no substitutes"
|
(test-assert "no substitutes"
|
||||||
(let* ((s (open-connection))
|
(with-store s
|
||||||
(d1 (package-derivation s %bootstrap-guile (%current-system)))
|
(let* ((d1 (package-derivation s %bootstrap-guile (%current-system)))
|
||||||
(d2 (package-derivation s %bootstrap-glibc (%current-system)))
|
(d2 (package-derivation s %bootstrap-glibc (%current-system)))
|
||||||
(o (map derivation->output-path (list d1 d2))))
|
(o (map derivation->output-path (list d1 d2))))
|
||||||
(set-build-options s #:use-substitutes? #f)
|
(set-build-options s #:use-substitutes? #f)
|
||||||
(and (not (has-substitutes? s (derivation-file-name d1)))
|
(and (not (has-substitutes? s (derivation-file-name d1)))
|
||||||
(not (has-substitutes? s (derivation-file-name d2)))
|
(not (has-substitutes? s (derivation-file-name d2)))
|
||||||
(null? (substitutable-paths s o))
|
(null? (substitutable-paths s o))
|
||||||
(null? (substitutable-path-info s o)))))
|
(null? (substitutable-path-info s o))))))
|
||||||
|
|
||||||
(test-skip (if (getenv "GUIX_BINARY_SUBSTITUTE_URL") 0 1))
|
(test-skip (if (getenv "GUIX_BINARY_SUBSTITUTE_URL") 0 1))
|
||||||
|
|
||||||
(test-assert "substitute query"
|
(test-assert "substitute query"
|
||||||
(let* ((s (open-connection))
|
(with-store s
|
||||||
(d (package-derivation s %bootstrap-guile (%current-system)))
|
(let* ((d (package-derivation s %bootstrap-guile (%current-system)))
|
||||||
(o (derivation->output-path d))
|
(o (derivation->output-path d))
|
||||||
(dir (and=> (getenv "GUIX_BINARY_SUBSTITUTE_URL")
|
(dir (and=> (getenv "GUIX_BINARY_SUBSTITUTE_URL")
|
||||||
(compose uri-path string->uri))))
|
(compose uri-path string->uri))))
|
||||||
|
@ -349,11 +349,11 @@ Deriver: ~a~%"
|
||||||
(((? substitutable? s))
|
(((? substitutable? s))
|
||||||
(and (string=? (substitutable-deriver s) (derivation-file-name d))
|
(and (string=? (substitutable-deriver s) (derivation-file-name d))
|
||||||
(null? (substitutable-references s))
|
(null? (substitutable-references s))
|
||||||
(equal? (substitutable-nar-size s) 1234)))))))
|
(equal? (substitutable-nar-size s) 1234))))))))
|
||||||
|
|
||||||
(test-assert "substitute"
|
(test-assert "substitute"
|
||||||
(let* ((s (open-connection))
|
(with-store s
|
||||||
(c (random-text)) ; contents of the output
|
(let* ((c (random-text)) ; contents of the output
|
||||||
(d (build-expression->derivation
|
(d (build-expression->derivation
|
||||||
s "substitute-me"
|
s "substitute-me"
|
||||||
`(call-with-output-file %output
|
`(call-with-output-file %output
|
||||||
|
@ -400,14 +400,14 @@ Deriver: ~a~%"
|
||||||
(set-build-options s #:use-substitutes? #t)
|
(set-build-options s #:use-substitutes? #t)
|
||||||
(and (has-substitutes? s o)
|
(and (has-substitutes? s o)
|
||||||
(build-derivations s (list d))
|
(build-derivations s (list d))
|
||||||
(equal? c (call-with-input-file o get-string-all)))))
|
(equal? c (call-with-input-file o get-string-all))))))
|
||||||
|
|
||||||
(test-assert "substitute, corrupt output hash"
|
(test-assert "substitute, corrupt output hash"
|
||||||
;; Tweak the substituter into installing a substitute whose hash doesn't
|
;; Tweak the substituter into installing a substitute whose hash doesn't
|
||||||
;; match the one announced in the narinfo. The daemon must notice this and
|
;; match the one announced in the narinfo. The daemon must notice this and
|
||||||
;; raise an error.
|
;; raise an error.
|
||||||
(let* ((s (open-connection))
|
(with-store s
|
||||||
(c "hello, world") ; contents of the output
|
(let* ((c "hello, world") ; contents of the output
|
||||||
(d (build-expression->derivation
|
(d (build-expression->derivation
|
||||||
s "corrupt-substitute"
|
s "corrupt-substitute"
|
||||||
`(mkdir %output)
|
`(mkdir %output)
|
||||||
|
@ -458,11 +458,11 @@ Deriver: ~a~%"
|
||||||
(pk 'corrupt c)
|
(pk 'corrupt c)
|
||||||
(not (zero? (nix-protocol-error-status c)))))
|
(not (zero? (nix-protocol-error-status c)))))
|
||||||
(build-derivations s (list d))
|
(build-derivations s (list d))
|
||||||
#f))))
|
#f)))))
|
||||||
|
|
||||||
(test-assert "substitute --fallback"
|
(test-assert "substitute --fallback"
|
||||||
(let* ((s (open-connection))
|
(with-store s
|
||||||
(t (random-text)) ; contents of the output
|
(let* ((t (random-text)) ; contents of the output
|
||||||
(d (build-expression->derivation
|
(d (build-expression->derivation
|
||||||
s "substitute-me-not"
|
s "substitute-me-not"
|
||||||
`(call-with-output-file %output
|
`(call-with-output-file %output
|
||||||
|
@ -508,7 +508,7 @@ Deriver: ~a~%"
|
||||||
(equal? t (call-with-input-file o get-string-all)))))
|
(equal? t (call-with-input-file o get-string-all)))))
|
||||||
;; Should fail.
|
;; Should fail.
|
||||||
(build-derivations s (list d))
|
(build-derivations s (list d))
|
||||||
#f))))
|
#f)))))
|
||||||
|
|
||||||
(test-assert "export/import several paths"
|
(test-assert "export/import several paths"
|
||||||
(let* ((texts (unfold (cut >= <> 10)
|
(let* ((texts (unfold (cut >= <> 10)
|
||||||
|
|
Reference in a new issue