tests: Don't hard-code the system type.

* tests/derivations.scm (%current-system): New variable.  Replace
  occurrences of "x86_64-linux" by %CURRENT-SYSTEM.
master
Ludovic Courtès 2012-06-10 15:34:46 +02:00
parent 9bc07f4df0
commit 81095052a8
1 changed files with 13 additions and 9 deletions

View File

@ -28,6 +28,10 @@
#:use-module (rnrs bytevectors) #:use-module (rnrs bytevectors)
#:use-module (ice-9 rdelim)) #:use-module (ice-9 rdelim))
(define %current-system
;; System type as expected by Nix, usually ARCHITECTURE-KERNEL.
"x86_64-linux")
(define %store (define %store
(false-if-exception (open-connection))) (false-if-exception (open-connection)))
@ -48,7 +52,7 @@
(let ((builder (add-text-to-store %store "my-builder.sh" (let ((builder (add-text-to-store %store "my-builder.sh"
"#!/bin/sh\necho hello, world\n" "#!/bin/sh\necho hello, world\n"
'()))) '())))
(store-path? (derivation %store "foo" "x86_64-linux" builder (store-path? (derivation %store "foo" %current-system builder
'() '(("HOME" . "/homeless")) '())))) '() '(("HOME" . "/homeless")) '()))))
(test-assert "build derivation with 1 source" (test-assert "build derivation with 1 source"
@ -57,7 +61,7 @@
"echo hello, world > \"$out\"\n" "echo hello, world > \"$out\"\n"
'())) '()))
((drv-path drv) ((drv-path drv)
(derivation %store "foo" "x86_64-linux" (derivation %store "foo" %current-system
"/bin/sh" `(,builder) "/bin/sh" `(,builder)
'(("HOME" . "/homeless") '(("HOME" . "/homeless")
("zzz" . "Z!") ("zzz" . "Z!")
@ -75,7 +79,7 @@
(let* ((builder (add-text-to-store %store "my-fixed-builder.sh" (let* ((builder (add-text-to-store %store "my-fixed-builder.sh"
"echo -n hello > $out" '())) "echo -n hello > $out" '()))
(hash (sha256 (string->utf8 "hello"))) (hash (sha256 (string->utf8 "hello")))
(drv-path (derivation %store "fixed" "x86_64-linux" (drv-path (derivation %store "fixed" %current-system
"/bin/sh" `(,builder) "/bin/sh" `(,builder)
'() `((,builder)) '() `((,builder))
#:hash hash #:hash-algo 'sha256)) #:hash hash #:hash-algo 'sha256))
@ -89,7 +93,7 @@
(let* ((builder (add-text-to-store %store "my-fixed-builder.sh" (let* ((builder (add-text-to-store %store "my-fixed-builder.sh"
"echo one > $out ; echo two > $second" "echo one > $out ; echo two > $second"
'())) '()))
(drv-path (derivation %store "fixed" "x86_64-linux" (drv-path (derivation %store "fixed" %current-system
"/bin/sh" `(,builder) "/bin/sh" `(,builder)
'(("HOME" . "/homeless") '(("HOME" . "/homeless")
("zzz" . "Z!") ("zzz" . "Z!")
@ -115,7 +119,7 @@
"echo $PATH ; mkdir --version ; mkdir $out ; touch $out/good" "echo $PATH ; mkdir --version ; mkdir $out ; touch $out/good"
'())) '()))
(drv-path (drv-path
(derivation %store "foo" "x86_64-linux" (derivation %store "foo" %current-system
"/bin/sh" `(,builder) "/bin/sh" `(,builder)
`(("PATH" . `(("PATH" .
,(string-append ,(string-append
@ -137,7 +141,7 @@
(call-with-output-file (string-append %output "/test") (call-with-output-file (string-append %output "/test")
(lambda (p) (lambda (p)
(display '(hello guix) p))))) (display '(hello guix) p)))))
(drv-path (build-expression->derivation %store "goo" "x86_64-linux" (drv-path (build-expression->derivation %store "goo" %current-system
builder '())) builder '()))
(succeeded? (build-derivations %store (list drv-path)))) (succeeded? (build-derivations %store (list drv-path))))
(and succeeded? (and succeeded?
@ -154,7 +158,7 @@
(lambda (p) (lambda (p)
(display '(world) p))))) (display '(world) p)))))
(drv-path (build-expression->derivation %store "double" (drv-path (build-expression->derivation %store "double"
"x86_64-linux" %current-system
builder '() builder '()
#:outputs '("out" #:outputs '("out"
"second"))) "second")))
@ -173,7 +177,7 @@
(dup2 (port->fdes p) 1) (dup2 (port->fdes p) 1)
(execl (string-append cu "/bin/uname") (execl (string-append cu "/bin/uname")
"uname" "-a"))))) "uname" "-a")))))
(drv-path (build-expression->derivation %store "uname" "x86_64-linux" (drv-path (build-expression->derivation %store "uname" %current-system
builder builder
`(("cu" . ,%coreutils)))) `(("cu" . ,%coreutils))))
(succeeded? (build-derivations %store (list drv-path)))) (succeeded? (build-derivations %store (list drv-path))))
@ -196,7 +200,7 @@
(lambda (p) (lambda (p)
(put-bytevector p bv)))))) (put-bytevector p bv))))))
(drv-path (build-expression->derivation (drv-path (build-expression->derivation
%store "hello-2.8.tar.gz" "x86_64-linux" builder '() %store "hello-2.8.tar.gz" %current-system builder '()
#:hash (nix-base32-string->bytevector #:hash (nix-base32-string->bytevector
"0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6") "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6")
#:hash-algo 'sha256)) #:hash-algo 'sha256))